-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 56 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 38 |
2 files changed, 49 insertions, 45 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 1ac9809..77dab9a 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,292 +1,298 @@ | |||
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() { | 135 | QCString Lib::version() { |
136 | // QCString str( xine_get_str_version() ); | 136 | // QCString str( xine_get_str_version() ); |
137 | // return str; | 137 | // return str; |
138 | return "test"; | 138 | return "test"; |
139 | } | 139 | } |
140 | 140 | ||
141 | int Lib::majorVersion() { | 141 | int Lib::majorVersion() { |
142 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); | 142 | int major, minor, sub; |
143 | return m_major_version; | 143 | xine_get_version ( &major, &minor, &sub ); |
144 | return major; | ||
144 | } | 145 | } |
145 | 146 | ||
146 | int Lib::minorVersion() { | 147 | int Lib::minorVersion() { |
147 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); | 148 | int major, minor, sub; |
148 | return m_minor_version; | 149 | xine_get_version ( &major, &minor, &sub ); |
150 | return minor; | ||
149 | } | 151 | } |
150 | 152 | ||
151 | int Lib::subVersion() { | 153 | int Lib::subVersion() { |
152 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); | 154 | int major, minor, sub; |
153 | return m_sub_version; | 155 | xine_get_version ( &major, &minor, &sub ); |
156 | return sub; | ||
154 | } | 157 | } |
155 | 158 | ||
156 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 159 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
157 | QString str = fileName.stripWhiteSpace(); | 160 | QString str = fileName.stripWhiteSpace(); |
158 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { | 161 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { |
159 | return 0; | 162 | return 0; |
160 | } | 163 | } |
161 | return xine_play( m_stream, startPos, start_time); | 164 | return xine_play( m_stream, startPos, start_time); |
162 | } | 165 | } |
163 | 166 | ||
164 | void Lib::stop() { | 167 | void Lib::stop() { |
165 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 168 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
166 | xine_stop( m_stream ); | 169 | xine_stop( m_stream ); |
167 | } | 170 | } |
168 | 171 | ||
169 | void Lib::pause() { | 172 | void Lib::pause() { |
170 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 173 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); |
171 | } | 174 | } |
172 | 175 | ||
173 | int Lib::speed() { | 176 | int Lib::speed() const { |
174 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 177 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
175 | } | 178 | } |
176 | 179 | ||
177 | void Lib::setSpeed( int speed ) { | 180 | void Lib::setSpeed( int speed ) { |
178 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 181 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
179 | } | 182 | } |
180 | 183 | ||
181 | int Lib::status() { | 184 | int Lib::status() const { |
182 | return xine_get_status( m_stream ); | 185 | return xine_get_status( m_stream ); |
183 | } | 186 | } |
184 | 187 | ||
185 | int Lib::currentPosition() { | 188 | int Lib::currentPosition() const { |
186 | xine_get_pos_length( m_stream, &m_pos, &m_time, &m_length ); | 189 | int pos, time, length; |
187 | return m_pos; | 190 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
191 | return pos; | ||
188 | } | 192 | } |
189 | 193 | ||
190 | int Lib::currentTime() { | 194 | int Lib::currentTime() const { |
191 | xine_get_pos_length( m_stream, &m_pos, &m_time, &m_length ); | 195 | int pos, time, length; |
192 | return m_time/1000; | 196 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
197 | return time/1000; | ||
193 | } | 198 | } |
194 | 199 | ||
195 | int Lib::length() { | 200 | int Lib::length() const { |
196 | xine_get_pos_length( m_stream, &m_pos, &m_time, &m_length ); | 201 | int pos, time, length; |
197 | return m_length/1000; | 202 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
203 | return length/1000; | ||
198 | } | 204 | } |
199 | 205 | ||
200 | bool Lib::isSeekable() { | 206 | bool Lib::isSeekable() const { |
201 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); | 207 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); |
202 | } | 208 | } |
203 | 209 | ||
204 | void Lib::seekTo( int time ) { | 210 | void Lib::seekTo( int time ) { |
205 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( | 211 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( |
206 | // since its now milliseconds we need *1000 | 212 | // since its now milliseconds we need *1000 |
207 | xine_play( m_stream, 0, time*1000 ); | 213 | xine_play( m_stream, 0, time*1000 ); |
208 | } | 214 | } |
209 | 215 | ||
210 | 216 | ||
211 | Frame Lib::currentFrame() { | 217 | Frame Lib::currentFrame() const { |
212 | Frame frame; | 218 | Frame frame; |
213 | return frame; | 219 | return frame; |
214 | }; | 220 | }; |
215 | 221 | ||
216 | QString Lib::metaInfo( int number) { | 222 | QString Lib::metaInfo( int number) const { |
217 | return xine_get_meta_info( m_stream, number ); | 223 | return xine_get_meta_info( m_stream, number ); |
218 | } | 224 | } |
219 | 225 | ||
220 | int Lib::error() { | 226 | int Lib::error() const { |
221 | return xine_get_error( m_stream ); | 227 | return xine_get_error( m_stream ); |
222 | }; | 228 | }; |
223 | 229 | ||
224 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 230 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
225 | { | 231 | { |
226 | assert( sendType == ThreadUtil::Channel::OneWay ); | 232 | assert( sendType == ThreadUtil::Channel::OneWay ); |
227 | handleXineEvent( msg->type() ); | 233 | handleXineEvent( msg->type() ); |
228 | delete msg; | 234 | delete msg; |
229 | } | 235 | } |
230 | 236 | ||
231 | void Lib::handleXineEvent( const xine_event_t* t ) { | 237 | void Lib::handleXineEvent( const xine_event_t* t ) { |
232 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); | 238 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); |
233 | } | 239 | } |
234 | 240 | ||
235 | void Lib::handleXineEvent( int type ) { | 241 | void Lib::handleXineEvent( int type ) { |
236 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 242 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
237 | emit stopped(); | 243 | emit stopped(); |
238 | } | 244 | } |
239 | } | 245 | } |
240 | 246 | ||
241 | 247 | ||
242 | void Lib::setShowVideo( bool video ) { | 248 | void Lib::setShowVideo( bool video ) { |
243 | m_video = video; | 249 | m_video = video; |
244 | ::null_set_show_video( m_videoOutput, video ); | 250 | ::null_set_show_video( m_videoOutput, video ); |
245 | } | 251 | } |
246 | 252 | ||
247 | bool Lib::isShowingVideo() { | 253 | bool Lib::isShowingVideo() const { |
248 | return ::null_is_showing_video( m_videoOutput ); | 254 | return ::null_is_showing_video( m_videoOutput ); |
249 | } | 255 | } |
250 | 256 | ||
251 | bool Lib::hasVideo() { | 257 | bool Lib::hasVideo() const { |
252 | return xine_get_stream_info( m_stream, 18 ); | 258 | return xine_get_stream_info( m_stream, 18 ); |
253 | } | 259 | } |
254 | 260 | ||
255 | void Lib::showVideoFullScreen( bool fullScreen ) { | 261 | void Lib::showVideoFullScreen( bool fullScreen ) { |
256 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 262 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
257 | } | 263 | } |
258 | 264 | ||
259 | bool Lib::isVideoFullScreen() { | 265 | bool Lib::isVideoFullScreen() const { |
260 | return ::null_is_fullscreen( m_videoOutput ); | 266 | return ::null_is_fullscreen( m_videoOutput ); |
261 | } | 267 | } |
262 | 268 | ||
263 | void Lib::setScaling( bool scale ) { | 269 | void Lib::setScaling( bool scale ) { |
264 | ::null_set_scaling( m_videoOutput, scale ); | 270 | ::null_set_scaling( m_videoOutput, scale ); |
265 | } | 271 | } |
266 | 272 | ||
267 | void Lib::setGamma( int value ) { | 273 | void Lib::setGamma( int value ) { |
268 | //qDebug( QString( "%1").arg(value) ); | 274 | //qDebug( QString( "%1").arg(value) ); |
269 | /* int gammaValue = ( 100 + value ); */ | 275 | /* int gammaValue = ( 100 + value ); */ |
270 | ::null_set_videoGamma( m_videoOutput, value ); | 276 | ::null_set_videoGamma( m_videoOutput, value ); |
271 | } | 277 | } |
272 | 278 | ||
273 | bool Lib::isScaling() { | 279 | bool Lib::isScaling() const { |
274 | return ::null_is_scaling( m_videoOutput ); | 280 | return ::null_is_scaling( m_videoOutput ); |
275 | } | 281 | } |
276 | 282 | ||
277 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 283 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
278 | ( (Lib*)user_data)->handleXineEvent( t ); | 284 | ( (Lib*)user_data)->handleXineEvent( t ); |
279 | } | 285 | } |
280 | 286 | ||
281 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 287 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
282 | int width, int height, int bytes ) { | 288 | int width, int height, int bytes ) { |
283 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 289 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
284 | } | 290 | } |
285 | 291 | ||
286 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 292 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
287 | if ( !m_video ) { | 293 | if ( !m_video ) { |
288 | qWarning("not showing video now"); | 294 | qWarning("not showing video now"); |
289 | return; | 295 | return; |
290 | } | 296 | } |
291 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 297 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
292 | } | 298 | } |
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 75b9f12..a7e51fb 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h | |||
@@ -1,208 +1,206 @@ | |||
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(); | 63 | QCString version(); |
64 | int majorVersion()/*const*/; | 64 | static int majorVersion(); |
65 | int minorVersion()/*const*/; | 65 | static int minorVersion(); |
66 | int subVersion()/*const*/; | 66 | static int subVersion(); |
67 | 67 | ||
68 | 68 | ||
69 | void resize ( const QSize &s ); | 69 | void resize ( const QSize &s ); |
70 | 70 | ||
71 | int play( const QString& fileName, | 71 | int play( const QString& fileName, |
72 | int startPos = 0, | 72 | int startPos = 0, |
73 | int start_time = 0 ); | 73 | int start_time = 0 ); |
74 | void stop() /*const*/; | 74 | void stop(); |
75 | void pause()/*const*/; | 75 | void pause(); |
76 | 76 | ||
77 | int speed() /*const*/; | 77 | int speed() const; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Set the speed of the stream, if codec supports it | 80 | * Set the speed of the stream, if codec supports it |
81 | * XINE_SPEED_PAUSE 0 | 81 | * XINE_SPEED_PAUSE 0 |
82 | * XINE_SPEED_SLOW_4 1 | 82 | * XINE_SPEED_SLOW_4 1 |
83 | * XINE_SPEED_SLOW_2 2 | 83 | * XINE_SPEED_SLOW_2 2 |
84 | * XINE_SPEED_NORMAL 4 | 84 | * XINE_SPEED_NORMAL 4 |
85 | * XINE_SPEED_FAST_2 8 | 85 | * XINE_SPEED_FAST_2 8 |
86 | *XINE_SPEED_FAST_4 16 | 86 | *XINE_SPEED_FAST_4 16 |
87 | */ | 87 | */ |
88 | void setSpeed( int speed = XINE_SPEED_PAUSE ); | 88 | void setSpeed( int speed = XINE_SPEED_PAUSE ); |
89 | 89 | ||
90 | int status() /*const*/; | 90 | int status() const; |
91 | 91 | ||
92 | int currentPosition()/*const*/; | 92 | int currentPosition()const; |
93 | //in seconds | 93 | //in seconds |
94 | int currentTime()/*const*/; | 94 | int currentTime()const; |
95 | 95 | ||
96 | int length() /*const*/; | 96 | int length() const; |
97 | 97 | ||
98 | bool isSeekable()/*const*/; | 98 | bool isSeekable()const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Whether or not to show video output | 101 | * Whether or not to show video output |
102 | */ | 102 | */ |
103 | void setShowVideo(bool video); | 103 | void setShowVideo(bool video); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * is we show video | 106 | * is we show video |
107 | */ | 107 | */ |
108 | bool isShowingVideo() /*const*/; | 108 | bool isShowingVideo() const; |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * | 111 | * |
112 | */ | 112 | */ |
113 | void showVideoFullScreen( bool fullScreen ); | 113 | void showVideoFullScreen( bool fullScreen ); |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * | 116 | * |
117 | */ | 117 | */ |
118 | bool isVideoFullScreen()/*const*/ ; | 118 | bool isVideoFullScreen() const; |
119 | 119 | ||
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Get the meta info (like author etc) from the stream | 122 | * Get the meta info (like author etc) from the stream |
123 | * XINE_META_INFO_TITLE 0 | 123 | * XINE_META_INFO_TITLE 0 |
124 | * XINE_META_INFO_COMMENT 1 | 124 | * XINE_META_INFO_COMMENT 1 |
125 | * XINE_META_INFO_ARTIST 2 | 125 | * XINE_META_INFO_ARTIST 2 |
126 | * XINE_META_INFO_GENRE 3 | 126 | * XINE_META_INFO_GENRE 3 |
127 | * XINE_META_INFO_ALBUM 4 | 127 | * XINE_META_INFO_ALBUM 4 |
128 | * XINE_META_INFO_YEAR 5 | 128 | * XINE_META_INFO_YEAR 5 |
129 | * XINE_META_INFO_VIDEOCODEC 6 | 129 | * XINE_META_INFO_VIDEOCODEC 6 |
130 | * XINE_META_INFO_AUDIOCODEC 7 | 130 | * XINE_META_INFO_AUDIOCODEC 7 |
131 | * XINE_META_INFO_SYSTEMLAYER 8 | 131 | * XINE_META_INFO_SYSTEMLAYER 8 |
132 | * XINE_META_INFO_INPUT_PLUGIN 9 | 132 | * XINE_META_INFO_INPUT_PLUGIN 9 |
133 | */ | 133 | */ |
134 | QString metaInfo( int number ); | 134 | QString metaInfo( int number ) const; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * | 137 | * |
138 | */ | 138 | */ |
139 | bool isScaling(); | 139 | bool isScaling() const; |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * seek to a position | 142 | * seek to a position |
143 | */ | 143 | */ |
144 | void seekTo( int time ); | 144 | void seekTo( int time ); |
145 | 145 | ||
146 | /** | 146 | /** |
147 | * | 147 | * |
148 | * @return is media stream has video | 148 | * @return is media stream has video |
149 | */ | 149 | */ |
150 | bool hasVideo(); | 150 | bool hasVideo() const; |
151 | 151 | ||
152 | /** | 152 | /** |
153 | * | 153 | * |
154 | */ | 154 | */ |
155 | void setScaling( bool ); | 155 | void setScaling( bool ); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | * Set the Gamma value for video output | 158 | * Set the Gamma value for video output |
159 | * @param int the value between -100 and 100, 0 is original | 159 | * @param int the value between -100 and 100, 0 is original |
160 | */ | 160 | */ |
161 | void setGamma( int ); | 161 | void setGamma( int ); |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * test | 164 | * test |
165 | */ | 165 | */ |
166 | Frame currentFrame()/*const*/; | 166 | Frame currentFrame() const; |
167 | 167 | ||
168 | /** | 168 | /** |
169 | * Returns the error code | 169 | * Returns the error code |
170 | * XINE_ERROR_NONE 0 | 170 | * XINE_ERROR_NONE 0 |
171 | * XINE_ERROR_NO_INPUT_PLUGIN 1 | 171 | * XINE_ERROR_NO_INPUT_PLUGIN 1 |
172 | * XINE_ERROR_NO_DEMUXER_PLUGIN 2 | 172 | * XINE_ERROR_NO_DEMUXER_PLUGIN 2 |
173 | * XINE_ERROR_DEMUXER_FAILED 3 | 173 | * XINE_ERROR_DEMUXER_FAILED 3 |
174 | */ | 174 | */ |
175 | int error() /*const*/; | 175 | int error() const; |
176 | 176 | ||
177 | signals: | 177 | signals: |
178 | 178 | ||
179 | void stopped(); | 179 | void stopped(); |
180 | 180 | ||
181 | protected: | 181 | protected: |
182 | virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); | 182 | virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); |
183 | 183 | ||
184 | private: | 184 | private: |
185 | int m_bytes_per_pixel; | 185 | int m_bytes_per_pixel; |
186 | int m_length, m_pos, m_time; | ||
187 | int m_major_version, m_minor_version, m_sub_version; | ||
188 | bool m_video:1; | 186 | bool m_video:1; |
189 | XineVideoWidget *m_wid; | 187 | XineVideoWidget *m_wid; |
190 | xine_t *m_xine; | 188 | xine_t *m_xine; |
191 | xine_stream_t *m_stream; | 189 | xine_stream_t *m_stream; |
192 | xine_cfg_entry_t *m_config; | 190 | xine_cfg_entry_t *m_config; |
193 | xine_vo_driver_t *m_videoOutput; | 191 | xine_vo_driver_t *m_videoOutput; |
194 | xine_ao_driver_t* m_audioOutput; | 192 | xine_ao_driver_t* m_audioOutput; |
195 | xine_event_queue_t *m_queue; | 193 | xine_event_queue_t *m_queue; |
196 | 194 | ||
197 | void handleXineEvent( const xine_event_t* t ); | 195 | void handleXineEvent( const xine_event_t* t ); |
198 | void handleXineEvent( int type ); | 196 | void handleXineEvent( int type ); |
199 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); | 197 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); |
200 | // C -> C++ bridge for the event system | 198 | // C -> C++ bridge for the event system |
201 | static void xine_event_handler( void* user_data, const xine_event_t* t); | 199 | static void xine_event_handler( void* user_data, const xine_event_t* t); |
202 | static void xine_display_frame( void* user_data, uint8_t* frame , | 200 | static void xine_display_frame( void* user_data, uint8_t* frame , |
203 | int width, int height, int bytes ); | 201 | int width, int height, int bytes ); |
204 | }; | 202 | }; |
205 | }; | 203 | }; |
206 | 204 | ||
207 | 205 | ||
208 | #endif | 206 | #endif |