summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp44
-rw-r--r--noncore/multimedia/opieplayer2/lib.h33
2 files changed, 75 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 00c534a..3b20873 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,170 +1,212 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
1 33
2#include <stdio.h> 34#include <stdio.h>
3#include <stdlib.h> 35#include <stdlib.h>
4//#include <qpe/qpeapplication.h>
5#include <qimage.h> 36#include <qimage.h>
37#include <qtextstream.h>
6#include <qpe/resource.h> 38#include <qpe/resource.h>
7 39
8#include <qfile.h> 40#include <qfile.h>
9 41
10#include <qgfx_qws.h> 42#include <qgfx_qws.h>
11#include <qdirectpainter_qws.h> 43#include <qdirectpainter_qws.h>
12 44
13#include "xinevideowidget.h" 45#include "xinevideowidget.h"
14#include "frame.h" 46#include "frame.h"
15#include "lib.h" 47#include "lib.h"
16 48
17typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
18 int width, int height,int bytes ); 50 int width, int height,int bytes );
19 51
20extern "C" { 52extern "C" {
21 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); 53 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video);
22 int null_is_showing_video( vo_driver_t* self ); 54 int null_is_showing_video( vo_driver_t* self );
23 void null_set_show_video( vo_driver_t* self, int show ); 55 void null_set_show_video( vo_driver_t* self, int show );
24 int null_is_fullscreen( vo_driver_t* self ); 56 int null_is_fullscreen( vo_driver_t* self );
25 void null_set_fullscreen( vo_driver_t* self, int screen ); 57 void null_set_fullscreen( vo_driver_t* self, int screen );
26 int null_is_scaling( vo_driver_t* self ); 58 int null_is_scaling( vo_driver_t* self );
27 void null_set_scaling( vo_driver_t* self, int scale ); 59 void null_set_scaling( vo_driver_t* self, int scale );
28 void null_set_gui_width( vo_driver_t* self, int width ); 60 void null_set_gui_width( vo_driver_t* self, int width );
29 void null_set_gui_height( vo_driver_t* self, int height ); 61 void null_set_gui_height( vo_driver_t* self, int height );
30 void null_set_mode( vo_driver_t* self, int depth, int rgb ); 62 void null_set_mode( vo_driver_t* self, int depth, int rgb );
31 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); 63 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data);
32} 64}
33 65
34using namespace XINE; 66using namespace XINE;
35 67
36Lib::Lib(XineVideoWidget* widget) { 68Lib::Lib(XineVideoWidget* widget) {
37 m_video = false; 69 m_video = false;
38 m_wid = widget; 70 m_wid = widget;
39 printf("Lib"); 71 printf("Lib");
40 QCString str( getenv("HOME") ); 72 QCString str( getenv("HOME") );
41 str += "/Settings/opiexine.cf"; 73 str += "/Settings/opiexine.cf";
42 // get the configuration 74 // get the configuration
75
76 // not really OO, should be an extra class, later
77 if ( !QFile(str).exists() ) {
78 QFile f(str);
79 f.open(IO_WriteOnly);
80 QTextStream ts( &f );
81 ts << "misc.memcpy_method:glibc";
82 f.close();
83 }
84
43 m_config = xine_config_file_init( str.data() ); 85 m_config = xine_config_file_init( str.data() );
44 86
45 // allocate oss for sound 87 // allocate oss for sound
46 // and fb for framebuffer 88 // and fb for framebuffer
47 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; 89 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ;
48 if (m_audioOutput == NULL ) 90 if (m_audioOutput == NULL )
49 printf("Failure\n"); 91 printf("Failure\n");
50 else 92 else
51 printf("Success\n"); 93 printf("Success\n");
52 94
53 95
54 // test code 96 // test code
55/* m_videoOutput = xine_load_video_output_plugin(m_config, "fb", 97/* m_videoOutput = xine_load_video_output_plugin(m_config, "fb",
56 VISUAL_TYPE_FB, 98 VISUAL_TYPE_FB,
57 0 ); 99 0 );
58*/ 100*/
59 101
60 char** files = xine_list_video_output_plugins(3); 102 char** files = xine_list_video_output_plugins(3);
61 char* out; 103 char* out;
62 int i = 0; 104 int i = 0;
63 while ( ( out = files[i] ) != 0 ) { 105 while ( ( out = files[i] ) != 0 ) {
64 printf("Video %s\n", out ); 106 printf("Video %s\n", out );
65 i++; 107 i++;
66 } 108 }
67// m_xine = xine_init( m_videoOutput, 109// m_xine = xine_init( m_videoOutput,
68// m_audioOutput, 110// m_audioOutput,
69// m_config ); 111// m_config );
70 // test loading 112 // test loading
71 m_videoOutput = ::init_video_out_plugin( m_config, NULL ); 113 m_videoOutput = ::init_video_out_plugin( m_config, NULL );
72 if (m_wid != 0 ) { 114 if (m_wid != 0 ) {
73 printf("!0\n" ); 115 printf("!0\n" );
74 resize ( m_wid-> size ( )); 116 resize ( m_wid-> size ( ));
75 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 117 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
76 m_wid-> setImage ( new QImage ( Resource::loadImage(""))); 118 m_wid-> setImage ( new QImage ( Resource::loadImage("")));
77 m_wid->repaint(); 119 m_wid->repaint();
78 } 120 }
79 null_display_handler( m_videoOutput, 121 null_display_handler( m_videoOutput,
80 xine_display_frame, 122 xine_display_frame,
81 this ); 123 this );
82 124
83 m_xine = xine_init( m_videoOutput, 125 m_xine = xine_init( m_videoOutput,
84 m_audioOutput, m_config ); 126 m_audioOutput, m_config );
85 // install the event handler 127 // install the event handler
86 xine_register_event_listener( m_xine, xine_event_handler, this ); 128 xine_register_event_listener( m_xine, xine_event_handler, this );
87} 129}
88 130
89Lib::~Lib() { 131Lib::~Lib() {
90 delete m_config; 132 delete m_config;
91 xine_remove_event_listener( m_xine, xine_event_handler ); 133 xine_remove_event_listener( m_xine, xine_event_handler );
92 xine_exit( m_xine ); 134 xine_exit( m_xine );
93 delete m_videoOutput; 135 delete m_videoOutput;
94 //delete m_audioOutput; 136 //delete m_audioOutput;
95 137
96} 138}
97 139
98void Lib::resize ( const QSize &s ) 140void Lib::resize ( const QSize &s )
99{ 141{
100 if ( s. width ( ) && s. height ( )) { 142 if ( s. width ( ) && s. height ( )) {
101 ::null_set_gui_width( m_videoOutput, s. width() ); 143 ::null_set_gui_width( m_videoOutput, s. width() );
102 ::null_set_gui_height(m_videoOutput, s. height() ); 144 ::null_set_gui_height(m_videoOutput, s. height() );
103 } 145 }
104} 146}
105 147
106QCString Lib::version() { 148QCString Lib::version() {
107 QCString str( xine_get_str_version() ); 149 QCString str( xine_get_str_version() );
108 return str; 150 return str;
109}; 151};
110 152
111int Lib::majorVersion() { 153int Lib::majorVersion() {
112 return xine_get_major_version(); 154 return xine_get_major_version();
113} 155}
114int Lib::minorVersion() { 156int Lib::minorVersion() {
115 return xine_get_minor_version(); 157 return xine_get_minor_version();
116}; 158};
117 159
118int Lib::subVersion() { 160int Lib::subVersion() {
119 return xine_get_sub_version(); 161 return xine_get_sub_version();
120} 162}
121int Lib::play( const QString& fileName, 163int Lib::play( const QString& fileName,
122 int startPos, 164 int startPos,
123 int start_time ) { 165 int start_time ) {
124 QString str = fileName.stripWhiteSpace(); 166 QString str = fileName.stripWhiteSpace();
125 //workaround OpiePlayer bug 167 //workaround OpiePlayer bug
126 if (str.right(1) == QString::fromLatin1("/") ) 168 if (str.right(1) == QString::fromLatin1("/") )
127 str = str.mid( str.length() -1 ); 169 str = str.mid( str.length() -1 );
128 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), 170 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(),
129 startPos, start_time); 171 startPos, start_time);
130} 172}
131void Lib::stop() { 173void Lib::stop() {
132 xine_stop(m_xine ); 174 xine_stop(m_xine );
133} 175}
134void Lib::pause(){ 176void Lib::pause(){
135 xine_set_speed( m_xine, SPEED_PAUSE ); 177 xine_set_speed( m_xine, SPEED_PAUSE );
136} 178}
137int Lib::speed() { 179int Lib::speed() {
138 return xine_get_speed( m_xine ); 180 return xine_get_speed( m_xine );
139} 181}
140void Lib::setSpeed( int speed ) { 182void Lib::setSpeed( int speed ) {
141 xine_set_speed( m_xine, speed ); 183 xine_set_speed( m_xine, speed );
142} 184}
143int Lib::status(){ 185int Lib::status(){
144 return xine_get_status( m_xine ); 186 return xine_get_status( m_xine );
145} 187}
146int Lib::currentPosition(){ 188int Lib::currentPosition(){
147 return xine_get_current_position( m_xine ); 189 return xine_get_current_position( m_xine );
148} 190}
149int Lib::currentTime() { 191int Lib::currentTime() {
150 return xine_get_current_time( m_xine ); 192 return xine_get_current_time( m_xine );
151}; 193};
152int Lib::length() { 194int Lib::length() {
153 return xine_get_stream_length( m_xine ); 195 return xine_get_stream_length( m_xine );
154} 196}
155bool Lib::isSeekable() { 197bool Lib::isSeekable() {
156 return xine_is_stream_seekable(m_xine); 198 return xine_is_stream_seekable(m_xine);
157} 199}
158Frame Lib::currentFrame() { 200Frame Lib::currentFrame() {
159 Frame frame; 201 Frame frame;
160 return frame; 202 return frame;
161}; 203};
162int Lib::error() { 204int Lib::error() {
163 return xine_get_error( m_xine ); 205 return xine_get_error( m_xine );
164}; 206};
165void Lib::handleXineEvent( xine_event_t* t ) { 207void Lib::handleXineEvent( xine_event_t* t ) {
166 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) 208 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED )
167 emit stopped(); 209 emit stopped();
168} 210}
169void Lib::setShowVideo( bool video ) { 211void Lib::setShowVideo( bool video ) {
170 m_video = video; 212 m_video = video;
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index a15f362..abd8c65 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -1,115 +1,146 @@
1 1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
2 33
3#ifndef ZECKEXINELIB_H 34#ifndef ZECKEXINELIB_H
4#define ZECKEXINELIB_H 35#define ZECKEXINELIB_H
5 36
6#include <qcstring.h> 37#include <qcstring.h>
7#include <qstring.h> 38#include <qstring.h>
8#include <qobject.h> 39#include <qobject.h>
9 40
10#include <xine.h> 41#include <xine.h>
11 42
12class XineVideoWidget; 43class XineVideoWidget;
13 44
14namespace XINE { 45namespace XINE {
15 46
16 /** 47 /**
17 * Lib wrapps the simple interface 48 * Lib wrapps the simple interface
18 * of libxine for easy every day use 49 * of libxine for easy every day use
19 * This will become a full C++ Wrapper 50 * This will become a full C++ Wrapper
20 * It supports playing, pausing, info, 51 * It supports playing, pausing, info,
21 * stooping, seeking. 52 * stooping, seeking.
22 */ 53 */
23 class Frame; 54 class Frame;
24 class Lib : public QObject { 55 class Lib : public QObject {
25 Q_OBJECT 56 Q_OBJECT
26 public: 57 public:
27 Lib(XineVideoWidget* = 0); 58 Lib(XineVideoWidget* = 0);
28 ~Lib(); 59 ~Lib();
29 QCString version(); 60 QCString version();
30 int majorVersion()/*const*/; 61 int majorVersion()/*const*/;
31 int minorVersion()/*const*/; 62 int minorVersion()/*const*/;
32 int subVersion()/*const*/; 63 int subVersion()/*const*/;
33 64
34 65
35 void resize ( const QSize &s ); 66 void resize ( const QSize &s );
36 67
37 int play( const QString& fileName, 68 int play( const QString& fileName,
38 int startPos = 0, 69 int startPos = 0,
39 int start_time = 0 ); 70 int start_time = 0 );
40 void stop() /*const*/; 71 void stop() /*const*/;
41 void pause()/*const*/; 72 void pause()/*const*/;
42 73
43 int speed() /*const*/; 74 int speed() /*const*/;
44 void setSpeed( int speed = SPEED_PAUSE ); 75 void setSpeed( int speed = SPEED_PAUSE );
45 76
46 int status() /*const*/; 77 int status() /*const*/;
47 78
48 int currentPosition()/*const*/; 79 int currentPosition()/*const*/;
49 //in seconds 80 //in seconds
50 int currentTime()/*const*/; 81 int currentTime()/*const*/;
51 int length() /*const*/; 82 int length() /*const*/;
52 83
53 bool isSeekable()/*const*/; 84 bool isSeekable()/*const*/;
54 85
55 /** 86 /**
56 * Whether or not to show video output 87 * Whether or not to show video output
57 */ 88 */
58 void setShowVideo(bool video); 89 void setShowVideo(bool video);
59 90
60 /** 91 /**
61 * is we show video 92 * is we show video
62 */ 93 */
63 bool isShowingVideo() /*const*/; 94 bool isShowingVideo() /*const*/;
64 95
65 /** 96 /**
66 * 97 *
67 */ 98 */
68 void showVideoFullScreen( bool fullScreen ); 99 void showVideoFullScreen( bool fullScreen );
69 100
70 /** 101 /**
71 * 102 *
72 */ 103 */
73 bool isVideoFullScreen()/*const*/ ; 104 bool isVideoFullScreen()/*const*/ ;
74 105
75 /** 106 /**
76 * 107 *
77 */ 108 */
78 bool isScaling(); 109 bool isScaling();
79 110
80 /** 111 /**
81 * 112 *
82 */ 113 */
83 void setScaling( bool ); 114 void setScaling( bool );
84 /** 115 /**
85 * test 116 * test
86 */ 117 */
87 Frame currentFrame()/*const*/; 118 Frame currentFrame()/*const*/;
88 119
89 /** 120 /**
90 * Returns the error code 121 * Returns the error code
91 */ 122 */
92 int error() /*const*/; 123 int error() /*const*/;
93 124
94 signals: 125 signals:
95 void stopped(); 126 void stopped();
96 private: 127 private:
97 int m_bytes_per_pixel; 128 int m_bytes_per_pixel;
98 bool m_video:1; 129 bool m_video:1;
99 XineVideoWidget *m_wid; 130 XineVideoWidget *m_wid;
100 xine_t *m_xine; 131 xine_t *m_xine;
101 config_values_t *m_config; 132 config_values_t *m_config;
102 vo_driver_t *m_videoOutput; 133 vo_driver_t *m_videoOutput;
103 ao_driver_t* m_audioOutput; 134 ao_driver_t* m_audioOutput;
104 135
105 void handleXineEvent( xine_event_t* t ); 136 void handleXineEvent( xine_event_t* t );
106 void drawFrame( uint8_t* frame, int width, int height, int bytes ); 137 void drawFrame( uint8_t* frame, int width, int height, int bytes );
107 // C -> C++ bridge for the event system 138 // C -> C++ bridge for the event system
108 static void xine_event_handler( void* user_data, xine_event_t* t); 139 static void xine_event_handler( void* user_data, xine_event_t* t);
109 static void xine_display_frame( void* user_data, uint8_t* frame , 140 static void xine_display_frame( void* user_data, uint8_t* frame ,
110 int width, int height, int bytes ); 141 int width, int height, int bytes );
111 }; 142 };
112}; 143};
113 144
114 145
115#endif 146#endif