author | alwin <alwin> | 2005-04-12 13:33:37 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-04-12 13:33:37 (UTC) |
commit | 6df2eb36803e072ea9db62153b762250742610f0 (patch) (side-by-side diff) | |
tree | 5e80ac2c581ffe19478110233dbd93ae1977f99f | |
parent | 81b7ea55be071eab5f8b4afd2c4c291dee365545 (diff) | |
download | opie-6df2eb36803e072ea9db62153b762250742610f0.zip opie-6df2eb36803e072ea9db62153b762250742610f0.tar.gz opie-6df2eb36803e072ea9db62153b762250742610f0.tar.bz2 |
some usefull xine-helpers
-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 @@ -265,70 +265,98 @@ int Lib::currentTime() const { if ( xine_get_pos_length( m_stream, &pos, &time, &length ) ) return time/1000; else return 0; } 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 { assert( m_initialized ); return xine_get_error( m_stream ); }; void Lib::ensureInitialized() { if ( m_initialized ) @@ -362,70 +390,64 @@ void Lib::handleXineEvent( const xine_event_t* t ) { prog = pt->percent; name = pt->description; } send( new ThreadUtil::ChannelMessage( t->type, prog, name ), OneWay ); } 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 ); } bool Lib::isScaling() const { assert( m_initialized ); return ::null_is_scaling( m_videoOutput ); } void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { ( (Lib*)user_data)->handleXineEvent( t ); 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 @@ -142,64 +142,68 @@ namespace XINE { void seekTo( int time ); /** * * @return is media stream has video */ bool hasVideo() const; /** * */ 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; xine_event_queue_t *m_queue; void handleXineEvent( const xine_event_t* t ); void handleXineEvent( int type, int data, const char* name ); void drawFrame( uint8_t* frame, int width, int height, int bytes ); // C -> C++ bridge for the event system static void xine_event_handler( void* user_data, const xine_event_t* t); static void xine_display_frame( void* user_data, uint8_t* frame , |