summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-13 22:52:38 (UTC)
committer simon <simon>2002-12-13 22:52:38 (UTC)
commit7a5b1d2dd538ee6d401e795057660f58e9a60eab (patch) (unidiff)
tree612483f02744b6b7f85ee4552c9227f2918293ef
parent15b3146ee488a3f31f355ece580f444c48bfc7e9 (diff)
downloadopie-7a5b1d2dd538ee6d401e795057660f58e9a60eab.zip
opie-7a5b1d2dd538ee6d401e795057660f58e9a60eab.tar.gz
opie-7a5b1d2dd538ee6d401e795057660f58e9a60eab.tar.bz2
- oops #1
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 9d4b1be..040eab3 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,371 +1,371 @@
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_video = false; 76 m_video = false;
77 m_wid = widget; 77 m_wid = widget;
78 printf("Lib"); 78 printf("Lib");
79 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 79 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
80 // get the configuration 80 // get the configuration
81 81
82 // not really OO, should be an extra class, later 82 // not really OO, should be an extra class, later
83 if ( !QFile::exists(configPath) ) { 83 if ( !QFile::exists(configPath) ) {
84 QFile f(configPath); 84 QFile f(configPath);
85 f.open(IO_WriteOnly); 85 f.open(IO_WriteOnly);
86 QTextStream ts( &f ); 86 QTextStream ts( &f );
87 ts << "misc.memcpy_method:glibc\n"; 87 ts << "misc.memcpy_method:glibc\n";
88 f.close(); 88 f.close();
89 } 89 }
90 90
91 if ( initMode == InitializeImmediately ) { 91 if ( initMode == InitializeImmediately ) {
92 initialize(); 92 initialize();
93 m_initialized = true; 93 m_initialized = true;
94 } 94 }
95 else 95 else
96 assert( false ); 96 assert( false );
97} 97}
98 98
99void Lib::run() 99void Lib::run()
100{ 100{
101 assert( false ); 101 assert( false );
102} 102}
103 103
104void Lib::initialize() 104void Lib::initialize()
105{ 105{
106 m_xine = xine_new( ); 106 m_xine = xine_new( );
107 107
108 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 108 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
109 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 109 xine_config_load( m_xine, QFile::encodeName( configPath ) );
110 110
111 xine_init( m_xine ); 111 xine_init( m_xine );
112 112
113 // allocate oss for sound 113 // allocate oss for sound
114 // and fb for framebuffer 114 // and fb for framebuffer
115 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 115 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
116 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 116 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
117 117
118 118
119//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); 119//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
120 120
121 121
122// null_display_handler( m_videoOutput, xine_display_frame, this ); 122// null_display_handler( m_videoOutput, xine_display_frame, this );
123 123
124 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 124 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
125 125
126 if (m_wid != 0 ) { 126 if (m_wid != 0 ) {
127 printf( "!0\n" ); 127 printf( "!0\n" );
128 resize ( m_wid-> size ( ) ); 128 resize ( m_wid-> size ( ) );
129 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 129 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
130 130
131// m_wid->repaint(); 131// m_wid->repaint();
132 } 132 }
133 133
134 m_queue = xine_event_new_queue (m_stream); 134 m_queue = xine_event_new_queue (m_stream);
135 135
136 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 136 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
137} 137}
138 138
139Lib::~Lib() { 139Lib::~Lib() {
140 assert( isRunning() == false ) 140 assert( isRunning() == false );
141 assert( m_initialized ); 141 assert( m_initialized );
142 142
143// free( m_config ); 143// free( m_config );
144 144
145 xine_close( m_stream ); 145 xine_close( m_stream );
146 146
147 xine_event_dispose_queue( m_queue ); 147 xine_event_dispose_queue( m_queue );
148 148
149 xine_dispose( m_stream ); 149 xine_dispose( m_stream );
150 150
151 xine_exit( m_xine ); 151 xine_exit( m_xine );
152 /* FIXME either free or delete but valgrind bitches against both */ 152 /* FIXME either free or delete but valgrind bitches against both */
153 //free( m_videoOutput ); 153 //free( m_videoOutput );
154 //delete m_audioOutput; 154 //delete m_audioOutput;
155} 155}
156 156
157void Lib::resize ( const QSize &s ) { 157void Lib::resize ( const QSize &s ) {
158 assert( m_initialized ); 158 assert( m_initialized );
159 159
160 if ( s. width ( ) && s. height ( ) ) { 160 if ( s. width ( ) && s. height ( ) ) {
161 ::null_set_gui_width( m_videoOutput, s. width() ); 161 ::null_set_gui_width( m_videoOutput, s. width() );
162 ::null_set_gui_height( m_videoOutput, s. height() ); 162 ::null_set_gui_height( m_videoOutput, s. height() );
163 } 163 }
164} 164}
165 165
166int Lib::majorVersion() { 166int Lib::majorVersion() {
167 int major, minor, sub; 167 int major, minor, sub;
168 xine_get_version ( &major, &minor, &sub ); 168 xine_get_version ( &major, &minor, &sub );
169 return major; 169 return major;
170} 170}
171 171
172int Lib::minorVersion() { 172int Lib::minorVersion() {
173 int major, minor, sub; 173 int major, minor, sub;
174 xine_get_version ( &major, &minor, &sub ); 174 xine_get_version ( &major, &minor, &sub );
175 return minor; 175 return minor;
176} 176}
177 177
178int Lib::subVersion() { 178int Lib::subVersion() {
179 int major, minor, sub; 179 int major, minor, sub;
180 xine_get_version ( &major, &minor, &sub ); 180 xine_get_version ( &major, &minor, &sub );
181 return sub; 181 return sub;
182} 182}
183 183
184int Lib::play( const QString& fileName, int startPos, int start_time ) { 184int Lib::play( const QString& fileName, int startPos, int start_time ) {
185 assert( m_initialized ); 185 assert( m_initialized );
186 186
187 QString str = fileName.stripWhiteSpace(); 187 QString str = fileName.stripWhiteSpace();
188 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { 188 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) {
189 return 0; 189 return 0;
190 } 190 }
191 return xine_play( m_stream, startPos, start_time); 191 return xine_play( m_stream, startPos, start_time);
192} 192}
193 193
194void Lib::stop() { 194void Lib::stop() {
195 assert( m_initialized ); 195 assert( m_initialized );
196 196
197 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 197 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
198 xine_stop( m_stream ); 198 xine_stop( m_stream );
199} 199}
200 200
201void Lib::pause( bool toggle ) { 201void Lib::pause( bool toggle ) {
202 assert( m_initialized ); 202 assert( m_initialized );
203 203
204 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 204 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
205} 205}
206 206
207int Lib::speed() const { 207int Lib::speed() const {
208 assert( m_initialized ); 208 assert( m_initialized );
209 209
210 return xine_get_param ( m_stream, XINE_PARAM_SPEED ); 210 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
211} 211}
212 212
213void Lib::setSpeed( int speed ) { 213void Lib::setSpeed( int speed ) {
214 assert( m_initialized ); 214 assert( m_initialized );
215 215
216 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); 216 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
217} 217}
218 218
219int Lib::status() const { 219int Lib::status() const {
220 assert( m_initialized ); 220 assert( m_initialized );
221 221
222 return xine_get_status( m_stream ); 222 return xine_get_status( m_stream );
223} 223}
224 224
225int Lib::currentPosition() const { 225int Lib::currentPosition() const {
226 assert( m_initialized ); 226 assert( m_initialized );
227 227
228 int pos, time, length; 228 int pos, time, length;
229 xine_get_pos_length( m_stream, &pos, &time, &length ); 229 xine_get_pos_length( m_stream, &pos, &time, &length );
230 return pos; 230 return pos;
231} 231}
232 232
233int Lib::currentTime() const { 233int Lib::currentTime() const {
234 assert( m_initialized ); 234 assert( m_initialized );
235 235
236 int pos, time, length; 236 int pos, time, length;
237 xine_get_pos_length( m_stream, &pos, &time, &length ); 237 xine_get_pos_length( m_stream, &pos, &time, &length );
238 return time/1000; 238 return time/1000;
239} 239}
240 240
241int Lib::length() const { 241int Lib::length() const {
242 assert( m_initialized ); 242 assert( m_initialized );
243 243
244 int pos, time, length; 244 int pos, time, length;
245 xine_get_pos_length( m_stream, &pos, &time, &length ); 245 xine_get_pos_length( m_stream, &pos, &time, &length );
246 return length/1000; 246 return length/1000;
247} 247}
248 248
249bool Lib::isSeekable() const { 249bool Lib::isSeekable() const {
250 assert( m_initialized ); 250 assert( m_initialized );
251 251
252 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 252 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
253} 253}
254 254
255void Lib::seekTo( int time ) { 255void Lib::seekTo( int time ) {
256 assert( m_initialized ); 256 assert( m_initialized );
257 257
258 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( 258 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
259 // since its now milliseconds we need *1000 259 // since its now milliseconds we need *1000
260 xine_play( m_stream, 0, time*1000 ); 260 xine_play( m_stream, 0, time*1000 );
261} 261}
262 262
263 263
264Frame Lib::currentFrame() const { 264Frame Lib::currentFrame() const {
265 assert( m_initialized ); 265 assert( m_initialized );
266 266
267 Frame frame; 267 Frame frame;
268 return frame; 268 return frame;
269}; 269};
270 270
271QString Lib::metaInfo( int number) const { 271QString Lib::metaInfo( int number) const {
272 assert( m_initialized ); 272 assert( m_initialized );
273 273
274 return xine_get_meta_info( m_stream, number ); 274 return xine_get_meta_info( m_stream, number );
275} 275}
276 276
277int Lib::error() const { 277int Lib::error() const {
278 assert( m_initialized ); 278 assert( m_initialized );
279 279
280 return xine_get_error( m_stream ); 280 return xine_get_error( m_stream );
281}; 281};
282 282
283void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) 283void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
284{ 284{
285 assert( sendType == ThreadUtil::Channel::OneWay ); 285 assert( sendType == ThreadUtil::Channel::OneWay );
286 handleXineEvent( msg->type() ); 286 handleXineEvent( msg->type() );
287 delete msg; 287 delete msg;
288} 288}
289 289
290void Lib::handleXineEvent( const xine_event_t* t ) { 290void Lib::handleXineEvent( const xine_event_t* t ) {
291 send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); 291 send( new ThreadUtil::ChannelMessage( t->type ), OneWay );
292} 292}
293 293
294void Lib::handleXineEvent( int type ) { 294void Lib::handleXineEvent( int type ) {
295 assert( m_initialized ); 295 assert( m_initialized );
296 296
297 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { 297 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) {
298 emit stopped(); 298 emit stopped();
299 } 299 }
300} 300}
301 301
302 302
303void Lib::setShowVideo( bool video ) { 303void Lib::setShowVideo( bool video ) {
304 assert( m_initialized ); 304 assert( m_initialized );
305 305
306 m_video = video; 306 m_video = video;
307 ::null_set_show_video( m_videoOutput, video ); 307 ::null_set_show_video( m_videoOutput, video );
308} 308}
309 309
310bool Lib::isShowingVideo() const { 310bool Lib::isShowingVideo() const {
311 assert( m_initialized ); 311 assert( m_initialized );
312 312
313 return ::null_is_showing_video( m_videoOutput ); 313 return ::null_is_showing_video( m_videoOutput );
314} 314}
315 315
316bool Lib::hasVideo() const { 316bool Lib::hasVideo() const {
317 assert( m_initialized ); 317 assert( m_initialized );
318 318
319 return xine_get_stream_info( m_stream, 18 ); 319 return xine_get_stream_info( m_stream, 18 );
320} 320}
321 321
322void Lib::showVideoFullScreen( bool fullScreen ) { 322void Lib::showVideoFullScreen( bool fullScreen ) {
323 assert( m_initialized ); 323 assert( m_initialized );
324 324
325 ::null_set_fullscreen( m_videoOutput, fullScreen ); 325 ::null_set_fullscreen( m_videoOutput, fullScreen );
326} 326}
327 327
328bool Lib::isVideoFullScreen() const { 328bool Lib::isVideoFullScreen() const {
329 assert( m_initialized ); 329 assert( m_initialized );
330 330
331 return ::null_is_fullscreen( m_videoOutput ); 331 return ::null_is_fullscreen( m_videoOutput );
332} 332}
333 333
334void Lib::setScaling( bool scale ) { 334void Lib::setScaling( bool scale ) {
335 assert( m_initialized ); 335 assert( m_initialized );
336 336
337 ::null_set_scaling( m_videoOutput, scale ); 337 ::null_set_scaling( m_videoOutput, scale );
338} 338}
339 339
340void Lib::setGamma( int value ) { 340void Lib::setGamma( int value ) {
341 assert( m_initialized ); 341 assert( m_initialized );
342 342
343 //qDebug( QString( "%1").arg(value) ); 343 //qDebug( QString( "%1").arg(value) );
344 /* int gammaValue = ( 100 + value ); */ 344 /* int gammaValue = ( 100 + value ); */
345 ::null_set_videoGamma( m_videoOutput, value ); 345 ::null_set_videoGamma( m_videoOutput, value );
346} 346}
347 347
348bool Lib::isScaling() const { 348bool Lib::isScaling() const {
349 assert( m_initialized ); 349 assert( m_initialized );
350 350
351 return ::null_is_scaling( m_videoOutput ); 351 return ::null_is_scaling( m_videoOutput );
352} 352}
353 353
354void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { 354void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) {
355 ( (Lib*)user_data)->handleXineEvent( t ); 355 ( (Lib*)user_data)->handleXineEvent( t );
356} 356}
357 357
358void Lib::xine_display_frame( void* user_data, uint8_t *frame, 358void Lib::xine_display_frame( void* user_data, uint8_t *frame,
359 int width, int height, int bytes ) { 359 int width, int height, int bytes ) {
360 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); 360 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
361} 361}
362 362
363void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 363void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
364 assert( m_initialized ); 364 assert( m_initialized );
365 365
366 if ( !m_video ) { 366 if ( !m_video ) {
367 qWarning("not showing video now"); 367 qWarning("not showing video now");
368 return; 368 return;
369 } 369 }
370 m_wid-> setVideoFrame ( frame, width, height, bytes ); 370 m_wid-> setVideoFrame ( frame, width, height, bytes );
371} 371}