summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp29
-rw-r--r--noncore/multimedia/opieplayer2/lib.h2
-rw-r--r--noncore/multimedia/opieplayer2/nullvideo.c11
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp18
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h3
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.h2
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp95
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.h20
9 files changed, 126 insertions, 60 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index eb57b67..00c534a 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -62,53 +62,56 @@ Lib::Lib(XineVideoWidget* widget) {
62 int i = 0; 62 int i = 0;
63 while ( ( out = files[i] ) != 0 ) { 63 while ( ( out = files[i] ) != 0 ) {
64 printf("Video %s\n", out ); 64 printf("Video %s\n", out );
65 i++; 65 i++;
66 } 66 }
67// m_xine = xine_init( m_videoOutput, 67// m_xine = xine_init( m_videoOutput,
68// m_audioOutput, 68// m_audioOutput,
69// m_config ); 69// m_config );
70 // test loading 70 // test loading
71 m_videoOutput = ::init_video_out_plugin( m_config, NULL ); 71 m_videoOutput = ::init_video_out_plugin( m_config, NULL );
72 if (m_wid != 0 ) { 72 if (m_wid != 0 ) {
73 printf("!0\n" ); 73 printf("!0\n" );
74 ::null_set_gui_width( m_videoOutput, m_wid->image()->width() ); 74 resize ( m_wid-> size ( ));
75 ::null_set_gui_height(m_videoOutput, m_wid->image()->height() );
76 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 75 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
77 m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; 76 m_wid-> setImage ( new QImage ( Resource::loadImage("")));
78 QImage image = Resource::loadImage("");
79 image = image.smoothScale( m_wid->width(), m_wid->height() );
80 QImage* img = new QImage( image );
81 m_wid->setImage( img );
82 m_wid->repaint(); 77 m_wid->repaint();
83 } 78 }
84 null_display_handler( m_videoOutput, 79 null_display_handler( m_videoOutput,
85 xine_display_frame, 80 xine_display_frame,
86 this ); 81 this );
87 82
88 m_xine = xine_init( m_videoOutput, 83 m_xine = xine_init( m_videoOutput,
89 m_audioOutput, m_config ); 84 m_audioOutput, m_config );
90 // install the event handler 85 // install the event handler
91 xine_register_event_listener( m_xine, xine_event_handler, this ); 86 xine_register_event_listener( m_xine, xine_event_handler, this );
92} 87}
93 88
94Lib::~Lib() { 89Lib::~Lib() {
95 delete m_config; 90 delete m_config;
96 xine_remove_event_listener( m_xine, xine_event_handler ); 91 xine_remove_event_listener( m_xine, xine_event_handler );
97 xine_exit( m_xine ); 92 xine_exit( m_xine );
98 delete m_videoOutput; 93 delete m_videoOutput;
99 //delete m_audioOutput; 94 //delete m_audioOutput;
100 95
101} 96}
102 97
98void Lib::resize ( const QSize &s )
99{
100 if ( s. width ( ) && s. height ( )) {
101 ::null_set_gui_width( m_videoOutput, s. width() );
102 ::null_set_gui_height(m_videoOutput, s. height() );
103 }
104}
105
103QCString Lib::version() { 106QCString Lib::version() {
104 QCString str( xine_get_str_version() ); 107 QCString str( xine_get_str_version() );
105 return str; 108 return str;
106}; 109};
107 110
108int Lib::majorVersion() { 111int Lib::majorVersion() {
109 return xine_get_major_version(); 112 return xine_get_major_version();
110} 113}
111int Lib::minorVersion() { 114int Lib::minorVersion() {
112 return xine_get_minor_version(); 115 return xine_get_minor_version();
113}; 116};
114 117
@@ -178,32 +181,26 @@ bool Lib::isVideoFullScreen() {
178} 181}
179void Lib::setScaling( bool scale ) { 182void Lib::setScaling( bool scale ) {
180 ::null_set_scaling( m_videoOutput, scale ); 183 ::null_set_scaling( m_videoOutput, scale );
181} 184}
182bool Lib::isScaling() { 185bool Lib::isScaling() {
183 return ::null_is_scaling( m_videoOutput ); 186 return ::null_is_scaling( m_videoOutput );
184} 187}
185void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { 188void Lib::xine_event_handler( void* user_data, xine_event_t* t ) {
186 ((Lib*)user_data)->handleXineEvent( t ); 189 ((Lib*)user_data)->handleXineEvent( t );
187} 190}
188void Lib::xine_display_frame( void* user_data, uint8_t *frame, 191void Lib::xine_display_frame( void* user_data, uint8_t *frame,
189 int width, int height, int bytes ) { 192 int width, int height, int bytes ) {
190// printf("display x frame"); 193
191 ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); 194 ((Lib*)user_data)->drawFrame( frame, width, height, bytes );
192// printf("displayed x frame\n");
193} 195}
194void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 196void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
195 if (!m_video ) { 197 if (!m_video ) {
196 qWarning("not showing video now"); 198 qWarning("not showing video now");
197 return; 199 return;
198 } 200 }
199// qWarning("called draw frame %d %d", width, height); 201// qWarning("called draw frame %d %d", width, height);
200 202
201 QSize size = m_wid->size(); 203 m_wid->setImage( frame, width, height, bytes );
202 int xoffset = (size.width() - width) / 2;
203 int yoffset = (size.height() - height) / 2;
204 int linestep = qt_screen->linestep();
205
206 m_wid->setImage( frame, yoffset, xoffset, width, height, linestep, bytes, m_bytes_per_pixel );
207// m_wid->repaint(false); 204// m_wid->repaint(false);
208 205
209} 206}
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index d568a32..a15f362 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -23,24 +23,26 @@ namespace XINE {
23 class Frame; 23 class Frame;
24 class Lib : public QObject { 24 class Lib : public QObject {
25 Q_OBJECT 25 Q_OBJECT
26 public: 26 public:
27 Lib(XineVideoWidget* = 0); 27 Lib(XineVideoWidget* = 0);
28 ~Lib(); 28 ~Lib();
29 QCString version(); 29 QCString version();
30 int majorVersion()/*const*/; 30 int majorVersion()/*const*/;
31 int minorVersion()/*const*/; 31 int minorVersion()/*const*/;
32 int subVersion()/*const*/; 32 int subVersion()/*const*/;
33 33
34 34
35 void resize ( const QSize &s );
36
35 int play( const QString& fileName, 37 int play( const QString& fileName,
36 int startPos = 0, 38 int startPos = 0,
37 int start_time = 0 ); 39 int start_time = 0 );
38 void stop() /*const*/; 40 void stop() /*const*/;
39 void pause()/*const*/; 41 void pause()/*const*/;
40 42
41 int speed() /*const*/; 43 int speed() /*const*/;
42 void setSpeed( int speed = SPEED_PAUSE ); 44 void setSpeed( int speed = SPEED_PAUSE );
43 45
44 int status() /*const*/; 46 int status() /*const*/;
45 47
46 int currentPosition()/*const*/; 48 int currentPosition()/*const*/;
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c
index 3a18a40..5ee8d5d 100644
--- a/noncore/multimedia/opieplayer2/nullvideo.c
+++ b/noncore/multimedia/opieplayer2/nullvideo.c
@@ -55,24 +55,25 @@ struct opie_frame_s {
55 int version; 55 int version;
56 int width; 56 int width;
57 int height; 57 int height;
58 int ratio_code; 58 int ratio_code;
59 int format; 59 int format;
60 int flags; 60 int flags;
61 int user_ratio; 61 int user_ratio;
62 62
63 double ratio_factor; 63 double ratio_factor;
64 int ideal_width; 64 int ideal_width;
65 int ideal_height; 65 int ideal_height;
66 int output_width, output_height; 66 int output_width, output_height;
67 int gui_width, gui_height;
67 uint8_t *chunk[3]; 68 uint8_t *chunk[3];
68 69
69 yuv2rgb_t *yuv2rgb; 70 yuv2rgb_t *yuv2rgb;
70 uint8_t *rgb_dst; 71 uint8_t *rgb_dst;
71 int yuv_stride; 72 int yuv_stride;
72 int stripe_height, stripe_inc; 73 int stripe_height, stripe_inc;
73 74
74 int bytes_per_line; 75 int bytes_per_line;
75 uint8_t *data; 76 uint8_t *data;
76 77
77// int show_video; 78// int show_video;
78 null_driver_t *output; 79 null_driver_t *output;
@@ -284,35 +285,37 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img,
284 printf("al crash aye?\n"); 285 printf("al crash aye?\n");
285 286
286 flags &= VO_BOTH_FIELDS; 287 flags &= VO_BOTH_FIELDS;
287 288
288 /* find out if we need to adapt this frame */ 289 /* find out if we need to adapt this frame */
289 290
290 if ((width != frame->width) 291 if ((width != frame->width)
291 || (height != frame->height) 292 || (height != frame->height)
292 || (ratio_code != frame->ratio_code) 293 || (ratio_code != frame->ratio_code)
293 || (flags != frame->flags) 294 || (flags != frame->flags)
294 || (format != frame->format) 295 || (format != frame->format)
295 || (this->user_ratio != frame->user_ratio) 296 || (this->user_ratio != frame->user_ratio)
296 || this->gui_changed ) { 297 || (this->gui_width != frame-> gui_width )
298 || (this-> gui_height != frame-> gui_height)) {
297 299
298 frame->width = width; 300 frame->width = width;
299 frame->height = height; 301 frame->height = height;
300 frame->ratio_code = ratio_code; 302 frame->ratio_code = ratio_code;
301 frame->flags = flags; 303 frame->flags = flags;
302 frame->format = format; 304 frame->format = format;
303 frame->user_ratio = this->user_ratio; 305 frame->user_ratio = this->user_ratio;
304 this->gui_changed = 0; 306 this->gui_changed = 0;
305 //frame->show_video = this->m_show_video; 307 //frame->show_video = this->m_show_video;
306 308 frame->gui_width = this->gui_width;
309 frame->gui_height = this->gui_height;
307 310
308 null_compute_ideal_size (this, frame); 311 null_compute_ideal_size (this, frame);
309 null_compute_rgb_size (this, frame); 312 null_compute_rgb_size (this, frame);
310 313
311 /* 314 /*
312 * (re-) allocate 315 * (re-) allocate
313 */ 316 */
314 if( frame->data ) { 317 if( frame->data ) {
315 if(frame->chunk[0] ){ 318 if(frame->chunk[0] ){
316 free( frame->chunk[0] ); 319 free( frame->chunk[0] );
317 frame->chunk[0] = NULL; 320 frame->chunk[0] = NULL;
318 } 321 }
@@ -527,26 +530,26 @@ static int null_redraw_needed( vo_driver_t* self ){
527vo_driver_t* init_video_out_plugin( config_values_t* conf, 530vo_driver_t* init_video_out_plugin( config_values_t* conf,
528 void* video ){ 531 void* video ){
529 null_driver_t *vo; 532 null_driver_t *vo;
530 vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); 533 vo = (null_driver_t*)malloc( sizeof(null_driver_t ) );
531 534
532 /* memset? */ 535 /* memset? */
533 memset(vo,0, sizeof(null_driver_t ) ); 536 memset(vo,0, sizeof(null_driver_t ) );
534 vo->m_show_video = 0; // false 537 vo->m_show_video = 0; // false
535 vo->m_video_fullscreen = 0; 538 vo->m_video_fullscreen = 0;
536 vo->m_is_scaling = 0; 539 vo->m_is_scaling = 0;
537 vo->user_ratio = ASPECT_AUTO; 540 vo->user_ratio = ASPECT_AUTO;
538 vo->display_ratio = 1.0; 541 vo->display_ratio = 1.0;
539 vo->gui_width = 200; 542 vo->gui_width = 16;
540 vo->gui_height = 150; 543 vo->gui_height = 8;
541 vo->frameDis = NULL; 544 vo->frameDis = NULL;
542 545
543 /* install callback handlers*/ 546 /* install callback handlers*/
544 vo->vo_driver.get_capabilities = null_get_capabilities; 547 vo->vo_driver.get_capabilities = null_get_capabilities;
545 vo->vo_driver.alloc_frame = null_alloc_frame; 548 vo->vo_driver.alloc_frame = null_alloc_frame;
546 vo->vo_driver.update_frame_format = null_update_frame_format; 549 vo->vo_driver.update_frame_format = null_update_frame_format;
547 vo->vo_driver.display_frame = null_display_frame; 550 vo->vo_driver.display_frame = null_display_frame;
548 vo->vo_driver.overlay_blend = null_overlay_blend; 551 vo->vo_driver.overlay_blend = null_overlay_blend;
549 vo->vo_driver.get_property = null_get_property; 552 vo->vo_driver.get_property = null_get_property;
550 vo->vo_driver.set_property = null_set_property; 553 vo->vo_driver.set_property = null_set_property;
551 vo->vo_driver.get_property_min_max = null_get_property_min_max; 554 vo->vo_driver.get_property_min_max = null_get_property_min_max;
552 vo->vo_driver.gui_data_exchange = null_gui_data_exchange; 555 vo->vo_driver.gui_data_exchange = null_gui_data_exchange;
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 48caf00..af06079 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -101,43 +101,45 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
101 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); 101 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) );
102 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); 102 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) );
103 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); 103 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) );
104 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 104 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
105 105
106 slider = new QSlider( Qt::Horizontal, this ); 106 slider = new QSlider( Qt::Horizontal, this );
107 slider->setMinValue( 0 ); 107 slider->setMinValue( 0 );
108 slider->setMaxValue( 1 ); 108 slider->setMaxValue( 1 );
109 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 109 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
110 slider->setFocusPolicy( QWidget::NoFocus ); 110 slider->setFocusPolicy( QWidget::NoFocus );
111 slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 111 slider->setGeometry( QRect( 7, 250, 220, 20 ) );
112 112
113 videoFrame = new XineVideoWidget ( this, "Video frame" );
114
115 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
116
113 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 117 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
114 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 118 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
115 119
116 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 120 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
117 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 121 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
118 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 122 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
119 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 123 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
120 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 124 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
121 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 125 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
122 126
123 // Intialise state 127 // Intialise state
124 setLength( mediaPlayerState->length() ); 128 setLength( mediaPlayerState->length() );
125 setPosition( mediaPlayerState->position() ); 129 setPosition( mediaPlayerState->position() );
126 setFullscreen( mediaPlayerState->fullscreen() ); 130 setFullscreen( mediaPlayerState->fullscreen() );
127 setPaused( mediaPlayerState->paused() ); 131 setPaused( mediaPlayerState->paused() );
128 setPlaying( mediaPlayerState->playing() ); 132 setPlaying( mediaPlayerState->playing() );
129 133
130 videoFrame = new XineVideoWidget( 240, 155 ,this, "Video frame" );
131
132} 134}
133 135
134 136
135VideoWidget::~VideoWidget() { 137VideoWidget::~VideoWidget() {
136 for ( int i = 0; i < 3; i++ ) { 138 for ( int i = 0; i < 3; i++ ) {
137 delete pixmaps[i]; 139 delete pixmaps[i];
138 } 140 }
139 delete currentFrame; 141 delete currentFrame;
140} 142}
141 143
142 144
143static bool videoSliderBeingMoved = FALSE; 145static bool videoSliderBeingMoved = FALSE;
@@ -270,44 +272,46 @@ void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
270 272
271 mouseMoveEvent( event ); 273 mouseMoveEvent( event );
272 } 274 }
273} 275}
274 276
275 277
276void VideoWidget::makeVisible() { 278void VideoWidget::makeVisible() {
277 if ( mediaPlayerState->fullscreen() ) { 279 if ( mediaPlayerState->fullscreen() ) {
278 setBackgroundMode( QWidget::NoBackground ); 280 setBackgroundMode( QWidget::NoBackground );
279 showFullScreen(); 281 showFullScreen();
280 resize( qApp->desktop()->size() ); 282 resize( qApp->desktop()->size() );
281 slider->hide(); 283 slider->hide();
284 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
282 } else { 285 } else {
283 setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 286 setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
284 showNormal(); 287 showNormal();
285 showMaximized(); 288 showMaximized();
286 slider->show(); 289 slider->show();
290 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) );
287 } 291 }
288} 292}
289 293
290 294
291void VideoWidget::paintEvent( QPaintEvent * ) { 295void VideoWidget::paintEvent( QPaintEvent * ) {
292 QPainter p( this ); 296 QPainter p( this );
293 297
294 if ( mediaPlayerState->fullscreen() ) { 298 if ( mediaPlayerState->fullscreen() ) {
295 // Clear the background 299 // Clear the background
296 p.setBrush( QBrush( Qt::black ) ); 300 p.setBrush( QBrush( Qt::black ) );
297 videoFrame->setGeometry( QRect( 0, 0 , 240 ,340 ) ); 301// videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) );
298 302
299 } else { 303 } else {
300 304
301 videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); 305 // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) );
302 // draw the buttons 306 // draw the buttons
303 307
304 for ( int i = 0; i < numButtons; i++ ) { 308 for ( int i = 0; i < numButtons; i++ ) {
305 paintButton( &p, i ); 309 paintButton( &p, i );
306 } 310 }
307 // draw the slider 311 // draw the slider
308 slider->repaint( TRUE ); 312 slider->repaint( TRUE );
309 } 313 }
310} 314}
311 315
312 316
313void VideoWidget::closeEvent( QCloseEvent* ) { 317void VideoWidget::closeEvent( QCloseEvent* ) {
@@ -373,12 +377,18 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e)
373 break; 377 break;
374 case Key_Left: 378 case Key_Left:
375 mediaPlayerState->setPrev(); 379 mediaPlayerState->setPrev();
376 break; 380 break;
377 case Key_Escape: 381 case Key_Escape:
378 break; 382 break;
379 383
380 }; 384 };
381} 385}
382XineVideoWidget* VideoWidget::vidWidget() { 386XineVideoWidget* VideoWidget::vidWidget() {
383 return videoFrame; 387 return videoFrame;
384} 388}
389
390
391void VideoWidget::setFullscreen ( bool b )
392{
393 setToggleButton( VideoFullscreen, b );
394} \ No newline at end of file
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 0122d5d..fc53f89 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -55,32 +55,33 @@ class VideoWidget : public QWidget {
55public: 55public:
56 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 56 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
57 ~VideoWidget(); 57 ~VideoWidget();
58 58
59 bool playVideo(); 59 bool playVideo();
60 XineVideoWidget* vidWidget(); 60 XineVideoWidget* vidWidget();
61public slots: 61public slots:
62 void updateSlider( long, long ); 62 void updateSlider( long, long );
63 void sliderPressed( ); 63 void sliderPressed( );
64 void sliderReleased( ); 64 void sliderReleased( );
65 void setPaused( bool b) { setToggleButton( VideoPause, b ); } 65 void setPaused( bool b) { setToggleButton( VideoPause, b ); }
66 void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } 66 void setPlaying( bool b) { setToggleButton( VideoPlay, b ); }
67 void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); } 67 void setFullscreen( bool b );
68 void makeVisible(); 68 void makeVisible();
69 void setPosition( long ); 69 void setPosition( long );
70 void setLength( long ); 70 void setLength( long );
71 void setView( char ); 71 void setView( char );
72 72
73signals: 73signals:
74 void sliderMoved( long ); 74 void sliderMoved( long );
75 void videoResized ( const QSize &s );
75 76
76protected: 77protected:
77 void paintEvent( QPaintEvent *pe ); 78 void paintEvent( QPaintEvent *pe );
78 void mouseMoveEvent( QMouseEvent *event ); 79 void mouseMoveEvent( QMouseEvent *event );
79 void mousePressEvent( QMouseEvent *event ); 80 void mousePressEvent( QMouseEvent *event );
80 void mouseReleaseEvent( QMouseEvent *event ); 81 void mouseReleaseEvent( QMouseEvent *event );
81 void closeEvent( QCloseEvent *event ); 82 void closeEvent( QCloseEvent *event );
82 void keyReleaseEvent( QKeyEvent *e); 83 void keyReleaseEvent( QKeyEvent *e);
83 84
84private: 85private:
85 void paintButton( QPainter *p, int i ); 86 void paintButton( QPainter *p, int i );
86 void toggleButton( int ); 87 void toggleButton( int );
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 19a9172..33889d0 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -34,24 +34,25 @@
34 34
35#include <qtimer.h> 35#include <qtimer.h>
36#include "xinecontrol.h" 36#include "xinecontrol.h"
37#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
38#include "videowidget.h" 38#include "videowidget.h"
39 39
40extern MediaPlayerState *mediaPlayerState; 40extern MediaPlayerState *mediaPlayerState;
41extern VideoWidget *videoUI; 41extern VideoWidget *videoUI;
42XineControl::XineControl( QObject *parent, const char *name ) 42XineControl::XineControl( QObject *parent, const char *name )
43 : QObject( parent, name ) { 43 : QObject( parent, name ) {
44 libXine = new XINE::Lib(videoUI->vidWidget() ); 44 libXine = new XINE::Lib(videoUI->vidWidget() );
45 45
46 connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & )));
46 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); 47 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) );
47 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); 48 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) );
48 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( setPosition( long ) ) ); 49 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( setPosition( long ) ) );
49 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 50 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
50 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 51 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
51 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 52 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
52 53
53} 54}
54 55
55XineControl::~XineControl() { 56XineControl::~XineControl() {
56 delete libXine; 57 delete libXine;
57} 58}
@@ -119,12 +120,17 @@ long XineControl::position() {
119// qDebug("POSITION : %d", m_position); 120// qDebug("POSITION : %d", m_position);
120 return m_position; 121 return m_position;
121} 122}
122 123
123void XineControl::setFullscreen( bool isSet ) { 124void XineControl::setFullscreen( bool isSet ) {
124 libXine->showVideoFullScreen( isSet); 125 libXine->showVideoFullScreen( isSet);
125} 126}
126 127
127void XineControl::seekTo( long second ) { 128void XineControl::seekTo( long second ) {
128 // libXine-> 129 // libXine->
129} 130}
130 131
132
133void XineControl::videoResized ( const QSize &s )
134{
135 libXine-> resize ( s );
136}
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h
index 295d2b4..4a61f32 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.h
+++ b/noncore/multimedia/opieplayer2/xinecontrol.h
@@ -47,24 +47,26 @@ public:
47 47
48public slots: 48public slots:
49 void play( const QString& fileName ); 49 void play( const QString& fileName );
50 void stop( bool ); 50 void stop( bool );
51 void pause( bool ); 51 void pause( bool );
52 void setFullscreen( bool ); 52 void setFullscreen( bool );
53 long currentTime(); 53 long currentTime();
54 void seekTo( long ); 54 void seekTo( long );
55 // get length of media file and set it 55 // get length of media file and set it
56 void length(); 56 void length();
57 long position(); 57 long position();
58 58
59 void videoResized ( const QSize &s );
60
59private: 61private:
60 XINE::Lib *libXine; 62 XINE::Lib *libXine;
61 MediaDetect mdetect; 63 MediaDetect mdetect;
62 long m_currentTime; 64 long m_currentTime;
63 long m_position; 65 long m_position;
64 66
65signals: 67signals:
66 void positionChanged( long ); 68 void positionChanged( long );
67 69
68}; 70};
69 71
70 72
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 4b69044..98446a0 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -29,29 +29,31 @@
29 If not, write to the Free Software Foundation, 29 If not, write to the Free Software Foundation,
30 Inc., 59 Temple Place - Suite 330, 30 Inc., 59 Temple Place - Suite 330,
31 Boston, MA 02111-1307, USA. 31 Boston, MA 02111-1307, USA.
32 32
33*/ 33*/
34 34
35#include <qimage.h> 35#include <qimage.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qgfx_qws.h> 37#include <qgfx_qws.h>
38#include <qdirectpainter_qws.h> 38#include <qdirectpainter_qws.h>
39#include <qgfx_qws.h> 39#include <qgfx_qws.h>
40#include <qsize.h> 40#include <qsize.h>
41#include <qapplication.h>
41 42
42#include <qpe/resource.h> 43#include <qpe/resource.h>
43 44
44#include "xinevideowidget.h" 45#include "xinevideowidget.h"
45 46
47
46static inline void memcpy_rev ( void *dst, void *src, size_t len ) 48static inline void memcpy_rev ( void *dst, void *src, size_t len )
47{ 49{
48 ((char *) src ) += len; 50 ((char *) src ) += len;
49 51
50 len >>= 1; 52 len >>= 1;
51 while ( len-- ) 53 while ( len-- )
52 *((short int *) dst )++ = *--((short int *) src ); 54 *((short int *) dst )++ = *--((short int *) src );
53} 55}
54 56
55static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) 57static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step )
56{ 58{
57 len >>= 1; 59 len >>= 1;
@@ -65,68 +67,67 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t st
65{ 67{
66 len >>= 1; 68 len >>= 1;
67 69
68 ((char *) src ) += ( len * step ); 70 ((char *) src ) += ( len * step );
69 71
70 while ( len-- ) { 72 while ( len-- ) {
71 ((char *) src ) -= step; 73 ((char *) src ) -= step;
72 *((short int *) dst )++ = *((short int *) src ); 74 *((short int *) dst )++ = *((short int *) src );
73 } 75 }
74} 76}
75 77
76 78
77XineVideoWidget::XineVideoWidget( int width, 79XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name )
78 int height,
79 QWidget* parent,
80 const char* name )
81 : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) 80 : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase )
82{ 81{
83 m_image = new QImage ( width, height, qt_screen-> depth ( ));
84 m_buff = 0;
85 setBackgroundMode ( NoBackground ); 82 setBackgroundMode ( NoBackground );
86 /* QImage image = Resource::loadImage("SoundPlayer"); 83
87 image = image.smoothScale( width, height ); 84 m_image = 0;
88 85 m_buff = 0;
89 m_image = new QImage( image );*/ 86 m_bytes_per_line_fb = qt_screen-> linestep ( );
87 m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8;
88 m_rotation = 0;
90} 89}
91 90
91
92XineVideoWidget::~XineVideoWidget ( ) 92XineVideoWidget::~XineVideoWidget ( )
93{ 93{
94 delete m_image; 94 delete m_image;
95} 95}
96 96
97void XineVideoWidget::clear ( ) 97void XineVideoWidget::clear ( )
98{ 98{
99 m_buff = 0; 99 m_buff = 0;
100 repaint ( false ); 100 repaint ( false );
101} 101}
102 102
103void XineVideoWidget::paintEvent ( QPaintEvent * ) 103void XineVideoWidget::paintEvent ( QPaintEvent * )
104{ 104{
105 //qWarning( "painting <<<" ); 105 //qWarning( "painting <<<" );
106 if ( m_buff == 0 ) { 106 if ( m_buff == 0 ) {
107 QPainter p ( this ); 107 QPainter p ( this );
108 p. fillRect ( rect ( ), black ); 108 p. fillRect ( rect ( ), black );
109 p. drawImage ( 0, 0, *m_image ); 109 if ( m_image )
110 p. drawImage ( 0, 0, *m_image );
110 //qWarning ( "logo\n" ); 111 //qWarning ( "logo\n" );
111 } 112 }
112 else { 113 else {
113 // qWarning ( "paintevent\n" ); 114 // qWarning ( "paintevent\n" );
114 115
115 QArray <QRect> qt_bug_workaround_clip_rects; 116 QArray <QRect> qt_bug_workaround_clip_rects;
116 117
117 { 118 {
118 QDirectPainter dp ( this ); 119 QDirectPainter dp ( this );
119 120
120 int rot = dp. transformOrientation ( ); 121 int rot = dp. transformOrientation ( ) + m_rotation;
121 122
122 uchar *fb = dp. frameBuffer ( ); 123 uchar *fb = dp. frameBuffer ( );
123 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; 124 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame;
124 125
125 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); 126 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
126 127
127 qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); 128 qt_bug_workaround_clip_rects. resize ( dp. numRects ( ));
128 129
129 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { 130 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) {
130 const QRect &clip = dp. rect ( i ); 131 const QRect &clip = dp. rect ( i );
131 132
132 qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); 133 qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
@@ -188,43 +189,79 @@ void XineVideoWidget::paintEvent ( QPaintEvent * )
188 { 189 {
189 // QVFB hack by MArtin Jones 190 // QVFB hack by MArtin Jones
190 QPainter p ( this ); 191 QPainter p ( this );
191 192
192 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { 193 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) {
193 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); 194 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) );
194 } 195 }
195 } 196 }
196 } 197 }
197 //qWarning( "painting >>>" ); 198 //qWarning( "painting >>>" );
198} 199}
199 200
200int XineVideoWidget::height ( ) const
201{
202 return m_image-> height ( );
203}
204
205int XineVideoWidget::width ( ) const
206{
207 return m_image-> width ( );
208}
209 201
210void XineVideoWidget::setImage ( QImage* image ) 202void XineVideoWidget::setImage ( QImage* image )
211{ 203{
212 delete m_image; 204 delete m_image;
213 m_image = image; 205 m_image = image;
214} 206}
215 207
216void XineVideoWidget::setImage( uchar* image, int yoffsetXLine, 208void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl )
217 int xoffsetXBytes, int width,
218 int height, int linestep, int bytes, int bpp )
219{ 209{
210 bool rot90 = (( -m_rotation ) & 1 );
211
212 if ( rot90 ) {
213 int d = w;
214 w = h;
215 h = d;
216 }
220 217
221 m_lastframe = m_thisframe; 218 m_lastframe = m_thisframe;
222 m_thisframe. setRect ( xoffsetXBytes, yoffsetXLine, width, height ); 219 m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h );
223 220
224 m_buff = image; 221 //qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h );
225 m_bytes_per_line_fb = linestep; 222
226 m_bytes_per_line_frame = bytes; 223 m_buff = img;
227 m_bytes_per_pixel = bpp; 224 m_bytes_per_line_frame = bpl;
228 225
229 repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); 226 repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false );
230} 227}
228
229void XineVideoWidget::resizeEvent ( QResizeEvent * )
230{
231 QSize s = size ( );
232 bool fs = ( s == qApp-> desktop ( )-> size ( ));
233
234 m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0;
235
236 if ( fs && qt_screen-> isTransformed ( )) {
237 s = qt_screen-> mapToDevice ( s );
238 }
239
240 //qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation );
241
242 emit videoResized ( s );
243}
244
245
246void XineVideoWidget::mousePressEvent ( QMouseEvent *me )
247{
248 QWidget *p = parentWidget ( );
249
250 if ( p ) {
251 QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( ));
252
253 QApplication::sendEvent ( p, &pme );
254 }
255}
256
257void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me )
258{
259 QWidget *p = parentWidget ( );
260
261 if ( p ) {
262 QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( ));
263
264 QApplication::sendEvent ( p, &pme );
265 }
266}
267
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h
index 7d9a6d2..2fc627d 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.h
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.h
@@ -26,39 +26,47 @@
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34 34
35 35
36#include <qwidget.h> 36#include <qwidget.h>
37 37
38#include "lib.h"
39
38class QImage; 40class QImage;
39class XineVideoWidget : public QWidget { 41class XineVideoWidget : public QWidget {
40 Q_OBJECT 42 Q_OBJECT
41public: 43public:
42 XineVideoWidget( int width, int height, QWidget* parent, const char* name ); 44 XineVideoWidget( QWidget* parent, const char* name );
43 ~XineVideoWidget(); 45 ~XineVideoWidget();
44 QImage *image() { return m_image; }; 46 QImage *image() { return m_image; };
45 void setImage( QImage* image ); 47 void setImage( QImage* image );
46 void setImage( uchar* image, int yoffsetXLine, int xoffsetXBytes, 48 void setImage( uchar* image, int width, int height, int linestep);
47 int width, int height, int linestep, int bytes, int bpp);
48 int width() const;
49 int height() const;
50 void clear() ; 49 void clear() ;
50
51protected: 51protected:
52 void paintEvent( QPaintEvent* p ); 52 void paintEvent( QPaintEvent* p );
53 void resizeEvent ( QResizeEvent *r );
54
55 void mousePressEvent ( QMouseEvent *e );
56 void mouseReleaseEvent ( QMouseEvent *e );
57
58signals:
59 void videoResized ( const QSize &s );
60
53private: 61private:
54 QRect m_lastframe; 62 QRect m_lastframe;
55 QRect m_thisframe; 63 QRect m_thisframe;
56 64
57 uchar* m_buff; 65 uchar* m_buff;
58 int m_bytes_per_line_fb; 66 int m_bytes_per_line_fb;
59 int m_bytes_per_line_frame; 67 int m_bytes_per_line_frame;
60 int m_bytes_per_pixel; 68 int m_bytes_per_pixel;
61 QImage* m_image; 69 QImage* m_image;
62 70 int m_rotation;
63}; 71};
64 72