Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 90 |
1 files changed, 51 insertions, 39 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index e3289bc..9f7a9c5 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,30 +1,30 @@ | |||
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. |
@@ -48,7 +48,7 @@ | |||
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 50 | typedef 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 | ||
53 | extern "C" { | 53 | extern "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 * ); |
@@ -189,6 +189,17 @@ int Lib::subVersion() { | |||
189 | return sub; | 189 | return sub; |
190 | } | 190 | } |
191 | 191 | ||
192 | int Lib::setfile(const QString& fileName) | ||
193 | { | ||
194 | QString str = fileName.stripWhiteSpace(); | ||
195 | |||
196 | |||
197 | if ( !xine_open( m_stream, str.utf8().data() ) ) { | ||
198 | return 0; | ||
199 | } | ||
200 | return 1; | ||
201 | } | ||
202 | |||
192 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 203 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
193 | assert( m_initialized ); | 204 | assert( m_initialized ); |
194 | 205 | ||
@@ -214,7 +225,7 @@ void Lib::pause( bool toggle ) { | |||
214 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 225 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); |
215 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); | 226 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); |
216 | } | 227 | } |
217 | 228 | ||
218 | else { | 229 | else { |
219 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL ); | 230 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL ); |
220 | } | 231 | } |
@@ -266,16 +277,16 @@ int Lib::length() const { | |||
266 | int iRetVal=0, iTestLoop=0; | 277 | int iRetVal=0, iTestLoop=0; |
267 | 278 | ||
268 | do | 279 | do |
269 | { | 280 | { |
270 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); | 281 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); |
271 | if (iRetVal) | 282 | if (iRetVal) |
272 | {/* 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.*/ |
273 | return length/1000; | 284 | return length/1000; |
274 | } | 285 | } |
275 | /*don't poll too much*/ | 286 | /*don't poll too much*/ |
276 | usleep(100000); | 287 | usleep(100000); |
277 | iTestLoop++; | 288 | iTestLoop++; |
278 | } | 289 | } |
279 | 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 |
280 | valid stream, then return -1 (this value could be used to make the stream | 291 | valid stream, then return -1 (this value could be used to make the stream |
281 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ | 292 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ |
@@ -302,7 +313,7 @@ void Lib::seekTo( int time ) { | |||
302 | xine_play( m_stream, 0, time*1000 ); | 313 | xine_play( m_stream, 0, time*1000 ); |
303 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 314 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); |
304 | } | 315 | } |
305 | 316 | ||
306 | } | 317 | } |
307 | 318 | ||
308 | 319 | ||
@@ -331,9 +342,10 @@ void Lib::ensureInitialized() | |||
331 | void Lib::setWidget( XineVideoWidget *widget ) | 342 | void Lib::setWidget( XineVideoWidget *widget ) |
332 | { | 343 | { |
333 | m_wid = widget; | 344 | m_wid = widget; |
334 | resize ( m_wid-> size ( ) ); | 345 | if (m_wid) { |
335 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 346 | resize ( m_wid-> size ( ) ); |
336 | m_wid->repaint(); | 347 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
348 | } | ||
337 | } | 349 | } |
338 | 350 | ||
339 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 351 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
@@ -431,7 +443,7 @@ void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | |||
431 | return; | 443 | return; |
432 | } | 444 | } |
433 | 445 | ||
434 | assert( m_wid ); | 446 | // assert( m_wid ); |
435 | 447 | ||
436 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 448 | if (m_wid) m_wid-> setVideoFrame ( frame, width, height, bytes ); |
437 | } | 449 | } |