]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mmsh.c
ffmpeg: check if number of input and output channels are valid.
[ffmpeg] / libavformat / mmsh.c
index f54a976e19005ddfdf13eacba9d7fff7e070ae35..e92b74fc0a5670db3800deea48ce093aad7bf1fa 100644 (file)
@@ -28,6 +28,7 @@
 #include <string.h>
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avstring.h"
+#include "libavutil/opt.h"
 #include "internal.h"
 #include "mms.h"
 #include "asf.h"
@@ -68,7 +69,6 @@ static int mmsh_close(URLContext *h)
         ffurl_close(mms->mms_hd);
     av_free(mms->streams);
     av_free(mms->asf_header);
-    av_freep(&h->priv_data);
     return 0;
 }
 
@@ -217,12 +217,9 @@ static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int tim
     char httpname[256], path[256], host[128];
     char *stream_selection = NULL;
     char headers[1024];
-    MMSHContext *mmsh;
+    MMSHContext *mmsh = h->priv_data;
     MMSContext *mms;
 
-    mmsh = h->priv_data = av_mallocz(sizeof(MMSHContext));
-    if (!h->priv_data)
-        return AVERROR(ENOMEM);
     mmsh->request_seq = h->is_streamed = 1;
     mms = &mmsh->mms;
     av_strlcpy(mmsh->location, uri, sizeof(mmsh->location));
@@ -233,7 +230,8 @@ static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int tim
         port = 80; // default mmsh protocol port
     ff_url_join(httpname, sizeof(httpname), "http", NULL, host, port, "%s", path);
 
-    if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_FLAG_READ) < 0) {
+    if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_FLAG_READ,
+                    &h->interrupt_callback) < 0) {
         return AVERROR(EIO);
     }
 
@@ -246,9 +244,9 @@ static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int tim
              CLIENTGUID
              "Connection: Close\r\n",
              host, port, mmsh->request_seq++);
-    ff_http_set_headers(mms->mms_hd, headers);
+    av_opt_set(mms->mms_hd->priv_data, "headers", headers, 0);
 
-    err = ffurl_connect(mms->mms_hd);
+    err = ffurl_connect(mms->mms_hd, NULL);
     if (err) {
         goto fail;
     }
@@ -261,8 +259,9 @@ static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int tim
     // close the socket and then reopen it for sending the second play request.
     ffurl_close(mms->mms_hd);
     memset(headers, 0, sizeof(headers));
-    if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_FLAG_READ) < 0) {
-        return AVERROR(EIO);
+    if ((err = ffurl_alloc(&mms->mms_hd, httpname, AVIO_FLAG_READ,
+                           &h->interrupt_callback)) < 0) {
+        goto fail;
     }
     stream_selection = av_mallocz(mms->stream_num * 19 + 1);
     if (!stream_selection)
@@ -293,9 +292,9 @@ static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int tim
         goto fail;
     }
     av_dlog(NULL, "out_buffer is %s", headers);
-    ff_http_set_headers(mms->mms_hd, headers);
+    av_opt_set(mms->mms_hd->priv_data, "headers", headers, 0);
 
-    err = ffurl_connect(mms->mms_hd);
+    err = ffurl_connect(mms->mms_hd, NULL);
     if (err) {
           goto fail;
     }
@@ -400,11 +399,11 @@ static int64_t mmsh_seek(URLContext *h, int64_t pos, int whence)
 }
 
 URLProtocol ff_mmsh_protocol = {
-    .name      = "mmsh",
-    .url_open  = mmsh_open,
-    .url_read  = mmsh_read,
-    .url_write = NULL,
-    .url_seek  = mmsh_seek,
-    .url_close = mmsh_close,
+    .name           = "mmsh",
+    .url_open       = mmsh_open,
+    .url_read       = mmsh_read,
+    .url_seek       = mmsh_seek,
+    .url_close      = mmsh_close,
     .url_read_seek  = mmsh_read_seek,
+    .priv_data_size = sizeof(MMSHContext),
 };