annotate loader/dshow/mediatype.c @ 24374:8591a357eb36

Fix warnings: cfg-common.h:386: warning: redundant redeclaration of 'audio_stream' stream/stream.h:301: warning: previous declaration of 'audio_stream' was here
author voroshil
date Mon, 10 Sep 2007 01:13:13 +0000
parents 450bb2a75cba
children 051891760e01
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 "mediatype.h"
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
24 #include "mp_msg.h"
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"
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
27 #include "libwin32.h"
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
28
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
29 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
30 WAVEFORMATEX* pWF;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
31 VIDEOINFOHEADER* Vhdr;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
32 int i;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
33 GUID* iid;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
34
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 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
37 if(label)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
38 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"AM_MEDIA_TYPE: %s\n",label);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
39 else
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
40 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
41 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
42 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
43 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
44 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
45 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
46 if((i)%8!=0) printf("\n");
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
47 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"-(Ptr:%p)--(%02d)--\n",pmt->pbFormat,pmt->cbFormat);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
48 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
49 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
50 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
51 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
52 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
53 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 iid=(GUID*)&(pmt->subtype);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
55 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
56 "%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
57 iid->f1, iid->f2, iid->f3,
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
58 (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
59 (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
60 (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
61 (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
62
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
63 iid=(GUID*)&(pmt->formattype);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
64 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
65 "%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
66 iid->f1, iid->f2, iid->f3,
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
67 (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
68 (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
69 (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
70 (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
71 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
72 pWF=(WAVEFORMATEX*)pmt->pbFormat;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
73 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: nChannels %d\n",pWF->nChannels);
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: nSamplesPerSec %d\n",pWF->nSamplesPerSec);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
75 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
76 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"PMT: nBlockAlign %d\n",pWF->nBlockAlign);
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: nAvgBytesPerSec %d\n",pWF->nAvgBytesPerSec);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
78 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
79 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
80 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
81 Vhdr=(VIDEOINFOHEADER*)pmt->pbFormat;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
82 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
83 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biWidth %ld\n",Vhdr->bmiHeader.biWidth);
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: biHeight %d\n",Vhdr->bmiHeader.biHeight);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
85 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biSizeImage %d\n",Vhdr->bmiHeader.biSizeImage);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
86 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
87 if(Vhdr->bmiHeader.biCompression){
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
88 Debug mp_msg(MSGT_LOADER,MSGL_DBG4,"Vhdr: biComression 0x%08x (%s)\n",Vhdr->bmiHeader.biCompression,vo_format_name(Vhdr->bmiHeader.biCompression));
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
89 }else
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
90 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
91
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 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
94 }
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 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
97 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
98 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
99
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
100 if(!pSrc || !pDest) return E_POINTER;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
101
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
102 if(pSrc == pDest) return E_INVALIDARG;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
103
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
104 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
105
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
106 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
107 if (!pSrc->pbFormat) return S_OK;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
108 if (!(pDest->pbFormat = CoTaskMemAlloc(pSrc->cbFormat)))
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
109 return E_OUTOFMEMORY;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
110 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
111 if (pDest->pUnk)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
112 pDest->pUnk->vt->AddRef(pDest->pUnk);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
113 return S_OK;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
114 }
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 void FreeMediaType(AM_MEDIA_TYPE * pMediaType)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
117 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
118 if (!pMediaType) return;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
119 if (pMediaType->pbFormat)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
120 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
121 CoTaskMemFree(pMediaType->pbFormat);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
122 pMediaType->pbFormat = NULL;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
123 }
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
124 if (pMediaType->pUnk)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
125 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
126 pMediaType->pUnk->vt->Release(pMediaType->pUnk);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
127 pMediaType->pUnk = NULL;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
128 }
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 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
132 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
133 AM_MEDIA_TYPE * pDest;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
134 if (!pSrc) return NULL;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
135 pDest = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
136 if (!pDest)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
137 return NULL;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
138
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
139 if (FAILED(CopyMediaType(pDest, pSrc)))
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
140 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
141 CoTaskMemFree(pDest);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
142 return NULL;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
143 }
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 return pDest;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
146 }
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 void DeleteMediaType(AM_MEDIA_TYPE * pMediaType)
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
149 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
150 if (!pMediaType) return;
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
151 FreeMediaType(pMediaType);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
152 CoTaskMemFree(pMediaType);
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
153 }
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 #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
156 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
157 {
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
158 return (((bWildcards && (IsEqualGUID(&pmt1->majortype, &GUID_NULL) || IsEqualGUID(&pmt2->majortype, &GUID_NULL))) || IsEqualGUID(&pmt1->majortype, &pmt2->majortype)) &&
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
159 ((bWildcards && (IsEqualGUID(&pmt1->subtype, &GUID_NULL) || IsEqualGUID(&pmt2->subtype, &GUID_NULL))) || IsEqualGUID(&pmt1->subtype, &pmt2->subtype)));
3d1b23cf3d08 Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
diff changeset
160 }