[vlc-commits] stream_extractor: add vlc_stream_extractor_Attach

Filip Roséen git at videolan.org
Tue Dec 6 15:58:28 CET 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Tue Nov 22 00:50:36 2016 +0100| [709924819e41ace9f7c09f00badd76c9c7a7a924] | committer: Thomas Guillem

stream_extractor: add vlc_stream_extractor_Attach

The documentation associated with these changes should explain what
the function does in detail, and why it is necessary. In short the
function simply tries to attach a stream-extractor to a stream_t.

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 include/vlc_stream_extractor.h | 27 +++++++++++++++++++++++++++
 src/input/stream_extractor.c   | 30 ++++++++++++++++++++++++++++++
 src/libvlccore.sym             |  1 +
 3 files changed, 58 insertions(+)

diff --git a/include/vlc_stream_extractor.h b/include/vlc_stream_extractor.h
index 1fe13b4..0d0e63e 100644
--- a/include/vlc_stream_extractor.h
+++ b/include/vlc_stream_extractor.h
@@ -87,6 +87,33 @@ struct stream_extractor_t {
 typedef struct stream_extractor_t stream_extractor_t;
 
 /**
+ * Construct a new stream_extractor-based stream
+ *
+ * This function is used to attach a stream to an already existing
+ * stream, where the underlying, attached, stream is a
+ * stream_extractor.
+ *
+ * If \p identifier is `NULL`, `*stream` is guaranteed to refer to a
+ * directory, otherwise \p identifier denotes the specific subentry
+ * that one would like to access within the stream.
+ *
+ * If \p identifier is not NULL, `*stream` will refer to data for the
+ * entity in question.
+ *
+ * \param[out] stream a pointer-to-pointer to stream, `*stream` will
+ *             refer to the attached stream on success, and left
+ *             untouched on failure.
+ * \param identifier NULL or a c-style string referring to the desired entity
+ * \param module_name NULL or an explicit stream-extractor module name
+ *
+ * \return VLC_SUCCESS if a stream-extractor was successfully
+ *         attached, an error-code on failure.
+ **/
+
+VLC_API int vlc_stream_extractor_Attach( stream_t** source,
+                                         char const* identifier,
+                                         char const* module_name );
+/**
  * @}
  */
 
diff --git a/src/input/stream_extractor.c b/src/input/stream_extractor.c
index 523e17e..82b04cc 100644
--- a/src/input/stream_extractor.c
+++ b/src/input/stream_extractor.c
@@ -189,6 +189,36 @@ se_InitStream( struct stream_extractor_private* priv, stream_t* source )
     return VLC_SUCCESS;
 }
 
+int
+vlc_stream_extractor_Attach( stream_t** source, char const* identifier,
+                             char const* module_name )
+{
+    struct stream_extractor_private* priv = vlc_custom_create(
+        (*source)->obj.parent, sizeof( *priv ), "stream_extractor" );
+
+    if( unlikely( !priv ) )
+        return VLC_ENOMEM;
+
+    priv->public.identifier = identifier ? strdup( identifier ) : NULL;
+
+    if( unlikely( identifier && !priv->public.identifier ) )
+        goto error;
+
+    priv->public.source = *source;
+    priv->module = module_need( &priv->public, "stream_extractor",
+                                module_name, true );
+
+    if( !priv->module || se_InitStream( priv, *source ) )
+        goto error;
+
+    *source = priv->stream;
+    return VLC_SUCCESS;
+
+error:
+    se_Release( priv );
+    return VLC_EGENERIC;
+}
+
 /**
  * @}
  **/
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 4e08ad6..cdb8f31 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -395,6 +395,7 @@ spu_ChangeFilters
 spu_Render
 spu_RegisterChannel
 spu_ClearChannel
+vlc_stream_extractor_Attach
 vlc_stream_Block
 vlc_stream_CommonNew
 vlc_stream_Delete



More information about the vlc-commits mailing list