]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Add RTP/ASF header parsing, which is part of the SDP of these streams. See
authorrbultje <rbultje@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Tue, 17 Mar 2009 12:34:57 +0000 (12:34 +0000)
committerrbultje <rbultje@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Tue, 17 Mar 2009 12:34:57 +0000 (12:34 +0000)
patch discussion in "[PATCH] RTSP-MS 10/15: ASF header parsing" thread.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@18023 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavformat/Makefile
libavformat/rtp_asf.c [new file with mode: 0644]
libavformat/rtp_asf.h [new file with mode: 0644]
libavformat/rtsp.c
libavformat/rtsp.h

index 426ca92f774e8e14226ad8da2cd6257a00c1d511..e883041673d21d12d974e865ce2a4902984afb05 100644 (file)
@@ -188,6 +188,7 @@ OBJS-$(CONFIG_ROQ_MUXER)                 += raw.o
 OBJS-$(CONFIG_RPL_DEMUXER)               += rpl.o
 OBJS-$(CONFIG_RTP_MUXER)                 += rtp.o         \
                                             rtp_aac.o     \
+                                            rtp_asf.o     \
                                             rtp_mpv.o     \
                                             rtpenc.o      \
                                             rtpenc_h264.o \
diff --git a/libavformat/rtp_asf.c b/libavformat/rtp_asf.c
new file mode 100644 (file)
index 0000000..0bc5c9e
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Microsoft RTP/ASF support.
+ * Copyright (c) 2008 Ronald S. Bultje
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file rtp-asf.c
+ * @brief Microsoft RTP/ASF support
+ * @author Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ */
+
+#include <libavutil/base64.h>
+#include <libavutil/avstring.h>
+#include "rtp_asf.h"
+#include "rtsp.h"
+#include "asf.h"
+
+void ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
+{
+    if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {
+        ByteIOContext pb;
+        RTSPState *rt = s->priv_data;
+        int len = strlen(p) * 6 / 8;
+        char *buf = av_mallocz(len);
+        av_base64_decode(buf, p, len);
+
+        init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
+        if (rt->asf_ctx) {
+            av_close_input_stream(rt->asf_ctx);
+            rt->asf_ctx = NULL;
+        }
+        av_open_input_stream(&rt->asf_ctx, &pb, "", &asf_demuxer, NULL);
+        av_free(buf);
+        rt->asf_ctx->pb = NULL;
+    }
+}
diff --git a/libavformat/rtp_asf.h b/libavformat/rtp_asf.h
new file mode 100644 (file)
index 0000000..08632a1
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Microsoft RTP/ASF support.
+ * Copyright (c) 2008 Ronald S. Bultje
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVFORMAT_RTP_ASF_H
+#define AVFORMAT_RTP_ASF_H
+
+#include "avformat.h"
+
+/**
+ * Parse a Windows Media Server-specific SDP line
+ *
+ * @param s RTSP demux context
+ * @param line the SDP line to be parsed
+ */
+void ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p);
+
+#endif /* AVFORMAT_RTP_ASF_H */
index 6806736ed24c5b43d93415db352014c5bea0cc34..a4938bae08342af92d870cb151aaa8954c0b4fa5 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "rtpdec.h"
 #include "rdt.h"
+#include "rtp_asf.h"
 
 //#define DEBUG
 //#define DEBUG_RTP_TCP
@@ -496,7 +497,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
         } else if (av_strstart(p, "IsRealDataType:integer;",&p)) {
             if (atoi(p) == 1)
                 rt->transport = RTSP_TRANSPORT_RDT;
-        } else if (s->nb_streams > 0) {
+        } else {
+            if (rt->server_type == RTSP_SERVER_WMS)
+                ff_wms_parse_sdp_a_line(s, p);
+            if (s->nb_streams > 0) {
             if (rt->server_type == RTSP_SERVER_REAL)
                 ff_real_parse_sdp_a_line(s, s->nb_streams - 1, p);
 
@@ -505,6 +509,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
                 rtsp_st->dynamic_handler->parse_sdp_a_line)
                 rtsp_st->dynamic_handler->parse_sdp_a_line(s, s->nb_streams - 1,
                     rtsp_st->dynamic_protocol_context, buf);
+            }
         }
         break;
     }
@@ -853,6 +858,10 @@ static void rtsp_close_streams(RTSPState *rt)
         }
     }
     av_free(rt->rtsp_streams);
+    if (rt->asf_ctx) {
+        av_close_input_stream (rt->asf_ctx);
+        rt->asf_ctx = NULL;
+    }
 }
 
 static int
index d44926ac3a92d05361f3df770654c687cce18b76..60d8c30f8726fab475bc0d71f2b7fbc4063b0249 100644 (file)
@@ -223,6 +223,12 @@ typedef struct RTSPState {
      * before sending a new "Subscribe:" command. */
     char last_subscription[1024];
     //@}
+
+    /** The following are used for RTP/ASF streams */
+    //@{
+    /** ASF demuxer context for the embedded ASF stream from WMS servers */
+    AVFormatContext *asf_ctx;
+    //@}
 } RTSPState;
 
 /**