Commit 4e5473ac authored by Olivier Teulière's avatar Olivier Teulière

* skins/vars/stream.cpp: support $N (stream name) and $F (full stream name)

parent 445d17b2
......@@ -139,6 +139,8 @@ SOURCES_skins2 = \
\
vars/playlist.cpp \
vars/playlist.hpp \
vars/stream.cpp \
vars/stream.hpp \
vars/time.cpp \
vars/time.hpp \
vars/volume.cpp \
......
......@@ -2,7 +2,7 @@
* vlcproc.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.cpp,v 1.4 2004/01/18 19:54:46 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -64,29 +64,31 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf )
// Create and register VLC variables
VarManager *pVarManager = VarManager::instance( getIntf() );
#define REGISTER_VAR( var, type, name ) \
var = VariablePtr( new type( getIntf() ) ); \
pVarManager->registerVar( var, name );
REGISTER_VAR( m_cPlaylist, Playlist, "playlist" )
pVarManager->registerVar( getPlaylistVar().getPositionVarPtr(),
"playlist.slider" );
REGISTER_VAR( m_cVarTime, Time, "time" )
REGISTER_VAR( m_cVarVolume, Volume, "volume" )
REGISTER_VAR( m_cVarStream, Stream, "stream" )
REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" ) // XXX broken
REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
#undef REGISTER_VAR
// Called when the playlist changes
var_AddCallback( pIntf->p_sys-> p_playlist, "intf-change",
var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
onIntfChange, this );
// Called when the current played item changes
var_AddCallback( pIntf->p_sys-> p_playlist, "playlist-current",
var_AddCallback( pIntf->p_sys->p_playlist, "playlist-current",
onPlaylistChange, this );
// Called when a playlist items changed
var_AddCallback( pIntf->p_sys-> p_playlist, "item-change",
// Called when a playlist item changed
var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
onItemChange, this );
getIntf()->p_sys->p_input = NULL;
......@@ -229,6 +231,18 @@ int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
{
VlcProc *pThis = ( VlcProc* )pParam;
// Update the stream variable
// XXX: we should not need to access p_inpu->psz_source directly, a
// getter should be provided by VLC core
playlist_t *p_playlist = (playlist_t*)pObj;
if( p_playlist->p_input )
{
Stream *pStream = (Stream*)pThis->m_cVarStream.get();
UString srcName( pThis->getIntf(),
p_playlist->p_input->psz_source );
pStream->set( srcName, false );
}
// Create a playlist notify command
// TODO: selective update
CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
......@@ -237,9 +251,9 @@ int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
pQueue->remove( "notify playlist" );
pQueue->push( CmdGenericPtr( pCmd ) );
/*
p_playlist_dialog->UpdateItem( old_val.i_int );
p_playlist_dialog->UpdateItem( new_val.i_int );*/
// p_playlist_dialog->UpdateItem( old_val.i_int );
// p_playlist_dialog->UpdateItem( new_val.i_int );
return VLC_SUCCESS;
}
......@@ -2,7 +2,7 @@
* vlcproc.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.hpp,v 1.4 2004/01/18 19:54:46 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -28,6 +28,7 @@
#include "../vars/playlist.hpp"
#include "../vars/time.hpp"
#include "../vars/volume.hpp"
#include "../vars/stream.hpp"
class OSTimer;
class VarBool;
......@@ -53,6 +54,9 @@ class VlcProc: public SkinObject
/// Getter for the volume variable
Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
/// Getter for the stream variable
Stream &getStreamVar() { return *((Stream*)(m_cVarStream.get())); }
/// Getter for the mute variable
VarBool &getIsMuteVar() { return *((VarBool*)(m_cVarMute.get())); }
......@@ -82,6 +86,8 @@ class VlcProc: public SkinObject
VariablePtr m_cVarTime;
/// Variable for audio volume
VariablePtr m_cVarVolume;
/// Variable for current stream properties (only name, currently)
VariablePtr m_cVarStream;
/// Variable for the "mute" state
VariablePtr m_cVarMute;
/// Variables related to the input
......
......@@ -27,6 +27,7 @@
#include "../src/var_manager.hpp"
#include "../vars/time.hpp"
#include "../vars/volume.hpp"
#include "../vars/stream.hpp"
const string VarText::m_type = "text";
......@@ -85,6 +86,16 @@ const UString VarText::get() const
temp.replace( pos, 2,
pVlcProc->getVolumeVar().getAsStringPercent().c_str() );
}
while( (pos = temp.find( "$N" )) != UString::npos )
{
temp.replace( pos, 2,
pVlcProc->getStreamVar().getAsStringName().c_str() );
}
while( (pos = temp.find( "$F" )) != UString::npos )
{
temp.replace( pos, 2,
pVlcProc->getStreamVar().getAsStringFullName().c_str() );
}
return temp;
}
......@@ -102,6 +113,7 @@ void VarText::set( const UString &rText )
VlcProc *pVlcProc = VlcProc::instance( getIntf() );
pVlcProc->getTimeVar().delObserver( this );
pVlcProc->getVolumeVar().delObserver( this );
pVlcProc->getStreamVar().delObserver( this );
VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getHelpText().delObserver( this );
......@@ -128,6 +140,14 @@ void VarText::set( const UString &rText )
{
pVlcProc->getVolumeVar().addObserver( this );
}
if( m_text.find( "$N" ) != UString::npos )
{
pVlcProc->getStreamVar().addObserver( this );
}
if( m_text.find( "$F" ) != UString::npos )
{
pVlcProc->getStreamVar().addObserver( this );
}
notify();
}
......
/*****************************************************************************
* time.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: time.cpp 6996 2004-03-07 12:55:32Z ipkiss $
*
* Authors: 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <stdio.h> // snprintf
#include "stream.hpp"
#include "../utils/ustring.hpp"
#include "../src/os_factory.hpp"
#include <vlc/input.h>
void Stream::set( const UString &name, bool updateVLC )
{
VarText::set( name );
// Avoid looping forever...
if( updateVLC )
{
// We have nothing to do here, until we decide that the user
// can change a stream name on the fly...
}
}
const string Stream::getAsStringName() const
{
string fullName = getAsStringFullName();
// XXX: This should be done in VLC core, not here...
// Remove path information if any
OSFactory *pFactory = OSFactory::instance( getIntf() );
string::size_type pos = fullName.rfind( pFactory->getDirSeparator() );
if( pos != string::npos )
{
fullName = fullName.substr( pos + 1, fullName.size() - pos + 1 );
}
return fullName;
}
const string Stream::getAsStringFullName() const
{
string ret;
// XXX: we are not using geIntf()->p_sys->p_input direclty here, because it
// is not updated by VlcProc yet. Anyway, we shouldn't need to do that,
// because VLC core should provide getter functions for the stream name...
if( getIntf()->p_sys->p_playlist->p_input == NULL )
{
ret = "";
}
else
{
ret = getIntf()->p_sys->p_playlist->p_input->psz_source;
}
return ret;
}
/*****************************************************************************
* stream.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: time.hpp 6996 2004-03-07 12:55:32Z ipkiss $
*
* Authors: 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef STREAM_HPP
#define STREAM_HPP
#include "../utils/var_text.hpp"
#include <string>
class UString;
/// Variable for VLC volume
class Stream: public VarText
{
public:
Stream( intf_thread_t *pIntf ): VarText( pIntf ) {}
virtual ~Stream() {}
virtual void set( const UString &name, bool updateVLC );
virtual void set( const UString &name ) { set( name, true ); }
/// Return current stream name
virtual const string getAsStringName() const;
/// Return current stream full name (i.e. including path)
virtual const string getAsStringFullName() const;
};
#endif
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