Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 74 |
1 files changed, 47 insertions, 27 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 4ae8490..84d28ce 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp @@ -40,40 +40,35 @@ _;:, .> :=|. This program is free software; you can /* QT */ #include <qtextstream.h> #include <qdir.h> #include <qgfx_qws.h> /* STD */ #include <assert.h> #include <unistd.h> typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, int width, int height,int bytes ); +typedef void (*vo_scale_cb) (void*, int, int, double, + int*, int*, int*, int*, double*, int*, int* ); +typedef void (*dest_size_cb) (void*, int, int, double, int*, int*, double*); + extern "C" { - xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); + xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void *, vo_scale_cb, dest_size_cb ); int null_is_showing_video( const xine_vo_driver_t* self ); void null_set_show_video( const xine_vo_driver_t* self, int show ); - int null_is_fullscreen( const xine_vo_driver_t* self ); - void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); - int null_is_scaling( const xine_vo_driver_t* self ); - void null_set_scaling( const xine_vo_driver_t* self, int scale ); - void null_set_gui_width( const xine_vo_driver_t* self, int width ); - void null_set_gui_height( const xine_vo_driver_t* self, int height ); void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); - void null_set_videoGamma( const xine_vo_driver_t* self , int value ); void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); - - void null_preload_decoders( xine_stream_t *stream ); } using namespace XINE; Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) { m_initialized = false; m_duringInitialization = false; m_video = false; m_wid = widget; printf("Lib"); QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; @@ -118,66 +113,65 @@ void Lib::initialize() { m_duringInitialization = true; m_xine = xine_new( ); QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; xine_config_load( m_xine, QFile::encodeName( configPath ) ); xine_init( m_xine ); // allocate oss for sound // and fb for framebuffer m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); - m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); + m_videoOutput = ::init_video_out_plugin( m_xine, NULL, + xine_display_frame, this, + xine_vo_scale_cb, + xine_dest_cb ); m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); if (m_wid != 0 ) setWidget( m_wid ); m_queue = xine_event_new_queue (m_stream); xine_event_create_listener_thread (m_queue, xine_event_handler, this); - ::null_preload_decoders( m_stream ); - m_duringInitialization = false; } Lib::~Lib() { assert( isRunning() == false ); assert( m_initialized ); // free( m_config ); xine_close( m_stream ); xine_event_dispose_queue( m_queue ); xine_dispose( m_stream ); xine_close_audio_driver(m_xine,m_audioOutput); xine_close_video_driver(m_xine,m_videoOutput); xine_exit( m_xine ); /* FIXME either free or delete but valgrind bitches against both */ //free( m_videoOutput ); //delete m_audioOutput; } void Lib::resize ( const QSize &s ) { assert( m_initialized || m_duringInitialization ); - if ( s. width ( ) && s. height ( ) ) { - ::null_set_gui_width( m_videoOutput, s. width() ); - ::null_set_gui_height( m_videoOutput, s. height() ); - } + if ( s. width ( ) && s. height ( ) ) + m_videoSize = s; } int Lib::majorVersion() { int major, minor, sub; xine_get_version ( &major, &minor, &sub ); return major; } int Lib::minorVersion() { int major, minor, sub; xine_get_version ( &major, &minor, &sub ); return minor; @@ -413,59 +407,85 @@ void Lib::setShowVideo( bool video ) { ::null_set_show_video( m_videoOutput, video ); } bool Lib::isShowingVideo() const { assert( m_initialized ); return ::null_is_showing_video( m_videoOutput ); } void Lib::showVideoFullScreen( bool fullScreen ) { assert( m_initialized ); - ::null_set_fullscreen( m_videoOutput, fullScreen ); + #warning use xine } bool Lib::isVideoFullScreen() const { assert( m_initialized ); - return ::null_is_fullscreen( m_videoOutput ); + #warning use xine + return false; } void Lib::setScaling( bool scale ) { assert( m_initialized ); - ::null_set_scaling( m_videoOutput, scale ); + xine_set_param( m_stream, XINE_PARAM_VO_ASPECT_RATIO, + scale ? XINE_VO_ASPECT_AUTO : XINE_VO_ASPECT_SQUARE ); } void Lib::setGamma( int value ) { assert( m_initialized ); - - ::null_set_videoGamma( m_videoOutput, value ); + xine_set_param( m_stream, XINE_PARAM_VO_BRIGHTNESS, value ); } bool Lib::isScaling() const { assert( m_initialized ); - return ::null_is_scaling( m_videoOutput ); + int aratio = xine_get_param( m_stream, XINE_PARAM_VO_ASPECT_RATIO ); + return aratio == XINE_VO_ASPECT_AUTO; } void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { ( (Lib*)user_data)->handleXineEvent( t ); } void Lib::xine_display_frame( void* user_data, uint8_t *frame, int width, int height, int bytes ) { ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); } +void Lib::xine_vo_scale_cb( void *user_data, int video_with, int video_height, + double video_pixel_aspect, + int *dest_x, int *dest_y, int *dest_width, + int *dest_height, double *dest_pixel_aspect, + int *win_x, int *win_y ) { + QSize size = ((Lib*)user_data)->m_videoSize; + if (!size.isValid()) + return; + + *dest_x = 0; + *dest_y = 0; + *dest_width = size.width(); + *dest_height = size.height(); + *win_x = 0; + *win_y = 0; +} + +void Lib::xine_dest_cb( void* user_data, int, int, double, + int *dest_width, int* dest_height, double* ) { + QSize size = ((Lib*)user_data)->m_videoSize; + if ( !size.isValid() ) + return; + + *dest_width = size.width(); + *dest_height = size.height(); +} + void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { assert( m_initialized ); - if ( !m_video ) { + if ( !m_video ) return; - } - -// assert( m_wid ); if (m_wid) m_wid-> setVideoFrame ( frame, width, height, bytes ); } |