author | erik <erik> | 2007-02-05 20:20:18 (UTC) |
---|---|---|
committer | erik <erik> | 2007-02-05 20:20:18 (UTC) |
commit | a505f79190d4d14a7c9595af3e9b78d9c613da21 (patch) (unidiff) | |
tree | bfdeab48ca93857d5c2ec4f7d9380bc61b2c08b1 | |
parent | b017b14c0ec6d327e061a1f96209e19fdc59885a (diff) | |
download | opie-a505f79190d4d14a7c9595af3e9b78d9c613da21.zip opie-a505f79190d4d14a7c9595af3e9b78d9c613da21.tar.gz opie-a505f79190d4d14a7c9595af3e9b78d9c613da21.tar.bz2 |
BUG: Lack of a << made opieplayer2 uncompilable.
FIX: It is put in now.
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 5f281b7..575f2b2 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,479 +1,479 @@ | |||
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 | typedef void (*vo_scale_cb) (void*, int, int, double, | 52 | typedef void (*vo_scale_cb) (void*, int, int, double, |
53 | int*, int*, int*, int*, double*, int*, int* ); | 53 | int*, int*, int*, int*, double*, int*, int* ); |
54 | typedef void (*dest_size_cb) (void*, int, int, double, int*, int*, double*); | 54 | typedef void (*dest_size_cb) (void*, int, int, double, int*, int*, double*); |
55 | 55 | ||
56 | 56 | ||
57 | extern "C" { | 57 | extern "C" { |
58 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void *, vo_scale_cb, dest_size_cb ); | 58 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void *, vo_scale_cb, dest_size_cb ); |
59 | int null_is_showing_video( const xine_vo_driver_t* self ); | 59 | int null_is_showing_video( const xine_vo_driver_t* self ); |
60 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 60 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
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_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 62 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
63 | } | 63 | } |
64 | 64 | ||
65 | using namespace XINE; | 65 | using namespace XINE; |
66 | 66 | ||
67 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) | 67 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) |
68 | { | 68 | { |
69 | m_initialized = false; | 69 | m_initialized = false; |
70 | m_duringInitialization = false; | 70 | m_duringInitialization = false; |
71 | m_video = false; | 71 | m_video = false; |
72 | m_wid = widget; | 72 | m_wid = widget; |
73 | printf("Lib"); | 73 | printf("Lib"); |
74 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 74 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
75 | // get the configuration | 75 | // get the configuration |
76 | 76 | ||
77 | // not really OO, should be an extra class, later | 77 | // not really OO, should be an extra class, later |
78 | if ( !QFile::exists(configPath) ) { | 78 | if ( !QFile::exists(configPath) ) { |
79 | QFile f(configPath); | 79 | QFile f(configPath); |
80 | if (f.open(IO_WriteOnly)) { | 80 | if (f.open(IO_WriteOnly)) { |
81 | QTextStream ts( &f ); | 81 | QTextStream ts( &f ); |
82 | ts << "misc.memcpy_method:glibc\n"; | 82 | ts << "misc.memcpy_method:glibc\n"; |
83 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; | 83 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; |
84 | ts << "codec.ffmpeg_pp_quality:3\n"; | 84 | ts << "codec.ffmpeg_pp_quality:3\n"; |
85 | ts << "audio.num_buffers:50\n"; | 85 | ts << "audio.num_buffers:50\n"; |
86 | ts << "audio.size_buffers:4096\n"; | 86 | ts << "audio.size_buffers:4096\n"; |
87 | ts << "video.num_buffers:20\n"; | 87 | ts << "video.num_buffers:20\n"; |
88 | ts << "video.size_buffers:4096\n"; | 88 | ts << "video.size_buffers:4096\n"; |
89 | ts << "audio.out_num_audio_buf:16\n"; | 89 | ts << "audio.out_num_audio_buf:16\n"; |
90 | ts << "audio.out_size_audio_buf:8096\n"; | 90 | ts << "audio.out_size_audio_buf:8096\n"; |
91 | ts << "audio.out_size_zero_buf:1024\n"; | 91 | ts << "audio.out_size_zero_buf:1024\n"; |
92 | ts << "audio.passthrough_offset:0\n"; | 92 | ts << "audio.passthrough_offset:0\n"; |
93 | f.close(); | 93 | f.close(); |
94 | } else | 94 | } else |
95 | owarn << "Failed to open " f.name() << oendl; | 95 | owarn << "Failed to open " << f.name() << oendl; |
96 | } | 96 | } |
97 | 97 | ||
98 | if ( initMode == InitializeImmediately ) { | 98 | if ( initMode == InitializeImmediately ) { |
99 | initialize(); | 99 | initialize(); |
100 | m_initialized = true; | 100 | m_initialized = true; |
101 | } | 101 | } |
102 | else | 102 | else |
103 | start(); | 103 | start(); |
104 | } | 104 | } |
105 | 105 | ||
106 | void Lib::run() | 106 | void Lib::run() |
107 | { | 107 | { |
108 | odebug << "Lib::run() started" << oendl; | 108 | odebug << "Lib::run() started" << oendl; |
109 | initialize(); | 109 | initialize(); |
110 | m_initialized = true; | 110 | m_initialized = true; |
111 | odebug << "Lib::run() finished" << oendl; | 111 | odebug << "Lib::run() finished" << oendl; |
112 | } | 112 | } |
113 | 113 | ||
114 | void Lib::initialize() | 114 | void Lib::initialize() |
115 | { | 115 | { |
116 | m_duringInitialization = true; | 116 | m_duringInitialization = true; |
117 | m_xine = xine_new( ); | 117 | m_xine = xine_new( ); |
118 | 118 | ||
119 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 119 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
120 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); | 120 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); |
121 | 121 | ||
122 | xine_init( m_xine ); | 122 | xine_init( m_xine ); |
123 | 123 | ||
124 | // allocate oss for sound | 124 | // allocate oss for sound |
125 | // and fb for framebuffer | 125 | // and fb for framebuffer |
126 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); | 126 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
127 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, | 127 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, |
128 | xine_display_frame, this, | 128 | xine_display_frame, this, |
129 | xine_vo_scale_cb, | 129 | xine_vo_scale_cb, |
130 | xine_dest_cb ); | 130 | xine_dest_cb ); |
131 | 131 | ||
132 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 132 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
133 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); | 133 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); |
134 | 134 | ||
135 | if (m_wid != 0 ) | 135 | if (m_wid != 0 ) |
136 | setWidget( m_wid ); | 136 | setWidget( m_wid ); |
137 | 137 | ||
138 | 138 | ||
139 | m_queue = xine_event_new_queue (m_stream); | 139 | m_queue = xine_event_new_queue (m_stream); |
140 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 140 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
141 | 141 | ||
142 | m_duringInitialization = false; | 142 | m_duringInitialization = false; |
143 | } | 143 | } |
144 | 144 | ||
145 | Lib::~Lib() { | 145 | Lib::~Lib() { |
146 | assert( isRunning() == false ); | 146 | assert( isRunning() == false ); |
147 | assert( m_initialized ); | 147 | assert( m_initialized ); |
148 | 148 | ||
149 | // free( m_config ); | 149 | // free( m_config ); |
150 | 150 | ||
151 | xine_close( m_stream ); | 151 | xine_close( m_stream ); |
152 | xine_event_dispose_queue( m_queue ); | 152 | xine_event_dispose_queue( m_queue ); |
153 | xine_dispose( m_stream ); | 153 | xine_dispose( m_stream ); |
154 | xine_close_audio_driver(m_xine,m_audioOutput); | 154 | xine_close_audio_driver(m_xine,m_audioOutput); |
155 | xine_close_video_driver(m_xine,m_videoOutput); | 155 | xine_close_video_driver(m_xine,m_videoOutput); |
156 | xine_exit( m_xine ); | 156 | xine_exit( m_xine ); |
157 | 157 | ||
158 | /* FIXME either free or delete but valgrind bitches against both */ | 158 | /* FIXME either free or delete but valgrind bitches against both */ |
159 | //free( m_videoOutput ); | 159 | //free( m_videoOutput ); |
160 | //delete m_audioOutput; | 160 | //delete m_audioOutput; |
161 | } | 161 | } |
162 | 162 | ||
163 | void Lib::resize ( const QSize &s ) { | 163 | void Lib::resize ( const QSize &s ) { |
164 | assert( m_initialized || m_duringInitialization ); | 164 | assert( m_initialized || m_duringInitialization ); |
165 | 165 | ||
166 | if ( s. width ( ) && s. height ( ) ) | 166 | if ( s. width ( ) && s. height ( ) ) |
167 | m_videoSize = s; | 167 | m_videoSize = s; |
168 | } | 168 | } |
169 | 169 | ||
170 | int Lib::majorVersion() { | 170 | int Lib::majorVersion() { |
171 | int major, minor, sub; | 171 | int major, minor, sub; |
172 | xine_get_version ( &major, &minor, &sub ); | 172 | xine_get_version ( &major, &minor, &sub ); |
173 | return major; | 173 | return major; |
174 | } | 174 | } |
175 | 175 | ||
176 | int Lib::minorVersion() { | 176 | int Lib::minorVersion() { |
177 | int major, minor, sub; | 177 | int major, minor, sub; |
178 | xine_get_version ( &major, &minor, &sub ); | 178 | xine_get_version ( &major, &minor, &sub ); |
179 | return minor; | 179 | return minor; |
180 | } | 180 | } |
181 | 181 | ||
182 | int Lib::subVersion() { | 182 | int Lib::subVersion() { |
183 | int major, minor, sub; | 183 | int major, minor, sub; |
184 | xine_get_version ( &major, &minor, &sub ); | 184 | xine_get_version ( &major, &minor, &sub ); |
185 | return sub; | 185 | return sub; |
186 | } | 186 | } |
187 | 187 | ||
188 | int Lib::setfile(const QString& fileName) | 188 | int Lib::setfile(const QString& fileName) |
189 | { | 189 | { |
190 | QString str = fileName.stripWhiteSpace(); | 190 | QString str = fileName.stripWhiteSpace(); |
191 | 191 | ||
192 | 192 | ||
193 | if ( !xine_open( m_stream, str.utf8().data() ) ) { | 193 | if ( !xine_open( m_stream, str.utf8().data() ) ) { |
194 | return 0; | 194 | return 0; |
195 | } | 195 | } |
196 | return 1; | 196 | return 1; |
197 | } | 197 | } |
198 | 198 | ||
199 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 199 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
200 | assert( m_initialized ); | 200 | assert( m_initialized ); |
201 | 201 | ||
202 | QString str = fileName.stripWhiteSpace(); | 202 | QString str = fileName.stripWhiteSpace(); |
203 | 203 | ||
204 | 204 | ||
205 | if ( !xine_open( m_stream, str.utf8().data() ) ) { | 205 | if ( !xine_open( m_stream, str.utf8().data() ) ) { |
206 | return 0; | 206 | return 0; |
207 | } | 207 | } |
208 | return xine_play( m_stream, startPos, start_time); | 208 | return xine_play( m_stream, startPos, start_time); |
209 | } | 209 | } |
210 | 210 | ||
211 | void Lib::stop() { | 211 | void Lib::stop() { |
212 | assert( m_initialized ); | 212 | assert( m_initialized ); |
213 | xine_stop( m_stream ); | 213 | xine_stop( m_stream ); |
214 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); | 214 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); |
215 | } | 215 | } |
216 | 216 | ||
217 | void Lib::pause( bool toggle ) { | 217 | void Lib::pause( bool toggle ) { |
218 | assert( m_initialized ); | 218 | assert( m_initialized ); |
219 | 219 | ||
220 | if ( toggle ) { | 220 | if ( toggle ) { |
221 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 221 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); |
222 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); | 222 | xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); |
223 | } | 223 | } |
224 | 224 | ||
225 | else { | 225 | else { |
226 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL ); | 226 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL ); |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | int Lib::speed() const { | 230 | int Lib::speed() const { |
231 | assert( m_initialized ); | 231 | assert( m_initialized ); |
232 | 232 | ||
233 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 233 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
234 | } | 234 | } |
235 | 235 | ||
236 | void Lib::setSpeed( int speed ) { | 236 | void Lib::setSpeed( int speed ) { |
237 | assert( m_initialized ); | 237 | assert( m_initialized ); |
238 | 238 | ||
239 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 239 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
240 | } | 240 | } |
241 | 241 | ||
242 | int Lib::status() const { | 242 | int Lib::status() const { |
243 | assert( m_initialized ); | 243 | assert( m_initialized ); |
244 | 244 | ||
245 | return xine_get_status( m_stream ); | 245 | return xine_get_status( m_stream ); |
246 | } | 246 | } |
247 | 247 | ||
248 | int Lib::currentPosition() const { | 248 | int Lib::currentPosition() const { |
249 | assert( m_initialized ); | 249 | assert( m_initialized ); |
250 | 250 | ||
251 | int pos, time, length; | 251 | int pos, time, length; |
252 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 252 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
253 | return pos; | 253 | return pos; |
254 | } | 254 | } |
255 | 255 | ||
256 | int Lib::currentTime() const { | 256 | int Lib::currentTime() const { |
257 | assert( m_initialized ); | 257 | assert( m_initialized ); |
258 | 258 | ||
259 | int pos, time, length; | 259 | int pos, time, length; |
260 | pos = time = length = 0; | 260 | pos = time = length = 0; |
261 | 261 | ||
262 | if ( xine_get_pos_length( m_stream, &pos, &time, &length ) ) | 262 | if ( xine_get_pos_length( m_stream, &pos, &time, &length ) ) |
263 | return time/1000; | 263 | return time/1000; |
264 | else | 264 | else |
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
267 | 267 | ||
268 | int Lib::length() const { | 268 | int Lib::length() const { |
269 | assert( m_initialized ); | 269 | assert( m_initialized ); |
270 | 270 | ||
271 | int pos, time, length; | 271 | int pos, time, length; |
272 | /* dilb: patch to solve the wrong stream length reported to the GUI*/ | 272 | /* dilb: patch to solve the wrong stream length reported to the GUI*/ |
273 | int iRetVal=0, iTestLoop=0; | 273 | int iRetVal=0, iTestLoop=0; |
274 | 274 | ||
275 | do | 275 | do |
276 | { | 276 | { |
277 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); | 277 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); |
278 | if (iRetVal) | 278 | if (iRetVal) |
279 | {/* if the function didn't return 0, then pos, time and length are valid.*/ | 279 | {/* if the function didn't return 0, then pos, time and length are valid.*/ |
280 | return length/1000; | 280 | return length/1000; |
281 | } | 281 | } |
282 | /*don't poll too much*/ | 282 | /*don't poll too much*/ |
283 | usleep(100000); | 283 | usleep(100000); |
284 | iTestLoop++; | 284 | iTestLoop++; |
285 | } | 285 | } |
286 | while ( iTestLoop < 10 ); /* if after 1s, we still don't have any | 286 | while ( iTestLoop < 10 ); /* if after 1s, we still don't have any |
287 | valid stream, then return -1 (this value could be used to make the stream | 287 | valid stream, then return -1 (this value could be used to make the stream |
288 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ | 288 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ |
289 | 289 | ||
290 | return -1; | 290 | return -1; |
291 | } | 291 | } |
292 | 292 | ||
293 | /* info about current stream */ | 293 | /* info about current stream */ |
294 | QSize Lib::videoSize()const | 294 | QSize Lib::videoSize()const |
295 | { | 295 | { |
296 | if (!m_initialized||!hasVideo()) return QSize(0,0); | 296 | if (!m_initialized||!hasVideo()) return QSize(0,0); |
297 | int width = xine_get_stream_info(m_stream,XINE_STREAM_INFO_VIDEO_WIDTH); | 297 | int width = xine_get_stream_info(m_stream,XINE_STREAM_INFO_VIDEO_WIDTH); |
298 | int height = xine_get_stream_info(m_stream,XINE_STREAM_INFO_VIDEO_HEIGHT); | 298 | int height = xine_get_stream_info(m_stream,XINE_STREAM_INFO_VIDEO_HEIGHT); |
299 | return QSize(width,height); | 299 | return QSize(width,height); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | bool Lib::isSeekable() const { | 303 | bool Lib::isSeekable() const { |
304 | assert( m_initialized ); | 304 | assert( m_initialized ); |
305 | 305 | ||
306 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); | 306 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); |
307 | } | 307 | } |
308 | 308 | ||
309 | bool Lib::hasVideo() const { | 309 | bool Lib::hasVideo() const { |
310 | assert( m_initialized ); | 310 | assert( m_initialized ); |
311 | 311 | ||
312 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_HAS_VIDEO); | 312 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_HAS_VIDEO); |
313 | } | 313 | } |
314 | 314 | ||
315 | int Lib::audioBitrate()const | 315 | int Lib::audioBitrate()const |
316 | { | 316 | { |
317 | if (!m_initialized) return 0; | 317 | if (!m_initialized) return 0; |
318 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_AUDIO_BITRATE); | 318 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_AUDIO_BITRATE); |
319 | } | 319 | } |
320 | int Lib::videoBitrate()const | 320 | int Lib::videoBitrate()const |
321 | { | 321 | { |
322 | if (!m_initialized||!hasVideo()) return 0; | 322 | if (!m_initialized||!hasVideo()) return 0; |
323 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_VIDEO_BITRATE); | 323 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_VIDEO_BITRATE); |
324 | } | 324 | } |
325 | /* end info block */ | 325 | /* end info block */ |
326 | 326 | ||
327 | void Lib::seekTo( int time ) { | 327 | void Lib::seekTo( int time ) { |
328 | assert( m_initialized ); | 328 | assert( m_initialized ); |
329 | 329 | ||
330 | odebug << "Seeking to second " << time << oendl; | 330 | odebug << "Seeking to second " << time << oendl; |
331 | //Keep it paused if it was in that state | 331 | //Keep it paused if it was in that state |
332 | if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) { | 332 | if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) { |
333 | xine_play( m_stream, 0, time*1000 ); | 333 | xine_play( m_stream, 0, time*1000 ); |
334 | } | 334 | } |
335 | 335 | ||
336 | else { | 336 | else { |
337 | xine_play( m_stream, 0, time*1000 ); | 337 | xine_play( m_stream, 0, time*1000 ); |
338 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 338 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); |
339 | } | 339 | } |
340 | 340 | ||
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | QString Lib::metaInfo( int number) const { | 344 | QString Lib::metaInfo( int number) const { |
345 | assert( m_initialized ); | 345 | assert( m_initialized ); |
346 | 346 | ||
347 | return xine_get_meta_info( m_stream, number ); | 347 | return xine_get_meta_info( m_stream, number ); |
348 | } | 348 | } |
349 | 349 | ||
350 | int Lib::error() const { | 350 | int Lib::error() const { |
351 | assert( m_initialized ); | 351 | assert( m_initialized ); |
352 | 352 | ||
353 | return xine_get_error( m_stream ); | 353 | return xine_get_error( m_stream ); |
354 | }; | 354 | }; |
355 | 355 | ||
356 | void Lib::ensureInitialized() | 356 | void Lib::ensureInitialized() |
357 | { | 357 | { |
358 | if ( m_initialized ) | 358 | if ( m_initialized ) |
359 | return; | 359 | return; |
360 | 360 | ||
361 | odebug << "waiting for initialization thread to finish" << oendl; | 361 | odebug << "waiting for initialization thread to finish" << oendl; |
362 | wait(); | 362 | wait(); |
363 | odebug << "initialization thread finished!" << oendl; | 363 | odebug << "initialization thread finished!" << oendl; |
364 | } | 364 | } |
365 | 365 | ||
366 | void Lib::setWidget( XineVideoWidget *widget ) | 366 | void Lib::setWidget( XineVideoWidget *widget ) |
367 | { | 367 | { |
368 | m_wid = widget; | 368 | m_wid = widget; |
369 | if (m_wid) { | 369 | if (m_wid) { |
370 | resize ( m_wid-> size ( ) ); | 370 | resize ( m_wid-> size ( ) ); |
371 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 371 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 375 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
376 | { | 376 | { |
377 | assert( sendType == ThreadUtil::Channel::OneWay ); | 377 | assert( sendType == ThreadUtil::Channel::OneWay ); |
378 | handleXineEvent( msg->type(), msg->data(), msg->msg() ); | 378 | handleXineEvent( msg->type(), msg->data(), msg->msg() ); |
379 | delete msg; | 379 | delete msg; |
380 | } | 380 | } |
381 | 381 | ||
382 | void Lib::handleXineEvent( const xine_event_t* t ) { | 382 | void Lib::handleXineEvent( const xine_event_t* t ) { |
383 | int prog = -1; const char* name = 0; | 383 | int prog = -1; const char* name = 0; |
384 | if ( t->type == XINE_EVENT_PROGRESS ) { | 384 | if ( t->type == XINE_EVENT_PROGRESS ) { |
385 | xine_progress_data_t *pt = static_cast<xine_progress_data_t*>( t->data ); | 385 | xine_progress_data_t *pt = static_cast<xine_progress_data_t*>( t->data ); |
386 | prog = pt->percent; | 386 | prog = pt->percent; |
387 | name = pt->description; | 387 | name = pt->description; |
388 | } | 388 | } |
389 | 389 | ||
390 | send( new ThreadUtil::ChannelMessage( t->type, prog, name ), OneWay ); | 390 | send( new ThreadUtil::ChannelMessage( t->type, prog, name ), OneWay ); |
391 | } | 391 | } |
392 | 392 | ||
393 | void Lib::handleXineEvent( int type, int data, const char* name ) { | 393 | void Lib::handleXineEvent( int type, int data, const char* name ) { |
394 | assert( m_initialized ); | 394 | assert( m_initialized ); |
395 | 395 | ||
396 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 396 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
397 | emit stopped(); | 397 | emit stopped(); |
398 | }else if ( type == XINE_EVENT_PROGRESS ) { | 398 | }else if ( type == XINE_EVENT_PROGRESS ) { |
399 | QString str = name == 0 ? QString::null : QString::fromUtf8( name ); | 399 | QString str = name == 0 ? QString::null : QString::fromUtf8( name ); |
400 | Global::statusMessage( tr( "Progress: %1 %2" ).arg( name, data ) );; | 400 | Global::statusMessage( tr( "Progress: %1 %2" ).arg( name, data ) );; |
401 | } | 401 | } |
402 | } | 402 | } |
403 | 403 | ||
404 | 404 | ||
405 | void Lib::setShowVideo( bool video ) { | 405 | void Lib::setShowVideo( bool video ) { |
406 | assert( m_initialized ); | 406 | assert( m_initialized ); |
407 | 407 | ||
408 | m_video = video; | 408 | m_video = video; |
409 | ::null_set_show_video( m_videoOutput, video ); | 409 | ::null_set_show_video( m_videoOutput, video ); |
410 | } | 410 | } |
411 | 411 | ||
412 | bool Lib::isShowingVideo() const { | 412 | bool Lib::isShowingVideo() const { |
413 | assert( m_initialized ); | 413 | assert( m_initialized ); |
414 | 414 | ||
415 | return ::null_is_showing_video( m_videoOutput ); | 415 | return ::null_is_showing_video( m_videoOutput ); |
416 | } | 416 | } |
417 | 417 | ||
418 | void Lib::showVideoFullScreen( bool fullScreen ) { | 418 | void Lib::showVideoFullScreen( bool fullScreen ) { |
419 | assert( m_initialized ); | 419 | assert( m_initialized ); |
420 | 420 | ||
421 | #warning use xine | 421 | #warning use xine |
422 | } | 422 | } |
423 | 423 | ||
424 | bool Lib::isVideoFullScreen() const { | 424 | bool Lib::isVideoFullScreen() const { |
425 | assert( m_initialized ); | 425 | assert( m_initialized ); |
426 | 426 | ||
427 | #warning use xine | 427 | #warning use xine |
428 | return false; | 428 | return false; |
429 | } | 429 | } |
430 | 430 | ||
431 | void Lib::setScaling( bool scale ) { | 431 | void Lib::setScaling( bool scale ) { |
432 | assert( m_initialized ); | 432 | assert( m_initialized ); |
433 | 433 | ||
434 | xine_set_param( m_stream, XINE_PARAM_VO_ASPECT_RATIO, | 434 | xine_set_param( m_stream, XINE_PARAM_VO_ASPECT_RATIO, |
435 | scale ? XINE_VO_ASPECT_AUTO : XINE_VO_ASPECT_SQUARE ); | 435 | scale ? XINE_VO_ASPECT_AUTO : XINE_VO_ASPECT_SQUARE ); |
436 | } | 436 | } |
437 | 437 | ||
438 | void Lib::setGamma( int value ) { | 438 | void Lib::setGamma( int value ) { |
439 | assert( m_initialized ); | 439 | assert( m_initialized ); |
440 | xine_set_param( m_stream, XINE_PARAM_VO_BRIGHTNESS, value ); | 440 | xine_set_param( m_stream, XINE_PARAM_VO_BRIGHTNESS, value ); |
441 | } | 441 | } |
442 | 442 | ||
443 | bool Lib::isScaling() const { | 443 | bool Lib::isScaling() const { |
444 | assert( m_initialized ); | 444 | assert( m_initialized ); |
445 | 445 | ||
446 | int aratio = xine_get_param( m_stream, XINE_PARAM_VO_ASPECT_RATIO ); | 446 | int aratio = xine_get_param( m_stream, XINE_PARAM_VO_ASPECT_RATIO ); |
447 | return aratio == XINE_VO_ASPECT_AUTO; | 447 | return aratio == XINE_VO_ASPECT_AUTO; |
448 | } | 448 | } |
449 | 449 | ||
450 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 450 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
451 | ( (Lib*)user_data)->handleXineEvent( t ); | 451 | ( (Lib*)user_data)->handleXineEvent( t ); |
452 | } | 452 | } |
453 | 453 | ||
454 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 454 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
455 | int width, int height, int bytes ) { | 455 | int width, int height, int bytes ) { |
456 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 456 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
457 | } | 457 | } |
458 | 458 | ||
459 | void Lib::xine_vo_scale_cb( void *user_data, int video_with, int video_height, | 459 | void Lib::xine_vo_scale_cb( void *user_data, int video_with, int video_height, |
460 | double video_pixel_aspect, | 460 | double video_pixel_aspect, |
461 | int *dest_x, int *dest_y, int *dest_width, | 461 | int *dest_x, int *dest_y, int *dest_width, |
462 | int *dest_height, double *dest_pixel_aspect, | 462 | int *dest_height, double *dest_pixel_aspect, |
463 | int *win_x, int *win_y ) { | 463 | int *win_x, int *win_y ) { |
464 | QSize size = ((Lib*)user_data)->m_videoSize; | 464 | QSize size = ((Lib*)user_data)->m_videoSize; |
465 | if (!size.isValid()) | 465 | if (!size.isValid()) |
466 | return; | 466 | return; |
467 | 467 | ||
468 | *dest_x = 0; | 468 | *dest_x = 0; |
469 | *dest_y = 0; | 469 | *dest_y = 0; |
470 | *dest_width = size.width(); | 470 | *dest_width = size.width(); |
471 | *dest_height = size.height(); | 471 | *dest_height = size.height(); |
472 | *win_x = 0; | 472 | *win_x = 0; |
473 | *win_y = 0; | 473 | *win_y = 0; |
474 | } | 474 | } |
475 | 475 | ||
476 | void Lib::xine_dest_cb( void* user_data, int, int, double, | 476 | void Lib::xine_dest_cb( void* user_data, int, int, double, |
477 | int *dest_width, int* dest_height, double* ) { | 477 | int *dest_width, int* dest_height, double* ) { |
478 | QSize size = ((Lib*)user_data)->m_videoSize; | 478 | QSize size = ((Lib*)user_data)->m_videoSize; |
479 | if ( !size.isValid() ) | 479 | if ( !size.isValid() ) |