43 return CoCreateInstance(CLSID_MemoryAllocator,
47 (
void **)ppAllocator);
53 __in_opt LPUNKNOWN pAgg,
56 __deref_out IUnknown **ppPassThru
61 HRESULT
hr = CoCreateInstance(CLSID_SeekingPassThru,
71 ISeekingPassThru *pPassThru;
72 hr = pUnkSeek->QueryInterface(IID_ISeekingPassThru, (
void**)&pPassThru);
77 hr = pPassThru->Init(bRenderer, pPin);
83 *ppPassThru = pUnkSeek;
89 #define CONNECT_TRACE_LEVEL 3
101 __inout_opt LPUNKNOWN pUnk,
107 m_State(State_Stopped),
134 __deref_out
void ** ppv)
136 if (
riid == IID_IMediaFilter) {
138 }
else if (
riid == IID_IPersist) {
160 UNREFERENCED_PARAMETER(dwMSecs);
205 *pClock = (IReferenceClock*)
m_pClock;
274 return VFW_E_NO_CLOCK;
278 HRESULT
hr =
m_pClock->GetTime((REFERENCE_TIME*)&rtStream);
300 __deref_out
void **ppv)
304 if (
riid == IID_IBaseFilter) {
306 }
else if (
riid == IID_IMediaFilter) {
308 }
else if (
riid == IID_IPersist) {
310 }
else if (
riid == IID_IAMovieSetup) {
323 return CUnknown::NonDelegatingRelease();
331 __inout_opt LPUNKNOWN pUnk,
337 m_State(State_Stopped),
354 __in_opt LPUNKNOWN pUnk,
357 __inout HRESULT *phr) :
361 m_State(State_Stopped),
373 UNREFERENCED_PARAMETER(phr);
378 __in_opt LPUNKNOWN pUnk,
384 m_State(State_Stopped),
398 __in_opt LPUNKNOWN pUnk,
401 __inout HRESULT *phr) :
405 m_State(State_Stopped),
417 UNREFERENCED_PARAMETER(phr);
458 UNREFERENCED_PARAMETER(dwMSecs);
503 *pClock = (IReferenceClock*)
m_pClock;
515 HRESULT
hr = NOERROR;
518 if (
m_State != State_Stopped) {
520 for (
int c = 0; c < cPins; c++) {
535 if (FAILED(hrTmp) && SUCCEEDED(
hr)) {
560 if (
m_State == State_Stopped) {
562 for (
int c = 0; c < cPins; c++) {
615 if (
m_State != State_Running) {
617 for (
int c = 0; c < cPins; c++) {
628 HRESULT
hr = pPin->
Run(tStart);
655 return VFW_E_NO_CLOCK;
659 HRESULT
hr =
m_pClock->GetTime((REFERENCE_TIME*)&rtStream);
684 return *ppEnum ==
NULL ? E_OUTOFMEMORY : NOERROR;
693 __deref_out IPin ** ppPin
702 for (
int i = 0; i < iCount; i++) {
708 if (0 == lstrcmpW(pPin->
Name(), Id)) {
718 return VFW_E_NOT_FOUND;
732 pInfo->achName[0] = L
'\0';
745 __inout_opt IFilterGraph * pGraph,
746 __in_opt LPCWSTR
pName)
754 HRESULT
hr =
m_pGraph->QueryInterface(IID_IMediaEventSink,
775 HRESULT
hr = StringCchLengthW(
pName, STRSAFE_MAX_CCH, &namelen);
779 m_pName =
new WCHAR[namelen + 1];
783 return E_OUTOFMEMORY;
800 __deref_out LPWSTR* pVendorInfo)
802 UNREFERENCED_PARAMETER(pVendorInfo);
813 LONG_PTR EventParam1,
814 LONG_PTR EventParam2)
817 IMediaEventSink *pSink =
m_pSink;
819 if (EC_COMPLETE == EventCode) {
820 EventParam2 = (LONG_PTR)(IBaseFilter*)
this;
823 return pSink->Notify(EventCode, EventParam1, EventParam2);
836 __in_opt AM_MEDIA_TYPE
const *pmt
839 IFilterGraph2 *pGraph2;
841 HRESULT
hr =
m_pGraph->QueryInterface(IID_IFilterGraph2, (
void **)&pGraph2);
843 hr = pGraph2->ReconnectEx(pPin, pmt);
850 return E_NOINTERFACE;
884 if(
NULL == psetupdata )
return S_FALSE;
889 HRESULT
hr = CoInitialize( (LPVOID)
NULL );
895 hr = CoCreateInstance( CLSID_FilterMapper
897 , CLSCTX_INPROC_SERVER
908 CoFreeUnusedLibraries();
925 if(
NULL == psetupdata )
return S_FALSE;
930 HRESULT
hr = CoInitialize( (LPVOID)
NULL );
936 hr = CoCreateInstance( CLSID_FilterMapper
938 , CLSCTX_INPROC_SERVER
952 CoFreeUnusedLibraries();
960 if( 0x80070002 ==
hr)
980 m_PinCache(
NAME(
"Pin Cache"))
996 if (pEnumPins ==
NULL) {
1000 ASSERT(m_Position <= m_PinCount);
1001 m_Position = pEnumPins->m_Position;
1002 m_PinCount = pEnumPins->m_PinCount;
1003 m_Version = pEnumPins->m_Version;
1004 m_PinCache.
AddTail(&(pEnumPins->m_PinCache));
1016 m_pFilter->Release();
1033 if (
riid == IID_IEnumPins ||
riid == IID_IUnknown) {
1037 return E_NOINTERFACE;
1044 return InterlockedIncrement(&m_cRef);
1048 CEnumPins::Release()
1050 ULONG cRef = InterlockedDecrement(&m_cRef);
1066 HRESULT
hr = NOERROR;
1069 if (AreWeOutOfSync() == TRUE) {
1071 hr = VFW_E_ENUM_OUT_OF_SYNC;
1075 if (*ppEnum ==
NULL) {
1087 __out_ecount(cPins) IPin **ppPins,
1088 __out_opt
ULONG *pcFetched)
1095 if (pcFetched!=
NULL) {
1101 return E_INVALIDARG;
1106 if (AreWeOutOfSync() == TRUE) {
1120 while (cFetched < cPins && m_PinCount > m_Position) {
1130 return VFW_E_ENUM_OUT_OF_SYNC;
1134 if (0 == m_PinCache.
Find(pPin))
1148 if (pcFetched!=
NULL) {
1149 *pcFetched = cFetched;
1152 return (cPins==cFetched ? NOERROR : S_FALSE);
1162 if (AreWeOutOfSync() == TRUE) {
1163 return VFW_E_ENUM_OUT_OF_SYNC;
1170 ULONG PinsLeft = m_PinCount - m_Position;
1171 if (cPins > PinsLeft) {
1174 m_Position += cPins;
1212 CEnumPins::Refresh()
1249 if (pEnumMediaTypes ==
NULL) {
1254 m_Position = pEnumMediaTypes->m_Position;
1255 m_Version = pEnumMediaTypes->m_Version;
1282 if (
riid == IID_IEnumMediaTypes ||
riid == IID_IUnknown) {
1286 return E_NOINTERFACE;
1291 CEnumMediaTypes::AddRef()
1293 return InterlockedIncrement(&m_cRef);
1297 CEnumMediaTypes::Release()
1299 ULONG cRef = InterlockedDecrement(&m_cRef);
1315 HRESULT
hr = NOERROR;
1318 if (AreWeOutOfSync() == TRUE) {
1320 hr = VFW_E_ENUM_OUT_OF_SYNC;
1326 if (*ppEnum ==
NULL) {
1346 __out_ecount(cMediaTypes) AM_MEDIA_TYPE **ppMediaTypes,
1347 __out
ULONG *pcFetched)
1352 if (AreWeOutOfSync() == TRUE) {
1353 return VFW_E_ENUM_OUT_OF_SYNC;
1356 if (pcFetched!=
NULL) {
1361 else if (cMediaTypes>1) {
1362 return E_INVALIDARG;
1372 while (cMediaTypes) {
1390 *ppMediaTypes = (AM_MEDIA_TYPE *)CoTaskMemAlloc(
sizeof(AM_MEDIA_TYPE));
1391 if (*ppMediaTypes ==
NULL) {
1396 **ppMediaTypes = cmt;
1399 cmt.pbFormat =
NULL;
1400 cmt.cbFormat =
NULL;
1409 if (pcFetched!=
NULL) {
1410 *pcFetched = cFetched;
1413 return ( cMediaTypes==0 ? NOERROR : S_FALSE );
1424 if (cMediaTypes == 0) {
1429 if (AreWeOutOfSync() == TRUE) {
1430 return VFW_E_ENUM_OUT_OF_SYNC;
1433 m_Position += cMediaTypes;
1437 return S_OK == m_pPin->
GetMediaType(m_Position - 1, &cmt) ? S_OK : S_FALSE;
1484 __inout HRESULT *phr,
1485 __in_opt LPCWSTR
pName,
1486 PIN_DIRECTION dir) :
1493 m_bRunTimeError(FALSE),
1498 m_bCanReconnectWhenActive(
false),
1499 m_bTryMyTypesFirst(
false),
1518 HRESULT
hr = StringCchLengthW(
pName, STRSAFE_MAX_CCH, &cchName);
1519 if (SUCCEEDED(
hr)) {
1520 m_pName =
new WCHAR[cchName + 1];
1536 __inout HRESULT *phr,
1537 __in_opt LPCWSTR
pName,
1538 PIN_DIRECTION dir) :
1545 m_bRunTimeError(FALSE),
1550 m_bCanReconnectWhenActive(
false),
1551 m_bTryMyTypesFirst(
false),
1570 HRESULT
hr = StringCchLengthW(
pName, STRSAFE_MAX_CCH, &cchName);
1571 if (SUCCEEDED(
hr)) {
1572 m_pName =
new WCHAR[cchName + 1];
1614 if (
riid == IID_IPin) {
1616 }
else if (
riid == IID_IQualityControl) {
1627 CBasePin::NonDelegatingAddRef()
1637 CBasePin::NonDelegatingRelease()
1652 PIN_INFO ConnectPinInfo;
1653 PIN_INFO ReceivePinInfo;
1656 StringCchCopyW(ConnectPinInfo.achName,
sizeof(ConnectPinInfo.achName)/
sizeof(WCHAR), L
"Bad Pin");
1661 if (FAILED(pReceivePin->QueryPinInfo(&ReceivePinInfo))) {
1662 StringCchCopyW(ReceivePinInfo.achName,
sizeof(ReceivePinInfo.achName)/
sizeof(WCHAR), L
"Bad Pin");
1680 UNREFERENCED_PARAMETER(pPin);
1684 GuidNames[*pmt->
Type()]));
1700 __in_opt
const AM_MEDIA_TYPE *pmt
1712 return VFW_E_ALREADY_CONNECTED;
1717 return VFW_E_NOT_STOPPED;
1784 if (
hr == NOERROR) {
1792 if (SUCCEEDED(
hr)) {
1795 hr = pReceivePin->ReceiveConnection((IPin *)
this, pmt);
1796 if (SUCCEEDED(
hr)) {
1800 if (SUCCEEDED(
hr)) {
1805 TEXT(
"Failed to complete connection")));
1806 pReceivePin->Disconnect();
1816 if (SUCCEEDED(
hr) ||
1818 (
hr == E_INVALIDARG)) {
1819 hr = VFW_E_TYPE_NOT_ACCEPTED;
1850 IEnumMediaTypes *pEnum)
1854 HRESULT
hr = pEnum->Reset();
1860 ULONG ulMediaCount = 0;
1863 HRESULT hrFailure = S_OK;
1872 hr = pEnum->Next(1, (AM_MEDIA_TYPE**)&pMediaType,&ulMediaCount);
1874 if (S_OK == hrFailure) {
1875 hrFailure = VFW_E_NO_ACCEPTABLE_TYPES;
1881 ASSERT(ulMediaCount == 1);
1888 pMediaType->MatchesPartial(pmt))) {
1894 SUCCEEDED(hrFailure) &&
1896 (
hr != E_INVALIDARG) &&
1897 (
hr != VFW_E_TYPE_NOT_ACCEPTED)) {
1901 hr = VFW_E_NO_ACCEPTABLE_TYPES;
1930 IEnumMediaTypes *pEnumMediaTypes =
NULL;
1945 HRESULT hrFailure = VFW_E_NO_ACCEPTABLE_TYPES;
1947 for (
int i = 0; i < 2; i++) {
1950 hr = pReceivePin->EnumMediaTypes(&pEnumMediaTypes);
1954 if (SUCCEEDED(
hr)) {
1957 pEnumMediaTypes->Release();
1958 if (SUCCEEDED(
hr)) {
1962 if ((
hr != E_FAIL) &&
1963 (
hr != E_INVALIDARG) &&
1964 (
hr != VFW_E_TYPE_NOT_ACCEPTED)) {
1981 UNREFERENCED_PARAMETER(pReceivePin);
2012 pPin->QueryDirection(&pd);
2014 ASSERT((pd == PINDIR_OUTPUT) || (pd == PINDIR_INPUT));
2019 return VFW_E_INVALID_DIRECTION;
2042 const AM_MEDIA_TYPE *pmt
2053 return VFW_E_ALREADY_CONNECTED;
2058 return VFW_E_NOT_STOPPED;
2078 if (
hr != NOERROR) {
2088 if (SUCCEEDED(
hr) ||
2090 (
hr == E_INVALIDARG)) {
2091 hr = VFW_E_TYPE_NOT_ACCEPTED;
2106 if (SUCCEEDED(
hr)) {
2108 if (SUCCEEDED(
hr)) {
2143 return VFW_E_NOT_STOPPED;
2156 if( FAILED(
hr ) ) {
2163 DbgBreak(
"WARNING: BreakConnect() failed in CBasePin::Disconnect()." );
2190 __deref_out IPin **ppPin
2207 return VFW_E_NOT_CONNECTED;
2214 __out AM_MEDIA_TYPE *pmt
2227 return VFW_E_NOT_CONNECTED;
2235 __out PIN_INFO * pInfo
2249 pInfo->achName[0] = L
'\0';
2259 __out PIN_DIRECTION * pPinDir
2272 __deref_out LPWSTR * Id
2288 const AM_MEDIA_TYPE *pmt
2316 __deref_out IEnumMediaTypes **ppEnum
2327 if (*ppEnum ==
NULL) {
2328 return E_OUTOFMEMORY;
2342 UNREFERENCED_PARAMETER(iPosition);
2343 UNREFERENCED_PARAMETER(pMediaType);
2344 return E_UNEXPECTED;
2387 UNREFERENCED_PARAMETER(tStart);
2425 UNREFERENCED_PARAMETER(q);
2426 UNREFERENCED_PARAMETER(pSender);
2427 DbgBreak(
"IQualityControl::Notify not over-ridden from CBasePin. (IGNORE is OK)");
2438 REFERENCE_TIME tStart,
2439 REFERENCE_TIME tStop,
2460 __inout HRESULT *phr,
2461 __in_opt LPCWSTR
pName) :
2462 CBasePin(pObjectName, pFilter, pLock, phr,
pName, PINDIR_OUTPUT),
2473 __inout HRESULT *phr,
2474 __in_opt LPCWSTR
pName) :
2475 CBasePin(pObjectName, pFilter, pLock, phr,
pName, PINDIR_OUTPUT),
2490 UNREFERENCED_PARAMETER(pReceivePin);
2514 hr = pPin->QueryInterface(IID_IMemInputPin, (
void **) &
m_pInputPin);
2534 if( FAILED(
hr ) ) {
2577 HRESULT
hr = NOERROR;
2584 ALLOCATOR_PROPERTIES prop;
2585 ZeroMemory(&prop,
sizeof(prop));
2589 pPin->GetAllocatorRequirements(&prop);
2592 if (prop.cbAlign == 0) {
2598 hr = pPin->GetAllocator(ppAlloc);
2599 if (SUCCEEDED(
hr)) {
2602 if (SUCCEEDED(
hr)) {
2603 hr = pPin->NotifyAllocator(*ppAlloc, FALSE);
2604 if (SUCCEEDED(
hr)) {
2613 (*ppAlloc)->Release();
2620 if (SUCCEEDED(
hr)) {
2626 if (SUCCEEDED(
hr)) {
2627 hr = pPin->NotifyAllocator(*ppAlloc, FALSE);
2628 if (SUCCEEDED(
hr)) {
2637 (*ppAlloc)->Release();
2649 __in_opt REFERENCE_TIME * pStartTime,
2650 __in_opt REFERENCE_TIME * pEndTime,
2654 return m_pAllocator->GetBuffer(ppSample,pStartTime,pEndTime,dwFlags);
2656 return E_NOINTERFACE;
2688 return VFW_E_NOT_CONNECTED;
2706 return VFW_E_NOT_CONNECTED;
2719 return VFW_E_NO_ALLOCATOR;
2733 return VFW_E_NO_ALLOCATOR;
2743 return E_UNEXPECTED;
2751 return E_UNEXPECTED;
2758 return E_UNEXPECTED;
2767 return VFW_E_NOT_CONNECTED;
2778 return VFW_E_NOT_CONNECTED;
2785 REFERENCE_TIME tStart,
2786 REFERENCE_TIME tStop,
2790 return VFW_E_NOT_CONNECTED;
2792 return m_Connected->NewSegment(tStart, tStop, dRate);
2808 __inout HRESULT *phr,
2809 __in_opt LPCWSTR pPinName) :
2810 CBasePin(pObjectName, pFilter, pLock, phr, pPinName, PINDIR_INPUT),
2822 __inout HRESULT *phr,
2823 __in_opt LPCWSTR pPinName) :
2824 CBasePin(pObjectName, pFilter, pLock, phr, pPinName, PINDIR_INPUT),
2850 if (
riid == IID_IMemInputPin) {
2871 __deref_out IMemAllocator **ppAllocator)
2897 IMemAllocator * pAllocator,
2905 pAllocator->AddRef();
2908 if (pOldAllocator !=
NULL) {
2909 pOldAllocator->Release();
2929 if( FAILED(
hr ) ) {
2969 IMediaSample2 *pSample2;
2970 if (SUCCEEDED(pSample->QueryInterface(IID_IMediaSample2, (
void **)&pSample2))) {
2972 pSample2->Release();
2982 if (S_OK == pSample->IsDiscontinuity()) {
2985 if (S_OK == pSample->IsPreroll()) {
2988 if (S_OK == pSample->IsSyncPoint()) {
2994 AM_SAMPLE_STOPVALID;
2996 if (S_OK == pSample->GetMediaType(&
m_SampleProps.pMediaType)) {
3006 if (!(
m_SampleProps.dwSampleFlags & AM_SAMPLE_TYPECHANGED)) {
3015 if (
hr == NOERROR) {
3024 return VFW_E_INVALIDMEDIATYPE;
3031 __in_ecount(nSamples) IMediaSample **pSamples,
3033 __out
long *nSamplesProcessed)
3039 *nSamplesProcessed = 0;
3040 while (nSamples-- > 0) {
3041 hr =
Receive(pSamples[*nSamplesProcessed]);
3047 (*nSamplesProcessed)++;
3060 int cOutputPins = 0;
3061 for (
int c = 0; c < cPins; c++) {
3072 if (pd == PINDIR_OUTPUT) {
3076 if (SUCCEEDED(
hr)) {
3079 IMemInputPin *pInputPin;
3080 hr = pConnected->QueryInterface(
3082 (
void **)&pInputPin);
3083 pConnected->Release();
3084 if (SUCCEEDED(
hr)) {
3085 hr = pInputPin->ReceiveCanBlock();
3086 pInputPin->Release();
3087 if (
hr != S_FALSE) {
3097 return cOutputPins == 0 ? S_OK : S_FALSE;
3155 UNREFERENCED_PARAMETER(q);
3158 DbgBreak(
"IQuality::Notify called on an input pin");
3170 return VFW_E_NO_ALLOCATOR;
3184 UNREFERENCED_PARAMETER(pProps);
3198 return VFW_E_WRONG_STATE;
3204 return VFW_E_RUNTIME_ERROR;
3219 DbgLog((
LOG_TRACE,3,TEXT(
"Passing Quality notification through transform")));
3225 IQualityControl * pIQC;
3227 hr = VFW_E_NOT_FOUND;
3229 m_Connected->QueryInterface(IID_IQualityControl, (
void**)&pIQC);
3261 __inout_opt HRESULT *phr,
3262 __in_bcount_opt(length) LPBYTE pBuffer,
3270 m_dwTypeSpecificFlags(0),
3271 m_dwStreamId(AM_STREAM_MEDIA),
3272 m_pAllocator(pAllocator)
3284 *phr = VFW_E_BUFFER_OVERFLOW;
3292 __inout_opt HRESULT *phr,
3293 __in_bcount_opt(length) LPBYTE pBuffer,
3301 m_dwTypeSpecificFlags(0),
3302 m_dwStreamId(AM_STREAM_MEDIA),
3303 m_pAllocator(pAllocator)
3306 PERFLOG_CTOR( L
"CMediaSample", (IMediaSample *)
this );
3321 PERFLOG_DTOR( L
"CMediaSample", (IMediaSample *)
this );
3334 if (
riid == IID_IMediaSample ||
3335 riid == IID_IMediaSample2 ||
3336 riid == IID_IUnknown) {
3340 return E_NOINTERFACE;
3345 CMediaSample::AddRef()
3347 return InterlockedIncrement(&
m_cRef);
3369 CMediaSample::Release()
3377 lRef = InterlockedDecrement(&
m_cRef);
3411 return VFW_E_BUFFER_OVERFLOW;
3432 *ppBuffer = m_pBuffer;
3439 CMediaSample::GetSize(
void)
3448 __out REFERENCE_TIME * pTimeStart,
3449 __out REFERENCE_TIME * pTimeEnd
3457 return VFW_E_SAMPLE_TIME_NOT_SET;
3463 return VFW_S_NO_STOP_TIME;
3477 __in_opt REFERENCE_TIME * pTimeStart,
3478 __in_opt REFERENCE_TIME * pTimeEnd
3481 if (pTimeStart ==
NULL) {
3485 if (pTimeEnd ==
NULL) {
3492 ASSERT(*pTimeEnd >= *pTimeStart);
3506 __out LONGLONG * pTimeStart,
3507 __out LONGLONG * pTimeEnd
3514 return VFW_E_MEDIA_TIME_NOT_SET;
3526 __in_opt LONGLONG * pTimeStart,
3527 __in_opt LONGLONG * pTimeEnd
3530 if (pTimeStart ==
NULL) {
3534 if (
NULL == pTimeEnd) {
3539 ASSERT(*pTimeEnd >= *pTimeStart);
3542 m_MediaEnd = (LONG)(*pTimeEnd - *pTimeStart);
3621 CMediaSample::GetActualDataLength(
void)
3631 ASSERT(lActual <= GetSize());
3632 return VFW_E_BUFFER_OVERFLOW;
3651 *ppMediaType =
NULL;
3660 if (*ppMediaType ==
NULL) {
3661 return E_OUTOFMEMORY;
3681 if (pMediaType ==
NULL) {
3694 return E_OUTOFMEMORY;
3704 __out_bcount(cbProperties) BYTE * pbProperties
3707 if (0 != cbProperties) {
3710 AM_SAMPLE2_PROPERTIES Props;
3711 Props.cbData = min(cbProperties,
sizeof(Props));
3714 Props.pbBuffer = m_pBuffer;
3718 Props.tStop =
m_End;
3720 if (
m_dwFlags & AM_SAMPLE_TYPECHANGED) {
3723 Props.pMediaType =
NULL;
3725 CopyMemory(pbProperties, &Props, Props.cbData);
3730 #define CONTAINS_FIELD(type, field, offset) \
3731 ((FIELD_OFFSET(type, field) + sizeof(((type *)0)->field)) <= offset)
3735 __in_bcount(cbProperties)
const BYTE * pbProperties
3740 AM_MEDIA_TYPE *pMediaType =
NULL;
3742 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbData, cbProperties)) {
3744 AM_SAMPLE2_PROPERTIES *pProps =
3745 (AM_SAMPLE2_PROPERTIES *)pbProperties;
3748 if (pProps->cbData < cbProperties) {
3749 cbProperties = pProps->cbData;
3752 if (cbProperties >
sizeof(*pProps) ||
3753 pProps->cbData >
sizeof(*pProps)) {
3754 return E_INVALIDARG;
3757 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwSampleFlags, cbProperties)) {
3759 if (pProps->dwSampleFlags &
3761 return E_INVALIDARG;
3766 if ((pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID) &&
3769 return E_INVALIDARG;
3773 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pbBuffer, cbProperties)) {
3776 if (pProps->pbBuffer != 0 && pProps->pbBuffer != m_pBuffer) {
3777 return E_INVALIDARG;
3780 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbBuffer, cbProperties)) {
3783 if (pProps->cbBuffer != 0 && pProps->cbBuffer !=
m_cbBuffer) {
3784 return E_INVALIDARG;
3787 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbBuffer, cbProperties) &&
3791 if (pProps->cbBuffer < pProps->lActual) {
3792 return E_INVALIDARG;
3796 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pMediaType, cbProperties)) {
3799 if (pProps->dwSampleFlags & AM_SAMPLE_TYPECHANGED) {
3802 if (pMediaType ==
NULL) {
3803 return E_OUTOFMEMORY;
3809 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwStreamId, cbProperties)) {
3812 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwSampleFlags, cbProperties)) {
3818 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwTypeSpecificFlags, cbProperties)) {
3823 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, lActual, cbProperties)) {
3828 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStop, cbProperties)) {
3831 m_End = pProps->tStop;
3833 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStart, cbProperties)) {
3839 if (
CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pMediaType, cbProperties)) {
3841 if (pProps->dwSampleFlags & AM_SAMPLE_TYPECHANGED) {
3887 __in_opt LPCTSTR pObjectName,
3890 __inout HRESULT *phr,
3891 __in_opt LPCWSTR
pName) :
3894 m_pGraphConfig(
NULL),
3895 m_bPinUsesReadOnlyAllocator(FALSE),
3896 m_BlockState(NOT_BLOCKED),
3897 m_hUnblockOutputPinEvent(
NULL),
3898 m_hNotifyCallerPinBlockedEvent(
NULL),
3899 m_dwBlockCallerThreadID(0),
3900 m_dwNumOutstandingOutputPinUsers(0)
3902 HRESULT
hr = Initialize();
3903 if( FAILED(
hr ) ) {
3911 __in_opt LPCSTR pObjectName,
3914 __inout HRESULT *phr,
3915 __in_opt LPCWSTR
pName) :
3918 m_pGraphConfig(
NULL),
3919 m_bPinUsesReadOnlyAllocator(FALSE),
3920 m_BlockState(NOT_BLOCKED),
3921 m_hUnblockOutputPinEvent(
NULL),
3922 m_hNotifyCallerPinBlockedEvent(
NULL),
3923 m_dwBlockCallerThreadID(0),
3924 m_dwNumOutstandingOutputPinUsers(0)
3926 HRESULT
hr = Initialize();
3927 if( FAILED(
hr ) ) {
3949 HRESULT CDynamicOutputPin::Initialize(
void)
3969 if(
riid == IID_IPinFlowControl) {
3970 return GetInterface(
static_cast<IPinFlowControl*
>(
this), ppv);
3984 const DWORD VALID_FLAGS = AM_PIN_FLOW_CONTROL_BLOCK;
3987 if(dwBlockFlags & ~VALID_FLAGS) {
3988 return E_INVALIDARG;
3992 if((dwBlockFlags & AM_PIN_FLOW_CONTROL_BLOCK) && (
NULL != hEvent)) {
3993 if( !::ResetEvent( hEvent ) ) {
3999 if(0 == dwBlockFlags) {
4003 if(
NULL != hEvent) {
4004 return E_INVALIDARG;
4014 if(dwBlockFlags & AM_PIN_FLOW_CONTROL_BLOCK) {
4017 if(
NULL == hEvent) {
4039 HANDLE hNotifyCallerPinBlockedEvent = :: CreateEvent(
NULL,
4045 if(
NULL == hNotifyCallerPinBlockedEvent) {
4080 return VFW_E_PIN_ALREADY_BLOCKED_ON_THIS_THREAD;
4082 return VFW_E_PIN_ALREADY_BLOCKED;
4086 BOOL fSuccess = ::DuplicateHandle( ::GetCurrentProcess(),
4087 hNotifyCallerPinBlockedEvent,
4088 ::GetCurrentProcess(),
4191 const DWORD UNBLOCK = WAIT_OBJECT_0;
4192 const DWORD STOP = WAIT_OBJECT_0 + 1;
4195 DWORD dwNumWaitEvents =
sizeof(ahWaitEvents)/
sizeof(
HANDLE);
4197 DWORD dwReturnValue = ::WaitForMultipleObjects( dwNumWaitEvents, ahWaitEvents, FALSE, INFINITE );
4205 switch( dwReturnValue ) {
4210 return VFW_E_STATE_CHANGED;
4216 DbgBreak(
"An Unexpected case occured in CDynamicOutputPin::StartUsingOutputPin()." );
4217 return E_UNEXPECTED;
4321 const AM_MEDIA_TYPE *pmt,
4322 REFERENCE_TIME tSegmentStart,
4323 REFERENCE_TIME tSegmentStop,
4329 ASSERT(StreamingThreadUsingOutputPin());
4335 HRESULT
hr = ChangeMediaType(&cmt);
4340 hr = DeliverNewSegment(tSegmentStart, tSegmentStop, dSegmentRate);
4341 if( FAILED(
hr ) ) {
4358 return VFW_E_NOT_CONNECTED;
4366 m_Connected->QueryInterface(IID_IPinConnection, (
void **)&pConnection);
4367 if(pConnection !=
NULL) {
4369 if(S_OK == pConnection->DynamicQueryAccept(pmt)) {
4371 HRESULT
hr = ChangeMediaTypeHelper(pmt);
4384 HRESULT CDynamicOutputPin::ChangeMediaTypeHelper(
const CMediaType *pmt)
4406 ALLOCATOR_PROPERTIES apInputPinRequirements;
4407 apInputPinRequirements.cbAlign = 0;
4408 apInputPinRequirements.cbBuffer = 0;
4409 apInputPinRequirements.cbPrefix = 0;
4410 apInputPinRequirements.cBuffers = 0;
4412 m_pInputPin->GetAllocatorRequirements(&apInputPinRequirements);
4415 if(0 == apInputPinRequirements.cbAlign) {
4416 apInputPinRequirements.cbAlign = 1;
4464 AM_GRAPH_CONFIG_RECONNECT_CACHE_REMOVED_FILTERS );
4475 ASSERT(
hr != VFW_E_ALREADY_COMMITTED);
4483 void CDynamicOutputPin::AssertValid(
void)
4522 const DWORD EVENT_SIGNALED = WAIT_OBJECT_0;
4524 DWORD dwReturnValue = ::WaitForSingleObject(hEvent, INFINITE);
4526 switch( dwReturnValue ) {
4527 case EVENT_SIGNALED:
4534 DbgBreak(
"An Unexpected case occured in CDynamicOutputPin::WaitEvent()." );
4535 return E_UNEXPECTED;
4553 __inout_opt LPUNKNOWN pUnk,
4554 __inout HRESULT *phr,
4556 BOOL fEnableReleaseCallback
4561 m_bCommitted(FALSE),
4562 m_bDecommitInProgress(FALSE),
4569 m_fEnableReleaseCallback(fEnableReleaseCallback),
4579 *phr = E_OUTOFMEMORY;
4587 __inout_opt LPUNKNOWN pUnk,
4588 __inout HRESULT *phr,
4590 BOOL fEnableReleaseCallback) :
4594 m_bCommitted(FALSE),
4595 m_bDecommitInProgress(FALSE),
4602 m_fEnableReleaseCallback(fEnableReleaseCallback),
4606 PERFLOG_CTOR( L
"CBaseAllocator", (IMemAllocator *)
this );
4612 *phr = E_OUTOFMEMORY;
4628 PERFLOG_DTOR( L
"CBaseAllocator", (IMemAllocator *)
this );
4648 if (
riid == IID_IMemAllocator ||
4650 return GetInterface((IMemAllocatorCallbackTemp *)
this, ppv);
4664 __in ALLOCATOR_PROPERTIES* pRequest,
4665 __out ALLOCATOR_PROPERTIES* pActual)
4672 ZeroMemory(pActual,
sizeof(ALLOCATOR_PROPERTIES));
4674 ASSERT(pRequest->cbBuffer > 0);
4677 if (pRequest->cbAlign != 1) {
4679 pRequest->cbAlign));
4680 return VFW_E_BADALIGN;
4690 return VFW_E_ALREADY_COMMITTED;
4696 return VFW_E_BUFFERS_OUTSTANDING;
4702 pActual->cbBuffer =
m_lSize = pRequest->cbBuffer;
4703 pActual->cBuffers =
m_lCount = pRequest->cBuffers;
4705 pActual->cbPrefix =
m_lPrefix = pRequest->cbPrefix;
4713 __out ALLOCATOR_PROPERTIES * pActual)
4732 __in_opt REFERENCE_TIME *pStartTime,
4733 __in_opt REFERENCE_TIME *pEndTime,
4737 UNREFERENCED_PARAMETER(pStartTime);
4738 UNREFERENCED_PARAMETER(pEndTime);
4739 UNREFERENCED_PARAMETER(dwFlags);
4750 return VFW_E_NOT_COMMITTED;
4753 if (pSample ==
NULL) {
4763 if (dwFlags & AM_GBF_NOWAIT) {
4764 return VFW_E_TIMEOUT;
4767 WaitForSingleObject(
m_hSem, INFINITE);
4778 *ppBuffer = pSample;
4801 BOOL bRelease = FALSE;
4845 IMemAllocatorNotifyCallbackTemp* pNotify
4862 __out LONG* plBuffersFree
4923 BOOL bRelease = FALSE;
4952 #pragma warning(push)
4954 #pragma warning(disable:4068)
4956 #pragma prefast(suppress:__WARNING_DEREF_NULL_PTR, "Suppress warning related to Free() invalidating 'this' which is no applicable to CBaseAllocator::Free()")
4959 #pragma warning(pop)
4977 return VFW_E_SIZENOTSET;
4995 CBaseAllocator::CSampleList::Remove(__inout
CMediaSample * pSample)
4998 for (pSearch = &m_List;
5000 pSearch = &(CBaseAllocator::NextSample(*pSearch))) {
5001 if (*pSearch == pSample) {
5002 *pSearch = CBaseAllocator::NextSample(pSample);
5003 CBaseAllocator::NextSample(pSample) =
NULL;
5008 DbgBreak(
"Couldn't find sample in list");
5026 __in_opt LPCTSTR
pName,
5027 __inout_opt LPUNKNOWN pUnk,
5028 __inout HRESULT *phr)
5036 __in_opt LPCSTR
pName,
5037 __inout_opt LPUNKNOWN pUnk,
5038 __inout HRESULT *phr)
5051 __in ALLOCATOR_PROPERTIES* pRequest,
5052 __out ALLOCATOR_PROPERTIES* pActual)
5058 ZeroMemory(pActual,
sizeof(ALLOCATOR_PROPERTIES));
5060 ASSERT(pRequest->cbBuffer > 0);
5062 SYSTEM_INFO SysInfo;
5063 GetSystemInfo(&SysInfo);
5066 if ((-pRequest->cbAlign & pRequest->cbAlign) != pRequest->cbAlign) {
5067 DbgLog((
LOG_ERROR, 1, TEXT(
"Alignment requested 0x%x not a power of 2!"),
5068 pRequest->cbAlign));
5071 if (pRequest->cbAlign == 0 ||
5072 (SysInfo.dwAllocationGranularity & (pRequest->cbAlign - 1)) != 0) {
5073 DbgLog((
LOG_ERROR, 1, TEXT(
"Invalid alignment 0x%x requested - granularity = 0x%x"),
5074 pRequest->cbAlign, SysInfo.dwAllocationGranularity));
5075 return VFW_E_BADALIGN;
5085 return VFW_E_ALREADY_COMMITTED;
5091 return VFW_E_BUFFERS_OUTSTANDING;
5099 LONG lSize = pRequest->cbBuffer + pRequest->cbPrefix;
5100 LONG lRemainder = lSize % pRequest->cbAlign;
5101 if (lRemainder != 0) {
5102 lSize = lSize - lRemainder + pRequest->cbAlign;
5104 pActual->cbBuffer =
m_lSize = (lSize - pRequest->cbPrefix);
5106 pActual->cBuffers =
m_lCount = pRequest->cBuffers;
5108 pActual->cbPrefix =
m_lPrefix = pRequest->cbPrefix;
5133 if (
hr == S_FALSE) {
5146 return E_OUTOFMEMORY;
5154 return E_OUTOFMEMORY;
5159 if (lRemainder != 0) {
5160 LONG lNewSize = lAlignedSize +
m_lAlignment - lRemainder;
5161 if (lNewSize < lAlignedSize) {
5162 return E_OUTOFMEMORY;
5164 lAlignedSize = lNewSize;
5173 LONGLONG lToAllocate =
m_lCount * (LONGLONG)lAlignedSize;
5176 if (lToAllocate > MAXLONG) {
5177 return E_OUTOFMEMORY;
5186 return E_OUTOFMEMORY;
5202 NAME(
"Default memory media sample"),
5209 if (pSample ==
NULL) {
5210 return E_OUTOFMEMORY;
5251 pSample =
m_lFree.RemoveHead();
5252 if (pSample !=
NULL) {
5283 , IFilterMapper * pIFM
5290 if(
NULL == psetupdata )
return S_FALSE;
5298 HRESULT
hr = pIFM->UnregisterFilter( *(psetupdata->
clsID) );
5306 hr = pIFM->RegisterFilter( *(psetupdata->
clsID)
5314 for( UINT m1=0; m1 < psetupdata->
nPins; m1++ )
5316 hr = pIFM->RegisterPin( *(psetupdata->
clsID)
5317 , psetupdata->
lpPin[m1].strName
5318 , psetupdata->
lpPin[m1].bRendered
5319 , psetupdata->
lpPin[m1].bOutput
5320 , psetupdata->
lpPin[m1].bZero
5321 , psetupdata->
lpPin[m1].bMany
5322 , *(psetupdata->
lpPin[m1].clsConnectsToFilter)
5323 , psetupdata->
lpPin[m1].strConnectsToPin );
5330 for( UINT m2=0; m2 < psetupdata->
lpPin[m1].nMediaTypes; m2++ )
5332 hr = pIFM->RegisterPinType( *(psetupdata->
clsID)
5333 , psetupdata->
lpPin[m1].strName
5334 , *(psetupdata->
lpPin[m1].lpMediaType[m2].clsMajorType)
5335 , *(psetupdata->
lpPin[m1].lpMediaType[m2].clsMinorType) );
5336 if( FAILED(
hr) )
break;
5338 if( FAILED(
hr) )
break;
5340 if( FAILED(
hr) )
break;
5350 if( 0x80070002 ==
hr)
5357 #pragma warning(disable:4514)