[vlc-devel] [PATCH 3/6] vlc_stream: add vlc_stream_NewMRL
Filip Roséen
filip at atch.se
Fri Mar 17 11:55:40 CET 2017
--
When replying to Hugo I noticed that the patch in which
this one is a reply to sadly has some changes that should have been in the
patch mentioned here:
- https://mailman.videolan.org/pipermail/vlc-devel/2017-March/112261.html
This patch is how it is supposed to look, sorry for the inconvenience.
---
include/vlc_stream.h | 16 ++++++++++++++++
src/input/stream.c | 27 +++++++++++++++++++++++++++
src/libvlccore.sym | 1 +
3 files changed, 44 insertions(+)
diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index 3a6d6ccd0e..55350d6b30 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -350,6 +350,22 @@ VLC_USED;
#define vlc_stream_NewURL(a, b) vlc_stream_NewURL(VLC_OBJECT(a), b)
/**
+ * Create a stream_t reading from a \ref MRL.
+ * You must delete it using vlc_stream_Delete.
+ *
+ * \warning This function shall only be used when MRL functionality is
+ * explicitly needed (such as when referring to items within an
+ * archive). \ref vlc_stream_NewURL shall be used where applicable.
+ *
+ * \param obj the parent of the requested stream
+ * \param mrl the mrl for which the stream_t should be created
+ * \return NULL on error, pointer to stream_t on success
+ */
+VLC_API stream_t * vlc_stream_NewMRL(vlc_object_t *obj, const char *mrl)
+VLC_USED;
+#define vlc_stream_NewMRL(a, b) vlc_stream_NewMRL(VLC_OBJECT(a), b)
+
+/**
* \defgroup stream_fifo FIFO stream
* In-memory anonymous pipe
@{
diff --git a/src/input/stream.c b/src/input/stream.c
index f63ca1fe53..063daa4c95 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -37,9 +37,11 @@
#include <vlc_access.h>
#include <vlc_charset.h>
#include <vlc_interrupt.h>
+#include <vlc_stream_extractor.h>
#include <libvlc.h>
#include "stream.h"
+#include "mrl_helpers.h"
typedef struct stream_priv_t
{
@@ -133,6 +135,31 @@ stream_t *(vlc_stream_NewURL)(vlc_object_t *p_parent, const char *psz_url)
return s;
}
+stream_t *(vlc_stream_NewMRL)(vlc_object_t* parent, const char* mrl )
+{
+ stream_t* stream = vlc_stream_NewURL( parent, mrl );
+
+ if( stream == NULL )
+ return NULL;
+
+ char const* anchor = strchr( mrl, '#' );
+
+ if( anchor == NULL )
+ anchor = "#";
+
+ char const* extra;
+ if( stream_extractor_AttachParsed( &stream, anchor + 1, &extra ) )
+ {
+ msg_Err( parent, "unable to open %s", mrl );
+ return NULL;
+ }
+
+ if( extra && *extra )
+ msg_Warn( parent, "ignoring extra fragment data: %s", extra );
+
+ return stream;
+}
+
/**
* Read from the stream until first newline.
* \param s Stream handle to read from
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 8c4d6cd2e7..79a034d153 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -410,6 +410,7 @@ vlc_stream_ReadLine
vlc_stream_ReadPartial
vlc_stream_Seek
vlc_stream_Tell
+vlc_stream_NewMRL
vlc_stream_NewURL
vlc_stream_vaControl
vlc_stream_ReadDir
--
2.12.0
More information about the vlc-devel
mailing list