annotate loader/dshow/mediatype.c @ 28604:011bd477ee51

Mark all Linux RealVideo decoders as buggy, they all seem to have some problem on some systems.
author reimar
date Tue, 17 Feb 2009 20:44:45 +0000
parents 0fdf04b07ecb
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
1 /*
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
2 * AM_MEDIA_TYPE service functions implementations
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
3 * Code is based on quartz/enummedia.c file from wine project.
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
4 * Modified by Vladimir Voroshilov
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
5 *
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
6 * Original code: Copyright 2003 Robert Shearman
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
7 *
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
11 * (at your option) any later version.
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
12 *
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
16 * GNU General Public License for more details.
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
17 *
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
21 *
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
22 */
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
23 #include "mp_msg.h"
25775
7a0bcfc36766 Add missing #include, fixes the warning:
diego
parents: 24428
diff changeset
24 #include "libmpcodecs/img_format.h"
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
25 #include "wine/winerror.h"
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
26 #include "com.h"
24428
4691811bd8c7 Move AM_MEDIA_TYPE structure definition to mediatype.h.
voroshil
parents: 24397
diff changeset
27 #include "mediatype.h"
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
28 #include "libwin32.h"
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
29
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
30 void DisplayMediaType(const char * label,const AM_MEDIA_TYPE* pmt){
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
31 WAVEFORMATEX* pWF;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
32 VIDEOINFOHEADER* Vhdr;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
33 int i;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
34 GUID* iid;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
35
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
36
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
37 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"=======================\n");
24397
5ed2a051eb85 Fix for:
voroshil
parents: 24396
diff changeset
38 if(label){
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
39 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"AM_MEDIA_TYPE: %s\n",label);
24397
5ed2a051eb85 Fix for:
voroshil
parents: 24396
diff changeset
40 }else
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
41 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"AM_MEDIA_TYPE:\n");
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
42 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"-(Ptr:%p)--------\n",pmt);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
43 for(i=0;i<sizeof(AM_MEDIA_TYPE);i++){
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
44 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"%02x ",(BYTE)((BYTE*)pmt)[i]);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
45 if((i+1)%8==0) Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"\n");
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
46 }
24395
51e96521303b Proper fix for:
voroshil
parents: 24391
diff changeset
47 if((i)%8!=0) Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"\n");
24396
8df63e0e011b Fix for:
voroshil
parents: 24395
diff changeset
48 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"-(Ptr:%p)--(%lu)--\n",pmt->pbFormat,pmt->cbFormat);
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
49 for(i=0;i<pmt->cbFormat;i++){
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
50 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"%02x ",(BYTE)pmt->pbFormat[i]);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
51 if((i+1)%8==0) Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"\n");
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
52 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
53 if((i)%8!=0) Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"\n");
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
54 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"-----------------------\n");
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
55 iid=(GUID*)&(pmt->subtype);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
56 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Subtype: %08x-%04x-%04x-%02x%02x-"
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
57 "%02x%02x%02x%02x%02x%02x\n",
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
58 iid->f1, iid->f2, iid->f3,
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
59 (unsigned char)iid->f4[1], (unsigned char)iid->f4[0],
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
60 (unsigned char)iid->f4[2], (unsigned char)iid->f4[3],
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
61 (unsigned char)iid->f4[4], (unsigned char)iid->f4[5],
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
62 (unsigned char)iid->f4[6], (unsigned char)iid->f4[7]);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
63
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
64 iid=(GUID*)&(pmt->formattype);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
65 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Format type: %08x-%04x-%04x-%02x%02x-"
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
66 "%02x%02x%02x%02x%02x%02x\n",
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
67 iid->f1, iid->f2, iid->f3,
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
68 (unsigned char)iid->f4[1], (unsigned char)iid->f4[0],
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
69 (unsigned char)iid->f4[2], (unsigned char)iid->f4[3],
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
70 (unsigned char)iid->f4[4], (unsigned char)iid->f4[5],
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
71 (unsigned char)iid->f4[6], (unsigned char)iid->f4[7]);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
72 if(pmt && memcmp(&pmt->formattype,&FORMAT_WaveFormatEx,16)==0 && pmt->pbFormat){
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
73 pWF=(WAVEFORMATEX*)pmt->pbFormat;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
74 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: nChannels %d\n",pWF->nChannels);
24396
8df63e0e011b Fix for:
voroshil
parents: 24395
diff changeset
75 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: nSamplesPerSec %ld\n",pWF->nSamplesPerSec);
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
76 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: wBitsPerSample %d\n",pWF->wBitsPerSample);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
77 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: nBlockAlign %d\n",pWF->nBlockAlign);
24396
8df63e0e011b Fix for:
voroshil
parents: 24395
diff changeset
78 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: nAvgBytesPerSec %ld\n",pWF->nAvgBytesPerSec);
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
79 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: SampleSize %ld\n",pmt->lSampleSize);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
80 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
81 if(pmt && memcmp(&pmt->formattype,&FORMAT_VideoInfo,16)==0 && pmt->pbFormat){
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
82 Vhdr=(VIDEOINFOHEADER*)pmt->pbFormat;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
83 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: dwBitRate %ld\n",Vhdr->dwBitRate);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
84 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biWidth %ld\n",Vhdr->bmiHeader.biWidth);
24396
8df63e0e011b Fix for:
voroshil
parents: 24395
diff changeset
85 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biHeight %ld\n",Vhdr->bmiHeader.biHeight);
8df63e0e011b Fix for:
voroshil
parents: 24395
diff changeset
86 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biSizeImage %ld\n",Vhdr->bmiHeader.biSizeImage);
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
87 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biBitCount %d\n",Vhdr->bmiHeader.biBitCount);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
88 if(Vhdr->bmiHeader.biCompression){
24396
8df63e0e011b Fix for:
voroshil
parents: 24395
diff changeset
89 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biComression 0x%08lx (%s)\n",Vhdr->bmiHeader.biCompression,vo_format_name(Vhdr->bmiHeader.biCompression));
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
90 }else
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
91 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biComression 0x00000000\n");
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
92
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
93 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
94 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"=======================\n");
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
95 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
96
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
97 HRESULT CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
98 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
99 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"%s(%p) called\n", "CopyMediaType",pSrc);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
100
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
101 if(!pSrc || !pDest) return E_POINTER;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
102
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
103 if(pSrc == pDest) return E_INVALIDARG;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
104
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
105 if(!pSrc->pbFormat && pSrc->cbFormat) return E_POINTER;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
106
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
107 memcpy(pDest, pSrc, sizeof(AM_MEDIA_TYPE));
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
108 if (!pSrc->pbFormat) return S_OK;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
109 if (!(pDest->pbFormat = CoTaskMemAlloc(pSrc->cbFormat)))
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
110 return E_OUTOFMEMORY;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
111 memcpy(pDest->pbFormat, pSrc->pbFormat, pSrc->cbFormat);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
112 if (pDest->pUnk)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
113 pDest->pUnk->vt->AddRef(pDest->pUnk);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
114 return S_OK;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
115 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
116
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
117 void FreeMediaType(AM_MEDIA_TYPE * pMediaType)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
118 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
119 if (!pMediaType) return;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
120 if (pMediaType->pbFormat)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
121 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
122 CoTaskMemFree(pMediaType->pbFormat);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
123 pMediaType->pbFormat = NULL;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
124 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
125 if (pMediaType->pUnk)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
126 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
127 pMediaType->pUnk->vt->Release(pMediaType->pUnk);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
128 pMediaType->pUnk = NULL;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
129 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
130 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
131
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
132 AM_MEDIA_TYPE * CreateMediaType(AM_MEDIA_TYPE const * pSrc)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
133 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
134 AM_MEDIA_TYPE * pDest;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
135 if (!pSrc) return NULL;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
136 pDest = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
137 if (!pDest)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
138 return NULL;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
139
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
140 if (FAILED(CopyMediaType(pDest, pSrc)))
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
141 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
142 CoTaskMemFree(pDest);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
143 return NULL;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
144 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
145
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
146 return pDest;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
147 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
148
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
149 void DeleteMediaType(AM_MEDIA_TYPE * pMediaType)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
150 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
151 if (!pMediaType) return;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
152 FreeMediaType(pMediaType);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
153 CoTaskMemFree(pMediaType);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
154 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
155
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
156 #define IsEqualGUID(a,b) (memcmp(a,b,16)==0)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
157 int CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, int bWildcards)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
158 {
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 25775
diff changeset
159 return ((bWildcards && (IsEqualGUID(&pmt1->majortype, &GUID_NULL) || IsEqualGUID(&pmt2->majortype, &GUID_NULL))) || IsEqualGUID(&pmt1->majortype, &pmt2->majortype)) &&
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 25775
diff changeset
160 ((bWildcards && (IsEqualGUID(&pmt1->subtype, &GUID_NULL) || IsEqualGUID(&pmt2->subtype, &GUID_NULL))) || IsEqualGUID(&pmt1->subtype, &pmt2->subtype));
22305
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
161 }