]> git.sesse.net Git - ffmpeg/commitdiff
rtsp: Parse SSRC attributes in the SDP
authorMartin Storsjö <martin@martin.st>
Tue, 4 Dec 2012 13:28:29 +0000 (15:28 +0200)
committerMartin Storsjö <martin@martin.st>
Wed, 11 May 2016 07:35:26 +0000 (10:35 +0300)
When feeding input RTP packets to the depacketizer via custom IO,
it needs to pick the right stream using the payload type for
RTP packets, and using the SSRC for RTCP packets. If the first
packet is an RTCP packet, we don't (currently) know the SSRC
yet and thus can't pick the right RTP depacketizer to handle it.

By parsing the SSRC attribute in the SDP, we can map initial
RTCP packets to the right stream.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/rtsp.c
libavformat/rtsp.h

index 7e430e838b06d9edc57c1850c6850bee8af96d5b..9e8733a10858af8bedb76b6050d5079db1e1d708 100644 (file)
@@ -565,6 +565,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
                 s1->seen_fmtp = 1;
                 av_strlcpy(s1->delayed_fmtp, buf, sizeof(s1->delayed_fmtp));
             }
+        } else if (av_strstart(p, "ssrc:", &p) && s->nb_streams > 0) {
+            rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
+            get_word(buf1, sizeof(buf1), &p);
+            rtsp_st->ssrc = strtoll(buf1, NULL, 10);
         } else if (av_strstart(p, "range:", &p)) {
             int64_t start, end;
 
@@ -824,6 +828,8 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
     if (!rtsp_st->transport_priv) {
          return AVERROR(ENOMEM);
     } else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RTP) {
+        RTPDemuxContext *rtpctx = rtsp_st->transport_priv;
+        rtpctx->ssrc = rtsp_st->ssrc;
         if (rtsp_st->dynamic_handler) {
             ff_rtp_parse_set_dynamic_protocol(rtsp_st->transport_priv,
                                               rtsp_st->dynamic_protocol_context,
index 0226dac0f1d48e8f25934abe56e95c88058b79fc..ff5b53207eb68d9e9cb72552da9dc4d108201b48 100644 (file)
@@ -457,6 +457,9 @@ typedef struct RTSPStream {
     /** Enable sending RTCP feedback messages according to RFC 4585 */
     int feedback;
 
+    /** SSRC for this stream, to allow identifying RTCP packets before the first RTP packet */
+    uint32_t ssrc;
+
     char crypto_suite[40];
     char crypto_params[100];
 } RTSPStream;