vlc | branch: master | Filip Roséen <[email protected]> | Fri Mar 17 11:48:00 2017 +0100| [c04c51616e83b939394e1ca160875d2436c54afc] | committer: Hugo Beauzée-Luyssen
input/stream: add stream_extractor_AttachedParsed This function will be used by entities who would otherwise have to manually attach stream-extractors to a stream through use of mrl_FragmentSplit and repeated use of vlc_stream_extractor_Attach. As this handles both, it will be prevent reimplementing the same functionality for cases where this is required. Signed-off-by: Hugo Beauzée-Luyssen <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c04c51616e83b939394e1ca160875d2436c54afc --- src/input/stream.h | 29 +++++++++++++++++++++++++++++ src/input/stream_extractor.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/input/stream.h b/src/input/stream.h index 5db5732f40..97d1957b26 100644 --- a/src/input/stream.h +++ b/src/input/stream.h @@ -53,6 +53,35 @@ stream_t *stream_FilterAutoNew( stream_t *source ) VLC_USED; */ stream_t *stream_FilterChainNew( stream_t *p_source, const char *psz_chain ); +/** + * Attach \ref stream_extractor%s according to specified data + * + * This function will parse the passed data, and try to attach a \ref + * stream_extractor for each specified entity as per the fragment specification + * associated with a \ref mrl, + * + * \warning The data in `*stream` can be modified even if this function only + * locates some of the entities specified in `psz_data`. It is up to + * the caller to free the resource referred to by `*stream`, no matter + * what this function returns. + * + * \warning Please see \ref vlc_stream_extractor_Attach for a function that + * will not modify the passed stream upon failure. \ref + * stream_extractor_AttachParsed shall only be used when the caller + * only cares about the stream on successful attachment of **all** + * stream-extractors referred to by `psz_data`, something which is not + * guaranteed. + * + * \param[out] source a pointer-to-pointer to stream where the attached + * stream-extractor will be applied. `*stream` will refer + * to the last successful attachment. + * \param[out] out_extra `*out_extra` will point to any additional data + * in `psz_data` that does not specify an entity (if any). + * \return VLC_SUCCESS on success, an error-code on failure + **/ +int stream_extractor_AttachParsed( stream_t** stream, const char* psz_data, + char const** out_extra ); + char *get_path(const char *location); #endif diff --git a/src/input/stream_extractor.c b/src/input/stream_extractor.c index 128c2a0ca9..29369dd2cc 100644 --- a/src/input/stream_extractor.c +++ b/src/input/stream_extractor.c @@ -337,6 +337,35 @@ vlc_stream_extractor_Attach( stream_t** source, char const* identifier, return StreamExtractorAttach( source, identifier, module_name ); } +int +stream_extractor_AttachParsed( stream_t** source, char const* data, + char const** out_extra ) +{ + vlc_array_t identifiers; + + if( mrl_FragmentSplit( &identifiers, out_extra, data ) ) + return VLC_EGENERIC; + + size_t count = vlc_array_count( &identifiers ); + size_t idx = 0; + + while( idx < count ) + { + char* id = vlc_array_item_at_index( &identifiers, idx ); + + if( vlc_stream_extractor_Attach( source, id, NULL ) ) + break; + + ++idx; + } + + for( size_t i = 0; i < count; ++i ) + free( vlc_array_item_at_index( &identifiers, i ) ); + vlc_array_clear( &identifiers ); + + return idx == count ? VLC_SUCCESS : VLC_EGENERIC; +} + char* vlc_stream_extractor_CreateMRL( stream_directory_t* directory, char const* subentry ) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
