summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/lib.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp165
1 files changed, 99 insertions, 66 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index d8a0694..4021d4a 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,7 +1,7 @@
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 =.
@@ -47,29 +47,29 @@
47#include "lib.h" 47#include "lib.h"
48 48
49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
50 int width, int height,int bytes ); 50 int width, int height,int bytes );
51 51
52extern "C" { 52extern "C" {
53 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); 53 xine_vo_driver_t* init_video_out_plugin( xine_cfg_entry_t* conf, void* video);
54 int null_is_showing_video( vo_driver_t* self ); 54 int null_is_showing_video( const xine_vo_driver_t* self );
55 void null_set_show_video( vo_driver_t* self, int show ); 55 void null_set_show_video( const xine_vo_driver_t* self, int show );
56 int null_is_fullscreen( vo_driver_t* self ); 56 int null_is_fullscreen( const xine_vo_driver_t* self );
57 void null_set_fullscreen( vo_driver_t* self, int screen ); 57 void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
58 int null_is_scaling( vo_driver_t* self ); 58 int null_is_scaling( const xine_vo_driver_t* self );
59 void null_set_scaling( vo_driver_t* self, int scale ); 59 void null_set_scaling( const xine_vo_driver_t* self, int scale );
60 void null_set_gui_width( vo_driver_t* self, int width ); 60 void null_set_gui_width( const xine_vo_driver_t* self, int width );
61 void null_set_gui_height( vo_driver_t* self, int height ); 61 void null_set_gui_height( const xine_vo_driver_t* self, int height );
62 void null_set_mode( vo_driver_t* self, int depth, int rgb ); 62 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb );
63 void null_set_videoGamma( vo_driver_t* self , int value ); 63 void null_set_videoGamma( const xine_vo_driver_t* self , int value );
64 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); 64 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data );
65} 65}
66 66
67using namespace XINE; 67using namespace XINE;
68 68
69Lib::Lib(XineVideoWidget* widget) { 69Lib::Lib( XineVideoWidget* widget ) {
70 m_video = false; 70 m_video = false;
71 m_wid = widget; 71 m_wid = widget;
72 printf("Lib"); 72 printf("Lib");
73 QCString str( getenv("HOME") ); 73 QCString str( getenv("HOME") );
74 str += "/Settings/opiexine.cf"; 74 str += "/Settings/opiexine.cf";
75 // get the configuration 75 // get the configuration
@@ -80,153 +80,186 @@ Lib::Lib(XineVideoWidget* widget) {
80 f.open(IO_WriteOnly); 80 f.open(IO_WriteOnly);
81 QTextStream ts( &f ); 81 QTextStream ts( &f );
82 ts << "misc.memcpy_method:glibc\n"; 82 ts << "misc.memcpy_method:glibc\n";
83 f.close(); 83 f.close();
84 } 84 }
85 85
86 m_config = xine_config_file_init( str.data() ); 86 m_xine = xine_new( );
87
88 xine_config_load( m_xine, str.data() );
89
87 90
88 // allocate oss for sound 91 // allocate oss for sound
89 // and fb for framebuffer 92 // and fb for framebuffer
90 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; 93 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
91 m_videoOutput = ::init_video_out_plugin( m_config, NULL ); 94 m_videoOutput = ::init_video_out_plugin( m_config, NULL );
95
96
97//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
98
99
100 null_display_handler( m_videoOutput, xine_display_frame, this );
101 xine_init( m_xine, m_audioOutput, m_videoOutput );
102
92 if (m_wid != 0 ) { 103 if (m_wid != 0 ) {
93 printf("!0\n" ); 104 printf( "!0\n" );
94 resize ( m_wid-> size ( )); 105 resize ( m_wid-> size ( ) );
95 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 106 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
96 m_wid-> setLogo ( new QImage ( Resource::loadImage(""))); 107
97 m_wid->repaint(); 108 m_wid->repaint();
98 } 109 }
99 null_display_handler( m_videoOutput,
100 xine_display_frame,
101 this );
102 110
103 m_xine = xine_init( m_videoOutput,
104 m_audioOutput, m_config );
105 // install the event handler
106 xine_register_event_listener( m_xine, xine_event_handler, this ); 111 xine_register_event_listener( m_xine, xine_event_handler, this );
107} 112}
108 113
109Lib::~Lib() { 114Lib::~Lib() {
110 free( m_config ); 115// free( m_config );
111 xine_remove_event_listener( m_xine, xine_event_handler ); 116 xine_remove_event_listener( m_xine, xine_event_handler );
112 xine_exit( m_xine ); 117 xine_exit( m_xine );
113 /* FIXME either free or delete but valgrind bitches against both */ 118 /* FIXME either free or delete but valgrind bitches against both */
114 //free( m_videoOutput ); 119 //free( m_videoOutput );
115 //delete m_audioOutput; 120 //delete m_audioOutput;
116
117} 121}
118 122
119void Lib::resize ( const QSize &s ) 123void Lib::resize ( const QSize &s ) {
120{ 124 if ( s. width ( ) && s. height ( ) ) {
121 if ( s. width ( ) && s. height ( )) { 125 ::null_set_gui_width( m_videoOutput, s. width() );
122 ::null_set_gui_width( m_videoOutput, s. width() ); 126 ::null_set_gui_height( m_videoOutput, s. height() );
123 ::null_set_gui_height(m_videoOutput, s. height() ); 127 }
124 }
125} 128}
126 129
127QCString Lib::version() { 130QCString Lib::version() {
128 QCString str( xine_get_str_version() ); 131 // QCString str( xine_get_str_version() );
129 return str; 132 // return str;
130}; 133 return "test";
134}
131 135
132int Lib::majorVersion() { 136int Lib::majorVersion() {
133 return xine_get_major_version(); 137 xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version );
138 return m_major_version;
134} 139}
140
135int Lib::minorVersion() { 141int Lib::minorVersion() {
136 return xine_get_minor_version(); 142 xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version );
137}; 143 return m_minor_version;
144}
138 145
139int Lib::subVersion() { 146int Lib::subVersion() {
140 return xine_get_sub_version(); 147 xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version );
148 return m_sub_version;
141} 149}
142int Lib::play( const QString& fileName, 150
143 int startPos, 151int Lib::play( const QString& fileName, int startPos, int start_time ) {
144 int start_time ) {
145 QString str = fileName.stripWhiteSpace(); 152 QString str = fileName.stripWhiteSpace();
146 //workaround OpiePlayer bug 153 xine_open( m_xine, QFile::encodeName(str.utf8() ).data() );
147 //f (str.right(1) == QString::fromLatin1("/") ) 154 return xine_play( m_xine, startPos, start_time);
148 // str = str.mid( str.length() -1 );
149 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(),
150 startPos, start_time);
151} 155}
156
152void Lib::stop() { 157void Lib::stop() {
153 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 158 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
154 xine_stop(m_xine ); 159 xine_stop( m_xine );
155} 160}
156void Lib::pause(){ 161
157 xine_set_speed( m_xine, SPEED_PAUSE ); 162void Lib::pause() {
163 xine_set_param( m_xine, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
158} 164}
165
159int Lib::speed() { 166int Lib::speed() {
160 return xine_get_speed( m_xine ); 167 return xine_get_param ( m_xine, XINE_PARAM_SPEED );
161} 168}
169
162void Lib::setSpeed( int speed ) { 170void Lib::setSpeed( int speed ) {
163 xine_set_speed( m_xine, speed ); 171 xine_set_param ( m_xine, XINE_PARAM_SPEED, speed );
164} 172}
165int Lib::status(){ 173
174int Lib::status() {
166 return xine_get_status( m_xine ); 175 return xine_get_status( m_xine );
167} 176}
168int Lib::currentPosition(){ 177
169 return xine_get_current_position( m_xine ); 178int Lib::currentPosition() {
179 xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length );
180 return m_pos;
181}
182
183int Lib::currentTime() {
184 xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length );
185 return m_time/1000;
170} 186}
171int Lib::currentTime() { 187
172 return xine_get_current_time( m_xine );
173};
174int Lib::length() { 188int Lib::length() {
175 return xine_get_stream_length( m_xine ); 189 xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length );
190 return m_length/1000;
176} 191}
192
177bool Lib::isSeekable() { 193bool Lib::isSeekable() {
178 return xine_is_stream_seekable(m_xine); 194 return xine_get_stream_info ( m_xine, XINE_STREAM_INFO_SEEKABLE );
179} 195}
196
180Frame Lib::currentFrame() { 197Frame Lib::currentFrame() {
181 Frame frame; 198 Frame frame;
182 return frame; 199 return frame;
183}; 200};
201
202QString Lib::metaInfo() {
203 xine_get_meta_info( m_xine, 0 );
204}
205
184int Lib::error() { 206int Lib::error() {
185 return xine_get_error( m_xine ); 207 return xine_get_error( m_xine );
186}; 208};
209
187void Lib::handleXineEvent( xine_event_t* t ) { 210void Lib::handleXineEvent( xine_event_t* t ) {
188 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) 211 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) {
189 emit stopped(); 212 emit stopped();
213 }
190} 214}
215
216
191void Lib::setShowVideo( bool video ) { 217void Lib::setShowVideo( bool video ) {
192 m_video = video; 218 m_video = video;
193 ::null_set_show_video( m_videoOutput, video ); 219 ::null_set_show_video( m_videoOutput, video );
194} 220}
221
195bool Lib::isShowingVideo() { 222bool Lib::isShowingVideo() {
196 return ::null_is_showing_video( m_videoOutput ); 223 return ::null_is_showing_video( m_videoOutput );
197} 224}
225
198void Lib::showVideoFullScreen( bool fullScreen ) { 226void Lib::showVideoFullScreen( bool fullScreen ) {
199 ::null_set_fullscreen( m_videoOutput, fullScreen ); 227 ::null_set_fullscreen( m_videoOutput, fullScreen );
200} 228}
229
201bool Lib::isVideoFullScreen() { 230bool Lib::isVideoFullScreen() {
202 return ::null_is_fullscreen( m_videoOutput ); 231 return ::null_is_fullscreen( m_videoOutput );
203} 232}
233
204void Lib::setScaling( bool scale ) { 234void Lib::setScaling( bool scale ) {
205 ::null_set_scaling( m_videoOutput, scale ); 235 ::null_set_scaling( m_videoOutput, scale );
206} 236}
207 237
208void Lib::setGamma( int value ) { 238void Lib::setGamma( int value ) {
209 //qDebug( QString( "%1").arg(value) ); 239 //qDebug( QString( "%1").arg(value) );
210 ::null_set_videoGamma( m_videoOutput, value ); 240 ::null_set_videoGamma( m_videoOutput, value );
211} 241}
212 242
213bool Lib::isScaling() { 243bool Lib::isScaling() {
214 return ::null_is_scaling( m_videoOutput ); 244 return ::null_is_scaling( m_videoOutput );
215} 245}
246
216void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { 247void Lib::xine_event_handler( void* user_data, xine_event_t* t ) {
217 ((Lib*)user_data)->handleXineEvent( t ); 248 ( (Lib*)user_data)->handleXineEvent( t );
218} 249}
250
219void Lib::xine_display_frame( void* user_data, uint8_t *frame, 251void Lib::xine_display_frame( void* user_data, uint8_t *frame,
220 int width, int height, int bytes ) { 252 int width, int height, int bytes ) {
221 253 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
222 ((Lib*)user_data)->drawFrame( frame, width, height, bytes );
223} 254}
255
224void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 256void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
225 if (!m_video ) { 257 if ( !m_video ) {
226 qWarning("not showing video now"); 258 qWarning("not showing video now");
227 return; 259 return;
228 } 260 }
261
229// qWarning( "called draw frame %d %d", width, height ); 262// qWarning( "called draw frame %d %d", width, height );
230 263
231 m_wid-> setVideoFrame ( frame, width, height, bytes ); 264 m_wid-> setVideoFrame ( frame, width, height, bytes );
232} 265}