<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>The current status of these patches, disregarding the now superseeded once, can easily be viewed at <a href="https://patches.videolan.org/bundle/FilipRoseen-refp/stream-extractor_newMRL/">bundle: FilipRoseen-refp / stream-extractor_newMRL</a>. I hope the recently created bundle makes it easier to see the changes, than jumping between messages here on <code>vlc-devel</code> (especially since I managed to confuse the content of <code>--in-reply-to</code> when invoking <code>git send-email</code>, making at least one patch be a reply to the wrong post).</p>
<p>Thanks.</p>
<p>On 2017-03-17 03:22, Filip Roséen wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> 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.
 ---
  src/input/stream.h           | 26 ++++++++++++++++++++++++++
  src/input/stream_extractor.c | 35 +++++++++++++++++++++++++++++++++++
  2 files changed, 61 insertions(+)

 diff --git a/src/input/stream.h b/src/input/stream.h
 index 5db5732f40..2f5ca8b9b7 100644
 --- a/src/input/stream.h
 +++ b/src/input/stream.h
 @@ -53,6 +53,32 @@ stream_t *stream_FilterAutoNew( stream_t *source ) VLC_USED;
   */
  stream_t *stream_FilterChainNew( stream_t *p_source, const char *psz_chain );

 +/**
 + * This function will parse the passed data, and try to attach
 + * stream-extractors for each specified entity as per \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 00cf5ee624..038912881c 100644
 --- a/src/input/stream_extractor.c
 +++ b/src/input/stream_extractor.c
 @@ -340,6 +340,41 @@ 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;
 +
 +    while( vlc_array_count( &identifiers ) )
 +    {
 +        char* id = vlc_array_item_at_index( &identifiers, 0 );
 +
 +        if( vlc_stream_extractor_Attach( source, id, NULL ) )
 +            break;
 +
 +        vlc_array_remove( &identifiers, 0 );
 +        free( id );
 +    }
 +
 +    size_t remaining = vlc_array_count( &identifiers );
 +
 +    for( size_t i = 0; i < remaining; ++i )
 +        free( vlc_array_item_at_index( &identifiers, i ) );
 +    vlc_array_clear( &identifiers );
 +
 +    if( remaining == 0 )
 +    {
 +        vlc_stream_extractor_Attach( source, NULL, NULL );
 +        return VLC_SUCCESS;
 +    }
 +
 +    return remaining == 0 ? VLC_SUCCESS : VLC_EGENERIC;
 +}
 +
  char*
  vlc_stream_extractor_CreateMRL( stream_directory_t* directory,
                                  char const* subentry )
 -- 
 2.12.0</code></pre>
</blockquote>
</body>
</html>