summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp34
-rw-r--r--noncore/multimedia/opieplayer2/lib.h4
2 files changed, 32 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 9f7a9c5..4ae8490 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,449 +1,471 @@
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 "xinevideowidget.h" 34#include "xinevideowidget.h"
35#include "lib.h" 35#include "lib.h"
36 36
37/* OPIE */ 37/* OPIE */
38#include <opie2/odebug.h> 38#include <opie2/odebug.h>
39#include <qpe/global.h> 39#include <qpe/global.h>
40 40
41/* QT */ 41/* QT */
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qdir.h> 43#include <qdir.h>
44#include <qgfx_qws.h> 44#include <qgfx_qws.h>
45 45
46/* STD */ 46/* STD */
47#include <assert.h> 47#include <assert.h>
48#include <unistd.h> 48#include <unistd.h>
49 49
50typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 50typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
51 int width, int height,int bytes ); 51 int width, int height,int bytes );
52 52
53extern "C" { 53extern "C" {
54 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); 54 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 ); 55 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 ); 56 void null_set_show_video( const xine_vo_driver_t* self, int show );
57 int null_is_fullscreen( const xine_vo_driver_t* self ); 57 int null_is_fullscreen( const xine_vo_driver_t* self );
58 void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); 58 void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
59 int null_is_scaling( const xine_vo_driver_t* self ); 59 int null_is_scaling( const xine_vo_driver_t* self );
60 void null_set_scaling( const xine_vo_driver_t* self, int scale ); 60 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 ); 61 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 ); 62 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 ); 63 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 ); 64 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 ); 65 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data );
66 66
67 void null_preload_decoders( xine_stream_t *stream ); 67 void null_preload_decoders( xine_stream_t *stream );
68} 68}
69 69
70using namespace XINE; 70using namespace XINE;
71 71
72Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) 72Lib::Lib( InitializationMode initMode, XineVideoWidget* widget )
73{ 73{
74 m_initialized = false; 74 m_initialized = false;
75 m_duringInitialization = false; 75 m_duringInitialization = 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 ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; 88 ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n";
89 ts << "codec.ffmpeg_pp_quality:3\n"; 89 ts << "codec.ffmpeg_pp_quality:3\n";
90 ts << "audio.num_buffers:50\n"; 90 ts << "audio.num_buffers:50\n";
91 ts << "audio.size_buffers:4096\n"; 91 ts << "audio.size_buffers:4096\n";
92 ts << "video.num_buffers:20\n"; 92 ts << "video.num_buffers:20\n";
93 ts << "video.size_buffers:4096\n"; 93 ts << "video.size_buffers:4096\n";
94 ts << "audio.out_num_audio_buf:16\n"; 94 ts << "audio.out_num_audio_buf:16\n";
95 ts << "audio.out_size_audio_buf:8096\n"; 95 ts << "audio.out_size_audio_buf:8096\n";
96 ts << "audio.out_size_zero_buf:1024\n"; 96 ts << "audio.out_size_zero_buf:1024\n";
97 ts << "audio.passthrough_offset:0\n"; 97 ts << "audio.passthrough_offset:0\n";
98 f.close(); 98 f.close();
99 } 99 }
100 100
101 if ( initMode == InitializeImmediately ) { 101 if ( initMode == InitializeImmediately ) {
102 initialize(); 102 initialize();
103 m_initialized = true; 103 m_initialized = true;
104 } 104 }
105 else 105 else
106 start(); 106 start();
107} 107}
108 108
109void Lib::run() 109void Lib::run()
110{ 110{
111 odebug << "Lib::run() started" << oendl; 111 odebug << "Lib::run() started" << oendl;
112 initialize(); 112 initialize();
113 m_initialized = true; 113 m_initialized = true;
114 odebug << "Lib::run() finished" << oendl; 114 odebug << "Lib::run() finished" << oendl;
115} 115}
116 116
117void Lib::initialize() 117void Lib::initialize()
118{ 118{
119 m_duringInitialization = true; 119 m_duringInitialization = true;
120 m_xine = xine_new( ); 120 m_xine = xine_new( );
121 121
122 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 122 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
123 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 123 xine_config_load( m_xine, QFile::encodeName( configPath ) );
124 124
125 xine_init( m_xine ); 125 xine_init( m_xine );
126 126
127 // allocate oss for sound 127 // allocate oss for sound
128 // and fb for framebuffer 128 // and fb for framebuffer
129 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 129 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
130 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 130 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
131 131
132 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 132 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
133 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); 133 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1);
134 134
135 if (m_wid != 0 ) 135 if (m_wid != 0 )
136 setWidget( m_wid ); 136 setWidget( m_wid );
137 137
138 138
139 m_queue = xine_event_new_queue (m_stream); 139 m_queue = xine_event_new_queue (m_stream);
140 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 140 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
141 141
142 ::null_preload_decoders( m_stream ); 142 ::null_preload_decoders( m_stream );
143 143
144 m_duringInitialization = false; 144 m_duringInitialization = false;
145} 145}
146 146
147Lib::~Lib() { 147Lib::~Lib() {
148 assert( isRunning() == false ); 148 assert( isRunning() == false );
149 assert( m_initialized ); 149 assert( m_initialized );
150 150
151// free( m_config ); 151// free( m_config );
152 152
153 xine_close( m_stream ); 153 xine_close( m_stream );
154 xine_event_dispose_queue( m_queue ); 154 xine_event_dispose_queue( m_queue );
155 xine_dispose( m_stream ); 155 xine_dispose( m_stream );
156 xine_close_audio_driver(m_xine,m_audioOutput); 156 xine_close_audio_driver(m_xine,m_audioOutput);
157 xine_close_video_driver(m_xine,m_videoOutput); 157 xine_close_video_driver(m_xine,m_videoOutput);
158 xine_exit( m_xine ); 158 xine_exit( m_xine );
159 159
160 /* FIXME either free or delete but valgrind bitches against both */ 160 /* FIXME either free or delete but valgrind bitches against both */
161 //free( m_videoOutput ); 161 //free( m_videoOutput );
162 //delete m_audioOutput; 162 //delete m_audioOutput;
163} 163}
164 164
165void Lib::resize ( const QSize &s ) { 165void Lib::resize ( const QSize &s ) {
166 assert( m_initialized || m_duringInitialization ); 166 assert( m_initialized || m_duringInitialization );
167 167
168 if ( s. width ( ) && s. height ( ) ) { 168 if ( s. width ( ) && s. height ( ) ) {
169 ::null_set_gui_width( m_videoOutput, s. width() ); 169 ::null_set_gui_width( m_videoOutput, s. width() );
170 ::null_set_gui_height( m_videoOutput, s. height() ); 170 ::null_set_gui_height( m_videoOutput, s. height() );
171 } 171 }
172} 172}
173 173
174int Lib::majorVersion() { 174int Lib::majorVersion() {
175 int major, minor, sub; 175 int major, minor, sub;
176 xine_get_version ( &major, &minor, &sub ); 176 xine_get_version ( &major, &minor, &sub );
177 return major; 177 return major;
178} 178}
179 179
180int Lib::minorVersion() { 180int Lib::minorVersion() {
181 int major, minor, sub; 181 int major, minor, sub;
182 xine_get_version ( &major, &minor, &sub ); 182 xine_get_version ( &major, &minor, &sub );
183 return minor; 183 return minor;
184} 184}
185 185
186int Lib::subVersion() { 186int Lib::subVersion() {
187 int major, minor, sub; 187 int major, minor, sub;
188 xine_get_version ( &major, &minor, &sub ); 188 xine_get_version ( &major, &minor, &sub );
189 return sub; 189 return sub;
190} 190}
191 191
192int Lib::setfile(const QString& fileName) 192int Lib::setfile(const QString& fileName)
193{ 193{
194 QString str = fileName.stripWhiteSpace(); 194 QString str = fileName.stripWhiteSpace();
195 195
196 196
197 if ( !xine_open( m_stream, str.utf8().data() ) ) { 197 if ( !xine_open( m_stream, str.utf8().data() ) ) {
198 return 0; 198 return 0;
199 } 199 }
200 return 1; 200 return 1;
201} 201}
202 202
203int Lib::play( const QString& fileName, int startPos, int start_time ) { 203int Lib::play( const QString& fileName, int startPos, int start_time ) {
204 assert( m_initialized ); 204 assert( m_initialized );
205 205
206 QString str = fileName.stripWhiteSpace(); 206 QString str = fileName.stripWhiteSpace();
207 207
208 208
209 if ( !xine_open( m_stream, str.utf8().data() ) ) { 209 if ( !xine_open( m_stream, str.utf8().data() ) ) {
210 return 0; 210 return 0;
211 } 211 }
212 return xine_play( m_stream, startPos, start_time); 212 return xine_play( m_stream, startPos, start_time);
213} 213}
214 214
215void Lib::stop() { 215void Lib::stop() {
216 assert( m_initialized ); 216 assert( m_initialized );
217 xine_stop( m_stream ); 217 xine_stop( m_stream );
218 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); 218 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1);
219} 219}
220 220
221void Lib::pause( bool toggle ) { 221void Lib::pause( bool toggle ) {
222 assert( m_initialized ); 222 assert( m_initialized );
223 223
224 if ( toggle ) { 224 if ( toggle ) {
225 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); 225 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
226 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); 226 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1);
227 } 227 }
228 228
229 else { 229 else {
230 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL ); 230 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL );
231 } 231 }
232} 232}
233 233
234int Lib::speed() const { 234int Lib::speed() const {
235 assert( m_initialized ); 235 assert( m_initialized );
236 236
237 return xine_get_param ( m_stream, XINE_PARAM_SPEED ); 237 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
238} 238}
239 239
240void Lib::setSpeed( int speed ) { 240void Lib::setSpeed( int speed ) {
241 assert( m_initialized ); 241 assert( m_initialized );
242 242
243 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); 243 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
244} 244}
245 245
246int Lib::status() const { 246int Lib::status() const {
247 assert( m_initialized ); 247 assert( m_initialized );
248 248
249 return xine_get_status( m_stream ); 249 return xine_get_status( m_stream );
250} 250}
251 251
252int Lib::currentPosition() const { 252int Lib::currentPosition() const {
253 assert( m_initialized ); 253 assert( m_initialized );
254 254
255 int pos, time, length; 255 int pos, time, length;
256 xine_get_pos_length( m_stream, &pos, &time, &length ); 256 xine_get_pos_length( m_stream, &pos, &time, &length );
257 return pos; 257 return pos;
258} 258}
259 259
260int Lib::currentTime() const { 260int Lib::currentTime() const {
261 assert( m_initialized ); 261 assert( m_initialized );
262 262
263 int pos, time, length; 263 int pos, time, length;
264 pos = time = length = 0; 264 pos = time = length = 0;
265 265
266 if ( xine_get_pos_length( m_stream, &pos, &time, &length ) ) 266 if ( xine_get_pos_length( m_stream, &pos, &time, &length ) )
267 return time/1000; 267 return time/1000;
268 else 268 else
269 return 0; 269 return 0;
270} 270}
271 271
272int Lib::length() const { 272int Lib::length() const {
273 assert( m_initialized ); 273 assert( m_initialized );
274 274
275 int pos, time, length; 275 int pos, time, length;
276/* dilb: patch to solve the wrong stream length reported to the GUI*/ 276/* dilb: patch to solve the wrong stream length reported to the GUI*/
277 int iRetVal=0, iTestLoop=0; 277 int iRetVal=0, iTestLoop=0;
278 278
279 do 279 do
280 { 280 {
281 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); 281 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length );
282 if (iRetVal) 282 if (iRetVal)
283 {/* if the function didn't return 0, then pos, time and length are valid.*/ 283 {/* if the function didn't return 0, then pos, time and length are valid.*/
284 return length/1000; 284 return length/1000;
285 } 285 }
286 /*don't poll too much*/ 286 /*don't poll too much*/
287 usleep(100000); 287 usleep(100000);
288 iTestLoop++; 288 iTestLoop++;
289 } 289 }
290 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any 290 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any
291valid stream, then return -1 (this value could be used to make the stream 291valid stream, then return -1 (this value could be used to make the stream
292unseekable, but it should never occur!! Mr. Murphy ? :) ) */ 292unseekable, but it should never occur!! Mr. Murphy ? :) ) */
293 293
294 return -1; 294 return -1;
295} 295}
296 296
297/* info about current stream */
298QSize Lib::videoSize()const
299{
300 if (!m_initialized||!hasVideo()) return QSize(0,0);
301 int width = xine_get_stream_info(m_stream,XINE_STREAM_INFO_VIDEO_WIDTH);
302 int height = xine_get_stream_info(m_stream,XINE_STREAM_INFO_VIDEO_HEIGHT);
303 return QSize(width,height);
304}
305
306
297bool Lib::isSeekable() const { 307bool Lib::isSeekable() const {
298 assert( m_initialized ); 308 assert( m_initialized );
299 309
300 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 310 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
301} 311}
302 312
313bool Lib::hasVideo() const {
314 assert( m_initialized );
315
316 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_HAS_VIDEO);
317}
318
319int Lib::audioBitrate()const
320{
321 if (!m_initialized) return 0;
322 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_AUDIO_BITRATE);
323}
324int Lib::videoBitrate()const
325{
326 if (!m_initialized||!hasVideo()) return 0;
327 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_VIDEO_BITRATE);
328}
329/* end info block */
330
303void Lib::seekTo( int time ) { 331void Lib::seekTo( int time ) {
304 assert( m_initialized ); 332 assert( m_initialized );
305 333
306 odebug << "Seeking to second " << time << oendl; 334 odebug << "Seeking to second " << time << oendl;
307 //Keep it paused if it was in that state 335 //Keep it paused if it was in that state
308 if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) { 336 if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) {
309 xine_play( m_stream, 0, time*1000 ); 337 xine_play( m_stream, 0, time*1000 );
310 } 338 }
311 339
312 else { 340 else {
313 xine_play( m_stream, 0, time*1000 ); 341 xine_play( m_stream, 0, time*1000 );
314 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); 342 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
315 } 343 }
316 344
317} 345}
318 346
319 347
320QString Lib::metaInfo( int number) const { 348QString Lib::metaInfo( int number) const {
321 assert( m_initialized ); 349 assert( m_initialized );
322 350
323 return xine_get_meta_info( m_stream, number ); 351 return xine_get_meta_info( m_stream, number );
324} 352}
325 353
326int Lib::error() const { 354int Lib::error() const {
327 assert( m_initialized ); 355 assert( m_initialized );
328 356
329 return xine_get_error( m_stream ); 357 return xine_get_error( m_stream );
330}; 358};
331 359
332void Lib::ensureInitialized() 360void Lib::ensureInitialized()
333{ 361{
334 if ( m_initialized ) 362 if ( m_initialized )
335 return; 363 return;
336 364
337 odebug << "waiting for initialization thread to finish" << oendl; 365 odebug << "waiting for initialization thread to finish" << oendl;
338 wait(); 366 wait();
339 odebug << "initialization thread finished!" << oendl; 367 odebug << "initialization thread finished!" << oendl;
340} 368}
341 369
342void Lib::setWidget( XineVideoWidget *widget ) 370void Lib::setWidget( XineVideoWidget *widget )
343{ 371{
344 m_wid = widget; 372 m_wid = widget;
345 if (m_wid) { 373 if (m_wid) {
346 resize ( m_wid-> size ( ) ); 374 resize ( m_wid-> size ( ) );
347 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 375 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
348 } 376 }
349} 377}
350 378
351void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) 379void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
352{ 380{
353 assert( sendType == ThreadUtil::Channel::OneWay ); 381 assert( sendType == ThreadUtil::Channel::OneWay );
354 handleXineEvent( msg->type(), msg->data(), msg->msg() ); 382 handleXineEvent( msg->type(), msg->data(), msg->msg() );
355 delete msg; 383 delete msg;
356} 384}
357 385
358void Lib::handleXineEvent( const xine_event_t* t ) { 386void Lib::handleXineEvent( const xine_event_t* t ) {
359 int prog = -1; const char* name = 0; 387 int prog = -1; const char* name = 0;
360 if ( t->type == XINE_EVENT_PROGRESS ) { 388 if ( t->type == XINE_EVENT_PROGRESS ) {
361 xine_progress_data_t *pt = static_cast<xine_progress_data_t*>( t->data ); 389 xine_progress_data_t *pt = static_cast<xine_progress_data_t*>( t->data );
362 prog = pt->percent; 390 prog = pt->percent;
363 name = pt->description; 391 name = pt->description;
364 } 392 }
365 393
366 send( new ThreadUtil::ChannelMessage( t->type, prog, name ), OneWay ); 394 send( new ThreadUtil::ChannelMessage( t->type, prog, name ), OneWay );
367} 395}
368 396
369void Lib::handleXineEvent( int type, int data, const char* name ) { 397void Lib::handleXineEvent( int type, int data, const char* name ) {
370 assert( m_initialized ); 398 assert( m_initialized );
371 399
372 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { 400 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) {
373 emit stopped(); 401 emit stopped();
374 }else if ( type == XINE_EVENT_PROGRESS ) { 402 }else if ( type == XINE_EVENT_PROGRESS ) {
375 QString str = name == 0 ? QString::null : QString::fromUtf8( name ); 403 QString str = name == 0 ? QString::null : QString::fromUtf8( name );
376 Global::statusMessage( tr( "Progress: %1 %2" ).arg( name, data ) );; 404 Global::statusMessage( tr( "Progress: %1 %2" ).arg( name, data ) );;
377 } 405 }
378} 406}
379 407
380 408
381void Lib::setShowVideo( bool video ) { 409void Lib::setShowVideo( bool video ) {
382 assert( m_initialized ); 410 assert( m_initialized );
383 411
384 m_video = video; 412 m_video = video;
385 ::null_set_show_video( m_videoOutput, video ); 413 ::null_set_show_video( m_videoOutput, video );
386} 414}
387 415
388bool Lib::isShowingVideo() const { 416bool Lib::isShowingVideo() const {
389 assert( m_initialized ); 417 assert( m_initialized );
390 418
391 return ::null_is_showing_video( m_videoOutput ); 419 return ::null_is_showing_video( m_videoOutput );
392} 420}
393 421
394bool Lib::hasVideo() const {
395 assert( m_initialized );
396
397 return xine_get_stream_info( m_stream, 18 );
398}
399
400void Lib::showVideoFullScreen( bool fullScreen ) { 422void Lib::showVideoFullScreen( bool fullScreen ) {
401 assert( m_initialized ); 423 assert( m_initialized );
402 424
403 ::null_set_fullscreen( m_videoOutput, fullScreen ); 425 ::null_set_fullscreen( m_videoOutput, fullScreen );
404} 426}
405 427
406bool Lib::isVideoFullScreen() const { 428bool Lib::isVideoFullScreen() const {
407 assert( m_initialized ); 429 assert( m_initialized );
408 430
409 return ::null_is_fullscreen( m_videoOutput ); 431 return ::null_is_fullscreen( m_videoOutput );
410} 432}
411 433
412void Lib::setScaling( bool scale ) { 434void Lib::setScaling( bool scale ) {
413 assert( m_initialized ); 435 assert( m_initialized );
414 436
415 ::null_set_scaling( m_videoOutput, scale ); 437 ::null_set_scaling( m_videoOutput, scale );
416} 438}
417 439
418void Lib::setGamma( int value ) { 440void Lib::setGamma( int value ) {
419 assert( m_initialized ); 441 assert( m_initialized );
420 442
421 ::null_set_videoGamma( m_videoOutput, value ); 443 ::null_set_videoGamma( m_videoOutput, value );
422} 444}
423 445
424bool Lib::isScaling() const { 446bool Lib::isScaling() const {
425 assert( m_initialized ); 447 assert( m_initialized );
426 448
427 return ::null_is_scaling( m_videoOutput ); 449 return ::null_is_scaling( m_videoOutput );
428} 450}
429 451
430void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { 452void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) {
431 ( (Lib*)user_data)->handleXineEvent( t ); 453 ( (Lib*)user_data)->handleXineEvent( t );
432} 454}
433 455
434void Lib::xine_display_frame( void* user_data, uint8_t *frame, 456void Lib::xine_display_frame( void* user_data, uint8_t *frame,
435 int width, int height, int bytes ) { 457 int width, int height, int bytes ) {
436 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); 458 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
437} 459}
438 460
439void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 461void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
440 assert( m_initialized ); 462 assert( m_initialized );
441 463
442 if ( !m_video ) { 464 if ( !m_video ) {
443 return; 465 return;
444 } 466 }
445 467
446// assert( m_wid ); 468// assert( m_wid );
447 469
448 if (m_wid) m_wid-> setVideoFrame ( frame, width, height, bytes ); 470 if (m_wid) m_wid-> setVideoFrame ( frame, width, height, bytes );
449} 471}
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index 2f5bf86..2607193 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -1,211 +1,215 @@
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 XINE_VIDEO_LIB_H 34#ifndef XINE_VIDEO_LIB_H
35#define XINE_VIDEO_LIB_H 35#define XINE_VIDEO_LIB_H
36 36
37#include <xine.h> 37#include <xine.h>
38 38
39#include "threadutil.h" 39#include "threadutil.h"
40 40
41class XineVideoWidget; 41class XineVideoWidget;
42 42
43namespace XINE { 43namespace XINE {
44 44
45 /** 45 /**
46 * Lib wrapps the simple interface 46 * Lib wrapps the simple interface
47 * of libxine for easy every day use 47 * of libxine for easy every day use
48 * This will become a full C++ Wrapper 48 * This will become a full C++ Wrapper
49 * It supports playing, pausing, info, 49 * It supports playing, pausing, info,
50 * stooping, seeking. 50 * stooping, seeking.
51 */ 51 */
52 class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread 52 class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread
53 { 53 {
54 Q_OBJECT 54 Q_OBJECT
55 public: 55 public:
56 enum InitializationMode { InitializeImmediately, InitializeInThread }; 56 enum InitializationMode { InitializeImmediately, InitializeInThread };
57 57
58 Lib( InitializationMode initMode, XineVideoWidget* = 0); 58 Lib( InitializationMode initMode, XineVideoWidget* = 0);
59 59
60 ~Lib(); 60 ~Lib();
61 static int majorVersion(); 61 static int majorVersion();
62 static int minorVersion(); 62 static int minorVersion();
63 static int subVersion(); 63 static int subVersion();
64 64
65 65
66 void resize ( const QSize &s ); 66 void resize ( const QSize &s );
67 67
68 int setfile(const QString& fileName); 68 int setfile(const QString& fileName);
69 int play( const QString& fileName, 69 int play( const QString& fileName,
70 int startPos = 0, 70 int startPos = 0,
71 int start_time = 0 ); 71 int start_time = 0 );
72 void stop(); 72 void stop();
73 void pause( bool toggle ); 73 void pause( bool toggle );
74 74
75 int speed() const; 75 int speed() const;
76 76
77 /** 77 /**
78 * Set the speed of the stream, if codec supports it 78 * Set the speed of the stream, if codec supports it
79 * XINE_SPEED_PAUSE 0 79 * XINE_SPEED_PAUSE 0
80 * XINE_SPEED_SLOW_4 1 80 * XINE_SPEED_SLOW_4 1
81 * XINE_SPEED_SLOW_2 2 81 * XINE_SPEED_SLOW_2 2
82 * XINE_SPEED_NORMAL 4 82 * XINE_SPEED_NORMAL 4
83 * XINE_SPEED_FAST_2 8 83 * XINE_SPEED_FAST_2 8
84 *XINE_SPEED_FAST_4 16 84 *XINE_SPEED_FAST_4 16
85 */ 85 */
86 void setSpeed( int speed = XINE_SPEED_PAUSE ); 86 void setSpeed( int speed = XINE_SPEED_PAUSE );
87 87
88 int status() const; 88 int status() const;
89 89
90 int currentPosition()const; 90 int currentPosition()const;
91 //in seconds 91 //in seconds
92 int currentTime()const; 92 int currentTime()const;
93 93
94 int length() const; 94 int length() const;
95 95
96 bool isSeekable()const; 96 bool isSeekable()const;
97 97
98 /** 98 /**
99 * Whether or not to show video output 99 * Whether or not to show video output
100 */ 100 */
101 void setShowVideo(bool video); 101 void setShowVideo(bool video);
102 102
103 /** 103 /**
104 * is we show video 104 * is we show video
105 */ 105 */
106 bool isShowingVideo() const; 106 bool isShowingVideo() const;
107 107
108 /** 108 /**
109 * 109 *
110 */ 110 */
111 void showVideoFullScreen( bool fullScreen ); 111 void showVideoFullScreen( bool fullScreen );
112 112
113 /** 113 /**
114 * 114 *
115 */ 115 */
116 bool isVideoFullScreen() const; 116 bool isVideoFullScreen() const;
117 117
118 118
119 /** 119 /**
120 * Get the meta info (like author etc) from the stream 120 * Get the meta info (like author etc) from the stream
121 * XINE_META_INFO_TITLE 0 121 * XINE_META_INFO_TITLE 0
122 * XINE_META_INFO_COMMENT 1 122 * XINE_META_INFO_COMMENT 1
123 * XINE_META_INFO_ARTIST 2 123 * XINE_META_INFO_ARTIST 2
124 * XINE_META_INFO_GENRE 3 124 * XINE_META_INFO_GENRE 3
125 * XINE_META_INFO_ALBUM 4 125 * XINE_META_INFO_ALBUM 4
126 * XINE_META_INFO_YEAR 5 126 * XINE_META_INFO_YEAR 5
127 * XINE_META_INFO_VIDEOCODEC 6 127 * XINE_META_INFO_VIDEOCODEC 6
128 * XINE_META_INFO_AUDIOCODEC 7 128 * XINE_META_INFO_AUDIOCODEC 7
129 * XINE_META_INFO_SYSTEMLAYER 8 129 * XINE_META_INFO_SYSTEMLAYER 8
130 * XINE_META_INFO_INPUT_PLUGIN 9 130 * XINE_META_INFO_INPUT_PLUGIN 9
131 */ 131 */
132 QString metaInfo( int number ) const; 132 QString metaInfo( int number ) const;
133 133
134 /** 134 /**
135 * 135 *
136 */ 136 */
137 bool isScaling() const; 137 bool isScaling() const;
138 138
139 /** 139 /**
140 * seek to a position 140 * seek to a position
141 */ 141 */
142 void seekTo( int time ); 142 void seekTo( int time );
143 143
144 /** 144 /**
145 * 145 *
146 * @return is media stream has video 146 * @return is media stream has video
147 */ 147 */
148 bool hasVideo() const; 148 bool hasVideo() const;
149 149
150 /** 150 /**
151 * 151 *
152 */ 152 */
153 void setScaling( bool ); 153 void setScaling( bool );
154 154
155 /** 155 /**
156 * Set the Gamma value for video output 156 * Set the Gamma value for video output
157 * @param int the value between -100 and 100, 0 is original 157 * @param int the value between -100 and 100, 0 is original
158 */ 158 */
159 void setGamma( int ); 159 void setGamma( int );
160 160
161 /** 161 /**
162 * Returns the error code 162 * Returns the error code
163 * XINE_ERROR_NONE 0 163 * XINE_ERROR_NONE 0
164 * XINE_ERROR_NO_INPUT_PLUGIN 1 164 * XINE_ERROR_NO_INPUT_PLUGIN 1
165 * XINE_ERROR_NO_DEMUXER_PLUGIN 2 165 * XINE_ERROR_NO_DEMUXER_PLUGIN 2
166 * XINE_ERROR_DEMUXER_FAILED 3 166 * XINE_ERROR_DEMUXER_FAILED 3
167 */ 167 */
168 int error() const; 168 int error() const;
169 169
170 void ensureInitialized(); 170 void ensureInitialized();
171 171
172 void setWidget( XineVideoWidget *widget ); 172 void setWidget( XineVideoWidget *widget );
173 173
174 QSize videoSize()const;
175 int audioBitrate()const;
176 int videoBitrate()const;
177
174 signals: 178 signals:
175 179
176 void stopped(); 180 void stopped();
177 181
178 void initialized(); 182 void initialized();
179 183
180 protected: 184 protected:
181 virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); 185 virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType );
182 186
183 virtual void run(); 187 virtual void run();
184 188
185 private: 189 private:
186 void initialize(); 190 void initialize();
187 191
188 int m_bytes_per_pixel; 192 int m_bytes_per_pixel;
189 bool m_initialized:1; 193 bool m_initialized:1;
190 bool m_duringInitialization:1; 194 bool m_duringInitialization:1;
191 bool m_video:1; 195 bool m_video:1;
192 XineVideoWidget *m_wid; 196 XineVideoWidget *m_wid;
193 xine_t *m_xine; 197 xine_t *m_xine;
194 xine_stream_t *m_stream; 198 xine_stream_t *m_stream;
195 xine_cfg_entry_t *m_config; 199 xine_cfg_entry_t *m_config;
196 xine_vo_driver_t *m_videoOutput; 200 xine_vo_driver_t *m_videoOutput;
197 xine_ao_driver_t* m_audioOutput; 201 xine_ao_driver_t* m_audioOutput;
198 xine_event_queue_t *m_queue; 202 xine_event_queue_t *m_queue;
199 203
200 void handleXineEvent( const xine_event_t* t ); 204 void handleXineEvent( const xine_event_t* t );
201 void handleXineEvent( int type, int data, const char* name ); 205 void handleXineEvent( int type, int data, const char* name );
202 void drawFrame( uint8_t* frame, int width, int height, int bytes ); 206 void drawFrame( uint8_t* frame, int width, int height, int bytes );
203 // C -> C++ bridge for the event system 207 // C -> C++ bridge for the event system
204 static void xine_event_handler( void* user_data, const xine_event_t* t); 208 static void xine_event_handler( void* user_data, const xine_event_t* t);
205 static void xine_display_frame( void* user_data, uint8_t* frame , 209 static void xine_display_frame( void* user_data, uint8_t* frame ,
206 int width, int height, int bytes ); 210 int width, int height, int bytes );
207 }; 211 };
208}; 212};
209 213
210 214
211#endif 215#endif