* intf_qt.cpp: Qt interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: intf_qt.cpp,v 1.3 2001/04/15 10:54:46 sam Exp $
+ * $Id: intf_qt.cpp,v 1.17 2002/07/20 18:01:43 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-extern "C"
-{
-
-#define MODULE_NAME qt
-#include "modules_inner.h"
-
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include "defs.h"
-
#include <errno.h> /* ENOMEM */
#include <stdlib.h> /* free() */
#include <string.h> /* strerror() */
#include <stdio.h>
-#include "config.h"
-#include "common.h"
-#include "threads.h"
-#include "mtime.h"
-#include "tests.h"
-#include "modules.h"
-
-#include "stream_control.h"
-#include "input_ext-intf.h"
-
-#include "intf_msg.h"
-#include "intf_playlist.h"
-#include "interface.h"
-
-#include "main.h"
-
-} /* extern "C" */
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
#include <qapplication.h>
#include <qmainwindow.h>
~IntfWindow();
private slots:
- void Manage( void );
+ void Manage ( void );
void FileOpen ( void );
- void FileQuit ( void ) { p_intf->b_die = 1; };
+ void FileQuit ( void );
void PlaybackPlay ( void );
void PlaybackPause ( void );
void DateDisplay ( int );
void About ( void );
- void Unimplemented( void ) { intf_WarnMsg( 3, "intf warning: "
- "unimplemented function" ); };
+ void Unimplemented( void ) { msg_Warn( p_intf, "unimplemented" ); };
private:
intf_thread_t *p_intf;
QLabel *p_date;
};
-#ifdef BUILTIN
-# include "intf_qt-BUILTIN.moc"
-#else
-# include "intf_qt.moc"
-#endif
+#include "intf_qt.moc"
#define SLIDER_MIN 0x00000
#define SLIDER_MAX 0x10000
/*****************************************************************************
* intf_sys_t: description and status of Qt interface
*****************************************************************************/
-typedef struct intf_sys_s
+struct intf_sys_t
{
QApplication *p_app;
IntfWindow *p_window;
-} intf_sys_t;
+ input_thread_t *p_input;
+};
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
-static int intf_Probe ( probedata_t *p_data );
static int intf_Open ( intf_thread_t *p_intf );
static void intf_Close ( intf_thread_t *p_intf );
static void intf_Run ( intf_thread_t *p_intf );
void _M( intf_getfunctions )( function_list_t * p_function_list )
{
- p_function_list->pf_probe = intf_Probe;
p_function_list->functions.intf.pf_open = intf_Open;
p_function_list->functions.intf.pf_close = intf_Close;
p_function_list->functions.intf.pf_run = intf_Run;
}
-/*****************************************************************************
- * intf_Probe: probe the interface and return a score
- *****************************************************************************
- * This function tries to initialize Qt and returns a score to the
- * plugin manager so that it can select the best plugin.
- *****************************************************************************/
-static int intf_Probe( probedata_t *p_data )
-{
- if( TestMethod( INTF_METHOD_VAR, "qt" ) )
- {
- return( 999 );
- }
-
- if( TestProgram( "qvlc" ) )
- {
- return( 180 );
- }
-
- return( 80 );
-}
-
/*****************************************************************************
* intf_Open: initialize and create window
*****************************************************************************/
p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
{
- intf_ErrMsg( "intf error: %s", strerror(ENOMEM) );
- return( 1 );
+ msg_Err( p_intf, "out of memory" );
+ return 1;
}
/* Create the C++ objects */
/* Tell the world we are here */
p_intf->p_sys->p_window->setCaption( VOUT_TITLE " (Qt interface)" );
- return( 0 );
+ p_intf->p_sys->p_input = NULL;
+
+ return 0;
}
/*****************************************************************************
*****************************************************************************/
static void intf_Close( intf_thread_t *p_intf )
{
+ if( p_intf->p_sys->p_input )
+ {
+ vlc_object_release( p_intf->p_sys->p_input );
+ }
+
/* Get rid of the C++ objects */
delete p_intf->p_sys->p_window;
delete p_intf->p_sys->p_app;
*****************************************************************************/
void IntfWindow::DateDisplay( int i_range )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_sys->p_input )
{
char psz_time[ OFFSETTOTIME_MAX_SIZE ];
- vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
- p_date->setText( input_OffsetToTime( p_intf->p_input, psz_time,
- ( p_intf->p_input->stream.p_selected_area->i_size * i_range )
- / SLIDER_MAX ) );
- vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
+ vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+ p_date->setText( input_OffsetToTime( p_intf->p_sys->p_input, psz_time,
+ ( p_intf->p_sys->p_input->stream.p_selected_area->i_size * i_range )
+ / SLIDER_MAX ) );
+ vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
}
*****************************************************************************/
void IntfWindow::FileOpen( void )
{
+ playlist_t *p_playlist;
QString file = QFileDialog::getOpenFileName( QString::null,
QString::null, this );
}
else
{
- intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, file.latin1() );
+ p_playlist = (playlist_t *)
+ vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+ if( p_playlist == NULL )
+ {
+ return;
+ }
+
+ playlist_Add( p_playlist, file.latin1(),
+ PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+ vlc_object_release( p_playlist );
}
}
+/*****************************************************************************
+ * FileQuit: terminate vlc
+ *****************************************************************************/
+void IntfWindow::FileQuit( void )
+{
+ p_intf->p_vlc->b_die = VLC_TRUE;
+}
+
/*****************************************************************************
* About: display the "about" box
*****************************************************************************
{
QMessageBox::about( this, "About",
"VideoLAN Client\n"
- "(C) 1996, 1997, 1998, 1999, 2000, 2001 - the VideoLAN Team\n"
+ "(C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 - the VideoLAN Team\n"
"\n"
"This is the VideoLAN client, a DVD and MPEG player.\n"
"It can play MPEG and MPEG 2 files from a file "
*****************************************************************************/
void IntfWindow::Manage( void )
{
+ /* Update the input */
+ if( p_intf->p_sys->p_input == NULL )
+ {
+ p_intf->p_sys->p_input = (input_thread_t *)
+ vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
+ }
+ else if( p_intf->p_sys->p_input->b_dead )
+ {
+ vlc_object_release( p_intf->p_sys->p_input );
+ p_intf->p_sys->p_input = NULL;
+ }
+
/* Manage the slider */
- if( p_intf->p_input != NULL )
+ if( p_intf->p_sys->p_input && p_intf->p_sys->p_input->stream.b_seekable )
{
int i_value = p_slider->value();
-#define p_area p_intf->p_input->stream.p_selected_area
+#define p_area p_intf->p_sys->p_input->stream.p_selected_area
/* If the user hasn't touched the slider since the last time,
* then the input can safely change it */
if( i_value == p_slider->oldvalue() )
{
off_t i_seek = ( i_value * p_area->i_size ) / SLIDER_MAX;
- input_Seek( p_intf->p_input, i_seek );
+ input_Seek( p_intf->p_sys->p_input, i_seek, INPUT_SEEK_SET );
/* Update the old value */
p_slider->setOldValue( i_value );
p_intf->b_menu_change = 0;
}
- /* Manage core vlc functions through the callback */
- p_intf->pf_manage( p_intf );
-
if( p_intf->b_die )
{
- /* Prepare to die, young Skywalker */
qApp->quit();
-
- /* Just in case */
- return;
}
}
*****************************************************************************/
void IntfWindow::PlaybackPlay( void )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_sys->p_input != NULL )
{
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+ input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
}
}
*****************************************************************************/
void IntfWindow::PlaybackPause( void )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_sys->p_input != NULL )
{
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
+ input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
}
}
*****************************************************************************/
void IntfWindow::PlaybackSlow( void )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_sys->p_input != NULL )
{
- input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
+ input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
}
}
*****************************************************************************/
void IntfWindow::PlaybackFast( void )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_sys->p_input != NULL )
{
- input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
+ input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
}
}
*****************************************************************************/
void IntfWindow::PlaylistPrev( void )
{
- if( p_intf->p_input != NULL )
+ playlist_t *p_playlist = (playlist_t *)
+ vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+
+ if( p_playlist == NULL )
{
- /* FIXME: temporary hack */
- intf_PlaylistPrev( p_main->p_playlist );
- intf_PlaylistPrev( p_main->p_playlist );
- p_intf->p_input->b_eof = 1;
+ return;
}
+
+ playlist_Prev( p_playlist );
+ vlc_object_release( p_playlist );
}
/*****************************************************************************
*****************************************************************************/
void IntfWindow::PlaylistNext( void )
{
- if( p_intf->p_input != NULL )
+ playlist_t *p_playlist = (playlist_t *)
+ vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+
+ if( p_playlist == NULL )
{
- /* FIXME: temporary hack */
- p_intf->p_input->b_eof = 1;
+ return;
}
+
+ playlist_Next( p_playlist );
+ vlc_object_release( p_playlist );
}
/*****************************************************************************