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
@@ -50,77 +50,80 @@ Lib::Lib(XineVideoWidget* widget) {
50 else 50 else
51 printf("Success\n"); 51 printf("Success\n");
52 52
53 53
54 // test code 54 // test code
55/* m_videoOutput = xine_load_video_output_plugin(m_config, "fb", 55/* m_videoOutput = xine_load_video_output_plugin(m_config, "fb",
56 VISUAL_TYPE_FB, 56 VISUAL_TYPE_FB,
57 0 ); 57 0 );
58*/ 58*/
59 59
60 char** files = xine_list_video_output_plugins(3); 60 char** files = xine_list_video_output_plugins(3);
61 char* out; 61 char* out;
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
115int Lib::subVersion() { 118int Lib::subVersion() {
116 return xine_get_sub_version(); 119 return xine_get_sub_version();
117} 120}
118int Lib::play( const QString& fileName, 121int Lib::play( const QString& fileName,
119 int startPos, 122 int startPos,
120 int start_time ) { 123 int start_time ) {
121 QString str = fileName.stripWhiteSpace(); 124 QString str = fileName.stripWhiteSpace();
122 //workaround OpiePlayer bug 125 //workaround OpiePlayer bug
123 if (str.right(1) == QString::fromLatin1("/") ) 126 if (str.right(1) == QString::fromLatin1("/") )
124 str = str.mid( str.length() -1 ); 127 str = str.mid( str.length() -1 );
125 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), 128 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(),
126 startPos, start_time); 129 startPos, start_time);
@@ -166,44 +169,38 @@ void Lib::handleXineEvent( xine_event_t* t ) {
166void Lib::setShowVideo( bool video ) { 169void Lib::setShowVideo( bool video ) {
167 m_video = video; 170 m_video = video;
168 ::null_set_show_video( m_videoOutput, video ); 171 ::null_set_show_video( m_videoOutput, video );
169} 172}
170bool Lib::isShowingVideo() { 173bool Lib::isShowingVideo() {
171 return ::null_is_showing_video( m_videoOutput ); 174 return ::null_is_showing_video( m_videoOutput );
172} 175}
173void Lib::showVideoFullScreen( bool fullScreen ) { 176void Lib::showVideoFullScreen( bool fullScreen ) {
174 ::null_set_fullscreen( m_videoOutput, fullScreen ); 177 ::null_set_fullscreen( m_videoOutput, fullScreen );
175} 178}
176bool Lib::isVideoFullScreen() { 179bool Lib::isVideoFullScreen() {
177 return ::null_is_fullscreen( m_videoOutput ); 180 return ::null_is_fullscreen( m_videoOutput );
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
@@ -11,48 +11,50 @@
11 11
12class XineVideoWidget; 12class XineVideoWidget;
13 13
14namespace XINE { 14namespace XINE {
15 15
16 /** 16 /**
17 * Lib wrapps the simple interface 17 * Lib wrapps the simple interface
18 * of libxine for easy every day use 18 * of libxine for easy every day use
19 * This will become a full C++ Wrapper 19 * This will become a full C++ Wrapper
20 * It supports playing, pausing, info, 20 * It supports playing, pausing, info,
21 * stooping, seeking. 21 * stooping, seeking.
22 */ 22 */
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*/;
47 //in seconds 49 //in seconds
48 int currentTime()/*const*/; 50 int currentTime()/*const*/;
49 int length() /*const*/; 51 int length() /*const*/;
50 52
51 bool isSeekable()/*const*/; 53 bool isSeekable()/*const*/;
52 54
53 /** 55 /**
54 * Whether or not to show video output 56 * Whether or not to show video output
55 */ 57 */
56 void setShowVideo(bool video); 58 void setShowVideo(bool video);
57 59
58 /** 60 /**
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
@@ -43,48 +43,49 @@ struct null_driver_s {
43 int gui_height; 43 int gui_height;
44 int gui_changed; 44 int gui_changed;
45 double display_ratio; 45 double display_ratio;
46 void* caller; 46 void* caller;
47 display_xine_frame_t frameDis; 47 display_xine_frame_t frameDis;
48 48
49 49
50}; 50};
51typedef struct opie_frame_s opie_frame_t; 51typedef struct opie_frame_s opie_frame_t;
52struct opie_frame_s { 52struct opie_frame_s {
53 vo_frame_t frame; 53 vo_frame_t frame;
54 char* name; 54 char* name;
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;
79}; 80};
80 81
81static uint32_t null_get_capabilities(vo_driver_t *self ){ 82static uint32_t null_get_capabilities(vo_driver_t *self ){
82 null_driver_t* this = (null_driver_t*)self; 83 null_driver_t* this = (null_driver_t*)self;
83 printf("capabilities\n"); 84 printf("capabilities\n");
84 return this->m_capabilities; 85 return this->m_capabilities;
85} 86}
86 87
87static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { 88static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) {
88 opie_frame_t *frame = (opie_frame_t *) vo_img ; 89 opie_frame_t *frame = (opie_frame_t *) vo_img ;
89 printf("frame copy\n"); 90 printf("frame copy\n");
90 if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video 91 if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video
@@ -272,59 +273,61 @@ static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) {
272 273
273 274
274// size specific 275// size specific
275 276
276 277
277static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, 278static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img,
278 uint32_t width, uint32_t height, 279 uint32_t width, uint32_t height,
279 int ratio_code, int format, int flags ){ 280 int ratio_code, int format, int flags ){
280 null_driver_t* this = (null_driver_t*) self; 281 null_driver_t* this = (null_driver_t*) self;
281 opie_frame_t* frame = (opie_frame_t*)img; 282 opie_frame_t* frame = (opie_frame_t*)img;
282 /* not needed now */ 283 /* not needed now */
283 printf("update_frame_format\n"); 284 printf("update_frame_format\n");
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 }
319 if(frame->chunk[1] ){ 322 if(frame->chunk[1] ){
320 free ( frame->chunk[1] ); 323 free ( frame->chunk[1] );
321 frame->chunk[1] = NULL; 324 frame->chunk[1] = NULL;
322 } 325 }
323 if(frame->chunk[2] ){ 326 if(frame->chunk[2] ){
324 free ( frame->chunk[2] ); 327 free ( frame->chunk[2] );
325 frame->chunk[2] = NULL; 328 frame->chunk[2] = NULL;
326 } 329 }
327 free ( frame->data ); 330 free ( frame->data );
328 } 331 }
329 printf("after freeing\n"); 332 printf("after freeing\n");
330 frame->data = xine_xmalloc (frame->output_width * frame->output_height * 333 frame->data = xine_xmalloc (frame->output_width * frame->output_height *
@@ -515,50 +518,50 @@ static int null_gui_data_exchange( vo_driver_t* self,
515 void *data ){ 518 void *data ){
516 return 0; 519 return 0;
517} 520}
518static void null_exit( vo_driver_t* self ){ 521static void null_exit( vo_driver_t* self ){
519 null_driver_t* this = (null_driver_t*)self; 522 null_driver_t* this = (null_driver_t*)self;
520 free ( this ); 523 free ( this );
521} 524}
522static int null_redraw_needed( vo_driver_t* self ){ 525static int null_redraw_needed( vo_driver_t* self ){
523 return 0; 526 return 0;
524} 527}
525 528
526 529
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;
553 vo->vo_driver.exit = null_exit; 556 vo->vo_driver.exit = null_exit;
554 vo->vo_driver.redraw_needed = null_redraw_needed; 557 vo->vo_driver.redraw_needed = null_redraw_needed;
555 558
556 559
557 /* capabilities */ 560 /* capabilities */
558 vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12; 561 vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12;
559 vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, 562 vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap,
560 vo->yuv2rgb_cmap); 563 vo->yuv2rgb_cmap);
561 printf("done initialisation\n"); 564 printf("done initialisation\n");
562 return (vo_driver_t*) vo; 565 return (vo_driver_t*) vo;
563} 566}
564 567
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
@@ -89,67 +89,69 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
89 QString Button0aPix, Button0bPix, controlsPix; 89 QString Button0aPix, Button0bPix, controlsPix;
90 //backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish"); 90 //backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish");
91 Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); 91 Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a");
92 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); 92 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b");
93 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); 93 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" );
94 94
95 cfg.setGroup("AudioWidget"); 95 cfg.setGroup("AudioWidget");
96 QString skin = cfg.readEntry("Skin","default"); 96 QString skin = cfg.readEntry("Skin","default");
97 QString skinPath = "opieplayer/skins/" + skin; 97 QString skinPath = "opieplayer/skins/" + skin;
98 backgroundPix = QString("%1/background").arg(skinPath) ; 98 backgroundPix = QString("%1/background").arg(skinPath) ;
99 99
100 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 100 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
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;
144 146
145 147
146void VideoWidget::sliderPressed() { 148void VideoWidget::sliderPressed() {
147 videoSliderBeingMoved = TRUE; 149 videoSliderBeingMoved = TRUE;
148} 150}
149 151
150 152
151void VideoWidget::sliderReleased() { 153void VideoWidget::sliderReleased() {
152 videoSliderBeingMoved = FALSE; 154 videoSliderBeingMoved = FALSE;
153 if ( slider->width() == 0 ) { 155 if ( slider->width() == 0 ) {
154 return; 156 return;
155 } 157 }
@@ -258,68 +260,70 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
258} 260}
259 261
260 262
261void VideoWidget::mousePressEvent( QMouseEvent *event ) { 263void VideoWidget::mousePressEvent( QMouseEvent *event ) {
262 mouseMoveEvent( event ); 264 mouseMoveEvent( event );
263} 265}
264 266
265 267
266void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 268void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
267 if ( mediaPlayerState->fullscreen() ) { 269 if ( mediaPlayerState->fullscreen() ) {
268 mediaPlayerState->setFullscreen( FALSE ); 270 mediaPlayerState->setFullscreen( FALSE );
269 makeVisible(); 271 makeVisible();
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* ) {
314 mediaPlayerState->setList(); 318 mediaPlayerState->setList();
315} 319}
316 320
317 321
318bool VideoWidget::playVideo() { 322bool VideoWidget::playVideo() {
319 bool result = FALSE; 323 bool result = FALSE;
320 324
321 int stream = 0; 325 int stream = 0;
322 326
323 int sw = 240; 327 int sw = 240;
324 int sh = 320; 328 int sh = 320;
325 int dd = QPixmap::defaultDepth(); 329 int dd = QPixmap::defaultDepth();
@@ -361,24 +365,30 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e)
361// emit lessClicked(); 365// emit lessClicked();
362// emit lessReleased(); 366// emit lessReleased();
363// toggleButton(6); 367// toggleButton(6);
364 break; 368 break;
365 case Key_Up: 369 case Key_Up:
366// toggleButton(5); 370// toggleButton(5);
367// emit moreClicked(); 371// emit moreClicked();
368// emit moreReleased(); 372// emit moreReleased();
369// toggleButton(5); 373// toggleButton(5);
370 break; 374 break;
371 case Key_Right: 375 case Key_Right:
372 mediaPlayerState->setNext(); 376 mediaPlayerState->setNext();
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
@@ -43,56 +43,57 @@ class QSlider;
43enum VideoButtons { 43enum VideoButtons {
44 VideoPrevious, 44 VideoPrevious,
45 VideoStop, 45 VideoStop,
46 VideoPlay, 46 VideoPlay,
47 VideoPause, 47 VideoPause,
48 VideoNext, 48 VideoNext,
49 VideoPlayList, 49 VideoPlayList,
50 VideoFullscreen 50 VideoFullscreen
51}; 51};
52 52
53class VideoWidget : public QWidget { 53class VideoWidget : public QWidget {
54 Q_OBJECT 54 Q_OBJECT
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 );
87 void setToggleButton( int, bool ); 88 void setToggleButton( int, bool );
88 89
89 QString backgroundPix; 90 QString backgroundPix;
90 QSlider *slider; 91 QSlider *slider;
91 QPixmap *pixmaps[3]; 92 QPixmap *pixmaps[3];
92 QImage *currentFrame; 93 QImage *currentFrame;
93 int scaledWidth; 94 int scaledWidth;
94 int scaledHeight; 95 int scaledHeight;
95 XineVideoWidget* videoFrame; 96 XineVideoWidget* videoFrame;
96}; 97};
97 98
98#endif // VIDEO_WIDGET_H 99#endif // VIDEO_WIDGET_H
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
@@ -22,48 +22,49 @@
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
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#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}
58 59
59void XineControl::play( const QString& fileName ) { 60void XineControl::play( const QString& fileName ) {
60 libXine->play( fileName ); 61 libXine->play( fileName );
61 mediaPlayerState->setPlaying( true ); 62 mediaPlayerState->setPlaying( true );
62 // default to audio view until we know how to handle video 63 // default to audio view until we know how to handle video
63 // MediaDetect mdetect; 64 // MediaDetect mdetect;
64 char whichGui = mdetect.videoOrAudio( fileName ); 65 char whichGui = mdetect.videoOrAudio( fileName );
65 if (whichGui == 'f') { 66 if (whichGui == 'f') {
66 qDebug("Nicht erkannter Dateityp"); 67 qDebug("Nicht erkannter Dateityp");
67 return; 68 return;
68 } 69 }
69 70
@@ -107,24 +108,29 @@ void XineControl::length() {
107 m_length = libXine->length(); 108 m_length = libXine->length();
108 mediaPlayerState->setLength( m_length ); 109 mediaPlayerState->setLength( m_length );
109} 110}
110 111
111long XineControl::position() { 112long XineControl::position() {
112 m_position = ( currentTime() ); 113 m_position = ( currentTime() );
113 mediaPlayerState->setPosition( m_position ); 114 mediaPlayerState->setPosition( m_position );
114 long emitPos = (long)m_position; 115 long emitPos = (long)m_position;
115 emit positionChanged( emitPos ); 116 emit positionChanged( emitPos );
116 if(mediaPlayerState->isPlaying) 117 if(mediaPlayerState->isPlaying)
117 // needs to be stopped the media is stopped 118 // needs to be stopped the media is stopped
118 QTimer::singleShot( 1000, this, SLOT( position() ) ); 119 QTimer::singleShot( 1000, this, SLOT( 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
@@ -35,37 +35,39 @@
35#define XINECONTROL_H 35#define XINECONTROL_H
36 36
37#include "lib.h" 37#include "lib.h"
38#include "mediadetect.h" 38#include "mediadetect.h"
39#include <qobject.h> 39#include <qobject.h>
40 40
41class XineControl : public QObject { 41class XineControl : public QObject {
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
44 XineControl( QObject *parent = 0, const char *name =0 ); 44 XineControl( QObject *parent = 0, const char *name =0 );
45 ~XineControl(); 45 ~XineControl();
46 int m_length; 46 int m_length;
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
71#endif 73#endif
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
@@ -17,128 +17,129 @@
17    .%`+i>       _;_. 17    .%`+i>       _;_.
18    .i_,=:_.      -<s. This program is distributed in the hope that 18    .i_,=:_.      -<s. This program is distributed in the hope that
19     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 19     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
20    : ..    .:,     . . . without even the implied warranty of 20    : ..    .:,     . . . without even the implied warranty of
21    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 21    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
22  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 22  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
23..}^=.=       =       ; Library General Public License for more 23..}^=.=       =       ; Library General Public License for more
24++=   -.     .`     .: details. 24++=   -.     .`     .: details.
25 :     =  ...= . :.=- 25 :     =  ...= . :.=-
26 -.   .:....=;==+<; You should have received a copy of the GNU 26 -.   .:....=;==+<; You should have received a copy of the GNU
27  -_. . .   )=.  = Library General Public License along with 27  -_. . .   )=.  = Library General Public License along with
28    --        :-=` this library; see the file COPYING.LIB. 28    --        :-=` this library; see the file COPYING.LIB.
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;
58 while ( len-- ) { 60 while ( len-- ) {
59 *((short int *) dst )++ = *((short int *) src ); 61 *((short int *) dst )++ = *((short int *) src );
60 ((char *) src ) += step; 62 ((char *) src ) += step;
61 } 63 }
62} 64}
63 65
64static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) 66static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step )
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 ( )));
133 134
134 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); 135 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb );
135 uchar *src = frame; 136 uchar *src = frame;
136 137
137 switch ( rot ) { 138 switch ( rot ) {
138 case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; 139 case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break;
139 case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; 140 case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break;
140 case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; 141 case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break;
141 case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; 142 case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break;
142 } 143 }
143 144
144 uint leftfill = 0; 145 uint leftfill = 0;
@@ -176,55 +177,91 @@ void XineVideoWidget::paintEvent ( QPaintEvent * )
176 dst += m_bytes_per_line_fb; 177 dst += m_bytes_per_line_fb;
177 178
178 switch ( rot ) { 179 switch ( rot ) {
179 case 0: src += m_bytes_per_line_frame; break; 180 case 0: src += m_bytes_per_line_frame; break;
180 case 1: src -= m_bytes_per_pixel; break; 181 case 1: src -= m_bytes_per_pixel; break;
181 case 2: src -= m_bytes_per_line_frame; break; 182 case 2: src -= m_bytes_per_line_frame; break;
182 case 3: src += m_bytes_per_pixel; break; 183 case 3: src += m_bytes_per_pixel; break;
183 } 184 }
184 } 185 }
185 } 186 }
186 } 187 }
187 //qWarning ( " ||| painting |||" ); 188 //qWarning ( " ||| painting |||" );
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
@@ -14,51 +14,59 @@
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
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