Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

libmpeg3plugin.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2001 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef LIBMPEG3_PLUGIN_H 
00021 #define LIBMPEG3_PLUGIN_H
00022 
00023 #include <qstring.h>
00024 #include <qapplication.h>
00025 #include "libmpeg3.h"
00026 #include "mpeg3protos.h"
00027 #include <qpe/mediaplayerplugininterface.h>
00028 
00029 
00030 // #define OLD_MEDIAPLAYER_API
00031 
00032 
00033 class LibMpeg3Plugin : public MediaPlayerDecoder {
00034 
00035 public:
00036     LibMpeg3Plugin() { file = NULL; }
00037     ~LibMpeg3Plugin() { close(); }
00038 
00039     const char *pluginName() { return "LibMpeg3Plugin"; }
00040     const char *pluginComment() { return "This is the libmpeg3 library writen by ... which has been modified by trolltech to use fixed point maths"; }
00041     double pluginVersion() { return 1.0; }
00042 
00043     bool isFileSupported( const QString& fileName ) { return mpeg3_check_sig( (char *)fileName.latin1() ) == 1; }
00044     bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; }
00045     bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; }
00046     bool isOpen() { return file != NULL; }
00047     const QString &fileInfo() { return strInfo = ""; }
00048 
00049     // If decoder doesn't support audio then return 0 here
00050     int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; }
00051     int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; }
00052     int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; }
00053 /*     int audioBitsPerSample(int) { return 0;} */
00054     int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } 
00055     bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; }
00056     long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; }
00057 #ifdef OLD_MEDIAPLAYER_API
00058     bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream );
00059     bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream );
00060     bool audioReadSamples( short *output, int channel, long samples, int stream );
00061     bool audioReReadSamples( short *output, int channel, long samples, int stream );
00062 #else
00063     bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream );
00064 #endif
00065 
00066     // If decoder doesn't support video then return 0 here
00067     int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; }
00068     int videoWidth( int stream ) { return file ? mpeg3_video_width( file, stream ) : 0; }
00069     int videoHeight( int stream ) { return file ? mpeg3_video_height( file, stream ) : 0; }
00070     double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; }
00071     int videoFrames( int stream )
00072 { return file ? mpeg3_video_frames( file, stream ) : 0; }
00073 /*
00074 {
00075     if ( file ) {
00076   int frames = mpeg3_video_frames( file, stream );
00077   if ( frames == 1 ) {
00078       int res = mpeg3_seek_percentage( file, 0.99 );
00079       printf("res: %i\n", res );
00080       mpeg3video_seek( file->vtrack[stream]->video );
00081       frames = mpeg3_get_frame( file, stream );
00082       mpeg3_seek_percentage( file, 0.0 );
00083   }
00084   return frames;
00085     }
00086     return 0;
00087 }
00088 */
00089     bool videoSetFrame( long frame, int stream ) { return file ? mpeg3_set_frame( file, frame, stream) == 1 : FALSE; }
00090     long videoGetFrame( int stream ) { return file ? mpeg3_get_frame( file, stream ) : 0; }
00091     bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream );
00092     bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream );
00093     bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream );
00094 
00095     // Profiling
00096     double getTime() { return file ? mpeg3_get_time( file ) : 0.0; }
00097 
00098     // Ignore if these aren't supported
00099     bool setSMP( int cpus ) { return file ? mpeg3_set_cpus( file, cpus ) == 1 : FALSE; }
00100     bool setMMX( bool useMMX ) { return file ? mpeg3_set_mmx( file, useMMX ) == 1 : FALSE; }
00101 
00102     // Capabilities
00103     bool supportsAudio() { return TRUE; }
00104     bool supportsVideo() { return TRUE; }
00105     bool supportsYUV() { return TRUE; }
00106     bool supportsMMX() { return TRUE; }
00107     bool supportsSMP() { return TRUE; }
00108     bool supportsStereo() { return TRUE; }
00109     bool supportsScaling() { return TRUE; }
00110 
00111     long getPlayTime() { return -1; }
00112 
00113 private:
00114     mpeg3_t *file;
00115     QString strInfo;
00116 
00117 };
00118 
00119 
00120 #endif
00121 

Generated on Sat Nov 5 16:15:37 2005 for OPIE by  doxygen 1.4.2