summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/lib.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp65
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
@@ -4,2 +4,4 @@
4//#include <qpe/qpeapplication.h> 4//#include <qpe/qpeapplication.h>
5#include <qimage.h>
6#include <qpe/resource.h>
5 7
@@ -7,2 +9,5 @@
7 9
10#include <qgfx_qws.h>
11#include <qdirectpainter_qws.h>
12
8#include "xinevideowidget.h" 13#include "xinevideowidget.h"
@@ -11,2 +16,4 @@
11 16
17typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
18 int width, int height,int bytes );
12 19
@@ -20,3 +27,6 @@ extern "C" {
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}
@@ -25,3 +35,5 @@ using namespace XINE;
25 35
26Lib::Lib(XineVideoWidget* /*widget*/) { 36Lib::Lib(XineVideoWidget* widget) {
37 m_video = false;
38 m_wid = widget;
27 printf("Lib"); 39 printf("Lib");
@@ -42,5 +54,6 @@ Lib::Lib(XineVideoWidget* /*widget*/) {
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
@@ -50,3 +63,3 @@ Lib::Lib(XineVideoWidget* /*widget*/) {
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++;
@@ -58,2 +71,18 @@ Lib::Lib(XineVideoWidget* /*widget*/) {
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,
@@ -91,3 +120,6 @@ int Lib::play( const QString& fileName,
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(),
@@ -134,2 +166,3 @@ void Lib::handleXineEvent( xine_event_t* t ) {
134void Lib::setShowVideo( bool video ) { 166void Lib::setShowVideo( bool video ) {
167 m_video = video;
135 ::null_set_show_video( m_videoOutput, video ); 168 ::null_set_show_video( m_videoOutput, video );
@@ -154 +187,23 @@ void Lib::xine_event_handler( void* user_data, xine_event_t* t ) {
154} 187}
188void 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}
194void 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}