]> git.sesse.net Git - vlc/blobdiff - plugins/qt/intf_qt.cpp
* ALL: the first libvlc commit.
[vlc] / plugins / qt / intf_qt.cpp
index 93048b766397fd424a73c1b7331f78ad7fa8081c..ad36ebdf4c338a37a93210e91e308903736286bb 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -113,7 +91,7 @@ private slots:
     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 );
@@ -126,8 +104,7 @@ private slots:
     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;
@@ -139,11 +116,7 @@ private:
     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
@@ -152,17 +125,15 @@ private:
 /*****************************************************************************
  * 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 );
@@ -176,7 +147,6 @@ extern "C"
 
 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;
@@ -184,27 +154,6 @@ void _M( intf_getfunctions )( function_list_t * p_function_list )
 
 }
 
-/*****************************************************************************
- * 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
  *****************************************************************************/
@@ -217,7 +166,7 @@ static int intf_Open( intf_thread_t *p_intf )
     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 );
     }
 
@@ -404,15 +353,15 @@ IntfWindow::~IntfWindow( void )
  *****************************************************************************/
 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 );
     }
 }
 
@@ -433,7 +382,8 @@ void IntfWindow::FileOpen( void )
     }
     else
     {
-        intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, file.latin1() );
+        intf_PlaylistAdd( p_intf->p_vlc->p_playlist,
+                          PLAYLIST_END, file.latin1() );
     }
 }
 
@@ -446,7 +396,7 @@ void IntfWindow::About( void )
 {
     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 "
@@ -463,12 +413,14 @@ void IntfWindow::About( void )
  *****************************************************************************/
 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() )
@@ -484,7 +436,7 @@ void IntfWindow::Manage( void )
         {
             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 );
@@ -492,6 +444,11 @@ void IntfWindow::Manage( void )
 #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 )
     {
@@ -499,17 +456,13 @@ void IntfWindow::Manage( void )
         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 );
 }
 
 /*****************************************************************************
@@ -517,9 +470,9 @@ void IntfWindow::Manage( void )
  *****************************************************************************/
 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 );
     }
 }
 
@@ -528,9 +481,9 @@ void IntfWindow::PlaybackPlay( void )
  *****************************************************************************/
 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 );
     }
 }
 
@@ -539,9 +492,9 @@ void IntfWindow::PlaybackPause( void )
  *****************************************************************************/
 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 );
     }
 }
 
@@ -550,9 +503,9 @@ void IntfWindow::PlaybackSlow( void )
  *****************************************************************************/
 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 );
     }
 }
 
@@ -561,12 +514,12 @@ void IntfWindow::PlaybackFast( void )
  *****************************************************************************/
 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;
     }
 }
 
@@ -575,10 +528,10 @@ void IntfWindow::PlaylistPrev( void )
  *****************************************************************************/
 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;
     }
 }