author | zecke <zecke> | 2002-07-11 22:44:54 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-07-11 22:44:54 (UTC) |
commit | d2c7228d2efe6f47ef5b7ec04157fcead775be74 (patch) (unidiff) | |
tree | 95584eff5b953cc4ac908da028ef3c66c75b28cd /noncore/multimedia/opieplayer2/lib.cpp | |
parent | 1651f048bb129b8e748a01c514d84c8626e0f1e2 (diff) | |
download | opie-d2c7228d2efe6f47ef5b7ec04157fcead775be74.zip opie-d2c7228d2efe6f47ef5b7ec04157fcead775be74.tar.gz opie-d2c7228d2efe6f47ef5b7ec04157fcead775be74.tar.bz2 |
broken video widget
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 | |||
@@ -2,13 +2,20 @@ | |||
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); |
@@ -18,12 +25,17 @@ extern "C" { | |||
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"; |
@@ -40,15 +52,16 @@ Lib::Lib(XineVideoWidget* /*widget*/) { | |||
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, |
@@ -56,6 +69,22 @@ Lib::Lib(XineVideoWidget* /*widget*/) { | |||
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 |
@@ -89,7 +118,10 @@ int Lib::subVersion() { | |||
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 | } |
@@ -132,6 +164,7 @@ void Lib::handleXineEvent( xine_event_t* t ) { | |||
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() { |
@@ -152,3 +185,25 @@ bool Lib::isScaling() { | |||
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 | } | ||