shivba


HI friends ,
i'm new learner in direct show.I want to write media type structure for each of the following file format.Could anybody tell me how can write it
i know Major Type for all.
want know sub type , format type ,bit rate ,sample freq etc whatever specification for each format.
AU,
SND,
WAV,
AIFF,
AVI,
MIDI,
WMA

thanks in advance




Re: DirectShow Development how can i get media type for each of the following format?

Ralf G

MSDN is probably the best place to start:
Have a look at:
Media Types: http://msdn2.microsoft.com/en-us/library/ms787271.aspx
DirectShow structures: http://msdn2.microsoft.com/en-us/library/ms783353.aspx
Audio Subtypes: http://msdn2.microsoft.com/en-us/library/ms779325.aspx




Re: DirectShow Development how can i get media type for each of the following format?

Thore Karlsen

One way to find some of that information is to get some of those files, make a graph to render the file, then check out the media types on the output pins of the appropriate filters.





Re: DirectShow Development how can i get media type for each of the following format?

shivba


for example i wana write like the following for each file format.

******************************************************************************************************

HRESULT CPushPinAudioStream::GetMediaType(CMediaType *pmt /*pMediaType*/)
{
CAutoLock cAutoLock(m_pFilter->pStateLock());

CheckPointer(pmt, E_POINTER);

pmt->InitMediaType();
pmt->SetType(&MEDIATYPE_Audio);
pmt->SetSubtype(&MEDIASUBTYPE_MPEG1AudioPayload);
pmt->SetFormatType(&FORMAT_WaveFormatEx);

MPEG1WAVEFORMAT* pwf = (MPEG1WAVEFORMAT*)pmt->AllocFormatBuffer(sizeof(MPEG1WAVEFORMAT));
ZeroMemory(pwf, sizeof(MPEG1WAVEFORMAT));
pwf->wfx.wFormatTag = WAVE_FORMAT_MPEG;
pwf->wfx.cbSize = sizeof(MPEG1WAVEFORMAT) - sizeof(WAVEFORMATEX);

long audiobitrate,samplesfreq;
this->m_pLib->GetAudioParameters(audiobitrate,samplesfreq);




pwf->wfx.nSamplesPerSec = samplesfreq; //pType->Attributes.audio.SamplesPerSecond;
pwf->wfx.nChannels = 1; // pType->Attributes.audio.NumberChannels;
/*
if (pType->Attributes.audio.NumberChannels > 1)
{
pwf->fwHeadMode = ACM_MPEG_STEREO;
}
else
{
pwf->fwHeadMode = ACM_MPEG_SINGLECHANNEL;
}
*/
pwf->fwHeadMode = ACM_MPEG_SINGLECHANNEL;

// the rest of the structure we don't know from the attributes, so
// we are going to guess -- the decoder behaviour is unlikely to be affected
pwf->fwHeadLayer = ACM_MPEG_LAYER3; //2;
pwf->wfx.nAvgBytesPerSec = audiobitrate *1024; //160 * 1024
pwf->wfx.nBlockAlign = 1152;




return S_OK;
}
**********************************************************************************************
HRESULT CPushPinVideoStream::GetMediaType(CMediaType *pMediaType)
{
CAutoLock cAutoLock(m_pFilter->pStateLock());

CheckPointer(pMediaType, E_POINTER);

/*
// If the bitmap file was not loaded, just fail here.
if (!m_pImage)
return E_FAIL;
*/

// Allocate enough room for the VIDEOINFOHEADER and the color tables
VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER*)pMediaType->AllocFormatBuffer(SIZE_PREHEADER + m_cbBitmapInfo);
if (pvi == 0)
return(E_OUTOFMEMORY);

ZeroMemory(pvi, pMediaType->cbFormat);
pvi->AvgTimePerFrame = m_rtFrameLength;

//////////////////////
long width, height,videotag;
width = height = videotag = 0;

/*
if(m_pLib)
{
this->m_pLib->GetVideoParameters( width, height,videotag);
}
else */
{
//352* 288
width = 352;
height = 288;
}

