Commit 7c68a177 authored by Ronald S. Bultje's avatar Ronald S. Bultje

Parse the OpaqueData field for every AVStream represented by this "set of

streams" (a single RTSPStream / RDTDemuxContext can represent several
AVStreams, that's just how Real/RDT was designed...). This will fill in
most of the AVStream/AVCodecContext header fields, similar to reading a
RM file header would. See "[PATCH] multi-stream MDPR parsing" thread on
mailinglist.

Originally committed as revision 16468 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 530bca94
...@@ -180,7 +180,7 @@ rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr) ...@@ -180,7 +180,7 @@ rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr)
size = rdt->mlti_data_size; size = rdt->mlti_data_size;
url_fseek(&pb, 0, SEEK_SET); url_fseek(&pb, 0, SEEK_SET);
} }
if (ff_rm_read_mdpr_codecdata(rdt->rmctx, &pb, st, rdt->rmst[0], size) < 0) if (ff_rm_read_mdpr_codecdata(rdt->rmctx, &pb, st, rdt->rmst[st->index], size) < 0)
return -1; return -1;
return 0; return 0;
...@@ -307,7 +307,7 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st, ...@@ -307,7 +307,7 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st,
init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL); init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
flags = (flags & PKT_FLAG_KEY) ? 2 : 0; flags = (flags & PKT_FLAG_KEY) ? 2 : 0;
res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[0], len, pkt, res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt,
&seq, &flags, timestamp); &seq, &flags, timestamp);
pos = url_ftell(&pb); pos = url_ftell(&pb);
if (res < 0) if (res < 0)
...@@ -322,7 +322,7 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st, ...@@ -322,7 +322,7 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st,
} else { } else {
rdt->audio_pkt_cnt = rdt->audio_pkt_cnt =
ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb,
st, rdt->rmst[0], pkt); st, rdt->rmst[st->index], pkt);
if (rdt->audio_pkt_cnt == 0 && if (rdt->audio_pkt_cnt == 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);
...@@ -389,15 +389,6 @@ ff_rdt_subscribe_rule (char *cmd, int size, ...@@ -389,15 +389,6 @@ ff_rdt_subscribe_rule (char *cmd, int size,
stream_nr, rule_nr * 2, stream_nr, rule_nr * 2 + 1); stream_nr, rule_nr * 2, stream_nr, rule_nr * 2 + 1);
} }
void
ff_rdt_subscribe_rule2 (RDTDemuxContext *s, char *cmd, int size,
int stream_nr, int rule_nr)
{
PayloadContext *rdt = s->dynamic_protocol_context;
rdt_load_mdpr(rdt, s->streams[0], rule_nr * 2);
}
static unsigned char * static unsigned char *
rdt_parse_b64buf (unsigned int *target_len, const char *p) rdt_parse_b64buf (unsigned int *target_len, const char *p)
{ {
...@@ -424,6 +415,19 @@ rdt_parse_sdp_line (AVFormatContext *s, int st_index, ...@@ -424,6 +415,19 @@ rdt_parse_sdp_line (AVFormatContext *s, int st_index,
rdt->mlti_data = rdt_parse_b64buf(&rdt->mlti_data_size, p); rdt->mlti_data = rdt_parse_b64buf(&rdt->mlti_data_size, p);
} else if (av_strstart(p, "StartTime:integer;", &p)) } else if (av_strstart(p, "StartTime:integer;", &p))
stream->first_dts = atoi(p); stream->first_dts = atoi(p);
else if (av_strstart(p, "ASMRuleBook:string;", &p)) {
int n = st_index, first = -1;
for (n = 0; n < s->nb_streams; n++)
if (s->streams[n]->priv_data == stream->priv_data) {
if (first == -1) first = n;
rdt->rmst[s->streams[n]->index] = ff_rm_alloc_rmstream();
rdt_load_mdpr(rdt, s->streams[n], (n - first) * 2);
if (s->streams[n]->codec->codec_id == CODEC_ID_AAC)
s->streams[n]->codec->frame_size = 1; // FIXME
}
}
return 0; return 0;
} }
...@@ -510,7 +514,6 @@ rdt_new_extradata (void) ...@@ -510,7 +514,6 @@ rdt_new_extradata (void)
PayloadContext *rdt = av_mallocz(sizeof(PayloadContext)); PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
av_open_input_stream(&rdt->rmctx, NULL, "", &rdt_demuxer, NULL); av_open_input_stream(&rdt->rmctx, NULL, "", &rdt_demuxer, NULL);
rdt->rmst[0] = ff_rm_alloc_rmstream();
return rdt; return rdt;
} }
...@@ -518,8 +521,13 @@ rdt_new_extradata (void) ...@@ -518,8 +521,13 @@ rdt_new_extradata (void)
static void static void
rdt_free_extradata (PayloadContext *rdt) rdt_free_extradata (PayloadContext *rdt)
{ {
ff_rm_free_rmstream(rdt->rmst[0]); int i;
av_free(rdt->rmst[0]);
for (i = 0; i < MAX_STREAMS; i++)
if (rdt->rmst[i]) {
ff_rm_free_rmstream(rdt->rmst[i]);
av_freep(&rdt->rmst[i]);
}
if (rdt->rmctx) if (rdt->rmctx)
av_close_input_stream(rdt->rmctx); av_close_input_stream(rdt->rmctx);
av_freep(&rdt->mlti_data); av_freep(&rdt->mlti_data);
......
...@@ -74,9 +74,6 @@ void av_register_rdt_dynamic_payload_handlers(void); ...@@ -74,9 +74,6 @@ void av_register_rdt_dynamic_payload_handlers(void);
*/ */
void ff_rdt_subscribe_rule(char *cmd, int size, void ff_rdt_subscribe_rule(char *cmd, int size,
int stream_nr, int rule_nr); int stream_nr, int rule_nr);
// FIXME this will be removed ASAP
void ff_rdt_subscribe_rule2(RDTDemuxContext *s, char *cmd, int size,
int stream_nr, int rule_nr);
/** /**
* Parse RDT-style packet header. * Parse RDT-style packet header.
......
...@@ -1364,10 +1364,6 @@ static int rtsp_read_packet(AVFormatContext *s, ...@@ -1364,10 +1364,6 @@ static int rtsp_read_packet(AVFormatContext *s,
for (i = 0; i < rt->nb_rtsp_streams; i++) { for (i = 0; i < rt->nb_rtsp_streams; i++) {
if (i != 0) av_strlcat(cmd, ",", sizeof(cmd)); if (i != 0) av_strlcat(cmd, ",", sizeof(cmd));
ff_rdt_subscribe_rule(cmd, sizeof(cmd), i, 0); ff_rdt_subscribe_rule(cmd, sizeof(cmd), i, 0);
if (rt->transport == RTSP_TRANSPORT_RDT)
ff_rdt_subscribe_rule2(
rt->rtsp_streams[i]->tx_ctx,
cmd, sizeof(cmd), i, 0);
} }
av_strlcat(cmd, "\r\n", sizeof(cmd)); av_strlcat(cmd, "\r\n", sizeof(cmd));
rtsp_send_cmd(s, cmd, reply, NULL); rtsp_send_cmd(s, cmd, reply, NULL);
......
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