author | alwin <alwin> | 2005-04-10 11:03:22 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-04-10 11:03:22 (UTC) |
commit | 713db174943e9184bfa68fa430123c52ad3c3b2b (patch) (unidiff) | |
tree | 6f19a3127d0b0d142db2520611fa66245124b862 | |
parent | 8729cfb1a96057fb2d46188aa091c4086ae6ae61 (diff) | |
download | opie-713db174943e9184bfa68fa430123c52ad3c3b2b.zip opie-713db174943e9184bfa68fa430123c52ad3c3b2b.tar.gz opie-713db174943e9184bfa68fa430123c52ad3c3b2b.tar.bz2 |
- replaced the origin videopaint with a more simple one (this high-sophisticated stuff
isn't needed) in xinevideo
- replaced an assert in lib.cpp with a "if" construct
- may set a file without start playing it (for getting information and so on)
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 90 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 49 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 180 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.h | 1 |
4 files changed, 163 insertions, 157 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index e3289bc..9f7a9c5 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,99 +1,99 @@ | |||
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 "xinevideowidget.h" | 34 | #include "xinevideowidget.h" |
35 | #include "lib.h" | 35 | #include "lib.h" |
36 | 36 | ||
37 | /* OPIE */ | 37 | /* OPIE */ |
38 | #include <opie2/odebug.h> | 38 | #include <opie2/odebug.h> |
39 | #include <qpe/global.h> | 39 | #include <qpe/global.h> |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qdir.h> | 43 | #include <qdir.h> |
44 | #include <qgfx_qws.h> | 44 | #include <qgfx_qws.h> |
45 | 45 | ||
46 | /* STD */ | 46 | /* STD */ |
47 | #include <assert.h> | 47 | #include <assert.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 50 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
51 | int width, int height,int bytes ); | 51 | int width, int height,int bytes ); |
52 | 52 | ||
53 | extern "C" { | 53 | extern "C" { |
54 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); | 54 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); |
55 | int null_is_showing_video( const xine_vo_driver_t* self ); | 55 | int null_is_showing_video( const xine_vo_driver_t* self ); |
56 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 56 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
57 | int null_is_fullscreen( const xine_vo_driver_t* self ); | 57 | int null_is_fullscreen( const xine_vo_driver_t* self ); |
58 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); | 58 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); |
59 | int null_is_scaling( const xine_vo_driver_t* self ); | 59 | int null_is_scaling( const xine_vo_driver_t* self ); |
60 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); | 60 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); |
61 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); | 61 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); |
62 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | 62 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
63 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 63 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
64 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | 64 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
65 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 65 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
66 | 66 | ||
67 | void null_preload_decoders( xine_stream_t *stream ); | 67 | void null_preload_decoders( xine_stream_t *stream ); |
68 | } | 68 | } |
69 | 69 | ||
70 | using namespace XINE; | 70 | using namespace XINE; |
71 | 71 | ||
72 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) | 72 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) |
73 | { | 73 | { |
74 | m_initialized = false; | 74 | m_initialized = false; |
75 | m_duringInitialization = false; | 75 | m_duringInitialization = false; |
76 | m_video = false; | 76 | m_video = false; |
77 | m_wid = widget; | 77 | m_wid = widget; |
78 | printf("Lib"); | 78 | printf("Lib"); |
79 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 79 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
80 | // get the configuration | 80 | // get the configuration |
81 | 81 | ||
82 | // not really OO, should be an extra class, later | 82 | // not really OO, should be an extra class, later |
83 | if ( !QFile::exists(configPath) ) { | 83 | if ( !QFile::exists(configPath) ) { |
84 | QFile f(configPath); | 84 | QFile f(configPath); |
85 | f.open(IO_WriteOnly); | 85 | f.open(IO_WriteOnly); |
86 | QTextStream ts( &f ); | 86 | QTextStream ts( &f ); |
87 | ts << "misc.memcpy_method:glibc\n"; | 87 | ts << "misc.memcpy_method:glibc\n"; |
88 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; | 88 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; |
89 | ts << "codec.ffmpeg_pp_quality:3\n"; | 89 | ts << "codec.ffmpeg_pp_quality:3\n"; |
90 | ts << "audio.num_buffers:50\n"; | 90 | ts << "audio.num_buffers:50\n"; |
91 | ts << "audio.size_buffers:4096\n"; | 91 | ts << "audio.size_buffers:4096\n"; |
92 | ts << "video.num_buffers:20\n"; | 92 | ts << "video.num_buffers:20\n"; |
93 | ts << "video.size_buffers:4096\n"; | 93 | ts << "video.size_buffers:4096\n"; |
94 | ts << "audio.out_num_audio_buf:16\n"; | 94 | ts << "audio.out_num_audio_buf:16\n"; |
95 | ts << "audio.out_size_audio_buf:8096\n"; | 95 | ts << "audio.out_size_audio_buf:8096\n"; |
96 | ts << "audio.out_size_zero_buf:1024\n"; | 96 | ts << "audio.out_size_zero_buf:1024\n"; |
97 | ts << "audio.passthrough_offset:0\n"; | 97 | ts << "audio.passthrough_offset:0\n"; |
98 | f.close(); | 98 | f.close(); |
99 | } | 99 | } |
@@ -144,241 +144,253 @@ void Lib::initialize() | |||
144 | m_duringInitialization = false; | 144 | m_duringInitialization = false; |
145 | } | 145 | } |
146 | 146 | ||
147 | Lib::~Lib() { | 147 | Lib::~Lib() { |
148 | assert( isRunning() == false ); | 148 | assert( isRunning() == false ); |
149 | assert( m_initialized ); | 149 | assert( m_initialized ); |
150 | 150 | ||
151 | // free( m_config ); | 151 | // free( m_config ); |
152 | 152 | ||
153 | xine_close( m_stream ); | 153 | xine_close( m_stream ); |
154 | xine_event_dispose_queue( m_queue ); | 154 | xine_event_dispose_queue( m_queue ); |
155 | xine_dispose( m_stream ); | 155 | xine_dispose( m_stream ); |
156 | xine_close_audio_driver(m_xine,m_audioOutput); | 156 | xine_close_audio_driver(m_xine,m_audioOutput); |
157 | xine_close_video_driver(m_xine,m_videoOutput); | 157 | xine_close_video_driver(m_xine,m_videoOutput); |
158 | xine_exit( m_xine ); | 158 | xine_exit( m_xine ); |
159 | 159 | ||
160 | /* FIXME either free or delete but valgrind bitches against both */ | 160 | /* FIXME either free or delete but valgrind bitches against both */ |
161 | //free( m_videoOutput ); | 161 | //free( m_videoOutput ); |
162 | //delete m_audioOutput; | 162 | //delete m_audioOutput; |
163 | } | 163 | } |
164 | 164 | ||
165 | void Lib::resize ( const QSize &s ) { | 165 | void Lib::resize ( const QSize &s ) { |
166 | assert( m_initialized || m_duringInitialization ); | 166 | assert( m_initialized || m_duringInitialization ); |
167 | 167 | ||
168 | if ( s. width ( ) && s. height ( ) ) { | 168 | if ( s. width ( ) && s. height ( ) ) { |
169 | ::null_set_gui_width( m_videoOutput, s. width() ); | 169 | ::null_set_gui_width( m_videoOutput, s. width() ); |
170 | ::null_set_gui_height( m_videoOutput, s. height() ); | 170 | ::null_set_gui_height( m_videoOutput, s. height() ); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | int Lib::majorVersion() { | 174 | int Lib::majorVersion() { |
175 | int major, minor, sub; | 175 | int major, minor, sub; |
176 | xine_get_version ( &major, &minor, &sub ); | 176 | xine_get_version ( &major, &minor, &sub ); |
177 | return major; | 177 | return major; |
178 | } | 178 | } |
179 | 179 | ||
180 | int Lib::minorVersion() { | 180 | int Lib::minorVersion() { |
181 | int major, minor, sub; | 181 | int major, minor, sub; |
182 | xine_get_version ( &major, &minor, &sub ); | 182 | xine_get_version ( &major, &minor, &sub ); |
183 | return minor; | 183 | return minor; |
184 | } | 184 | } |
185 | 185 | ||
186 | int Lib::subVersion() { | 186 | int Lib::subVersion() { |
187 | int major, minor, sub; | 187 | int major, minor, sub; |
188 | xine_get_version ( &major, &minor, &sub ); | 188 | xine_get_version ( &major, &minor, &sub ); |
189 | return sub; | 189 | return sub; |
190 | } | 190 | } |
191 | 191 | ||
192 | int Lib::setfile(const QString& fileName) | ||
193 | { | ||
194 | QString str = fileName.stripWhiteSpace(); | ||
195 | |||
196 | |||
197 | if ( !xine_open( m_stream, str.utf8().data() ) ) { | ||
198 | return 0; | ||
199 | } | ||
200 | return 1; | ||
201 | } | ||
202 | |||
192 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 203 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
193 | assert( m_initialized ); | 204 | assert( m_initialized ); |
194 | 205 | ||
195 | QString str = fileName.stripWhiteSpace(); | 206 | QString str = fileName.stripWhiteSpace(); |
196 | 207 | ||
197 | 208 | ||
198 | if ( !xine_open( m_stream, str.utf8().data() ) ) { | 209 | if ( !xine_open( m_stream, str.utf8().data() ) ) { |
199 | return 0; | 210 | return 0; |
200 | } | 211 | } |
201 | return xine_play( m_stream, startPos, start_time); | 212 | return xine_play( m_stream, startPos, start_time); |
202 | } | 213 | } |
203 | 214 | ||
204 | void Lib::stop() { | 215 | void Lib::stop() { |
205 | assert( m_initialized ); | 216 | assert( m_initialized ); |
206 | xine_stop( m_stream ); | 217 | xine_stop( m_stream ); |
207 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); | 218 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); |
208 | } | 219 | } |
209 | 220 | ||
210 | void Lib::pause( bool toggle ) { | 221 | void Lib::pause( bool toggle ) { |
211 | assert( m_initialized ); | 222 | assert( m_initialized ); |
212 | 223 | ||
213 | if ( toggle ) { | 224 | if ( toggle ) { |
214 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 225 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); |
215 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); | 226 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); |
216 | } | 227 | } |
217 | 228 | ||
218 | else { | 229 | else { |
219 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL ); | 230 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL ); |
220 | } | 231 | } |
221 | } | 232 | } |
222 | 233 | ||
223 | int Lib::speed() const { | 234 | int Lib::speed() const { |
224 | assert( m_initialized ); | 235 | assert( m_initialized ); |
225 | 236 | ||
226 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 237 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
227 | } | 238 | } |
228 | 239 | ||
229 | void Lib::setSpeed( int speed ) { | 240 | void Lib::setSpeed( int speed ) { |
230 | assert( m_initialized ); | 241 | assert( m_initialized ); |
231 | 242 | ||
232 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 243 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
233 | } | 244 | } |
234 | 245 | ||
235 | int Lib::status() const { | 246 | int Lib::status() const { |
236 | assert( m_initialized ); | 247 | assert( m_initialized ); |
237 | 248 | ||
238 | return xine_get_status( m_stream ); | 249 | return xine_get_status( m_stream ); |
239 | } | 250 | } |
240 | 251 | ||
241 | int Lib::currentPosition() const { | 252 | int Lib::currentPosition() const { |
242 | assert( m_initialized ); | 253 | assert( m_initialized ); |
243 | 254 | ||
244 | int pos, time, length; | 255 | int pos, time, length; |
245 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 256 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
246 | return pos; | 257 | return pos; |
247 | } | 258 | } |
248 | 259 | ||
249 | int Lib::currentTime() const { | 260 | int Lib::currentTime() const { |
250 | assert( m_initialized ); | 261 | assert( m_initialized ); |
251 | 262 | ||
252 | int pos, time, length; | 263 | int pos, time, length; |
253 | pos = time = length = 0; | 264 | pos = time = length = 0; |
254 | 265 | ||
255 | if ( xine_get_pos_length( m_stream, &pos, &time, &length ) ) | 266 | if ( xine_get_pos_length( m_stream, &pos, &time, &length ) ) |
256 | return time/1000; | 267 | return time/1000; |
257 | else | 268 | else |
258 | return 0; | 269 | return 0; |
259 | } | 270 | } |
260 | 271 | ||
261 | int Lib::length() const { | 272 | int Lib::length() const { |
262 | assert( m_initialized ); | 273 | assert( m_initialized ); |
263 | 274 | ||
264 | int pos, time, length; | 275 | int pos, time, length; |
265 | /* dilb: patch to solve the wrong stream length reported to the GUI*/ | 276 | /* dilb: patch to solve the wrong stream length reported to the GUI*/ |
266 | int iRetVal=0, iTestLoop=0; | 277 | int iRetVal=0, iTestLoop=0; |
267 | 278 | ||
268 | do | 279 | do |
269 | { | 280 | { |
270 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); | 281 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); |
271 | if (iRetVal) | 282 | if (iRetVal) |
272 | {/* if the function didn't return 0, then pos, time and length are valid.*/ | 283 | {/* if the function didn't return 0, then pos, time and length are valid.*/ |
273 | return length/1000; | 284 | return length/1000; |
274 | } | 285 | } |
275 | /*don't poll too much*/ | 286 | /*don't poll too much*/ |
276 | usleep(100000); | 287 | usleep(100000); |
277 | iTestLoop++; | 288 | iTestLoop++; |
278 | } | 289 | } |
279 | while ( iTestLoop < 10 ); /* if after 1s, we still don't have any | 290 | while ( iTestLoop < 10 ); /* if after 1s, we still don't have any |
280 | valid stream, then return -1 (this value could be used to make the stream | 291 | valid stream, then return -1 (this value could be used to make the stream |
281 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ | 292 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ |
282 | 293 | ||
283 | return -1; | 294 | return -1; |
284 | } | 295 | } |
285 | 296 | ||
286 | bool Lib::isSeekable() const { | 297 | bool Lib::isSeekable() const { |
287 | assert( m_initialized ); | 298 | assert( m_initialized ); |
288 | 299 | ||
289 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); | 300 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); |
290 | } | 301 | } |
291 | 302 | ||
292 | void Lib::seekTo( int time ) { | 303 | void Lib::seekTo( int time ) { |
293 | assert( m_initialized ); | 304 | assert( m_initialized ); |
294 | 305 | ||
295 | odebug << "Seeking to second " << time << oendl; | 306 | odebug << "Seeking to second " << time << oendl; |
296 | //Keep it paused if it was in that state | 307 | //Keep it paused if it was in that state |
297 | if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) { | 308 | if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) { |
298 | xine_play( m_stream, 0, time*1000 ); | 309 | xine_play( m_stream, 0, time*1000 ); |
299 | } | 310 | } |
300 | 311 | ||
301 | else { | 312 | else { |
302 | xine_play( m_stream, 0, time*1000 ); | 313 | xine_play( m_stream, 0, time*1000 ); |
303 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 314 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); |
304 | } | 315 | } |
305 | 316 | ||
306 | } | 317 | } |
307 | 318 | ||
308 | 319 | ||
309 | QString Lib::metaInfo( int number) const { | 320 | QString Lib::metaInfo( int number) const { |
310 | assert( m_initialized ); | 321 | assert( m_initialized ); |
311 | 322 | ||
312 | return xine_get_meta_info( m_stream, number ); | 323 | return xine_get_meta_info( m_stream, number ); |
313 | } | 324 | } |
314 | 325 | ||
315 | int Lib::error() const { | 326 | int Lib::error() const { |
316 | assert( m_initialized ); | 327 | assert( m_initialized ); |
317 | 328 | ||
318 | return xine_get_error( m_stream ); | 329 | return xine_get_error( m_stream ); |
319 | }; | 330 | }; |
320 | 331 | ||
321 | void Lib::ensureInitialized() | 332 | void Lib::ensureInitialized() |
322 | { | 333 | { |
323 | if ( m_initialized ) | 334 | if ( m_initialized ) |
324 | return; | 335 | return; |
325 | 336 | ||
326 | odebug << "waiting for initialization thread to finish" << oendl; | 337 | odebug << "waiting for initialization thread to finish" << oendl; |
327 | wait(); | 338 | wait(); |
328 | odebug << "initialization thread finished!" << oendl; | 339 | odebug << "initialization thread finished!" << oendl; |
329 | } | 340 | } |
330 | 341 | ||
331 | void Lib::setWidget( XineVideoWidget *widget ) | 342 | void Lib::setWidget( XineVideoWidget *widget ) |
332 | { | 343 | { |
333 | m_wid = widget; | 344 | m_wid = widget; |
334 | resize ( m_wid-> size ( ) ); | 345 | if (m_wid) { |
335 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 346 | resize ( m_wid-> size ( ) ); |
336 | m_wid->repaint(); | 347 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
348 | } | ||
337 | } | 349 | } |
338 | 350 | ||
339 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 351 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
340 | { | 352 | { |
341 | assert( sendType == ThreadUtil::Channel::OneWay ); | 353 | assert( sendType == ThreadUtil::Channel::OneWay ); |
342 | handleXineEvent( msg->type(), msg->data(), msg->msg() ); | 354 | handleXineEvent( msg->type(), msg->data(), msg->msg() ); |
343 | delete msg; | 355 | delete msg; |
344 | } | 356 | } |
345 | 357 | ||
346 | void Lib::handleXineEvent( const xine_event_t* t ) { | 358 | void Lib::handleXineEvent( const xine_event_t* t ) { |
347 | int prog = -1; const char* name = 0; | 359 | int prog = -1; const char* name = 0; |
348 | if ( t->type == XINE_EVENT_PROGRESS ) { | 360 | if ( t->type == XINE_EVENT_PROGRESS ) { |
349 | xine_progress_data_t *pt = static_cast<xine_progress_data_t*>( t->data ); | 361 | xine_progress_data_t *pt = static_cast<xine_progress_data_t*>( t->data ); |
350 | prog = pt->percent; | 362 | prog = pt->percent; |
351 | name = pt->description; | 363 | name = pt->description; |
352 | } | 364 | } |
353 | 365 | ||
354 | send( new ThreadUtil::ChannelMessage( t->type, prog, name ), OneWay ); | 366 | send( new ThreadUtil::ChannelMessage( t->type, prog, name ), OneWay ); |
355 | } | 367 | } |
356 | 368 | ||
357 | void Lib::handleXineEvent( int type, int data, const char* name ) { | 369 | void Lib::handleXineEvent( int type, int data, const char* name ) { |
358 | assert( m_initialized ); | 370 | assert( m_initialized ); |
359 | 371 | ||
360 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 372 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
361 | emit stopped(); | 373 | emit stopped(); |
362 | }else if ( type == XINE_EVENT_PROGRESS ) { | 374 | }else if ( type == XINE_EVENT_PROGRESS ) { |
363 | QString str = name == 0 ? QString::null : QString::fromUtf8( name ); | 375 | QString str = name == 0 ? QString::null : QString::fromUtf8( name ); |
364 | Global::statusMessage( tr( "Progress: %1 %2" ).arg( name, data ) );; | 376 | Global::statusMessage( tr( "Progress: %1 %2" ).arg( name, data ) );; |
365 | } | 377 | } |
366 | } | 378 | } |
367 | 379 | ||
368 | 380 | ||
369 | void Lib::setShowVideo( bool video ) { | 381 | void Lib::setShowVideo( bool video ) { |
370 | assert( m_initialized ); | 382 | assert( m_initialized ); |
371 | 383 | ||
372 | m_video = video; | 384 | m_video = video; |
373 | ::null_set_show_video( m_videoOutput, video ); | 385 | ::null_set_show_video( m_videoOutput, video ); |
374 | } | 386 | } |
375 | 387 | ||
376 | bool Lib::isShowingVideo() const { | 388 | bool Lib::isShowingVideo() const { |
377 | assert( m_initialized ); | 389 | assert( m_initialized ); |
378 | 390 | ||
379 | return ::null_is_showing_video( m_videoOutput ); | 391 | return ::null_is_showing_video( m_videoOutput ); |
380 | } | 392 | } |
381 | 393 | ||
382 | bool Lib::hasVideo() const { | 394 | bool Lib::hasVideo() const { |
383 | assert( m_initialized ); | 395 | assert( m_initialized ); |
384 | 396 | ||
@@ -386,52 +398,52 @@ bool Lib::hasVideo() const { | |||
386 | } | 398 | } |
387 | 399 | ||
388 | void Lib::showVideoFullScreen( bool fullScreen ) { | 400 | void Lib::showVideoFullScreen( bool fullScreen ) { |
389 | assert( m_initialized ); | 401 | assert( m_initialized ); |
390 | 402 | ||
391 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 403 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
392 | } | 404 | } |
393 | 405 | ||
394 | bool Lib::isVideoFullScreen() const { | 406 | bool Lib::isVideoFullScreen() const { |
395 | assert( m_initialized ); | 407 | assert( m_initialized ); |
396 | 408 | ||
397 | return ::null_is_fullscreen( m_videoOutput ); | 409 | return ::null_is_fullscreen( m_videoOutput ); |
398 | } | 410 | } |
399 | 411 | ||
400 | void Lib::setScaling( bool scale ) { | 412 | void Lib::setScaling( bool scale ) { |
401 | assert( m_initialized ); | 413 | assert( m_initialized ); |
402 | 414 | ||
403 | ::null_set_scaling( m_videoOutput, scale ); | 415 | ::null_set_scaling( m_videoOutput, scale ); |
404 | } | 416 | } |
405 | 417 | ||
406 | void Lib::setGamma( int value ) { | 418 | void Lib::setGamma( int value ) { |
407 | assert( m_initialized ); | 419 | assert( m_initialized ); |
408 | 420 | ||
409 | ::null_set_videoGamma( m_videoOutput, value ); | 421 | ::null_set_videoGamma( m_videoOutput, value ); |
410 | } | 422 | } |
411 | 423 | ||
412 | bool Lib::isScaling() const { | 424 | bool Lib::isScaling() const { |
413 | assert( m_initialized ); | 425 | assert( m_initialized ); |
414 | 426 | ||
415 | return ::null_is_scaling( m_videoOutput ); | 427 | return ::null_is_scaling( m_videoOutput ); |
416 | } | 428 | } |
417 | 429 | ||
418 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 430 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
419 | ( (Lib*)user_data)->handleXineEvent( t ); | 431 | ( (Lib*)user_data)->handleXineEvent( t ); |
420 | } | 432 | } |
421 | 433 | ||
422 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 434 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
423 | int width, int height, int bytes ) { | 435 | int width, int height, int bytes ) { |
424 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 436 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
425 | } | 437 | } |
426 | 438 | ||
427 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 439 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
428 | assert( m_initialized ); | 440 | assert( m_initialized ); |
429 | 441 | ||
430 | if ( !m_video ) { | 442 | if ( !m_video ) { |
431 | return; | 443 | return; |
432 | } | 444 | } |
433 | 445 | ||
434 | assert( m_wid ); | 446 | // assert( m_wid ); |
435 | 447 | ||
436 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 448 | if (m_wid) m_wid-> setVideoFrame ( frame, width, height, bytes ); |
437 | } | 449 | } |
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index ab432a0..2f5bf86 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h | |||
@@ -1,115 +1,116 @@ | |||
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 | #ifndef XINE_VIDEO_LIB_H | 34 | #ifndef XINE_VIDEO_LIB_H |
35 | #define XINE_VIDEO_LIB_H | 35 | #define XINE_VIDEO_LIB_H |
36 | 36 | ||
37 | #include <xine.h> | 37 | #include <xine.h> |
38 | 38 | ||
39 | #include "threadutil.h" | 39 | #include "threadutil.h" |
40 | 40 | ||
41 | class XineVideoWidget; | 41 | class XineVideoWidget; |
42 | 42 | ||
43 | namespace XINE { | 43 | namespace XINE { |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Lib wrapps the simple interface | 46 | * Lib wrapps the simple interface |
47 | * of libxine for easy every day use | 47 | * of libxine for easy every day use |
48 | * This will become a full C++ Wrapper | 48 | * This will become a full C++ Wrapper |
49 | * It supports playing, pausing, info, | 49 | * It supports playing, pausing, info, |
50 | * stooping, seeking. | 50 | * stooping, seeking. |
51 | */ | 51 | */ |
52 | class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread | 52 | class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread |
53 | { | 53 | { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
56 | enum InitializationMode { InitializeImmediately, InitializeInThread }; | 56 | enum InitializationMode { InitializeImmediately, InitializeInThread }; |
57 | 57 | ||
58 | Lib( InitializationMode initMode, XineVideoWidget* = 0); | 58 | Lib( InitializationMode initMode, XineVideoWidget* = 0); |
59 | 59 | ||
60 | ~Lib(); | 60 | ~Lib(); |
61 | static int majorVersion(); | 61 | static int majorVersion(); |
62 | static int minorVersion(); | 62 | static int minorVersion(); |
63 | static int subVersion(); | 63 | static int subVersion(); |
64 | 64 | ||
65 | 65 | ||
66 | void resize ( const QSize &s ); | 66 | void resize ( const QSize &s ); |
67 | 67 | ||
68 | int setfile(const QString& fileName); | ||
68 | int play( const QString& fileName, | 69 | int play( const QString& fileName, |
69 | int startPos = 0, | 70 | int startPos = 0, |
70 | int start_time = 0 ); | 71 | int start_time = 0 ); |
71 | void stop(); | 72 | void stop(); |
72 | void pause( bool toggle ); | 73 | void pause( bool toggle ); |
73 | 74 | ||
74 | int speed() const; | 75 | int speed() const; |
75 | 76 | ||
76 | /** | 77 | /** |
77 | * Set the speed of the stream, if codec supports it | 78 | * Set the speed of the stream, if codec supports it |
78 | * XINE_SPEED_PAUSE 0 | 79 | * XINE_SPEED_PAUSE 0 |
79 | * XINE_SPEED_SLOW_4 1 | 80 | * XINE_SPEED_SLOW_4 1 |
80 | * XINE_SPEED_SLOW_2 2 | 81 | * XINE_SPEED_SLOW_2 2 |
81 | * XINE_SPEED_NORMAL 4 | 82 | * XINE_SPEED_NORMAL 4 |
82 | * XINE_SPEED_FAST_2 8 | 83 | * XINE_SPEED_FAST_2 8 |
83 | *XINE_SPEED_FAST_4 16 | 84 | *XINE_SPEED_FAST_4 16 |
84 | */ | 85 | */ |
85 | void setSpeed( int speed = XINE_SPEED_PAUSE ); | 86 | void setSpeed( int speed = XINE_SPEED_PAUSE ); |
86 | 87 | ||
87 | int status() const; | 88 | int status() const; |
88 | 89 | ||
89 | int currentPosition()const; | 90 | int currentPosition()const; |
90 | //in seconds | 91 | //in seconds |
91 | int currentTime()const; | 92 | int currentTime()const; |
92 | 93 | ||
93 | int length() const; | 94 | int length() const; |
94 | 95 | ||
95 | bool isSeekable()const; | 96 | bool isSeekable()const; |
96 | 97 | ||
97 | /** | 98 | /** |
98 | * Whether or not to show video output | 99 | * Whether or not to show video output |
99 | */ | 100 | */ |
100 | void setShowVideo(bool video); | 101 | void setShowVideo(bool video); |
101 | 102 | ||
102 | /** | 103 | /** |
103 | * is we show video | 104 | * is we show video |
104 | */ | 105 | */ |
105 | bool isShowingVideo() const; | 106 | bool isShowingVideo() const; |
106 | 107 | ||
107 | /** | 108 | /** |
108 | * | 109 | * |
109 | */ | 110 | */ |
110 | void showVideoFullScreen( bool fullScreen ); | 111 | void showVideoFullScreen( bool fullScreen ); |
111 | 112 | ||
112 | /** | 113 | /** |
113 | * | 114 | * |
114 | */ | 115 | */ |
115 | bool isVideoFullScreen() const; | 116 | bool isVideoFullScreen() const; |
@@ -145,66 +146,66 @@ namespace XINE { | |||
145 | * @return is media stream has video | 146 | * @return is media stream has video |
146 | */ | 147 | */ |
147 | bool hasVideo() const; | 148 | bool hasVideo() const; |
148 | 149 | ||
149 | /** | 150 | /** |
150 | * | 151 | * |
151 | */ | 152 | */ |
152 | void setScaling( bool ); | 153 | void setScaling( bool ); |
153 | 154 | ||
154 | /** | 155 | /** |
155 | * Set the Gamma value for video output | 156 | * Set the Gamma value for video output |
156 | * @param int the value between -100 and 100, 0 is original | 157 | * @param int the value between -100 and 100, 0 is original |
157 | */ | 158 | */ |
158 | void setGamma( int ); | 159 | void setGamma( int ); |
159 | 160 | ||
160 | /** | 161 | /** |
161 | * Returns the error code | 162 | * Returns the error code |
162 | * XINE_ERROR_NONE 0 | 163 | * XINE_ERROR_NONE 0 |
163 | * XINE_ERROR_NO_INPUT_PLUGIN 1 | 164 | * XINE_ERROR_NO_INPUT_PLUGIN 1 |
164 | * XINE_ERROR_NO_DEMUXER_PLUGIN 2 | 165 | * XINE_ERROR_NO_DEMUXER_PLUGIN 2 |
165 | * XINE_ERROR_DEMUXER_FAILED 3 | 166 | * XINE_ERROR_DEMUXER_FAILED 3 |
166 | */ | 167 | */ |
167 | int error() const; | 168 | int error() const; |
168 | 169 | ||
169 | void ensureInitialized(); | 170 | void ensureInitialized(); |
170 | 171 | ||
171 | void setWidget( XineVideoWidget *widget ); | 172 | void setWidget( XineVideoWidget *widget ); |
172 | 173 | ||
173 | signals: | 174 | signals: |
174 | 175 | ||
175 | void stopped(); | 176 | void stopped(); |
176 | 177 | ||
177 | void initialized(); | 178 | void initialized(); |
178 | 179 | ||
179 | protected: | 180 | protected: |
180 | virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); | 181 | virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); |
181 | 182 | ||
182 | virtual void run(); | 183 | virtual void run(); |
183 | 184 | ||
184 | private: | 185 | private: |
185 | void initialize(); | 186 | void initialize(); |
186 | 187 | ||
187 | int m_bytes_per_pixel; | 188 | int m_bytes_per_pixel; |
188 | bool m_initialized:1; | 189 | bool m_initialized:1; |
189 | bool m_duringInitialization:1; | 190 | bool m_duringInitialization:1; |
190 | bool m_video:1; | 191 | bool m_video:1; |
191 | XineVideoWidget *m_wid; | 192 | XineVideoWidget *m_wid; |
192 | xine_t *m_xine; | 193 | xine_t *m_xine; |
193 | xine_stream_t *m_stream; | 194 | xine_stream_t *m_stream; |
194 | xine_cfg_entry_t *m_config; | 195 | xine_cfg_entry_t *m_config; |
195 | xine_vo_driver_t *m_videoOutput; | 196 | xine_vo_driver_t *m_videoOutput; |
196 | xine_ao_driver_t* m_audioOutput; | 197 | xine_ao_driver_t* m_audioOutput; |
197 | xine_event_queue_t *m_queue; | 198 | xine_event_queue_t *m_queue; |
198 | 199 | ||
199 | void handleXineEvent( const xine_event_t* t ); | 200 | void handleXineEvent( const xine_event_t* t ); |
200 | void handleXineEvent( int type, int data, const char* name ); | 201 | void handleXineEvent( int type, int data, const char* name ); |
201 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); | 202 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); |
202 | // C -> C++ bridge for the event system | 203 | // C -> C++ bridge for the event system |
203 | static void xine_event_handler( void* user_data, const xine_event_t* t); | 204 | static void xine_event_handler( void* user_data, const xine_event_t* t); |
204 | static void xine_display_frame( void* user_data, uint8_t* frame , | 205 | static void xine_display_frame( void* user_data, uint8_t* frame , |
205 | int width, int height, int bytes ); | 206 | int width, int height, int bytes ); |
206 | }; | 207 | }; |
207 | }; | 208 | }; |
208 | 209 | ||
209 | 210 | ||
210 | #endif | 211 | #endif |
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 211791b..7f59085 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -126,222 +126,214 @@ XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | |||
126 | m_bytes_per_line_fb = qt_screen-> linestep ( ); | 126 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
127 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | 127 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
128 | m_rotation = 0; | 128 | m_rotation = 0; |
129 | m_lastsize = 0; | 129 | m_lastsize = 0; |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | XineVideoWidget::~XineVideoWidget ( ) | 133 | XineVideoWidget::~XineVideoWidget ( ) |
134 | { | 134 | { |
135 | ThreadUtil::AutoLock a(m_bufmutex); | 135 | ThreadUtil::AutoLock a(m_bufmutex); |
136 | if (m_buff) { | 136 | if (m_buff) { |
137 | delete[]m_buff; | 137 | delete[]m_buff; |
138 | m_lastsize=0; | 138 | m_lastsize=0; |
139 | m_buff = 0; | 139 | m_buff = 0; |
140 | } | 140 | } |
141 | if (m_logo) { | 141 | if (m_logo) { |
142 | delete m_logo; | 142 | delete m_logo; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | void XineVideoWidget::clear ( ) | 146 | void XineVideoWidget::clear ( ) |
147 | { | 147 | { |
148 | ThreadUtil::AutoLock a(m_bufmutex); | 148 | ThreadUtil::AutoLock a(m_bufmutex); |
149 | if (m_buff) { | 149 | if (m_buff) { |
150 | delete[]m_buff; | 150 | delete[]m_buff; |
151 | m_lastsize=0; | 151 | m_lastsize=0; |
152 | m_buff = 0; | 152 | m_buff = 0; |
153 | } | 153 | } |
154 | repaint ( false ); | 154 | repaint ( false ); |
155 | } | 155 | } |
156 | 156 | ||
157 | QSize XineVideoWidget::videoSize() const | 157 | QSize XineVideoWidget::videoSize() const |
158 | { | 158 | { |
159 | QSize s = size(); | 159 | QSize s = size(); |
160 | bool fs = ( s == qApp->desktop()->size() ); | 160 | bool fs = ( s == qApp->desktop()->size() ); |
161 | 161 | ||
162 | // if we are in fullscreen mode, do not rotate the video | 162 | // if we are in fullscreen mode, do not rotate the video |
163 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | 163 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) |
164 | m_rotation = fs ? - qt_screen->transformOrientation() : 0; | 164 | m_rotation = fs ? - qt_screen->transformOrientation() : 0; |
165 | 165 | ||
166 | if ( fs && qt_screen->isTransformed() ) | 166 | if ( fs && qt_screen->isTransformed() ) |
167 | s = qt_screen->mapToDevice( s ); | 167 | s = qt_screen->mapToDevice( s ); |
168 | 168 | ||
169 | return s; | 169 | return s; |
170 | } | 170 | } |
171 | 171 | ||
172 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 172 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
173 | { | 173 | { |
174 | if (m_bufmutex.isLocked()) { | ||
175 | return; | ||
176 | } | ||
174 | ThreadUtil::AutoLock a(m_bufmutex); | 177 | ThreadUtil::AutoLock a(m_bufmutex); |
175 | QPainter p ( this ); | 178 | QPainter p ( this ); |
176 | p. fillRect ( rect (), black ); | 179 | p. fillRect ( rect (), black ); |
177 | if (m_logo) | 180 | if (m_logo) |
178 | p. drawImage ( 0, 0, *m_logo ); | 181 | p. drawImage ( 0, 0, *m_logo ); |
179 | } | 182 | } |
180 | 183 | ||
181 | void XineVideoWidget::paintEvent2 ( QPaintEvent * ) | 184 | void XineVideoWidget::paintEvent2 ( QPaintEvent * ) |
182 | { | 185 | { |
183 | ThreadUtil::AutoLock a(m_bufmutex); | 186 | ThreadUtil::AutoLock a(m_bufmutex); |
187 | QPainter p (this); | ||
184 | if ( m_buff == 0 ) { | 188 | if ( m_buff == 0 ) { |
185 | QPainter p ( this ); | ||
186 | p. fillRect ( rect ( ), black ); | 189 | p. fillRect ( rect ( ), black ); |
187 | if ( m_logo ) | 190 | if ( m_logo ) |
188 | p. drawImage ( 0, 0, *m_logo ); | 191 | p. drawImage ( 0, 0, *m_logo ); |
189 | } | 192 | } else if (m_lastsize){ |
190 | else { | ||
191 | // Qt needs to be notified which areas were really updated .. strange | 193 | // Qt needs to be notified which areas were really updated .. strange |
192 | QArray <QRect> qt_bug_workaround_clip_rects; | 194 | QArray <QRect> qt_bug_workaround_clip_rects; |
193 | 195 | ||
194 | { | 196 | { |
195 | QDirectPainter dp ( this ); | 197 | QDirectPainter dp ( this ); |
196 | 198 | ||
197 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation | 199 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation |
198 | 200 | ||
201 | bool rot90 = (( -m_rotation ) & 1 ); | ||
202 | |||
203 | int _vw,_vh; | ||
204 | switch (rot90) { | ||
205 | case true: | ||
206 | _vh = m_framesize.width(); | ||
207 | _vw = m_framesize.height(); | ||
208 | break; | ||
209 | default: | ||
210 | _vw = m_framesize.width(); | ||
211 | _vh = m_framesize.height(); | ||
212 | break; | ||
213 | break; | ||
214 | } | ||
215 | int middle_w = _vw/2; | ||
216 | int middle_h = _vh/2; | ||
217 | m_thisframe.setRect(width()/2-middle_w,height()/2-middle_h,_vw,_vh); | ||
218 | QRect topFill,rightFill,leftFill,downFill; | ||
219 | topFill. setRect(0,0 ,width(),m_thisframe.top()); | ||
220 | downFill.setCoords(0,m_thisframe.bottom(),width(),height()); | ||
221 | rightFill.setCoords(m_thisframe.right(),0,width(),height()); | ||
222 | leftFill.setCoords(0,0,m_thisframe.left(),height()); | ||
223 | |||
224 | if (topFill.isValid()) { | ||
225 | p.fillRect(topFill,black); | ||
226 | } | ||
227 | if (downFill.isValid()) { | ||
228 | p.fillRect(downFill,black); | ||
229 | } | ||
230 | if (rightFill.isValid()) { | ||
231 | p.fillRect(rightFill,black); | ||
232 | } | ||
233 | if (leftFill.isValid()) { | ||
234 | p.fillRect(leftFill,black); | ||
235 | } | ||
199 | uchar *fb = dp. frameBuffer ( ); | 236 | uchar *fb = dp. frameBuffer ( ); |
200 | uchar *frame = m_buff; | 237 | uchar *frame = m_buff; |
201 | 238 | ||
202 | // where is the video frame in fb coordinates | 239 | // where is the video frame in fb coordinates |
203 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 240 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), |
204 | 241 | qt_screen-> height ( ))); | |
205 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 242 | |
206 | 243 | uchar * src = frame; | |
207 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { | 244 | uchar * dst = fb+framerect.y()*m_bytes_per_line_fb+framerect.x()*m_bytes_per_pixel; |
208 | const QRect &clip = dp. rect ( i ); | 245 | |
209 | 246 | for (int y=framerect.top();y<=framerect.bottom();++y) { | |
210 | qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 247 | switch (rot) { |
211 | 248 | case 0: | |
212 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb | 249 | memcpy(dst,src,m_bytes_per_line_frame); |
213 | uchar *src = frame; | 250 | src+=m_bytes_per_line_frame; |
214 | 251 | break; | |
215 | // Adjust the start the source data based on the rotation (xine frame) | 252 | case 1: |
216 | switch ( rot ) { | 253 | memcpy_step ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame ); |
217 | case 0: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame )); break; | 254 | src -= m_bytes_per_pixel; |
218 | case 1: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel )); break; | 255 | break; |
219 | case 2: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame )); break; | 256 | case 2: |
220 | case 3: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame )); break; | 257 | memcpy_rev ( dst, src, m_thisframe.size().width()); |
221 | default: break; | 258 | src-=m_bytes_per_line_frame; |
222 | } | 259 | break; |
223 | 260 | case 3: | |
224 | // all of the following widths/heights are fb relative (0deg rotation) | 261 | memcpy_step_rev ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame ); |
225 | 262 | src += m_bytes_per_pixel; | |
226 | uint leftfill = 0; // black border on the "left" side of the video frame | 263 | break; |
227 | uint framefill = 0; // "width" of the video frame | 264 | default: |
228 | uint rightfill = 0; // black border on the "right" side of the video frame | 265 | break; |
229 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect | ||
230 | |||
231 | if ( clip. left ( ) < framerect. left ( )) | ||
232 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; | ||
233 | if ( clip. right ( ) > framerect. right ( )) | ||
234 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; | ||
235 | |||
236 | framefill = clipwidth - ( leftfill + rightfill ); | ||
237 | |||
238 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | ||
239 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | ||
240 | // "above" or "below" the video -> black | ||
241 | memset ( dst, 0, clipwidth ); | ||
242 | } | ||
243 | else { | ||
244 | if ( leftfill ) | ||
245 | memset ( dst, 0, leftfill ); // "left" border -> black | ||
246 | |||
247 | if ( framefill ) { // blit in the video frame | ||
248 | // see above for an explanation of the different memcpys | ||
249 | |||
250 | switch ( rot ) { | ||
251 | case 0: memcpy ( dst + leftfill, src, framefill & ~1 ); break; | ||
252 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | ||
253 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | ||
254 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | ||
255 | default: break; | ||
256 | } | ||
257 | } | ||
258 | if ( rightfill ) | ||
259 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black | ||
260 | } | ||
261 | |||
262 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer | ||
263 | |||
264 | // advance one "line" in the xine frame data | ||
265 | switch ( rot ) { | ||
266 | case 0: src += m_bytes_per_line_frame; break; | ||
267 | case 1: src -= m_bytes_per_pixel; break; | ||
268 | case 2: src -= m_bytes_per_line_frame; break; | ||
269 | case 3: src += m_bytes_per_pixel; break; | ||
270 | default: break; | ||
271 | } | ||
272 | } | 266 | } |
267 | dst += m_bytes_per_line_fb; | ||
273 | } | 268 | } |
274 | } | 269 | } |
275 | 270 | ||
271 | |||
276 | { | 272 | { |
277 | // QVFB hack by Martin Jones | 273 | // QVFB hack by Martin Jones |
278 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter | 274 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter |
279 | 275 | p.fillRect(QRect(mapFromGlobal (m_thisframe. topLeft ( )), m_thisframe.size ()),QBrush(NoBrush)); | |
280 | QPainter p ( this ); | ||
281 | |||
282 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | ||
283 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); | ||
284 | } | ||
285 | } | 276 | } |
286 | } | 277 | } |
287 | } | 278 | } |
288 | 279 | ||
289 | |||
290 | QImage *XineVideoWidget::logo ( ) const | 280 | QImage *XineVideoWidget::logo ( ) const |
291 | { | 281 | { |
292 | return m_logo; | 282 | return m_logo; |
293 | } | 283 | } |
294 | 284 | ||
295 | 285 | ||
296 | void XineVideoWidget::setLogo ( QImage* logo ) | 286 | void XineVideoWidget::setLogo ( QImage* logo ) |
297 | { | 287 | { |
298 | delete m_logo; | 288 | delete m_logo; |
299 | m_logo = logo; | 289 | m_logo = logo; |
300 | } | 290 | } |
301 | 291 | ||
302 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) | 292 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) |
303 | { | 293 | { |
304 | // mutex area for AutoLock | 294 | // mutex area for AutoLock |
305 | { | 295 | { |
306 | if (m_bufmutex.isLocked()) { | 296 | if (m_bufmutex.isLocked()||w>width()||h>height()) { |
307 | // no time to wait - drop frame | 297 | // no time to wait - drop frame |
308 | return; | 298 | return; |
309 | } | 299 | } |
310 | ThreadUtil::AutoLock a(m_bufmutex); | 300 | ThreadUtil::AutoLock a(m_bufmutex); |
311 | bool rot90 = (( -m_rotation ) & 1 ); | 301 | bool rot90 = (( -m_rotation ) & 1 ); |
312 | int l = h*m_bytes_per_pixel*w; | 302 | int l = h*bpl; |
313 | if (l>m_lastsize) { | 303 | if (l!=m_lastsize) { |
314 | if (m_buff) { | 304 | if (m_buff) { |
315 | delete[]m_buff; | 305 | delete[]m_buff; |
316 | } | 306 | } |
317 | m_buff = new uchar[l]; | 307 | if (l>0) { |
318 | m_lastsize=l; | 308 | m_buff = new uchar[l]; |
309 | odebug << "Point to: " << (unsigned long)m_buff << oendl; | ||
310 | m_lastsize=l; | ||
311 | } else { | ||
312 | m_buff = 0; | ||
313 | } | ||
314 | } else if (l==0){ | ||
315 | delete[] m_buff; | ||
316 | m_buff = 0; | ||
319 | } | 317 | } |
320 | 318 | m_lastsize = l; | |
321 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height | 319 | m_framesize = QSize(w,h); |
322 | int d = w; | 320 | if (m_buff && m_lastsize) { |
323 | w = h; | 321 | memcpy(m_buff,img,m_lastsize); |
324 | h = d; | ||
325 | } | 322 | } |
326 | |||
327 | m_lastframe = m_thisframe; | ||
328 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | ||
329 | |||
330 | memcpy(m_buff,img,m_lastsize); | ||
331 | m_bytes_per_line_frame = bpl; | 323 | m_bytes_per_line_frame = bpl; |
332 | } // Release Mutex | 324 | } // Release Mutex |
333 | 325 | ||
334 | paintEvent2(0); | 326 | paintEvent2(0); |
335 | } | 327 | } |
336 | 328 | ||
337 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 329 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
338 | { | 330 | { |
339 | emit videoResized( videoSize() ); | 331 | emit videoResized( videoSize() ); |
340 | } | 332 | } |
341 | 333 | ||
342 | 334 | ||
343 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) | 335 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) |
344 | { | 336 | { |
345 | emit clicked(); | 337 | emit clicked(); |
346 | } | 338 | } |
347 | 339 | ||
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h index 7f00aaa..eccff1a 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.h +++ b/noncore/multimedia/opieplayer2/xinevideowidget.h | |||
@@ -28,53 +28,54 @@ | |||
28 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. | 28 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
29 | If not, write to the Free Software Foundation, | 29 | If not, write to the Free Software Foundation, |
30 | Inc., 59 Temple Place - Suite 330, | 30 | Inc., 59 Temple Place - Suite 330, |
31 | Boston, MA 02111-1307, USA. | 31 | Boston, MA 02111-1307, USA. |
32 | 32 | ||
33 | */ | 33 | */ |
34 | 34 | ||
35 | 35 | ||
36 | #include <qwidget.h> | 36 | #include <qwidget.h> |
37 | 37 | ||
38 | #include "lib.h" | 38 | #include "lib.h" |
39 | 39 | ||
40 | class QImage; | 40 | class QImage; |
41 | 41 | ||
42 | 42 | ||
43 | class XineVideoWidget : public QWidget { | 43 | class XineVideoWidget : public QWidget { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | 45 | ||
46 | public: | 46 | public: |
47 | XineVideoWidget ( QWidget* parent, const char* name ); | 47 | XineVideoWidget ( QWidget* parent, const char* name ); |
48 | ~XineVideoWidget ( ); | 48 | ~XineVideoWidget ( ); |
49 | QImage *logo ( ) const; | 49 | QImage *logo ( ) const; |
50 | void setLogo ( QImage *image ); | 50 | void setLogo ( QImage *image ); |
51 | void setVideoFrame ( uchar *image, int width, int height, int linestep ); | 51 | void setVideoFrame ( uchar *image, int width, int height, int linestep ); |
52 | void clear ( ); | 52 | void clear ( ); |
53 | 53 | ||
54 | QSize videoSize() const; | 54 | QSize videoSize() const; |
55 | 55 | ||
56 | protected: | 56 | protected: |
57 | void paintEvent2( QPaintEvent *p ); | 57 | void paintEvent2( QPaintEvent *p ); |
58 | virtual void paintEvent(QPaintEvent*); | 58 | virtual void paintEvent(QPaintEvent*); |
59 | virtual void resizeEvent ( QResizeEvent *r ); | 59 | virtual void resizeEvent ( QResizeEvent *r ); |
60 | 60 | ||
61 | void mouseReleaseEvent ( QMouseEvent *e ); | 61 | void mouseReleaseEvent ( QMouseEvent *e ); |
62 | 62 | ||
63 | signals: | 63 | signals: |
64 | void clicked ( ); | 64 | void clicked ( ); |
65 | void videoResized ( const QSize &s ); | 65 | void videoResized ( const QSize &s ); |
66 | 66 | ||
67 | private: | 67 | private: |
68 | QRect m_lastframe; | 68 | QRect m_lastframe; |
69 | QRect m_thisframe; | 69 | QRect m_thisframe; |
70 | 70 | ||
71 | uchar *m_buff; | 71 | uchar *m_buff; |
72 | int m_bytes_per_line_fb; | 72 | int m_bytes_per_line_fb; |
73 | int m_bytes_per_line_frame; | 73 | int m_bytes_per_line_frame; |
74 | int m_bytes_per_pixel; | 74 | int m_bytes_per_pixel; |
75 | int m_lastsize; | 75 | int m_lastsize; |
76 | QSize m_framesize; | ||
76 | QImage *m_logo; | 77 | QImage *m_logo; |
77 | mutable int m_rotation; | 78 | mutable int m_rotation; |
78 | ThreadUtil::Mutex m_bufmutex; | 79 | ThreadUtil::Mutex m_bufmutex; |
79 | }; | 80 | }; |
80 | 81 | ||