summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/lib.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp90
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,63 +1,63 @@
/*
-                This file is part of the Opie Project
+ This file is part of the Opie Project
-              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
+ Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 LJP <>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
-           .>+-=
- _;:,     .>    :=|. This program is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This program is distributed in the hope that
-     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
-    : ..    .:,     . . . without even the implied warranty of
-    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
-  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.=       =       ; Library General Public License for more
-++=   -.     .`     .: details.
- :     =  ...= . :.=-
- -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
-    --        :-=` this library; see the file COPYING.LIB.
+ .>+-=
+_;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU General Public
+.="- .-=="i, .._ License as published by the Free Software
+- . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+: = ...= . :.=-
+-. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "xinevideowidget.h"
#include "lib.h"
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/global.h>
/* QT */
#include <qtextstream.h>
#include <qdir.h>
#include <qgfx_qws.h>
/* STD */
#include <assert.h>
#include <unistd.h>
typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
- int width, int height,int bytes );
+ int width, int height,int bytes );
extern "C" {
xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * );
int null_is_showing_video( const xine_vo_driver_t* self );
void null_set_show_video( const xine_vo_driver_t* self, int show );
int null_is_fullscreen( const xine_vo_driver_t* self );
void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
int null_is_scaling( const xine_vo_driver_t* self );
void null_set_scaling( const xine_vo_driver_t* self, int scale );
void null_set_gui_width( const xine_vo_driver_t* self, int width );
void null_set_gui_height( const xine_vo_driver_t* self, int height );
void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb );
@@ -180,24 +180,35 @@ int Lib::majorVersion() {
int Lib::minorVersion() {
int major, minor, sub;
xine_get_version ( &major, &minor, &sub );
return minor;
}
int Lib::subVersion() {
int major, minor, sub;
xine_get_version ( &major, &minor, &sub );
return sub;
}
+int Lib::setfile(const QString& fileName)
+{
+ QString str = fileName.stripWhiteSpace();
+
+
+ if ( !xine_open( m_stream, str.utf8().data() ) ) {
+ return 0;
+ }
+ return 1;
+}
+
int Lib::play( const QString& fileName, int startPos, int start_time ) {
assert( m_initialized );
QString str = fileName.stripWhiteSpace();
if ( !xine_open( m_stream, str.utf8().data() ) ) {
return 0;
}
return xine_play( m_stream, startPos, start_time);
}
@@ -205,25 +216,25 @@ void Lib::stop() {
assert( m_initialized );
xine_stop( m_stream );
xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1);
}
void Lib::pause( bool toggle ) {
assert( m_initialized );
if ( toggle ) {
xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1);
}
-
+
else {
xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL );
}
}
int Lib::speed() const {
assert( m_initialized );
return xine_get_param ( m_stream, XINE_PARAM_SPEED );
}
void Lib::setSpeed( int speed ) {
@@ -257,34 +268,34 @@ int Lib::currentTime() const {
else
return 0;
}
int Lib::length() const {
assert( m_initialized );
int pos, time, length;
/* dilb: patch to solve the wrong stream length reported to the GUI*/
int iRetVal=0, iTestLoop=0;
do
- {
- iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length );
- if (iRetVal)
- {/* if the function didn't return 0, then pos, time and length are valid.*/
- return length/1000;
- }
- /*don't poll too much*/
- usleep(100000);
- iTestLoop++;
- }
+ {
+ iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length );
+ if (iRetVal)
+ {/* if the function didn't return 0, then pos, time and length are valid.*/
+ return length/1000;
+ }
+ /*don't poll too much*/
+ usleep(100000);
+ iTestLoop++;
+ }
while ( iTestLoop < 10 ); /* if after 1s, we still don't have any
valid stream, then return -1 (this value could be used to make the stream
unseekable, but it should never occur!! Mr. Murphy ? :) ) */
return -1;
}
bool Lib::isSeekable() const {
assert( m_initialized );
return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
}
@@ -293,25 +304,25 @@ void Lib::seekTo( int time ) {
assert( m_initialized );
odebug << "Seeking to second " << time << oendl;
//Keep it paused if it was in that state
if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) {
xine_play( m_stream, 0, time*1000 );
}
else {
xine_play( m_stream, 0, time*1000 );
xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
}
-
+
}
QString Lib::metaInfo( int number) const {
assert( m_initialized );
return xine_get_meta_info( m_stream, number );
}
int Lib::error() const {
assert( m_initialized );
@@ -322,27 +333,28 @@ void Lib::ensureInitialized()
{
if ( m_initialized )
return;
odebug << "waiting for initialization thread to finish" << oendl;
wait();
odebug << "initialization thread finished!" << oendl;
}
void Lib::setWidget( XineVideoWidget *widget )
{
m_wid = widget;
- resize ( m_wid-> size ( ) );
- ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
- m_wid->repaint();
+ if (m_wid) {
+ resize ( m_wid-> size ( ) );
+ ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
+ }
}
void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
{
assert( sendType == ThreadUtil::Channel::OneWay );
handleXineEvent( msg->type(), msg->data(), msg->msg() );
delete msg;
}
void Lib::handleXineEvent( const xine_event_t* t ) {
int prog = -1; const char* name = 0;
if ( t->type == XINE_EVENT_PROGRESS ) {
@@ -422,16 +434,16 @@ void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) {
void Lib::xine_display_frame( void* user_data, uint8_t *frame,
int width, int height, int bytes ) {
( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
}
void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
assert( m_initialized );
if ( !m_video ) {
return;
}
- assert( m_wid );
+// assert( m_wid );
- m_wid-> setVideoFrame ( frame, width, height, bytes );
+ if (m_wid) m_wid-> setVideoFrame ( frame, width, height, bytes );
}