DShow高手留步:about Audio compress codec filter.

whoo 2001-08-10 03:54:32
在DShow中如何使用ACM的codec,比如:

Audio capture filters-->[dsp, LH or other codec] filter --> renderer.

MSDN上说永远都用不着手工加入codec filters,graph manager 会自动加入,只需要设置所需要的格式就是了。

言下之意是不是我只需要设置audio capture filter 的output PIN地format就行了?
我已经用了output pin的IAMStreamConfig来SetFormat()了,只是GetFormat()正常,SetFormat()失败。

是WaveFormatEx设置的问题么?如果是的话如何设置非标准PCM的格式呢?

如果解决问题的话,分数可以到给分上限(甚至更多)。
...全文
173 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
kofxdm 2001-10-25
  • 打赏
  • 举报
回复
up
capboy 2001-10-24
  • 打赏
  • 举报
回复
看看这里的吧.是在DSHOW的FILTER中的SYNTH的例子.就是用来播放音频的.是个很好的参考代码.
// Implement GetMediaType/1 to return the type you support.
HRESULT CSynthStream::GetMediaType(CMediaType *pmt) {

// The caller must hold the state lock because this function
// calls get_OutputFormat() and GetPCMFormatStructure().
// The function assumes that the state of the m_Synth
// object does not change between the two calls. The
// m_Synth object's state will not change if the
// state lock is held.
ASSERT(CritCheckIn(m_pParent->pStateLock()));

WAVEFORMATEX *pwfex;
SYNTH_OUTPUT_FORMAT ofCurrent;

HRESULT hr = m_Synth->get_OutputFormat( &ofCurrent );
if (FAILED(hr)) {
return hr;
}

if (SYNTH_OF_PCM == ofCurrent) {
pwfex = (WAVEFORMATEX *) pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
if (NULL == pwfex) {
return E_OUTOFMEMORY;
}

m_Synth->GetPCMFormatStructure(pwfex);

} else if (SYNTH_OF_MS_ADPCM == ofCurrent) {
DWORD dwMaxWAVEFORMATEXSize;

MMRESULT mmr = acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FORMAT, (void*)&dwMaxWAVEFORMATEXSize);

// acmMetrics() returns 0 if no errors occur.
if( 0 != mmr ) {
return E_FAIL;
}

pwfex = (WAVEFORMATEX *) pmt->AllocFormatBuffer(dwMaxWAVEFORMATEXSize);
if (NULL == pwfex) {
return E_OUTOFMEMORY;
}

WAVEFORMATEX wfexSourceFormat;
m_Synth->GetPCMFormatStructure(&wfexSourceFormat);

ZeroMemory(pwfex, dwMaxWAVEFORMATEXSize);
pwfex->wFormatTag = WAVE_FORMAT_ADPCM;
pwfex->cbSize = (USHORT)(dwMaxWAVEFORMATEXSize - sizeof(WAVEFORMATEX));
pwfex->nChannels = wfexSourceFormat.nChannels;
pwfex->nSamplesPerSec = wfexSourceFormat.nSamplesPerSec;

mmr = acmFormatSuggest(NULL,
&wfexSourceFormat,
pwfex,
dwMaxWAVEFORMATEXSize,
ACM_FORMATSUGGESTF_WFORMATTAG | ACM_FORMATSUGGESTF_NSAMPLESPERSEC | ACM_FORMATSUGGESTF_NCHANNELS);
// acmFormatSuggest() returns 0 if no errors occur.
if( 0 != mmr ) {
return E_FAIL;
}

} else {
return E_UNEXPECTED;
}

return CreateAudioMediaType(pwfex, pmt, FALSE);
}
chenm001 2001-10-24
  • 打赏
  • 举报
回复
up
whoo 2001-08-22
  • 打赏
  • 举报
回复
to: faredu(电视人) 
mp3 encoder 是DShow的Filter,当然可以加进去。
ACM codec 是由acm wrapper封装的,所有的audio codec都是一个filter(acm wrapper)。所以无法根据GUID将特定的acm codec加入到graph中。
电视人 2001-08-17
  • 打赏
  • 举报
回复
怎么不行呢?我已经作了mp3网络广播的程序,在audio capure后直接连上mp3的encoder就可以了嘛,回放倒是不用特别连接,全部用acm warpper都可以,也算自动连接吧
whoo 2001-08-16
  • 打赏
  • 举报
回复
当然是 连接pin之前设置 了。
我猜是WaveFormatEx设置的问题,如何设置非标准PCM的格式呢?那些特殊的参数没有文档说明。
whoo 2001-08-13
  • 打赏
  • 举报
回复
有人么?
电视人 2001-08-13
  • 打赏
  • 举报
回复
连接pin之前设置,不然后续filter无法更改mediatype导致失败

8,324

社区成员

发帖
与我相关
我的任务
社区描述
游戏开发相关内容讨论专区
社区管理员
  • 游戏开发
  • 呆呆敲代码的小Y
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