FLACDecodeInputPin.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 
00034 //Local Includes
00035 #include "FLACdecoderdllstuff.h"
00036 
00037 //External Includes
00038 #include "FLACPushDecoder.h"
00039 #include "IOggDecoder.h"
00040 #include <libOOOgg/OggPacket.h>
00041 #include <libOOOgg/StampedOggPacket.h>
00042 
00043 //STL Includes
00044 //debug only
00045 #include <fstream>
00046 //
00047 using namespace std;
00048 
00049 
00050 class FLACDecodeInputPin
00051         //Base Classes
00052         :       public AbstractTransformInputPin
00053         ,       public IOggDecoder
00054 {
00055 public:
00056         //COM Initialisation
00057         DECLARE_IUNKNOWN
00058         STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
00059 
00060         //Constructors
00061         FLACDecodeInputPin(AbstractTransformFilter* inFilter, CCritSec* inFilterLock, AbstractTransformOutputPin* inOutputPin, vector<CMediaType*> inAcceptableMediaTypes);
00062         virtual ~FLACDecodeInputPin(void);
00063 
00064         virtual HRESULT SetMediaType(const CMediaType* inMediaType);
00065         virtual HRESULT CheckMediaType(const CMediaType *inMediaType);
00066 
00067         virtual STDMETHODIMP BeginFlush();
00068         virtual STDMETHODIMP EndFlush();
00069         virtual STDMETHODIMP EndOfStream(void);
00070         virtual STDMETHODIMP NewSegment(REFERENCE_TIME inStartTime, REFERENCE_TIME inStopTime, double inRate);
00071 
00072         virtual STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES *outRequestedProps);
00073 
00074         virtual STDMETHODIMP FLACDecodeInputPin::Receive(IMediaSample* inSample);
00075 
00076         //IOggDecoder Interface
00077         virtual LOOG_INT64 convertGranuleToTime(LOOG_INT64 inGranule);
00078         virtual LOOG_INT64 mustSeekBefore(LOOG_INT64 inGranule);
00079         virtual IOggDecoder::eAcceptHeaderResult showHeaderPacket(OggPacket* inCodecHeaderPacket);
00080         virtual string getCodecShortName();
00081         virtual string getCodecIdentString();
00082         
00083 protected:
00084 
00085         static const unsigned long DECODED_BUFFER_SIZE = 1<<20;         //1 Meg buffer
00086         
00087         static const unsigned long FLAC_NUM_BUFFERS = 75;
00088         static const unsigned long FLAC_BUFFER_SIZE = 65536; //Check
00089 
00090         //Implementation of pure virtuals from AbstractTransformInputPin
00091         virtual bool ConstructCodec();
00092         virtual void DestroyCodec();
00093         virtual HRESULT TransformData(unsigned char* inBuf, long inNumBytes);
00094 
00095         //Member Data
00096         bool mGotMetaData;
00097         FLACPushDecoder mFLACDecoder;
00098         CCritSec* mCodecLock;
00099         unsigned long mUptoFrame;
00100 
00101         OggPacket* mMetadataPacket;
00102 
00103         enum eFLACType {
00104                 FT_UNKNOWN,
00105                 FT_CLASSIC,
00106                 FT_OGG_FLAC_1,
00107         };
00108 
00109         eFLACType mFLACType;
00110 
00111         enum eFLACSetupState {
00112                 VSS_SEEN_NOTHING,
00113                 VSS_SEEN_BOS,
00114                 VSS_SEEN_COMMENT,
00115                 VSS_ALL_HEADERS_SEEN,
00116                 VSS_ERROR
00117         };
00118 
00119         eFLACSetupState mSetupState;
00120 
00121         unsigned long mDecodedByteCount;
00122         unsigned char* mDecodedBuffer;
00123 
00124         __int64 mRateNumerator;
00125         static const __int64 RATE_DENOMINATOR = 65536;
00126 
00127 
00128         
00129         //debug only
00130         //fstream debugLog;
00131         //
00132 
00133 };

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