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