]> git.sesse.net Git - vlc/commitdiff
* all: new skin text variable "$B" to get the stream bitrate
authorCyril Deguet <asmax@videolan.org>
Sun, 9 Apr 2006 14:29:26 +0000 (14:29 +0000)
committerCyril Deguet <asmax@videolan.org>
Sun, 9 Apr 2006 14:29:26 +0000 (14:29 +0000)
* winamp2.xml: added "kbps" info in winamp skins

doc/skins/skins2-howto.xml
modules/gui/skins2/src/file_bitmap.cpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/src/vlcproc.hpp
modules/gui/skins2/utils/ustring.cpp
modules/gui/skins2/utils/ustring.hpp
modules/gui/skins2/utils/var_text.cpp
share/skins2/winamp2.xml

index f548bc5a96032ad8ffe59bcec9158c7d6c32ef3b..3791898c8306c59bba78dbc097ac263cbd2395b5 100644 (file)
@@ -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>
 
 <itemizedlist>
+  <listitem><para>
+    <emphasis>$B</emphasis>: Get the stream bitrate (in kb/s).
+  </para></listitem>
   <listitem><para>
     <emphasis>$V</emphasis>: Value of the volume (from 0 to 100 --> useful for a percentage).
   </para></listitem>
index b41a79650fc8e90754fc31ad4e1e8f931a11c684..e52415d1de2361059253812c1290720e203b6088 100644 (file)
@@ -37,6 +37,8 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
 
     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 );
     if( !pPic ) return;
 
index 125c43bafaa6f5494297f667ace0f9f13638f84b..bc978219773e5bc2ebce1f4e685e93ef8831ef92 100644 (file)
@@ -26,6 +26,7 @@
 #include <vlc/vout.h>
 #include <aout_internal.h>
 
+#include <math.h>
 #include "vlcproc.hpp"
 #include "os_factory.hpp"
 #include "os_timer.hpp"
@@ -108,6 +109,8 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     pVarManager->registerVar( m_cVarStreamName, "streamName" );
     m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
     pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
+    m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
+    pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
 
     // Register the equalizer bands
     for( int i = 0; i < EqualizerBands::kNbBands; i++)
@@ -239,6 +242,7 @@ void VlcProc::manage()
     VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
     VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
     VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
+    VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
 
     // Refresh audio variables
     refreshAudio();
@@ -290,6 +294,12 @@ void VlcProc::manage()
             pVarFullscreen->set( pVout->b_fullscreen );
             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
     {
@@ -558,13 +568,16 @@ int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
 
 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 &rStreamURI = getStreamURIVar();
         // XXX: we should not need to access p_input->psz_source directly, a
         // 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...
         // Remove path information if any
         OSFactory *pFactory = OSFactory::instance( getIntf() );
@@ -574,10 +587,9 @@ void VlcProc::updateStreamName( playlist_t *p_playlist )
             name = name.substr( pos + 1, name.size() - pos + 1 );
         }
         UString srcName( getIntf(), name.c_str() );
-        UString srcURI( getIntf(),
-                         p_playlist->p_input->input.p_item->psz_uri );
+        UString srcURI( getIntf(), pItem->psz_uri );
 
-        // Create commands to update the stream variables
+       // Create commands to update the stream variables
         CmdSetText *pCmd1 = new CmdSetText( getIntf(), rStreamName, srcName );
         CmdSetText *pCmd2 = new CmdSetText( getIntf(), rStreamURI, srcURI );
         // Push the commands in the asynchronous command queue
index 94bf422b0a8219adad80ea8c0efdc2dfdcc95e6a..d298c13367c645e1a24e39280363bfedbe3a6393 100644 (file)
@@ -72,6 +72,10 @@ class VlcProc: public SkinObject
         VarText &getStreamURIVar()
             { return *((VarText*)(m_cVarStreamURI.get())); }
 
+        /// Getter for the stream bitrate variable
+        VarText &getStreamBitRateVar()
+            { return *((VarText*)(m_cVarStreamBitRate.get())); }
+
         /// Getter for the vout size variable
         VarBox &getVoutSizeVar() { return m_varVoutSize; }
 
@@ -110,6 +114,7 @@ class VlcProc: public SkinObject
         /// Variable for current stream properties
         VariablePtr m_cVarStreamName;
         VariablePtr m_cVarStreamURI;
+        VariablePtr m_cVarStreamBitRate;
         /// Variable for the "mute" state
         VariablePtr m_cVarMute;
         /// Variables related to the input
index 8689f9377e92123957aa3888ecad2e44d7d4f552..5513fe4344d089f8f98e097c98bd4c2722d15683 100644 (file)
@@ -23,6 +23,7 @@
  *****************************************************************************/
 
 #include <string.h>
+#include <sstream>
 #include "ustring.hpp"
 
 
@@ -328,3 +329,12 @@ UString UString::substr( uint32_t position, uint32_t n) const
 
     return tmp;
 }
+
+
+UString UString::fromInt( intf_thread_t *pIntf, int number)
+{
+    stringstream ss;
+    ss << number;
+    return UString( pIntf, ss.str().c_str() );
+}
+
index ed74132992ba90545d0c000251958701094e68c6..90175b6c214f4ccccac31eb7684d2deef4f1d309 100644 (file)
@@ -82,6 +82,9 @@ class UString: public SkinObject
         /// characters in this string starting at index position
         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
         void debug() const;
 
index 4b0dda3403b67d3e93db47670aedd44fca95bc78..7ca12fd7bc231ea02ff70cdcf394557854753cfb 100644 (file)
@@ -48,6 +48,7 @@ VarText::~VarText()
         pVlcProc->getVolumeVar().delObserver( this );
         pVlcProc->getStreamURIVar().delObserver( this );
         pVlcProc->getStreamNameVar().delObserver( this );
+        pVlcProc->getStreamBitRateVar().delObserver( this );
         VarManager *pVarManager = VarManager::instance( getIntf() );
         pVarManager->getHelpText().delObserver( this );
     }
@@ -121,6 +122,10 @@ const UString VarText::get() const
     {
         temp.replace( pos, 2, pVlcProc->getStreamURIVar().get() );
     }
+    while( (pos = temp.find( "$B" )) != UString::npos )
+    {
+        temp.replace( pos, 2, pVlcProc->getStreamBitRateVar().get() );
+    }
 
     return temp;
 }
@@ -144,6 +149,7 @@ void VarText::set( const UString &rText )
         pVlcProc->getVolumeVar().delObserver( this );
         pVlcProc->getStreamNameVar().delObserver( this );
         pVlcProc->getStreamURIVar().delObserver( this );
+        pVlcProc->getStreamBitRateVar().delObserver( this );
         VarManager *pVarManager = VarManager::instance( getIntf() );
         pVarManager->getHelpText().delObserver( this );
 
@@ -179,6 +185,10 @@ void VarText::set( const UString &rText )
         {
             pVlcProc->getStreamURIVar().addObserver( this );
         }
+        if( m_text.find( "$B" ) != UString::npos )
+        {
+            pVlcProc->getStreamBitRateVar().addObserver( this );
+        }
     }
 
     notify();
index 9bd0c497cf49b4b5e9758e7bd77f6dafa4dd4105..2371ff2d92acb74932b96e4a1d1e45530c8700b9 100644 (file)
                 <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="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%">
                     <SliderBackground image="volume_bg;volume_bg_2" nbvert="28" padvert="2" />
                 </Slider>