DiracDecodeSourcePin.cpp

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 #include "stdafx.h"
00032 #include ".\DiracDecodeSourcePin.h"
00033 
00034 DiracDecodeSourcePin::DiracDecodeSourcePin(DiracDecodeSourceFilter* inParentFilter, CCritSec* inFilterLock)
00035         :       CBaseOutputPin(NAME("Dirac Video Source Pin"), inParentFilter, inFilterLock, &mFilterHR, L"Video Out")
00036 {
00037 }
00038 
00039 DiracDecodeSourcePin::~DiracDecodeSourcePin(void)
00040 {
00041 }
00042 
00043 STDMETHODIMP DiracDecodeSourcePin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
00044 {
00045         
00046         return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv); 
00047 }
00048 
00049 HRESULT DiracDecodeSourcePin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
00050 {
00051         
00052         mDataQueue->NewSegment(tStart, tStop, dRate);
00053 
00054         return S_OK;
00055 }
00056 HRESULT DiracDecodeSourcePin::DeliverEndOfStream(void)
00057 {
00058         
00059         mDataQueue->EOS();
00060     return S_OK;
00061 }
00062 
00063 HRESULT DiracDecodeSourcePin::DeliverEndFlush(void)
00064 {
00065         mDataQueue->EndFlush();
00066     return S_OK;
00067 }
00068 
00069 HRESULT DiracDecodeSourcePin::DeliverBeginFlush(void)
00070 {
00071         
00072         mDataQueue->BeginFlush();
00073     return S_OK;
00074 }
00075 
00076 HRESULT DiracDecodeSourcePin::CompleteConnect (IPin *inReceivePin)
00077 {
00078         mFilterHR = S_OK;
00079         //Set the delegate for seeking
00080         //((BasicSeekable*)(inReceivePin))->SetDelegate(this);
00081         //This may cause issue if pins are disconnected and reconnected
00082         //DELETE in DEStructor
00083         mDataQueue = new COutputQueue (inReceivePin, &mFilterHR, FALSE, TRUE,1,TRUE, NUM_BUFFERS);
00084         if (FAILED(mFilterHR)) {
00085                 mFilterHR = mFilterHR;
00086         }
00087         
00088         return CBaseOutputPin::CompleteConnect(inReceivePin);
00089 }
00090 
00091 HRESULT DiracDecodeSourcePin::BreakConnect(void) {
00092         delete mDataQueue;
00093         mDataQueue = NULL;
00094         return CBaseOutputPin::BreakConnect();
00095 }
00096 
00097         //CSourceStream virtuals
00098 HRESULT DiracDecodeSourcePin::GetMediaType(int inPosition, CMediaType* outMediaType) {
00099         //Put it in from the info we got in the constructor.
00100         //NOTE::: May have missed some fields ????
00101         //NOTE::: May want to check for null pointers
00102         //outMediaType->SetFormat(mMediaType->Format(), mMediaType->FormatLength());
00103         if (inPosition == 0) {
00104                 CMediaType locMediaType;
00105 
00106                 locMediaType.majortype = MEDIATYPE_Video;
00107                 locMediaType.subtype = MEDIASUBTYPE_YV12;
00108                 locMediaType.formattype = FORMAT_VideoInfo;
00109                 locMediaType.cbFormat = sizeof(VIDEOINFOHEADER);
00110                 locMediaType.pbFormat = NULL; //(BYTE*)mCMMLFormatBlock; //(BYTE*)locSpeexFormatInfo;
00111                 locMediaType.pUnk = NULL;
00112                 *outMediaType = locMediaType;
00113                 return S_OK;
00114         } else {
00115                 return VFW_S_NO_MORE_ITEMS;
00116         }
00117 }
00118 HRESULT DiracDecodeSourcePin::CheckMediaType(const CMediaType* inMediaType) {
00119         if ((inMediaType->majortype == MEDIATYPE_Video) && (inMediaType->subtype == MEDIASUBTYPE_YV12)) {
00120                 return S_OK;
00121         } else {
00122                 return E_FAIL;
00123         }
00124 }
00125 HRESULT DiracDecodeSourcePin::DecideBufferSize(IMemAllocator* inoutAllocator, ALLOCATOR_PROPERTIES* inoutInputRequest) {
00126 
00127         HRESULT locHR = S_OK;
00128 
00129         ALLOCATOR_PROPERTIES locReqAlloc;
00130         ALLOCATOR_PROPERTIES locActualAlloc;
00131 
00132 
00133         locReqAlloc.cbAlign = 1;
00134         locReqAlloc.cbBuffer = BUFFER_SIZE;
00135         locReqAlloc.cbPrefix = 0;
00136         locReqAlloc.cBuffers = NUM_BUFFERS;
00137 
00138         locHR = inoutAllocator->SetProperties(&locReqAlloc, &locActualAlloc);
00139 
00140         if (locHR != S_OK) {
00141                 return locHR;
00142         }
00143         
00144         locHR = inoutAllocator->Commit();
00145 
00146         return locHR;
00147 
00148 }
00149 
00150 

Generated on Tue Feb 15 14:54:15 2005 for oggdsf by  doxygen 1.3.9