[vlc-devel] [PATCH 06/21] input/stream: stream-fragments: add vlc_stream_CreateFragmentMRL

Denis Charmet typx at dinauz.org
Mon Aug 1 11:06:16 CEST 2016


Hi,

On 2016-07-31 22:42, Filip Roséen wrote:
> If an implementation implements functionality such as that associated
> with "stream_t.pf_readdir", it will need to be able to generate MRLs
> for the entries within.
> 
> This commit adds the function "vlc_stream_CreateFragmentMRL"; see the
> documentation for more information.
> ---
>  include/vlc_stream.h | 15 +++++++++++++++
>  src/input/stream.c   | 21 +++++++++++++++++++++
>  src/libvlccore.sym   |  1 +
>  3 files changed, 37 insertions(+)
> 
> diff --git a/include/vlc_stream.h b/include/vlc_stream.h
> index e81005b..0771b76 100644
> --- a/include/vlc_stream.h
> +++ b/include/vlc_stream.h
> @@ -534,6 +534,21 @@ do { \
>   **/
> 
>  /**
> + * \ingroup stream_fragments
> + *
> + * This function will create an MRL that will refer to an entity 
> named \p
> + * resource that logically exists within the stream referred to by \p 
> s.
> + *
> + * See ::vlc_stream_PopFragment for more information.
> + *
> + * \note It is the responsibility of the caller to free the returned 
> value.
> + * \param s the stream
> + * \param resource the resource which the MRL shall refer to
> + * \return the created MRL, or NULL on error
> + **/
> +VLC_API char* vlc_stream_CreateFragmentedMRL( stream_t * s, char
> const * resource );
> +
> +/**
>   * @}
>   */
> 
> diff --git a/src/input/stream.c b/src/input/stream.c
> index 304dd33..8b7b9a3 100644
> --- a/src/input/stream.c
> +++ b/src/input/stream.c
> @@ -751,6 +751,27 @@ int vlc_stream_ReadDir( stream_t *s,
> input_item_node_t *p_node )
>      return s->pf_readdir( s, p_node );
>  }
> 
> +char* vlc_stream_CreateFragmentedMRL( stream_t* s, char const * 
> fragment )
> +{
> +    stream_priv_t *priv = (stream_priv_t*)s;
> +
> +    size_t   offset = priv->fragments.offset;
> +    char**     data = priv->fragments.data;
> +    char* mrl_cache = data[offset - 1];
> +
> +    char* payload;
> +    char* result;
> +
> +    if( PrepareFragment( &payload, fragment, offset ) )

You might want to make sure that fragment is not NULL else there will 
be a segfault in EscapeFragment.

> +        return NULL;
> +
> +    int ret = asprintf( &result, "%s%s", mrl_cache, payload );
> +
> +    free( payload );
> +
> +    return ret != -1 ? result : NULL;
> +}
> +
>  static int EscapeFragment( char** out, char const* data )
>  {
>      size_t out_len = 0;
> diff --git a/src/libvlccore.sym b/src/libvlccore.sym
> index ae86025..463efd1 100644
> --- a/src/libvlccore.sym
> +++ b/src/libvlccore.sym
> @@ -403,6 +403,7 @@ spu_RegisterChannel
>  spu_ClearChannel
>  vlc_stream_Block
>  vlc_stream_CommonNew
> +vlc_stream_CreateFragmentedMRL
>  vlc_stream_Delete
>  vlc_stream_Eof
>  vlc_stream_FilterNew

Regards,
-- 
Denis Charmet - TypX
Le mauvais esprit est un art de vivre


More information about the vlc-devel mailing list