[FFmpeg-devel] [PATCH] RTSP-MS 12/15: ASF payload support

Ronald S. Bultje rsbultje
Tue Mar 17 13:49:25 CET 2009


Hi,

2009/1/10 Michael Niedermayer <michaelni at gmx.at>:
> On Tue, Jan 06, 2009 at 12:15:41AM -0500, Ronald S. Bultje wrote:
>> + ? ? ? ? ? ? ? ? ? ?s->streams[stream_index]->codec->extradata =
>> + ? ? ? ? ? ? ? ? ? ? ? ?av_malloc(s->streams[stream_index]->codec->extradata_size);
>> + ? ? ? ? ? ? ? ? ? ?memcpy(s->streams[stream_index]->codec->extradata,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? rt->asf_ctx->streams[i]->codec->extradata,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? s->streams[stream_index]->codec->extradata_size);
>
> you are missing FF_INPUT_BUFFER_PADDING_SIZE besides
> why not just set extradata(_size) to 0 in the source? or does that fail somehow?

Good point, and that works indeed. In this revision, I also removed
the "rtx" payload which I initially added because I now know it isn't
needed for basic playback (and wouldn't use the same packet layout
anyway).

New patch attached. Luca (Abeni :-) ), could you review the rtpdec.c parts?

Thanks,
Ronald
-------------- next part --------------
Index: ffmpeg-svn/libavformat/rtp_asf.c
===================================================================
--- ffmpeg-svn.orig/libavformat/rtp_asf.c	2009-03-17 08:45:56.000000000 -0400
+++ ffmpeg-svn/libavformat/rtp_asf.c	2009-03-17 08:46:30.000000000 -0400
@@ -27,6 +27,7 @@
 
 #include <libavutil/base64.h>
 #include <libavutil/avstring.h>
+#include "rtp.h"
 #include "rtp_asf.h"
 #include "rtsp.h"
 #include "asf.h"
@@ -50,3 +51,41 @@
         rt->asf_ctx->pb = NULL;
     }
 }
+
+static int
+asfrtp_parse_sdp_line (AVFormatContext *s, int stream_index,
+                       PayloadContext *asf, const char *line)
+{
+    if (av_strstart(line, "stream:", &line)) {
+        RTSPState *rt = s->priv_data;
+
+        s->streams[stream_index]->id = strtol(line, NULL, 10);
+
+        if (rt->asf_ctx) {
+            int i;
+
+            for (i = 0; i < rt->asf_ctx->nb_streams; i++) {
+                if (s->streams[stream_index]->id == rt->asf_ctx->streams[i]->id) {
+                    *s->streams[stream_index]->codec =
+                        *rt->asf_ctx->streams[i]->codec;
+                    rt->asf_ctx->streams[i]->codec->extradata_size = 0;
+                    rt->asf_ctx->streams[i]->codec->extradata = NULL;
+                    av_set_pts_info(s->streams[stream_index], 32, 1, 1000);
+                }
+           }
+        }
+    }
+
+    return 0;
+}
+
+#define RTP_ASF_HANDLER(n, s, t) \
+RTPDynamicProtocolHandler ff_ms_rtp_ ## n ## _handler = { \
+    s, \
+    t, \
+    CODEC_ID_NONE, \
+    asfrtp_parse_sdp_line, \
+};
+
+RTP_ASF_HANDLER(asf_pfv, "x-asf-pf",  CODEC_TYPE_VIDEO);
+RTP_ASF_HANDLER(asf_pfa, "x-asf-pf",  CODEC_TYPE_AUDIO);
Index: ffmpeg-svn/libavformat/rtpdec.c
===================================================================
--- ffmpeg-svn.orig/libavformat/rtpdec.c	2009-03-17 08:45:56.000000000 -0400
+++ ffmpeg-svn/libavformat/rtpdec.c	2009-03-17 08:46:26.000000000 -0400
@@ -48,6 +48,8 @@
 
 static RTPDynamicProtocolHandler mp4v_es_handler= {"MP4V-ES", CODEC_TYPE_VIDEO, CODEC_ID_MPEG4};
 static RTPDynamicProtocolHandler mpeg4_generic_handler= {"mpeg4-generic", CODEC_TYPE_AUDIO, CODEC_ID_AAC};
+extern RTPDynamicProtocolHandler ff_ms_rtp_asf_pfv_handler,
+                                 ff_ms_rtp_asf_pfa_handler;
 
 void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler)
 {
@@ -60,6 +62,9 @@
     ff_register_dynamic_payload_handler(&mp4v_es_handler);
     ff_register_dynamic_payload_handler(&mpeg4_generic_handler);
     ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler);
+
+    ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfv_handler);
+    ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfa_handler);
 }
 
 static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int len)



More information about the ffmpeg-devel mailing list