-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 34 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 4 |
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 | |||
@@ -281,38 +281,66 @@ int Lib::length() const { | |||
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 |
291 | 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 |
292 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ | 292 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ |
293 | 293 | ||
294 | return -1; | 294 | return -1; |
295 | } | 295 | } |
296 | 296 | ||
297 | /* info about current stream */ | ||
298 | QSize 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 | |||
297 | bool Lib::isSeekable() const { | 307 | bool 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 | ||
313 | bool Lib::hasVideo() const { | ||
314 | assert( m_initialized ); | ||
315 | |||
316 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_HAS_VIDEO); | ||
317 | } | ||
318 | |||
319 | int Lib::audioBitrate()const | ||
320 | { | ||
321 | if (!m_initialized) return 0; | ||
322 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_AUDIO_BITRATE); | ||
323 | } | ||
324 | int 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 | |||
303 | void Lib::seekTo( int time ) { | 331 | void 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 | ||
@@ -378,38 +406,32 @@ void Lib::handleXineEvent( int type, int data, const char* name ) { | |||
378 | } | 406 | } |
379 | 407 | ||
380 | 408 | ||
381 | void Lib::setShowVideo( bool video ) { | 409 | void 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 | ||
388 | bool Lib::isShowingVideo() const { | 416 | bool 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 | ||
394 | bool Lib::hasVideo() const { | ||
395 | assert( m_initialized ); | ||
396 | |||
397 | return xine_get_stream_info( m_stream, 18 ); | ||
398 | } | ||
399 | |||
400 | void Lib::showVideoFullScreen( bool fullScreen ) { | 422 | void 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 | ||
406 | bool Lib::isVideoFullScreen() const { | 428 | bool 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 | ||
412 | void Lib::setScaling( bool scale ) { | 434 | void 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 ); |
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 | |||
@@ -158,32 +158,36 @@ namespace XINE { | |||
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; |