Mercurial > mplayer.hg
annotate loader/dshow/cmediasample.c @ 22253:389c91ead5b6
Fix license header.
author | diego |
---|---|
date | Mon, 19 Feb 2007 00:20:48 +0000 |
parents | 24dc4ec0d08d |
children | 3d1b23cf3d08 |
rev | line source |
---|---|
15166
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
1 /* |
18783 | 2 * Modified for use with MPlayer, detailed changelog at |
3 * http://svn.mplayerhq.hu/mplayer/trunk/ | |
15166
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
4 * $Id$ |
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
5 */ |
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
6 |
1545 | 7 #include "cmediasample.h" |
2069 | 8 #include "wine/winerror.h" |
168 | 9 #include <stdio.h> |
10 #include <string.h> | |
7386 | 11 #include <stdlib.h> |
1545 | 12 |
8292 | 13 /* |
14 * currently hack to make some extra room for DS Acel codec which | |
15 * seems to overwrite allocated memory - FIXME better later | |
16 * check the buffer allocation | |
17 */ | |
18 static const int SAFETY_ACEL = 1024; | |
19 | |
22028 | 20 /** |
21 * \brief IPin::QueryInternalConnections (retries pin's internal connections) | |
22 * | |
23 * \param[in] This pointer to IPin interface | |
24 * \param[out] apPin Array that receives pins, internally connected to this | |
25 * \param[in,out] nPint Size of an array | |
26 * | |
27 * \return S_OK - success | |
28 * \return S_FALSE - pin rejects media type | |
29 * \return E_NOTIMPL - not implemented | |
30 * | |
31 */ | |
3056 | 32 static long STDCALL CMediaSample_QueryInterface(IUnknown* This, |
7386 | 33 /* [in] */ const GUID* iid, |
1545 | 34 /* [iid_is][out] */ void **ppv) |
168 | 35 { |
3056 | 36 Debug printf("CMediaSample_QueryInterface(%p) called\n", This); |
1545 | 37 if (!ppv) |
38 return E_INVALIDARG; | |
3056 | 39 if (memcmp(iid, &IID_IUnknown, sizeof(*iid)) == 0) |
168 | 40 { |
3056 | 41 *ppv = (void*)This; |
42 ((IMediaSample*) This)->vt->AddRef(This); | |
168 | 43 return 0; |
44 } | |
3056 | 45 if (memcmp(iid, &IID_IMediaSample, sizeof(*iid)) == 0) |
168 | 46 { |
3056 | 47 *ppv = (void*)This; |
48 ((IMediaSample*) This)->vt->AddRef(This); | |
168 | 49 return 0; |
50 } | |
1545 | 51 return E_NOINTERFACE; |
168 | 52 } |
53 | |
22028 | 54 /** |
55 * \brief IUnknown::AddRef (increases reference counter for interface) | |
56 * | |
57 * \param[in] This pointer to IUnknown class | |
58 * | |
59 * \return new value of reference counter | |
60 * | |
61 * \remarks | |
62 * Return value should be used only for debug purposes | |
63 * | |
64 */ | |
1545 | 65 static long STDCALL CMediaSample_AddRef(IUnknown* This) |
168 | 66 { |
3056 | 67 Debug printf("CMediaSample_AddRef(%p) called\n", This); |
168 | 68 ((CMediaSample*)This)->refcount++; |
69 return 0; | |
70 } | |
1545 | 71 |
22028 | 72 /** |
73 * \brief CMediaSample destructor | |
74 * | |
75 * \param[in] This pointer to CMediaSample object | |
76 * | |
77 */ | |
3056 | 78 void CMediaSample_Destroy(CMediaSample* This) |
79 { | |
80 | |
81 Debug printf("CMediaSample_Destroy(%p) called (ref:%d)\n", This, This->refcount); | |
82 free(This->vt); | |
83 free(This->own_block); | |
84 if (This->media_type.pbFormat) | |
9964 | 85 free(This->media_type.pbFormat); |
3056 | 86 free(This); |
87 } | |
88 | |
22028 | 89 /** |
90 * \brief IUnknown::Release (desreases reference counter for interface) | |
91 * | |
92 * \param[in] This pointer to IUnknown class | |
93 * | |
94 * \return new value of reference counter | |
95 * | |
96 * \remarks | |
97 * When reference counter reaches zero calls destructor | |
98 * Return value should be used only for debug purposes | |
99 * | |
100 */ | |
1545 | 101 static long STDCALL CMediaSample_Release(IUnknown* This) |
168 | 102 { |
3467 | 103 CMediaSample* parent = (CMediaSample*)This; |
3056 | 104 Debug printf("CMediaSample_Release(%p) called (new ref:%d)\n", |
1545 | 105 This, ((CMediaSample*)This)->refcount-1); |
3467 | 106 |
107 if (--((CMediaSample*) This)->refcount == 0) | |
3056 | 108 { |
1545 | 109 parent->all->vt->ReleaseBuffer((IMemAllocator*)(parent->all), |
110 (IMediaSample*)This); | |
3056 | 111 } |
168 | 112 return 0; |
113 } | |
1545 | 114 |
22028 | 115 /** |
116 * \brief IMediaSample::GetPointer (retrieves a read/write pointer to the media sample's buffer) | |
117 * | |
118 * \param[in] This pointer to CMediaSample object | |
119 * \param[out] address of variable that receives pointer to sample's buffer | |
120 * | |
121 * \return S_OK success | |
122 * \return apropriate error otherwise | |
123 * | |
124 * \note The calles should not free or reallocate buffer | |
125 * | |
126 */ | |
3467 | 127 static HRESULT STDCALL CMediaSample_GetPointer(IMediaSample* This, |
128 /* [out] */ BYTE** ppBuffer) | |
168 | 129 { |
3467 | 130 Debug printf("CMediaSample_GetPointer(%p) called -> %p, size: %d %d\n", This, ((CMediaSample*) This)->block, ((CMediaSample*)This)->actual_size, ((CMediaSample*)This)->size); |
1545 | 131 if (!ppBuffer) |
132 return E_INVALIDARG; | |
3467 | 133 *ppBuffer = (BYTE*) ((CMediaSample*) This)->block; |
168 | 134 return 0; |
135 } | |
136 | |
22028 | 137 /** |
138 * \brief IMediaSample::GetSize (retrieves a size of buffer in bytes) | |
139 * | |
140 * \param[in] This pointer to CMediaSample object | |
141 * | |
142 * \return size of buffer in bytes | |
143 * | |
144 */ | |
1545 | 145 static long STDCALL CMediaSample_GetSize(IMediaSample * This) |
168 | 146 { |
3467 | 147 Debug printf("CMediaSample_GetSize(%p) called -> %d\n", This, ((CMediaSample*) This)->size); |
148 return ((CMediaSample*) This)->size; | |
168 | 149 } |
150 | |
22028 | 151 /** |
152 * \brief IMediaSample::GetTime (retrieves a stream time at wich sample sould start and finish) | |
153 * | |
154 * \param[in] This pointer to CMediaSample object | |
155 * \param[out] pTimeStart pointer to variable that receives start time | |
156 * \param[out] pTimeEnd pointer to variable that receives end time | |
157 * | |
158 * \return S_OK success | |
159 * \return VFW_E_NO_STOP_TIME The sample has valid start time, but no stop time | |
160 * \return VFW_E_SAMPLE_TIME_NOT_SET The sample is not time-stamped | |
161 * | |
162 * \remarks | |
163 * Both values are relative to stream time | |
164 * | |
165 */ | |
1545 | 166 static HRESULT STDCALL CMediaSample_GetTime(IMediaSample * This, |
167 /* [out] */ REFERENCE_TIME *pTimeStart, | |
168 /* [out] */ REFERENCE_TIME *pTimeEnd) | |
168 | 169 { |
8292 | 170 Debug printf("CMediaSample_GetTime(%p) called (UNIMPLEMENTED)\n", This); |
168 | 171 return E_NOTIMPL; |
172 } | |
173 | |
22028 | 174 /** |
175 * \brief IMediaSample::SetTime (sets a stream time at wich sample sould start and finish) | |
176 * | |
177 * \param[in] This pointer to CMediaSample object | |
178 * \param[out] pTimeStart pointer to variable that contains start time | |
179 * \param[out] pTimeEnd pointer to variable that contains end time | |
180 * | |
181 * \return S_OK success | |
182 * \return apropriate error otherwise | |
183 * | |
184 * \remarks | |
185 * Both values are relative to stream time | |
186 * To invalidate the stream times set pTimeStart and pTimeEnd to NULL. this will cause | |
187 * IMEdiaSample::GetTime to return VFW_E_SAMPLE_TIME_NOT_SET | |
188 * | |
189 */ | |
1545 | 190 static HRESULT STDCALL CMediaSample_SetTime(IMediaSample * This, |
191 /* [in] */ REFERENCE_TIME *pTimeStart, | |
192 /* [in] */ REFERENCE_TIME *pTimeEnd) | |
168 | 193 { |
8292 | 194 Debug printf("CMediaSample_SetTime(%p) called (UNIMPLEMENTED)\n", This); |
168 | 195 return E_NOTIMPL; |
196 } | |
197 | |
22028 | 198 /** |
199 * \brief IMediaSample::IsSyncPoint (determines if start of this sample is sync point) | |
200 * | |
201 * \param[in] This pointer to CMediaSample object | |
202 * | |
203 * \return S_OK start of this sample is sync point | |
204 * \return S_FALSE start of this sample is not sync point | |
205 * | |
206 * \remarks | |
207 * If bTemporalCompression of AM_MEDIA_TYPE is FALSE, all samples are sync points. | |
208 * | |
209 */ | |
1545 | 210 static HRESULT STDCALL CMediaSample_IsSyncPoint(IMediaSample * This) |
168 | 211 { |
3056 | 212 Debug printf("CMediaSample_IsSyncPoint(%p) called\n", This); |
1545 | 213 if (((CMediaSample*)This)->isSyncPoint) |
214 return 0; | |
168 | 215 return 1; |
216 } | |
217 | |
22028 | 218 /** |
219 * \brief IMediaSample::SetSyncPoint (specifies if start of this sample is sync point) | |
220 * | |
221 * \param[in] This pointer to CMediaSample object | |
222 * \param[in] bIsSyncPoint specifies whether this is sync point or not | |
223 * | |
224 * \return S_OK success | |
225 * \return apropriate error code otherwise | |
226 * | |
227 */ | |
1545 | 228 static HRESULT STDCALL CMediaSample_SetSyncPoint(IMediaSample * This, |
229 long bIsSyncPoint) | |
168 | 230 { |
3056 | 231 Debug printf("CMediaSample_SetSyncPoint(%p) called\n", This); |
3467 | 232 ((CMediaSample*)This)->isSyncPoint = bIsSyncPoint; |
168 | 233 return 0; |
234 } | |
235 | |
22028 | 236 /** |
237 * \brief IMediaSample::IsPreroll (determines if this sample is preroll sample) | |
238 * | |
239 * \param[in] This pointer to CMediaSample object | |
240 * | |
241 * \return S_OK if this sample is preroll sample | |
242 * \return S_FALSE if this sample is not preroll sample | |
243 * | |
244 * \remarks | |
245 * Preroll samples are processed but not displayed. They are lokated in media stream | |
246 * before displayable samples. | |
247 * | |
248 */ | |
1545 | 249 static HRESULT STDCALL CMediaSample_IsPreroll(IMediaSample * This) |
168 | 250 { |
3056 | 251 Debug printf("CMediaSample_IsPreroll(%p) called\n", This); |
1545 | 252 |
253 if (((CMediaSample*)This)->isPreroll) | |
168 | 254 return 0;//S_OK |
1545 | 255 |
256 return 1;//S_FALSE | |
168 | 257 } |
258 | |
22028 | 259 /** |
260 * \brief IMediaSample::SetPreroll (specifies if this sample is preroll sample) | |
261 * | |
262 * \param[in] This pointer to CMediaSample object | |
263 * \param[in] bIsPreroll specifies whether this sample is preroll sample or not | |
264 * | |
265 * \return S_OK success | |
266 * \return apropriate error code otherwise | |
267 * | |
268 * \remarks | |
269 * Preroll samples are processed but not displayed. They are lokated in media stream | |
270 * before displayable samples. | |
271 * | |
272 */ | |
1545 | 273 static HRESULT STDCALL CMediaSample_SetPreroll(IMediaSample * This, |
274 long bIsPreroll) | |
168 | 275 { |
3056 | 276 Debug printf("CMediaSample_SetPreroll(%p) called\n", This); |
168 | 277 ((CMediaSample*)This)->isPreroll=bIsPreroll; |
278 return 0; | |
279 } | |
280 | |
22028 | 281 /** |
282 * \brief IMediaSample::GetActualDataLength (retrieves the length of valid data in the buffer) | |
283 * | |
284 * \param[in] This pointer to CMediaSample object | |
285 * | |
286 * \return length of valid data in buffer in bytes | |
287 * | |
288 */ | |
3056 | 289 static long STDCALL CMediaSample_GetActualDataLength(IMediaSample* This) |
168 | 290 { |
3056 | 291 Debug printf("CMediaSample_GetActualDataLength(%p) called -> %d\n", This, ((CMediaSample*)This)->actual_size); |
168 | 292 return ((CMediaSample*)This)->actual_size; |
293 } | |
294 | |
22028 | 295 /** |
296 * \brief IMediaSample::SetActualDataLength (specifies the length of valid data in the buffer) | |
297 * | |
298 * \param[in] This pointer to CMediaSample object | |
299 * \param[in] __MIDL_0010 length of data in sample in bytes | |
300 * | |
301 * \return S_OK success | |
302 * \return VFW_E_BUFFER_OVERFLOW length specified by parameter is larger than buffer size | |
303 * | |
304 */ | |
3056 | 305 static HRESULT STDCALL CMediaSample_SetActualDataLength(IMediaSample* This, |
1545 | 306 long __MIDL_0010) |
168 | 307 { |
3467 | 308 CMediaSample* cms = (CMediaSample*)This; |
3056 | 309 Debug printf("CMediaSample_SetActualDataLength(%p, %ld) called\n", This, __MIDL_0010); |
8292 | 310 |
3467 | 311 if (__MIDL_0010 > cms->size) |
168 | 312 { |
3467 | 313 char* c = cms->own_block; |
8292 | 314 Debug printf("CMediaSample - buffer overflow %ld %d %p %p\n", |
3467 | 315 __MIDL_0010, ((CMediaSample*)This)->size, cms->own_block, cms->block); |
8292 | 316 cms->own_block = (char*) realloc(cms->own_block, (size_t) __MIDL_0010 + SAFETY_ACEL); |
3467 | 317 if (c == cms->block) |
318 cms->block = cms->own_block; | |
319 cms->size = __MIDL_0010; | |
168 | 320 } |
3467 | 321 cms->actual_size = __MIDL_0010; |
168 | 322 return 0; |
323 } | |
324 | |
22028 | 325 /** |
326 * \brief IMediaSample::GetMediaType (retrieves media type, if it changed from previous sample) | |
327 * | |
328 * \param[in] This pointer to CMediaSample object | |
329 * \param[out] ppMediaType address of variable that receives pointer to AM_MEDIA_TYPE. | |
330 * | |
331 * \return S_OK success | |
332 * \return S_FALSE Media type was not changed from previous sample | |
333 * \return E_OUTOFMEMORY Insufficient memory | |
334 * | |
335 * \remarks | |
336 * If media type is not changed from previous sample, ppMediaType is null | |
337 * If method returns S_OK caller should free memory allocated for structure | |
338 * including pbFormat block | |
339 */ | |
3056 | 340 static HRESULT STDCALL CMediaSample_GetMediaType(IMediaSample* This, |
341 AM_MEDIA_TYPE** ppMediaType) | |
168 | 342 { |
3056 | 343 AM_MEDIA_TYPE* t; |
344 Debug printf("CMediaSample_GetMediaType(%p) called\n", This); | |
168 | 345 if(!ppMediaType) |
1545 | 346 return E_INVALIDARG; |
168 | 347 if(!((CMediaSample*)This)->type_valid) |
348 { | |
349 *ppMediaType=0; | |
350 return 1; | |
351 } | |
3056 | 352 |
353 t = &((CMediaSample*)This)->media_type; | |
9964 | 354 // if(t.pbFormat)free(t.pbFormat); |
18878 | 355 (*ppMediaType) = malloc(sizeof(AM_MEDIA_TYPE)); |
3056 | 356 **ppMediaType = *t; |
18878 | 357 (*ppMediaType)->pbFormat = malloc(t->cbFormat); |
3056 | 358 memcpy((*ppMediaType)->pbFormat, t->pbFormat, t->cbFormat); |
359 // *ppMediaType=0; //media type was not changed | |
1545 | 360 return 0; |
168 | 361 } |
362 | |
22028 | 363 /** |
364 * \brief IMediaType::SetMediaType (specifies media type for sample) | |
365 * | |
366 * \param[in] This pointer to CMediaSample object | |
367 * \param[in] pMediaType pointer to AM_MEDIA_TYPE specifies new media type | |
368 * | |
369 * \return S_OK success | |
370 * \return E_OUTOFMEMORY insufficient memory | |
371 * | |
372 */ | |
1545 | 373 static HRESULT STDCALL CMediaSample_SetMediaType(IMediaSample * This, |
374 AM_MEDIA_TYPE *pMediaType) | |
168 | 375 { |
3056 | 376 AM_MEDIA_TYPE* t; |
377 Debug printf("CMediaSample_SetMediaType(%p) called\n", This); | |
1545 | 378 if (!pMediaType) |
379 return E_INVALIDARG; | |
3056 | 380 t = &((CMediaSample*)This)->media_type; |
381 if (t->pbFormat) | |
9964 | 382 free(t->pbFormat); |
3056 | 383 t = pMediaType; |
3467 | 384 if (t->cbFormat) |
385 { | |
18878 | 386 t->pbFormat = malloc(t->cbFormat); |
3467 | 387 memcpy(t->pbFormat, pMediaType->pbFormat, t->cbFormat); |
388 } | |
389 else | |
390 t->pbFormat = 0; | |
391 ((CMediaSample*) This)->type_valid=1; | |
1545 | 392 |
168 | 393 return 0; |
394 } | |
395 | |
22028 | 396 /** |
397 * \brief IMediaSample::IsDiscontinuity (determines if this sample represents data break | |
398 * in stream) | |
399 * | |
400 * \param[in] This pointer to CMediaSample object | |
401 * | |
402 * \return S_OK if this sample is break in data stream | |
403 * \return S_FALSE otherwise | |
404 * | |
405 * \remarks | |
406 * Discontinuity occures when filter seeks to different place in the stream or when drops | |
407 * samples. | |
408 * | |
409 */ | |
1545 | 410 static HRESULT STDCALL CMediaSample_IsDiscontinuity(IMediaSample * This) |
168 | 411 { |
3056 | 412 Debug printf("CMediaSample_IsDiscontinuity(%p) called\n", This); |
3467 | 413 return ((CMediaSample*) This)->isDiscontinuity; |
168 | 414 } |
415 | |
22028 | 416 /** |
417 * \brief IMediaSample::IsDiscontinuity (specifies whether this sample represents data break | |
418 * in stream) | |
419 * | |
420 * \param[in] This pointer to CMediaSample object | |
421 * \param[in] bDiscontinuity if TRUE this sample represents discontinuity with previous sample | |
422 * | |
423 * \return S_OK success | |
424 * \return apropriate error code otherwise | |
425 * | |
426 */ | |
1545 | 427 static HRESULT STDCALL CMediaSample_SetDiscontinuity(IMediaSample * This, |
428 long bDiscontinuity) | |
168 | 429 { |
3467 | 430 Debug printf("CMediaSample_SetDiscontinuity(%p) called (%ld)\n", This, bDiscontinuity); |
431 ((CMediaSample*) This)->isDiscontinuity = bDiscontinuity; | |
432 return 0; | |
1545 | 433 } |
434 | |
22028 | 435 /** |
436 * \brief IMediaSample::GetMediaTime (retrieves the media times of this sample) | |
437 * | |
438 * \param[in] This pointer to CMediaSample object | |
439 * \param[out] pTimeStart pointer to variable that receives start time | |
440 * \param[out] pTimeEnd pointer to variable that receives end time | |
441 * | |
442 * \return S_OK success | |
443 * \return VFW_E_MEDIA_TIME_NOT_SET The sample is not time-stamped | |
444 * | |
445 */ | |
1545 | 446 static HRESULT STDCALL CMediaSample_GetMediaTime(IMediaSample * This, |
447 /* [out] */ LONGLONG *pTimeStart, | |
448 /* [out] */ LONGLONG *pTimeEnd) | |
449 { | |
3056 | 450 Debug printf("CMediaSample_GetMediaTime(%p) called\n", This); |
3467 | 451 if (pTimeStart) |
452 *pTimeStart = ((CMediaSample*) This)->time_start; | |
453 if (pTimeEnd) | |
454 *pTimeEnd = ((CMediaSample*) This)->time_end; | |
455 return 0; | |
1545 | 456 } |
457 | |
22028 | 458 /** |
459 * \brief IMediaSample::GetMediaTime (retrieves the media times of this sample) | |
460 * | |
461 * \param[in] This pointer to CMediaSample object | |
462 * \param[out] pTimeStart pointer to variable that specifies start time | |
463 * \param[out] pTimeEnd pointer to variable that specifies end time | |
464 * | |
465 * \return S_OK success | |
466 * \return apropriate error code otherwise | |
467 * | |
468 * \remarks | |
469 * To invalidate the media times set pTimeStart and pTimeEnd to NULL. this will cause | |
470 * IMEdiaSample::GetTime to return VFW_E_MEDIA_TIME_NOT_SET | |
471 */ | |
1545 | 472 static HRESULT STDCALL CMediaSample_SetMediaTime(IMediaSample * This, |
473 /* [in] */ LONGLONG *pTimeStart, | |
474 /* [in] */ LONGLONG *pTimeEnd) | |
475 { | |
3056 | 476 Debug printf("CMediaSample_SetMediaTime(%p) called\n", This); |
3467 | 477 if (pTimeStart) |
478 ((CMediaSample*) This)->time_start = *pTimeStart; | |
479 if (pTimeEnd) | |
480 ((CMediaSample*) This)->time_end = *pTimeEnd; | |
481 return 0; | |
168 | 482 } |
483 | |
22028 | 484 /** |
485 * \brief CMediaSample::SetPointer (extension for direct memory write of decompressed data) | |
486 * | |
487 * \param[in] This pointer to CMediaSample object | |
488 * \param[in] pointer pointer to an external buffer to store data to | |
489 * | |
490 */ | |
3056 | 491 static void CMediaSample_SetPointer(CMediaSample* This, char* pointer) |
168 | 492 { |
3056 | 493 Debug printf("CMediaSample_SetPointer(%p) called -> %p\n", This, pointer); |
494 if (pointer) | |
495 This->block = pointer; | |
496 else | |
497 This->block = This->own_block; | |
498 } | |
1545 | 499 |
22028 | 500 /** |
501 * \brief CMediaSample::SetPointer (resets pointer to external buffer with internal one) | |
502 * | |
503 * \param[in] This pointer to CMediaSample object | |
504 * | |
505 */ | |
3056 | 506 static void CMediaSample_ResetPointer(CMediaSample* This) |
507 { | |
508 Debug printf("CMediaSample_ResetPointer(%p) called\n", This); | |
509 This->block = This->own_block; | |
168 | 510 } |
511 | |
22028 | 512 /** |
513 * \brief CMediaSample constructor | |
514 * | |
515 * \param[in] allocator IMemallocator interface of allocator to use | |
516 * \param[in] _size size of internal buffer | |
517 * | |
518 * \return pointer to CMediaSample object of NULL if error occured | |
519 * | |
520 */ | |
3056 | 521 CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int _size) |
168 | 522 { |
3467 | 523 CMediaSample* This = (CMediaSample*) malloc(sizeof(CMediaSample)); |
524 if (!This) | |
525 return NULL; | |
526 | |
527 // some hack here! | |
528 // it looks like Acelp decoder is actually accessing | |
529 // the allocated memory before it sets the new size for it ??? | |
530 // -- maybe it's being initialized with wrong parameters | |
531 // anyway this is fixes the problem somehow with some reserves | |
532 // | |
533 // using different trick for now - in DS_Audio modify sample size | |
534 //if (_size < 0x1000) | |
535 // _size = (_size + 0xfff) & ~0xfff; | |
536 | |
3056 | 537 This->vt = (IMediaSample_vt*) malloc(sizeof(IMediaSample_vt)); |
8292 | 538 This->own_block = (char*) malloc((size_t)_size + SAFETY_ACEL); |
3467 | 539 This->media_type.pbFormat = 0; |
540 | |
541 if (!This->vt || !This->own_block) | |
542 { | |
543 CMediaSample_Destroy(This); | |
544 return NULL; | |
545 } | |
3056 | 546 |
547 This->vt->QueryInterface = CMediaSample_QueryInterface; | |
548 This->vt->AddRef = CMediaSample_AddRef; | |
549 This->vt->Release = CMediaSample_Release; | |
550 This->vt->GetPointer = CMediaSample_GetPointer; | |
551 This->vt->GetSize = CMediaSample_GetSize; | |
552 This->vt->GetTime = CMediaSample_GetTime; | |
553 This->vt->SetTime = CMediaSample_SetTime; | |
554 This->vt->IsSyncPoint = CMediaSample_IsSyncPoint; | |
555 This->vt->SetSyncPoint = CMediaSample_SetSyncPoint; | |
556 This->vt->IsPreroll = CMediaSample_IsPreroll; | |
557 This->vt->SetPreroll = CMediaSample_SetPreroll; | |
558 This->vt->GetActualDataLength = CMediaSample_GetActualDataLength; | |
559 This->vt->SetActualDataLength = CMediaSample_SetActualDataLength; | |
560 This->vt->GetMediaType = CMediaSample_GetMediaType; | |
561 This->vt->SetMediaType = CMediaSample_SetMediaType; | |
562 This->vt->IsDiscontinuity = CMediaSample_IsDiscontinuity; | |
563 This->vt->SetDiscontinuity = CMediaSample_SetDiscontinuity; | |
564 This->vt->GetMediaTime = CMediaSample_GetMediaTime; | |
565 This->vt->SetMediaTime = CMediaSample_SetMediaTime; | |
566 | |
567 This->all = allocator; | |
568 This->size = _size; | |
569 This->refcount = 0; // increased by MemAllocator | |
570 This->actual_size = 0; | |
571 This->isPreroll = 0; | |
3467 | 572 This->isDiscontinuity = 1; |
573 This->time_start = 0; | |
574 This->time_end = 0; | |
3056 | 575 This->type_valid = 0; |
576 This->block = This->own_block; | |
577 | |
578 This->SetPointer = CMediaSample_SetPointer; | |
579 This->ResetPointer = CMediaSample_ResetPointer; | |
580 | |
581 Debug printf("CMediaSample_Create(%p) called - sample size %d, buffer %p\n", | |
582 This, This->size, This->block); | |
583 | |
584 return This; | |
168 | 585 } |