30 #ifndef __DIRECTSHOWDECODER_H__
31 #define __DIRECTSHOWDECODER_H__
43 #define RESTORE__DEBUG
52 #include <atlcomcli.h>
69 struct __declspec(uuid("{71771540-2017-11cf-ae26-0020afd79767}
")) CLSID_TextureRenderer;
76 class H3DAPI_API DirectShowDecoder : public H3DVideoClipDecoderNode {
79 class DShowEventHandler: public AutoUpdate< SFTime > {
80 virtual void update();
85 class CFrameGrabber: public CBaseVideoRenderer {
88 CFrameGrabber(LPUNKNOWN pUnk, HRESULT *phr, DirectShowDecoder *d );
90 // CBaseVideoRenderer functions
93 HRESULT CheckMediaType(const CMediaType *pmt );
96 HRESULT SetMediaType(const CMediaType *pmt );
99 HRESULT DoRenderSample(IMediaSample *pMediaSample);
104 void OnReceiveFirstSample(IMediaSample *pSample) {
105 DoRenderSample( pSample );
108 DirectShowDecoder *decoder;
111 friend class CFrameGrabber;
118 ~DirectShowDecoder();
121 virtual bool loadClip( const string &url );
124 virtual void startPlaying();
128 virtual void stopPlaying();
131 virtual void pausePlaying();
135 virtual void setLooping( bool v ) {
140 virtual H3DTime getPosition();
143 virtual void setPosition( H3DTime pos );
149 virtual bool setRate( double r ) {
153 hr = g_pMS->SetRate( r );
161 virtual H3DTime getDuration() {
166 virtual bool haveNewFrame() { return have_new_frame; }
169 virtual void getNewFrame( unsigned char *buffer );
172 virtual unsigned int getFrameWidth() { return frame_width; }
175 virtual unsigned int getFrameHeight() { return frame_height; }
178 virtual unsigned int getFrameBitsPerPixel() { return 24; }
181 virtual unsigned int getFrameSize() {
186 virtual unsigned int getFrameByteAlignment() {
191 virtual Image::PixelType getFramePixelType() { return Image::BGR; }
194 virtual Image::PixelComponentType getFramePixelComponentType() {
195 return Image::UNSIGNED;
199 static H3DNodeDatabase database;
202 static DecoderRegistration reader_registration;
206 static bool supportsFileType( const string &url );
208 // DirectShow pointers
209 CComPtr<IGraphBuilder> g_pGB; // GraphBuilder
210 CComPtr<IMediaControl> g_pMC; // Media Control
211 CComPtr<IMediaSeeking> g_pMS; // Media Seeking
212 CComPtr<IMediaEvent> g_pME; // Media Event
213 CComPtr<IBaseFilter> g_pRenderer; // our custom renderer
216 HRESULT initDShowTextureRenderer( const string &url );
220 void cleanupDShow( void );
223 unsigned int frame_width;
226 unsigned int frame_height;
229 unsigned int frame_size;
232 unsigned int data_size;
245 CFrameGrabber *frame_grabber;
254 H3DUniquePtr< DShowEventHandler > event_handler;
Contains different templates to modify field behaviour.
Header file for H3DVideoClipDecoderNode, the abstract base class for all nodes the decodes video clip...
Contains the SFTime field class.
H3D API namespace.
Definition: Anchor.h:38