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
00032
00033
00034
00035 #include "stdafx.h"
00036 #include "cmmlsourcepin.h"
00037
00038 CMMLSourcePin::CMMLSourcePin( TCHAR* inObjectName,
00039 OggDemuxSourceFilter* inParentFilter,
00040 CCritSec* inFilterLock,
00041 StreamHeaders* inHeaderSource,
00042 CMediaType* inMediaType,
00043 wstring inPinName,
00044 unsigned long inNumBuffers,
00045 unsigned long inBufferSize)
00046 : OggDemuxSourcePin(inObjectName, inParentFilter, inFilterLock, inHeaderSource, inMediaType, inPinName, true, inNumBuffers, inBufferSize)
00047 {
00048
00049 }
00050
00051 CMMLSourcePin::~CMMLSourcePin(void)
00052 {
00053 }
00054
00055
00056 STDMETHODIMP CMMLSourcePin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
00057 {
00058 if (riid == IID_IMediaSeeking) {
00059 *ppv = (IMediaSeeking*)this;
00060 ((IUnknown*)*ppv)->AddRef();
00061 return NOERROR;
00062 }
00063
00064 return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
00065 }
00066 STDMETHODIMP CMMLSourcePin::Render(IPin* inOutputPin, IGraphBuilder* inGraphBuilder) {
00067 if (inOutputPin == NULL || inGraphBuilder == NULL) {
00068 return E_POINTER;
00069 }
00070
00071
00072 IBaseFilter* locCMMLFilter = NULL;
00073
00074
00075
00076 HRESULT locHR = S_OK;
00077
00078 if (locCMMLFilter == NULL) {
00079 locHR= CoCreateInstance(CLSID_CMMLDecodeFilter, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void **)&locCMMLFilter);
00080 if (locHR != S_OK) {
00081 return locHR;
00082 }
00083
00084 locHR = inGraphBuilder->AddFilter(locCMMLFilter, L"CMML Decode Filter");
00085 if (locHR != S_OK) {
00086 locCMMLFilter->Release();
00087 return locHR;
00088 }
00089 }
00090
00091 IEnumPins* locEnumPins;
00092 IPin* locCMMLInputPin = NULL;
00093 locHR = locCMMLFilter->EnumPins(&locEnumPins);
00094
00095 if (SUCCEEDED(locHR)) {
00096 if (S_OK != locEnumPins->Next(1, &locCMMLInputPin, 0)) {
00097 locHR = E_UNEXPECTED;
00098 }
00099 }
00100
00101 if (SUCCEEDED(locHR)) {
00102
00103
00104
00105
00107
00108
00109 locHR = inGraphBuilder->ConnectDirect(inOutputPin, locCMMLInputPin, mMediaType);
00110 locCMMLInputPin->Release();
00111 }
00112 if (FAILED(locHR))
00113 {
00114
00115 inGraphBuilder->RemoveFilter(locCMMLFilter);
00116 }
00117 locCMMLFilter->Release();
00118
00119 return locHR;
00120
00121
00122 }
00123 STDMETHODIMP CMMLSourcePin::Backout(IPin* inOutputPin, IGraphBuilder* inGraphBuilder) {
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 return S_OK;
00149 }
00150
00151 bool CMMLSourcePin::deliverOggPacket(StampedOggPacket* inPacket) {
00152
00153
00154
00155
00156 CAutoLock locStreamLock(mParentFilter->mStreamLock);
00157 IMediaSample* locSample = NULL;
00158 REFERENCE_TIME locStart = inPacket->endTime() * 10000;
00159 REFERENCE_TIME locStop = inPacket->endTime() * 10000;
00160
00161
00162 DbgLog((LOG_TRACE, 2, "Getting Buffer in Source Pin..."));
00163
00164
00165 HRESULT locHR = GetDeliveryBuffer(&locSample, &locStart, &locStop, NULL);
00166 DbgLog((LOG_TRACE, 2, "* After get Buffer in Source Pin..."));
00167
00168 if (locHR != S_OK) {
00169 DbgLog((LOG_TRACE, 2, "Getting Delivery Buff FAILED"));
00170
00171
00172 return false;
00173 }
00174
00175
00176
00177
00178
00179 locSample->SetTime(&locStart, &locStop);
00180
00181
00182 locSample->SetMediaTime(&mParentFilter->mSeekTimeBase, &mParentFilter->mSeekTimeBase);
00183 locSample->SetSyncPoint(TRUE);
00184
00185
00186
00187 BYTE* locBuffer = NULL;
00188 locSample->GetPointer(&locBuffer);
00189
00190 if (locSample->GetSize() >= inPacket->packetSize()) {
00191
00192 memcpy((void*)locBuffer, (const void*)inPacket->packetData(), inPacket->packetSize());
00193 locSample->SetActualDataLength(inPacket->packetSize());
00194
00195 locHR = mDataQueue->Receive(locSample);
00196
00197 if (locHR != S_OK) {
00198
00199
00200 return false;
00201
00202 } else {
00203
00204 return true;
00205 }
00206 } else {
00207 throw 0;
00208 }
00209 }