X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fplaylist%2Fqtl.c;h=73aaff5590c7f9fb497f04ffb2bb0f480564a3c9;hb=922b5784b451e815c1c9626eb4537a7f6d4b9836;hp=2340ee2a3a884a1a615ab08a08108fe04ce306b3;hpb=449fd28aaf007c6411251dae9d0dbfdc65b135d1;p=vlc diff --git a/modules/demux/playlist/qtl.c b/modules/demux/playlist/qtl.c index 2340ee2a3a..73aaff5590 100644 --- a/modules/demux/playlist/qtl.c +++ b/modules/demux/playlist/qtl.c @@ -52,20 +52,11 @@ volume - 0 (mute) - 100 (max) # include "config.h" #endif -#include +#include #include #include "playlist.h" -#include "vlc_xml.h" - -struct demux_sys_t -{ - playlist_t *p_playlist; - input_item_t *p_current_input; - - xml_t *p_xml; - xml_reader_t *p_xml_reader; -}; +#include typedef enum { FULLSCREEN_NORMAL, FULLSCREEN_DOUBLE, @@ -87,39 +78,34 @@ static int Control( demux_t *p_demux, int i_query, va_list args ); /***************************************************************************** * Import_QTL: main import function *****************************************************************************/ -int E_(Import_QTL)( vlc_object_t *p_this ) +int Import_QTL( vlc_object_t *p_this ) { - DEMUX_BY_EXTENSION_MSG( ".qtl", "using QuickTime Media Link reader" ); - p_demux->p_sys->p_playlist = NULL; - p_demux->p_sys->p_xml = NULL; - p_demux->p_sys->p_xml_reader = NULL; + demux_t *p_demux = (demux_t *)p_this; + + if( !demux_IsPathExtension( p_demux, ".qtl" ) ) + return VLC_EGENERIC; + + p_demux->pf_demux = Demux; + p_demux->pf_control = Control; + msg_Dbg( p_demux, "using QuickTime Media Link reader" ); + return VLC_SUCCESS; } /***************************************************************************** * Deactivate: frees unused data *****************************************************************************/ -void E_(Close_QTL)( vlc_object_t *p_this ) +void Close_QTL( vlc_object_t *p_this ) { - demux_t *p_demux = (demux_t *)p_this; - demux_sys_t *p_sys = p_demux->p_sys; - - if( p_sys->p_playlist ) - vlc_object_release( p_sys->p_playlist ); - if( p_sys->p_xml_reader ) - xml_ReaderDelete( p_sys->p_xml, p_sys->p_xml_reader ); - if( p_sys->p_xml ) - xml_Delete( p_sys->p_xml ); - free( p_sys ); + (void)p_this; } static int Demux( demux_t *p_demux ) { - demux_sys_t *p_sys = p_demux->p_sys; - xml_t *p_xml; xml_reader_t *p_xml_reader; char *psz_eltname = NULL; input_item_t *p_input; + int i_ret = -1; /* List of all possible attributes. The only required one is "src" */ bool b_autoplay = false; @@ -137,23 +123,17 @@ static int Demux( demux_t *p_demux ) char *psz_mimetype = NULL; int i_volume = 100; - INIT_PLAYLIST_STUFF; - - p_sys->p_playlist = p_playlist; - p_sys->p_current_input = p_current_input; - - p_xml = p_sys->p_xml = xml_Create( p_demux ); - if( !p_xml ) return -1; + input_item_t *p_current_input = GetCurrentItem(p_demux); - p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s ); - if( !p_xml_reader ) return -1; - p_sys->p_xml_reader = p_xml_reader; + p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s ); + if( !p_xml_reader ) + goto error; /* check root node */ if( xml_ReaderRead( p_xml_reader ) != 1 ) { msg_Err( p_demux, "invalid file (no root node)" ); - return -1; + goto error; } if( xml_ReaderNodeType( p_xml_reader ) != XML_READER_STARTELEM || @@ -174,44 +154,30 @@ static int Demux( demux_t *p_demux ) msg_Err( p_demux, "invalid root node %i, %s", xml_ReaderNodeType( p_xml_reader ), psz_eltname ); free( psz_eltname ); - return -1; + goto error; } } free( psz_eltname ); - while( xml_ReaderNextAttr( p_sys->p_xml_reader ) == VLC_SUCCESS ) + while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) { - char *psz_attrname = xml_ReaderName( p_sys->p_xml_reader ); - char *psz_attrvalue = xml_ReaderValue( p_sys->p_xml_reader ); + char *psz_attrname = xml_ReaderName( p_xml_reader ); + char *psz_attrvalue = xml_ReaderValue( p_xml_reader ); if( !psz_attrname || !psz_attrvalue ) { free( psz_attrname ); free( psz_attrvalue ); - return -1; + goto error; } if( !strcmp( psz_attrname, "autoplay" ) ) { - if( !strcmp( psz_attrvalue, "true" ) ) - { - b_autoplay = true; - } - else - { - b_autoplay = false; - } + b_autoplay = !strcmp( psz_attrvalue, "true" ); } else if( !strcmp( psz_attrname, "controler" ) ) { - if( !strcmp( psz_attrvalue, "false" ) ) - { - b_controler = false; - } - else - { - b_controler = true; - } + b_controler = !strcmp( psz_attrvalue, "false" ); } else if( !strcmp( psz_attrname, "fullscreen" ) ) { @@ -243,14 +209,7 @@ static int Demux( demux_t *p_demux ) } else if( !strcmp( psz_attrname, "kioskmode" ) ) { - if( !strcmp( psz_attrvalue, "true" ) ) - { - b_kioskmode = true; - } - else - { - b_kioskmode = false; - } + b_kioskmode = !strcmp( psz_attrvalue, "true" ); } else if( !strcmp( psz_attrname, "loop" ) ) { @@ -278,14 +237,7 @@ static int Demux( demux_t *p_demux ) } else if( !strcmp( psz_attrname, "playeveryframe" ) ) { - if( !strcmp( psz_attrvalue, "true" ) ) - { - b_playeveryframe = true; - } - else - { - b_playeveryframe = false; - } + b_playeveryframe = !strcmp( psz_attrvalue, "true" ); } else if( !strcmp( psz_attrname, "qtnext" ) ) { @@ -294,14 +246,7 @@ static int Demux( demux_t *p_demux ) } else if( !strcmp( psz_attrname, "quitwhendone" ) ) { - if( !strcmp( psz_attrvalue, "true" ) ) - { - b_quitwhendone = true; - } - else - { - b_quitwhendone = false; - } + b_quitwhendone = !strcmp( psz_attrvalue, "true" ); } else if( !strcmp( psz_attrname, "src" ) ) { @@ -327,22 +272,22 @@ static int Demux( demux_t *p_demux ) } msg_Dbg( p_demux, "autoplay: %s (unused by VLC)", - b_autoplay==true ? "true": "false" ); + b_autoplay ? "true": "false" ); msg_Dbg( p_demux, "controler: %s (unused by VLC)", - b_controler==true?"true": "false" ); + b_controler ? "true": "false" ); msg_Dbg( p_demux, "fullscreen: %s (unused by VLC)", ppsz_fullscreen[fullscreen] ); msg_Dbg( p_demux, "href: %s", psz_href ); msg_Dbg( p_demux, "kioskmode: %s (unused by VLC)", - b_kioskmode==true?"true":"false" ); + b_kioskmode ? "true":"false" ); msg_Dbg( p_demux, "loop: %s (unused by VLC)", ppsz_loop[loop] ); msg_Dbg( p_demux, "movieid: %d (unused by VLC)", i_movieid ); msg_Dbg( p_demux, "moviename: %s", psz_moviename ); msg_Dbg( p_demux, "playeverframe: %s (unused by VLC)", - b_playeveryframe==true?"true":"false" ); + b_playeveryframe ? "true":"false" ); msg_Dbg( p_demux, "qtnext: %s", psz_qtnext ); msg_Dbg( p_demux, "quitwhendone: %s (unused by VLC)", - b_quitwhendone==true?"true":"false" ); + b_quitwhendone ? "true":"false" ); msg_Dbg( p_demux, "src: %s", psz_src ); msg_Dbg( p_demux, "mimetype: %s", psz_mimetype ); msg_Dbg( p_demux, "volume: %d (unused by VLC)", i_volume ); @@ -354,34 +299,37 @@ static int Demux( demux_t *p_demux ) } else { - p_input = input_ItemNewExt( p_sys->p_playlist, - psz_src, psz_moviename, 0, NULL, -1 ); -#define SADD_INFO( type, field ) if( field ) { input_ItemAddInfo( \ - p_input, "QuickTime Media Link", _(type), "%s", field ) ; } + input_item_node_t *p_subitems = input_item_node_Create( p_current_input ); + p_input = input_item_New( p_demux, psz_src, psz_moviename ); +#define SADD_INFO( type, field ) if( field ) { input_item_AddInfo( \ + p_input, "QuickTime Media Link", type, "%s", field ) ; } SADD_INFO( "href", psz_href ); - SADD_INFO( "mime type", psz_mimetype ); - input_ItemAddSubItem( p_current_input, p_input ); + SADD_INFO( _("Mime"), psz_mimetype ); + input_item_node_AppendItem( p_subitems, p_input ); vlc_gc_decref( p_input ); if( psz_qtnext ) { - p_input = input_ItemNewExt( p_sys->p_playlist, - psz_qtnext, NULL, 0, NULL, -1 ); - input_ItemAddSubItem( p_current_input, p_input ); + p_input = input_item_New( p_demux, psz_qtnext, NULL ); + input_item_node_AppendItem( p_subitems, p_input ); vlc_gc_decref( p_input ); } + input_item_node_PostAndDelete( p_subitems ); } - HANDLE_PLAY_AND_RELEASE; + i_ret = 0; /* Needed for correct operation of go back */ - p_sys->p_playlist = NULL; +error: + if( p_xml_reader ) + xml_ReaderDelete( p_xml_reader ); + + vlc_gc_decref(p_current_input); free( psz_href ); free( psz_moviename ); free( psz_qtnext ); free( psz_src ); free( psz_mimetype ); - - return 0; /* Needed for correct operation of go back */ + return i_ret; } static int Control( demux_t *p_demux, int i_query, va_list args )