summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-11-09 11:18:45 (UTC)
committer harlekin <harlekin>2002-11-09 11:18:45 (UTC)
commit29758bfcaabf75a3155e8af140c11ca9ed014c42 (patch) (unidiff)
treeea8a0ed7eaffe1517a61fb5ac8bc2491eaf59f77
parent84e685e0c2922899dcdd69cfc23ecbccbf855af4 (diff)
downloadopie-29758bfcaabf75a3155e8af140c11ca9ed014c42.zip
opie-29758bfcaabf75a3155e8af140c11ca9ed014c42.tar.gz
opie-29758bfcaabf75a3155e8af140c11ca9ed014c42.tar.bz2
adated to todays version of xine api
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp63
-rw-r--r--noncore/multimedia/opieplayer2/lib.h6
2 files changed, 32 insertions, 37 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index c0e5acd..1ebbbd8 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -78,51 +78,54 @@ Lib::Lib( XineVideoWidget* widget ) {
78 if ( !QFile(str).exists() ) { 78 if ( !QFile(str).exists() ) {
79 QFile f(str); 79 QFile f(str);
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_xine = xine_new( ); 86 m_xine = xine_new( );
87 87
88 xine_config_load( m_xine, str.data() ); 88 xine_config_load( m_xine, str.data() );
89 89
90 xine_init( m_xine );
90 91
91 // allocate oss for sound 92 // allocate oss for sound
92 // and fb for framebuffer 93 // and fb for framebuffer
93 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 94 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
94 m_videoOutput = ::init_video_out_plugin( m_config, NULL ); 95 m_videoOutput = ::init_video_out_plugin( m_config, NULL );
95 96
96 97
97//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); 98//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
98 99
99 100
100 null_display_handler( m_videoOutput, xine_display_frame, this ); 101 null_display_handler( m_videoOutput, xine_display_frame, this );
101 xine_init( m_xine, m_audioOutput, m_videoOutput ); 102
103 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
102 104
103 if (m_wid != 0 ) { 105 if (m_wid != 0 ) {
104 printf( "!0\n" ); 106 printf( "!0\n" );
105 resize ( m_wid-> size ( ) ); 107 resize ( m_wid-> size ( ) );
106 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 108 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
107 109
108 m_wid->repaint(); 110 m_wid->repaint();
109 } 111 }
110 112
111 xine_register_event_listener( m_xine, xine_event_handler, this ); 113 m_queue = xine_event_new_queue (m_stream);
114
115 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
112} 116}
113 117
114Lib::~Lib() { 118Lib::~Lib() {
115// free( m_config ); 119// free( m_config );
116 xine_remove_event_listener( m_xine, xine_event_handler );
117 xine_exit( m_xine ); 120 xine_exit( m_xine );
118 /* FIXME either free or delete but valgrind bitches against both */ 121 /* FIXME either free or delete but valgrind bitches against both */
119 //free( m_videoOutput ); 122 //free( m_videoOutput );
120 //delete m_audioOutput; 123 //delete m_audioOutput;
121} 124}
122 125
123void Lib::resize ( const QSize &s ) { 126void Lib::resize ( const QSize &s ) {
124 if ( s. width ( ) && s. height ( ) ) { 127 if ( s. width ( ) && s. height ( ) ) {
125 ::null_set_gui_width( m_videoOutput, s. width() ); 128 ::null_set_gui_width( m_videoOutput, s. width() );
126 ::null_set_gui_height( m_videoOutput, s. height() ); 129 ::null_set_gui_height( m_videoOutput, s. height() );
127 } 130 }
128} 131}
@@ -141,142 +144,132 @@ int Lib::majorVersion() {
141int Lib::minorVersion() { 144int Lib::minorVersion() {
142 xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); 145 xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version );
143 return m_minor_version; 146 return m_minor_version;
144} 147}
145 148
146int Lib::subVersion() { 149int Lib::subVersion() {
147 xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); 150 xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version );
148 return m_sub_version; 151 return m_sub_version;
149} 152}
150 153
151int Lib::play( const QString& fileName, int startPos, int start_time ) { 154int Lib::play( const QString& fileName, int startPos, int start_time ) {
152 QString str = fileName.stripWhiteSpace(); 155 QString str = fileName.stripWhiteSpace();
153 if ( !xine_open( m_xine, QFile::encodeName(str.utf8() ).data() ) ) { 156 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) {
154 return 0; 157 return 0;
155 } 158 }
156 return xine_play( m_xine, startPos, start_time); 159 return xine_play( m_stream, startPos, start_time);
157} 160}
158 161
159void Lib::stop() { 162void Lib::stop() {
160 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 163 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
161 xine_stop( m_xine ); 164 xine_stop( m_stream );
162} 165}
163 166
164void Lib::pause() { 167void Lib::pause() {
165 xine_set_param( m_xine, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); 168 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
166} 169}
167 170
168int Lib::speed() { 171int Lib::speed() {
169 return xine_get_param ( m_xine, XINE_PARAM_SPEED ); 172 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
170} 173}
171 174
172void Lib::setSpeed( int speed ) { 175void Lib::setSpeed( int speed ) {
173 xine_set_param ( m_xine, XINE_PARAM_SPEED, speed ); 176 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
174} 177}
175 178
176int Lib::status() { 179int Lib::status() {
177 return xine_get_status( m_xine ); 180 return xine_get_status( m_stream );
178} 181}
179 182
180int Lib::currentPosition() { 183int Lib::currentPosition() {
181 xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); 184 xine_get_pos_length( m_stream, &m_pos, &m_time, &m_length );
182 return m_pos; 185 return m_pos;
183} 186}
184 187
185int Lib::currentTime() { 188int Lib::currentTime() {
186 xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); 189 xine_get_pos_length( m_stream, &m_pos, &m_time, &m_length );
187 return m_time/1000; 190 return m_time/1000;
188} 191}
189 192
190int Lib::length() { 193int Lib::length() {
191 xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); 194 xine_get_pos_length( m_stream, &m_pos, &m_time, &m_length );
192 return m_length/1000; 195 return m_length/1000;
193} 196}
194 197
195bool Lib::isSeekable() { 198bool Lib::isSeekable() {
196 return xine_get_stream_info( m_xine, XINE_STREAM_INFO_SEEKABLE ); 199 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
197} 200}
198 201
199void Lib::seekTo( int time ) { 202void Lib::seekTo( int time ) {
200// xine_trick_mode ( m_xine, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( 203 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
201 xine_play( m_xine, 0, time ); 204 xine_play( m_stream, 0, time );
202} 205}
203 206
204 207
205Frame Lib::currentFrame() { 208Frame Lib::currentFrame() {
206 Frame frame; 209 Frame frame;
207 return frame; 210 return frame;
208}; 211};
209 212
210QString Lib::metaInfo( int number) { 213QString Lib::metaInfo( int number) {
211 return xine_get_meta_info( m_xine, number ); 214 return xine_get_meta_info( m_stream, number );
212} 215}
213 216
214int Lib::error() { 217int Lib::error() {
215 return xine_get_error( m_xine ); 218 return xine_get_error( m_stream );
216}; 219};
217 220
218void Lib::handleXineEvent( xine_event_t* t ) { 221void Lib::handleXineEvent( const xine_event_t* t ) {
219 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) { 222 if ( t->type == XINE_EVENT_UI_PLAYBACK_FINISHED ) {
220 emit stopped(); 223 emit stopped();
221 } 224 }
222} 225}
223 226
224 227
225void Lib::setShowVideo( bool video ) { 228void Lib::setShowVideo( bool video ) {
226 m_video = video; 229 m_video = video;
227 ::null_set_show_video( m_videoOutput, video ); 230 ::null_set_show_video( m_videoOutput, video );
228} 231}
229 232
230bool Lib::isShowingVideo() { 233bool Lib::isShowingVideo() {
231 return ::null_is_showing_video( m_videoOutput ); 234 return ::null_is_showing_video( m_videoOutput );
232} 235}
233 236
234bool Lib::hasVideo() { 237bool Lib::hasVideo() {
235 //looks like it is not implemented yet 238 return xine_get_stream_info( m_stream, 18 );
236 //return xine_get_stream_info( m_xine, XINE_STREAM_INFO_VIDEO_CHANNELS );
237 // ugly hack until xine is ready, look for the width of the video
238 int test = xine_get_stream_info( m_xine, 2 );
239 if( test > 0 ) {
240 // qDebug( QString(" has video: %1").arg( test ) );
241 return true;
242 } else {
243 //qDebug ( "does not have video ");
244 return false;
245 }
246} 239}
247 240
248void Lib::showVideoFullScreen( bool fullScreen ) { 241void Lib::showVideoFullScreen( bool fullScreen ) {
249 ::null_set_fullscreen( m_videoOutput, fullScreen ); 242 ::null_set_fullscreen( m_videoOutput, fullScreen );
250} 243}
251 244
252bool Lib::isVideoFullScreen() { 245bool Lib::isVideoFullScreen() {
253 return ::null_is_fullscreen( m_videoOutput ); 246 return ::null_is_fullscreen( m_videoOutput );
254} 247}
255 248
256void Lib::setScaling( bool scale ) { 249void Lib::setScaling( bool scale ) {
257 ::null_set_scaling( m_videoOutput, scale ); 250 ::null_set_scaling( m_videoOutput, scale );
258} 251}
259 252
260void Lib::setGamma( int value ) { 253void Lib::setGamma( int value ) {
261 //qDebug( QString( "%1").arg(value) ); 254 //qDebug( QString( "%1").arg(value) );
262 int gammaValue = ( 100 + value ); 255 /* int gammaValue = ( 100 + value ); */
263 ::null_set_videoGamma( m_videoOutput, value ); 256 ::null_set_videoGamma( m_videoOutput, value );
264} 257}
265 258
266bool Lib::isScaling() { 259bool Lib::isScaling() {
267 return ::null_is_scaling( m_videoOutput ); 260 return ::null_is_scaling( m_videoOutput );
268} 261}
269 262
270void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { 263void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) {
271 ( (Lib*)user_data)->handleXineEvent( t ); 264 ( (Lib*)user_data)->handleXineEvent( t );
272} 265}
273 266
274void Lib::xine_display_frame( void* user_data, uint8_t *frame, 267void Lib::xine_display_frame( void* user_data, uint8_t *frame,
275 int width, int height, int bytes ) { 268 int width, int height, int bytes ) {
276 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); 269 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
277} 270}
278 271
279void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 272void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
280 if ( !m_video ) { 273 if ( !m_video ) {
281 qWarning("not showing video now"); 274 qWarning("not showing video now");
282 return; 275 return;
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index 6cdd9c6..191dbbd 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -171,27 +171,29 @@ namespace XINE {
171 */ 171 */
172 int error() /*const*/; 172 int error() /*const*/;
173 173
174 signals: 174 signals:
175 void stopped(); 175 void stopped();
176 private: 176 private:
177 int m_bytes_per_pixel; 177 int m_bytes_per_pixel;
178 int m_length, m_pos, m_time; 178 int m_length, m_pos, m_time;
179 int m_major_version, m_minor_version, m_sub_version; 179 int m_major_version, m_minor_version, m_sub_version;
180 bool m_video:1; 180 bool m_video:1;
181 XineVideoWidget *m_wid; 181 XineVideoWidget *m_wid;
182 xine_t *m_xine; 182 xine_t *m_xine;
183 xine_stream_t *m_stream;
183 xine_cfg_entry_t *m_config; 184 xine_cfg_entry_t *m_config;
184 xine_vo_driver_t *m_videoOutput; 185 xine_vo_driver_t *m_videoOutput;
185 xine_ao_driver_t* m_audioOutput; 186 xine_ao_driver_t* m_audioOutput;
187 xine_event_queue_t *m_queue;
186 188
187 void handleXineEvent( xine_event_t* t ); 189 void handleXineEvent( const xine_event_t* t );
188 void drawFrame( uint8_t* frame, int width, int height, int bytes ); 190 void drawFrame( uint8_t* frame, int width, int height, int bytes );
189 // C -> C++ bridge for the event system 191 // C -> C++ bridge for the event system
190 static void xine_event_handler( void* user_data, xine_event_t* t); 192 static void xine_event_handler( void* user_data, const xine_event_t* t);
191 static void xine_display_frame( void* user_data, uint8_t* frame , 193 static void xine_display_frame( void* user_data, uint8_t* frame ,
192 int width, int height, int bytes ); 194 int width, int height, int bytes );
193 }; 195 };
194}; 196};
195 197
196 198
197#endif 199#endif