00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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
00080
00081
00082
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
00098 HRESULT DiracDecodeSourcePin::GetMediaType(int inPosition, CMediaType* outMediaType) {
00099
00100
00101
00102
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;
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