mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Add RMStream object as function argument to public functions so that non-.rm
AVStreams can be used to call these public rmdec.c functions as well, as is the case for RDT/RTSP streams. See mailinglist discussion in "[PATCH] rdt.c: don't reuse the same AVStream in both RTSP and RM demuxer" thread. Originally committed as revision 16366 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
ba61472911
commit
886e89d0d0
@ -81,6 +81,7 @@ ff_rdt_parse_close(RDTDemuxContext *s)
|
||||
|
||||
struct PayloadContext {
|
||||
AVFormatContext *rmctx;
|
||||
RMStream *rmst[MAX_STREAMS];
|
||||
uint8_t *mlti_data;
|
||||
unsigned int mlti_data_size;
|
||||
char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE];
|
||||
@ -174,7 +175,7 @@ rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr)
|
||||
size = rdt->mlti_data_size;
|
||||
url_fseek(&pb, 0, SEEK_SET);
|
||||
}
|
||||
if (ff_rm_read_mdpr_codecdata(rdt->rmctx, &pb, st, size) < 0)
|
||||
if (ff_rm_read_mdpr_codecdata(rdt->rmctx, &pb, st, rdt->rmst[0], size) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -301,7 +302,7 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st,
|
||||
|
||||
init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
|
||||
flags = (flags & PKT_FLAG_KEY) ? 2 : 0;
|
||||
res = ff_rm_parse_packet (rdt->rmctx, &pb, st, len, pkt,
|
||||
res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[0], len, pkt,
|
||||
&seq, &flags, timestamp);
|
||||
pos = url_ftell(&pb);
|
||||
if (res < 0)
|
||||
@ -314,7 +315,7 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
} else {
|
||||
ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, pkt);
|
||||
ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, rdt->rmst[0], pkt);
|
||||
if (rdt->audio_pkt_cnt[st->id] == 0 &&
|
||||
st->codec->codec_id == CODEC_ID_AAC)
|
||||
av_freep(&rdt->rmctx->pb);
|
||||
@ -426,6 +427,7 @@ rdt_new_extradata (void)
|
||||
PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
|
||||
|
||||
av_open_input_stream(&rdt->rmctx, NULL, "", &rdt_demuxer, NULL);
|
||||
rdt->rmst[0] = ff_rm_alloc_rmstream();
|
||||
|
||||
return rdt;
|
||||
}
|
||||
@ -433,6 +435,7 @@ rdt_new_extradata (void)
|
||||
static void
|
||||
rdt_free_extradata (PayloadContext *rdt)
|
||||
{
|
||||
ff_rm_free_rmstream(rdt->rmst[0]);
|
||||
if (rdt->rmctx)
|
||||
av_close_input_stream(rdt->rmctx);
|
||||
av_freep(&rdt->mlti_data);
|
||||
|
@ -40,11 +40,13 @@ extern AVInputFormat rdt_demuxer;
|
||||
* @param pb context to read the data from
|
||||
* @param st the stream that the MDPR chunk belongs to and where to store the
|
||||
* parameters read from the chunk into
|
||||
* @param rst real-specific stream information
|
||||
* @param codec_data_size size of the MDPR chunk
|
||||
* @return 0 on success, errno codes on error
|
||||
*/
|
||||
int ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
|
||||
AVStream *st, int codec_data_size);
|
||||
AVStream *st, RMStream *rst,
|
||||
int codec_data_size);
|
||||
|
||||
/**
|
||||
* Parse one rm-stream packet from the input bytestream.
|
||||
@ -52,6 +54,7 @@ int ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
|
||||
* @param s context containing RMContext and ByteIOContext for stream reading
|
||||
* @param pb context to read the data from
|
||||
* @param st stream to which the packet to be read belongs
|
||||
* @param rst Real-specific stream information
|
||||
* @param len packet length to read from the input
|
||||
* @param pkt packet location to store the parsed packet data
|
||||
* @param seq pointer to an integer containing the sequence number, may be
|
||||
@ -64,7 +67,7 @@ int ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
|
||||
* errno codes on error
|
||||
*/
|
||||
int ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
|
||||
AVStream *st, int len,
|
||||
AVStream *st, RMStream *rst, int len,
|
||||
AVPacket *pkt, int *seq, int *flags, int64_t *ts);
|
||||
|
||||
/**
|
||||
@ -78,9 +81,10 @@ int ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
|
||||
* @param s context containing RMContext and ByteIOContext for stream reading
|
||||
* @param pb context to read the data from
|
||||
* @param st stream that this packet belongs to
|
||||
* @param rst Real-specific stream information
|
||||
* @param pkt location to store the packet data
|
||||
*/
|
||||
void ff_rm_retrieve_cache (AVFormatContext *s, ByteIOContext *pb,
|
||||
AVStream *st, AVPacket *pkt);
|
||||
AVStream *st, RMStream *rst, AVPacket *pkt);
|
||||
|
||||
#endif /* AVFORMAT_RM_H */
|
||||
|
@ -87,9 +87,8 @@ void ff_rm_free_rmstream (RMStream *rms)
|
||||
}
|
||||
|
||||
static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
|
||||
AVStream *st, int read_all)
|
||||
AVStream *st, RMStream *ast, int read_all)
|
||||
{
|
||||
RMStream *ast = st->priv_data;
|
||||
char buf[256];
|
||||
uint32_t version;
|
||||
|
||||
@ -228,20 +227,18 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
|
||||
|
||||
int
|
||||
ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
|
||||
AVStream *st, int codec_data_size)
|
||||
AVStream *st, RMStream *rst, int codec_data_size)
|
||||
{
|
||||
unsigned int v;
|
||||
int size;
|
||||
int64_t codec_pos;
|
||||
RMStream *rst;
|
||||
|
||||
st->priv_data = rst = ff_rm_alloc_rmstream();
|
||||
av_set_pts_info(st, 64, 1, 1000);
|
||||
codec_pos = url_ftell(pb);
|
||||
v = get_be32(pb);
|
||||
if (v == MKTAG(0xfd, 'a', 'r', '.')) {
|
||||
/* ra type header */
|
||||
if (rm_read_audio_stream_info(s, pb, st, 0))
|
||||
if (rm_read_audio_stream_info(s, pb, st, rst, 0))
|
||||
return -1;
|
||||
} else {
|
||||
int fps, fps2;
|
||||
@ -308,7 +305,8 @@ static int rm_read_header_old(AVFormatContext *s, AVFormatParameters *ap)
|
||||
st = av_new_stream(s, 0);
|
||||
if (!st)
|
||||
return -1;
|
||||
return rm_read_audio_stream_info(s, s->pb, st, 1);
|
||||
st->priv_data = ff_rm_alloc_rmstream();
|
||||
return rm_read_audio_stream_info(s, s->pb, st, st->priv_data, 1);
|
||||
}
|
||||
|
||||
static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
@ -390,7 +388,9 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
get_str8(pb, buf, sizeof(buf)); /* desc */
|
||||
get_str8(pb, buf, sizeof(buf)); /* mimetype */
|
||||
st->codec->codec_type = CODEC_TYPE_DATA;
|
||||
if (ff_rm_read_mdpr_codecdata(s, s->pb, st, get_be32(pb)) < 0)
|
||||
st->priv_data = ff_rm_alloc_rmstream();
|
||||
if (ff_rm_read_mdpr_codecdata(s, s->pb, st, st->priv_data,
|
||||
get_be32(pb)) < 0)
|
||||
return -1;
|
||||
break;
|
||||
case MKTAG('D', 'A', 'T', 'A'):
|
||||
@ -584,18 +584,16 @@ rm_ac3_swap_bytes (AVStream *st, AVPacket *pkt)
|
||||
|
||||
int
|
||||
ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
|
||||
AVStream *st, int len, AVPacket *pkt,
|
||||
AVStream *st, RMStream *ast, int len, AVPacket *pkt,
|
||||
int *seq, int *flags, int64_t *timestamp)
|
||||
{
|
||||
RMDemuxContext *rm = s->priv_data;
|
||||
|
||||
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
|
||||
rm->current_stream= st->id;
|
||||
if(rm_assemble_video_frame(s, pb, rm, st->priv_data, pkt, len) == 1)
|
||||
if(rm_assemble_video_frame(s, pb, rm, ast, pkt, len) == 1)
|
||||
return -1; //got partial frame
|
||||
} else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
|
||||
RMStream *ast = st->priv_data;
|
||||
|
||||
if ((st->codec->codec_id == CODEC_ID_RA_288) ||
|
||||
(st->codec->codec_id == CODEC_ID_COOK) ||
|
||||
(st->codec->codec_id == CODEC_ID_ATRAC3) ||
|
||||
@ -685,10 +683,9 @@ ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
|
||||
|
||||
void
|
||||
ff_rm_retrieve_cache (AVFormatContext *s, ByteIOContext *pb,
|
||||
AVStream *st, AVPacket *pkt)
|
||||
AVStream *st, RMStream *ast, AVPacket *pkt)
|
||||
{
|
||||
RMDemuxContext *rm = s->priv_data;
|
||||
RMStream *ast = st->priv_data;
|
||||
|
||||
assert (rm->audio_pkt_cnt > 0);
|
||||
|
||||
@ -717,7 +714,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
if (rm->audio_pkt_cnt) {
|
||||
// If there are queued audio packet return them first
|
||||
st = s->streams[rm->audio_stream_num];
|
||||
ff_rm_retrieve_cache(s, s->pb, st, pkt);
|
||||
ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt);
|
||||
} else if (rm->old_format) {
|
||||
RMStream *ast;
|
||||
|
||||
@ -756,7 +753,8 @@ resync:
|
||||
return AVERROR(EIO);
|
||||
st = s->streams[i];
|
||||
|
||||
if (ff_rm_parse_packet (s, s->pb, st, len, pkt, &seq, &flags, ×tamp) < 0)
|
||||
if (ff_rm_parse_packet (s, s->pb, st, st->priv_data, len, pkt,
|
||||
&seq, &flags, ×tamp) < 0)
|
||||
goto resync;
|
||||
|
||||
if((flags&2) && (seq&0x7F) == 1)
|
||||
|
Loading…
Reference in New Issue
Block a user