Commit ef5c2337 authored by Cyril Deguet's avatar Cyril Deguet

* all: new skin text variable "$B" to get the stream bitrate

* winamp2.xml: added "kbps" info in winamp skins
parent ae6b2bb9
...@@ -897,6 +897,9 @@ difficulty to understand how VLC skins work.</para> ...@@ -897,6 +897,9 @@ difficulty to understand how VLC skins work.</para>
<para>When specifying the <link linkend="texttext">text</link> attribute of the <link linkend="Text">Text</link> control or any tooltip attribute, you can insert escape sequences which will be expanded dynamically. An escape sequence always starts with the '$' character, followed by one or more predefined letters. Here is the list of accepted escape sequences:</para> <para>When specifying the <link linkend="texttext">text</link> attribute of the <link linkend="Text">Text</link> control or any tooltip attribute, you can insert escape sequences which will be expanded dynamically. An escape sequence always starts with the '$' character, followed by one or more predefined letters. Here is the list of accepted escape sequences:</para>
<itemizedlist> <itemizedlist>
<listitem><para>
<emphasis>$B</emphasis>: Get the stream bitrate (in kb/s).
</para></listitem>
<listitem><para> <listitem><para>
<emphasis>$V</emphasis>: Value of the volume (from 0 to 100 --> useful for a percentage). <emphasis>$V</emphasis>: Value of the volume (from 0 to 100 --> useful for a percentage).
</para></listitem> </para></listitem>
......
...@@ -37,6 +37,8 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler, ...@@ -37,6 +37,8 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
fmt_out.i_chroma = VLC_FOURCC('R','V','3','2'); fmt_out.i_chroma = VLC_FOURCC('R','V','3','2');
fprintf(stderr,"FILE %s\n", fileName.c_str());
pPic = image_ReadUrl( pImageHandler, fileName.c_str(), &fmt_in, &fmt_out ); pPic = image_ReadUrl( pImageHandler, fileName.c_str(), &fmt_in, &fmt_out );
if( !pPic ) return; if( !pPic ) return;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <vlc/vout.h> #include <vlc/vout.h>
#include <aout_internal.h> #include <aout_internal.h>
#include <math.h>
#include "vlcproc.hpp" #include "vlcproc.hpp"
#include "os_factory.hpp" #include "os_factory.hpp"
#include "os_timer.hpp" #include "os_timer.hpp"
...@@ -108,6 +109,8 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), ...@@ -108,6 +109,8 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
pVarManager->registerVar( m_cVarStreamName, "streamName" ); pVarManager->registerVar( m_cVarStreamName, "streamName" );
m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) ); m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
pVarManager->registerVar( m_cVarStreamURI, "streamURI" ); pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
// Register the equalizer bands // Register the equalizer bands
for( int i = 0; i < EqualizerBands::kNbBands; i++) for( int i = 0; i < EqualizerBands::kNbBands; i++)
...@@ -239,6 +242,7 @@ void VlcProc::manage() ...@@ -239,6 +242,7 @@ void VlcProc::manage()
VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get(); VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get(); VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get(); VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
// Refresh audio variables // Refresh audio variables
refreshAudio(); refreshAudio();
...@@ -290,6 +294,12 @@ void VlcProc::manage() ...@@ -290,6 +294,12 @@ void VlcProc::manage()
pVarFullscreen->set( pVout->b_fullscreen ); pVarFullscreen->set( pVout->b_fullscreen );
vlc_object_release( pVout ); vlc_object_release( pVout );
} }
// Get information on the current playlist item
input_item_t *pItem = pInput->input.p_item;
// Get the input bitrate
int bitrate = (int)(roundf(pItem->p_stats->f_demux_bitrate*8000));
pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
} }
else else
{ {
...@@ -558,13 +568,16 @@ int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable, ...@@ -558,13 +568,16 @@ int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
void VlcProc::updateStreamName( playlist_t *p_playlist ) void VlcProc::updateStreamName( playlist_t *p_playlist )
{ {
if( p_playlist->p_input ) if( p_playlist && p_playlist->p_input )
{ {
// Get playlist item information
input_item_t *pItem = p_playlist->p_input->input.p_item;
VarText &rStreamName = getStreamNameVar(); VarText &rStreamName = getStreamNameVar();
VarText &rStreamURI = getStreamURIVar(); VarText &rStreamURI = getStreamURIVar();
// XXX: we should not need to access p_input->psz_source directly, a // XXX: we should not need to access p_input->psz_source directly, a
// getter should be provided by VLC core // getter should be provided by VLC core
string name = p_playlist->p_input->input.p_item->psz_name; string name = pItem->psz_name;
// XXX: This should be done in VLC core, not here... // XXX: This should be done in VLC core, not here...
// Remove path information if any // Remove path information if any
OSFactory *pFactory = OSFactory::instance( getIntf() ); OSFactory *pFactory = OSFactory::instance( getIntf() );
...@@ -574,10 +587,9 @@ void VlcProc::updateStreamName( playlist_t *p_playlist ) ...@@ -574,10 +587,9 @@ void VlcProc::updateStreamName( playlist_t *p_playlist )
name = name.substr( pos + 1, name.size() - pos + 1 ); name = name.substr( pos + 1, name.size() - pos + 1 );
} }
UString srcName( getIntf(), name.c_str() ); UString srcName( getIntf(), name.c_str() );
UString srcURI( getIntf(), UString srcURI( getIntf(), pItem->psz_uri );
p_playlist->p_input->input.p_item->psz_uri );
// Create commands to update the stream variables // Create commands to update the stream variables
CmdSetText *pCmd1 = new CmdSetText( getIntf(), rStreamName, srcName ); CmdSetText *pCmd1 = new CmdSetText( getIntf(), rStreamName, srcName );
CmdSetText *pCmd2 = new CmdSetText( getIntf(), rStreamURI, srcURI ); CmdSetText *pCmd2 = new CmdSetText( getIntf(), rStreamURI, srcURI );
// Push the commands in the asynchronous command queue // Push the commands in the asynchronous command queue
......
...@@ -72,6 +72,10 @@ class VlcProc: public SkinObject ...@@ -72,6 +72,10 @@ class VlcProc: public SkinObject
VarText &getStreamURIVar() VarText &getStreamURIVar()
{ return *((VarText*)(m_cVarStreamURI.get())); } { return *((VarText*)(m_cVarStreamURI.get())); }
/// Getter for the stream bitrate variable
VarText &getStreamBitRateVar()
{ return *((VarText*)(m_cVarStreamBitRate.get())); }
/// Getter for the vout size variable /// Getter for the vout size variable
VarBox &getVoutSizeVar() { return m_varVoutSize; } VarBox &getVoutSizeVar() { return m_varVoutSize; }
...@@ -110,6 +114,7 @@ class VlcProc: public SkinObject ...@@ -110,6 +114,7 @@ class VlcProc: public SkinObject
/// Variable for current stream properties /// Variable for current stream properties
VariablePtr m_cVarStreamName; VariablePtr m_cVarStreamName;
VariablePtr m_cVarStreamURI; VariablePtr m_cVarStreamURI;
VariablePtr m_cVarStreamBitRate;
/// Variable for the "mute" state /// Variable for the "mute" state
VariablePtr m_cVarMute; VariablePtr m_cVarMute;
/// Variables related to the input /// Variables related to the input
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*****************************************************************************/ *****************************************************************************/
#include <string.h> #include <string.h>
#include <sstream>
#include "ustring.hpp" #include "ustring.hpp"
...@@ -328,3 +329,12 @@ UString UString::substr( uint32_t position, uint32_t n) const ...@@ -328,3 +329,12 @@ UString UString::substr( uint32_t position, uint32_t n) const
return tmp; return tmp;
} }
UString UString::fromInt( intf_thread_t *pIntf, int number)
{
stringstream ss;
ss << number;
return UString( pIntf, ss.str().c_str() );
}
...@@ -82,6 +82,9 @@ class UString: public SkinObject ...@@ -82,6 +82,9 @@ class UString: public SkinObject
/// characters in this string starting at index position /// characters in this string starting at index position
UString substr( uint32_t position = 0, uint32_t n = npos) const; UString substr( uint32_t position = 0, uint32_t n = npos) const;
/// Build a string from an integer
static UString fromInt(intf_thread_t *pIntf, int number);
/// XXX: temporary /// XXX: temporary
void debug() const; void debug() const;
......
...@@ -48,6 +48,7 @@ VarText::~VarText() ...@@ -48,6 +48,7 @@ VarText::~VarText()
pVlcProc->getVolumeVar().delObserver( this ); pVlcProc->getVolumeVar().delObserver( this );
pVlcProc->getStreamURIVar().delObserver( this ); pVlcProc->getStreamURIVar().delObserver( this );
pVlcProc->getStreamNameVar().delObserver( this ); pVlcProc->getStreamNameVar().delObserver( this );
pVlcProc->getStreamBitRateVar().delObserver( this );
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getHelpText().delObserver( this ); pVarManager->getHelpText().delObserver( this );
} }
...@@ -121,6 +122,10 @@ const UString VarText::get() const ...@@ -121,6 +122,10 @@ const UString VarText::get() const
{ {
temp.replace( pos, 2, pVlcProc->getStreamURIVar().get() ); temp.replace( pos, 2, pVlcProc->getStreamURIVar().get() );
} }
while( (pos = temp.find( "$B" )) != UString::npos )
{
temp.replace( pos, 2, pVlcProc->getStreamBitRateVar().get() );
}
return temp; return temp;
} }
...@@ -144,6 +149,7 @@ void VarText::set( const UString &rText ) ...@@ -144,6 +149,7 @@ void VarText::set( const UString &rText )
pVlcProc->getVolumeVar().delObserver( this ); pVlcProc->getVolumeVar().delObserver( this );
pVlcProc->getStreamNameVar().delObserver( this ); pVlcProc->getStreamNameVar().delObserver( this );
pVlcProc->getStreamURIVar().delObserver( this ); pVlcProc->getStreamURIVar().delObserver( this );
pVlcProc->getStreamBitRateVar().delObserver( this );
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getHelpText().delObserver( this ); pVarManager->getHelpText().delObserver( this );
...@@ -179,6 +185,10 @@ void VarText::set( const UString &rText ) ...@@ -179,6 +185,10 @@ void VarText::set( const UString &rText )
{ {
pVlcProc->getStreamURIVar().addObserver( this ); pVlcProc->getStreamURIVar().addObserver( this );
} }
if( m_text.find( "$B" ) != UString::npos )
{
pVlcProc->getStreamBitRateVar().addObserver( this );
}
} }
notify(); notify();
......
...@@ -194,6 +194,7 @@ ...@@ -194,6 +194,7 @@
<Image x="0" y="0" image="title_focus" action="move" action2="main_window.setLayout(small_layout)" /> <Image x="0" y="0" image="title_focus" action="move" action2="main_window.setLayout(small_layout)" />
<Text font="digits_font;digits_font_2" x="30" y="26" width="72" text="$t" visible="not vlc.isStopped" scrolling="none" alignment="right" /> <Text font="digits_font;digits_font_2" x="30" y="26" width="72" text="$t" visible="not vlc.isStopped" scrolling="none" alignment="right" />
<Text font="text_font" x="111" y="27" width="155" text="$N" /> <Text font="text_font" x="111" y="27" width="155" text="$N" />
<Text font="text_font" x="111" y="43" width="15" text="$B" scrolling="none" alignment="right" />
<Slider value="volume" x="107" y="57" up="volume_up" down="volume_down" points="(7,6),(58,6)" tooltiptext="Volume: $V%"> <Slider value="volume" x="107" y="57" up="volume_up" down="volume_down" points="(7,6),(58,6)" tooltiptext="Volume: $V%">
<SliderBackground image="volume_bg;volume_bg_2" nbvert="28" padvert="2" /> <SliderBackground image="volume_bg;volume_bg_2" nbvert="28" padvert="2" />
</Slider> </Slider>
......
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