00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028
00030 #ifndef __H3DVIDEOCLIPDECODERNODE_H__
00031 #define __H3DVIDEOCLIPDECODERNODE_H__
00032
00033 #include "Node.h"
00034 #include "Image.h"
00035 #include <list>
00036
00037 namespace H3D {
00038
00043 class H3DAPI_API H3DVideoClipDecoderNode : public Node {
00044 protected:
00045 typedef enum {
00046 PLAYING = 0,
00047 STOPPED = 1,
00048 PAUSED = 2
00049 } PlayStatus;
00050
00051 public:
00052 typedef H3DVideoClipDecoderNode*( *CreateNodeFunc)();
00053
00055 typedef bool ( *SupportsFileFunc)( const string &url );
00056
00057 template< class N >
00058 static H3DVideoClipDecoderNode *newImageLoaderNode() { return new N; };
00059
00061 struct H3DAPI_API DecoderRegistration{
00062 public:
00064 DecoderRegistration( const string &_name,
00065 CreateNodeFunc _create,
00066 SupportsFileFunc _supports ):
00067 name( _name ),
00068 create_func( _create ),
00069 supports_func( _supports ) {
00070
00071 if( !H3DVideoClipDecoderNode::initialized ) {
00072 H3DVideoClipDecoderNode::registered_decoders =
00073 new list< DecoderRegistration >;
00074 initialized = true;
00075 }
00076 H3DVideoClipDecoderNode::registerDecoder( *this );
00077 }
00078
00079 string name;
00080 CreateNodeFunc create_func;
00081 SupportsFileFunc supports_func;
00082 };
00083
00085 H3DVideoClipDecoderNode():
00086 status( STOPPED ) {
00087 type_name = "H3DVideoClipDecoderNode";
00088 }
00089
00092 virtual bool loadClip( const string &url ) = 0;
00093
00095 virtual bool haveNewFrame() = 0;
00096
00098 virtual void getNewFrame( unsigned char *buffer ) = 0;
00099
00101 virtual unsigned int getFrameSize() = 0;
00102
00104 virtual unsigned int getFrameWidth() = 0;
00105
00107 virtual unsigned int getFrameHeight() = 0;
00108
00110 virtual Image::PixelType getFramePixelType() = 0;
00111
00113 virtual Image::PixelComponentType getFramePixelComponentType() = 0;
00114
00116 virtual unsigned int getFrameBitsPerPixel() = 0;
00117
00119 virtual void startPlaying() = 0;
00120
00123 virtual void stopPlaying() = 0;
00124
00126 virtual void pausePlaying() = 0;
00127
00130 virtual void setLooping( bool on ) = 0;
00131
00133 virtual H3DTime getPosition() = 0;
00134
00136 virtual void setPosition( H3DTime pos ) = 0;
00137
00141 virtual bool setRate( double r ) = 0;
00142
00145 virtual H3DTime getDuration() = 0;
00146
00148 inline PlayStatus getPlayStatus() { return status; }
00149
00153 virtual string defaultXMLContainerField() {
00154 return "decoder";
00155 }
00156
00161 static H3DVideoClipDecoderNode *getSupportedDecoder( const string &url );
00162
00169 static void registerDecoder( const string &name,
00170 CreateNodeFunc create,
00171 SupportsFileFunc supports ) {
00172 registerDecoder( DecoderRegistration( name, create, supports ) );
00173 }
00174
00177 static void registerDecoder( const DecoderRegistration &fr ) {
00178 registered_decoders->push_back( fr );
00179 }
00180
00181 protected:
00182 static list< DecoderRegistration > *registered_decoders;
00183 static bool initialized;
00184 PlayStatus status;
00185 };
00186 }
00187
00188 #endif