Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 63 |
1 files changed, 28 insertions, 35 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 | |||
@@ -86,8 +86,9 @@ Lib::Lib( XineVideoWidget* widget ) { | |||
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 ); |
@@ -97,9 +98,10 @@ Lib::Lib( XineVideoWidget* widget ) { | |||
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 ( ) ); |
@@ -107,14 +109,15 @@ Lib::Lib( XineVideoWidget* widget ) { | |||
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 | ||
114 | Lib::~Lib() { | 118 | Lib::~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; |
@@ -149,57 +152,57 @@ int Lib::subVersion() { | |||
149 | } | 152 | } |
150 | 153 | ||
151 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 154 | int 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 | ||
159 | void Lib::stop() { | 162 | void 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 | ||
164 | void Lib::pause() { | 167 | void 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 | ||
168 | int Lib::speed() { | 171 | int 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 | ||
172 | void Lib::setSpeed( int speed ) { | 175 | void 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 | ||
176 | int Lib::status() { | 179 | int Lib::status() { |
177 | return xine_get_status( m_xine ); | 180 | return xine_get_status( m_stream ); |
178 | } | 181 | } |
179 | 182 | ||
180 | int Lib::currentPosition() { | 183 | int 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 | ||
185 | int Lib::currentTime() { | 188 | int 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 | ||
190 | int Lib::length() { | 193 | int 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 | ||
195 | bool Lib::isSeekable() { | 198 | bool 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 | ||
199 | void Lib::seekTo( int time ) { | 202 | void 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 | ||
205 | Frame Lib::currentFrame() { | 208 | Frame Lib::currentFrame() { |
@@ -207,17 +210,17 @@ Frame Lib::currentFrame() { | |||
207 | return frame; | 210 | return frame; |
208 | }; | 211 | }; |
209 | 212 | ||
210 | QString Lib::metaInfo( int number) { | 213 | QString 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 | ||
214 | int Lib::error() { | 217 | int Lib::error() { |
215 | return xine_get_error( m_xine ); | 218 | return xine_get_error( m_stream ); |
216 | }; | 219 | }; |
217 | 220 | ||
218 | void Lib::handleXineEvent( xine_event_t* t ) { | 221 | void 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 | ||
@@ -231,19 +234,9 @@ bool Lib::isShowingVideo() { | |||
231 | return ::null_is_showing_video( m_videoOutput ); | 234 | return ::null_is_showing_video( m_videoOutput ); |
232 | } | 235 | } |
233 | 236 | ||
234 | bool Lib::hasVideo() { | 237 | bool 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 | ||
248 | void Lib::showVideoFullScreen( bool fullScreen ) { | 241 | void Lib::showVideoFullScreen( bool fullScreen ) { |
249 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 242 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
@@ -257,18 +250,18 @@ void Lib::setScaling( bool scale ) { | |||
257 | ::null_set_scaling( m_videoOutput, scale ); | 250 | ::null_set_scaling( m_videoOutput, scale ); |
258 | } | 251 | } |
259 | 252 | ||
260 | void Lib::setGamma( int value ) { | 253 | void 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 | ||
266 | bool Lib::isScaling() { | 259 | bool Lib::isScaling() { |
267 | return ::null_is_scaling( m_videoOutput ); | 260 | return ::null_is_scaling( m_videoOutput ); |
268 | } | 261 | } |
269 | 262 | ||
270 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { | 263 | void 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 | ||
274 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 267 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |