Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore 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 | |||
@@ -3,11 +3,18 @@ | |||
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" { |
@@ -19,10 +26,15 @@ extern "C" { | |||
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") ); |
@@ -41,7 +53,8 @@ Lib::Lib(XineVideoWidget* /*widget*/) { | |||
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); |
@@ -49,5 +62,5 @@ Lib::Lib(XineVideoWidget* /*widget*/) { | |||
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 | } |
@@ -57,4 +70,20 @@ Lib::Lib(XineVideoWidget* /*widget*/) { | |||
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 ); |
@@ -90,5 +119,8 @@ 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); |
@@ -133,4 +165,5 @@ void Lib::handleXineEvent( xine_event_t* t ) { | |||
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 | } |
@@ -153,2 +186,24 @@ 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 | } | ||