前言






H:\webrtc-20210315\webrtc-20210315\webrtc\webrtc-checkout\src\modules\video_capture\windows\help_functions_ds.cc
hr = pKs->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0,
&PinCategory, sizeof(GUID), &cbReturned);
代码分析
h:\webrtc-20210315\webrtc-20210315\webrtc\webrtc-checkout\src\modules\video_capture\windows\video_capture_ds.cc
VideoCaptureDS::Init
int32_t VideoCaptureDS::Init(const char* deviceUniqueIdUTF8) {***_outputCapturePin = GetOutputPin(_captureFilter, PIN_CATEGORY_CAPTURE);if (!_outputCapturePin) {RTC_LOG(LS_INFO) << "Failed to get output capture pin";return -1;}***}
—》H:\webrtc-20210315\webrtc-20210315\webrtc\webrtc-checkout\src\modules\video_capture\windows\help_functions_ds.cc
GetOutputPin
IPin* GetOutputPin(IBaseFilter* filter, REFGUID Category) {HRESULT hr;IPin* pin = NULL;IEnumPins* pPinEnum = NULL;filter->EnumPins(&pPinEnum);if (pPinEnum == NULL) {return NULL;}// get first unconnected pinhr = pPinEnum->Reset(); // set to first pinwhile (S_OK == pPinEnum->Next(1, &pin, NULL)) {PIN_DIRECTION pPinDir;pin->QueryDirection(&pPinDir);if (PINDIR_OUTPUT == pPinDir) // This is an output pin{ // 我们就是要获取输出的pin,这里的GUID_NULL表示任意类型if (Category == GUID_NULL || PinMatchesCategory(pin, Category)) {pPinEnum->Release();return pin;}}pin->Release();pin = NULL;}pPinEnum->Release();return NULL;}

—》PinMatchesCategory(pin, Category)
PinMatchesCategory
BOOL PinMatchesCategory(IPin* pPin, REFGUID Category) {BOOL bFound = FALSE;IKsPropertySet* pKs = NULL;// 获取该IKsPropertySet接口HRESULT hr = pPin->QueryInterface(IID_PPV_ARGS(&pKs));if (SUCCEEDED(hr)) {GUID PinCategory;DWORD cbReturned;hr = pKs->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0,&PinCategory, sizeof(GUID), &cbReturned);if (SUCCEEDED(hr) && (cbReturned == sizeof(GUID))) {// 如果PinCategory等于输入的Category,则说明已经找到了匹配的pinbFound = (PinCategory == Category);}pKs->Release();}return bFound;}

调用堆栈

