[vlc-commits] access: handle attachment:// with vlc_stream_AttachmentNew

Thomas Guillem git at videolan.org
Fri Jul 20 17:23:10 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jul 20 16:28:54 2018 +0200| [3b767778943843ba0247fa99169988d70ba0948c] | committer: Thomas Guillem

access: handle attachment:// with vlc_stream_AttachmentNew

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3b767778943843ba0247fa99169988d70ba0948c
---

 src/input/access.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/input/access.c b/src/input/access.c
index 732837e28b..1a25d5194b 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -70,6 +70,31 @@ static void vlc_access_Destroy(stream_t *access)
 
 #define MAX_REDIR 5
 
+static stream_t *accessNewAttachment(vlc_object_t *parent,
+                                     input_thread_t *input, const char *mrl)
+{
+    if (!input)
+        return NULL;
+
+    input_attachment_t *attachment;
+    if (input_Control(input, INPUT_GET_ATTACHMENT, &attachment, mrl + 13))
+        return NULL;
+    stream_t *stream = vlc_stream_AttachmentNew(parent, attachment);
+    if (!stream)
+    {
+        vlc_input_attachment_Delete(attachment);
+        return NULL;
+    }
+    stream->psz_url = strdup(mrl);
+    if (!stream->psz_url)
+    {
+        vlc_stream_Delete(stream);
+        return NULL;
+    }
+    stream->psz_location = stream->psz_url + 13;
+    return stream;
+}
+
 /*****************************************************************************
  * access_New:
  *****************************************************************************/
@@ -80,6 +105,9 @@ static stream_t *access_New(vlc_object_t *parent, input_thread_t *input,
     char *redirv[MAX_REDIR];
     unsigned redirc = 0;
 
+    if (strncmp(mrl, "attachment://", 13) == 0)
+        return accessNewAttachment(parent, input, mrl);
+
     stream_t *access = vlc_stream_CustomNew(parent, vlc_access_Destroy,
                                             sizeof (*priv), "access");
     if (unlikely(access == NULL))



More information about the vlc-commits mailing list