Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 4021d4a..85030de 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -105,161 +105,180 @@ Lib::Lib( XineVideoWidget* widget ) { | |||
105 | resize ( m_wid-> size ( ) ); | 105 | resize ( m_wid-> size ( ) ); |
106 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 106 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
107 | 107 | ||
108 | m_wid->repaint(); | 108 | m_wid->repaint(); |
109 | } | 109 | } |
110 | 110 | ||
111 | xine_register_event_listener( m_xine, xine_event_handler, this ); | 111 | xine_register_event_listener( m_xine, xine_event_handler, this ); |
112 | } | 112 | } |
113 | 113 | ||
114 | Lib::~Lib() { | 114 | Lib::~Lib() { |
115 | // free( m_config ); | 115 | // free( m_config ); |
116 | xine_remove_event_listener( m_xine, xine_event_handler ); | 116 | xine_remove_event_listener( m_xine, xine_event_handler ); |
117 | xine_exit( m_xine ); | 117 | xine_exit( m_xine ); |
118 | /* FIXME either free or delete but valgrind bitches against both */ | 118 | /* FIXME either free or delete but valgrind bitches against both */ |
119 | //free( m_videoOutput ); | 119 | //free( m_videoOutput ); |
120 | //delete m_audioOutput; | 120 | //delete m_audioOutput; |
121 | } | 121 | } |
122 | 122 | ||
123 | void Lib::resize ( const QSize &s ) { | 123 | void Lib::resize ( const QSize &s ) { |
124 | if ( s. width ( ) && s. height ( ) ) { | 124 | if ( s. width ( ) && s. height ( ) ) { |
125 | ::null_set_gui_width( m_videoOutput, s. width() ); | 125 | ::null_set_gui_width( m_videoOutput, s. width() ); |
126 | ::null_set_gui_height( m_videoOutput, s. height() ); | 126 | ::null_set_gui_height( m_videoOutput, s. height() ); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | QCString Lib::version() { | 130 | QCString Lib::version() { |
131 | // QCString str( xine_get_str_version() ); | 131 | // QCString str( xine_get_str_version() ); |
132 | // return str; | 132 | // return str; |
133 | return "test"; | 133 | return "test"; |
134 | } | 134 | } |
135 | 135 | ||
136 | int Lib::majorVersion() { | 136 | int Lib::majorVersion() { |
137 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); | 137 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); |
138 | return m_major_version; | 138 | return m_major_version; |
139 | } | 139 | } |
140 | 140 | ||
141 | int Lib::minorVersion() { | 141 | int Lib::minorVersion() { |
142 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); | 142 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); |
143 | return m_minor_version; | 143 | return m_minor_version; |
144 | } | 144 | } |
145 | 145 | ||
146 | int Lib::subVersion() { | 146 | int Lib::subVersion() { |
147 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); | 147 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); |
148 | return m_sub_version; | 148 | return m_sub_version; |
149 | } | 149 | } |
150 | 150 | ||
151 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 151 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
152 | QString str = fileName.stripWhiteSpace(); | 152 | QString str = fileName.stripWhiteSpace(); |
153 | xine_open( m_xine, QFile::encodeName(str.utf8() ).data() ); | 153 | if ( !xine_open( m_xine, QFile::encodeName(str.utf8() ).data() ) ) { |
154 | return 0; | ||
155 | } | ||
154 | return xine_play( m_xine, startPos, start_time); | 156 | return xine_play( m_xine, startPos, start_time); |
155 | } | 157 | } |
156 | 158 | ||
157 | void Lib::stop() { | 159 | void Lib::stop() { |
158 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 160 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
159 | xine_stop( m_xine ); | 161 | xine_stop( m_xine ); |
160 | } | 162 | } |
161 | 163 | ||
162 | void Lib::pause() { | 164 | void Lib::pause() { |
163 | xine_set_param( m_xine, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 165 | xine_set_param( m_xine, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); |
164 | } | 166 | } |
165 | 167 | ||
166 | int Lib::speed() { | 168 | int Lib::speed() { |
167 | return xine_get_param ( m_xine, XINE_PARAM_SPEED ); | 169 | return xine_get_param ( m_xine, XINE_PARAM_SPEED ); |
168 | } | 170 | } |
169 | 171 | ||
170 | void Lib::setSpeed( int speed ) { | 172 | void Lib::setSpeed( int speed ) { |
171 | xine_set_param ( m_xine, XINE_PARAM_SPEED, speed ); | 173 | xine_set_param ( m_xine, XINE_PARAM_SPEED, speed ); |
172 | } | 174 | } |
173 | 175 | ||
174 | int Lib::status() { | 176 | int Lib::status() { |
175 | return xine_get_status( m_xine ); | 177 | return xine_get_status( m_xine ); |
176 | } | 178 | } |
177 | 179 | ||
178 | int Lib::currentPosition() { | 180 | int Lib::currentPosition() { |
179 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); | 181 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); |
180 | return m_pos; | 182 | return m_pos; |
181 | } | 183 | } |
182 | 184 | ||
183 | int Lib::currentTime() { | 185 | int Lib::currentTime() { |
184 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); | 186 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); |
185 | return m_time/1000; | 187 | return m_time/1000; |
186 | } | 188 | } |
187 | 189 | ||
188 | int Lib::length() { | 190 | int Lib::length() { |
189 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); | 191 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); |
190 | return m_length/1000; | 192 | return m_length/1000; |
191 | } | 193 | } |
192 | 194 | ||
193 | bool Lib::isSeekable() { | 195 | bool Lib::isSeekable() { |
194 | return xine_get_stream_info ( m_xine, XINE_STREAM_INFO_SEEKABLE ); | 196 | return xine_get_stream_info( m_xine, XINE_STREAM_INFO_SEEKABLE ); |
197 | } | ||
198 | |||
199 | void Lib::seekTo( int time ) { | ||
200 | // xine_trick_mode ( m_xine, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( | ||
201 | xine_play( m_xine, 0, time ); | ||
195 | } | 202 | } |
196 | 203 | ||
204 | |||
197 | Frame Lib::currentFrame() { | 205 | Frame Lib::currentFrame() { |
198 | Frame frame; | 206 | Frame frame; |
199 | return frame; | 207 | return frame; |
200 | }; | 208 | }; |
201 | 209 | ||
202 | QString Lib::metaInfo() { | 210 | QString Lib::metaInfo( int number) { |
203 | xine_get_meta_info( m_xine, 0 ); | 211 | return xine_get_meta_info( m_xine, number ); |
204 | } | 212 | } |
205 | 213 | ||
206 | int Lib::error() { | 214 | int Lib::error() { |
207 | return xine_get_error( m_xine ); | 215 | return xine_get_error( m_xine ); |
208 | }; | 216 | }; |
209 | 217 | ||
210 | void Lib::handleXineEvent( xine_event_t* t ) { | 218 | void Lib::handleXineEvent( xine_event_t* t ) { |
211 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) { | 219 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) { |
212 | emit stopped(); | 220 | emit stopped(); |
213 | } | 221 | } |
214 | } | 222 | } |
215 | 223 | ||
216 | 224 | ||
217 | void Lib::setShowVideo( bool video ) { | 225 | void Lib::setShowVideo( bool video ) { |
218 | m_video = video; | 226 | m_video = video; |
219 | ::null_set_show_video( m_videoOutput, video ); | 227 | ::null_set_show_video( m_videoOutput, video ); |
220 | } | 228 | } |
221 | 229 | ||
222 | bool Lib::isShowingVideo() { | 230 | bool Lib::isShowingVideo() { |
223 | return ::null_is_showing_video( m_videoOutput ); | 231 | return ::null_is_showing_video( m_videoOutput ); |
224 | } | 232 | } |
225 | 233 | ||
234 | bool Lib::hasVideo() { | ||
235 | //looks like it is not implemented yet | ||
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 | } | ||
247 | |||
226 | void Lib::showVideoFullScreen( bool fullScreen ) { | 248 | void Lib::showVideoFullScreen( bool fullScreen ) { |
227 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 249 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
228 | } | 250 | } |
229 | 251 | ||
230 | bool Lib::isVideoFullScreen() { | 252 | bool Lib::isVideoFullScreen() { |
231 | return ::null_is_fullscreen( m_videoOutput ); | 253 | return ::null_is_fullscreen( m_videoOutput ); |
232 | } | 254 | } |
233 | 255 | ||
234 | void Lib::setScaling( bool scale ) { | 256 | void Lib::setScaling( bool scale ) { |
235 | ::null_set_scaling( m_videoOutput, scale ); | 257 | ::null_set_scaling( m_videoOutput, scale ); |
236 | } | 258 | } |
237 | 259 | ||
238 | void Lib::setGamma( int value ) { | 260 | void Lib::setGamma( int value ) { |
239 | //qDebug( QString( "%1").arg(value) ); | 261 | //qDebug( QString( "%1").arg(value) ); |
240 | ::null_set_videoGamma( m_videoOutput, value ); | 262 | ::null_set_videoGamma( m_videoOutput, value ); |
241 | } | 263 | } |
242 | 264 | ||
243 | bool Lib::isScaling() { | 265 | bool Lib::isScaling() { |
244 | return ::null_is_scaling( m_videoOutput ); | 266 | return ::null_is_scaling( m_videoOutput ); |
245 | } | 267 | } |
246 | 268 | ||
247 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { | 269 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { |
248 | ( (Lib*)user_data)->handleXineEvent( t ); | 270 | ( (Lib*)user_data)->handleXineEvent( t ); |
249 | } | 271 | } |
250 | 272 | ||
251 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 273 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
252 | int width, int height, int bytes ) { | 274 | int width, int height, int bytes ) { |
253 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 275 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
254 | } | 276 | } |
255 | 277 | ||
256 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 278 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
257 | if ( !m_video ) { | 279 | if ( !m_video ) { |
258 | qWarning("not showing video now"); | 280 | qWarning("not showing video now"); |
259 | return; | 281 | return; |
260 | } | 282 | } |
261 | |||
262 | // qWarning( "called draw frame %d %d", width, height ); | ||
263 | |||
264 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 283 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
265 | } | 284 | } |