Commit 5dc722b5 authored by Clément Stenac's avatar Clément Stenac

* configure.ac : Added new folders

* New playlist import/export system:
   -export plugin in misc/playlist (contains one module for each file type)
   -open plugin = special demuxer2, that can be opened from the command
    line or the graphical interface.
  NB: the demuxer "playlist" is forced to earn speed, but this does not
  work yet, as we have a demux2

* modules/gui/wxwindows: use the new import/export.

* src/playlist/group.c : fixed boundary check

* src/playlist/item-ext.c: correctly reset stuff when clearing the playlist
parent 0bbccbb1
dnl Autoconf settings for vlc
dnl $Id: configure.ac,v 1.148 2004/01/09 18:32:03 gbazin Exp $
dnl $Id: configure.ac,v 1.149 2004/01/11 00:45:06 zorglub Exp $
AC_INIT(vlc,0.7.1-cvs)
......@@ -3586,6 +3586,7 @@ AC_CONFIG_FILES([
modules/demux/avi/Makefile
modules/demux/mp4/Makefile
modules/demux/mpeg/Makefile
modules/demux/playlist/Makefile
modules/demux/util/Makefile
modules/gui/Makefile
modules/gui/beos/Makefile
......@@ -3606,6 +3607,7 @@ AC_CONFIG_FILES([
modules/misc/memcpy/Makefile
modules/misc/network/Makefile
modules/misc/testsuite/Makefile
modules/misc/playlist/Makefile
modules/mux/Makefile
modules/mux/mpeg/Makefile
modules/packetizer/Makefile
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.101 2004/01/09 18:32:03 gbazin Exp $
* $Id: vlc_common.h,v 1.102 2004/01/11 00:45:06 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -192,6 +192,7 @@ typedef struct playlist_item_t playlist_item_t;
typedef struct playlist_group_t playlist_group_t;
typedef struct item_info_t item_info_t;
typedef struct item_info_category_t item_info_category_t;
typedef struct playlist_export_t playlist_export_t;
/* Modules */
typedef struct module_bank_t module_bank_t;
......
......@@ -2,7 +2,7 @@
* vlc_playlist.h : Playlist functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
* $Id: vlc_playlist.h,v 1.23 2004/01/10 14:24:33 hartman Exp $
* $Id: vlc_playlist.h,v 1.24 2004/01/11 00:45:06 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -56,6 +56,15 @@ struct item_info_category_t
item_info_t **pp_infos; /**< Pointer to an array of infos */
};
/**
* playlist export helper structure
*/
struct playlist_export_t
{
char *psz_filename;
FILE *p_file;
};
/**
* playlist item
* \see playlist_t
......@@ -209,8 +218,8 @@ VLC_EXPORT( int, playlist_Sort, ( playlist_t *, int, int) );
VLC_EXPORT( int, playlist_Move, ( playlist_t *, int, int ) );
/* Load/Save */
VLC_EXPORT( int, playlist_LoadFile, ( playlist_t *, const char * ) );
VLC_EXPORT( int, playlist_SaveFile, ( playlist_t *, const char * ) );
VLC_EXPORT( int, playlist_Import, ( playlist_t *, const char * ) );
VLC_EXPORT( int, playlist_Export, ( playlist_t *, const char *, const char * ) );
/**
* tell if a playlist is currently playing.
......
SOURCES_playlist = playlist.c \
old.c \
m3u.c
/*****************************************************************************
* m3u.c : M3U playlist format import
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: m3u.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <errno.h> /* ENOMEM */
/*****************************************************************************
* Local prototypes
*****************************************************************************/
int Import_M3U ( vlc_object_t * );
static int Demux( demux_t *p_demux);
static int Control( demux_t *p_demux, int i_query, va_list args );
/*****************************************************************************
* Import_Old : main import function
*****************************************************************************/
int Import_M3U( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
uint8_t *p_peek;
if( stream_Peek( p_demux->s , &p_peek, 7 ) < 7 )
{
msg_Err( p_demux, "cannot peek" );
return VLC_EGENERIC;
}
if( strncmp( p_peek, "#EXTM3U", 7 ) )
{
msg_Warn(p_demux, "m3u import module discarded: invalid file");
return VLC_EGENERIC;
}
msg_Info( p_demux, "Found valid M3U playlist file");
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
return VLC_SUCCESS;
}
static int Demux( demux_t *p_demux)
{
msg_Warn(p_demux, "Not yet implemented" );
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_demux,
VLC_OBJECT_PLAYLIST, FIND_PARENT );
p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE;
vlc_object_release( p_playlist );
return VLC_SUCCESS;
}
static int Control( demux_t *p_demux, int i_query, va_list args )
{
return VLC_EGENERIC;
}
/*****************************************************************************
* old.c : Old playlist format import
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: old.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <errno.h> /* ENOMEM */
#define PLAYLIST_FILE_HEADER "# vlc playlist file version 0.5"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
int Import_Old ( vlc_object_t * );
static int Demux( demux_t *p_demux);
static int Control( demux_t *p_demux, int i_query, va_list args );
/*****************************************************************************
* Import_Old : main import function
*****************************************************************************/
int Import_Old( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
uint8_t *p_peek;
if( stream_Peek( p_demux->s, &p_peek, 31 ) < 31 )
{
msg_Err( p_demux, "cannot peek" );
return VLC_EGENERIC;
}
if( strncmp( p_peek, PLAYLIST_FILE_HEADER , 31 ) )
{
msg_Warn(p_demux, "old import module discarded: invalid file");
return VLC_EGENERIC;
}
msg_Info( p_demux, "Found valid old playlist file");
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
return VLC_SUCCESS;
}
static int Demux( demux_t *p_demux)
{
char *psz_line;
/* Attach playlist and start reading data */
playlist_t *p_playlist;
p_playlist = (playlist_t*)vlc_object_find( p_demux,
VLC_OBJECT_PLAYLIST, FIND_PARENT );
if( !p_playlist )
{
msg_Err( p_demux, "cannot attach playlist" );
return VLC_EGENERIC;
}
p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE;
while( ( psz_line = stream_ReadLine( p_demux->s) ) != NULL )
{
if( ( psz_line[0] == '#' ) || (psz_line[0] == '\r') ||
( psz_line[0] == '\n') || (psz_line[0] == (char)0) )
{
continue;
}
/* Remove end of line */
if( psz_line[strlen(psz_line) -1 ] == '\n' ||
psz_line[strlen(psz_line) -1 ] == '\r' )
{
psz_line[ strlen(psz_line) -1 ] = (char)0;
if( psz_line[strlen(psz_line) - 1 ] == '\r' )
psz_line[strlen(psz_line) - 1 ] = (char)0;
}
playlist_Add( p_playlist, psz_line, psz_line, PLAYLIST_APPEND,
PLAYLIST_END );
free( psz_line );
}
p_demux->b_die = VLC_TRUE;
vlc_object_release( p_playlist );
return VLC_SUCCESS;
}
static int Control( demux_t *p_demux, int i_query, va_list args )
{
return VLC_EGENERIC;
}
/*****************************************************************************
* playlist.c : Playlist import module
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: playlist.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
/***************************************************************************
* Prototypes
***************************************************************************/
int Import_Old ( vlc_object_t * );
int Import_M3U ( vlc_object_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
add_shortcut( "playlist" );
set_description( _("Old playlist open") );
add_shortcut( "old-open" );
set_capability( "demux2" , 10 );
set_callbacks( Import_Old , NULL );
add_submodule();
set_description( _("M3U playlist import") );
add_shortcut( "m3u-open" );
set_capability( "demux2" , 10 );
set_callbacks( Import_M3U , NULL );
vlc_module_end();
......@@ -2,7 +2,7 @@
* playlist.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
* $Id: playlist.cpp,v 1.35 2004/01/10 03:36:03 hartman Exp $
* $Id: playlist.cpp,v 1.36 2004/01/11 00:45:06 zorglub Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
*
......@@ -86,7 +86,9 @@ enum
Search_Event,
/* controls */
ListView_Event
ListView_Event,
Browse_Event, /* For export playlist */
};
BEGIN_EVENT_TABLE(Playlist, wxFrame)
......@@ -154,6 +156,14 @@ BEGIN_EVENT_TABLE(NewGroup, wxDialog)
EVT_BUTTON( wxID_CANCEL, NewGroup::OnCancel)
END_EVENT_TABLE()
/* Event Table for the ExportPlaylist class */
BEGIN_EVENT_TABLE(ExportPlaylist, wxDialog)
EVT_BUTTON( wxID_OK, ExportPlaylist::OnOk)
EVT_BUTTON( wxID_CANCEL, ExportPlaylist::OnCancel)
EVT_BUTTON( Browse_Event, ExportPlaylist::OnBrowse)
END_EVENT_TABLE()
/*****************************************************************************
* Constructor.
*****************************************************************************/
......@@ -408,17 +418,18 @@ void Playlist::UpdateItem( int i )
{
return;
}
if( i < 0 || i > p_playlist->i_size )
if( i < 0 || i >= p_playlist->i_size || !p_playlist->pp_items[i] )
{
vlc_object_release(p_playlist);
return;
}
listview->SetItem( i, 0, wxL2U(p_playlist->pp_items[i]->psz_name) );
listview->SetItem( i, 1, wxL2U( playlist_GetInfo( p_playlist, i,
"General" , "Author" ) ) );
_("General") , _("Author") ) ) );
char *psz_group = playlist_FindGroup(p_playlist,p_playlist->
pp_items[i]->i_group);
listview->SetItem( i, 2,
wxL2U(playlist_FindGroup(p_playlist,p_playlist->
pp_items[i]->i_group) ) );
wxL2U( psz_group ? psz_group : _("Normal") ) );
if( p_playlist->pp_items[i]->b_enabled == VLC_FALSE )
{
......@@ -577,23 +588,9 @@ void Playlist::OnClose( wxCommandEvent& WXUNUSED(event) )
void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
{
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return;
}
wxFileDialog dialog( this, wxU(_("Save playlist")),
wxT(""), wxT(""), wxT("*"), wxSAVE );
if( dialog.ShowModal() == wxID_OK )
{
playlist_SaveFile( p_playlist, dialog.GetPath().mb_str() );
}
vlc_object_release( p_playlist );
ExportPlaylist *exp_pl = new ExportPlaylist( p_intf, this);
exp_pl->ShowModal();
delete exp_pl;
}
void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
......@@ -611,7 +608,7 @@ void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
if( dialog.ShowModal() == wxID_OK )
{
playlist_LoadFile( p_playlist, dialog.GetPath().mb_str() );
playlist_Import( p_playlist, dialog.GetPath().mb_str() );
}
vlc_object_release( p_playlist );
......@@ -1153,7 +1150,7 @@ int ItemChanged( vlc_object_t *p_this, const char *psz_variable,
/***************************************************************************
* NewGroup
* NewGroup Class
***************************************************************************/
NewGroup::NewGroup( intf_thread_t *_p_intf, wxWindow *_p_parent ):
wxDialog( _p_parent, -1, wxU(_("New Group")), wxDefaultPosition,
......@@ -1218,9 +1215,9 @@ void NewGroup::OnOk( wxCommandEvent& event )
{
psz_name = NULL;
}
vlc_object_release( p_playlist );
}
vlc_object_release( p_playlist );
EndModal( wxID_OK );
}
......@@ -1228,3 +1225,138 @@ void NewGroup::OnCancel( wxCommandEvent& WXUNUSED(event) )
{
EndModal( wxID_CANCEL );
}
/***************************************************************************
* Export playlist class
***************************************************************************/
ExportPlaylist::ExportPlaylist( intf_thread_t *_p_intf, wxWindow *_p_parent ):
wxDialog( _p_parent, -1, wxU(_("Export playlist")), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_FRAME_STYLE )
{
vlc_list_t *p_list;
module_t *p_module;
/* Initializations */
p_intf = _p_intf;
SetIcon( *p_intf->p_sys->p_icon );
/* Create a panel to put everything in*/
wxPanel *panel = new wxPanel( this, -1 );
panel->SetAutoLayout( TRUE );
/* Create the file box */
wxStaticBox *file_box = new wxStaticBox( panel, -1,
wxU(_("File to save to")) );
wxStaticBoxSizer *file_sizer = new wxStaticBoxSizer( file_box,
wxHORIZONTAL );
file_text = new wxTextCtrl(panel, -1, wxU(""),wxDefaultPosition,
wxSize(250,-1),wxTE_PROCESS_ENTER);
file_text->SetToolTip( wxU(_("Enter the name of the file to export "
"the playlist to.")) );
wxButton *file_button = new wxButton( panel, Browse_Event,
wxU(_("Browse")) );
file_sizer->Add( file_text, 0, wxALL | wxALIGN_CENTER , 5 );
file_sizer->Add( file_button, 0, wxALL | wxALIGN_CENTER , 5 );
/* Create the type box */
wxStaticBox *type_box = new wxStaticBox( panel, -1,
wxU(_("Select export type")) );
wxStaticBoxSizer *type_sizer = new wxStaticBoxSizer( type_box,
wxHORIZONTAL );
type_combo = new wxComboBox( panel, -1, wxT(""), wxDefaultPosition,
wxSize(250, -1), 0, NULL );
type_sizer->Add( type_combo, 0, wxALL | wxALIGN_CENTER, 5 );
type_sizer->Layout();
wxButton *ok_button = new wxButton(panel, wxID_OK, wxU(_("OK")) );
ok_button->SetDefault();
wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
wxU(_("Cancel")) );
wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
button_sizer->Add( ok_button, 0, wxALL, 5 );
button_sizer->Add( cancel_button, 0, wxALL, 5 );
button_sizer->Layout();
wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
panel_sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
panel_sizer->Add( type_sizer, 0, wxEXPAND | wxALL, 5 );
panel_sizer->Add( button_sizer, 0, wxEXPAND | wxALL, 5 );
panel_sizer->Layout();
panel->SetSizerAndFit( panel_sizer );
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
main_sizer->Add( panel, 1, wxEXPAND, 0 );
main_sizer->Layout();
SetSizerAndFit( main_sizer );
/* build a list of available modules */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( int i_index = 0; i_index < p_list->i_count; i_index++ )
{
p_module = (module_t *)p_list->p_values[i_index].p_object ;
if( !strcmp( p_module->psz_capability, "playlist export" ) )
{
type_combo->Append( wxU(p_module->psz_longname),
p_module->pp_shortcuts[1] ?
p_module->pp_shortcuts[1] :
p_module->psz_object_name );
}
}
vlc_list_release( p_list );
}
ExportPlaylist::~ExportPlaylist()
{
}
void ExportPlaylist::OnOk( wxCommandEvent& WXUNUSED(event) )
{
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
char *psz_type = (char *)type_combo->GetClientData(
type_combo->GetSelection() );
if( file_text->GetValue().mb_str() && psz_type )
{
playlist_Export( p_playlist, file_text->GetValue().mb_str(),
psz_type );
}
}
vlc_object_release( p_playlist );
EndModal( wxID_OK );
}
void ExportPlaylist::OnCancel( wxCommandEvent& WXUNUSED(event) )
{
EndModal( wxID_CANCEL );
}
void ExportPlaylist::OnBrowse( wxCommandEvent& WXUNUSED(event) )
{
wxFileDialog dialog( this, wxU(_("Save playlist")),
wxT(""), wxT(""), wxT("*"), wxSAVE );
if( dialog.ShowModal() == wxID_OK )
{
file_text->SetValue( dialog.GetPath() );
}
}
......@@ -2,7 +2,7 @@
* preferences.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: preferences.cpp,v 1.44 2003/12/22 02:24:52 sam Exp $
* $Id: preferences.cpp,v 1.45 2004/01/11 00:45:06 zorglub Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -328,7 +328,7 @@ static char * GetCapabilityHelp( char *psz_capability, int i_type)
if( !strcasecmp(psz_capability,"video filter") )
return i_type == 1 ? VIDEO_FILTER_TITLE : VIDEO_FILTER_HELP;
return "";
return " ";
}
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* wxwindows.h: private wxWindows interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: wxwindows.h,v 1.83 2004/01/05 13:00:39 zorglub Exp $
* $Id: wxwindows.h,v 1.84 2004/01/11 00:45:06 zorglub Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -740,6 +740,7 @@ private:
/* Playlist */
class ItemInfoDialog;
class NewGroup;
class ExportPlaylist;
class Playlist: public wxFrame
{
public:
......@@ -841,6 +842,24 @@ protected:
char *psz_name;
};
class ExportPlaylist: public wxDialog
{
public:
/* Constructor */
ExportPlaylist(intf_thread_t *p_intf, wxWindow *p_parent );
virtual ~ExportPlaylist();
private:
/* Event handlers (these functions should _not_ be virtual) */
void OnOk( wxCommandEvent& event );
void OnCancel( wxCommandEvent& event );
void OnBrowse( wxCommandEvent& event );
DECLARE_EVENT_TABLE();
intf_thread_t *p_intf;
wxTextCtrl *file_text;
wxComboBox *type_combo;
};
/* ItemInfo Dialog */
class ItemInfoDialog: public wxDialog
......
/*****************************************************************************
* export.c : Playlist export module
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: export.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
/***************************************************************************
* Prototypes
***************************************************************************/
void Export_Native ( intf_thread_t *p_intf );
void Export_M3U ( intf_thread_t *p_intf );
void Export_Old ( intf_thread_t *p_intf );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
add_submodule();
set_description( _("Native playlist exporter") );
add_shortcut( "export-native" );