[FFmpeg-cvslog] rtpdec: Add an init function that can do custom codec context initialization

Martin Storsjö git at videolan.org
Thu Dec 1 03:02:41 CET 2011


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Tue Nov 29 16:51:26 2011 +0200| [258366066479391aa998e3c8e87f70bec559db72] | committer: Martin Storsjö

rtpdec: Add an init function that can do custom codec context initialization

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=258366066479391aa998e3c8e87f70bec559db72
---

 libavformat/rtpdec.h |    1 +
 libavformat/rtsp.c   |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/libavformat/rtpdec.h b/libavformat/rtpdec.h
index eb1e62d..9e2bfd0 100644
--- a/libavformat/rtpdec.h
+++ b/libavformat/rtpdec.h
@@ -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,
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index d0e9bbf..1f32050 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -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 */



More information about the ffmpeg-cvslog mailing list