|
// DSCodecFormat.cpp: implementation of the CDSCodecFormat class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DShowEncoder.h"
#include "DSCodecFormat.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDSCodecFormat::CDSCodecFormat()
{
m_pMediaType = NULL;
}
CDSCodecFormat::~CDSCodecFormat()
{
if (m_pMediaType != NULL) {
// Free pMediaType
if (m_pMediaType->cbFormat != 0) {
CoTaskMemFree((PVOID)m_pMediaType->pbFormat);
// Strictly unnecessary but tidier
m_pMediaType->cbFormat = 0;
m_pMediaType->pbFormat = NULL;
}
if (m_pMediaType->pUnk != NULL) {
m_pMediaType->pUnk->Release();
m_pMediaType->pUnk = NULL;
}
CoTaskMemFree((PVOID)m_pMediaType);
}
}
WORD CDSCodecFormat::NumberOfChannels()
{
if (m_pMediaType != NULL) {
WAVEFORMATEX* pFormat = (WAVEFORMATEX*) m_pMediaType->pbFormat;
return pFormat->nChannels;
}
return -1;
}
DWORD CDSCodecFormat::SamplesPerSecond()
{
if (m_pMediaType != NULL) {
WAVEFORMATEX* pFormat = (WAVEFORMATEX*) m_pMediaType->pbFormat;
return pFormat->nSamplesPerSec;
}
return -1;
}
DWORD CDSCodecFormat::BytesPerSec()
{
if (m_pMediaType != NULL) {
WAVEFORMATEX* pFormat = (WAVEFORMATEX*) m_pMediaType->pbFormat;
return pFormat->nAvgBytesPerSec;
}
return -1;
}
WORD CDSCodecFormat::BitsPerSample()
{
if (m_pMediaType != NULL) {
WAVEFORMATEX* pFormat = (WAVEFORMATEX*) m_pMediaType->pbFormat;
return pFormat->wBitsPerSample;
}
return -1;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.