summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/lib.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/lib.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 39364ab..3a82a50 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,249 +1,249 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <stdio.h> 34#include <stdio.h>
35#include <stdlib.h> 35#include <stdlib.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qtextstream.h> 37#include <qtextstream.h>
38#include <qpe/resource.h> 38#include <qpe/resource.h>
39 39
40#include <qfile.h> 40#include <qfile.h>
41 41
42#include <qgfx_qws.h> 42#include <qgfx_qws.h>
43#include <qdirectpainter_qws.h> 43#include <qdirectpainter_qws.h>
44 44
45#include "xinevideowidget.h" 45#include "xinevideowidget.h"
46#include "frame.h" 46#include "frame.h"
47#include "lib.h" 47#include "lib.h"
48 48
49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
50 int width, int height,int bytes ); 50 int width, int height,int bytes );
51 51
52extern "C" { 52extern "C" {
53 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); 53 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video);
54 int null_is_showing_video( vo_driver_t* self ); 54 int null_is_showing_video( vo_driver_t* self );
55 void null_set_show_video( vo_driver_t* self, int show ); 55 void null_set_show_video( vo_driver_t* self, int show );
56 int null_is_fullscreen( vo_driver_t* self ); 56 int null_is_fullscreen( vo_driver_t* self );
57 void null_set_fullscreen( vo_driver_t* self, int screen ); 57 void null_set_fullscreen( vo_driver_t* self, int screen );
58 int null_is_scaling( vo_driver_t* self ); 58 int null_is_scaling( vo_driver_t* self );
59 void null_set_scaling( vo_driver_t* self, int scale ); 59 void null_set_scaling( vo_driver_t* self, int scale );
60 void null_set_gui_width( vo_driver_t* self, int width ); 60 void null_set_gui_width( vo_driver_t* self, int width );
61 void null_set_gui_height( vo_driver_t* self, int height ); 61 void null_set_gui_height( vo_driver_t* self, int height );
62 void null_set_mode( vo_driver_t* self, int depth, int rgb ); 62 void null_set_mode( vo_driver_t* self, int depth, int rgb );
63 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); 63 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data);
64} 64}
65 65
66using namespace XINE; 66using namespace XINE;
67 67
68Lib::Lib(XineVideoWidget* widget) { 68Lib::Lib(XineVideoWidget* widget) {
69 m_video = false; 69 m_video = false;
70 m_wid = widget; 70 m_wid = widget;
71 printf("Lib"); 71 printf("Lib");
72 QCString str( getenv("HOME") ); 72 QCString str( getenv("HOME") );
73 str += "/Settings/opiexine.cf"; 73 str += "/Settings/opiexine.cf";
74 // get the configuration 74 // get the configuration
75 75
76 // not really OO, should be an extra class, later 76 // not really OO, should be an extra class, later
77 if ( !QFile(str).exists() ) { 77 if ( !QFile(str).exists() ) {
78 QFile f(str); 78 QFile f(str);
79 f.open(IO_WriteOnly); 79 f.open(IO_WriteOnly);
80 QTextStream ts( &f ); 80 QTextStream ts( &f );
81 ts << "misc.memcpy_method:glibc\n"; 81 ts << "misc.memcpy_method:glibc\n";
82 f.close(); 82 f.close();
83 } 83 }
84 84
85 m_config = xine_config_file_init( str.data() ); 85 m_config = xine_config_file_init( str.data() );
86 86
87 // allocate oss for sound 87 // allocate oss for sound
88 // and fb for framebuffer 88 // and fb for framebuffer
89 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; 89 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ;
90 if (m_audioOutput == NULL ) 90 if (m_audioOutput == NULL )
91 printf("Failure\n"); 91 printf("Failure\n");
92 else 92 else
93 printf("Success\n"); 93 printf("Success\n");
94 94
95 95
96 // test code 96 // test code
97/* m_videoOutput = xine_load_video_output_plugin(m_config, "fb", 97/* m_videoOutput = xine_load_video_output_plugin(m_config, "fb",
98 VISUAL_TYPE_FB, 98 VISUAL_TYPE_FB,
99 0 ); 99 0 );
100*/ 100*/
101 101
102 char** files = xine_list_video_output_plugins(3); 102 char** files = xine_list_video_output_plugins(3);
103 char* out; 103 char* out;
104 int i = 0; 104 int i = 0;
105 while ( ( out = files[i] ) != 0 ) { 105 while ( ( out = files[i] ) != 0 ) {
106 printf("Video %s\n", out ); 106 printf("Video %s\n", out );
107 i++; 107 i++;
108 } 108 }
109// m_xine = xine_init( m_videoOutput, 109// m_xine = xine_init( m_videoOutput,
110// m_audioOutput, 110// m_audioOutput,
111// m_config ); 111// m_config );
112 // test loading 112 // test loading
113 m_videoOutput = ::init_video_out_plugin( m_config, NULL ); 113 m_videoOutput = ::init_video_out_plugin( m_config, NULL );
114 if (m_wid != 0 ) { 114 if (m_wid != 0 ) {
115 printf("!0\n" ); 115 printf("!0\n" );
116 resize ( m_wid-> size ( )); 116 resize ( m_wid-> size ( ));
117 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 117 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
118 m_wid-> setImage ( new QImage ( Resource::loadImage(""))); 118 m_wid-> setImage ( new QImage ( Resource::loadImage("")));
119 m_wid->repaint(); 119 m_wid->repaint();
120 } 120 }
121 null_display_handler( m_videoOutput, 121 null_display_handler( m_videoOutput,
122 xine_display_frame, 122 xine_display_frame,
123 this ); 123 this );
124 124
125 m_xine = xine_init( m_videoOutput, 125 m_xine = xine_init( m_videoOutput,
126 m_audioOutput, m_config ); 126 m_audioOutput, m_config );
127 // install the event handler 127 // install the event handler
128 xine_register_event_listener( m_xine, xine_event_handler, this ); 128 xine_register_event_listener( m_xine, xine_event_handler, this );
129} 129}
130 130
131Lib::~Lib() { 131Lib::~Lib() {
132 delete m_config; 132 delete m_config;
133 xine_remove_event_listener( m_xine, xine_event_handler ); 133 xine_remove_event_listener( m_xine, xine_event_handler );
134 xine_exit( m_xine ); 134 xine_exit( m_xine );
135 delete m_videoOutput; 135 delete m_videoOutput;
136 //delete m_audioOutput; 136 //delete m_audioOutput;
137 137
138} 138}
139 139
140void Lib::resize ( const QSize &s ) 140void Lib::resize ( const QSize &s )
141{ 141{
142 if ( s. width ( ) && s. height ( )) { 142 if ( s. width ( ) && s. height ( )) {
143 ::null_set_gui_width( m_videoOutput, s. width() ); 143 ::null_set_gui_width( m_videoOutput, s. width() );
144 ::null_set_gui_height(m_videoOutput, s. height() ); 144 ::null_set_gui_height(m_videoOutput, s. height() );
145 } 145 }
146} 146}
147 147
148QCString Lib::version() { 148QCString Lib::version() {
149 QCString str( xine_get_str_version() ); 149 QCString str( xine_get_str_version() );
150 return str; 150 return str;
151}; 151};
152 152
153int Lib::majorVersion() { 153int Lib::majorVersion() {
154 return xine_get_major_version(); 154 return xine_get_major_version();
155} 155}
156int Lib::minorVersion() { 156int Lib::minorVersion() {
157 return xine_get_minor_version(); 157 return xine_get_minor_version();
158}; 158};
159 159
160int Lib::subVersion() { 160int Lib::subVersion() {
161 return xine_get_sub_version(); 161 return xine_get_sub_version();
162} 162}
163int Lib::play( const QString& fileName, 163int Lib::play( const QString& fileName,
164 int startPos, 164 int startPos,
165 int start_time ) { 165 int start_time ) {
166 QString str = fileName.stripWhiteSpace(); 166 QString str = fileName.stripWhiteSpace();
167 //workaround OpiePlayer bug 167 //workaround OpiePlayer bug
168 if (str.right(1) == QString::fromLatin1("/") ) 168 //f (str.right(1) == QString::fromLatin1("/") )
169 str = str.mid( str.length() -1 ); 169 // str = str.mid( str.length() -1 );
170 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), 170 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(),
171 startPos, start_time); 171 startPos, start_time);
172} 172}
173void Lib::stop() { 173void Lib::stop() {
174 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 174 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
175 xine_stop(m_xine ); 175 xine_stop(m_xine );
176} 176}
177void Lib::pause(){ 177void Lib::pause(){
178 xine_set_speed( m_xine, SPEED_PAUSE ); 178 xine_set_speed( m_xine, SPEED_PAUSE );
179} 179}
180int Lib::speed() { 180int Lib::speed() {
181 return xine_get_speed( m_xine ); 181 return xine_get_speed( m_xine );
182} 182}
183void Lib::setSpeed( int speed ) { 183void Lib::setSpeed( int speed ) {
184 xine_set_speed( m_xine, speed ); 184 xine_set_speed( m_xine, speed );
185} 185}
186int Lib::status(){ 186int Lib::status(){
187 return xine_get_status( m_xine ); 187 return xine_get_status( m_xine );
188} 188}
189int Lib::currentPosition(){ 189int Lib::currentPosition(){
190 return xine_get_current_position( m_xine ); 190 return xine_get_current_position( m_xine );
191} 191}
192int Lib::currentTime() { 192int Lib::currentTime() {
193 return xine_get_current_time( m_xine ); 193 return xine_get_current_time( m_xine );
194}; 194};
195int Lib::length() { 195int Lib::length() {
196 return xine_get_stream_length( m_xine ); 196 return xine_get_stream_length( m_xine );
197} 197}
198bool Lib::isSeekable() { 198bool Lib::isSeekable() {
199 return xine_is_stream_seekable(m_xine); 199 return xine_is_stream_seekable(m_xine);
200} 200}
201Frame Lib::currentFrame() { 201Frame Lib::currentFrame() {
202 Frame frame; 202 Frame frame;
203 return frame; 203 return frame;
204}; 204};
205int Lib::error() { 205int Lib::error() {
206 return xine_get_error( m_xine ); 206 return xine_get_error( m_xine );
207}; 207};
208void Lib::handleXineEvent( xine_event_t* t ) { 208void Lib::handleXineEvent( xine_event_t* t ) {
209 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) 209 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED )
210 emit stopped(); 210 emit stopped();
211} 211}
212void Lib::setShowVideo( bool video ) { 212void Lib::setShowVideo( bool video ) {
213 m_video = video; 213 m_video = video;
214 ::null_set_show_video( m_videoOutput, video ); 214 ::null_set_show_video( m_videoOutput, video );
215} 215}
216bool Lib::isShowingVideo() { 216bool Lib::isShowingVideo() {
217 return ::null_is_showing_video( m_videoOutput ); 217 return ::null_is_showing_video( m_videoOutput );
218} 218}
219void Lib::showVideoFullScreen( bool fullScreen ) { 219void Lib::showVideoFullScreen( bool fullScreen ) {
220 ::null_set_fullscreen( m_videoOutput, fullScreen ); 220 ::null_set_fullscreen( m_videoOutput, fullScreen );
221} 221}
222bool Lib::isVideoFullScreen() { 222bool Lib::isVideoFullScreen() {
223 return ::null_is_fullscreen( m_videoOutput ); 223 return ::null_is_fullscreen( m_videoOutput );
224} 224}
225void Lib::setScaling( bool scale ) { 225void Lib::setScaling( bool scale ) {
226 ::null_set_scaling( m_videoOutput, scale ); 226 ::null_set_scaling( m_videoOutput, scale );
227} 227}
228bool Lib::isScaling() { 228bool Lib::isScaling() {
229 return ::null_is_scaling( m_videoOutput ); 229 return ::null_is_scaling( m_videoOutput );
230} 230}
231void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { 231void Lib::xine_event_handler( void* user_data, xine_event_t* t ) {
232 ((Lib*)user_data)->handleXineEvent( t ); 232 ((Lib*)user_data)->handleXineEvent( t );
233} 233}
234void Lib::xine_display_frame( void* user_data, uint8_t *frame, 234void Lib::xine_display_frame( void* user_data, uint8_t *frame,
235 int width, int height, int bytes ) { 235 int width, int height, int bytes ) {
236 236
237 ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); 237 ((Lib*)user_data)->drawFrame( frame, width, height, bytes );
238} 238}
239void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 239void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
240 if (!m_video ) { 240 if (!m_video ) {
241 qWarning("not showing video now"); 241 qWarning("not showing video now");
242 return; 242 return;
243 } 243 }
244// qWarning("called draw frame %d %d", width, height); 244// qWarning("called draw frame %d %d", width, height);
245 245
246 m_wid->setImage( frame, width, height, bytes ); 246 m_wid->setImage( frame, width, height, bytes );
247// m_wid->repaint(false); 247// m_wid->repaint(false);
248 248
249} 249}