Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 1ab5c96..248221b 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -25,48 +25,49 @@ | |||
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 "xinevideowidget.h" | 34 | #include "xinevideowidget.h" |
35 | #include "frame.h" | 35 | #include "frame.h" |
36 | #include "lib.h" | 36 | #include "lib.h" |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <opie2/odebug.h> | 39 | #include <opie2/odebug.h> |
40 | using namespace Opie::Core; | 40 | using namespace Opie::Core; |
41 | 41 | ||
42 | /* QT */ | 42 | /* QT */ |
43 | #include <qtextstream.h> | 43 | #include <qtextstream.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <qgfx_qws.h> | 45 | #include <qgfx_qws.h> |
46 | 46 | ||
47 | /* STD */ | 47 | /* STD */ |
48 | #include <assert.h> | 48 | #include <assert.h> |
49 | #include <unistd.h> | ||
49 | 50 | ||
50 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 51 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
51 | int width, int height,int bytes ); | 52 | int width, int height,int bytes ); |
52 | 53 | ||
53 | extern "C" { | 54 | extern "C" { |
54 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); | 55 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); |
55 | int null_is_showing_video( const xine_vo_driver_t* self ); | 56 | int null_is_showing_video( const xine_vo_driver_t* self ); |
56 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 57 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
57 | int null_is_fullscreen( const xine_vo_driver_t* self ); | 58 | int null_is_fullscreen( const xine_vo_driver_t* self ); |
58 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); | 59 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); |
59 | int null_is_scaling( const xine_vo_driver_t* self ); | 60 | int null_is_scaling( const xine_vo_driver_t* self ); |
60 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); | 61 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); |
61 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); | 62 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); |
62 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | 63 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
63 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 64 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
64 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | 65 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
65 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 66 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
66 | 67 | ||
67 | void null_preload_decoders( xine_stream_t *stream ); | 68 | void null_preload_decoders( xine_stream_t *stream ); |
68 | } | 69 | } |
69 | 70 | ||
70 | using namespace XINE; | 71 | using namespace XINE; |
71 | 72 | ||
72 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) | 73 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) |
@@ -87,87 +88,87 @@ Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) | |||
87 | ts << "misc.memcpy_method:glibc\n"; | 88 | ts << "misc.memcpy_method:glibc\n"; |
88 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; | 89 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; |
89 | ts << "codec.ffmpeg_pp_quality:3\n"; | 90 | ts << "codec.ffmpeg_pp_quality:3\n"; |
90 | ts << "audio.num_buffers:50\n"; | 91 | ts << "audio.num_buffers:50\n"; |
91 | ts << "audio.size_buffers:4096\n"; | 92 | ts << "audio.size_buffers:4096\n"; |
92 | ts << "video.num_buffers:20\n"; | 93 | ts << "video.num_buffers:20\n"; |
93 | ts << "video.size_buffers:4096\n"; | 94 | ts << "video.size_buffers:4096\n"; |
94 | ts << "audio.out_num_audio_buf:16\n"; | 95 | ts << "audio.out_num_audio_buf:16\n"; |
95 | ts << "audio.out_size_audio_buf:8096\n"; | 96 | ts << "audio.out_size_audio_buf:8096\n"; |
96 | ts << "audio.out_size_zero_buf:1024\n"; | 97 | ts << "audio.out_size_zero_buf:1024\n"; |
97 | ts << "audio.passthrough_offset:0\n"; | 98 | ts << "audio.passthrough_offset:0\n"; |
98 | f.close(); | 99 | f.close(); |
99 | } | 100 | } |
100 | 101 | ||
101 | if ( initMode == InitializeImmediately ) { | 102 | if ( initMode == InitializeImmediately ) { |
102 | initialize(); | 103 | initialize(); |
103 | m_initialized = true; | 104 | m_initialized = true; |
104 | } | 105 | } |
105 | else | 106 | else |
106 | start(); | 107 | start(); |
107 | } | 108 | } |
108 | 109 | ||
109 | void Lib::run() | 110 | void Lib::run() |
110 | { | 111 | { |
111 | odebug << "Lib::run() started" << oendl; | 112 | odebug << "Lib::run() started" << oendl; |
112 | initialize(); | 113 | initialize(); |
113 | m_initialized = true; | 114 | m_initialized = true; |
114 | odebug << "Lib::run() finished" << oendl; | 115 | odebug << "Lib::run() finished" << oendl; |
115 | } | 116 | } |
116 | 117 | ||
117 | void Lib::initialize() | 118 | void Lib::initialize() |
118 | { | 119 | { |
119 | m_duringInitialization = true; | 120 | m_duringInitialization = true; |
120 | m_xine = xine_new( ); | 121 | m_xine = xine_new( ); |
121 | 122 | ||
122 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 123 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
123 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); | 124 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); |
124 | 125 | ||
125 | xine_init( m_xine ); | 126 | xine_init( m_xine ); |
126 | 127 | ||
127 | // allocate oss for sound | 128 | // allocate oss for sound |
128 | // and fb for framebuffer | 129 | // and fb for framebuffer |
129 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); | 130 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
130 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); | 131 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); |
131 | 132 | ||
132 | 133 | ||
133 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); | 134 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); |
134 | 135 | ||
135 | 136 | ||
136 | // null_display_handler( m_videoOutput, xine_display_frame, this ); | 137 | // null_display_handler( m_videoOutput, xine_display_frame, this ); |
137 | 138 | ||
138 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 139 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
139 | 140 | ||
140 | if (m_wid != 0 ) { | 141 | if (m_wid != 0 ) { |
141 | printf( "!0\n" ); | 142 | printf( "!0\n" ); |
142 | setWidget( m_wid ); | 143 | setWidget( m_wid ); |
143 | } | 144 | } |
144 | 145 | ||
145 | m_queue = xine_event_new_queue (m_stream); | 146 | m_queue = xine_event_new_queue (m_stream); |
146 | 147 | ||
147 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 148 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
148 | 149 | ||
149 | ::null_preload_decoders( m_stream ); | 150 | ::null_preload_decoders( m_stream ); |
150 | 151 | ||
151 | m_duringInitialization = false; | 152 | m_duringInitialization = false; |
152 | } | 153 | } |
153 | 154 | ||
154 | Lib::~Lib() { | 155 | Lib::~Lib() { |
155 | assert( isRunning() == false ); | 156 | assert( isRunning() == false ); |
156 | assert( m_initialized ); | 157 | assert( m_initialized ); |
157 | 158 | ||
158 | // free( m_config ); | 159 | // free( m_config ); |
159 | 160 | ||
160 | xine_close( m_stream ); | 161 | xine_close( m_stream ); |
161 | 162 | ||
162 | xine_event_dispose_queue( m_queue ); | 163 | xine_event_dispose_queue( m_queue ); |
163 | 164 | ||
164 | xine_dispose( m_stream ); | 165 | xine_dispose( m_stream ); |
165 | 166 | ||
166 | xine_exit( m_xine ); | 167 | xine_exit( m_xine ); |
167 | /* FIXME either free or delete but valgrind bitches against both */ | 168 | /* FIXME either free or delete but valgrind bitches against both */ |
168 | //free( m_videoOutput ); | 169 | //free( m_videoOutput ); |
169 | //delete m_audioOutput; | 170 | //delete m_audioOutput; |
170 | } | 171 | } |
171 | 172 | ||
172 | void Lib::resize ( const QSize &s ) { | 173 | void Lib::resize ( const QSize &s ) { |
173 | assert( m_initialized || m_duringInitialization ); | 174 | assert( m_initialized || m_duringInitialization ); |
@@ -196,49 +197,49 @@ int Lib::subVersion() { | |||
196 | return sub; | 197 | return sub; |
197 | } | 198 | } |
198 | 199 | ||
199 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 200 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
200 | assert( m_initialized ); | 201 | assert( m_initialized ); |
201 | // FIXME actually a hack imho. Should not be needed to dispose the whole stream | 202 | // FIXME actually a hack imho. Should not be needed to dispose the whole stream |
202 | // but without we get wrong media length reads from libxine for the second media | 203 | // but without we get wrong media length reads from libxine for the second media |
203 | //xine_dispose ( m_stream ); | 204 | //xine_dispose ( m_stream ); |
204 | 205 | ||
205 | QString str = fileName.stripWhiteSpace(); | 206 | QString str = fileName.stripWhiteSpace(); |
206 | 207 | ||
207 | //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 208 | //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
208 | //m_queue = xine_event_new_queue (m_stream); | 209 | //m_queue = xine_event_new_queue (m_stream); |
209 | //xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 210 | //xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
210 | 211 | ||
211 | if ( !xine_open( m_stream, str.utf8().data() ) ) { | 212 | if ( !xine_open( m_stream, str.utf8().data() ) ) { |
212 | return 0; | 213 | return 0; |
213 | } | 214 | } |
214 | return xine_play( m_stream, startPos, start_time); | 215 | return xine_play( m_stream, startPos, start_time); |
215 | } | 216 | } |
216 | 217 | ||
217 | void Lib::stop() { | 218 | void Lib::stop() { |
218 | assert( m_initialized ); | 219 | assert( m_initialized ); |
219 | 220 | ||
220 | odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl; | 221 | odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl; |
221 | xine_stop( m_stream ); | 222 | xine_stop( m_stream ); |
222 | } | 223 | } |
223 | 224 | ||
224 | void Lib::pause( bool toggle ) { | 225 | void Lib::pause( bool toggle ) { |
225 | assert( m_initialized ); | 226 | assert( m_initialized ); |
226 | 227 | ||
227 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); | 228 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); |
228 | } | 229 | } |
229 | 230 | ||
230 | int Lib::speed() const { | 231 | int Lib::speed() const { |
231 | assert( m_initialized ); | 232 | assert( m_initialized ); |
232 | 233 | ||
233 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 234 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
234 | } | 235 | } |
235 | 236 | ||
236 | void Lib::setSpeed( int speed ) { | 237 | void Lib::setSpeed( int speed ) { |
237 | assert( m_initialized ); | 238 | assert( m_initialized ); |
238 | 239 | ||
239 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 240 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
240 | } | 241 | } |
241 | 242 | ||
242 | int Lib::status() const { | 243 | int Lib::status() const { |
243 | assert( m_initialized ); | 244 | assert( m_initialized ); |
244 | 245 | ||
@@ -308,51 +309,51 @@ void Lib::seekTo( int time ) { | |||
308 | Frame Lib::currentFrame() const { | 309 | Frame Lib::currentFrame() const { |
309 | assert( m_initialized ); | 310 | assert( m_initialized ); |
310 | 311 | ||
311 | Frame frame; | 312 | Frame frame; |
312 | return frame; | 313 | return frame; |
313 | }; | 314 | }; |
314 | 315 | ||
315 | QString Lib::metaInfo( int number) const { | 316 | QString Lib::metaInfo( int number) const { |
316 | assert( m_initialized ); | 317 | assert( m_initialized ); |
317 | 318 | ||
318 | return xine_get_meta_info( m_stream, number ); | 319 | return xine_get_meta_info( m_stream, number ); |
319 | } | 320 | } |
320 | 321 | ||
321 | int Lib::error() const { | 322 | int Lib::error() const { |
322 | assert( m_initialized ); | 323 | assert( m_initialized ); |
323 | 324 | ||
324 | return xine_get_error( m_stream ); | 325 | return xine_get_error( m_stream ); |
325 | }; | 326 | }; |
326 | 327 | ||
327 | void Lib::ensureInitialized() | 328 | void Lib::ensureInitialized() |
328 | { | 329 | { |
329 | if ( m_initialized ) | 330 | if ( m_initialized ) |
330 | return; | 331 | return; |
331 | 332 | ||
332 | odebug << "waiting for initialization thread to finish" << oendl; | 333 | odebug << "waiting for initialization thread to finish" << oendl; |
333 | wait(); | 334 | wait(); |
334 | odebug << "initialization thread finished!" << oendl; | 335 | odebug << "initialization thread finished!" << oendl; |
335 | } | 336 | } |
336 | 337 | ||
337 | void Lib::setWidget( XineVideoWidget *widget ) | 338 | void Lib::setWidget( XineVideoWidget *widget ) |
338 | { | 339 | { |
339 | m_wid = widget; | 340 | m_wid = widget; |
340 | resize ( m_wid-> size ( ) ); | 341 | resize ( m_wid-> size ( ) ); |
341 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 342 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
342 | m_wid->repaint(); | 343 | m_wid->repaint(); |
343 | } | 344 | } |
344 | 345 | ||
345 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 346 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
346 | { | 347 | { |
347 | assert( sendType == ThreadUtil::Channel::OneWay ); | 348 | assert( sendType == ThreadUtil::Channel::OneWay ); |
348 | handleXineEvent( msg->type() ); | 349 | handleXineEvent( msg->type() ); |
349 | delete msg; | 350 | delete msg; |
350 | } | 351 | } |
351 | 352 | ||
352 | void Lib::handleXineEvent( const xine_event_t* t ) { | 353 | void Lib::handleXineEvent( const xine_event_t* t ) { |
353 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); | 354 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); |
354 | } | 355 | } |
355 | 356 | ||
356 | void Lib::handleXineEvent( int type ) { | 357 | void Lib::handleXineEvent( int type ) { |
357 | assert( m_initialized ); | 358 | assert( m_initialized ); |
358 | 359 | ||
@@ -403,32 +404,32 @@ void Lib::setGamma( int value ) { | |||
403 | assert( m_initialized ); | 404 | assert( m_initialized ); |
404 | 405 | ||
405 | ::null_set_videoGamma( m_videoOutput, value ); | 406 | ::null_set_videoGamma( m_videoOutput, value ); |
406 | } | 407 | } |
407 | 408 | ||
408 | bool Lib::isScaling() const { | 409 | bool Lib::isScaling() const { |
409 | assert( m_initialized ); | 410 | assert( m_initialized ); |
410 | 411 | ||
411 | return ::null_is_scaling( m_videoOutput ); | 412 | return ::null_is_scaling( m_videoOutput ); |
412 | } | 413 | } |
413 | 414 | ||
414 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 415 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
415 | ( (Lib*)user_data)->handleXineEvent( t ); | 416 | ( (Lib*)user_data)->handleXineEvent( t ); |
416 | } | 417 | } |
417 | 418 | ||
418 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 419 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
419 | int width, int height, int bytes ) { | 420 | int width, int height, int bytes ) { |
420 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 421 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
421 | } | 422 | } |
422 | 423 | ||
423 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 424 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
424 | assert( m_initialized ); | 425 | assert( m_initialized ); |
425 | 426 | ||
426 | if ( !m_video ) { | 427 | if ( !m_video ) { |
427 | owarn << "not showing video now" << oendl; | 428 | owarn << "not showing video now" << oendl; |
428 | return; | 429 | return; |
429 | } | 430 | } |
430 | 431 | ||
431 | assert( m_wid ); | 432 | assert( m_wid ); |
432 | 433 | ||
433 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 434 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
434 | } | 435 | } |