Update shell xxxAW wrapper prototypes for fixed SHLWAPI functions.
[wine] / dlls / msdmo / dmort.c
1 /*
2  * Implements dmort APIs.
3  *
4  * Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "wine/obj_base.h"
27 #include "mediaobj.h"
28 #include "dmort.h"
29
30 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
32
33
34 HRESULT WINAPI MoCopyMediaType( DMO_MEDIA_TYPE* pmtDst, const DMO_MEDIA_TYPE* pmtSrc )
35 {
36         FIXME( "() not tested\n" );
37
38         memcpy( &pmtDst->majortype, &pmtSrc->majortype, sizeof(GUID) );
39         memcpy( &pmtDst->subtype, &pmtSrc->subtype, sizeof(GUID) );
40         pmtDst->bFixedSizeSamples = pmtSrc->bFixedSizeSamples;
41         pmtDst->bTemporalCompression = pmtSrc->bTemporalCompression;
42         pmtDst->lSampleSize = pmtSrc->lSampleSize;
43         memcpy( &pmtDst->formattype, &pmtSrc->formattype, sizeof(GUID) );
44         pmtDst->pUnk = NULL;
45         pmtDst->cbFormat = pmtSrc->cbFormat;
46         pmtDst->pbFormat = NULL;
47
48         if ( pmtSrc->pbFormat != NULL && pmtSrc->cbFormat != 0 )
49         {
50                 pmtDst->pbFormat = (BYTE*)CoTaskMemAlloc( pmtSrc->cbFormat );
51                 if ( pmtDst->pbFormat == NULL )
52                 {
53                         return E_OUTOFMEMORY;
54                 }
55                 memcpy( pmtDst->pbFormat, pmtSrc->pbFormat, pmtSrc->cbFormat );
56         }
57
58         if ( pmtSrc->pUnk != NULL )
59         {
60                 pmtDst->pUnk = pmtSrc->pUnk;
61                 IUnknown_AddRef( pmtSrc->pUnk );
62         }
63
64         return S_OK;
65 }
66
67 HRESULT WINAPI MoCreateMediaType( DMO_MEDIA_TYPE** ppmt, DWORD cbFormat )
68 {
69         HRESULT hr;
70         DMO_MEDIA_TYPE* pmt;
71
72         FIXME( "() not tested\n" );
73
74         if ( ppmt == NULL )
75                 return E_POINTER;
76         *ppmt = NULL;
77
78         pmt = (DMO_MEDIA_TYPE*)CoTaskMemAlloc( sizeof(DMO_MEDIA_TYPE) );
79         if ( pmt == NULL )
80                 return E_OUTOFMEMORY;
81         hr = MoInitMediaType( pmt, cbFormat );
82         if ( FAILED(hr) )
83                 return hr;
84
85         *ppmt = pmt;
86
87         return S_OK;
88 }
89
90 HRESULT WINAPI MoDeleteMediaType( DMO_MEDIA_TYPE* pmt )
91 {
92         FIXME( "() not tested\n" );
93
94         MoFreeMediaType( pmt );
95         CoTaskMemFree( pmt );
96
97         return S_OK;
98 }
99
100 HRESULT WINAPI MoDuplicateMediaType( DMO_MEDIA_TYPE** ppmtDest, const DMO_MEDIA_TYPE* pmtSrc )
101 {
102         HRESULT hr;
103         DMO_MEDIA_TYPE* pmtDup;
104
105         FIXME( "() not tested\n" );
106
107         if ( ppmtDest == NULL )
108                 return E_POINTER;
109         *ppmtDest = NULL;
110
111         pmtDup = (DMO_MEDIA_TYPE*)CoTaskMemAlloc( sizeof(DMO_MEDIA_TYPE) );
112         if ( pmtDup == NULL )
113                 return E_OUTOFMEMORY;
114         hr = MoCopyMediaType( pmtDup, pmtSrc );
115         if ( FAILED(hr) )
116                 return hr;
117
118         *ppmtDest = pmtDup;
119
120         return S_OK;
121 }
122
123 HRESULT WINAPI MoFreeMediaType( DMO_MEDIA_TYPE* pmt )
124 {
125         FIXME( "() not tested\n" );
126
127         if ( pmt->pUnk != NULL )
128         {
129                 IUnknown_Release( pmt->pUnk );
130                 pmt->pUnk = NULL;
131         }
132         if ( pmt->pbFormat != NULL )
133         {
134                 CoTaskMemFree( pmt->pbFormat );
135                 pmt->cbFormat = 0;
136                 pmt->pbFormat = NULL;
137         }
138
139         return S_OK;
140 }
141
142 HRESULT WINAPI MoInitMediaType( DMO_MEDIA_TYPE* pmt, DWORD cbFormat )
143 {
144         FIXME( "() not tested\n" );
145
146         memset( pmt, 0, sizeof(DMO_MEDIA_TYPE) );
147
148         pmt->pUnk = NULL;
149         if ( cbFormat > 0 )
150         {
151                 pmt->pbFormat = (BYTE*)CoTaskMemAlloc( cbFormat );
152                 if ( pmt->pbFormat == NULL )
153                         return E_OUTOFMEMORY;
154                 memset( pmt->pbFormat, 0, cbFormat );
155         }
156         pmt->cbFormat = cbFormat;
157
158         return S_OK;
159 }