SpeexDecodeInputPin.h

Go to the documentation of this file.
00001 //===========================================================================
00002 //Copyright (C) 2003, 2004 Zentaro Kavanagh
00003 //
00004 //Redistribution and use in source and binary forms, with or without
00005 //modification, are permitted provided that the following conditions
00006 //are met:
00007 //
00008 //- Redistributions of source code must retain the above copyright
00009 //  notice, this list of conditions and the following disclaimer.
00010 //
00011 //- Redistributions in binary form must reproduce the above copyright
00012 //  notice, this list of conditions and the following disclaimer in the
00013 //  documentation and/or other materials provided with the distribution.
00014 //
00015 //- Neither the name of Zentaro Kavanagh nor the names of contributors 
00016 //  may be used to endorse or promote products derived from this software 
00017 //  without specific prior written permission.
00018 //
00019 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020 //``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021 //LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00022 //PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
00023 //CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00024 //EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00025 //PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00026 //PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00027 //LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028 //NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 //===========================================================================
00031 
00032 #pragma once
00033 #include "speexdecoderdllstuff.h"
00034 #include "IOggDecoder.h"
00035 #include "AbstractTransformInputPin.h"
00036 #include "SpeexDecodeInputPin.h"
00037 
00038 #include "SpeexDecodeFilter.h"
00039 
00040 extern "C" {
00041 //#include <fishsound/fishsound.h>
00042 #include "fish_cdecl.h"
00043 }
00044 
00045 class SpeexDecodeOutputPin;
00046 
00047 class SpeexDecodeInputPin 
00048         :       public AbstractTransformInputPin
00049         ,       public IOggDecoder
00050 {
00051 public:
00052         DECLARE_IUNKNOWN
00053         STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
00054         SpeexDecodeInputPin(AbstractTransformFilter* inFilter, CCritSec* inFilterLock, AbstractTransformOutputPin* inOutputPin, vector<CMediaType*> inAcceptableMediaTypes);
00055         virtual ~SpeexDecodeInputPin(void);
00056         
00057         static int __cdecl SpeexDecoded (FishSound* inFishSound, float** inPCM, long inFrames, void* inThisPointer);
00058 
00059 
00060         virtual HRESULT SetMediaType(const CMediaType* inMediaType);
00061         virtual HRESULT CheckMediaType(const CMediaType *inMediaType);
00062         virtual STDMETHODIMP NewSegment(REFERENCE_TIME inStartTime, REFERENCE_TIME inStopTime, double inRate);
00063         virtual STDMETHODIMP EndFlush();
00064 
00065         virtual STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES *outRequestedProps);
00066 
00067         virtual STDMETHODIMP Receive(IMediaSample* inSample);
00068 
00069         //IOggDecoder Interface
00070         virtual LOOG_INT64 convertGranuleToTime(LOOG_INT64 inGranule);
00071         virtual LOOG_INT64 mustSeekBefore(LOOG_INT64 inGranule);
00072         virtual IOggDecoder::eAcceptHeaderResult showHeaderPacket(OggPacket* inCodecHeaderPacket);
00073         virtual string getCodecShortName();
00074         virtual string getCodecIdentString();
00075 
00076 
00077 protected:
00078         static const unsigned long DECODED_BUFFER_SIZE = 1<<20;         //1 Meg buffer
00079         static const unsigned long SPEEX_IDENT_HEADER_SIZE = 80;
00080         static const unsigned long SPEEX_NUM_BUFFERS = 75;
00081         static const unsigned long SPEEX_BUFFER_SIZE = 65536;
00082 
00083         //Implementation of pure virtuals from AbstractTransformInputPin
00084         virtual bool ConstructCodec();
00085         virtual void DestroyCodec();
00086         virtual HRESULT TransformData(unsigned char* inBuf, long inNumBytes);
00087 
00088         FishSound* mFishSound;
00089         FishSoundInfo mFishInfo; 
00090 
00091         int mNumChannels;
00092         int mFrameSize;
00093         int mSampleRate;
00094         unsigned int mUptoFrame;
00095 
00096         bool mBegun;
00097 
00098         unsigned char* mDecodedBuffer;
00099 
00100         unsigned long mDecodedByteCount;
00101 
00102         enum eSpeexSetupState {
00103                 VSS_SEEN_NOTHING,
00104                 VSS_SEEN_BOS,
00105                 VSS_SEEN_COMMENT,
00106                 VSS_ALL_HEADERS_SEEN,
00107                 VSS_ERROR
00108         };
00109 
00110         eSpeexSetupState mSetupState;
00111 
00112         __int64 mRateNumerator;
00113         static const __int64 RATE_DENOMINATOR = 65536;
00114 
00115 
00116 
00117 };

Generated on Thu Feb 16 23:48:08 2006 for oggdsf by  doxygen 1.3.9