📄 mediatype.c
字号:
/* * AM_MEDIA_TYPE service functions implementations * Code is based on quartz/enummedia.c file from wine project. * Modified by Vladimir Voroshilov * * Original code: Copyright 2003 Robert Shearman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */#include "config.h"#if (C_HAS_DIRECTSHOW)#include "mediatype.h"#include "wine/winerror.h"#include "com.h"#ifndef NOAVIFILE_HEADERS#include "audiodecoder.h"#include "except.h"#else#include "libwin32.h"#endifHRESULT CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc){ if(!pSrc || !pDest) return E_POINTER; if(pSrc == pDest) return E_INVALIDARG; if(!pSrc->pbFormat && pSrc->cbFormat) return E_POINTER; memcpy(pDest, pSrc, sizeof(AM_MEDIA_TYPE)); if (!pSrc->pbFormat) return S_OK; if (!(pDest->pbFormat = CoTaskMemAlloc(pSrc->cbFormat))) return E_OUTOFMEMORY; memcpy(pDest->pbFormat, pSrc->pbFormat, pSrc->cbFormat); if (pDest->pUnk) pDest->pUnk->vt->AddRef(pDest->pUnk); return S_OK;}void FreeMediaType(AM_MEDIA_TYPE * pMediaType){ if (!pMediaType) return; if (pMediaType->pbFormat) { CoTaskMemFree(pMediaType->pbFormat); pMediaType->pbFormat = NULL; } if (pMediaType->pUnk) { LOG_MSG("FreeMediaType(%p): %p", pMediaType, pMediaType->pUnk); pMediaType->pUnk->vt->Release(pMediaType->pUnk); pMediaType->pUnk = NULL; }}AM_MEDIA_TYPE * CreateMediaType(AM_MEDIA_TYPE const * pSrc){ AM_MEDIA_TYPE * pDest; if (!pSrc) return NULL; pDest = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); if (!pDest) return NULL; if (FAILED(CopyMediaType(pDest, pSrc))) { CoTaskMemFree(pDest); return NULL; } return pDest;}void DeleteMediaType(AM_MEDIA_TYPE * pMediaType){ if (!pMediaType) return; FreeMediaType(pMediaType); CoTaskMemFree(pMediaType);}#define IsEqualGUID(a,b) (memcmp(a,b,16)==0)int CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, int bWildcards){ return (((bWildcards && (IsEqualGUID(&pmt1->majortype, &GUID_NULL) || IsEqualGUID(&pmt2->majortype, &GUID_NULL))) || IsEqualGUID(&pmt1->majortype, &pmt2->majortype)) && ((bWildcards && (IsEqualGUID(&pmt1->subtype, &GUID_NULL) || IsEqualGUID(&pmt2->subtype, &GUID_NULL))) || IsEqualGUID(&pmt1->subtype, &pmt2->subtype)));}#endif // (C_HAS_DIRECTSHOW)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -