Commit 467472bc authored by Cyril Deguet's avatar Cyril Deguet

* all: added a new skin text variable "$S" to get the audio sample rate

 (in KHz) + fixed the bitrate ("$B") variable to use only the audio bit rate.
* winamp2.xml: updated the winamp2 skin
parent 3782ac32
...@@ -921,7 +921,7 @@ difficulty to understand how VLC skins work.</para> ...@@ -921,7 +921,7 @@ difficulty to understand how VLC skins work.</para>
<itemizedlist> <itemizedlist>
<listitem><para> <listitem><para>
<emphasis>$B</emphasis>: Get the stream bitrate (in kb/s). <emphasis>$B</emphasis>: Get the audio stream bitrate (in kb/s).
</para></listitem> </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).
...@@ -948,6 +948,9 @@ difficulty to understand how VLC skins work.</para> ...@@ -948,6 +948,9 @@ difficulty to understand how VLC skins work.</para>
<listitem><para> <listitem><para>
<emphasis>$F</emphasis>: Full name (with path) of the stream that is being played. <emphasis>$F</emphasis>: Full name (with path) of the stream that is being played.
</para></listitem> </para></listitem>
<listitem><para>
<emphasis>$S</emphasis>: Get the audio sample rate (in kHz).
</para></listitem>
</itemizedlist> </itemizedlist>
<para>Example of <link linkend="slidertooltiptext">tooltiptext</link> value for a slider controlling the volume: "Volume: $V%".</para> <para>Example of <link linkend="slidertooltiptext">tooltiptext</link> value for a slider controlling the volume: "Volume: $V%".</para>
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#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"
...@@ -111,6 +110,8 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), ...@@ -111,6 +110,8 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
pVarManager->registerVar( m_cVarStreamURI, "streamURI" ); pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) ); m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" ); pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
// Register the equalizer bands // Register the equalizer bands
for( int i = 0; i < EqualizerBands::kNbBands; i++) for( int i = 0; i < EqualizerBands::kNbBands; i++)
...@@ -243,6 +244,7 @@ void VlcProc::manage() ...@@ -243,6 +244,7 @@ void VlcProc::manage()
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(); VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
// Refresh audio variables // Refresh audio variables
refreshAudio(); refreshAudio();
...@@ -295,11 +297,13 @@ void VlcProc::manage() ...@@ -295,11 +297,13 @@ void VlcProc::manage()
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 // Get the input bitrate
int bitrate = (int)(roundf(pItem->p_stats->f_demux_bitrate*8000)); int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
pBitrate->set( UString::fromInt( getIntf(), bitrate ) ); pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
// Get the audio sample rate
int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
} }
else else
{ {
......
...@@ -76,6 +76,10 @@ class VlcProc: public SkinObject ...@@ -76,6 +76,10 @@ class VlcProc: public SkinObject
VarText &getStreamBitRateVar() VarText &getStreamBitRateVar()
{ return *((VarText*)(m_cVarStreamBitRate.get())); } { return *((VarText*)(m_cVarStreamBitRate.get())); }
/// Getter for the stream sample rate variable
VarText &getStreamSampleRateVar()
{ return *((VarText*)(m_cVarStreamSampleRate.get())); }
/// Getter for the vout size variable /// Getter for the vout size variable
VarBox &getVoutSizeVar() { return m_varVoutSize; } VarBox &getVoutSizeVar() { return m_varVoutSize; }
...@@ -115,6 +119,7 @@ class VlcProc: public SkinObject ...@@ -115,6 +119,7 @@ class VlcProc: public SkinObject
VariablePtr m_cVarStreamName; VariablePtr m_cVarStreamName;
VariablePtr m_cVarStreamURI; VariablePtr m_cVarStreamURI;
VariablePtr m_cVarStreamBitRate; VariablePtr m_cVarStreamBitRate;
VariablePtr m_cVarStreamSampleRate;
/// 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
......
...@@ -49,6 +49,7 @@ VarText::~VarText() ...@@ -49,6 +49,7 @@ VarText::~VarText()
pVlcProc->getStreamURIVar().delObserver( this ); pVlcProc->getStreamURIVar().delObserver( this );
pVlcProc->getStreamNameVar().delObserver( this ); pVlcProc->getStreamNameVar().delObserver( this );
pVlcProc->getStreamBitRateVar().delObserver( this ); pVlcProc->getStreamBitRateVar().delObserver( this );
pVlcProc->getStreamSampleRateVar().delObserver( this );
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getHelpText().delObserver( this ); pVarManager->getHelpText().delObserver( this );
} }
...@@ -126,6 +127,10 @@ const UString VarText::get() const ...@@ -126,6 +127,10 @@ const UString VarText::get() const
{ {
temp.replace( pos, 2, pVlcProc->getStreamBitRateVar().get() ); temp.replace( pos, 2, pVlcProc->getStreamBitRateVar().get() );
} }
while( (pos = temp.find( "$S" )) != UString::npos )
{
temp.replace( pos, 2, pVlcProc->getStreamSampleRateVar().get() );
}
return temp; return temp;
} }
...@@ -150,6 +155,7 @@ void VarText::set( const UString &rText ) ...@@ -150,6 +155,7 @@ void VarText::set( const UString &rText )
pVlcProc->getStreamNameVar().delObserver( this ); pVlcProc->getStreamNameVar().delObserver( this );
pVlcProc->getStreamURIVar().delObserver( this ); pVlcProc->getStreamURIVar().delObserver( this );
pVlcProc->getStreamBitRateVar().delObserver( this ); pVlcProc->getStreamBitRateVar().delObserver( this );
pVlcProc->getStreamSampleRateVar().delObserver( this );
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getHelpText().delObserver( this ); pVarManager->getHelpText().delObserver( this );
...@@ -189,6 +195,10 @@ void VarText::set( const UString &rText ) ...@@ -189,6 +195,10 @@ void VarText::set( const UString &rText )
{ {
pVlcProc->getStreamBitRateVar().addObserver( this ); pVlcProc->getStreamBitRateVar().addObserver( this );
} }
if( m_text.find( "$S" ) != UString::npos )
{
pVlcProc->getStreamSampleRateVar().addObserver( this );
}
} }
notify(); notify();
...@@ -217,3 +227,4 @@ void VarText::onUpdate( Subject<VarText,void*> &rVariable, void *arg ) ...@@ -217,3 +227,4 @@ void VarText::onUpdate( Subject<VarText,void*> &rVariable, void *arg )
notify(); notify();
} }
} }
...@@ -195,6 +195,7 @@ ...@@ -195,6 +195,7 @@
<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" /> <Text font="text_font" x="111" y="43" width="15" text="$B" scrolling="none" alignment="right" />
<Text font="text_font" x="151" y="43" width="15" text="$S" 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>
......
...@@ -1596,8 +1596,11 @@ static void EsOutAddInfo( es_out_t *out, es_out_id_t *es ) ...@@ -1596,8 +1596,11 @@ static void EsOutAddInfo( es_out_t *out, es_out_id_t *es )
"%d", fmt->audio.i_channels ); "%d", fmt->audio.i_channels );
if( fmt->audio.i_rate > 0 ) if( fmt->audio.i_rate > 0 )
{
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"), input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"),
_("%d Hz"), fmt->audio.i_rate ); _("%d Hz"), fmt->audio.i_rate );
var_SetInteger( p_input, "sample-rate", fmt->audio.i_rate );
}
if( fmt->audio.i_bitspersample > 0 ) if( fmt->audio.i_bitspersample > 0 )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, input_Control( p_input, INPUT_ADD_INFO, psz_cat,
...@@ -1605,8 +1608,11 @@ static void EsOutAddInfo( es_out_t *out, es_out_id_t *es ) ...@@ -1605,8 +1608,11 @@ static void EsOutAddInfo( es_out_t *out, es_out_id_t *es )
fmt->audio.i_bitspersample ); fmt->audio.i_bitspersample );
if( fmt->i_bitrate > 0 ) if( fmt->i_bitrate > 0 )
{
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"), input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"),
_("%d kb/s"), fmt->i_bitrate / 1000 ); _("%d kb/s"), fmt->i_bitrate / 1000 );
var_SetInteger( p_input, "bit-rate", fmt->i_bitrate );
}
break; break;
case VIDEO_ES: case VIDEO_ES:
......
...@@ -726,6 +726,9 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick ) ...@@ -726,6 +726,9 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
es_out_Control( p_input->p_es_out, ES_OUT_SET_ACTIVE, VLC_FALSE ); es_out_Control( p_input->p_es_out, ES_OUT_SET_ACTIVE, VLC_FALSE );
es_out_Control( p_input->p_es_out, ES_OUT_SET_MODE, ES_OUT_MODE_NONE ); es_out_Control( p_input->p_es_out, ES_OUT_SET_MODE, ES_OUT_MODE_NONE );
var_Create( p_input, "bit-rate", VLC_VAR_INTEGER );
var_Create( p_input, "sample-rate", VLC_VAR_INTEGER );
if( InputSourceInit( p_input, &p_input->input, if( InputSourceInit( p_input, &p_input->input,
p_input->input.p_item->psz_uri, NULL, b_quick ) ) p_input->input.p_item->psz_uri, NULL, b_quick ) )
{ {
......
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