summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-13 23:07:43 (UTC)
committer simon <simon>2002-12-13 23:07:43 (UTC)
commit2e922ec81282a735a04ca1e822329c615b979ebf (patch) (unidiff)
tree742b662eb9d441aec1a12f2d3b531245b934cdb1
parent2e91febca20a3b550d06ba33a4d41b40555a8bbf (diff)
downloadopie-2e922ec81282a735a04ca1e822329c615b979ebf.zip
opie-2e922ec81282a735a04ca1e822329c615b979ebf.tar.gz
opie-2e922ec81282a735a04ca1e822329c615b979ebf.tar.bz2
- fill in some code on the threading side. not activated, yet
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/lib.h2
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp3
3 files changed, 16 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index cef46a1..84194b7 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,374 +1,385 @@
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#include <stdio.h> 34#include <stdio.h>
35#include <stdlib.h> 35#include <stdlib.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qtextstream.h> 37#include <qtextstream.h>
38#include <qpe/resource.h> 38#include <qpe/resource.h>
39 39
40#include <qfile.h> 40#include <qfile.h>
41#include <qdir.h> 41#include <qdir.h>
42 42
43#include <qgfx_qws.h> 43#include <qgfx_qws.h>
44#include <qdirectpainter_qws.h> 44#include <qdirectpainter_qws.h>
45 45
46#include <assert.h> 46#include <assert.h>
47 47
48#include "xinevideowidget.h" 48#include "xinevideowidget.h"
49#include "frame.h" 49#include "frame.h"
50#include "lib.h" 50#include "lib.h"
51 51
52 52
53typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 53typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
54 int width, int height,int bytes ); 54 int width, int height,int bytes );
55 55
56extern "C" { 56extern "C" {
57 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); 57 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * );
58 int null_is_showing_video( const xine_vo_driver_t* self ); 58 int null_is_showing_video( const xine_vo_driver_t* self );
59 void null_set_show_video( const xine_vo_driver_t* self, int show ); 59 void null_set_show_video( const xine_vo_driver_t* self, int show );
60 int null_is_fullscreen( const xine_vo_driver_t* self ); 60 int null_is_fullscreen( const xine_vo_driver_t* self );
61 void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); 61 void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
62 int null_is_scaling( const xine_vo_driver_t* self ); 62 int null_is_scaling( const xine_vo_driver_t* self );
63 void null_set_scaling( const xine_vo_driver_t* self, int scale ); 63 void null_set_scaling( const xine_vo_driver_t* self, int scale );
64 void null_set_gui_width( const xine_vo_driver_t* self, int width ); 64 void null_set_gui_width( const xine_vo_driver_t* self, int width );
65 void null_set_gui_height( const xine_vo_driver_t* self, int height ); 65 void null_set_gui_height( const xine_vo_driver_t* self, int height );
66 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); 66 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb );
67 void null_set_videoGamma( const xine_vo_driver_t* self , int value ); 67 void null_set_videoGamma( const xine_vo_driver_t* self , int value );
68 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); 68 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data );
69} 69}
70 70
71using namespace XINE; 71using namespace XINE;
72 72
73Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) 73Lib::Lib( InitializationMode initMode, XineVideoWidget* widget )
74{ 74{
75 m_initialized = false; 75 m_initialized = false;
76 m_duringInitialization = false; 76 m_duringInitialization = false;
77 m_video = false; 77 m_video = false;
78 m_wid = widget; 78 m_wid = widget;
79 printf("Lib"); 79 printf("Lib");
80 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 80 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
81 // get the configuration 81 // get the configuration
82 82
83 // not really OO, should be an extra class, later 83 // not really OO, should be an extra class, later
84 if ( !QFile::exists(configPath) ) { 84 if ( !QFile::exists(configPath) ) {
85 QFile f(configPath); 85 QFile f(configPath);
86 f.open(IO_WriteOnly); 86 f.open(IO_WriteOnly);
87 QTextStream ts( &f ); 87 QTextStream ts( &f );
88 ts << "misc.memcpy_method:glibc\n"; 88 ts << "misc.memcpy_method:glibc\n";
89 f.close(); 89 f.close();
90 } 90 }
91 91
92 if ( initMode == InitializeImmediately ) { 92 if ( initMode == InitializeImmediately ) {
93 initialize(); 93 initialize();
94 m_initialized = true; 94 m_initialized = true;
95 } 95 }
96 else 96 else
97 assert( false ); 97 assert( false );
98} 98}
99 99
100void Lib::run() 100void Lib::run()
101{ 101{
102 assert( false ); 102 initialize();
103 m_initialized = true;
103} 104}
104 105
105void Lib::initialize() 106void Lib::initialize()
106{ 107{
107 m_duringInitialization = true; 108 m_duringInitialization = true;
108 m_xine = xine_new( ); 109 m_xine = xine_new( );
109 110
110 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 111 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
111 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 112 xine_config_load( m_xine, QFile::encodeName( configPath ) );
112 113
113 xine_init( m_xine ); 114 xine_init( m_xine );
114 115
115 // allocate oss for sound 116 // allocate oss for sound
116 // and fb for framebuffer 117 // and fb for framebuffer
117 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 118 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
118 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 119 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
119 120
120 121
121//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); 122//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
122 123
123 124
124// null_display_handler( m_videoOutput, xine_display_frame, this ); 125// null_display_handler( m_videoOutput, xine_display_frame, this );
125 126
126 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 127 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
127 128
128 if (m_wid != 0 ) { 129 if (m_wid != 0 ) {
129 printf( "!0\n" ); 130 printf( "!0\n" );
130 resize ( m_wid-> size ( ) ); 131 resize ( m_wid-> size ( ) );
131 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 132 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
132 133
133// m_wid->repaint(); 134// m_wid->repaint();
134 } 135 }
135 136
136 m_queue = xine_event_new_queue (m_stream); 137 m_queue = xine_event_new_queue (m_stream);
137 138
138 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 139 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
139 m_duringInitialization = false; 140 m_duringInitialization = false;
140} 141}
141 142
142Lib::~Lib() { 143Lib::~Lib() {
143 assert( isRunning() == false ); 144 assert( isRunning() == false );
144 assert( m_initialized ); 145 assert( m_initialized );
145 146
146// free( m_config ); 147// free( m_config );
147 148
148 xine_close( m_stream ); 149 xine_close( m_stream );
149 150
150 xine_event_dispose_queue( m_queue ); 151 xine_event_dispose_queue( m_queue );
151 152
152 xine_dispose( m_stream ); 153 xine_dispose( m_stream );
153 154
154 xine_exit( m_xine ); 155 xine_exit( m_xine );
155 /* FIXME either free or delete but valgrind bitches against both */ 156 /* FIXME either free or delete but valgrind bitches against both */
156 //free( m_videoOutput ); 157 //free( m_videoOutput );
157 //delete m_audioOutput; 158 //delete m_audioOutput;
158} 159}
159 160
160void Lib::resize ( const QSize &s ) { 161void Lib::resize ( const QSize &s ) {
161 assert( m_initialized || m_duringInitialization ); 162 assert( m_initialized || m_duringInitialization );
162 163
163 if ( s. width ( ) && s. height ( ) ) { 164 if ( s. width ( ) && s. height ( ) ) {
164 ::null_set_gui_width( m_videoOutput, s. width() ); 165 ::null_set_gui_width( m_videoOutput, s. width() );
165 ::null_set_gui_height( m_videoOutput, s. height() ); 166 ::null_set_gui_height( m_videoOutput, s. height() );
166 } 167 }
167} 168}
168 169
169int Lib::majorVersion() { 170int Lib::majorVersion() {
170 int major, minor, sub; 171 int major, minor, sub;
171 xine_get_version ( &major, &minor, &sub ); 172 xine_get_version ( &major, &minor, &sub );
172 return major; 173 return major;
173} 174}
174 175
175int Lib::minorVersion() { 176int Lib::minorVersion() {
176 int major, minor, sub; 177 int major, minor, sub;
177 xine_get_version ( &major, &minor, &sub ); 178 xine_get_version ( &major, &minor, &sub );
178 return minor; 179 return minor;
179} 180}
180 181
181int Lib::subVersion() { 182int Lib::subVersion() {
182 int major, minor, sub; 183 int major, minor, sub;
183 xine_get_version ( &major, &minor, &sub ); 184 xine_get_version ( &major, &minor, &sub );
184 return sub; 185 return sub;
185} 186}
186 187
187int Lib::play( const QString& fileName, int startPos, int start_time ) { 188int Lib::play( const QString& fileName, int startPos, int start_time ) {
188 assert( m_initialized ); 189 assert( m_initialized );
189 190
190 QString str = fileName.stripWhiteSpace(); 191 QString str = fileName.stripWhiteSpace();
191 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { 192 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) {
192 return 0; 193 return 0;
193 } 194 }
194 return xine_play( m_stream, startPos, start_time); 195 return xine_play( m_stream, startPos, start_time);
195} 196}
196 197
197void Lib::stop() { 198void Lib::stop() {
198 assert( m_initialized ); 199 assert( m_initialized );
199 200
200 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 201 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
201 xine_stop( m_stream ); 202 xine_stop( m_stream );
202} 203}
203 204
204void Lib::pause( bool toggle ) { 205void Lib::pause( bool toggle ) {
205 assert( m_initialized ); 206 assert( m_initialized );
206 207
207 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 208 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
208} 209}
209 210
210int Lib::speed() const { 211int Lib::speed() const {
211 assert( m_initialized ); 212 assert( m_initialized );
212 213
213 return xine_get_param ( m_stream, XINE_PARAM_SPEED ); 214 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
214} 215}
215 216
216void Lib::setSpeed( int speed ) { 217void Lib::setSpeed( int speed ) {
217 assert( m_initialized ); 218 assert( m_initialized );
218 219
219 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); 220 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
220} 221}
221 222
222int Lib::status() const { 223int Lib::status() const {
223 assert( m_initialized ); 224 assert( m_initialized );
224 225
225 return xine_get_status( m_stream ); 226 return xine_get_status( m_stream );
226} 227}
227 228
228int Lib::currentPosition() const { 229int Lib::currentPosition() const {
229 assert( m_initialized ); 230 assert( m_initialized );
230 231
231 int pos, time, length; 232 int pos, time, length;
232 xine_get_pos_length( m_stream, &pos, &time, &length ); 233 xine_get_pos_length( m_stream, &pos, &time, &length );
233 return pos; 234 return pos;
234} 235}
235 236
236int Lib::currentTime() const { 237int Lib::currentTime() const {
237 assert( m_initialized ); 238 assert( m_initialized );
238 239
239 int pos, time, length; 240 int pos, time, length;
240 xine_get_pos_length( m_stream, &pos, &time, &length ); 241 xine_get_pos_length( m_stream, &pos, &time, &length );
241 return time/1000; 242 return time/1000;
242} 243}
243 244
244int Lib::length() const { 245int Lib::length() const {
245 assert( m_initialized ); 246 assert( m_initialized );
246 247
247 int pos, time, length; 248 int pos, time, length;
248 xine_get_pos_length( m_stream, &pos, &time, &length ); 249 xine_get_pos_length( m_stream, &pos, &time, &length );
249 return length/1000; 250 return length/1000;
250} 251}
251 252
252bool Lib::isSeekable() const { 253bool Lib::isSeekable() const {
253 assert( m_initialized ); 254 assert( m_initialized );
254 255
255 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 256 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
256} 257}
257 258
258void Lib::seekTo( int time ) { 259void Lib::seekTo( int time ) {
259 assert( m_initialized ); 260 assert( m_initialized );
260 261
261 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( 262 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
262 // since its now milliseconds we need *1000 263 // since its now milliseconds we need *1000
263 xine_play( m_stream, 0, time*1000 ); 264 xine_play( m_stream, 0, time*1000 );
264} 265}
265 266
266 267
267Frame Lib::currentFrame() const { 268Frame Lib::currentFrame() const {
268 assert( m_initialized ); 269 assert( m_initialized );
269 270
270 Frame frame; 271 Frame frame;
271 return frame; 272 return frame;
272}; 273};
273 274
274QString Lib::metaInfo( int number) const { 275QString Lib::metaInfo( int number) const {
275 assert( m_initialized ); 276 assert( m_initialized );
276 277
277 return xine_get_meta_info( m_stream, number ); 278 return xine_get_meta_info( m_stream, number );
278} 279}
279 280
280int Lib::error() const { 281int Lib::error() const {
281 assert( m_initialized ); 282 assert( m_initialized );
282 283
283 return xine_get_error( m_stream ); 284 return xine_get_error( m_stream );
284}; 285};
285 286
287void Lib::ensureInitialized()
288{
289 if ( m_initialized )
290 return;
291
292 qDebug( "waiting for initialization thread to finish" );
293 wait();
294 qDebug( "initialization thread finished!" );
295}
296
286void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) 297void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
287{ 298{
288 assert( sendType == ThreadUtil::Channel::OneWay ); 299 assert( sendType == ThreadUtil::Channel::OneWay );
289 handleXineEvent( msg->type() ); 300 handleXineEvent( msg->type() );
290 delete msg; 301 delete msg;
291} 302}
292 303
293void Lib::handleXineEvent( const xine_event_t* t ) { 304void Lib::handleXineEvent( const xine_event_t* t ) {
294 send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); 305 send( new ThreadUtil::ChannelMessage( t->type ), OneWay );
295} 306}
296 307
297void Lib::handleXineEvent( int type ) { 308void Lib::handleXineEvent( int type ) {
298 assert( m_initialized ); 309 assert( m_initialized );
299 310
300 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { 311 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) {
301 emit stopped(); 312 emit stopped();
302 } 313 }
303} 314}
304 315
305 316
306void Lib::setShowVideo( bool video ) { 317void Lib::setShowVideo( bool video ) {
307 assert( m_initialized ); 318 assert( m_initialized );
308 319
309 m_video = video; 320 m_video = video;
310 ::null_set_show_video( m_videoOutput, video ); 321 ::null_set_show_video( m_videoOutput, video );
311} 322}
312 323
313bool Lib::isShowingVideo() const { 324bool Lib::isShowingVideo() const {
314 assert( m_initialized ); 325 assert( m_initialized );
315 326
316 return ::null_is_showing_video( m_videoOutput ); 327 return ::null_is_showing_video( m_videoOutput );
317} 328}
318 329
319bool Lib::hasVideo() const { 330bool Lib::hasVideo() const {
320 assert( m_initialized ); 331 assert( m_initialized );
321 332
322 return xine_get_stream_info( m_stream, 18 ); 333 return xine_get_stream_info( m_stream, 18 );
323} 334}
324 335
325void Lib::showVideoFullScreen( bool fullScreen ) { 336void Lib::showVideoFullScreen( bool fullScreen ) {
326 assert( m_initialized ); 337 assert( m_initialized );
327 338
328 ::null_set_fullscreen( m_videoOutput, fullScreen ); 339 ::null_set_fullscreen( m_videoOutput, fullScreen );
329} 340}
330 341
331bool Lib::isVideoFullScreen() const { 342bool Lib::isVideoFullScreen() const {
332 assert( m_initialized ); 343 assert( m_initialized );
333 344
334 return ::null_is_fullscreen( m_videoOutput ); 345 return ::null_is_fullscreen( m_videoOutput );
335} 346}
336 347
337void Lib::setScaling( bool scale ) { 348void Lib::setScaling( bool scale ) {
338 assert( m_initialized ); 349 assert( m_initialized );
339 350
340 ::null_set_scaling( m_videoOutput, scale ); 351 ::null_set_scaling( m_videoOutput, scale );
341} 352}
342 353
343void Lib::setGamma( int value ) { 354void Lib::setGamma( int value ) {
344 assert( m_initialized ); 355 assert( m_initialized );
345 356
346 //qDebug( QString( "%1").arg(value) ); 357 //qDebug( QString( "%1").arg(value) );
347 /* int gammaValue = ( 100 + value ); */ 358 /* int gammaValue = ( 100 + value ); */
348 ::null_set_videoGamma( m_videoOutput, value ); 359 ::null_set_videoGamma( m_videoOutput, value );
349} 360}
350 361
351bool Lib::isScaling() const { 362bool Lib::isScaling() const {
352 assert( m_initialized ); 363 assert( m_initialized );
353 364
354 return ::null_is_scaling( m_videoOutput ); 365 return ::null_is_scaling( m_videoOutput );
355} 366}
356 367
357void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { 368void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) {
358 ( (Lib*)user_data)->handleXineEvent( t ); 369 ( (Lib*)user_data)->handleXineEvent( t );
359} 370}
360 371
361void Lib::xine_display_frame( void* user_data, uint8_t *frame, 372void Lib::xine_display_frame( void* user_data, uint8_t *frame,
362 int width, int height, int bytes ) { 373 int width, int height, int bytes ) {
363 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); 374 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
364} 375}
365 376
366void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 377void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
367 assert( m_initialized ); 378 assert( m_initialized );
368 379
369 if ( !m_video ) { 380 if ( !m_video ) {
370 qWarning("not showing video now"); 381 qWarning("not showing video now");
371 return; 382 return;
372 } 383 }
373 m_wid-> setVideoFrame ( frame, width, height, bytes ); 384 m_wid-> setVideoFrame ( frame, width, height, bytes );
374} 385}
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index 9dd7385..6b67f67 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -1,217 +1,219 @@
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#ifndef ZECKEXINELIB_H 34#ifndef ZECKEXINELIB_H
35#define ZECKEXINELIB_H 35#define ZECKEXINELIB_H
36 36
37#include <qcstring.h> 37#include <qcstring.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <xine.h> 41#include <xine.h>
42//#include "xine.h" 42//#include "xine.h"
43 43
44#include "threadutil.h" 44#include "threadutil.h"
45 45
46class XineVideoWidget; 46class XineVideoWidget;
47 47
48namespace XINE { 48namespace XINE {
49 49
50 /** 50 /**
51 * Lib wrapps the simple interface 51 * Lib wrapps the simple interface
52 * of libxine for easy every day use 52 * of libxine for easy every day use
53 * This will become a full C++ Wrapper 53 * This will become a full C++ Wrapper
54 * It supports playing, pausing, info, 54 * It supports playing, pausing, info,
55 * stooping, seeking. 55 * stooping, seeking.
56 */ 56 */
57 class Frame; 57 class Frame;
58 class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread 58 class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread
59 { 59 {
60 Q_OBJECT 60 Q_OBJECT
61 public: 61 public:
62 enum InitializationMode { InitializeImmediately, InitializeInThread }; 62 enum InitializationMode { InitializeImmediately, InitializeInThread };
63 63
64 Lib( InitializationMode initMode, XineVideoWidget* = 0); 64 Lib( InitializationMode initMode, XineVideoWidget* = 0);
65 65
66 ~Lib(); 66 ~Lib();
67 static int majorVersion(); 67 static int majorVersion();
68 static int minorVersion(); 68 static int minorVersion();
69 static int subVersion(); 69 static int subVersion();
70 70
71 71
72 void resize ( const QSize &s ); 72 void resize ( const QSize &s );
73 73
74 int play( const QString& fileName, 74 int play( const QString& fileName,
75 int startPos = 0, 75 int startPos = 0,
76 int start_time = 0 ); 76 int start_time = 0 );
77 void stop(); 77 void stop();
78 void pause( bool toggle ); 78 void pause( bool toggle );
79 79
80 int speed() const; 80 int speed() const;
81 81
82 /** 82 /**
83 * Set the speed of the stream, if codec supports it 83 * Set the speed of the stream, if codec supports it
84 * XINE_SPEED_PAUSE 0 84 * XINE_SPEED_PAUSE 0
85 * XINE_SPEED_SLOW_4 1 85 * XINE_SPEED_SLOW_4 1
86 * XINE_SPEED_SLOW_2 2 86 * XINE_SPEED_SLOW_2 2
87 * XINE_SPEED_NORMAL 4 87 * XINE_SPEED_NORMAL 4
88 * XINE_SPEED_FAST_2 8 88 * XINE_SPEED_FAST_2 8
89 *XINE_SPEED_FAST_4 16 89 *XINE_SPEED_FAST_4 16
90 */ 90 */
91 void setSpeed( int speed = XINE_SPEED_PAUSE ); 91 void setSpeed( int speed = XINE_SPEED_PAUSE );
92 92
93 int status() const; 93 int status() const;
94 94
95 int currentPosition()const; 95 int currentPosition()const;
96 //in seconds 96 //in seconds
97 int currentTime()const; 97 int currentTime()const;
98 98
99 int length() const; 99 int length() const;
100 100
101 bool isSeekable()const; 101 bool isSeekable()const;
102 102
103 /** 103 /**
104 * Whether or not to show video output 104 * Whether or not to show video output
105 */ 105 */
106 void setShowVideo(bool video); 106 void setShowVideo(bool video);
107 107
108 /** 108 /**
109 * is we show video 109 * is we show video
110 */ 110 */
111 bool isShowingVideo() const; 111 bool isShowingVideo() const;
112 112
113 /** 113 /**
114 * 114 *
115 */ 115 */
116 void showVideoFullScreen( bool fullScreen ); 116 void showVideoFullScreen( bool fullScreen );
117 117
118 /** 118 /**
119 * 119 *
120 */ 120 */
121 bool isVideoFullScreen() const; 121 bool isVideoFullScreen() const;
122 122
123 123
124 /** 124 /**
125 * Get the meta info (like author etc) from the stream 125 * Get the meta info (like author etc) from the stream
126 * XINE_META_INFO_TITLE 0 126 * XINE_META_INFO_TITLE 0
127 * XINE_META_INFO_COMMENT 1 127 * XINE_META_INFO_COMMENT 1
128 * XINE_META_INFO_ARTIST 2 128 * XINE_META_INFO_ARTIST 2
129 * XINE_META_INFO_GENRE 3 129 * XINE_META_INFO_GENRE 3
130 * XINE_META_INFO_ALBUM 4 130 * XINE_META_INFO_ALBUM 4
131 * XINE_META_INFO_YEAR 5 131 * XINE_META_INFO_YEAR 5
132 * XINE_META_INFO_VIDEOCODEC 6 132 * XINE_META_INFO_VIDEOCODEC 6
133 * XINE_META_INFO_AUDIOCODEC 7 133 * XINE_META_INFO_AUDIOCODEC 7
134 * XINE_META_INFO_SYSTEMLAYER 8 134 * XINE_META_INFO_SYSTEMLAYER 8
135 * XINE_META_INFO_INPUT_PLUGIN 9 135 * XINE_META_INFO_INPUT_PLUGIN 9
136 */ 136 */
137 QString metaInfo( int number ) const; 137 QString metaInfo( int number ) const;
138 138
139 /** 139 /**
140 * 140 *
141 */ 141 */
142 bool isScaling() const; 142 bool isScaling() const;
143 143
144 /** 144 /**
145 * seek to a position 145 * seek to a position
146 */ 146 */
147 void seekTo( int time ); 147 void seekTo( int time );
148 148
149 /** 149 /**
150 * 150 *
151 * @return is media stream has video 151 * @return is media stream has video
152 */ 152 */
153 bool hasVideo() const; 153 bool hasVideo() const;
154 154
155 /** 155 /**
156 * 156 *
157 */ 157 */
158 void setScaling( bool ); 158 void setScaling( bool );
159 159
160 /** 160 /**
161 * Set the Gamma value for video output 161 * Set the Gamma value for video output
162 * @param int the value between -100 and 100, 0 is original 162 * @param int the value between -100 and 100, 0 is original
163 */ 163 */
164 void setGamma( int ); 164 void setGamma( int );
165 165
166 /** 166 /**
167 * test 167 * test
168 */ 168 */
169 Frame currentFrame() const; 169 Frame currentFrame() const;
170 170
171 /** 171 /**
172 * Returns the error code 172 * Returns the error code
173 * XINE_ERROR_NONE 0 173 * XINE_ERROR_NONE 0
174 * XINE_ERROR_NO_INPUT_PLUGIN 1 174 * XINE_ERROR_NO_INPUT_PLUGIN 1
175 * XINE_ERROR_NO_DEMUXER_PLUGIN 2 175 * XINE_ERROR_NO_DEMUXER_PLUGIN 2
176 * XINE_ERROR_DEMUXER_FAILED 3 176 * XINE_ERROR_DEMUXER_FAILED 3
177 */ 177 */
178 int error() const; 178 int error() const;
179 179
180 void ensureInitialized();
181
180 signals: 182 signals:
181 183
182 void stopped(); 184 void stopped();
183 185
184 void initialized(); 186 void initialized();
185 187
186 protected: 188 protected:
187 virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); 189 virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType );
188 190
189 virtual void run(); 191 virtual void run();
190 192
191 private: 193 private:
192 void initialize(); 194 void initialize();
193 195
194 int m_bytes_per_pixel; 196 int m_bytes_per_pixel;
195 bool m_initialized:1; 197 bool m_initialized:1;
196 bool m_duringInitialization:1; 198 bool m_duringInitialization:1;
197 bool m_video:1; 199 bool m_video:1;
198 XineVideoWidget *m_wid; 200 XineVideoWidget *m_wid;
199 xine_t *m_xine; 201 xine_t *m_xine;
200 xine_stream_t *m_stream; 202 xine_stream_t *m_stream;
201 xine_cfg_entry_t *m_config; 203 xine_cfg_entry_t *m_config;
202 xine_vo_driver_t *m_videoOutput; 204 xine_vo_driver_t *m_videoOutput;
203 xine_ao_driver_t* m_audioOutput; 205 xine_ao_driver_t* m_audioOutput;
204 xine_event_queue_t *m_queue; 206 xine_event_queue_t *m_queue;
205 207
206 void handleXineEvent( const xine_event_t* t ); 208 void handleXineEvent( const xine_event_t* t );
207 void handleXineEvent( int type ); 209 void handleXineEvent( int type );
208 void drawFrame( uint8_t* frame, int width, int height, int bytes ); 210 void drawFrame( uint8_t* frame, int width, int height, int bytes );
209 // C -> C++ bridge for the event system 211 // C -> C++ bridge for the event system
210 static void xine_event_handler( void* user_data, const xine_event_t* t); 212 static void xine_event_handler( void* user_data, const xine_event_t* t);
211 static void xine_display_frame( void* user_data, uint8_t* frame , 213 static void xine_display_frame( void* user_data, uint8_t* frame ,
212 int width, int height, int bytes ); 214 int width, int height, int bytes );
213 }; 215 };
214}; 216};
215 217
216 218
217#endif 219#endif
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 1aa3daa..7c54499 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,269 +1,270 @@
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..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; 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  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = 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 <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include "xinecontrol.h" 39#include "xinecontrol.h"
40#include "mediaplayerstate.h" 40#include "mediaplayerstate.h"
41#include "xinevideowidget.h" 41#include "xinevideowidget.h"
42 42
43XineControl::XineControl( XineVideoWidget *xineWidget, 43XineControl::XineControl( XineVideoWidget *xineWidget,
44 MediaPlayerState &_mediaPlayerState, 44 MediaPlayerState &_mediaPlayerState,
45 QObject *parent, const char *name ) 45 QObject *parent, const char *name )
46 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 46 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
47{ 47{
48
49 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); 48 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget );
50 49
51 init(); 50 init();
52} 51}
53 52
54XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, 53XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget,
55 MediaPlayerState &_mediaPlayerState, 54 MediaPlayerState &_mediaPlayerState,
56 QObject *parent, const char *name ) 55 QObject *parent, const char *name )
57 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 56 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
58{ 57{
58 xine->ensureInitialized();
59
59 init(); 60 init();
60} 61}
61 62
62void XineControl::init() 63void XineControl::init()
63{ 64{
64 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); 65 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) );
65 connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); 66 connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) );
66 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 67 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
67 connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 68 connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
68 connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 69 connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
69 connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); 70 connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
70 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 71 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
71 connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); 72 connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) );
72 73
73 disabledSuspendScreenSaver = FALSE; 74 disabledSuspendScreenSaver = FALSE;
74} 75}
75 76
76XineControl::~XineControl() { 77XineControl::~XineControl() {
77#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 78#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
78 if ( disabledSuspendScreenSaver ) { 79 if ( disabledSuspendScreenSaver ) {
79 disabledSuspendScreenSaver = FALSE; 80 disabledSuspendScreenSaver = FALSE;
80 // Re-enable the suspend mode 81 // Re-enable the suspend mode
81 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 82 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
82 } 83 }
83#endif 84#endif
84 delete libXine; 85 delete libXine;
85} 86}
86 87
87void XineControl::play( const QString& fileName ) { 88void XineControl::play( const QString& fileName ) {
88 hasVideoChannel = FALSE; 89 hasVideoChannel = FALSE;
89 hasAudioChannel = FALSE; 90 hasAudioChannel = FALSE;
90 m_fileName = fileName; 91 m_fileName = fileName;
91 92
92 qDebug("<<FILENAME: " + fileName + ">>>>"); 93 qDebug("<<FILENAME: " + fileName + ">>>>");
93 94
94 if ( !libXine->play( fileName, 0, 0 ) ) { 95 if ( !libXine->play( fileName, 0, 0 ) ) {
95 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 96 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
96 // toggle stop so the the play button is reset 97 // toggle stop so the the play button is reset
97 mediaPlayerState.setPlaying( false ); 98 mediaPlayerState.setPlaying( false );
98 return; 99 return;
99 } 100 }
100 mediaPlayerState.setPlaying( true ); 101 mediaPlayerState.setPlaying( true );
101 102
102 MediaPlayerState::DisplayType displayType; 103 MediaPlayerState::DisplayType displayType;
103 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); 104 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) );
104 if ( !libXine->hasVideo() ) { 105 if ( !libXine->hasVideo() ) {
105 displayType = MediaPlayerState::Audio; 106 displayType = MediaPlayerState::Audio;
106 qDebug("HAS AUDIO"); 107 qDebug("HAS AUDIO");
107 libXine->setShowVideo( false ); 108 libXine->setShowVideo( false );
108 hasAudioChannel = TRUE; 109 hasAudioChannel = TRUE;
109 } else { 110 } else {
110 displayType = MediaPlayerState::Video; 111 displayType = MediaPlayerState::Video;
111 qDebug("HAS VIDEO"); 112 qDebug("HAS VIDEO");
112 libXine->setShowVideo( true ); 113 libXine->setShowVideo( true );
113 hasVideoChannel = TRUE; 114 hasVideoChannel = TRUE;
114 } 115 }
115 // determine if slider is shown 116 // determine if slider is shown
116 mediaPlayerState.setIsSeekable( libXine->isSeekable() ); 117 mediaPlayerState.setIsSeekable( libXine->isSeekable() );
117 118
118 // which gui (video / audio) 119 // which gui (video / audio)
119 mediaPlayerState.setDisplayType( displayType ); 120 mediaPlayerState.setDisplayType( displayType );
120 121
121#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 122#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
122 if ( !disabledSuspendScreenSaver ) { 123 if ( !disabledSuspendScreenSaver ) {
123 disabledSuspendScreenSaver = TRUE; 124 disabledSuspendScreenSaver = TRUE;
124 // Stop the screen from blanking and power saving state 125 // Stop the screen from blanking and power saving state
125 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) 126 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
126 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 127 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend );
127 } 128 }
128#endif 129#endif
129 130
130 length(); 131 length();
131 position(); 132 position();
132} 133}
133 134
134void XineControl::nextMedia() { 135void XineControl::nextMedia() {
135 mediaPlayerState.setNext(); 136 mediaPlayerState.setNext();
136} 137}
137 138
138void XineControl::setGamma( int value ) { 139void XineControl::setGamma( int value ) {
139 libXine->setGamma( value ); 140 libXine->setGamma( value );
140} 141}
141 142
142void XineControl::stop( bool isSet ) { 143void XineControl::stop( bool isSet ) {
143 if ( !isSet ) { 144 if ( !isSet ) {
144 libXine->stop(); 145 libXine->stop();
145 146
146#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 147#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
147 if ( disabledSuspendScreenSaver ) { 148 if ( disabledSuspendScreenSaver ) {
148 disabledSuspendScreenSaver = FALSE; 149 disabledSuspendScreenSaver = FALSE;
149 // Re-enable the suspend mode 150 // Re-enable the suspend mode
150 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 151 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
151 } 152 }
152#endif 153#endif
153 } 154 }
154} 155}
155 156
156/** 157/**
157 * Pause playback 158 * Pause playback
158 * @isSet 159 * @isSet
159 */ 160 */
160void XineControl::pause( bool isSet) { 161void XineControl::pause( bool isSet) {
161 libXine->pause( isSet ); 162 libXine->pause( isSet );
162} 163}
163 164
164 165
165/** 166/**
166 * get current time in playback 167 * get current time in playback
167 */ 168 */
168long XineControl::currentTime() { 169long XineControl::currentTime() {
169 // todo: jede sekunde überprüfen 170 // todo: jede sekunde überprüfen
170 m_currentTime = libXine->currentTime(); 171 m_currentTime = libXine->currentTime();
171 return m_currentTime; 172 return m_currentTime;
172 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 173 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
173} 174}
174 175
175/** 176/**
176 * Set the length of the media file 177 * Set the length of the media file
177 */ 178 */
178void XineControl::length() { 179void XineControl::length() {
179 m_length = libXine->length(); 180 m_length = libXine->length();
180 mediaPlayerState.setLength( m_length ); 181 mediaPlayerState.setLength( m_length );
181} 182}
182 183
183 184
184/** 185/**
185 * Reports the position the xine backend is at right now 186 * Reports the position the xine backend is at right now
186 * @return long the postion in seconds 187 * @return long the postion in seconds
187 */ 188 */
188long XineControl::position() { 189long XineControl::position() {
189 m_position = ( currentTime() ); 190 m_position = ( currentTime() );
190 mediaPlayerState.updatePosition( m_position ); 191 mediaPlayerState.updatePosition( m_position );
191 long emitPos = (long)m_position; 192 long emitPos = (long)m_position;
192 emit positionChanged( emitPos ); 193 emit positionChanged( emitPos );
193 if( mediaPlayerState.isPlaying() ) { 194 if( mediaPlayerState.isPlaying() ) {
194 // needs to be stopped the media is stopped 195 // needs to be stopped the media is stopped
195 QTimer::singleShot( 1000, this, SLOT( position() ) ); 196 QTimer::singleShot( 1000, this, SLOT( position() ) );
196 } 197 }
197 // qDebug("POSITION : %d", m_position); 198 // qDebug("POSITION : %d", m_position);
198 return m_position; 199 return m_position;
199} 200}
200 201
201/** 202/**
202 * Set videoplayback to fullscreen 203 * Set videoplayback to fullscreen
203 * @param isSet 204 * @param isSet
204 */ 205 */
205void XineControl::setFullscreen( bool isSet ) { 206void XineControl::setFullscreen( bool isSet ) {
206 libXine->showVideoFullScreen( isSet ); 207 libXine->showVideoFullScreen( isSet );
207} 208}
208 209
209 210
210QString XineControl::getMetaInfo() { 211QString XineControl::getMetaInfo() {
211 212
212 QString returnString; 213 QString returnString;
213 214
214 if ( !libXine->metaInfo( 0 ).isEmpty() ) { 215 if ( !libXine->metaInfo( 0 ).isEmpty() ) {
215 returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); 216 returnString += tr( " Title: " + libXine->metaInfo( 0 ) );
216 } 217 }
217 218
218 if ( !libXine->metaInfo( 1 ).isEmpty() ) { 219 if ( !libXine->metaInfo( 1 ).isEmpty() ) {
219 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); 220 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
220 } 221 }
221 222
222 if ( !libXine->metaInfo( 2 ).isEmpty() ) { 223 if ( !libXine->metaInfo( 2 ).isEmpty() ) {
223 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); 224 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) );
224 } 225 }
225 226
226 if ( !libXine->metaInfo( 3 ).isEmpty() ) { 227 if ( !libXine->metaInfo( 3 ).isEmpty() ) {
227 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); 228 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) );
228 } 229 }
229 230
230 if ( !libXine->metaInfo( 4 ).isEmpty() ) { 231 if ( !libXine->metaInfo( 4 ).isEmpty() ) {
231 returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); 232 returnString += tr( " Album: " + libXine->metaInfo( 4 ) );
232 } 233 }
233 234
234 if ( !libXine->metaInfo( 5 ).isEmpty() ) { 235 if ( !libXine->metaInfo( 5 ).isEmpty() ) {
235 returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); 236 returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
236 } 237 }
237 return returnString; 238 return returnString;
238} 239}
239 240
240QString XineControl::getErrorCode() { 241QString XineControl::getErrorCode() {
241 242
242 int errorCode = libXine->error(); 243 int errorCode = libXine->error();
243 244
244 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); 245 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) );
245 246
246 if ( errorCode == 1 ) { 247 if ( errorCode == 1 ) {
247 return tr( "No input plugin found for this media type" ); 248 return tr( "No input plugin found for this media type" );
248 } else if ( errorCode == 2 ) { 249 } else if ( errorCode == 2 ) {
249 return tr( "No demux plugin found for this media type" ); 250 return tr( "No demux plugin found for this media type" );
250 } else if ( errorCode == 3 ) { 251 } else if ( errorCode == 3 ) {
251 return tr( "Demuxing failed for this media type" ); 252 return tr( "Demuxing failed for this media type" );
252 } else if ( errorCode == 4 ) { 253 } else if ( errorCode == 4 ) {
253 return tr( "Malformed MRL" ); 254 return tr( "Malformed MRL" );
254 } else { 255 } else {
255 return tr( "Some other error" ); 256 return tr( "Some other error" );
256 } 257 }
257} 258}
258 259
259/** 260/**
260 * Seek to a position in the track 261 * Seek to a position in the track
261 * @param second the second to jump to 262 * @param second the second to jump to
262 */ 263 */
263void XineControl::seekTo( long second ) { 264void XineControl::seekTo( long second ) {
264 libXine->seekTo( (int)second ); 265 libXine->seekTo( (int)second );
265} 266}
266 267
267void XineControl::videoResized ( const QSize &s ) { 268void XineControl::videoResized ( const QSize &s ) {
268 libXine->resize( s ); 269 libXine->resize( s );
269} 270}