我正在寻找DirectShow中的接口,它只允许我推送一个频率。
IAMTVTuner
界面允许您put_channel
,但这需要预调卡。我想指定调到的频率。模拟调谐可以实现吗? (然而,您可以使用数字流接口轻松完成)。
答案 0 :(得分:3)
I think this codeproject link should help you
以下是代码:
// It is assumed that you have constructed the complete TV tuner Graph
// of your Device.And will use this function to set custom frequencies
// or to fine tune a tuned TV channel.Please also make sure to set the
// appropriate Video standard and contry code before calling this function.
#define INSTANCEDATA_OF_PROPERTY_PTR(x) ((PKSPROPERTY((x))) + 1)
#define INSTANCEDATA_OF_PROPERTY_SIZE(x) (sizeof((x)) - sizeof(KSPROPERTY))
HRESULT SetFrequency(long Freq)
{
HRESULT hr;
DWORD dwSupported=0;
// Query the IKsPropertySet on your Device TV Tuner Filter.
// m_pTvtuner is IBaseFilter Pointer of your TV Tuner Filter.
CComPtr m_pKSProp;
hr = m_pTvtuner->QueryInterface(IID_IKsPropertySet, (void**)&m_pKSProp);
if (FAILED(hr))
return E_FAIL;
KSPROPERTY_TUNER_MODE_CAPS_S ModeCaps;
KSPROPERTY_TUNER_FREQUENCY_S Frequency;
memset(&ModeCaps,0,sizeof(KSPROPERTY_TUNER_MODE_CAPS_S));
memset(&Frequency,0,sizeof(KSPROPERTY_TUNER_FREQUENCY_S));
ModeCaps.Mode = AMTUNER_MODE_TV;
// Check either the Property is supported or not by the Tuner drivers
hr = m_pKSProp->QuerySupported(PROPSETID_TUNER,
KSPROPERTY_TUNER_MODE_CAPS,&dwSupported);
if(SUCCEEDED(hr) && dwSupported&KSPROPERTY_SUPPORT_GET)
{
DWORD cbBytes=0;
hr = m_pKSProp->Get(PROPSETID_TUNER,KSPROPERTY_TUNER_MODE_CAPS,
INSTANCEDATA_OF_PROPERTY_PTR(&ModeCaps),
INSTANCEDATA_OF_PROPERTY_SIZE(ModeCaps),
&ModeCaps,
sizeof(ModeCaps),
&cbBytes);
}
else
return E_FAIL;
Frequency.Frequency=Freq;
if(ModeCaps.Strategy==KS_TUNER_STRATEGY_DRIVER_TUNES)
Frequency.TuningFlags=KS_TUNER_TUNING_FINE;
else
Frequency.TuningFlags=KS_TUNER_TUNING_EXACT;
// Here the real magic starts
if(Freq>=ModeCaps.MinFrequency && Freq<=ModeCaps.MaxFrequency)
{
hr = m_pKSProp->Set(PROPSETID_TUNER,
KSPROPERTY_TUNER_FREQUENCY,
INSTANCEDATA_OF_PROPERTY_PTR(&Frequency),
INSTANCEDATA_OF_PROPERTY_SIZE(Frequency),
&Frequency,
sizeof(Frequency));
if(FAILED(hr))
return E_FAIL;
}
else
return E_FAIL;
return S_OK;
}