41 if (FAILED(
hr) && (
NULL != phr)) {
50 if (FAILED(
hr) && (
NULL != phr)) {
71 *
this = (AM_MEDIA_TYPE &) rt;
85 return ((IsEqualGUID(majortype,rt.majortype) == TRUE) &&
86 (IsEqualGUID(subtype,rt.subtype) == TRUE) &&
87 (IsEqualGUID(formattype,rt.formattype) == TRUE) &&
88 (cbFormat == rt.cbFormat) &&
90 pbFormat !=
NULL && rt.pbFormat !=
NULL &&
91 (memcmp(pbFormat, rt.pbFormat, cbFormat) == 0)));
110 return Set((AM_MEDIA_TYPE &) rt);
121 return E_OUTOFMEMORY;
132 return (!IsEqualGUID(majortype,GUID_NULL));
165 bFixedSizeSamples = TRUE;
173 bFixedSizeSamples = FALSE;
179 bTemporalCompression = bCompressed;
189 memcpy(pbFormat, pformat, cb);
202 formattype = *pformattype;
211 CoTaskMemFree((
PVOID)pbFormat);
229 if (cbFormat == length) {
235 BYTE *pNewFormat = (PBYTE)CoTaskMemAlloc(length);
236 if (pNewFormat ==
NULL) {
237 if (length <= cbFormat)
return pbFormat;
245 CoTaskMemFree((
PVOID)pbFormat);
249 pbFormat = pNewFormat;
266 if (cbFormat == length) {
272 BYTE *pNewFormat = (PBYTE)CoTaskMemAlloc(length);
273 if (pNewFormat ==
NULL) {
274 if (length <= cbFormat)
return pbFormat;
283 memcpy(pNewFormat,pbFormat,min(length,cbFormat));
284 CoTaskMemFree((
PVOID)pbFormat);
288 pbFormat = pNewFormat;
296 ZeroMemory((
PVOID)
this,
sizeof(*
this));
298 bFixedSizeSamples = TRUE;
308 if ((majortype == GUID_NULL) ||
309 (formattype == GUID_NULL)) {
319 if ((ppartial->majortype != GUID_NULL) &&
320 (majortype != ppartial->majortype)) {
323 if ((ppartial->subtype != GUID_NULL) &&
324 (subtype != ppartial->subtype)) {
328 if (ppartial->formattype != GUID_NULL) {
330 if (formattype != ppartial->formattype) {
333 if (cbFormat != ppartial->cbFormat) {
336 if ((cbFormat != 0) &&
337 (memcmp(pbFormat, ppartial->pbFormat, cbFormat) != 0)) {
362 CoTaskMemFree((
PVOID)pmt);
377 AM_MEDIA_TYPE *pMediaType =
378 (AM_MEDIA_TYPE *)CoTaskMemAlloc(
sizeof(AM_MEDIA_TYPE));
380 if (pMediaType ==
NULL) {
387 CoTaskMemFree((
PVOID)pMediaType);
397 HRESULT WINAPI
CopyMediaType(__out AM_MEDIA_TYPE *pmtTarget,
const AM_MEDIA_TYPE *pmtSource)
401 ASSERT(pmtSource != pmtTarget);
402 *pmtTarget = *pmtSource;
403 if (pmtSource->cbFormat != 0) {
405 pmtTarget->pbFormat = (PBYTE)CoTaskMemAlloc(pmtSource->cbFormat);
406 if (pmtTarget->pbFormat ==
NULL) {
407 pmtTarget->cbFormat = 0;
408 return E_OUTOFMEMORY;
411 pmtTarget->cbFormat);
414 if (pmtTarget->pUnk !=
NULL) {
415 pmtTarget->pUnk->AddRef();
425 if (mt.cbFormat != 0) {
426 CoTaskMemFree((
PVOID)mt.pbFormat);
432 if (mt.pUnk !=
NULL) {
441 const WAVEFORMATEX *pwfx,
442 __out AM_MEDIA_TYPE *pmt,
446 pmt->majortype = MEDIATYPE_Audio;
450 pmt->subtype =
FOURCCMap(pwfx->wFormatTag);
452 pmt->formattype = FORMAT_WaveFormatEx;
453 pmt->bFixedSizeSamples = TRUE;
454 pmt->bTemporalCompression = FALSE;
455 pmt->lSampleSize = pwfx->nBlockAlign;
458 if (pwfx->wFormatTag == WAVE_FORMAT_PCM) {
459 pmt->cbFormat =
sizeof(WAVEFORMATEX);
461 pmt->cbFormat =
sizeof(WAVEFORMATEX) + pwfx->cbSize;
463 pmt->pbFormat = (PBYTE)CoTaskMemAlloc(pmt->cbFormat);
464 if (pmt->pbFormat ==
NULL) {
465 return E_OUTOFMEMORY;
467 if (pwfx->wFormatTag == WAVE_FORMAT_PCM) {
468 CopyMemory(pmt->pbFormat, pwfx,
sizeof(PCMWAVEFORMAT));
469 ((WAVEFORMATEX *)pmt->pbFormat)->cbSize = 0;
471 CopyMemory(pmt->pbFormat, pwfx, pmt->cbFormat);
478 #pragma warning(disable:4514)