-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 34 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 4 |
2 files changed, 32 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 9f7a9c5..4ae8490 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp @@ -273,54 +273,82 @@ int Lib::length() const { assert( m_initialized ); int pos, time, length; /* dilb: patch to solve the wrong stream length reported to the GUI*/ int iRetVal=0, iTestLoop=0; do { iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); if (iRetVal) {/* if the function didn't return 0, then pos, time and length are valid.*/ return length/1000; } /*don't poll too much*/ usleep(100000); iTestLoop++; } while ( iTestLoop < 10 ); /* if after 1s, we still don't have any valid stream, then return -1 (this value could be used to make the stream unseekable, but it should never occur!! Mr. Murphy ? :) ) */ return -1; } +/* info about current stream */ +QSize Lib::videoSize()const +{ + if (!m_initialized||!hasVideo()) return QSize(0,0); + int width = xine_get_stream_info(m_stream,XINE_STREAM_INFO_VIDEO_WIDTH); + int height = xine_get_stream_info(m_stream,XINE_STREAM_INFO_VIDEO_HEIGHT); + return QSize(width,height); +} + + bool Lib::isSeekable() const { assert( m_initialized ); return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); } +bool Lib::hasVideo() const { + assert( m_initialized ); + + return xine_get_stream_info( m_stream, XINE_STREAM_INFO_HAS_VIDEO); +} + +int Lib::audioBitrate()const +{ + if (!m_initialized) return 0; + return xine_get_stream_info( m_stream, XINE_STREAM_INFO_AUDIO_BITRATE); +} +int Lib::videoBitrate()const +{ + if (!m_initialized||!hasVideo()) return 0; + return xine_get_stream_info( m_stream, XINE_STREAM_INFO_VIDEO_BITRATE); +} +/* end info block */ + void Lib::seekTo( int time ) { assert( m_initialized ); odebug << "Seeking to second " << time << oendl; //Keep it paused if it was in that state if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) { xine_play( m_stream, 0, time*1000 ); } else { xine_play( m_stream, 0, time*1000 ); xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); } } QString Lib::metaInfo( int number) const { assert( m_initialized ); return xine_get_meta_info( m_stream, number ); } int Lib::error() const { @@ -370,54 +398,48 @@ void Lib::handleXineEvent( int type, int data, const char* name ) { assert( m_initialized ); if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { emit stopped(); }else if ( type == XINE_EVENT_PROGRESS ) { QString str = name == 0 ? QString::null : QString::fromUtf8( name ); Global::statusMessage( tr( "Progress: %1 %2" ).arg( name, data ) );; } } void Lib::setShowVideo( bool video ) { assert( m_initialized ); m_video = video; ::null_set_show_video( m_videoOutput, video ); } bool Lib::isShowingVideo() const { assert( m_initialized ); return ::null_is_showing_video( m_videoOutput ); } -bool Lib::hasVideo() const { - assert( m_initialized ); - - return xine_get_stream_info( m_stream, 18 ); -} - void Lib::showVideoFullScreen( bool fullScreen ) { assert( m_initialized ); ::null_set_fullscreen( m_videoOutput, fullScreen ); } bool Lib::isVideoFullScreen() const { assert( m_initialized ); return ::null_is_fullscreen( m_videoOutput ); } void Lib::setScaling( bool scale ) { assert( m_initialized ); ::null_set_scaling( m_videoOutput, scale ); } void Lib::setGamma( int value ) { assert( m_initialized ); ::null_set_videoGamma( m_videoOutput, value ); } diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 2f5bf86..2607193 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h @@ -150,48 +150,52 @@ namespace XINE { /** * */ void setScaling( bool ); /** * Set the Gamma value for video output * @param int the value between -100 and 100, 0 is original */ void setGamma( int ); /** * Returns the error code * XINE_ERROR_NONE 0 * XINE_ERROR_NO_INPUT_PLUGIN 1 * XINE_ERROR_NO_DEMUXER_PLUGIN 2 * XINE_ERROR_DEMUXER_FAILED 3 */ int error() const; void ensureInitialized(); void setWidget( XineVideoWidget *widget ); + QSize videoSize()const; + int audioBitrate()const; + int videoBitrate()const; + signals: void stopped(); void initialized(); protected: virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); virtual void run(); private: void initialize(); int m_bytes_per_pixel; bool m_initialized:1; bool m_duringInitialization:1; bool m_video:1; XineVideoWidget *m_wid; xine_t *m_xine; xine_stream_t *m_stream; xine_cfg_entry_t *m_config; xine_vo_driver_t *m_videoOutput; xine_ao_driver_t* m_audioOutput; |