Commit e947989f authored by Cyril Deguet's avatar Cyril Deguet

* src/vlcproc.*: added the callbacks for vout requests. The vout window

    handle is now stored in VlcProc.
  * x11/x11_window.cpp, win32/win32_window.cpp: set the vout window in 
    VlcProc instead of the old "drawable" trick
  * all: renamed "Time" into "StreamTime" because of a name conflict with 
   X11 (did i hear "namespace" ? ;)
parent 8db09e71
......@@ -80,7 +80,7 @@ void ExprEvaluator::parse( const string &rExpr )
// TODO compare to a set of operators
if( token == "not" || token == "or" || token == "and" )
{
// Pop the operator stock while the operator has a higher
// Pop the operator stack while the operator has a higher
// precedence than the top of the stack
while( !opStack.empty() &&
hasPrecedency( token, opStack.back() ) )
......
......@@ -23,6 +23,7 @@
*****************************************************************************/
#include <vlc/aout.h>
#include <vlc/vout.h>
#include "vlcproc.hpp"
#include "os_factory.hpp"
......@@ -55,7 +56,8 @@ void VlcProc::destroy( intf_thread_t *pIntf )
}
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf )
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), m_pVoutWindow( NULL ),
m_pVout( NULL )
{
// Create a timer to poll the status of the vlc
OSFactory *pOsFactory = OSFactory::instance( pIntf );
......@@ -73,7 +75,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf )
"playlist.slider" );
REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
REGISTER_VAR( m_cVarTime, Time, "time" )
REGISTER_VAR( m_cVarTime, StreamTime, "time" )
REGISTER_VAR( m_cVarVolume, Volume, "volume" )
REGISTER_VAR( m_cVarStream, Stream, "stream" )
REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" ) // XXX broken
......@@ -98,6 +100,11 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf )
var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
onItemChange, this );
// Callbacks for vout requests
getIntf()->pf_request_window = &getWindow;
getIntf()->pf_release_window = &releaseWindow;
getIntf()->pf_control_window = &controlWindow;
getIntf()->p_sys->p_input = NULL;
}
......@@ -113,6 +120,18 @@ VlcProc::~VlcProc()
}
void VlcProc::setVoutWindow( void *pVoutWindow )
{
m_pVoutWindow = pVoutWindow;
// Reparent the vout window
if( m_pVout )
{
if( vout_Control( m_pVout, VOUT_REPARENT ) != VLC_SUCCESS )
vout_Control( m_pVout, VOUT_CLOSE );
}
}
void VlcProc::manage()
{
// Did the user requested to quit vlc ?
......@@ -124,7 +143,7 @@ void VlcProc::manage()
}
// Get the VLC variables
Time *pTime = (Time*)m_cVarTime.get();
StreamTime *pTime = (StreamTime*)m_cVarTime.get();
Volume *pVolume = (Volume*)m_cVarVolume.get();
VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
......@@ -277,3 +296,28 @@ int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
return VLC_SUCCESS;
}
void *VlcProc::getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
int *pXHint, int *pYHint,
unsigned int *pWidthHint,
unsigned int *pHeightHint )
{
VlcProc *pThis = pIntf->p_sys->p_vlcProc;
pThis->m_pVout = pVout;
return pThis->m_pVoutWindow;
}
void VlcProc::releaseWindow( intf_thread_t *pIntf, void *pWindow )
{
VlcProc *pThis = pIntf->p_sys->p_vlcProc;
pThis->m_pVout = NULL;
}
int VlcProc::controlWindow( intf_thread_t *pIntf, void *pWindow,
int query, va_list args )
{
return VLC_SUCCESS;
}
......@@ -49,7 +49,7 @@ class VlcProc: public SkinObject
Playlist &getPlaylistVar() { return *((Playlist*)m_cPlaylist.get()); }
/// Getter for the time variable
Time &getTimeVar() { return *((Time*)(m_cVarTime.get())); }
StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
/// Getter for the volume variable
Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
......@@ -72,6 +72,9 @@ class VlcProc: public SkinObject
/// Getter for the seekable variable
VarBool &getIsSeekableVar() { return *((VarBool*)(m_cVarSeekable.get())); }
/// Set the vout window handle
void setVoutWindow( void *pVoutWindow );
protected:
// Protected because it is a singleton
VlcProc( intf_thread_t *pIntf );
......@@ -97,6 +100,10 @@ class VlcProc: public SkinObject
VariablePtr m_cVarStopped;
VariablePtr m_cVarPaused;
VariablePtr m_cVarSeekable;
/// Vout window hanlde
void *m_pVoutWindow;
/// Vout thread
vout_thread_t *m_pVout;
/// Poll VLC internals to update the status (volume, current time in
/// the stream, current filename, play/pause/stop status, ...)
......@@ -123,6 +130,19 @@ class VlcProc: public SkinObject
static int onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam );
/// Callback to request a vout window
static void *getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
int *pXHint, int *pYHint,
unsigned int *pWidthHint,
unsigned int *pHeightHint );
/// Callback to release a vout window
static void releaseWindow( intf_thread_t *pIntf, void *pWindow );
/// Callback to change a vout window
static int controlWindow( intf_thread_t *pIntf, void *pWindow,
int query, va_list args );
};
......
......@@ -28,7 +28,7 @@
#include <vlc/input.h>
void Time::set( float percentage, bool updateVLC )
void StreamTime::set( float percentage, bool updateVLC )
{
VarPercent::set( percentage );
......@@ -43,7 +43,7 @@ void Time::set( float percentage, bool updateVLC )
}
const string Time::getAsStringPercent() const
const string StreamTime::getAsStringPercent() const
{
int value = (int)(100. * get());
// 0 <= value <= 100, so we need 4 chars
......@@ -56,7 +56,7 @@ const string Time::getAsStringPercent() const
}
const string Time::getAsStringCurrTime() const
const string StreamTime::getAsStringCurrTime() const
{
if( getIntf()->p_sys->p_input == NULL ||
!getIntf()->p_sys->p_input->stream.b_seekable )
......@@ -71,7 +71,7 @@ const string Time::getAsStringCurrTime() const
}
const string Time::getAsStringTimeLeft() const
const string StreamTime::getAsStringTimeLeft() const
{
if( getIntf()->p_sys->p_input == NULL ||
!getIntf()->p_sys->p_input->stream.b_seekable )
......@@ -87,7 +87,7 @@ const string Time::getAsStringTimeLeft() const
}
const string Time::getAsStringDuration() const
const string StreamTime::getAsStringDuration() const
{
if( getIntf()->p_sys->p_input == NULL ||
!getIntf()->p_sys->p_input->stream.b_seekable )
......@@ -102,7 +102,7 @@ const string Time::getAsStringDuration() const
}
const string Time::formatTime( int seconds ) const
const string StreamTime::formatTime( int seconds ) const
{
char *psz_time = new char[MSTRTIME_MAX_SIZE];
snprintf( psz_time, MSTRTIME_MAX_SIZE, "%d:%02d:%02d",
......
......@@ -28,12 +28,12 @@
#include "../utils/var_percent.hpp"
#include <string>
/// Variable for VLC volume
class Time: public VarPercent
/// Variable for VLC strem time
class StreamTime: public VarPercent
{
public:
Time( intf_thread_t *pIntf ): VarPercent( pIntf ) {}
virtual ~Time() {}
StreamTime( intf_thread_t *pIntf ): VarPercent( pIntf ) {}
virtual ~StreamTime() {}
virtual void set( float percentage, bool updateVLC );
......
......@@ -90,7 +90,6 @@ class Win32Factory: public OSFactory
/// Map to find the GenericWindow associated with a Win32Window
map<HWND, GenericWindow*> m_windowMap;
/// Functions dynamically loaded from the dll, because they don't exist
/// on Win9x/NT4
// We dynamically load msimg32.dll to get a pointer to TransparentBlt()
......
......@@ -25,6 +25,7 @@
#ifdef WIN32_SKINS
#include "../src/generic_window.hpp"
#include "../src/vlcproc.hpp"
#include "win32_window.hpp"
#include "win32_dragdrop.hpp"
#include "win32_factory.hpp"
......@@ -78,12 +79,11 @@ Win32Window::Win32Window( intf_thread_t *pIntf, GenericWindow &rWindow,
// Register the window as a drop target
RegisterDragDrop( m_hWnd, m_pDropTarget );
}
// XXX: Kludge to tell VLC that this window is the vout
// XXX Set this window as the vout
if( pParentWindow )
{
vlc_value_t value;
value.i_int = (int) (ptrdiff_t) (void *) m_hWnd;
var_Set( getIntf()->p_vlc, "drawable", value );
VlcProc::instance( getIntf() )->setVoutWindow( (void*)m_hWnd );
}
}
......
......@@ -27,6 +27,7 @@
#include <X11/Xatom.h>
#include "../src/generic_window.hpp"
#include "../src/vlcproc.hpp"
#include "x11_window.hpp"
#include "x11_display.hpp"
#include "x11_graphics.hpp"
......@@ -108,24 +109,21 @@ X11Window::X11Window( intf_thread_t *pIntf, GenericWindow &rWindow,
// Associate the window to the main "parent" window
XSetTransientForHint( XDISPLAY, m_wnd, m_rDisplay.getMainWindow() );
// XXX Kludge to tell VLC that this window is the vout
// XXX Set this window as the vout
if( m_pParent )
{
vlc_value_t value;
value.i_int = (int) (ptrdiff_t) (void *) m_wnd;
var_Set( getIntf()->p_vlc, "drawable", value );
VlcProc::instance( getIntf() )->setVoutWindow( (void*)m_wnd );
}
}
X11Window::~X11Window()
{
// XXX Kludge to tell VLC that this window is no more the vout
// XXX This window is no more the vout
if( m_pParent )
{
vlc_value_t value;
value.i_int = 0;
var_Set( getIntf()->p_vlc, "drawable", value );
VlcProc::instance( getIntf() )->setVoutWindow( NULL );
}
X11Factory *pFactory = (X11Factory*)X11Factory::instance( getIntf() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment