mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
rtsp: Don't store RTSPStream in AVStream->priv_data
For mpegts in RTP, there isn't a direct mapping between RTSPStreams and AVStreams, and the RTSPStream isn't ever stored in AVStream->priv_data, which was earlier leaked. The fix for this leak, inea7f080749
, lead to double frees for other, normal RTP streams. This patch avoids storing RTSPStreams in AVStream->priv_data, thus avoiding the double free. The RTSPStreams are always available via RTSPState->rtsp_streams anyway. Tested with MS-RTSP, RealRTSP, DSS and mpegts/RTP. Signed-off-by: Luca Barbato <lu_zero@gentoo.org> (cherry picked from commitd9c0510e22
)
This commit is contained in:
parent
4a908866a1
commit
c6347bdf08
@ -273,8 +273,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
|
|||||||
s1->default_ip = sdp_ip;
|
s1->default_ip = sdp_ip;
|
||||||
s1->default_ttl = ttl;
|
s1->default_ttl = ttl;
|
||||||
} else {
|
} else {
|
||||||
st = s->streams[s->nb_streams - 1];
|
rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
|
||||||
rtsp_st = st->priv_data;
|
|
||||||
rtsp_st->sdp_ip = sdp_ip;
|
rtsp_st->sdp_ip = sdp_ip;
|
||||||
rtsp_st->sdp_ttl = ttl;
|
rtsp_st->sdp_ttl = ttl;
|
||||||
}
|
}
|
||||||
@ -326,7 +325,6 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
|
|||||||
st = av_new_stream(s, 0);
|
st = av_new_stream(s, 0);
|
||||||
if (!st)
|
if (!st)
|
||||||
return;
|
return;
|
||||||
st->priv_data = rtsp_st;
|
|
||||||
rtsp_st->stream_index = st->index;
|
rtsp_st->stream_index = st->index;
|
||||||
st->codec->codec_type = codec_type;
|
st->codec->codec_type = codec_type;
|
||||||
if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) {
|
if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) {
|
||||||
@ -355,8 +353,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
|
|||||||
} else {
|
} else {
|
||||||
char proto[32];
|
char proto[32];
|
||||||
/* get the control url */
|
/* get the control url */
|
||||||
st = s->streams[s->nb_streams - 1];
|
rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
|
||||||
rtsp_st = st->priv_data;
|
|
||||||
|
|
||||||
/* XXX: may need to add full url resolution */
|
/* XXX: may need to add full url resolution */
|
||||||
av_url_split(proto, sizeof(proto), NULL, 0, NULL, 0,
|
av_url_split(proto, sizeof(proto), NULL, 0, NULL, 0,
|
||||||
@ -377,7 +374,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
|
|||||||
get_word(buf1, sizeof(buf1), &p);
|
get_word(buf1, sizeof(buf1), &p);
|
||||||
payload_type = atoi(buf1);
|
payload_type = atoi(buf1);
|
||||||
st = s->streams[s->nb_streams - 1];
|
st = s->streams[s->nb_streams - 1];
|
||||||
rtsp_st = st->priv_data;
|
rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
|
||||||
sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p);
|
sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p);
|
||||||
} else if (av_strstart(p, "fmtp:", &p) ||
|
} else if (av_strstart(p, "fmtp:", &p) ||
|
||||||
av_strstart(p, "framesize:", &p)) {
|
av_strstart(p, "framesize:", &p)) {
|
||||||
@ -385,9 +382,8 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
|
|||||||
// let dynamic protocol handlers have a stab at the line.
|
// let dynamic protocol handlers have a stab at the line.
|
||||||
get_word(buf1, sizeof(buf1), &p);
|
get_word(buf1, sizeof(buf1), &p);
|
||||||
payload_type = atoi(buf1);
|
payload_type = atoi(buf1);
|
||||||
for (i = 0; i < s->nb_streams; i++) {
|
for (i = 0; i < rt->nb_rtsp_streams; i++) {
|
||||||
st = s->streams[i];
|
rtsp_st = rt->rtsp_streams[i];
|
||||||
rtsp_st = st->priv_data;
|
|
||||||
if (rtsp_st->sdp_payload_type == payload_type &&
|
if (rtsp_st->sdp_payload_type == payload_type &&
|
||||||
rtsp_st->dynamic_handler &&
|
rtsp_st->dynamic_handler &&
|
||||||
rtsp_st->dynamic_handler->parse_sdp_a_line)
|
rtsp_st->dynamic_handler->parse_sdp_a_line)
|
||||||
@ -417,7 +413,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
|
|||||||
if (rt->server_type == RTSP_SERVER_REAL)
|
if (rt->server_type == RTSP_SERVER_REAL)
|
||||||
ff_real_parse_sdp_a_line(s, s->nb_streams - 1, p);
|
ff_real_parse_sdp_a_line(s, s->nb_streams - 1, p);
|
||||||
|
|
||||||
rtsp_st = s->streams[s->nb_streams - 1]->priv_data;
|
rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
|
||||||
if (rtsp_st->dynamic_handler &&
|
if (rtsp_st->dynamic_handler &&
|
||||||
rtsp_st->dynamic_handler->parse_sdp_a_line)
|
rtsp_st->dynamic_handler->parse_sdp_a_line)
|
||||||
rtsp_st->dynamic_handler->parse_sdp_a_line(s,
|
rtsp_st->dynamic_handler->parse_sdp_a_line(s,
|
||||||
|
@ -79,14 +79,12 @@ int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr)
|
|||||||
/* Set up the RTSPStreams for each AVStream */
|
/* Set up the RTSPStreams for each AVStream */
|
||||||
for (i = 0; i < s->nb_streams; i++) {
|
for (i = 0; i < s->nb_streams; i++) {
|
||||||
RTSPStream *rtsp_st;
|
RTSPStream *rtsp_st;
|
||||||
AVStream *st = s->streams[i];
|
|
||||||
|
|
||||||
rtsp_st = av_mallocz(sizeof(RTSPStream));
|
rtsp_st = av_mallocz(sizeof(RTSPStream));
|
||||||
if (!rtsp_st)
|
if (!rtsp_st)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st);
|
dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st);
|
||||||
|
|
||||||
st->priv_data = rtsp_st;
|
|
||||||
rtsp_st->stream_index = i;
|
rtsp_st->stream_index = i;
|
||||||
|
|
||||||
av_strlcpy(rtsp_st->control_url, rt->control_uri, sizeof(rtsp_st->control_url));
|
av_strlcpy(rtsp_st->control_url, rt->control_uri, sizeof(rtsp_st->control_url));
|
||||||
|
Loading…
Reference in New Issue
Block a user