[vlc-devel] [PATCH 10/21] input/stream: stream-fragments: add stream_CopyStateFragments
Filip Roséen
filip at atch.se
Sun Jul 31 22:42:19 CEST 2016
This commit implements stream_CopyStateFragments, an internal function
only accessible by the core. The function will be used to properly
copy the fragment state from one stream to another, as is required
when:
- appending stream_filters to the accessor-chain
- creating the stream-wrapper that is present for every accessor
we create.
---
src/input/stream.c | 24 ++++++++++++++++++++++++
src/input/stream.h | 16 ++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/src/input/stream.c b/src/input/stream.c
index 0113863..2817add 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -864,6 +864,30 @@ char* vlc_stream_PopFragment( stream_t * s )
return fragment;
}
+int stream_CopyFragmentState( stream_t * dst, stream_t * src )
+{
+ stream_priv_t * priv_src = (stream_priv_t*)src;
+ stream_priv_t * priv_dst = (stream_priv_t*)dst;
+
+ assert( priv_dst->fragments.data == NULL );
+ assert( priv_dst->fragments.tokens == 0 );
+
+ for( size_t i = 0; i < priv_src->fragments.tokens; ++i )
+ {
+ TAB_APPEND(
+ priv_dst->fragments.tokens,
+ priv_dst->fragments.data,
+ strdup( priv_src->fragments.data[i] ) );
+
+ if( unlikely( !priv_dst->fragments.data[i] ) )
+ return VLC_EGENERIC;
+ }
+
+ priv_dst->fragments.offset = priv_src->fragments.offset;
+
+ return VLC_SUCCESS;
+}
+
static int EscapeFragment( char** out, char const* data )
{
size_t out_len = 0;
diff --git a/src/input/stream.h b/src/input/stream.h
index 5db5732..88287b0 100644
--- a/src/input/stream.h
+++ b/src/input/stream.h
@@ -55,4 +55,20 @@ stream_t *stream_FilterChainNew( stream_t *p_source, const char *psz_chain );
char *get_path(const char *location);
+/**
+ * \ingroup stream_fragments_internals
+ * \internal
+ *
+ * This function will copy the internal \ref stream_fragments state of the
+ * stream referred to by \p src to the stream referred to by \p dst.
+ *
+ * \pre \p dst must not refer to a stream created by ::vlc_stream_CommonNewMRL.
+ *
+ * \param dst the destination stream
+ * \param src the source stream
+ *
+ * \return VLC_SUCCESS on success, a negative value on error
+ **/
+int stream_CopyFragmentState( stream_t * dst, stream_t * src );
+
#endif
--
2.9.2
More information about the vlc-devel
mailing list