Commit 4bc1d553 authored by Cyril Deguet's avatar Cyril Deguet

* backport [15240] to get a functional winamp2 skin for 0.8.5

parent c64b6382
......@@ -921,7 +921,7 @@ difficulty to understand how VLC skins work.</para>
<itemizedlist>
<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>
<listitem><para>
<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>
<listitem><para>
<emphasis>$F</emphasis>: Full name (with path) of the stream that is being played.
</para></listitem>
<listitem><para>
<emphasis>$S</emphasis>: Get the audio sample rate (in kHz).
</para></listitem>
</itemizedlist>
<para>Example of <link linkend="slidertooltiptext">tooltiptext</link> value for a slider controlling the volume: "Volume: $V%".</para>
......
......@@ -26,7 +26,6 @@
#include <vlc/vout.h>
#include <aout_internal.h>
#include <math.h>
#include "vlcproc.hpp"
#include "os_factory.hpp"
#include "os_timer.hpp"
......@@ -111,6 +110,8 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
// Register the equalizer bands
for( int i = 0; i < EqualizerBands::kNbBands; i++)
......@@ -243,6 +244,7 @@ void VlcProc::manage()
VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
// Refresh audio variables
refreshAudio();
......@@ -295,11 +297,13 @@ void VlcProc::manage()
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));
int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
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
{
......
......@@ -76,6 +76,10 @@ class VlcProc: public SkinObject
VarText &getStreamBitRateVar()
{ 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
VarBox &getVoutSizeVar() { return m_varVoutSize; }
......@@ -115,6 +119,7 @@ class VlcProc: public SkinObject
VariablePtr m_cVarStreamName;
VariablePtr m_cVarStreamURI;
VariablePtr m_cVarStreamBitRate;
VariablePtr m_cVarStreamSampleRate;
/// Variable for the "mute" state
VariablePtr m_cVarMute;
/// Variables related to the input
......
......@@ -49,6 +49,7 @@ VarText::~VarText()
pVlcProc->getStreamURIVar().delObserver( this );
pVlcProc->getStreamNameVar().delObserver( this );
pVlcProc->getStreamBitRateVar().delObserver( this );
pVlcProc->getStreamSampleRateVar().delObserver( this );
VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getHelpText().delObserver( this );
}
......@@ -126,6 +127,10 @@ const UString VarText::get() const
{
temp.replace( pos, 2, pVlcProc->getStreamBitRateVar().get() );
}
while( (pos = temp.find( "$S" )) != UString::npos )
{
temp.replace( pos, 2, pVlcProc->getStreamSampleRateVar().get() );
}
return temp;
}
......@@ -150,6 +155,7 @@ void VarText::set( const UString &rText )
pVlcProc->getStreamNameVar().delObserver( this );
pVlcProc->getStreamURIVar().delObserver( this );
pVlcProc->getStreamBitRateVar().delObserver( this );
pVlcProc->getStreamSampleRateVar().delObserver( this );
VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getHelpText().delObserver( this );
......@@ -189,6 +195,10 @@ void VarText::set( const UString &rText )
{
pVlcProc->getStreamBitRateVar().addObserver( this );
}
if( m_text.find( "$S" ) != UString::npos )
{
pVlcProc->getStreamSampleRateVar().addObserver( this );
}
}
notify();
......@@ -217,3 +227,4 @@ void VarText::onUpdate( Subject<VarText,void*> &rVariable, void *arg )
notify();
}
}
......@@ -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="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="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%">
<SliderBackground image="volume_bg;volume_bg_2" nbvert="28" padvert="2" />
</Slider>
......
......@@ -1596,8 +1596,11 @@ static void EsOutAddInfo( es_out_t *out, es_out_id_t *es )
"%d", fmt->audio.i_channels );
if( fmt->audio.i_rate > 0 )
{
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"),
_("%d Hz"), fmt->audio.i_rate );
var_SetInteger( p_input, "sample-rate", fmt->audio.i_rate );
}
if( fmt->audio.i_bitspersample > 0 )
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 )
fmt->audio.i_bitspersample );
if( fmt->i_bitrate > 0 )
{
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"),
_("%d kb/s"), fmt->i_bitrate / 1000 );
var_SetInteger( p_input, "bit-rate", fmt->i_bitrate );
}
break;
case VIDEO_ES:
......
......@@ -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_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,
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