Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index a42b8e5..5c24dbe 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -13,420 +13,420 @@ | |||
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 | 34 | ||
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | 38 | ||
39 | #include <qgfx_qws.h> | 39 | #include <qgfx_qws.h> |
40 | 40 | ||
41 | #include <assert.h> | 41 | #include <assert.h> |
42 | 42 | ||
43 | #include "xinevideowidget.h" | 43 | #include "xinevideowidget.h" |
44 | #include "frame.h" | 44 | #include "frame.h" |
45 | #include "lib.h" | 45 | #include "lib.h" |
46 | 46 | ||
47 | 47 | ||
48 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 48 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
49 | int width, int height,int bytes ); | 49 | int width, int height,int bytes ); |
50 | 50 | ||
51 | extern "C" { | 51 | extern "C" { |
52 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); | 52 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); |
53 | int null_is_showing_video( const xine_vo_driver_t* self ); | 53 | int null_is_showing_video( const xine_vo_driver_t* self ); |
54 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 54 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
55 | int null_is_fullscreen( const xine_vo_driver_t* self ); | 55 | int null_is_fullscreen( const xine_vo_driver_t* self ); |
56 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); | 56 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); |
57 | int null_is_scaling( const xine_vo_driver_t* self ); | 57 | int null_is_scaling( const xine_vo_driver_t* self ); |
58 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); | 58 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); |
59 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); | 59 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); |
60 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | 60 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
61 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 61 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
62 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | 62 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
63 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 63 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
64 | 64 | ||
65 | void null_preload_decoders( xine_stream_t *stream ); | 65 | void null_preload_decoders( xine_stream_t *stream ); |
66 | } | 66 | } |
67 | 67 | ||
68 | using namespace XINE; | 68 | using namespace XINE; |
69 | 69 | ||
70 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) | 70 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) |
71 | { | 71 | { |
72 | m_initialized = false; | 72 | m_initialized = false; |
73 | m_duringInitialization = false; | 73 | m_duringInitialization = false; |
74 | m_video = false; | 74 | m_video = false; |
75 | m_wid = widget; | 75 | m_wid = widget; |
76 | printf("Lib"); | 76 | printf("Lib"); |
77 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 77 | QString configPath = QDir::homeDirPath() + "/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::exists(configPath) ) { | 81 | if ( !QFile::exists(configPath) ) { |
82 | QFile f(configPath); | 82 | QFile f(configPath); |
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 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; | 86 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; |
87 | ts << "codec.ffmpeg_pp_quality:3\n"; | 87 | ts << "codec.ffmpeg_pp_quality:3\n"; |
88 | ts << "audio.num_buffers:50\n"; | 88 | ts << "audio.num_buffers:50\n"; |
89 | ts << "audio.size_buffers:4096\n"; | 89 | ts << "audio.size_buffers:4096\n"; |
90 | ts << "video.num_buffers:20\n"; | 90 | ts << "video.num_buffers:20\n"; |
91 | ts << "video.size_buffers:4096\n"; | 91 | ts << "video.size_buffers:4096\n"; |
92 | ts << "audio.out_num_audio_buf:16\n"; | 92 | ts << "audio.out_num_audio_buf:16\n"; |
93 | ts << "audio.out_size_audio_buf:8096\n"; | 93 | ts << "audio.out_size_audio_buf:8096\n"; |
94 | ts << "audio.out_size_zero_buf:1024\n"; | 94 | ts << "audio.out_size_zero_buf:1024\n"; |
95 | ts << "audio.passthrough_offset:0\n"; | 95 | ts << "audio.passthrough_offset:0\n"; |
96 | f.close(); | 96 | f.close(); |
97 | } | 97 | } |
98 | 98 | ||
99 | if ( initMode == InitializeImmediately ) { | 99 | if ( initMode == InitializeImmediately ) { |
100 | initialize(); | 100 | initialize(); |
101 | m_initialized = true; | 101 | m_initialized = true; |
102 | } | 102 | } |
103 | else | 103 | else |
104 | start(); | 104 | start(); |
105 | } | 105 | } |
106 | 106 | ||
107 | void Lib::run() | 107 | void Lib::run() |
108 | { | 108 | { |
109 | qDebug( "Lib::run() started" ); | 109 | odebug << "Lib::run() started" << oendl; |
110 | initialize(); | 110 | initialize(); |
111 | m_initialized = true; | 111 | m_initialized = true; |
112 | qDebug( "Lib::run() finished" ); | 112 | odebug << "Lib::run() finished" << oendl; |
113 | } | 113 | } |
114 | 114 | ||
115 | void Lib::initialize() | 115 | void Lib::initialize() |
116 | { | 116 | { |
117 | m_duringInitialization = true; | 117 | m_duringInitialization = true; |
118 | m_xine = xine_new( ); | 118 | m_xine = xine_new( ); |
119 | 119 | ||
120 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 120 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
121 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); | 121 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); |
122 | 122 | ||
123 | xine_init( m_xine ); | 123 | xine_init( m_xine ); |
124 | 124 | ||
125 | // allocate oss for sound | 125 | // allocate oss for sound |
126 | // and fb for framebuffer | 126 | // and fb for framebuffer |
127 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); | 127 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
128 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); | 128 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); |
129 | 129 | ||
130 | 130 | ||
131 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); | 131 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); |
132 | 132 | ||
133 | 133 | ||
134 | // null_display_handler( m_videoOutput, xine_display_frame, this ); | 134 | // null_display_handler( m_videoOutput, xine_display_frame, this ); |
135 | 135 | ||
136 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 136 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
137 | 137 | ||
138 | if (m_wid != 0 ) { | 138 | if (m_wid != 0 ) { |
139 | printf( "!0\n" ); | 139 | printf( "!0\n" ); |
140 | setWidget( m_wid ); | 140 | setWidget( m_wid ); |
141 | } | 141 | } |
142 | 142 | ||
143 | m_queue = xine_event_new_queue (m_stream); | 143 | m_queue = xine_event_new_queue (m_stream); |
144 | 144 | ||
145 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 145 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
146 | 146 | ||
147 | ::null_preload_decoders( m_stream ); | 147 | ::null_preload_decoders( m_stream ); |
148 | 148 | ||
149 | m_duringInitialization = false; | 149 | m_duringInitialization = false; |
150 | } | 150 | } |
151 | 151 | ||
152 | Lib::~Lib() { | 152 | Lib::~Lib() { |
153 | assert( isRunning() == false ); | 153 | assert( isRunning() == false ); |
154 | assert( m_initialized ); | 154 | assert( m_initialized ); |
155 | 155 | ||
156 | // free( m_config ); | 156 | // free( m_config ); |
157 | 157 | ||
158 | xine_close( m_stream ); | 158 | xine_close( m_stream ); |
159 | 159 | ||
160 | xine_event_dispose_queue( m_queue ); | 160 | xine_event_dispose_queue( m_queue ); |
161 | 161 | ||
162 | xine_dispose( m_stream ); | 162 | xine_dispose( m_stream ); |
163 | 163 | ||
164 | xine_exit( m_xine ); | 164 | xine_exit( m_xine ); |
165 | /* FIXME either free or delete but valgrind bitches against both */ | 165 | /* FIXME either free or delete but valgrind bitches against both */ |
166 | //free( m_videoOutput ); | 166 | //free( m_videoOutput ); |
167 | //delete m_audioOutput; | 167 | //delete m_audioOutput; |
168 | } | 168 | } |
169 | 169 | ||
170 | void Lib::resize ( const QSize &s ) { | 170 | void Lib::resize ( const QSize &s ) { |
171 | assert( m_initialized || m_duringInitialization ); | 171 | assert( m_initialized || m_duringInitialization ); |
172 | 172 | ||
173 | if ( s. width ( ) && s. height ( ) ) { | 173 | if ( s. width ( ) && s. height ( ) ) { |
174 | ::null_set_gui_width( m_videoOutput, s. width() ); | 174 | ::null_set_gui_width( m_videoOutput, s. width() ); |
175 | ::null_set_gui_height( m_videoOutput, s. height() ); | 175 | ::null_set_gui_height( m_videoOutput, s. height() ); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | int Lib::majorVersion() { | 179 | int Lib::majorVersion() { |
180 | int major, minor, sub; | 180 | int major, minor, sub; |
181 | xine_get_version ( &major, &minor, &sub ); | 181 | xine_get_version ( &major, &minor, &sub ); |
182 | return major; | 182 | return major; |
183 | } | 183 | } |
184 | 184 | ||
185 | int Lib::minorVersion() { | 185 | int Lib::minorVersion() { |
186 | int major, minor, sub; | 186 | int major, minor, sub; |
187 | xine_get_version ( &major, &minor, &sub ); | 187 | xine_get_version ( &major, &minor, &sub ); |
188 | return minor; | 188 | return minor; |
189 | } | 189 | } |
190 | 190 | ||
191 | int Lib::subVersion() { | 191 | int Lib::subVersion() { |
192 | int major, minor, sub; | 192 | int major, minor, sub; |
193 | xine_get_version ( &major, &minor, &sub ); | 193 | xine_get_version ( &major, &minor, &sub ); |
194 | return sub; | 194 | return sub; |
195 | } | 195 | } |
196 | 196 | ||
197 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 197 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
198 | assert( m_initialized ); | 198 | assert( m_initialized ); |
199 | // FIXME actually a hack imho. Should not be needed to dispose the whole stream | 199 | // FIXME actually a hack imho. Should not be needed to dispose the whole stream |
200 | // but without we get wrong media length reads from libxine for the second media | 200 | // but without we get wrong media length reads from libxine for the second media |
201 | //xine_dispose ( m_stream ); | 201 | //xine_dispose ( m_stream ); |
202 | 202 | ||
203 | QString str = fileName.stripWhiteSpace(); | 203 | QString str = fileName.stripWhiteSpace(); |
204 | 204 | ||
205 | //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 205 | //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
206 | //m_queue = xine_event_new_queue (m_stream); | 206 | //m_queue = xine_event_new_queue (m_stream); |
207 | //xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 207 | //xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
208 | 208 | ||
209 | if ( !xine_open( m_stream, str.utf8().data() ) ) { | 209 | if ( !xine_open( m_stream, str.utf8().data() ) ) { |
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | return xine_play( m_stream, startPos, start_time); | 212 | return xine_play( m_stream, startPos, start_time); |
213 | } | 213 | } |
214 | 214 | ||
215 | void Lib::stop() { | 215 | void Lib::stop() { |
216 | assert( m_initialized ); | 216 | assert( m_initialized ); |
217 | 217 | ||
218 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 218 | odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl; |
219 | xine_stop( m_stream ); | 219 | xine_stop( m_stream ); |
220 | } | 220 | } |
221 | 221 | ||
222 | void Lib::pause( bool toggle ) { | 222 | void Lib::pause( bool toggle ) { |
223 | assert( m_initialized ); | 223 | assert( m_initialized ); |
224 | 224 | ||
225 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); | 225 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); |
226 | } | 226 | } |
227 | 227 | ||
228 | int Lib::speed() const { | 228 | int Lib::speed() const { |
229 | assert( m_initialized ); | 229 | assert( m_initialized ); |
230 | 230 | ||
231 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 231 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
232 | } | 232 | } |
233 | 233 | ||
234 | void Lib::setSpeed( int speed ) { | 234 | void Lib::setSpeed( int speed ) { |
235 | assert( m_initialized ); | 235 | assert( m_initialized ); |
236 | 236 | ||
237 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 237 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
238 | } | 238 | } |
239 | 239 | ||
240 | int Lib::status() const { | 240 | int Lib::status() const { |
241 | assert( m_initialized ); | 241 | assert( m_initialized ); |
242 | 242 | ||
243 | return xine_get_status( m_stream ); | 243 | return xine_get_status( m_stream ); |
244 | } | 244 | } |
245 | 245 | ||
246 | int Lib::currentPosition() const { | 246 | int Lib::currentPosition() const { |
247 | assert( m_initialized ); | 247 | assert( m_initialized ); |
248 | 248 | ||
249 | int pos, time, length; | 249 | int pos, time, length; |
250 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 250 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
251 | return pos; | 251 | return pos; |
252 | } | 252 | } |
253 | 253 | ||
254 | int Lib::currentTime() const { | 254 | int Lib::currentTime() const { |
255 | assert( m_initialized ); | 255 | assert( m_initialized ); |
256 | 256 | ||
257 | int pos, time, length; | 257 | int pos, time, length; |
258 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 258 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
259 | if ( time > 0 ) { | 259 | if ( time > 0 ) { |
260 | return time/1000; | 260 | return time/1000; |
261 | } else { | 261 | } else { |
262 | return 0; | 262 | return 0; |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | int Lib::length() const { | 266 | int Lib::length() const { |
267 | assert( m_initialized ); | 267 | assert( m_initialized ); |
268 | 268 | ||
269 | int pos, time, length; | 269 | int pos, time, length; |
270 | /* dilb: patch to solve the wrong stream length reported to the GUI*/ | 270 | /* dilb: patch to solve the wrong stream length reported to the GUI*/ |
271 | int iRetVal=0, iTestLoop=0; | 271 | int iRetVal=0, iTestLoop=0; |
272 | 272 | ||
273 | do | 273 | do |
274 | { | 274 | { |
275 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); | 275 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); |
276 | if (iRetVal) | 276 | if (iRetVal) |
277 | {/* if the function didn't return 0, then pos, time and length are valid.*/ | 277 | {/* if the function didn't return 0, then pos, time and length are valid.*/ |
278 | return length/1000; | 278 | return length/1000; |
279 | } | 279 | } |
280 | /*don't poll too much*/ | 280 | /*don't poll too much*/ |
281 | usleep(100000); | 281 | usleep(100000); |
282 | iTestLoop++; | 282 | iTestLoop++; |
283 | } | 283 | } |
284 | while ( iTestLoop < 10 ); /* if after 1s, we still don't have any | 284 | while ( iTestLoop < 10 ); /* if after 1s, we still don't have any |
285 | valid stream, then return -1 (this value could be used to make the stream | 285 | valid stream, then return -1 (this value could be used to make the stream |
286 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ | 286 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ |
287 | 287 | ||
288 | return -1; | 288 | return -1; |
289 | } | 289 | } |
290 | 290 | ||
291 | bool Lib::isSeekable() const { | 291 | bool Lib::isSeekable() const { |
292 | assert( m_initialized ); | 292 | assert( m_initialized ); |
293 | 293 | ||
294 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); | 294 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); |
295 | } | 295 | } |
296 | 296 | ||
297 | void Lib::seekTo( int time ) { | 297 | void Lib::seekTo( int time ) { |
298 | assert( m_initialized ); | 298 | assert( m_initialized ); |
299 | 299 | ||
300 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( | 300 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( |
301 | // since its now milliseconds we need *1000 | 301 | // since its now milliseconds we need *1000 |
302 | xine_play( m_stream, 0, time*1000 ); | 302 | xine_play( m_stream, 0, time*1000 ); |
303 | } | 303 | } |
304 | 304 | ||
305 | 305 | ||
306 | Frame Lib::currentFrame() const { | 306 | Frame Lib::currentFrame() const { |
307 | assert( m_initialized ); | 307 | assert( m_initialized ); |
308 | 308 | ||
309 | Frame frame; | 309 | Frame frame; |
310 | return frame; | 310 | return frame; |
311 | }; | 311 | }; |
312 | 312 | ||
313 | QString Lib::metaInfo( int number) const { | 313 | QString Lib::metaInfo( int number) const { |
314 | assert( m_initialized ); | 314 | assert( m_initialized ); |
315 | 315 | ||
316 | return xine_get_meta_info( m_stream, number ); | 316 | return xine_get_meta_info( m_stream, number ); |
317 | } | 317 | } |
318 | 318 | ||
319 | int Lib::error() const { | 319 | int Lib::error() const { |
320 | assert( m_initialized ); | 320 | assert( m_initialized ); |
321 | 321 | ||
322 | return xine_get_error( m_stream ); | 322 | return xine_get_error( m_stream ); |
323 | }; | 323 | }; |
324 | 324 | ||
325 | void Lib::ensureInitialized() | 325 | void Lib::ensureInitialized() |
326 | { | 326 | { |
327 | if ( m_initialized ) | 327 | if ( m_initialized ) |
328 | return; | 328 | return; |
329 | 329 | ||
330 | qDebug( "waiting for initialization thread to finish" ); | 330 | odebug << "waiting for initialization thread to finish" << oendl; |
331 | wait(); | 331 | wait(); |
332 | qDebug( "initialization thread finished!" ); | 332 | odebug << "initialization thread finished!" << oendl; |
333 | } | 333 | } |
334 | 334 | ||
335 | void Lib::setWidget( XineVideoWidget *widget ) | 335 | void Lib::setWidget( XineVideoWidget *widget ) |
336 | { | 336 | { |
337 | m_wid = widget; | 337 | m_wid = widget; |
338 | resize ( m_wid-> size ( ) ); | 338 | resize ( m_wid-> size ( ) ); |
339 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 339 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
340 | m_wid->repaint(); | 340 | m_wid->repaint(); |
341 | } | 341 | } |
342 | 342 | ||
343 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 343 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
344 | { | 344 | { |
345 | assert( sendType == ThreadUtil::Channel::OneWay ); | 345 | assert( sendType == ThreadUtil::Channel::OneWay ); |
346 | handleXineEvent( msg->type() ); | 346 | handleXineEvent( msg->type() ); |
347 | delete msg; | 347 | delete msg; |
348 | } | 348 | } |
349 | 349 | ||
350 | void Lib::handleXineEvent( const xine_event_t* t ) { | 350 | void Lib::handleXineEvent( const xine_event_t* t ) { |
351 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); | 351 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); |
352 | } | 352 | } |
353 | 353 | ||
354 | void Lib::handleXineEvent( int type ) { | 354 | void Lib::handleXineEvent( int type ) { |
355 | assert( m_initialized ); | 355 | assert( m_initialized ); |
356 | 356 | ||
357 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 357 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
358 | emit stopped(); | 358 | emit stopped(); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | void Lib::setShowVideo( bool video ) { | 363 | void Lib::setShowVideo( bool video ) { |
364 | assert( m_initialized ); | 364 | assert( m_initialized ); |
365 | 365 | ||
366 | m_video = video; | 366 | m_video = video; |
367 | ::null_set_show_video( m_videoOutput, video ); | 367 | ::null_set_show_video( m_videoOutput, video ); |
368 | } | 368 | } |
369 | 369 | ||
370 | bool Lib::isShowingVideo() const { | 370 | bool Lib::isShowingVideo() const { |
371 | assert( m_initialized ); | 371 | assert( m_initialized ); |
372 | 372 | ||
373 | return ::null_is_showing_video( m_videoOutput ); | 373 | return ::null_is_showing_video( m_videoOutput ); |
374 | } | 374 | } |
375 | 375 | ||
376 | bool Lib::hasVideo() const { | 376 | bool Lib::hasVideo() const { |
377 | assert( m_initialized ); | 377 | assert( m_initialized ); |
378 | 378 | ||
379 | return xine_get_stream_info( m_stream, 18 ); | 379 | return xine_get_stream_info( m_stream, 18 ); |
380 | } | 380 | } |
381 | 381 | ||
382 | void Lib::showVideoFullScreen( bool fullScreen ) { | 382 | void Lib::showVideoFullScreen( bool fullScreen ) { |
383 | assert( m_initialized ); | 383 | assert( m_initialized ); |
384 | 384 | ||
385 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 385 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
386 | } | 386 | } |
387 | 387 | ||
388 | bool Lib::isVideoFullScreen() const { | 388 | bool Lib::isVideoFullScreen() const { |
389 | assert( m_initialized ); | 389 | assert( m_initialized ); |
390 | 390 | ||
391 | return ::null_is_fullscreen( m_videoOutput ); | 391 | return ::null_is_fullscreen( m_videoOutput ); |
392 | } | 392 | } |
393 | 393 | ||
394 | void Lib::setScaling( bool scale ) { | 394 | void Lib::setScaling( bool scale ) { |
395 | assert( m_initialized ); | 395 | assert( m_initialized ); |
396 | 396 | ||
397 | ::null_set_scaling( m_videoOutput, scale ); | 397 | ::null_set_scaling( m_videoOutput, scale ); |
398 | } | 398 | } |
399 | 399 | ||
400 | void Lib::setGamma( int value ) { | 400 | void Lib::setGamma( int value ) { |
401 | assert( m_initialized ); | 401 | assert( m_initialized ); |
402 | 402 | ||
403 | ::null_set_videoGamma( m_videoOutput, value ); | 403 | ::null_set_videoGamma( m_videoOutput, value ); |
404 | } | 404 | } |
405 | 405 | ||
406 | bool Lib::isScaling() const { | 406 | bool Lib::isScaling() const { |
407 | assert( m_initialized ); | 407 | assert( m_initialized ); |
408 | 408 | ||
409 | return ::null_is_scaling( m_videoOutput ); | 409 | return ::null_is_scaling( m_videoOutput ); |
410 | } | 410 | } |
411 | 411 | ||
412 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 412 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
413 | ( (Lib*)user_data)->handleXineEvent( t ); | 413 | ( (Lib*)user_data)->handleXineEvent( t ); |
414 | } | 414 | } |
415 | 415 | ||
416 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 416 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
417 | int width, int height, int bytes ) { | 417 | int width, int height, int bytes ) { |
418 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 418 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
419 | } | 419 | } |
420 | 420 | ||
421 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 421 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
422 | assert( m_initialized ); | 422 | assert( m_initialized ); |
423 | 423 | ||
424 | if ( !m_video ) { | 424 | if ( !m_video ) { |
425 | qWarning("not showing video now"); | 425 | owarn << "not showing video now" << oendl; |
426 | return; | 426 | return; |
427 | } | 427 | } |
428 | 428 | ||
429 | assert( m_wid ); | 429 | assert( m_wid ); |
430 | 430 | ||
431 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 431 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
432 | } | 432 | } |