summaryrefslogtreecommitdiff
authorsandman <sandman>2002-08-03 23:58:20 (UTC)
committer sandman <sandman>2002-08-03 23:58:20 (UTC)
commit0cecd08dba036f39e414e34a2b7c070008ee3884 (patch) (unidiff)
treec187c9308f0553b1d5d9cd59093bcc3c11740665
parent8fb605fdfbbcbc654f567efcb59f02ec0d26228a (diff)
downloadopie-0cecd08dba036f39e414e34a2b7c070008ee3884.zip
opie-0cecd08dba036f39e414e34a2b7c070008ee3884.tar.gz
opie-0cecd08dba036f39e414e34a2b7c070008ee3884.tar.bz2
Added support for fullscreen playback
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
@@ -10,200 +10,197 @@
10#include <qgfx_qws.h> 10#include <qgfx_qws.h>
11#include <qdirectpainter_qws.h> 11#include <qdirectpainter_qws.h>
12 12
13#include "xinevideowidget.h" 13#include "xinevideowidget.h"
14#include "frame.h" 14#include "frame.h"
15#include "lib.h" 15#include "lib.h"
16 16
17typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 17typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
18 int width, int height,int bytes ); 18 int width, int height,int bytes );
19 19
20extern "C" { 20extern "C" {
21 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); 21 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video);
22 int null_is_showing_video( vo_driver_t* self ); 22 int null_is_showing_video( vo_driver_t* self );
23 void null_set_show_video( vo_driver_t* self, int show ); 23 void null_set_show_video( vo_driver_t* self, int show );
24 int null_is_fullscreen( vo_driver_t* self ); 24 int null_is_fullscreen( vo_driver_t* self );
25 void null_set_fullscreen( vo_driver_t* self, int screen ); 25 void null_set_fullscreen( vo_driver_t* self, int screen );
26 int null_is_scaling( vo_driver_t* self ); 26 int null_is_scaling( vo_driver_t* self );
27 void null_set_scaling( vo_driver_t* self, int scale ); 27 void null_set_scaling( vo_driver_t* self, int scale );
28 void null_set_gui_width( vo_driver_t* self, int width ); 28 void null_set_gui_width( vo_driver_t* self, int width );
29 void null_set_gui_height( vo_driver_t* self, int height ); 29 void null_set_gui_height( vo_driver_t* self, int height );
30 void null_set_mode( vo_driver_t* self, int depth, int rgb ); 30 void null_set_mode( vo_driver_t* self, int depth, int rgb );
31 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); 31 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data);
32} 32}
33 33
34using namespace XINE; 34using namespace XINE;
35 35
36Lib::Lib(XineVideoWidget* widget) { 36Lib::Lib(XineVideoWidget* widget) {
37 m_video = false; 37 m_video = false;
38 m_wid = widget; 38 m_wid = widget;
39 printf("Lib"); 39 printf("Lib");
40 QCString str( getenv("HOME") ); 40 QCString str( getenv("HOME") );
41 str += "/Settings/opiexine.cf"; 41 str += "/Settings/opiexine.cf";
42 // get the configuration 42 // get the configuration
43 m_config = xine_config_file_init( str.data() ); 43 m_config = xine_config_file_init( str.data() );
44 44
45 // allocate oss for sound 45 // allocate oss for sound
46 // and fb for framebuffer 46 // and fb for framebuffer
47 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; 47 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ;
48 if (m_audioOutput == NULL ) 48 if (m_audioOutput == NULL )
49 printf("Failure\n"); 49 printf("Failure\n");
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);
127} 130}
128void Lib::stop() { 131void Lib::stop() {
129 xine_stop(m_xine ); 132 xine_stop(m_xine );
130} 133}
131void Lib::pause(){ 134void Lib::pause(){
132 xine_set_speed( m_xine, SPEED_PAUSE ); 135 xine_set_speed( m_xine, SPEED_PAUSE );
133} 136}
134int Lib::speed() { 137int Lib::speed() {
135 return xine_get_speed( m_xine ); 138 return xine_get_speed( m_xine );
136} 139}
137void Lib::setSpeed( int speed ) { 140void Lib::setSpeed( int speed ) {
138 xine_set_speed( m_xine, speed ); 141 xine_set_speed( m_xine, speed );
139} 142}
140int Lib::status(){ 143int Lib::status(){
141 return xine_get_status( m_xine ); 144 return xine_get_status( m_xine );
142} 145}
143int Lib::currentPosition(){ 146int Lib::currentPosition(){
144 return xine_get_current_position( m_xine ); 147 return xine_get_current_position( m_xine );
145} 148}
146int Lib::currentTime() { 149int Lib::currentTime() {
147 return xine_get_current_time( m_xine ); 150 return xine_get_current_time( m_xine );
148}; 151};
149int Lib::length() { 152int Lib::length() {
150 return xine_get_stream_length( m_xine ); 153 return xine_get_stream_length( m_xine );
151} 154}
152bool Lib::isSeekable() { 155bool Lib::isSeekable() {
153 return xine_is_stream_seekable(m_xine); 156 return xine_is_stream_seekable(m_xine);
154} 157}
155Frame Lib::currentFrame() { 158Frame Lib::currentFrame() {
156 Frame frame; 159 Frame frame;
157 return frame; 160 return frame;
158}; 161};
159int Lib::error() { 162int Lib::error() {
160 return xine_get_error( m_xine ); 163 return xine_get_error( m_xine );
161}; 164};
162void Lib::handleXineEvent( xine_event_t* t ) { 165void Lib::handleXineEvent( xine_event_t* t ) {
163 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) 166 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED )
164 emit stopped(); 167 emit stopped();
165} 168}
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
@@ -1,98 +1,100 @@
1 1
2 2
3#ifndef ZECKEXINELIB_H 3#ifndef ZECKEXINELIB_H
4#define ZECKEXINELIB_H 4#define ZECKEXINELIB_H
5 5
6#include <qcstring.h> 6#include <qcstring.h>
7#include <qstring.h> 7#include <qstring.h>
8#include <qobject.h> 8#include <qobject.h>
9 9
10#include <xine.h> 10#include <xine.h>
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 /**
59 * is we show video 61 * is we show video
60 */ 62 */
61 bool isShowingVideo() /*const*/; 63 bool isShowingVideo() /*const*/;
62 64
63 /** 65 /**
64 * 66 *
65 */ 67 */
66 void showVideoFullScreen( bool fullScreen ); 68 void showVideoFullScreen( bool fullScreen );
67 69
68 /** 70 /**
69 * 71 *
70 */ 72 */
71 bool isVideoFullScreen()/*const*/ ; 73 bool isVideoFullScreen()/*const*/ ;
72 74
73 /** 75 /**
74 * 76 *
75 */ 77 */
76 bool isScaling(); 78 bool isScaling();
77 79
78 /** 80 /**
79 * 81 *
80 */ 82 */
81 void setScaling( bool ); 83 void setScaling( bool );
82 /** 84 /**
83 * test 85 * test
84 */ 86 */
85 Frame currentFrame()/*const*/; 87 Frame currentFrame()/*const*/;
86 88
87 /** 89 /**
88 * Returns the error code 90 * Returns the error code
89 */ 91 */
90 int error() /*const*/; 92 int error() /*const*/;
91 93
92 signals: 94 signals:
93 void stopped(); 95 void stopped();
94 private: 96 private:
95 int m_bytes_per_pixel; 97 int m_bytes_per_pixel;
96 bool m_video:1; 98 bool m_video:1;
97 XineVideoWidget *m_wid; 99 XineVideoWidget *m_wid;
98 xine_t *m_xine; 100 xine_t *m_xine;
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
@@ -3,128 +3,129 @@
3#include <stdlib.h> 3#include <stdlib.h>
4#include <stdio.h> 4#include <stdio.h>
5 5
6#include <math.h> 6#include <math.h>
7 7
8#include <xine/video_out.h> 8#include <xine/video_out.h>
9#include <xine/xine_internal.h> 9#include <xine/xine_internal.h>
10#include <xine/xineutils.h> 10#include <xine/xineutils.h>
11#include <xine/configfile.h> 11#include <xine/configfile.h>
12 12
13#include <pthread.h> 13#include <pthread.h>
14#include "alphablend.h" 14#include "alphablend.h"
15#include "yuv2rgb.h" 15#include "yuv2rgb.h"
16 16
17#define printf(x,...) 17#define printf(x,...)
18 18
19/* the caller for our event draw handler */ 19/* the caller for our event draw handler */
20typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 20typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
21 int width, int height,int bytes ); 21 int width, int height,int bytes );
22 22
23typedef struct null_driver_s null_driver_t; 23typedef struct null_driver_s null_driver_t;
24 24
25struct null_driver_s { 25struct null_driver_s {
26 vo_driver_t vo_driver; 26 vo_driver_t vo_driver;
27 uint32_t m_capabilities; 27 uint32_t m_capabilities;
28 int m_show_video; 28 int m_show_video;
29 int m_video_fullscreen; 29 int m_video_fullscreen;
30 int m_is_scaling; 30 int m_is_scaling;
31 int depth, bpp, bytes_per_pixel; 31 int depth, bpp, bytes_per_pixel;
32 int yuv2rgb_mode; 32 int yuv2rgb_mode;
33 int yuv2rgb_swap; 33 int yuv2rgb_swap;
34 int zuv2rgb_gamma; 34 int zuv2rgb_gamma;
35 uint8_t *yuv2rgb_cmap; 35 uint8_t *yuv2rgb_cmap;
36 yuv2rgb_factory_t *yuv2rgb_factory; 36 yuv2rgb_factory_t *yuv2rgb_factory;
37 vo_overlay_t *overlay; 37 vo_overlay_t *overlay;
38 int user_ratio; 38 int user_ratio;
39 double output_scale_factor; 39 double output_scale_factor;
40 int last_frame_output_width; 40 int last_frame_output_width;
41 int last_frame_output_height; 41 int last_frame_output_height;
42 int gui_width; 42 int gui_width;
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
91 92
92 if (frame->format == IMGFMT_YV12) { 93 if (frame->format == IMGFMT_YV12) {
93 frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, 94 frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst,
94 src[0], src[1], src[2]); 95 src[0], src[1], src[2]);
95 } else { 96 } else {
96 97
97 frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, 98 frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst,
98 src[0]); 99 src[0]);
99 } 100 }
100 101
101 frame->rgb_dst += frame->stripe_inc; 102 frame->rgb_dst += frame->stripe_inc;
102 printf("returning\n"); 103 printf("returning\n");
103} 104}
104 105
105static void null_frame_field (vo_frame_t *vo_img, int which_field) { 106static void null_frame_field (vo_frame_t *vo_img, int which_field) {
106 107
107 opie_frame_t *frame = (opie_frame_t *) vo_img ; 108 opie_frame_t *frame = (opie_frame_t *) vo_img ;
108 printf("field\n\n"); 109 printf("field\n\n");
109 110
110 switch (which_field) { 111 switch (which_field) {
111 case VO_TOP_FIELD: 112 case VO_TOP_FIELD:
112 frame->rgb_dst = (uint8_t *)frame->data; 113 frame->rgb_dst = (uint8_t *)frame->data;
113 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; 114 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line;
114 break; 115 break;
115 case VO_BOTTOM_FIELD: 116 case VO_BOTTOM_FIELD:
116 frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; 117 frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ;
117 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; 118 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line;
118 break; 119 break;
119 case VO_BOTH_FIELDS: 120 case VO_BOTH_FIELDS:
120 frame->rgb_dst = (uint8_t *)frame->data; 121 frame->rgb_dst = (uint8_t *)frame->data;
121 break; 122 break;
122 } 123 }
123} 124}
124 125
125 126
126/* take care of the frame*/ 127/* take care of the frame*/
127static void null_frame_dispose( vo_frame_t* vo_img){ 128static void null_frame_dispose( vo_frame_t* vo_img){
128 opie_frame_t* frame = (opie_frame_t*)vo_img; 129 opie_frame_t* frame = (opie_frame_t*)vo_img;
129 printf("frame_dispose\n"); 130 printf("frame_dispose\n");
130 if( frame->data ) 131 if( frame->data )
@@ -232,139 +233,141 @@ static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) {
232 frame->ideal_width = frame->width; 233 frame->ideal_width = frame->width;
233 frame->ideal_height = frame->height / corr_factor + 0.5; 234 frame->ideal_height = frame->height / corr_factor + 0.5;
234 } 235 }
235 236
236 } 237 }
237 } 238 }
238 printf("return from helper\n"); 239 printf("return from helper\n");
239} 240}
240 241
241static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) { 242static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) {
242 243
243 double x_factor, y_factor; 244 double x_factor, y_factor;
244 245
245 /* 246 /*
246 * make the frame fit into the given destination area 247 * make the frame fit into the given destination area
247 */ 248 */
248 249
249 x_factor = (double) this->gui_width / (double) frame->ideal_width; 250 x_factor = (double) this->gui_width / (double) frame->ideal_width;
250 y_factor = (double) this->gui_height / (double) frame->ideal_height; 251 y_factor = (double) this->gui_height / (double) frame->ideal_height;
251 252
252 if ( x_factor < y_factor ) { 253 if ( x_factor < y_factor ) {
253 frame->output_width = (double) frame->ideal_width * x_factor ; 254 frame->output_width = (double) frame->ideal_width * x_factor ;
254 frame->output_height = (double) frame->ideal_height * x_factor ; 255 frame->output_height = (double) frame->ideal_height * x_factor ;
255 } else { 256 } else {
256 frame->output_width = (double) frame->ideal_width * y_factor ; 257 frame->output_width = (double) frame->ideal_width * y_factor ;
257 frame->output_height = (double) frame->ideal_height * y_factor ; 258 frame->output_height = (double) frame->ideal_height * y_factor ;
258 } 259 }
259 260
260#define LOG 1 261#define LOG 1
261#ifdef LOG 262#ifdef LOG
262 printf("video_out_fb: frame source %d x %d => screen output %d x %d%s\n", 263 printf("video_out_fb: frame source %d x %d => screen output %d x %d%s\n",
263 frame->width, frame->height, 264 frame->width, frame->height,
264 frame->output_width, frame->output_height, 265 frame->output_width, frame->output_height,
265 ( frame->width != frame->output_width 266 ( frame->width != frame->output_width
266 || frame->height != frame->output_height 267 || frame->height != frame->output_height
267 ? ", software scaling" 268 ? ", software scaling"
268 : "" ) 269 : "" )
269 ); 270 );
270#endif 271#endif
271} 272}
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 *
331 this->bytes_per_pixel ); 334 this->bytes_per_pixel );
332 335
333 if( format == IMGFMT_YV12 ) { 336 if( format == IMGFMT_YV12 ) {
334 int image_size = width * height; /* cast ouch*/ 337 int image_size = width * height; /* cast ouch*/
335 frame->frame.base[0] = xine_xmalloc_aligned(16, image_size, 338 frame->frame.base[0] = xine_xmalloc_aligned(16, image_size,
336 (void **)&frame->chunk[0] ); 339 (void **)&frame->chunk[0] );
337 frame->frame.base[1] = xine_xmalloc_aligned(16, image_size, 340 frame->frame.base[1] = xine_xmalloc_aligned(16, image_size,
338 (void **)&frame->chunk[1] ); 341 (void **)&frame->chunk[1] );
339 frame->frame.base[2] = xine_xmalloc_aligned(16, image_size, 342 frame->frame.base[2] = xine_xmalloc_aligned(16, image_size,
340 (void **)&frame->chunk[2] ); 343 (void **)&frame->chunk[2] );
341 }else{ 344 }else{
342 int image_size = width * height; /* cast ouch*/ 345 int image_size = width * height; /* cast ouch*/
343 frame->frame.base[0] = xine_xmalloc_aligned(16, image_size, 346 frame->frame.base[0] = xine_xmalloc_aligned(16, image_size,
344 (void **)&frame->chunk[0] ); 347 (void **)&frame->chunk[0] );
345 frame->chunk[1] = NULL; 348 frame->chunk[1] = NULL;
346 frame->chunk[2] = NULL; 349 frame->chunk[2] = NULL;
347 } 350 }
348 351
349 frame->format = format; 352 frame->format = format;
350 frame->width = width; 353 frame->width = width;
351 frame->height = height; 354 frame->height = height;
352 355
353 frame->stripe_height = 16 * frame->output_height / frame->height; 356 frame->stripe_height = 16 * frame->output_height / frame->height;
354 frame->bytes_per_line = frame->output_width * this->bytes_per_pixel; 357 frame->bytes_per_line = frame->output_width * this->bytes_per_pixel;
355 358
356 /* 359 /*
357 * set up colorspace converter 360 * set up colorspace converter
358 */ 361 */
359 if(1 /*this->m_show_video*/ ){ 362 if(1 /*this->m_show_video*/ ){
360 printf("showing video\n"); 363 printf("showing video\n");
361 364
362 switch (flags) { 365 switch (flags) {
363 case VO_TOP_FIELD: 366 case VO_TOP_FIELD:
364 case VO_BOTTOM_FIELD: 367 case VO_BOTTOM_FIELD:
365 frame->yuv2rgb->configure (frame->yuv2rgb, 368 frame->yuv2rgb->configure (frame->yuv2rgb,
366 frame->width, 369 frame->width,
367 16, 370 16,
368 frame->width*2, 371 frame->width*2,
369 frame->width, 372 frame->width,
370 frame->output_width, 373 frame->output_width,
@@ -475,130 +478,130 @@ static void null_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo
475 frame->width, frame->height); 478 frame->width, frame->height);
476 break; 479 break;
477 case 24: 480 case 24:
478 blend_rgb24( (uint8_t *)frame->data, overlay, 481 blend_rgb24( (uint8_t *)frame->data, overlay,
479 frame->output_width, frame->output_height, 482 frame->output_width, frame->output_height,
480 frame->width, frame->height); 483 frame->width, frame->height);
481 break; 484 break;
482 case 32: 485 case 32:
483 blend_rgb32( (uint8_t *)frame->data, overlay, 486 blend_rgb32( (uint8_t *)frame->data, overlay,
484 frame->output_width, frame->output_height, 487 frame->output_width, frame->output_height,
485 frame->width, frame->height); 488 frame->width, frame->height);
486 break; 489 break;
487 default: 490 default:
488 /* It should never get here */ 491 /* It should never get here */
489 break; 492 break;
490 } 493 }
491 } 494 }
492} 495}
493 496
494 497
495static int null_get_property( vo_driver_t* self, 498static int null_get_property( vo_driver_t* self,
496 int property ){ 499 int property ){
497 printf("property get\n"); 500 printf("property get\n");
498 return 0; 501 return 0;
499} 502}
500static int null_set_property( vo_driver_t* self, 503static int null_set_property( vo_driver_t* self,
501 int property, 504 int property,
502 int value ){ 505 int value ){
503 printf("set property\n"); 506 printf("set property\n");
504 return value; 507 return value;
505} 508}
506static void null_get_property_min_max( vo_driver_t* self, 509static void null_get_property_min_max( vo_driver_t* self,
507 int property, int *min, 510 int property, int *min,
508 int *max ){ 511 int *max ){
509 printf("min max\n"); 512 printf("min max\n");
510 *max = 0; 513 *max = 0;
511 *min = 0; 514 *min = 0;
512} 515}
513static int null_gui_data_exchange( vo_driver_t* self, 516static int null_gui_data_exchange( vo_driver_t* self,
514 int data_type, 517 int data_type,
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
565static vo_info_t vo_info_null = { 568static vo_info_t vo_info_null = {
566 5, 569 5,
567 "null plugin", 570 "null plugin",
568 NULL, 571 NULL,
569 VISUAL_TYPE_FB, 572 VISUAL_TYPE_FB,
570 5 573 5
571}; 574};
572 575
573vo_info_t *get_video_out_plugin_info(){ 576vo_info_t *get_video_out_plugin_info(){
574 vo_info_null.description = _("xine video output plugin using null device"); 577 vo_info_null.description = _("xine video output plugin using null device");
575 return &vo_info_null; 578 return &vo_info_null;
576} 579}
577 580
578/* this is special for this device */ 581/* this is special for this device */
579/** 582/**
580 * We know that we will be controled by the XINE LIB++ 583 * We know that we will be controled by the XINE LIB++
581 */ 584 */
582 585
583/** 586/**
584 * 587 *
585 */ 588 */
586int null_is_showing_video( vo_driver_t* self ){ 589int null_is_showing_video( vo_driver_t* self ){
587 null_driver_t* this = (null_driver_t*)self; 590 null_driver_t* this = (null_driver_t*)self;
588 return this->m_show_video; 591 return this->m_show_video;
589} 592}
590void null_set_show_video( vo_driver_t* self, int show ) { 593void null_set_show_video( vo_driver_t* self, int show ) {
591 ((null_driver_t*)self)->m_show_video = show; 594 ((null_driver_t*)self)->m_show_video = show;
592} 595}
593 596
594int null_is_fullscreen( vo_driver_t* self ){ 597int null_is_fullscreen( vo_driver_t* self ){
595 return ((null_driver_t*)self)->m_video_fullscreen; 598 return ((null_driver_t*)self)->m_video_fullscreen;
596} 599}
597void null_set_fullscreen( vo_driver_t* self, int screen ){ 600void null_set_fullscreen( vo_driver_t* self, int screen ){
598 ((null_driver_t*)self)->m_video_fullscreen = screen; 601 ((null_driver_t*)self)->m_video_fullscreen = screen;
599} 602}
600int null_is_scaling( vo_driver_t* self ){ 603int null_is_scaling( vo_driver_t* self ){
601 return ((null_driver_t*)self)->m_is_scaling; 604 return ((null_driver_t*)self)->m_is_scaling;
602} 605}
603void null_set_scaling( vo_driver_t* self, int scale ){ 606void null_set_scaling( vo_driver_t* self, int scale ){
604 ((null_driver_t*)self)->m_is_scaling = scale; 607 ((null_driver_t*)self)->m_is_scaling = scale;
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
@@ -49,147 +49,149 @@
49# include <qdirectpainter_qws.h> 49# include <qdirectpainter_qws.h>
50# include <qgfxraster_qws.h> 50# include <qgfxraster_qws.h>
51#endif 51#endif
52 52
53 53
54extern MediaPlayerState *mediaPlayerState; 54extern MediaPlayerState *mediaPlayerState;
55 55
56 56
57static const int xo = 2; // movable x offset 57static const int xo = 2; // movable x offset
58static const int yo = 0; // movable y offset 58static const int yo = 0; // movable y offset
59 59
60 60
61struct MediaButton { 61struct MediaButton {
62 int xPos, yPos; 62 int xPos, yPos;
63 bool isToggle, isHeld, isDown; 63 bool isToggle, isHeld, isDown;
64 int controlType; 64 int controlType;
65}; 65};
66 66
67 67
68// Layout information for the videoButtons (and if it is a toggle button or not) 68// Layout information for the videoButtons (and if it is a toggle button or not)
69MediaButton videoButtons[] = { 69MediaButton videoButtons[] = {
70 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous 70 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous
71 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop 71 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop
72 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play 72 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play
73 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause 73 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause
74 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next 74 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next
75 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist 75 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist
76 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen 76 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen
77}; 77};
78 78
79 79
80static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 80static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
81 81
82 82
83VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 83VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
84 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 84 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
85 setCaption( tr("OpiePlayer - Video") ); 85 setCaption( tr("OpiePlayer - Video") );
86 Config cfg("OpiePlayer"); 86 Config cfg("OpiePlayer");
87 cfg.setGroup("VideoWidget"); 87 cfg.setGroup("VideoWidget");
88 88
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 }
156 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 158 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
157 mediaPlayerState->setPosition( val ); 159 mediaPlayerState->setPosition( val );
158} 160}
159 161
160 162
161void VideoWidget::setPosition( long i ) { 163void VideoWidget::setPosition( long i ) {
162 updateSlider( i, mediaPlayerState->length() ); 164 updateSlider( i, mediaPlayerState->length() );
163} 165}
164 166
165 167
166void VideoWidget::setLength( long max ) { 168void VideoWidget::setLength( long max ) {
167 updateSlider( mediaPlayerState->position(), max ); 169 updateSlider( mediaPlayerState->position(), max );
168} 170}
169 171
170 172
171void VideoWidget::setView( char view ) { 173void VideoWidget::setView( char view ) {
172 if ( view == 'v' ) { 174 if ( view == 'v' ) {
173 makeVisible(); 175 makeVisible();
174 } else { 176 } else {
175 // Effectively blank the view next time we show it so it looks nicer 177 // Effectively blank the view next time we show it so it looks nicer
176 scaledWidth = 0; 178 scaledWidth = 0;
177 scaledHeight = 0; 179 scaledHeight = 0;
178 hide(); 180 hide();
179 } 181 }
180} 182}
181 183
182 184
183void VideoWidget::updateSlider( long i, long max ) { 185void VideoWidget::updateSlider( long i, long max ) {
184 // Will flicker too much if we don't do this 186 // Will flicker too much if we don't do this
185 if ( max == 0 ) { 187 if ( max == 0 ) {
186 return; 188 return;
187 } 189 }
188 int width = slider->width(); 190 int width = slider->width();
189 int val = int((double)i * width / max); 191 int val = int((double)i * width / max);
190 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 192 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
191 if ( slider->value() != val ) { 193 if ( slider->value() != val ) {
192 slider->setValue( val ); 194 slider->setValue( val );
193 } 195 }
194 if ( slider->maxValue() != width ) { 196 if ( slider->maxValue() != width ) {
195 slider->setMaxValue( width ); 197 slider->setMaxValue( width );
@@ -218,167 +220,175 @@ void VideoWidget::paintButton( QPainter *p, int i ) {
218 int offset = 10 + videoButtons[i].isDown; 220 int offset = 10 + videoButtons[i].isDown;
219 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); 221 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] );
220 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); 222 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
221} 223}
222 224
223 225
224void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 226void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
225 for ( int i = 0; i < numButtons; i++ ) { 227 for ( int i = 0; i < numButtons; i++ ) {
226 int x = videoButtons[i].xPos; 228 int x = videoButtons[i].xPos;
227 int y = videoButtons[i].yPos; 229 int y = videoButtons[i].yPos;
228 if ( event->state() == QMouseEvent::LeftButton ) { 230 if ( event->state() == QMouseEvent::LeftButton ) {
229 // The test to see if the mouse click is inside the circular button or not 231 // The test to see if the mouse click is inside the circular button or not
230 // (compared with the radius squared to avoid a square-root of our distance) 232 // (compared with the radius squared to avoid a square-root of our distance)
231 int radius = 16; 233 int radius = 16;
232 QPoint center = QPoint( x + radius, y + radius ); 234 QPoint center = QPoint( x + radius, y + radius );
233 QPoint dXY = center - event->pos(); 235 QPoint dXY = center - event->pos();
234 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 236 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
235 bool isOnButton = dist <= (radius * radius); 237 bool isOnButton = dist <= (radius * radius);
236 if ( isOnButton != videoButtons[i].isHeld ) { 238 if ( isOnButton != videoButtons[i].isHeld ) {
237 videoButtons[i].isHeld = isOnButton; 239 videoButtons[i].isHeld = isOnButton;
238 toggleButton(i); 240 toggleButton(i);
239 } 241 }
240 } else { 242 } else {
241 if ( videoButtons[i].isHeld ) { 243 if ( videoButtons[i].isHeld ) {
242 videoButtons[i].isHeld = FALSE; 244 videoButtons[i].isHeld = FALSE;
243 if ( !videoButtons[i].isToggle ) 245 if ( !videoButtons[i].isToggle )
244 setToggleButton( i, FALSE ); 246 setToggleButton( i, FALSE );
245 } 247 }
246 } 248 }
247 switch (i) { 249 switch (i) {
248 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 250 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
249 case VideoStop: mediaPlayerState->setPlaying(FALSE); return; 251 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
250 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; 252 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
251 case VideoNext: mediaPlayerState->setNext(); return; 253 case VideoNext: mediaPlayerState->setNext(); return;
252 case VideoPrevious: mediaPlayerState->setPrev(); return; 254 case VideoPrevious: mediaPlayerState->setPrev(); return;
253 case VideoPlayList: mediaPlayerState->setList(); return; 255 case VideoPlayList: mediaPlayerState->setList(); return;
254 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 256 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
255 } 257 }
256 258
257 } 259 }
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();
326 int w = height(); 330 int w = height();
327 int h = width(); 331 int h = width();
328 332
329 return true; 333 return true;
330} 334}
331 335
332 336
333 337
334void VideoWidget::keyReleaseEvent( QKeyEvent *e) 338void VideoWidget::keyReleaseEvent( QKeyEvent *e)
335{ 339{
336 switch ( e->key() ) { 340 switch ( e->key() ) {
337////////////////////////////// Zaurus keys 341////////////////////////////// Zaurus keys
338 case Key_Home: 342 case Key_Home:
339 break; 343 break;
340 case Key_F9: //activity 344 case Key_F9: //activity
341 break; 345 break;
342 case Key_F10: //contacts 346 case Key_F10: //contacts
343// hide(); 347// hide();
344 break; 348 break;
345 case Key_F11: //menu 349 case Key_F11: //menu
346 break; 350 break;
347 case Key_F12: //home 351 case Key_F12: //home
348 break; 352 break;
349 case Key_F13: //mail 353 case Key_F13: //mail
350 break; 354 break;
351 case Key_Space: { 355 case Key_Space: {
352 if(mediaPlayerState->playing()) { 356 if(mediaPlayerState->playing()) {
353 mediaPlayerState->setPlaying(FALSE); 357 mediaPlayerState->setPlaying(FALSE);
354 } else { 358 } else {
355 mediaPlayerState->setPlaying(TRUE); 359 mediaPlayerState->setPlaying(TRUE);
356 } 360 }
357 } 361 }
358 break; 362 break;
359 case Key_Down: 363 case Key_Down:
360// toggleButton(6); 364// toggleButton(6);
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
@@ -3,99 +3,100 @@
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
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#ifndef VIDEO_WIDGET_H 34#ifndef VIDEO_WIDGET_H
35#define VIDEO_WIDGET_H 35#define VIDEO_WIDGET_H
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include "xinevideowidget.h" 38#include "xinevideowidget.h"
39 39
40class QPixmap; 40class QPixmap;
41class QSlider; 41class QSlider;
42 42
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
99 100
100 101
101 102
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
@@ -1,130 +1,136 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
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#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
70 if (whichGui == 'a') { 71 if (whichGui == 'a') {
71 libXine->setShowVideo( false ); 72 libXine->setShowVideo( false );
72 } else { 73 } else {
73 libXine->setShowVideo( true ); 74 libXine->setShowVideo( true );
74 } 75 }
75 76
76 // determine if slider is shown 77 // determine if slider is shown
77 // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); 78 // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) );
78 mediaPlayerState->setIsStreaming( libXine->isSeekable() ); 79 mediaPlayerState->setIsStreaming( libXine->isSeekable() );
79 // which gui (video / audio) 80 // which gui (video / audio)
80 mediaPlayerState->setView( whichGui ); 81 mediaPlayerState->setView( whichGui );
81 length(); 82 length();
82 position(); 83 position();
83} 84}
84 85
85void XineControl::stop( bool isSet ) { 86void XineControl::stop( bool isSet ) {
86 if ( !isSet) { 87 if ( !isSet) {
87 libXine->stop(); 88 libXine->stop();
88 mediaPlayerState->setList(); 89 mediaPlayerState->setList();
89 //mediaPlayerState->setPlaying( false ); 90 //mediaPlayerState->setPlaying( false );
90 } else { 91 } else {
91 // play again 92 // play again
92 } 93 }
93} 94}
94 95
95void XineControl::pause( bool isSet) { 96void XineControl::pause( bool isSet) {
96 libXine->pause(); 97 libXine->pause();
97} 98}
98 99
99long XineControl::currentTime() { 100long XineControl::currentTime() {
100 // todo: jede sekunde überprüfen 101 // todo: jede sekunde überprüfen
101 m_currentTime = libXine->currentTime(); 102 m_currentTime = libXine->currentTime();
102 return m_currentTime; 103 return m_currentTime;
103 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 104 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
104} 105}
105 106
106void XineControl::length() { 107void 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
@@ -1,71 +1,73 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
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#ifndef XINECONTROL_H 34#ifndef XINECONTROL_H
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
@@ -1,230 +1,267 @@
1 1
2/* 2/*
3                This file is part of the Opie Project 3                This file is part of the Opie Project
4 4
5              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 5              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
6 Copyright (c) 2002 LJP <> 6 Copyright (c) 2002 LJP <>
7 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 7 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
8 =. 8 =.
9 .=l. 9 .=l.
10           .>+-= 10           .>+-=
11 _;:,     .>    :=|. This program is free software; you can 11 _;:,     .>    :=|. This program is free software; you can
12.> <`_,   >  .   <= redistribute it and/or modify it under 12.> <`_,   >  .   <= redistribute it and/or modify it under
13:`=1 )Y*s>-.--   : the terms of the GNU General Public 13:`=1 )Y*s>-.--   : the terms of the GNU General Public
14.="- .-=="i,     .._ License as published by the Free Software 14.="- .-=="i,     .._ License as published by the Free Software
15 - .   .-<_>     .<> Foundation; either version 2 of the License, 15 - .   .-<_>     .<> Foundation; either version 2 of the License,
16     ._= =}       : or (at your option) any later version. 16     ._= =}       : or (at your option) any later version.
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;
145 uint framefill = 0; 146 uint framefill = 0;
146 uint rightfill = 0; 147 uint rightfill = 0;
147 uint clipwidth = clip. width ( ) * m_bytes_per_pixel; 148 uint clipwidth = clip. width ( ) * m_bytes_per_pixel;
148 149
149 if ( clip. left ( ) < framerect. left ( )) 150 if ( clip. left ( ) < framerect. left ( ))
150 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; 151 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
151 if ( clip. right ( ) > framerect. right ( )) 152 if ( clip. right ( ) > framerect. right ( ))
152 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; 153 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
153 154
154 framefill = clipwidth - ( leftfill + rightfill ); 155 framefill = clipwidth - ( leftfill + rightfill );
155 156
156 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { 157 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
157 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { 158 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
158 memset ( dst, 0, clipwidth ); 159 memset ( dst, 0, clipwidth );
159 } 160 }
160 else { 161 else {
161 if ( leftfill ) 162 if ( leftfill )
162 memset ( dst, 0, leftfill ); 163 memset ( dst, 0, leftfill );
163 164
164 if ( framefill ) { 165 if ( framefill ) {
165 switch ( rot ) { 166 switch ( rot ) {
166 case 0: memcpy ( dst + leftfill, src, framefill ); break; 167 case 0: memcpy ( dst + leftfill, src, framefill ); break;
167 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; 168 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
168 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; 169 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break;
169 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; 170 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
170 } 171 }
171 } 172 }
172 if ( rightfill ) 173 if ( rightfill )
173 memset ( dst + leftfill + framefill, 0, rightfill ); 174 memset ( dst + leftfill + framefill, 0, rightfill );
174 } 175 }
175 176
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
@@ -1,64 +1,72 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
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