]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtpdec_asf.c
Merge commit '82b6e451161f19ab90bfb9565b710021caf5dcbd'
[ffmpeg] / libavformat / rtpdec_asf.c
index b0a50353fd8c247f5cc2b50364926c5c1efbaceb..019123e55941085f3cc7937a0e99bb110584b9d2 100644 (file)
@@ -2,20 +2,20 @@
  * Microsoft RTP/ASF support.
  * Copyright (c) 2008 Ronald S. Bultje
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * 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.
  *
- * Libav is distributed in the hope that it will be useful,
+ * 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 Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
@@ -25,6 +25,7 @@
  * @author Ronald S. Bultje <rbultje@ronald.bitfreak.net>
  */
 
+#include "libavutil/avassert.h"
 #include "libavutil/base64.h"
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
@@ -102,6 +103,8 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
         AVDictionary *opts = NULL;
         int len = strlen(p) * 6 / 8;
         char *buf = av_mallocz(len);
+        AVInputFormat *iformat;
+
         av_base64_decode(buf, p, len);
 
         if (rtp_asf_fix_header(buf, len) < 0)
@@ -111,11 +114,19 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
         if (rt->asf_ctx) {
             avformat_close_input(&rt->asf_ctx);
         }
+        if (!(iformat = av_find_input_format("asf")))
+            return AVERROR_DEMUXER_NOT_FOUND;
         if (!(rt->asf_ctx = avformat_alloc_context()))
             return AVERROR(ENOMEM);
         rt->asf_ctx->pb      = &pb;
         av_dict_set(&opts, "no_resync_search", "1", 0);
-        ret = avformat_open_input(&rt->asf_ctx, "", &ff_asf_demuxer, &opts);
+
+        if ((ret = ff_copy_whitelists(rt->asf_ctx, s)) < 0) {
+            av_dict_free(&opts);
+            return ret;
+        }
+
+        ret = avformat_open_input(&rt->asf_ctx, "", iformat, &opts);
         av_dict_free(&opts);
         if (ret < 0)
             return ret;
@@ -188,7 +199,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
 
         av_freep(&asf->buf);
 
-        ffio_init_context(pb, buf, len, 0, NULL, NULL, NULL, NULL);
+        ffio_init_context(pb, (uint8_t *)buf, len, 0, NULL, NULL, NULL, NULL);
 
         while (avio_tell(pb) + 4 < len) {
             int start_off = avio_tell(pb);
@@ -213,10 +224,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
                  * multiple RTP packets.
                  */
                 if (asf->pktbuf && len_off != avio_tell(asf->pktbuf)) {
-                    uint8_t *p;
-                    avio_close_dyn_buf(asf->pktbuf, &p);
-                    asf->pktbuf = NULL;
-                    av_free(p);
+                    ffio_free_dyn_buf(&asf->pktbuf);
                 }
                 if (!len_off && !asf->pktbuf &&
                     (res = avio_open_dyn_buf(&asf->pktbuf)) < 0)
@@ -277,14 +285,9 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
     return res == 1 ? -1 : res;
 }
 
-static void asfrtp_free_context(PayloadContext *asf)
+static void asfrtp_close_context(PayloadContext *asf)
 {
-    if (asf->pktbuf) {
-        uint8_t *p = NULL;
-        avio_close_dyn_buf(asf->pktbuf, &p);
-        asf->pktbuf = NULL;
-        av_free(p);
-    }
+    ffio_free_dyn_buf(&asf->pktbuf);
     av_freep(&asf->buf);
     av_free(asf);
 }
@@ -296,7 +299,7 @@ RTPDynamicProtocolHandler ff_ms_rtp_ ## n ## _handler = { \
     .codec_id         = AV_CODEC_ID_NONE, \
     .priv_data_size   = sizeof(PayloadContext), \
     .parse_sdp_a_line = asfrtp_parse_sdp_line, \
-    .free             = asfrtp_free_context, \
+    .close            = asfrtp_close_context, \
     .parse_packet     = asfrtp_parse_packet,   \
 }