BYTE *plocal = new BYTE[sizeof(BITMAPINFOHEADER)+ (width * height)];
if(!plocal)
{
OutputDebugString(TEXT("Could not allocate m_pImage\n"));
//*phr = E_OUTOFMEMORY;
return E_OUTOFMEMORY;
}
//pbmi.. cbmpinfo..
BITMAPINFOHEADER* m_pBitInfoHead = (BITMAPINFOHEADER *)plocal;
//(BITMAPINFOHEADER *)(malloc(sizeof(BITMAPINFOHEADER)));
m_pBitInfoHead->biSize = sizeof(BITMAPINFOHEADER);
m_pBitInfoHead->biWidth = width * 2;
m_pBitInfoHead->biHeight = height;
m_pBitInfoHead->biPlanes = 1;
m_pBitInfoHead->biBitCount = 24;
m_pBitInfoHead->biCompression = BI_RGB;
m_pBitInfoHead->biSizeImage = 0;
m_pBitInfoHead->biXPelsPerMeter = 0x0B12;
m_pBitInfoHead->biYPelsPerMeter = 0x0B12;
m_pBitInfoHead->biClrUsed = 0;
m_pBitInfoHead->biClrImportant = 0;
///////////////////////////


// Copy the header info
memcpy(&(pvi->bmiHeader), m_pBitInfoHead, m_cbBitmapInfo);

// Set image size for use in FillBuffer
pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader);

// Clear source and target rectangles
SetRectEmpty(&(pvi->rcSource)); // we want the whole image area rendered
SetRectEmpty(&(pvi->rcTarget)); // no particular destination rectangle

pMediaType->SetType(&MEDIATYPE_Video);
pMediaType->SetFormatType(&FORMAT_VideoInfo);
pMediaType->SetTemporalCompression(FALSE);

// Work out the GUID for the subtype from the header info.
const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader);
pMediaType->SetSubtype(&SubTypeGUID);
pMediaType->SetSampleSize(pvi->bmiHeader.biSizeImage);

return S_OK;
}






Re: DirectShow Development how can i get media type for each of the following format?

shivba



thanks
but how can i see media type on the out put pin right click properties it is not showing anthing.
message --Requested page cannot be diaplayed





Re: DirectShow Development how can i get media type for each of the following format?

Ralf G

Are you using Graphedit On my system if a filter is unconnected the tab shows "Preferred Media Types" -> "None" and not the page cannot be displayed

Like Thore said, you need to render the graph first and then right-click the output pin and select "Pin Properties". The output type generally only displays once you've connected the input pin of the filter.




Re: DirectShow Development how can i get media type for each of the following format?

shivba



yes i'm using graph edit.I'm rendering a .WAV file.Right clicking -->properties .Still the same message.

C:\stream_ ----------->wave parser----->default direct sound device





Re: DirectShow Development how can i get media type for each of the following format?

Thore Karlsen

In addition to what Ralf said, you may have to register proppage.dll manually. It should be in the bin directory of the Windows/Platform SDK, and you can register it from the command line by running "regsvr32 proppage.dll".





Re: DirectShow Development how can i get media type for each of the following format?

shivba



Thank you very much Thore & Ralf I'm able to see
Major type
subtype and format type on the o/p pin.How to about other media types and how to get it





Re: DirectShow Development how can i get media type for each of the following format?

Ralf G

What do you mean by the other media types If you want to get more details about the media type structures themselves you'll have to do what Thore said above: Find a Source for every single input type you want to cater for. Once you've done that you can write a dummy transform filter that simply passes the information to the next downstream filter. Then connect this in between the respective source filter and the rest of the rendered graph.

In your dummy filter override the SetMediaType method. This method get's called when the source filter is connected to the input pin of your dummy filter.

It will look something like this:

Code Block

HRESULT CTMBaseFilter::SetMediaType( PIN_DIRECTION direction, const CMediaType *pmt )}{
if (direction == PINDIR_INPUT)
{
if (pmt->formattype == FORMAT_VideoInfo)
{
// WARNING! In general you cannot just copy a VIDEOINFOHEADER
// struct, because the BITMAPINFOHEADER member may be followed by
// random amounts of palette entries or color masks. (See VIDEOINFO
// structure in the DShow SDK docs.) Here it's OK because we just
// want the information that's in the VIDEOINFOHEADER struct itself.

VIDEOINFOHEADER* pVih = (VIDEOINFOHEADER*) pmt->pbFormat;
CopyMemory(&m_videoInHeader, pVih, sizeof(VIDEOINFOHEADER));
//Set these values now
so we don't have to repeat it for each transform
m_nInHeight = abs(m_videoInHeader.bmiHeader.biHeight);
m_nInWidth = m_videoInHeader.bmiHeader.biWidth;
m_nInPixels = m_nInHeight * m_nInWidth;
}
else if (pmt->formattype == FORMAT_WaveFormatEx)
{
WAVEFORMATEX* pAih = (WAVEFORMATEX*)pmt->pbFormat;
CopyMemory(&m_audioInHeader, pAih, sizeof(WAVEFORMATEX));
}
..........................................................
}
return S_OK;



If you put a breakpoint at the line in red, you'll be able to examine pmt which is derived from AM_MEDIA_TYPE to see what information it contains.