rtpdec: Add an init function that can do custom codec context initialization
authorMartin Storsjö <martin@martin.st>
Tue, 29 Nov 2011 14:51:26 +0000 (16:51 +0200)
committerMartin Storsjö <martin@martin.st>
Wed, 30 Nov 2011 15:32:18 +0000 (17:32 +0200)
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/rtpdec.h
libavformat/rtsp.c

index eb1e62daec2fdf69d22e85b96d49e3bbba6a4a47..9e2bfd01d50fea16cc629807bc0c63bc124d11bb 100644 (file)
@@ -122,6 +122,7 @@ struct RTPDynamicProtocolHandler_s {
                             * require any custom depacketization code. */
 
     // may be null
+    int (*init)(AVFormatContext *s, int st_index, PayloadContext *priv_data); ///< Initialize dynamic protocol handler, called after the full rtpmap line is parsed
     int (*parse_sdp_a_line) (AVFormatContext *s,
                              int st_index,
                              PayloadContext *priv_data,
index d0e9bbf6af6534b0e2f8c841b6cb763f0a41f4dd..1f32050c69bc07e025c19f64667bdbb4e39b9570 100644 (file)
@@ -251,6 +251,9 @@ static int sdp_parse_rtpmap(AVFormatContext *s,
     default:
         break;
     }
+    if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->init)
+        rtsp_st->dynamic_handler->init(s, st->index,
+                                       rtsp_st->dynamic_protocol_context);
     return 0;
 }
 
@@ -387,6 +390,9 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
                 handler = ff_rtp_handler_find_by_id(
                               rtsp_st->sdp_payload_type, st->codec->codec_type);
                 init_rtp_handler(handler, rtsp_st, st->codec);
+                if (handler && handler->init)
+                    handler->init(s, st->index,
+                                  rtsp_st->dynamic_protocol_context);
             }
         }
         /* put a default control url */