]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mmsh.c
rtspenc: Check the return value from ffio_open_dyn_packet_buf
[ffmpeg] / libavformat / mmsh.c
index 6ea1592d42cac9121343792a91357c3008572238..5e9d0bc1345eb07274ce5afb200487fe07aaf00b 100644 (file)
@@ -68,7 +68,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 +216,9 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
     char httpname[256], path[256], host[128], location[1024];
     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(location, uri, sizeof(location));
@@ -249,7 +245,7 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
              host, port, mmsh->request_seq++);
     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;
     }
@@ -262,9 +258,9 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
     // 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,
-                    &h->interrupt_callback) < 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)
@@ -296,7 +292,7 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
     av_dlog(NULL, "out_buffer is %s", 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;
     }
@@ -363,10 +359,10 @@ static int mmsh_read(URLContext *h, uint8_t *buf, int size)
 }
 
 URLProtocol ff_mmsh_protocol = {
-    .name      = "mmsh",
-    .url_open  = mmsh_open,
-    .url_read  = mmsh_read,
-    .url_write = NULL,
-    .url_seek  = NULL,
-    .url_close = mmsh_close,
+    .name           = "mmsh",
+    .url_open       = mmsh_open,
+    .url_read       = mmsh_read,
+    .url_close      = mmsh_close,
+    .priv_data_size = sizeof(MMSHContext),
+    .flags          = URL_PROTOCOL_FLAG_NETWORK,
 };