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