[vlc-devel] [PATCH 1/1] dvdnav: add external access module support
Thomas Guillem
tom at gllm.fr
Fri Oct 17 17:47:46 CEST 2014
Use the following url: "dvd://http://" to open a DVD iso via http.
---
modules/access/dvdnav.c | 69 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 61 insertions(+), 8 deletions(-)
diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index 858aab7..ab8dbbe 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -108,6 +108,7 @@ vlc_module_end ()
struct demux_sys_t
{
dvdnav_t *dvdnav;
+ stream_t *stream;
/* */
bool b_reset_pcr;
@@ -175,6 +176,26 @@ static int EventIntf( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
+ * dvdnav stream callbacks
+ *****************************************************************************/
+static int stream_cb_seek( void *s, uint64_t pos )
+{
+ return stream_Seek( (stream_t *)s, pos );
+}
+
+static int stream_cb_read( void *s, void* buffer, int size )
+{
+ return stream_Read( (stream_t *)s, buffer, size );
+}
+
+static dvdnav_stream_cb stream_cb =
+{
+ .pf_seek = stream_cb_seek,
+ .pf_read = stream_cb_read,
+ .pf_readv = NULL,
+};
+
+/*****************************************************************************
* DemuxOpen:
*****************************************************************************/
static int Open( vlc_object_t *p_this )
@@ -182,6 +203,7 @@ static int Open( vlc_object_t *p_this )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
dvdnav_t *p_dvdnav;
+ stream_t *p_stream;
int i_angle;
char *psz_file;
char *psz_code;
@@ -191,16 +213,31 @@ static int Open( vlc_object_t *p_this )
&& !strncmp(p_demux->psz_access, "dvd", 3) )
forced = true;
- if( !p_demux->psz_file || !*p_demux->psz_file )
+ if( strstr( p_demux->psz_location, "://" ) != NULL )
+ {
+ /*
+ * Try to open dvd*://full_url.
+ * Example with dvdnav://http://www.example.com/iso
+ * psz_location is http://www.example.com/iso
+ * and stream_UrlNew with return a http stream_t.
+ */
+ psz_file = NULL;
+ p_stream = stream_UrlNew( p_this, p_demux->psz_location );
+ }
+ else if( !p_demux->psz_file || !*p_demux->psz_file )
{
/* Only when selected */
if( !forced )
return VLC_EGENERIC;
psz_file = var_InheritString( p_this, "dvd" );
+ p_stream = NULL;
}
else
+ {
psz_file = strdup( p_demux->psz_file );
+ p_stream = NULL;
+ }
#if defined( _WIN32 ) || defined( __OS2__ )
if( psz_file != NULL )
@@ -213,21 +250,32 @@ static int Open( vlc_object_t *p_this )
else
psz_file = strdup("");
#endif
- if( unlikely(psz_file == NULL) )
+ if( unlikely(psz_file == NULL && p_stream == NULL ) )
return VLC_EGENERIC;
/* Try some simple probing to avoid going through dvdnav_open too often */
- if( !forced && ProbeDVD( psz_file ) != VLC_SUCCESS )
+ if( !forced && psz_file != NULL && ProbeDVD( psz_file ) != VLC_SUCCESS )
{
free( psz_file );
return VLC_EGENERIC;
}
- /* Open dvdnav */
- const char *psz_path = ToLocale( psz_file );
- if( dvdnav_open( &p_dvdnav, psz_path ) != DVDNAV_STATUS_OK )
- p_dvdnav = NULL;
- LocaleFree( psz_path );
+ if( p_stream != NULL )
+ {
+ /* Open dvdnav */
+ if( dvdnav_open_stream( &p_dvdnav,
+ p_stream, &stream_cb ) != DVDNAV_STATUS_OK )
+ p_dvdnav = NULL;
+ }
+ else
+ {
+ /* Open dvdnav */
+ const char *psz_path = ToLocale( psz_file );
+ if( dvdnav_open( &p_dvdnav, psz_path ) != DVDNAV_STATUS_OK )
+ p_dvdnav = NULL;
+ LocaleFree( psz_path );
+ }
+
if( p_dvdnav == NULL )
{
msg_Warn( p_demux, "cannot open DVD (%s)", psz_file);
@@ -239,6 +287,7 @@ static int Open( vlc_object_t *p_this )
/* Fill p_demux field */
DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
p_sys->dvdnav = p_dvdnav;
+ p_sys->stream = p_stream;
p_sys->b_reset_pcr = false;
ps_track_init( p_sys->tk );
@@ -419,6 +468,10 @@ static void Close( vlc_object_t *p_this )
TAB_CLEAN( p_sys->i_title, p_sys->title );
dvdnav_close( p_sys->dvdnav );
+
+ if( p_sys->stream != NULL )
+ stream_Delete( p_sys->stream );
+
free( p_sys );
}
--
2.1.0
More information about the vlc-devel
mailing list