]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/vlcproc.cpp
Skins: missing include, makes skins2 on Windows fail to build.
[vlc] / modules / gui / skins2 / src / vlcproc.cpp
index 39e94901fece8cf80b3bcc20bba3881632cc3ca1..8d6baab98d26ce3a1560e5388efa8d34b8fa71e5 100644 (file)
@@ -1,11 +1,11 @@
 /*****************************************************************************
  * vlcproc.cpp
  *****************************************************************************
- * Copyright (C) 2003 the VideoLAN team
+ * Copyright (C) 2003-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulie <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * 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
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_aout.h>
 #include <vlc_vout.h>
 #include <vlc_playlist.h>
+#include <vlc_window.h>
 
 #include "vlcproc.hpp"
 #include "os_factory.hpp"
@@ -44,6 +45,7 @@
 #include "../commands/cmd_resize.hpp"
 #include "../commands/cmd_vars.hpp"
 #include "../commands/cmd_dialogs.hpp"
+#include "../commands/cmd_update_item.hpp"
 #include "../utils/var_bool.hpp"
 #include <sstream>
 
@@ -148,7 +150,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     var_AddCallback( pIntf->p_sys->p_playlist, "item-deleted",
                      onItemDelete, this );
     // Called when the "interface shower" wants us to show the skin
-    var_AddCallback( pIntf->p_sys->p_playlist, "intf-show",
+    var_AddCallback( pIntf->p_libvlc, "intf-show",
                      onIntfShow, this );
     // Called when the current played item changes
     var_AddCallback( pIntf->p_sys->p_playlist, "playlist-current",
@@ -162,12 +164,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     // Called when we have an interaction dialog to display
     var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
     var_AddCallback( pIntf, "interaction", onInteraction, this );
-    pIntf->b_interaction = true;
-
-    // Callbacks for vout requests
-    getIntf()->pf_request_window = &getWindow;
-    getIntf()->pf_release_window = &releaseWindow;
-    getIntf()->pf_control_window = &controlWindow;
+    interaction_Register( pIntf );
 
     getIntf()->p_sys->p_input = NULL;
 }
@@ -182,10 +179,7 @@ VlcProc::~VlcProc()
         vlc_object_release( getIntf()->p_sys->p_input );
     }
 
-    // Callbacks for vout requests
-    getIntf()->pf_request_window = NULL;
-    getIntf()->pf_release_window = NULL;
-    getIntf()->pf_control_window = NULL;
+    interaction_Unregister( getIntf() );
 
     var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
                      onIntfChange, this );
@@ -193,7 +187,7 @@ VlcProc::~VlcProc()
                      onItemAppend, this );
     var_DelCallback( getIntf()->p_sys->p_playlist, "item-deleted",
                      onItemDelete, this );
-    var_DelCallback( getIntf()->p_sys->p_playlist, "intf-show",
+    var_DelCallback( getIntf()->p_libvlc, "intf-show",
                      onIntfShow, this );
     var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-current",
                      onPlaylistChange, this );
@@ -235,7 +229,7 @@ void VlcProc::dropVout()
 void VlcProc::manage()
 {
     // Did the user request to quit vlc ?
-    if( intf_ShouldDie( getIntf() ) )
+    if( !vlc_object_alive( getIntf() ) )
     {
         CmdQuit *pCmd = new CmdQuit( getIntf() );
         AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
@@ -332,14 +326,11 @@ void VlcProc::refreshInput()
     VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
     VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
 
-    input_thread_t *pInput = getIntf()->p_sys->p_input;
-
     // Update the input
     if( getIntf()->p_sys->p_input == NULL )
     {
-        getIntf()->p_sys->p_input = getIntf()->p_sys->p_playlist->p_input;
-        if( getIntf()->p_sys->p_input )
-            vlc_object_yield( getIntf()->p_sys->p_input );
+        getIntf()->p_sys->p_input =
+            playlist_CurrentInput( getIntf()->p_sys->p_playlist );
     }
     else if( getIntf()->p_sys->p_input->b_dead )
     {
@@ -347,8 +338,9 @@ void VlcProc::refreshInput()
         getIntf()->p_sys->p_input = NULL;
     }
 
+    input_thread_t *pInput = getIntf()->p_sys->p_input;
 
-    if( pInput && !pInput->b_die )
+    if( pInput && vlc_object_alive (pInput) )
     {
         // Refresh time variables
         vlc_value_t pos;
@@ -377,8 +369,7 @@ void VlcProc::refreshInput()
         pVarHasAudio->set( audio_es.i_int > 0 );
 
         // Refresh fullscreen status
-        vout_thread_t *pVout = (vout_thread_t *)vlc_object_find( pInput,
-                                     VLC_OBJECT_VOUT, FIND_CHILD );
+        vout_thread_t *pVout = input_GetVout( pInput );
         pVarHasVout->set( pVout != NULL );
         if( pVout )
         {
@@ -413,8 +404,7 @@ int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
     VlcProc *pThis = (VlcProc*)pParam;
 
     // Update the stream variable
-    playlist_t *p_playlist = (playlist_t*)pObj;
-    pThis->updateStreamName(p_playlist);
+    pThis->updateStreamName();
 
     // Create a playtree notify command (for new style playtree)
     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
@@ -431,7 +421,7 @@ int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
                          vlc_value_t oldVal, vlc_value_t newVal,
                          void *pParam )
 {
-    if (newVal.i_int)
+    if (newVal.b_bool)
     {
         VlcProc *pThis = (VlcProc*)pParam;
 
@@ -455,8 +445,7 @@ int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
     VlcProc *pThis = (VlcProc*)pParam;
 
     // Update the stream variable
-    playlist_t *p_playlist = (playlist_t*)pObj;
-    pThis->updateStreamName(p_playlist);
+    pThis->updateStreamName();
 
     // Create a playtree notify command
     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
@@ -522,8 +511,7 @@ int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
 
     // Update the stream variable
-    playlist_t *p_playlist = (playlist_t*)pObj;
-    pThis->updateStreamName(p_playlist);
+    pThis->updateStreamName();
 
     // Create two playtree notify commands: one for old item, one for new
     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
@@ -567,40 +555,16 @@ int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
 }
 
 
-void VlcProc::updateStreamName( playlist_t *p_playlist )
+void VlcProc::updateStreamName()
 {
-    if( p_playlist && p_playlist->p_input )
-    {
-        // Get playlist item information
-        input_item_t *pItem = input_GetItem(p_playlist->p_input);
-
-        VarText &rStreamName = getStreamNameVar();
-        VarText &rStreamURI = getStreamURIVar();
-        // XXX: we should not need to access p_input->psz_source directly, a
-        // getter should be provided by VLC core
-        string name = pItem->psz_name;
-        // XXX: This should be done in VLC core, not here...
-        // Remove path information if any
-        OSFactory *pFactory = OSFactory::instance( getIntf() );
-        string::size_type pos = name.rfind( pFactory->getDirSeparator() );
-        if( pos != string::npos )
-        {
-            name = name.substr( pos + 1, name.size() - pos + 1 );
-        }
-        UString srcName( getIntf(), name.c_str() );
-        UString srcURI( getIntf(), pItem->psz_uri );
+    // Create a update item command
+    CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
 
-       // Create commands to update the stream variables
-        CmdSetText *pCmd1 = new CmdSetText( getIntf(), rStreamName, srcName );
-        CmdSetText *pCmd2 = new CmdSetText( getIntf(), rStreamURI, srcURI );
-        // Push the commands in the asynchronous command queue
-        AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
-        pQueue->push( CmdGenericPtr( pCmd1 ), false );
-        pQueue->push( CmdGenericPtr( pCmd2 ), false );
-    }
+    // Push the command in the asynchronous command queue
+    AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
+    pQueue->push( CmdGenericPtr( pCmdItem ) );
 }
 
-
 void *VlcProc::getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
                           int *pXHint, int *pYHint,
                           unsigned int *pWidthHint,
@@ -633,9 +597,10 @@ void VlcProc::releaseWindow( intf_thread_t *pIntf, void *pWindow )
 }
 
 
-int VlcProc::controlWindow( intf_thread_t *pIntf, void *pWindow,
+int VlcProc::controlWindow( struct vout_window_t *pWnd,
                             int query, va_list args )
 {
+    intf_thread_t *pIntf = (intf_thread_t *)pWnd->p_private;
     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
 
     switch( query )
@@ -651,7 +616,7 @@ int VlcProc::controlWindow( intf_thread_t *pIntf, void *pWindow,
 
                 // Post a resize vout command
                 CmdResizeVout *pCmd =
-                    new CmdResizeVout( pThis->getIntf(), pWindow,
+                    new CmdResizeVout( pThis->getIntf(), pWnd->handle,
                                        i_width, i_height );
                 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
                 pQueue->push( CmdGenericPtr( pCmd ) );
@@ -659,7 +624,7 @@ int VlcProc::controlWindow( intf_thread_t *pIntf, void *pWindow,
         }
 
         default:
-            msg_Dbg( pIntf, "control query not supported" );
+            msg_Dbg( pWnd, "control query not supported" );
             break;
     }