-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 5ae6c21..eb57b67 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,209 +1,209 @@ | |||
1 | 1 | ||
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | //#include <qpe/qpeapplication.h> | 4 | //#include <qpe/qpeapplication.h> |
5 | #include <qimage.h> | 5 | #include <qimage.h> |
6 | #include <qpe/resource.h> | 6 | #include <qpe/resource.h> |
7 | 7 | ||
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | 9 | ||
10 | #include <qgfx_qws.h> | 10 | #include <qgfx_qws.h> |
11 | #include <qdirectpainter_qws.h> | 11 | #include <qdirectpainter_qws.h> |
12 | 12 | ||
13 | #include "xinevideowidget.h" | 13 | #include "xinevideowidget.h" |
14 | #include "frame.h" | 14 | #include "frame.h" |
15 | #include "lib.h" | 15 | #include "lib.h" |
16 | 16 | ||
17 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 17 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
18 | int width, int height,int bytes ); | 18 | int width, int height,int bytes ); |
19 | 19 | ||
20 | extern "C" { | 20 | extern "C" { |
21 | vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); | 21 | vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); |
22 | int null_is_showing_video( vo_driver_t* self ); | 22 | int null_is_showing_video( vo_driver_t* self ); |
23 | void null_set_show_video( vo_driver_t* self, int show ); | 23 | void null_set_show_video( vo_driver_t* self, int show ); |
24 | int null_is_fullscreen( vo_driver_t* self ); | 24 | int null_is_fullscreen( vo_driver_t* self ); |
25 | void null_set_fullscreen( vo_driver_t* self, int screen ); | 25 | void null_set_fullscreen( vo_driver_t* self, int screen ); |
26 | int null_is_scaling( vo_driver_t* self ); | 26 | int null_is_scaling( vo_driver_t* self ); |
27 | void null_set_scaling( vo_driver_t* self, int scale ); | 27 | void null_set_scaling( vo_driver_t* self, int scale ); |
28 | void null_set_gui_width( vo_driver_t* self, int width ); | 28 | void null_set_gui_width( vo_driver_t* self, int width ); |
29 | void null_set_gui_height( vo_driver_t* self, int height ); | 29 | void null_set_gui_height( vo_driver_t* self, int height ); |
30 | void null_set_mode( vo_driver_t* self, int depth, int rgb ); | 30 | void null_set_mode( vo_driver_t* self, int depth, int rgb ); |
31 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); | 31 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); |
32 | } | 32 | } |
33 | 33 | ||
34 | using namespace XINE; | 34 | using namespace XINE; |
35 | 35 | ||
36 | Lib::Lib(XineVideoWidget* widget) { | 36 | Lib::Lib(XineVideoWidget* widget) { |
37 | m_video = false; | 37 | m_video = false; |
38 | m_wid = widget; | 38 | m_wid = widget; |
39 | printf("Lib"); | 39 | printf("Lib"); |
40 | QCString str( getenv("HOME") ); | 40 | QCString str( getenv("HOME") ); |
41 | str += "/Settings/opiexine.cf"; | 41 | str += "/Settings/opiexine.cf"; |
42 | // get the configuration | 42 | // get the configuration |
43 | m_config = xine_config_file_init( str.data() ); | 43 | m_config = xine_config_file_init( str.data() ); |
44 | 44 | ||
45 | // allocate oss for sound | 45 | // allocate oss for sound |
46 | // and fb for framebuffer | 46 | // and fb for framebuffer |
47 | m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; | 47 | m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; |
48 | if (m_audioOutput == NULL ) | 48 | if (m_audioOutput == NULL ) |
49 | printf("Failure\n"); | 49 | printf("Failure\n"); |
50 | else | 50 | else |
51 | printf("Success\n"); | 51 | printf("Success\n"); |
52 | 52 | ||
53 | 53 | ||
54 | // test code | 54 | // test code |
55 | /* m_videoOutput = xine_load_video_output_plugin(m_config, "fb", | 55 | /* m_videoOutput = xine_load_video_output_plugin(m_config, "fb", |
56 | VISUAL_TYPE_FB, | 56 | VISUAL_TYPE_FB, |
57 | 0 ); | 57 | 0 ); |
58 | */ | 58 | */ |
59 | 59 | ||
60 | char** files = xine_list_video_output_plugins(3); | 60 | char** files = xine_list_video_output_plugins(3); |
61 | char* out; | 61 | char* out; |
62 | int i = 0; | 62 | int i = 0; |
63 | while ( ( out = files[i] ) != 0 ) { | 63 | while ( ( out = files[i] ) != 0 ) { |
64 | printf("Video %s\n", out ); | 64 | printf("Video %s\n", out ); |
65 | i++; | 65 | i++; |
66 | } | 66 | } |
67 | // m_xine = xine_init( m_videoOutput, | 67 | // m_xine = xine_init( m_videoOutput, |
68 | // m_audioOutput, | 68 | // m_audioOutput, |
69 | // m_config ); | 69 | // m_config ); |
70 | // test loading | 70 | // test loading |
71 | m_videoOutput = ::init_video_out_plugin( m_config, NULL ); | 71 | m_videoOutput = ::init_video_out_plugin( m_config, NULL ); |
72 | if (m_wid != 0 ) { | 72 | if (m_wid != 0 ) { |
73 | printf("!0\n" ); | 73 | printf("!0\n" ); |
74 | ::null_set_gui_width( m_videoOutput, m_wid->image()->width() ); | 74 | ::null_set_gui_width( m_videoOutput, m_wid->image()->width() ); |
75 | ::null_set_gui_height(m_videoOutput, m_wid->image()->height() ); | 75 | ::null_set_gui_height(m_videoOutput, m_wid->image()->height() ); |
76 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 76 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
77 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | 77 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
78 | QImage image = Resource::loadImage("SoundPlayer"); | 78 | QImage image = Resource::loadImage(""); |
79 | image = image.smoothScale( m_wid->width(), m_wid->height() ); | 79 | image = image.smoothScale( m_wid->width(), m_wid->height() ); |
80 | QImage* img = new QImage( image ); | 80 | QImage* img = new QImage( image ); |
81 | m_wid->setImage( img ); | 81 | m_wid->setImage( img ); |
82 | m_wid->repaint(); | 82 | m_wid->repaint(); |
83 | } | 83 | } |
84 | null_display_handler( m_videoOutput, | 84 | null_display_handler( m_videoOutput, |
85 | xine_display_frame, | 85 | xine_display_frame, |
86 | this ); | 86 | this ); |
87 | 87 | ||
88 | m_xine = xine_init( m_videoOutput, | 88 | m_xine = xine_init( m_videoOutput, |
89 | m_audioOutput, m_config ); | 89 | m_audioOutput, m_config ); |
90 | // install the event handler | 90 | // install the event handler |
91 | xine_register_event_listener( m_xine, xine_event_handler, this ); | 91 | xine_register_event_listener( m_xine, xine_event_handler, this ); |
92 | } | 92 | } |
93 | 93 | ||
94 | Lib::~Lib() { | 94 | Lib::~Lib() { |
95 | delete m_config; | 95 | delete m_config; |
96 | xine_remove_event_listener( m_xine, xine_event_handler ); | 96 | xine_remove_event_listener( m_xine, xine_event_handler ); |
97 | xine_exit( m_xine ); | 97 | xine_exit( m_xine ); |
98 | delete m_videoOutput; | 98 | delete m_videoOutput; |
99 | //delete m_audioOutput; | 99 | //delete m_audioOutput; |
100 | 100 | ||
101 | } | 101 | } |
102 | 102 | ||
103 | QCString Lib::version() { | 103 | QCString Lib::version() { |
104 | QCString str( xine_get_str_version() ); | 104 | QCString str( xine_get_str_version() ); |
105 | return str; | 105 | return str; |
106 | }; | 106 | }; |
107 | 107 | ||
108 | int Lib::majorVersion() { | 108 | int Lib::majorVersion() { |
109 | return xine_get_major_version(); | 109 | return xine_get_major_version(); |
110 | } | 110 | } |
111 | int Lib::minorVersion() { | 111 | int Lib::minorVersion() { |
112 | return xine_get_minor_version(); | 112 | return xine_get_minor_version(); |
113 | }; | 113 | }; |
114 | 114 | ||
115 | int Lib::subVersion() { | 115 | int Lib::subVersion() { |
116 | return xine_get_sub_version(); | 116 | return xine_get_sub_version(); |
117 | } | 117 | } |
118 | int Lib::play( const QString& fileName, | 118 | int Lib::play( const QString& fileName, |
119 | int startPos, | 119 | int startPos, |
120 | int start_time ) { | 120 | int start_time ) { |
121 | QString str = fileName.stripWhiteSpace(); | 121 | QString str = fileName.stripWhiteSpace(); |
122 | //workaround OpiePlayer bug | 122 | //workaround OpiePlayer bug |
123 | if (str.right(1) == QString::fromLatin1("/") ) | 123 | if (str.right(1) == QString::fromLatin1("/") ) |
124 | str = str.mid( str.length() -1 ); | 124 | str = str.mid( str.length() -1 ); |
125 | return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), | 125 | return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), |
126 | startPos, start_time); | 126 | startPos, start_time); |
127 | } | 127 | } |
128 | void Lib::stop() { | 128 | void Lib::stop() { |
129 | xine_stop(m_xine ); | 129 | xine_stop(m_xine ); |
130 | } | 130 | } |
131 | void Lib::pause(){ | 131 | void Lib::pause(){ |
132 | xine_set_speed( m_xine, SPEED_PAUSE ); | 132 | xine_set_speed( m_xine, SPEED_PAUSE ); |
133 | } | 133 | } |
134 | int Lib::speed() { | 134 | int Lib::speed() { |
135 | return xine_get_speed( m_xine ); | 135 | return xine_get_speed( m_xine ); |
136 | } | 136 | } |
137 | void Lib::setSpeed( int speed ) { | 137 | void Lib::setSpeed( int speed ) { |
138 | xine_set_speed( m_xine, speed ); | 138 | xine_set_speed( m_xine, speed ); |
139 | } | 139 | } |
140 | int Lib::status(){ | 140 | int Lib::status(){ |
141 | return xine_get_status( m_xine ); | 141 | return xine_get_status( m_xine ); |
142 | } | 142 | } |
143 | int Lib::currentPosition(){ | 143 | int Lib::currentPosition(){ |
144 | return xine_get_current_position( m_xine ); | 144 | return xine_get_current_position( m_xine ); |
145 | } | 145 | } |
146 | int Lib::currentTime() { | 146 | int Lib::currentTime() { |
147 | return xine_get_current_time( m_xine ); | 147 | return xine_get_current_time( m_xine ); |
148 | }; | 148 | }; |
149 | int Lib::length() { | 149 | int Lib::length() { |
150 | return xine_get_stream_length( m_xine ); | 150 | return xine_get_stream_length( m_xine ); |
151 | } | 151 | } |
152 | bool Lib::isSeekable() { | 152 | bool Lib::isSeekable() { |
153 | return xine_is_stream_seekable(m_xine); | 153 | return xine_is_stream_seekable(m_xine); |
154 | } | 154 | } |
155 | Frame Lib::currentFrame() { | 155 | Frame Lib::currentFrame() { |
156 | Frame frame; | 156 | Frame frame; |
157 | return frame; | 157 | return frame; |
158 | }; | 158 | }; |
159 | int Lib::error() { | 159 | int Lib::error() { |
160 | return xine_get_error( m_xine ); | 160 | return xine_get_error( m_xine ); |
161 | }; | 161 | }; |
162 | void Lib::handleXineEvent( xine_event_t* t ) { | 162 | void Lib::handleXineEvent( xine_event_t* t ) { |
163 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) | 163 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) |
164 | emit stopped(); | 164 | emit stopped(); |
165 | } | 165 | } |
166 | void Lib::setShowVideo( bool video ) { | 166 | void Lib::setShowVideo( bool video ) { |
167 | m_video = video; | 167 | m_video = video; |
168 | ::null_set_show_video( m_videoOutput, video ); | 168 | ::null_set_show_video( m_videoOutput, video ); |
169 | } | 169 | } |
170 | bool Lib::isShowingVideo() { | 170 | bool Lib::isShowingVideo() { |
171 | return ::null_is_showing_video( m_videoOutput ); | 171 | return ::null_is_showing_video( m_videoOutput ); |
172 | } | 172 | } |
173 | void Lib::showVideoFullScreen( bool fullScreen ) { | 173 | void Lib::showVideoFullScreen( bool fullScreen ) { |
174 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 174 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
175 | } | 175 | } |
176 | bool Lib::isVideoFullScreen() { | 176 | bool Lib::isVideoFullScreen() { |
177 | return ::null_is_fullscreen( m_videoOutput ); | 177 | return ::null_is_fullscreen( m_videoOutput ); |
178 | } | 178 | } |
179 | void Lib::setScaling( bool scale ) { | 179 | void Lib::setScaling( bool scale ) { |
180 | ::null_set_scaling( m_videoOutput, scale ); | 180 | ::null_set_scaling( m_videoOutput, scale ); |
181 | } | 181 | } |
182 | bool Lib::isScaling() { | 182 | bool Lib::isScaling() { |
183 | return ::null_is_scaling( m_videoOutput ); | 183 | return ::null_is_scaling( m_videoOutput ); |
184 | } | 184 | } |
185 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { | 185 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { |
186 | ((Lib*)user_data)->handleXineEvent( t ); | 186 | ((Lib*)user_data)->handleXineEvent( t ); |
187 | } | 187 | } |
188 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 188 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
189 | int width, int height, int bytes ) { | 189 | int width, int height, int bytes ) { |
190 | // printf("display x frame"); | 190 | // printf("display x frame"); |
191 | ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 191 | ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
192 | // printf("displayed x frame\n"); | 192 | // printf("displayed x frame\n"); |
193 | } | 193 | } |
194 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 194 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
195 | if (!m_video ) { | 195 | if (!m_video ) { |
196 | qWarning("not showing video now"); | 196 | qWarning("not showing video now"); |
197 | return; | 197 | return; |
198 | } | 198 | } |
199 | // qWarning("called draw frame %d %d", width, height); | 199 | // qWarning("called draw frame %d %d", width, height); |
200 | 200 | ||
201 | QSize size = m_wid->size(); | 201 | QSize size = m_wid->size(); |
202 | int xoffset = (size.width() - width) / 2; | 202 | int xoffset = (size.width() - width) / 2; |
203 | int yoffset = (size.height() - height) / 2; | 203 | int yoffset = (size.height() - height) / 2; |
204 | int linestep = qt_screen->linestep(); | 204 | int linestep = qt_screen->linestep(); |
205 | 205 | ||
206 | m_wid->setImage( frame, yoffset, xoffset, width, height, linestep, bytes, m_bytes_per_pixel ); | 206 | m_wid->setImage( frame, yoffset, xoffset, width, height, linestep, bytes, m_bytes_per_pixel ); |
207 | // m_wid->repaint(false); | 207 | // m_wid->repaint(false); |
208 | 208 | ||
209 | } | 209 | } |