Commit a1ae9f4b authored by Filip Roséen's avatar Filip Roséen Committed by Hugo Beauzée-Luyssen

vlc_stream: add vlc_stream_NewMRL

Signed-off-by: default avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent c04c5161
......@@ -89,6 +89,29 @@ typedef struct stream_directory_t {
} stream_directory_t;
/**
* Create a stream for the data referred to by a \ref mrl
*
* This function will create a \ref stream that reads from the specified \ref
* mrl, potentially making use of \ref stream_extractor%s to access named
* entities within the data read from the original source.
*
* - See the \ref mrl specification for further information.
* - The returned resource shall be deleted through \ref vlc_stream_Delete.
*
* \warning This function is only be used when \ref mrl functionality is
* explicitly needed, \ref vlc_stream_NewURL shall be used where
* applicable (and functionality associated with \ref MRL is not
* wanted nor needed).
*
* \param obj the owner of the requested stream
* \param mrl the mrl for which the stream_t should be created
* \return `NULL` on error, a pointer to \ref stream_t on success.
**/
VLC_API stream_t * vlc_stream_NewMRL(vlc_object_t *obj, const char *mrl)
VLC_USED;
#define vlc_stream_NewMRL(a, b) vlc_stream_NewMRL(VLC_OBJECT(a), b)
/**
* Create a relative MRL for the associated entity
*
......
......@@ -37,9 +37,11 @@
#include <vlc_access.h>
#include <vlc_charset.h>
#include <vlc_interrupt.h>
#include <vlc_stream_extractor.h>
#include <libvlc.h>
#include "stream.h"
#include "mrl_helpers.h"
typedef struct stream_priv_t
{
......@@ -133,6 +135,32 @@ stream_t *(vlc_stream_NewURL)(vlc_object_t *p_parent, const char *psz_url)
return s;
}
stream_t *(vlc_stream_NewMRL)(vlc_object_t* parent, const char* mrl )
{
stream_t* stream = vlc_stream_NewURL( parent, mrl );
if( stream == NULL )
return NULL;
char const* anchor = strchr( mrl, '#' );
if( anchor == NULL )
return stream;
char const* extra;
if( stream_extractor_AttachParsed( &stream, anchor + 1, &extra ) )
{
msg_Err( parent, "unable to open %s", mrl );
vlc_stream_Delete( stream );
return NULL;
}
if( extra && *extra )
msg_Warn( parent, "ignoring extra fragment data: %s", extra );
return stream;
}
/**
* Read from the stream until first newline.
* \param s Stream handle to read from
......
......@@ -411,6 +411,7 @@ vlc_stream_ReadLine
vlc_stream_ReadPartial
vlc_stream_Seek
vlc_stream_Tell
vlc_stream_NewMRL
vlc_stream_NewURL
vlc_stream_vaControl
vlc_stream_ReadDir
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment