예제 #1
0
IAMAudioInputMixer * GetMixer(IPin * inPin)
{
	IAMAudioInputMixer * pMixer = NULL;
	inPin->QueryInterface(IID_IAMAudioInputMixer, (void**) &pMixer);
	if (pMixer)
	{
		pMixer->Release();
	}
	return pMixer;
}
예제 #2
0
HRESULT CALLBACK EnumInputCallBack( const char* pName/*返回值*/, IPin * pin /*设备*/, LPVOID lp/*参数*/, BOOL& bCancel/*是否退出循环*/ )
{
	char* p = (char*)lp;
	if( strcmp( p, pName )==0 )
	{
		bCancel = TRUE;
		IAMAudioInputMixer * pMixer = GetMixer(pin);
		if( pMixer->put_Enable(TRUE)==S_OK )
		{
			if( pMixer->put_MixLevel(AMF_AUTOMATICGAIN) != S_OK )
			{
				return S_FALSE;
			}
		}
		else
			return S_FALSE;
	}
	return S_OK;
}
예제 #3
0
HRESULT CKTVDlg::activePin(IBaseFilter* filter, int index, wchar_t* str /*= NULL*/ , int pinIndex  )
{
    HRESULT r = -1;
    int nActivePin = -1;

    if (pinIndex == -1)
    {
        if (GetWinVersion() >= WINVERSION_VISTA)
        {
            nActivePin = 0;
        }
        else
        {
            for (int j = 0; j < m_captureFilterVec[index].PinVec.size(); j++)
            {
                if (m_captureFilterVec[index].PinVec[j].find(str) != wstring::npos)
                {
                    nActivePin = j;
                    break;
                }
            }
        }
    }
    else
    {
        nActivePin = pinIndex;
    }

    IPin *pPin=0;
    IAMAudioInputMixer *pPinMixer;

    // How many pins are in the input pin list?
    int nPins = m_captureFilterVec[index].PinVec.size();


    // Activate the selected input pin and deactivate all others
    for (int i=0; i<nPins; i++)
    {
        // Get this pin's interface
        r = GetPin(filter, PINDIR_INPUT, i, &pPin);
        if (SUCCEEDED(r))
        {
            r = pPin->QueryInterface(IID_IAMAudioInputMixer, (void **)&pPinMixer);
            if (SUCCEEDED(r))
            {
                // If this is our selected pin, enable it
                if (i == nActivePin)
                {
                    // Set any other audio properties on this pin
                    //r = SetInputPinProperties(pPinMixer);

                    // If there is only one input pin, this method
                    // might return E_NOTIMPL.
                    r = pPinMixer->put_Enable(TRUE);
                }
                // Otherwise, disable it
                else
                {
                    //r = pPinMixer->put_Enable(FALSE);
                }

                pPinMixer->Release();
            }

            // Release pin interfaces
            pPin->Release();
        }
    }

    return S_OK;
}