// pdwGroup value is set to: // - 0 if the track isn't controlled by any underlying IAMStreamSelect interface // - 1 if the track is controlled by an underlying IAMStreamSelect interface and is not selected at that level // - 2 if the track is controlled by an underlying IAMStreamSelect interface and is selected at that level STDMETHODIMP CStreamSwitcherFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk) { CAutoLock cAutoLock(&m_csPins); IUnknown* pObject = nullptr; bool bFound = false; POSITION pos = m_pInputs.GetHeadPosition(); while (pos && !bFound) { CStreamSwitcherInputPin* pInputPin = m_pInputs.GetNext(pos); if (pInputPin->IsConnected()) { if (CComPtr<IAMStreamSelect> pSSF = pInputPin->GetStreamSelectionFilter()) { DWORD cStreams = 0; HRESULT hr = pSSF->Count(&cStreams); if (SUCCEEDED(hr)) { for (int i = 0; i < (int)cStreams; i++) { AM_MEDIA_TYPE* pmt = nullptr; DWORD dwFlags; LPWSTR pszName = nullptr; hr = pSSF->Info(i, &pmt, &dwFlags, plcid, NULL, &pszName, nullptr, nullptr); if (SUCCEEDED(hr) && pmt && pmt->majortype == MEDIATYPE_Audio) { if (lIndex == 0) { bFound = true; pObject = pSSF; if (ppmt) { *ppmt = pmt; } else { DeleteMediaType(pmt); } if (pdwFlags) { *pdwFlags = (m_pInput == pInputPin) ? dwFlags : 0; } if (pdwGroup) { *pdwGroup = (dwFlags & (AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE)) ? 2 : 1; } if (ppszName) { *ppszName = pszName; } else { CoTaskMemFree(pszName); } break; } else { lIndex--; } } DeleteMediaType(pmt); CoTaskMemFree(pszName); } } } else if (lIndex == 0) { bFound = true; if (ppmt) { *ppmt = CreateMediaType(&m_pOutput->CurrentMediaType()); } if (pdwFlags) { *pdwFlags = (m_pInput == pInputPin) ? AMSTREAMSELECTINFO_EXCLUSIVE : 0; } if (plcid) { *plcid = 0; } if (pdwGroup) { *pdwGroup = 0; } if (ppszName) { *ppszName = (WCHAR*)CoTaskMemAlloc((wcslen(pInputPin->Name()) + 1) * sizeof(WCHAR)); if (*ppszName) { wcscpy_s(*ppszName, wcslen(pInputPin->Name()) + 1, pInputPin->Name()); } } } else { lIndex--; } } } if (!bFound) { return E_INVALIDARG; } if (ppObject) { *ppObject = pObject; if (pObject) { pObject->AddRef(); } } if (ppUnk) { *ppUnk = nullptr; } return S_OK; }