Commit a15ebf34 authored by Ronald S. Bultje's avatar Ronald S. Bultje

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.

Originally committed as revision 16110 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 616deed2
...@@ -84,6 +84,7 @@ struct PayloadContext { ...@@ -84,6 +84,7 @@ struct PayloadContext {
uint8_t *mlti_data; uint8_t *mlti_data;
unsigned int mlti_data_size; unsigned int mlti_data_size;
char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE]; char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE];
int audio_pkt_cnt[MAX_STREAMS]; /**< remaining audio packets in rmdec */
}; };
void void
...@@ -294,9 +295,8 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st, ...@@ -294,9 +295,8 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st,
{ {
int seq = 1, res; int seq = 1, res;
ByteIOContext pb; ByteIOContext pb;
RMContext *rm = rdt->rmctx->priv_data;
if (rm->audio_pkt_cnt == 0) { if (rdt->audio_pkt_cnt == 0) {
int pos; int pos;
init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL); init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
...@@ -306,7 +306,8 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st, ...@@ -306,7 +306,8 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st,
pos = url_ftell(&pb); pos = url_ftell(&pb);
if (res < 0) if (res < 0)
return res; return res;
if (rm->audio_pkt_cnt > 0 && rdt->audio_pkt_cnt[st->id] = res;
if (rdt->audio_pkt_cnt[st->id] > 0 &&
st->codec->codec_id == CODEC_ID_AAC) { st->codec->codec_id == CODEC_ID_AAC) {
memcpy (rdt->buffer, buf + pos, len - pos); memcpy (rdt->buffer, buf + pos, len - pos);
rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0, rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
...@@ -314,14 +315,14 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st, ...@@ -314,14 +315,14 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st,
} }
} else { } else {
ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, pkt); ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, pkt);
if (rm->audio_pkt_cnt == 0 && if (rdt->audio_pkt_cnt[st->id] == 0 &&
st->codec->codec_id == CODEC_ID_AAC) st->codec->codec_id == CODEC_ID_AAC)
av_freep(&rdt->rmctx->pb); av_freep(&rdt->rmctx->pb);
} }
pkt->stream_index = st->index; pkt->stream_index = st->index;
pkt->pts = *timestamp; pkt->pts = *timestamp;
return rm->audio_pkt_cnt > 0; return rdt->audio_pkt_cnt[st->id] > 0;
} }
int int
......
...@@ -93,7 +93,9 @@ int ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb, ...@@ -93,7 +93,9 @@ int ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
* @param flags pointer to an integer containing the packet flags, may be * @param flags pointer to an integer containing the packet flags, may be
updated updated
* @param ts pointer to timestamp, may be updated * @param ts pointer to timestamp, may be updated
* @return 0 on success, errno codes on error * @return >=0 on success (where >0 indicates there are cached samples that
* can be retrieved with subsequent calls to ff_rm_retrieve_cache()),
* errno codes on error
*/ */
int ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb, int ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
AVStream *st, int len, AVStream *st, int len,
......
...@@ -644,7 +644,7 @@ ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb, ...@@ -644,7 +644,7 @@ ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
if (*flags & 2) if (*flags & 2)
pkt->flags |= PKT_FLAG_KEY; pkt->flags |= PKT_FLAG_KEY;
return 0; return st->codec->codec_type == CODEC_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment