* intf_qt.cpp: Qt interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: intf_qt.cpp,v 1.9 2001/12/07 18:33:08 sam Exp $
+ * $Id: intf_qt.cpp,v 1.14 2002/06/01 12:32:00 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 "common.h"
-#include "intf_msg.h"
-#include "threads.h"
-#include "mtime.h"
-#include "tests.h"
-
-#include "stream_control.h"
-#include "input_ext-intf.h"
-
-#include "intf_playlist.h"
-#include "interface.h"
-
-#include "modules.h"
-#include "modules_export.h"
-
-} /* extern "C" */
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
#include <qapplication.h>
#include <qmainwindow.h>
void Manage( void );
void FileOpen ( void );
- void FileQuit ( void ) { p_intf->b_die = 1; };
+ void FileQuit ( void ) { qApp->quit(); };
void PlaybackPlay ( void );
void PlaybackPause ( void );
void DateDisplay ( int );
void About ( void );
- void Unimplemented( void ) { intf_WarnMsg( 1, "intf warning: "
- "unimplemented function" ); };
+ void Unimplemented( void ) { msg_Warn( p_intf, "unimplemented" ); };
private:
intf_thread_t *p_intf;
QLabel *p_date;
};
-#ifdef BUILTIN
-# include "BUILTIN_intf_qt.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_s
{
QApplication *p_app;
IntfWindow *p_window;
-
-} intf_sys_t;
+};
/*****************************************************************************
* 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) );
+ msg_Err( p_intf, "out of memory" );
return( 1 );
}
*****************************************************************************/
void IntfWindow::DateDisplay( int i_range )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
{
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 )
+ vlc_mutex_lock( &p_intf->p_vlc->p_input_bank->pp_input[0]->stream.stream_lock );
+ p_date->setText( input_OffsetToTime( p_intf->p_vlc->p_input_bank->pp_input[0], psz_time,
+ ( p_intf->p_vlc->p_input_bank->pp_input[0]->stream.p_selected_area->i_size * i_range )
/ SLIDER_MAX ) );
- vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
+ vlc_mutex_unlock( &p_intf->p_vlc->p_input_bank->pp_input[0]->stream.stream_lock );
}
}
}
else
{
- intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, file.latin1() );
+ intf_PlaylistAdd( p_intf->p_vlc->p_playlist,
+ PLAYLIST_END, file.latin1() );
}
}
{
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 )
{
+ input_thread_t *p_input = vlc_object_find_input( p_intf );
+
/* Manage the slider */
- if( p_intf->p_input != NULL && p_intf->p_input->stream.b_seekable )
+ if( p_input != NULL && 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_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_input, i_seek, INPUT_SEEK_SET );
/* Update the old value */
p_slider->setOldValue( i_value );
#undef p_area
}
+ if( p_input != NULL )
+ {
+ vlc_object_release( p_input );
+ }
+
/* If the "display popup" flag has changed, popup the context menu */
if( p_intf->b_menu_change )
{
p_intf->b_menu_change = 0;
}
- /* Manage core vlc functions through the callback */
- p_intf->pf_manage( p_intf );
-
- if( p_intf->b_die )
+ if( p_intf->p_vlc->b_die )
{
- /* Prepare to die, young Skywalker */
qApp->quit();
-
- /* Just in case */
- return;
}
+
+ /* Manage core vlc functions through the callback */
+ p_intf->pf_manage( p_intf );
}
/*****************************************************************************
*****************************************************************************/
void IntfWindow::PlaybackPlay( void )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
{
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+ input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
}
}
*****************************************************************************/
void IntfWindow::PlaybackPause( void )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
{
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
+ input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], INPUT_STATUS_PAUSE );
}
}
*****************************************************************************/
void IntfWindow::PlaybackSlow( void )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
{
- input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
+ input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], INPUT_STATUS_SLOWER );
}
}
*****************************************************************************/
void IntfWindow::PlaybackFast( void )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
{
- input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
+ input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], INPUT_STATUS_FASTER );
}
}
*****************************************************************************/
void IntfWindow::PlaylistPrev( void )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
{
/* FIXME: temporary hack */
- intf_PlaylistPrev( p_main->p_playlist );
- intf_PlaylistPrev( p_main->p_playlist );
- p_intf->p_input->b_eof = 1;
+ intf_PlaylistPrev( p_intf->p_vlc->p_playlist );
+ intf_PlaylistPrev( p_intf->p_vlc->p_playlist );
+ p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
}
}
*****************************************************************************/
void IntfWindow::PlaylistNext( void )
{
- if( p_intf->p_input != NULL )
+ if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
{
/* FIXME: temporary hack */
- p_intf->p_input->b_eof = 1;
+ p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
}
}