comparison rdt.c @ 4096:233ba738a68e libavformat

Don't access RMContext directly in rdt.c. Rather, use the return value of ff_rm_parse_packet() to indicate whether more audio packets are available in the demuxer from the last RM frame, and save that in the RDT parsing context. See patch/discussion in "[PATCH] rdt.c: don't access RMContext" on ML.
author rbultje
date Sat, 13 Dec 2008 21:37:27 +0000
parents 8adccfc01be3
children 90a12fced519
comparison
equal deleted inserted replaced
4095:27f4b31bc790 4096:233ba738a68e
82 struct PayloadContext { 82 struct PayloadContext {
83 AVFormatContext *rmctx; 83 AVFormatContext *rmctx;
84 uint8_t *mlti_data; 84 uint8_t *mlti_data;
85 unsigned int mlti_data_size; 85 unsigned int mlti_data_size;
86 char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE]; 86 char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE];
87 int audio_pkt_cnt[MAX_STREAMS]; /**< remaining audio packets in rmdec */
87 }; 88 };
88 89
89 void 90 void
90 ff_rdt_calc_response_and_checksum(char response[41], char chksum[9], 91 ff_rdt_calc_response_and_checksum(char response[41], char chksum[9],
91 const char *challenge) 92 const char *challenge)
292 AVPacket *pkt, uint32_t *timestamp, 293 AVPacket *pkt, uint32_t *timestamp,
293 const uint8_t *buf, int len, int flags) 294 const uint8_t *buf, int len, int flags)
294 { 295 {
295 int seq = 1, res; 296 int seq = 1, res;
296 ByteIOContext pb; 297 ByteIOContext pb;
297 RMContext *rm = rdt->rmctx->priv_data; 298
298 299 if (rdt->audio_pkt_cnt == 0) {
299 if (rm->audio_pkt_cnt == 0) {
300 int pos; 300 int pos;
301 301
302 init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL); 302 init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
303 flags = (flags & PKT_FLAG_KEY) ? 2 : 0; 303 flags = (flags & PKT_FLAG_KEY) ? 2 : 0;
304 res = ff_rm_parse_packet (rdt->rmctx, &pb, st, len, pkt, 304 res = ff_rm_parse_packet (rdt->rmctx, &pb, st, len, pkt,
305 &seq, &flags, timestamp); 305 &seq, &flags, timestamp);
306 pos = url_ftell(&pb); 306 pos = url_ftell(&pb);
307 if (res < 0) 307 if (res < 0)
308 return res; 308 return res;
309 if (rm->audio_pkt_cnt > 0 && 309 rdt->audio_pkt_cnt[st->id] = res;
310 if (rdt->audio_pkt_cnt[st->id] > 0 &&
310 st->codec->codec_id == CODEC_ID_AAC) { 311 st->codec->codec_id == CODEC_ID_AAC) {
311 memcpy (rdt->buffer, buf + pos, len - pos); 312 memcpy (rdt->buffer, buf + pos, len - pos);
312 rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0, 313 rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
313 NULL, NULL, NULL, NULL); 314 NULL, NULL, NULL, NULL);
314 } 315 }
315 } else { 316 } else {
316 ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, pkt); 317 ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, pkt);
317 if (rm->audio_pkt_cnt == 0 && 318 if (rdt->audio_pkt_cnt[st->id] == 0 &&
318 st->codec->codec_id == CODEC_ID_AAC) 319 st->codec->codec_id == CODEC_ID_AAC)
319 av_freep(&rdt->rmctx->pb); 320 av_freep(&rdt->rmctx->pb);
320 } 321 }
321 pkt->stream_index = st->index; 322 pkt->stream_index = st->index;
322 pkt->pts = *timestamp; 323 pkt->pts = *timestamp;
323 324
324 return rm->audio_pkt_cnt > 0; 325 return rdt->audio_pkt_cnt[st->id] > 0;
325 } 326 }
326 327
327 int 328 int
328 ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt, 329 ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt,
329 const uint8_t *buf, int len) 330 const uint8_t *buf, int len)