VorbisDecodeInputPin.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 <vector>
00034 #include <fstream>
00035 using namespace std;
00036 #include "vorbisdecoderdllstuff.h"
00037 
00038 
00039 
00040 #include "IOggDecoder.h"
00041 #include "IOggOutputPin.h"
00042 #include "AbstractTransformInputPin.h"
00043 #include "VorbisDecodeInputPin.h"
00044 
00045 #include "VorbisDecodeFilter.h"
00046 
00047 extern "C" {
00048 //#include <fishsound/fishsound.h>
00049 #include "fish_cdecl.h"
00050 }
00051 
00052 class VorbisDecodeOutputPin;
00053 
00054 class VorbisDecodeInputPin 
00055         :       public AbstractTransformInputPin
00056         ,       public IOggDecoder
00057 {
00058 public:
00059 
00060         DECLARE_IUNKNOWN
00061         STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
00062         VorbisDecodeInputPin(AbstractTransformFilter* inFilter, CCritSec* inFilterLock, AbstractTransformOutputPin* inOutputPin, vector<CMediaType*> inAcceptableMediaTypes);
00063         virtual ~VorbisDecodeInputPin(void);
00064         static int __cdecl VorbisDecoded (FishSound* inFishSound, float** inPCM, long inFrames, void* inThisPointer);
00065 
00066         virtual HRESULT SetMediaType(const CMediaType* inMediaType);
00067         virtual HRESULT CheckMediaType(const CMediaType *inMediaType);
00068         virtual STDMETHODIMP NewSegment(REFERENCE_TIME inStartTime, REFERENCE_TIME inStopTime, double inRate);
00069         virtual STDMETHODIMP EndFlush();
00070 
00071         virtual STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES *outRequestedProps);
00072         virtual HRESULT CompleteConnect(IPin *inReceivePin);
00073 
00074         //Overriden from AbstractTransform input pin
00075         virtual STDMETHODIMP Receive(IMediaSample* inSample);
00076 
00077         //IOggDecoder Interface
00078         virtual LOOG_INT64 convertGranuleToTime(LOOG_INT64 inGranule);
00079         virtual LOOG_INT64 mustSeekBefore(LOOG_INT64 inGranule);
00080         virtual IOggDecoder::eAcceptHeaderResult showHeaderPacket(OggPacket* inCodecHeaderPacket);
00081         virtual string getCodecShortName();
00082         virtual string getCodecIdentString();
00083 
00084 
00085 
00086 protected:
00087         //fstream debugLog;
00088 
00089         static const unsigned long DECODED_BUFFER_SIZE = 1<<20;         //1 Meg buffer
00090 
00091         enum eVorbisSetupState {
00092                 VSS_SEEN_NOTHING,
00093                 VSS_SEEN_BOS,
00094                 VSS_SEEN_COMMENT,
00095                 VSS_ALL_HEADERS_SEEN,
00096                 VSS_ERROR
00097         };
00098 
00099         eVorbisSetupState mSetupState;
00100 
00101         static const unsigned long VORBIS_IDENT_HEADER_SIZE = 30;
00102         static const unsigned long VORBIS_NUM_BUFFERS = 75;
00103         static const unsigned long VORBIS_BUFFER_SIZE = 65536;
00104 
00105         //Implementation of virtuals from AbstractTransform Filter
00106         virtual bool ConstructCodec();
00107         virtual void DestroyCodec();
00108         virtual HRESULT TransformData(unsigned char* inBuf, long inNumBytes);
00109 
00110         HRESULT mHR;
00111         bool mBegun;
00112 
00113         FishSound* mFishSound;
00114         FishSoundInfo mFishInfo; 
00115 
00116         int mNumChannels;
00117         int mFrameSize;
00118         int mSampleRate;
00119         unsigned int mUptoFrame;
00120 
00121         unsigned char* mDecodedBuffer;
00122         unsigned long mDecodedByteCount;
00123 
00124         __int64 mRateNumerator;
00125         static const __int64 RATE_DENOMINATOR = 65536;
00126 
00127         IOggOutputPin* mOggOutputPinInterface;
00128         bool mSentStreamOffset;
00129 
00130 };
00131 

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