Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

playlist.c

00001 /*****************************************************************************
00002  * playlist.c :  Playlist import module
00003  *****************************************************************************
00004  * Copyright (C) 2004 the VideoLAN team
00005  * $Id: playlist.c 12821 2005-10-11 17:16:13Z zorglub $
00006  *
00007  * Authors: Clément Stenac <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 #include <vlc/vlc.h>
00028 #include <vlc/input.h>
00029 #include <vlc_playlist.h>
00030 
00031 #include "playlist.h"
00032 
00033 /*****************************************************************************
00034  * Module descriptor
00035  *****************************************************************************/
00036 #define AUTOSTART_TEXT N_( "Auto start" )
00037 #define AUTOSTART_LONGTEXT N_( "Automatically start the playlist when " \
00038     "it's loaded.\n" )
00039 
00040 vlc_module_begin();
00041     add_shortcut( "playlist" );
00042     set_category( CAT_INPUT );
00043     set_subcategory( SUBCAT_INPUT_DEMUX );
00044 
00045     add_bool( "playlist-autostart", 1, NULL, AUTOSTART_TEXT, AUTOSTART_LONGTEXT,
00046               VLC_FALSE );
00047 
00048     set_shortname( _("Playlist") );
00049     set_description( _("Playlist") );
00050     add_shortcut( "old-open" );
00051     set_capability( "demux2", 10 );
00052     set_callbacks( E_(Import_Old), NULL );
00053 #if 0
00054     add_submodule();
00055         set_description( _("Native playlist import") );
00056         add_shortcut( "playlist" );
00057         add_shortcut( "native-open" );
00058         set_capability( "demux2", 10 );
00059         set_callbacks( E_(Import_Native), E_(Close_Native) );
00060 #endif
00061     add_submodule();
00062         set_description( _("M3U playlist import") );
00063         add_shortcut( "m3u-open" );
00064         set_capability( "demux2", 10 );
00065         set_callbacks( E_(Import_M3U), E_(Close_M3U) );
00066     add_submodule();
00067         set_description( _("PLS playlist import") );
00068         add_shortcut( "pls-open" );
00069         set_capability( "demux2", 10 );
00070         set_callbacks( E_(Import_PLS), E_(Close_PLS) );
00071     add_submodule();
00072         set_description( _("B4S playlist import") );
00073         add_shortcut( "b4s-open" );
00074         add_shortcut( "shout-b4s" );
00075         set_capability( "demux2", 10 );
00076         set_callbacks( E_(Import_B4S), E_(Close_B4S) );
00077     add_submodule();
00078         set_description( _("DVB playlist import") );
00079         add_shortcut( "dvb-open" );
00080         set_capability( "demux2", 10 );
00081         set_callbacks( E_(Import_DVB), E_(Close_DVB) );
00082 vlc_module_end();
00083 
00084 
00089 char *E_(FindPrefix)( demux_t *p_demux )
00090 {
00091     char *psz_name;
00092     char *psz_path = strdup( p_demux->psz_path );
00093 
00094 #ifndef WIN32
00095     psz_name = strrchr( psz_path, '/' );
00096 #else
00097     psz_name = strrchr( psz_path, '\\' );
00098     if( !psz_name ) psz_name = strrchr( psz_path, '/' );
00099 #endif
00100     if( psz_name ) psz_name[1] = '\0';
00101     else *psz_path = '\0';
00102 
00103     return psz_path;
00104 }
00105 
00110 char *E_(ProcessMRL)( char *psz_mrl, char *psz_prefix )
00111 {
00112     /* Check for a protocol name.
00113      * for URL, we should look for "://"
00114      * for MRL (Media Resource Locator) ([[<access>][/<demux>]:][<source>]),
00115      * we should look for ":", so we end up looking simply for ":"
00116      * PB: on some file systems, ':' are valid characters though */
00117 
00118     /* Simple cases first */
00119     if( !psz_mrl || !*psz_mrl ) return NULL;
00120     if( !psz_prefix || !*psz_prefix ) return strdup( psz_mrl );
00121 
00122     /* Check if the line specifies an absolute path */
00123     if( *psz_mrl == '/' || *psz_mrl == '\\' ) return strdup( psz_mrl );
00124 
00125     /* Check if the line specifies an mrl/url
00126      * (and on win32, contains a drive letter) */
00127     if( strchr( psz_mrl, ':' ) ) return strdup( psz_mrl );
00128 
00129     /* This a relative path, prepend the prefix */
00130     asprintf( &psz_mrl, "%s%s", psz_prefix, psz_mrl );
00131     return psz_mrl;
00132 }
00133 
00134 vlc_bool_t E_(FindItem)( demux_t *p_demux, playlist_t *p_playlist,
00135                      playlist_item_t **pp_item )
00136 {
00137      vlc_bool_t b_play = var_CreateGetBool( p_demux, "playlist-autostart" );
00138 
00139      if( b_play && p_playlist->status.p_item &&
00140              &p_playlist->status.p_item->input ==
00141                 ((input_thread_t *)p_demux->p_parent)->input.p_item )
00142      {
00143          msg_Dbg( p_playlist, "starting playlist playback" );
00144          *pp_item = p_playlist->status.p_item;
00145          b_play = VLC_TRUE;
00146      }
00147      else
00148      {
00149          input_item_t *p_current = ( (input_thread_t*)p_demux->p_parent)->
00150                                                         input.p_item;
00151          *pp_item = playlist_LockItemGetByInput( p_playlist, p_current );
00152          if( !*pp_item )
00153          {
00154              msg_Dbg( p_playlist, "unable to find item in playlist");
00155          }
00156          msg_Dbg( p_playlist, "not starting playlist playback");
00157          b_play = VLC_FALSE;
00158      }
00159      return b_play;
00160 }

Generated on Tue Dec 20 10:14:35 2005 for vlc-0.8.4a by  doxygen 1.4.2