[vlc-devel] [PATCH 15/21] input/{stream, access}: add function stream_AccessDummyNew
Filip Roséen
filip at atch.se
Sun Jul 31 22:42:24 CEST 2016
This commits adds the possibility to create a dummy stream that can be
used as the source for entities that needs one for functionality not
related to reads.
As stream-fragment data is associated with a stream, this new
functionality especially comes in handy to associate a stream_t with
an access_demux.
---
src/input/access.c | 37 +++++++++++++++++++++++++++++++++++++
src/input/stream.h | 6 ++++++
2 files changed, 43 insertions(+)
diff --git a/src/input/access.c b/src/input/access.c
index 65b3ce8..9cf68fc 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -171,6 +171,29 @@ int access_vaDirectoryControlHelper( access_t *p_access, int i_query, va_list ar
return VLC_SUCCESS;
}
+static ssize_t AStreamNoRead(stream_t* s, void* buf, size_t len )
+{
+ VLC_UNUSED( s ); VLC_UNUSED( buf ); VLC_UNUSED( len );
+ return 0;
+}
+
+static int AStreamNoControl(stream_t* s, int i_query, va_list args )
+{
+ VLC_UNUSED( s ); VLC_UNUSED( i_query ); VLC_UNUSED( args );
+ return VLC_EGENERIC;
+}
+
+static int AStreamNoSeek(stream_t* s, uint64_t pos )
+{
+ VLC_UNUSED( s ); VLC_UNUSED( pos );
+ return VLC_EGENERIC;
+}
+
+static void AStreamNoDestroy( stream_t* s )
+{
+ VLC_UNUSED( s );
+}
+
static int AStreamNoReadDir(stream_t *s, input_item_node_t *p_node)
{
(void) s; (void) p_node;
@@ -321,6 +344,20 @@ stream_t *stream_AccessNew(vlc_object_t *parent, input_thread_t *input,
return s;
}
+stream_t* stream_AccessDummyNew( vlc_object_t* parent,
+ input_thread_t* p_input, const char* mrl )
+{
+ stream_t* s = vlc_stream_CommonNewMRL( parent, mrl, AStreamNoDestroy );
+
+ s->pf_read = AStreamNoRead;
+ s->pf_seek = AStreamNoSeek;
+ s->pf_control = AStreamNoControl;
+
+ s->p_input = p_input;
+
+ return s;
+}
+
static int compar_type(input_item_t *p1, input_item_t *p2)
{
if (p1->i_type != p2->i_type)
diff --git a/src/input/stream.h b/src/input/stream.h
index 88287b0..c2eb62a 100644
--- a/src/input/stream.h
+++ b/src/input/stream.h
@@ -37,6 +37,12 @@ void stream_CommonDelete( stream_t *s );
stream_t *stream_AccessNew(vlc_object_t *, input_thread_t *, bool, const char *);
/**
+ * Function used to create a stream_t that does not support
+ * any read operations, but will still be valid in terms of state.
+ */
+stream_t* stream_AccessDummyNew( vlc_object_t*, input_thread_t*, const char*);
+
+/**
* Automatically wraps a stream with any applicable stream filter.
* @return the (outermost/downstream) stream filter; if no filters were added,
* then the function return the source parameter.
--
2.9.2
More information about the vlc-devel
mailing list