-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 4a96408..1b5fd51 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,293 +1,300 @@ | |||
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 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <stdio.h> | 34 | #include <stdio.h> |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <qimage.h> | 36 | #include <qimage.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | 41 | ||
42 | #include <qgfx_qws.h> | 42 | #include <qgfx_qws.h> |
43 | #include <qdirectpainter_qws.h> | 43 | #include <qdirectpainter_qws.h> |
44 | 44 | ||
45 | #include <assert.h> | 45 | #include <assert.h> |
46 | 46 | ||
47 | #include "xinevideowidget.h" | 47 | #include "xinevideowidget.h" |
48 | #include "frame.h" | 48 | #include "frame.h" |
49 | #include "lib.h" | 49 | #include "lib.h" |
50 | 50 | ||
51 | 51 | ||
52 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 52 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
53 | int width, int height,int bytes ); | 53 | int width, int height,int bytes ); |
54 | 54 | ||
55 | extern "C" { | 55 | extern "C" { |
56 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); | 56 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); |
57 | int null_is_showing_video( const xine_vo_driver_t* self ); | 57 | int null_is_showing_video( const xine_vo_driver_t* self ); |
58 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 58 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
59 | int null_is_fullscreen( const xine_vo_driver_t* self ); | 59 | int null_is_fullscreen( const xine_vo_driver_t* self ); |
60 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); | 60 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); |
61 | int null_is_scaling( const xine_vo_driver_t* self ); | 61 | int null_is_scaling( const xine_vo_driver_t* self ); |
62 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); | 62 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); |
63 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); | 63 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); |
64 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | 64 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
65 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 65 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
66 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | 66 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
67 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 67 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
68 | } | 68 | } |
69 | 69 | ||
70 | using namespace XINE; | 70 | using namespace XINE; |
71 | 71 | ||
72 | Lib::Lib( XineVideoWidget* widget ) { | 72 | Lib::Lib( XineVideoWidget* widget ) { |
73 | m_video = false; | 73 | m_video = false; |
74 | m_wid = widget; | 74 | m_wid = widget; |
75 | printf("Lib"); | 75 | printf("Lib"); |
76 | QCString str( getenv("HOME") ); | 76 | QCString str( getenv("HOME") ); |
77 | str += "/Settings/opiexine.cf"; | 77 | str += "/Settings/opiexine.cf"; |
78 | // get the configuration | 78 | // get the configuration |
79 | 79 | ||
80 | // not really OO, should be an extra class, later | 80 | // not really OO, should be an extra class, later |
81 | if ( !QFile(str).exists() ) { | 81 | if ( !QFile(str).exists() ) { |
82 | QFile f(str); | 82 | QFile f(str); |
83 | f.open(IO_WriteOnly); | 83 | f.open(IO_WriteOnly); |
84 | QTextStream ts( &f ); | 84 | QTextStream ts( &f ); |
85 | ts << "misc.memcpy_method:glibc\n"; | 85 | ts << "misc.memcpy_method:glibc\n"; |
86 | f.close(); | 86 | f.close(); |
87 | } | 87 | } |
88 | 88 | ||
89 | m_xine = xine_new( ); | 89 | m_xine = xine_new( ); |
90 | 90 | ||
91 | xine_config_load( m_xine, str.data() ); | 91 | xine_config_load( m_xine, str.data() ); |
92 | 92 | ||
93 | xine_init( m_xine ); | 93 | xine_init( m_xine ); |
94 | 94 | ||
95 | // allocate oss for sound | 95 | // allocate oss for sound |
96 | // and fb for framebuffer | 96 | // and fb for framebuffer |
97 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); | 97 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
98 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); | 98 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); |
99 | 99 | ||
100 | 100 | ||
101 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); | 101 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); |
102 | 102 | ||
103 | 103 | ||
104 | // null_display_handler( m_videoOutput, xine_display_frame, this ); | 104 | // null_display_handler( m_videoOutput, xine_display_frame, this ); |
105 | 105 | ||
106 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 106 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
107 | 107 | ||
108 | if (m_wid != 0 ) { | 108 | if (m_wid != 0 ) { |
109 | printf( "!0\n" ); | 109 | printf( "!0\n" ); |
110 | resize ( m_wid-> size ( ) ); | 110 | resize ( m_wid-> size ( ) ); |
111 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 111 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
112 | 112 | ||
113 | m_wid->repaint(); | 113 | m_wid->repaint(); |
114 | } | 114 | } |
115 | 115 | ||
116 | m_queue = xine_event_new_queue (m_stream); | 116 | m_queue = xine_event_new_queue (m_stream); |
117 | 117 | ||
118 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 118 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
119 | } | 119 | } |
120 | 120 | ||
121 | Lib::~Lib() { | 121 | Lib::~Lib() { |
122 | // free( m_config ); | 122 | // free( m_config ); |
123 | |||
124 | xine_close( m_stream ); | ||
125 | |||
126 | xine_event_dispose_queue( m_queue ); | ||
127 | |||
128 | xine_dispose( m_stream ); | ||
129 | |||
123 | xine_exit( m_xine ); | 130 | xine_exit( m_xine ); |
124 | /* FIXME either free or delete but valgrind bitches against both */ | 131 | /* FIXME either free or delete but valgrind bitches against both */ |
125 | //free( m_videoOutput ); | 132 | //free( m_videoOutput ); |
126 | //delete m_audioOutput; | 133 | //delete m_audioOutput; |
127 | } | 134 | } |
128 | 135 | ||
129 | void Lib::resize ( const QSize &s ) { | 136 | void Lib::resize ( const QSize &s ) { |
130 | if ( s. width ( ) && s. height ( ) ) { | 137 | if ( s. width ( ) && s. height ( ) ) { |
131 | ::null_set_gui_width( m_videoOutput, s. width() ); | 138 | ::null_set_gui_width( m_videoOutput, s. width() ); |
132 | ::null_set_gui_height( m_videoOutput, s. height() ); | 139 | ::null_set_gui_height( m_videoOutput, s. height() ); |
133 | } | 140 | } |
134 | } | 141 | } |
135 | 142 | ||
136 | int Lib::majorVersion() { | 143 | int Lib::majorVersion() { |
137 | int major, minor, sub; | 144 | int major, minor, sub; |
138 | xine_get_version ( &major, &minor, &sub ); | 145 | xine_get_version ( &major, &minor, &sub ); |
139 | return major; | 146 | return major; |
140 | } | 147 | } |
141 | 148 | ||
142 | int Lib::minorVersion() { | 149 | int Lib::minorVersion() { |
143 | int major, minor, sub; | 150 | int major, minor, sub; |
144 | xine_get_version ( &major, &minor, &sub ); | 151 | xine_get_version ( &major, &minor, &sub ); |
145 | return minor; | 152 | return minor; |
146 | } | 153 | } |
147 | 154 | ||
148 | int Lib::subVersion() { | 155 | int Lib::subVersion() { |
149 | int major, minor, sub; | 156 | int major, minor, sub; |
150 | xine_get_version ( &major, &minor, &sub ); | 157 | xine_get_version ( &major, &minor, &sub ); |
151 | return sub; | 158 | return sub; |
152 | } | 159 | } |
153 | 160 | ||
154 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 161 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
155 | QString str = fileName.stripWhiteSpace(); | 162 | QString str = fileName.stripWhiteSpace(); |
156 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { | 163 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { |
157 | return 0; | 164 | return 0; |
158 | } | 165 | } |
159 | return xine_play( m_stream, startPos, start_time); | 166 | return xine_play( m_stream, startPos, start_time); |
160 | } | 167 | } |
161 | 168 | ||
162 | void Lib::stop() { | 169 | void Lib::stop() { |
163 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 170 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
164 | xine_stop( m_stream ); | 171 | xine_stop( m_stream ); |
165 | } | 172 | } |
166 | 173 | ||
167 | void Lib::pause() { | 174 | void Lib::pause() { |
168 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 175 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); |
169 | } | 176 | } |
170 | 177 | ||
171 | int Lib::speed() const { | 178 | int Lib::speed() const { |
172 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 179 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
173 | } | 180 | } |
174 | 181 | ||
175 | void Lib::setSpeed( int speed ) { | 182 | void Lib::setSpeed( int speed ) { |
176 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 183 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
177 | } | 184 | } |
178 | 185 | ||
179 | int Lib::status() const { | 186 | int Lib::status() const { |
180 | return xine_get_status( m_stream ); | 187 | return xine_get_status( m_stream ); |
181 | } | 188 | } |
182 | 189 | ||
183 | int Lib::currentPosition() const { | 190 | int Lib::currentPosition() const { |
184 | int pos, time, length; | 191 | int pos, time, length; |
185 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 192 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
186 | return pos; | 193 | return pos; |
187 | } | 194 | } |
188 | 195 | ||
189 | int Lib::currentTime() const { | 196 | int Lib::currentTime() const { |
190 | int pos, time, length; | 197 | int pos, time, length; |
191 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 198 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
192 | return time/1000; | 199 | return time/1000; |
193 | } | 200 | } |
194 | 201 | ||
195 | int Lib::length() const { | 202 | int Lib::length() const { |
196 | int pos, time, length; | 203 | int pos, time, length; |
197 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 204 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
198 | return length/1000; | 205 | return length/1000; |
199 | } | 206 | } |
200 | 207 | ||
201 | bool Lib::isSeekable() const { | 208 | bool Lib::isSeekable() const { |
202 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); | 209 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); |
203 | } | 210 | } |
204 | 211 | ||
205 | void Lib::seekTo( int time ) { | 212 | void Lib::seekTo( int time ) { |
206 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( | 213 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( |
207 | // since its now milliseconds we need *1000 | 214 | // since its now milliseconds we need *1000 |
208 | xine_play( m_stream, 0, time*1000 ); | 215 | xine_play( m_stream, 0, time*1000 ); |
209 | } | 216 | } |
210 | 217 | ||
211 | 218 | ||
212 | Frame Lib::currentFrame() const { | 219 | Frame Lib::currentFrame() const { |
213 | Frame frame; | 220 | Frame frame; |
214 | return frame; | 221 | return frame; |
215 | }; | 222 | }; |
216 | 223 | ||
217 | QString Lib::metaInfo( int number) const { | 224 | QString Lib::metaInfo( int number) const { |
218 | return xine_get_meta_info( m_stream, number ); | 225 | return xine_get_meta_info( m_stream, number ); |
219 | } | 226 | } |
220 | 227 | ||
221 | int Lib::error() const { | 228 | int Lib::error() const { |
222 | return xine_get_error( m_stream ); | 229 | return xine_get_error( m_stream ); |
223 | }; | 230 | }; |
224 | 231 | ||
225 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 232 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
226 | { | 233 | { |
227 | assert( sendType == ThreadUtil::Channel::OneWay ); | 234 | assert( sendType == ThreadUtil::Channel::OneWay ); |
228 | handleXineEvent( msg->type() ); | 235 | handleXineEvent( msg->type() ); |
229 | delete msg; | 236 | delete msg; |
230 | } | 237 | } |
231 | 238 | ||
232 | void Lib::handleXineEvent( const xine_event_t* t ) { | 239 | void Lib::handleXineEvent( const xine_event_t* t ) { |
233 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); | 240 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); |
234 | } | 241 | } |
235 | 242 | ||
236 | void Lib::handleXineEvent( int type ) { | 243 | void Lib::handleXineEvent( int type ) { |
237 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 244 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
238 | emit stopped(); | 245 | emit stopped(); |
239 | } | 246 | } |
240 | } | 247 | } |
241 | 248 | ||
242 | 249 | ||
243 | void Lib::setShowVideo( bool video ) { | 250 | void Lib::setShowVideo( bool video ) { |
244 | m_video = video; | 251 | m_video = video; |
245 | ::null_set_show_video( m_videoOutput, video ); | 252 | ::null_set_show_video( m_videoOutput, video ); |
246 | } | 253 | } |
247 | 254 | ||
248 | bool Lib::isShowingVideo() const { | 255 | bool Lib::isShowingVideo() const { |
249 | return ::null_is_showing_video( m_videoOutput ); | 256 | return ::null_is_showing_video( m_videoOutput ); |
250 | } | 257 | } |
251 | 258 | ||
252 | bool Lib::hasVideo() const { | 259 | bool Lib::hasVideo() const { |
253 | return xine_get_stream_info( m_stream, 18 ); | 260 | return xine_get_stream_info( m_stream, 18 ); |
254 | } | 261 | } |
255 | 262 | ||
256 | void Lib::showVideoFullScreen( bool fullScreen ) { | 263 | void Lib::showVideoFullScreen( bool fullScreen ) { |
257 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 264 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
258 | } | 265 | } |
259 | 266 | ||
260 | bool Lib::isVideoFullScreen() const { | 267 | bool Lib::isVideoFullScreen() const { |
261 | return ::null_is_fullscreen( m_videoOutput ); | 268 | return ::null_is_fullscreen( m_videoOutput ); |
262 | } | 269 | } |
263 | 270 | ||
264 | void Lib::setScaling( bool scale ) { | 271 | void Lib::setScaling( bool scale ) { |
265 | ::null_set_scaling( m_videoOutput, scale ); | 272 | ::null_set_scaling( m_videoOutput, scale ); |
266 | } | 273 | } |
267 | 274 | ||
268 | void Lib::setGamma( int value ) { | 275 | void Lib::setGamma( int value ) { |
269 | //qDebug( QString( "%1").arg(value) ); | 276 | //qDebug( QString( "%1").arg(value) ); |
270 | /* int gammaValue = ( 100 + value ); */ | 277 | /* int gammaValue = ( 100 + value ); */ |
271 | ::null_set_videoGamma( m_videoOutput, value ); | 278 | ::null_set_videoGamma( m_videoOutput, value ); |
272 | } | 279 | } |
273 | 280 | ||
274 | bool Lib::isScaling() const { | 281 | bool Lib::isScaling() const { |
275 | return ::null_is_scaling( m_videoOutput ); | 282 | return ::null_is_scaling( m_videoOutput ); |
276 | } | 283 | } |
277 | 284 | ||
278 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 285 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
279 | ( (Lib*)user_data)->handleXineEvent( t ); | 286 | ( (Lib*)user_data)->handleXineEvent( t ); |
280 | } | 287 | } |
281 | 288 | ||
282 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 289 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
283 | int width, int height, int bytes ) { | 290 | int width, int height, int bytes ) { |
284 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 291 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
285 | } | 292 | } |
286 | 293 | ||
287 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 294 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
288 | if ( !m_video ) { | 295 | if ( !m_video ) { |
289 | qWarning("not showing video now"); | 296 | qWarning("not showing video now"); |
290 | return; | 297 | return; |
291 | } | 298 | } |
292 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 299 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
293 | } | 300 | } |