author | harlekin <harlekin> | 2002-09-24 20:26:17 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-09-24 20:26:17 (UTC) |
commit | 7a04855af4e042152a47e90192dc4c2c20858e8c (patch) (unidiff) | |
tree | cca4567d71b8210dc8905804cebc203b71fc4958 /noncore/multimedia/opieplayer2/lib.cpp | |
parent | 02074fb65c5e879ef1d28e52cf4e1ec4a6727599 (diff) | |
download | opie-7a04855af4e042152a47e90192dc4c2c20858e8c.zip opie-7a04855af4e042152a47e90192dc4c2c20858e8c.tar.gz opie-7a04855af4e042152a47e90192dc4c2c20858e8c.tar.bz2 |
adapted to the new api
Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 165 |
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,3 +1,3 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
@@ -51,21 +51,21 @@ typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | |||
51 | 51 | ||
52 | extern "C" { | 52 | extern "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 | ||
67 | using namespace XINE; | 67 | using namespace XINE; |
68 | 68 | ||
69 | Lib::Lib(XineVideoWidget* widget) { | 69 | Lib::Lib( XineVideoWidget* widget ) { |
70 | m_video = false; | 70 | m_video = false; |
71 | m_wid = widget; | 71 | m_wid = widget; |
@@ -84,29 +84,34 @@ Lib::Lib(XineVideoWidget* widget) { | |||
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 | ||
109 | Lib::~Lib() { | 114 | Lib::~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 ); |
@@ -114,92 +119,117 @@ Lib::~Lib() { | |||
114 | //free( m_videoOutput ); | 119 | //free( m_videoOutput ); |
115 | //delete m_audioOutput; | 120 | //delete m_audioOutput; |
116 | |||
117 | } | 121 | } |
118 | 122 | ||
119 | void Lib::resize ( const QSize &s ) | 123 | void 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 | ||
127 | QCString Lib::version() { | 130 | QCString 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 | ||
132 | int Lib::majorVersion() { | 136 | int 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 | |||
135 | int Lib::minorVersion() { | 141 | int 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 | ||
139 | int Lib::subVersion() { | 146 | int 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 | } |
142 | int Lib::play( const QString& fileName, | 150 | |
143 | int startPos, | 151 | int 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 | |||
152 | void Lib::stop() { | 157 | void 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 | } |
156 | void Lib::pause(){ | 161 | |
157 | xine_set_speed( m_xine, SPEED_PAUSE ); | 162 | void Lib::pause() { |
163 | xine_set_param( m_xine, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | ||
158 | } | 164 | } |
165 | |||
159 | int Lib::speed() { | 166 | int Lib::speed() { |
160 | return xine_get_speed( m_xine ); | 167 | return xine_get_param ( m_xine, XINE_PARAM_SPEED ); |
161 | } | 168 | } |
169 | |||
162 | void Lib::setSpeed( int speed ) { | 170 | void Lib::setSpeed( int speed ) { |
163 | xine_set_speed( m_xine, speed ); | 171 | xine_set_param ( m_xine, XINE_PARAM_SPEED, speed ); |
164 | } | 172 | } |
165 | int Lib::status(){ | 173 | |
174 | int Lib::status() { | ||
166 | return xine_get_status( m_xine ); | 175 | return xine_get_status( m_xine ); |
167 | } | 176 | } |
168 | int Lib::currentPosition(){ | 177 | |
169 | return xine_get_current_position( m_xine ); | 178 | int Lib::currentPosition() { |
179 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); | ||
180 | return m_pos; | ||
181 | } | ||
182 | |||
183 | int Lib::currentTime() { | ||
184 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); | ||
185 | return m_time/1000; | ||
170 | } | 186 | } |
171 | int Lib::currentTime() { | 187 | |
172 | return xine_get_current_time( m_xine ); | ||
173 | }; | ||
174 | int Lib::length() { | 188 | int 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 | |||
177 | bool Lib::isSeekable() { | 193 | bool 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 | |||
180 | Frame Lib::currentFrame() { | 197 | Frame Lib::currentFrame() { |
181 | Frame frame; | 198 | Frame frame; |
182 | return frame; | 199 | return frame; |
183 | }; | 200 | }; |
201 | |||
202 | QString Lib::metaInfo() { | ||
203 | xine_get_meta_info( m_xine, 0 ); | ||
204 | } | ||
205 | |||
184 | int Lib::error() { | 206 | int Lib::error() { |
185 | return xine_get_error( m_xine ); | 207 | return xine_get_error( m_xine ); |
186 | }; | 208 | }; |
209 | |||
187 | void Lib::handleXineEvent( xine_event_t* t ) { | 210 | void 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 | |||
191 | void Lib::setShowVideo( bool video ) { | 217 | void 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 | |||
195 | bool Lib::isShowingVideo() { | 222 | bool Lib::isShowingVideo() { |
196 | return ::null_is_showing_video( m_videoOutput ); | 223 | return ::null_is_showing_video( m_videoOutput ); |
197 | } | 224 | } |
225 | |||
198 | void Lib::showVideoFullScreen( bool fullScreen ) { | 226 | void Lib::showVideoFullScreen( bool fullScreen ) { |
199 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 227 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
200 | } | 228 | } |
229 | |||
201 | bool Lib::isVideoFullScreen() { | 230 | bool Lib::isVideoFullScreen() { |
202 | return ::null_is_fullscreen( m_videoOutput ); | 231 | return ::null_is_fullscreen( m_videoOutput ); |
203 | } | 232 | } |
233 | |||
204 | void Lib::setScaling( bool scale ) { | 234 | void Lib::setScaling( bool scale ) { |
205 | ::null_set_scaling( m_videoOutput, scale ); | 235 | ::null_set_scaling( m_videoOutput, scale ); |
@@ -214,17 +244,20 @@ bool Lib::isScaling() { | |||
214 | return ::null_is_scaling( m_videoOutput ); | 244 | return ::null_is_scaling( m_videoOutput ); |
215 | } | 245 | } |
246 | |||
216 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { | 247 | void 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 | |||
219 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 251 | void 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 | |||
224 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 256 | void 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 | ||