Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ADPCM media type on output pin?

28 views
Skip to first unread message

Daniel S

unread,
Sep 8, 2009, 7:35:46 AM9/8/09
to
I have a ADPCM compressed audio stream that I read from the network.
The media type is not transferred over the network. In the receiving
filter I want to hard code the media type of the output pin to be
ADPCM. However, I don't manage to do this. Is there a sample that
illustrates how to do this?

The reason for hardcoding the media type is that then I can prototype
the graph connection in graphedit without implementing a property page
for the filter.

If I try PCM audio I can make the filter connect.

I use the following code in GetMediaType:

static ADPCMCOEFSET MSADPCM_CoeffSet[] =
{
{256, 0}, {512, -256}, {0, 0}, {192, 64}, {240, 0}, {460, -208},
{392, -232}
};

HRESULT MyOutputPin::GetMediaType(int iPosition, CMediaType *pmt)
{
CAutoLock cAutoLock(m_pFilter->pStateLock());

if(iPosition == 0)
{

ADPCMWAVEFORMAT* adpcm = (ADPCMWAVEFORMAT*)pmt->AllocFormatBuffer
(50);
WAVEFORMATEX* pwfex = &(adpcm->wfx);

pwfex->wFormatTag = WAVE_FORMAT_ADPCM;
pwfex->nChannels = 2;
pwfex->nSamplesPerSec = 44100;
pwfex->wBitsPerSample = 8;
pwfex->nBlockAlign = (WORD)((pwfex->wBitsPerSample * pwfex-
>nChannels) / 8);
pwfex->nAvgBytesPerSec = pwfex->nBlockAlign * pwfex->nSamplesPerSec;
pwfex->cbSize = 32;
adpcm->wSamplesPerBlock = 2048;

adpcm->wNumCoef = 7;
memcpy(adpcm->aCoef, MSADPCM_CoeffSet, 14);

return CreateAudioMediaType(pwfex, pmt, FALSE);
}

return VFW_S_NO_MORE_ITEMS;
}

The DirectShow "synth" sample can output ADPCM but I don't manage to
make that code work in my output pin.

When I do "render pin" in graphedit I get the "no such interface"
error message. The error occurs here:

amfilter.cpp:1784

if (hr == NOERROR) {
m_Connected = pReceivePin;
m_Connected->AddRef();
hr = SetMediaType(pmt);
if (SUCCEEDED(hr)) {

// Here I get the error
hr = pReceivePin->ReceiveConnection((IPin *)this, pmt);

...

0 new messages