ReactOS 0.4.16-dev-109-gf4cb10f
mediasample.cpp
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WDM Streaming ActiveMovie Proxy
4 * FILE: dll/directx/ksproxy/mediasample.cpp
5 * PURPOSE: IMediaSample interface
6 *
7 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8 */
9#include "precomp.h"
10
12{
13public:
15
17 {
19 return m_Ref;
20 }
22 {
24 if (!m_Ref)
25 {
26 if (m_Allocator)
27 {
29 return 0;
30 }
31 delete this;
32 return 0;
33 }
34 return m_Ref;
35 }
36
38 long STDMETHODCALLTYPE GetSize(void);
53
55 virtual ~CMediaSample(){}
56
57protected:
71
72public:
74
76
77
78};
79
81 IMemAllocator * Allocator,
82 BYTE * Buffer,
84 m_Flags(0),
85 m_TypeFlags(0),
86 m_Buffer(Buffer),
87 m_ActualLength(BufferSize),
88 m_BufferSize(BufferSize),
89 m_Allocator(Allocator),
90 m_Next(0),
91 m_StartTime(0),
92 m_StopTime(0),
93 m_MediaStart(0),
94 m_MediaStop(0),
95 m_MediaType(0),
96 m_StreamId(0),
97 m_Ref(0),
98 m_bMediaTimeValid(0)
99{
100}
101
102
106 IN REFIID refiid,
108{
109 if (IsEqualGUID(refiid, IID_IUnknown) ||
110 IsEqualGUID(refiid, IID_IMediaSample))
111 {
112 *Output = PVOID(this);
113 reinterpret_cast<IMediaSample*>(*Output)->AddRef();
114 return NOERROR;
115 }
116 if (IsEqualGUID(refiid, IID_IMediaSample2))
117 {
118#if 0
119 *Output = (IMediaSample2*)(this);
120 reinterpret_cast<IMediaSample2*>(*Output)->AddRef();
121 return NOERROR;
122#endif
123 }
124
125 return E_NOINTERFACE;
126}
127
128//-------------------------------------------------------------------
129// IMediaSample interface
130//
134 BYTE **ppBuffer)
135{
136 if (!ppBuffer)
137 return E_POINTER;
138
139 *ppBuffer = m_Buffer;
140 return S_OK;
141}
142
143long
146{
147 return m_BufferSize;
148}
149
153 REFERENCE_TIME *pTimeStart,
154 REFERENCE_TIME *pTimeEnd)
155{
156 HRESULT hr;
157
158 if (!pTimeStart || !pTimeEnd)
159 return E_POINTER;
160
162 {
163 // no time is set
165 }
166
167 *pTimeStart = m_StartTime;
168
170 {
171 *pTimeEnd = m_StopTime;
172 hr = NOERROR;
173 }
174 else
175 {
176 *pTimeEnd = m_StartTime + 1;
178 }
179 return hr;
180}
181
185{
186 if (!pTimeStart)
187 {
189 return NOERROR;
190 }
191
192 if (!pTimeEnd)
193 {
196 m_StartTime = *pTimeStart;
197 return NOERROR;
198 }
199
200
202 m_StartTime = *pTimeStart;
203 m_StopTime = *pTimeEnd;
204
205 return NOERROR;
206}
207
211{
213}
217{
218 if (bIsSyncPoint)
220 else
221 m_Flags &= ~AM_SAMPLE_SPLICEPOINT;
222
223 return NOERROR;
224}
225
229{
230 return (m_Flags & AM_SAMPLE_PREROLL) ? S_OK : S_FALSE;
231}
232
236{
237 if (bIsPreroll)
239 else
240 m_Flags &= ~AM_SAMPLE_PREROLL;
241
242 return NOERROR;
243}
244
245long
248{
249 return m_ActualLength;
250}
251
255{
256 if (Length > m_BufferSize)
258
260 return NOERROR;
261}
262
266{
267 if (!m_MediaType)
268 {
269 *ppMediaType = NULL;
270 return S_FALSE;
271 }
272
273 assert(0);
274 return E_NOTIMPL;
275}
276
280{
281 OutputDebugStringW(L"CMediaSample::SetMediaType NotImplemented\n");
282 return E_NOTIMPL;
283}
284
285
289{
291}
292
296{
297 if (bDiscontinuity)
299 else
300 m_Flags &= ~AM_SAMPLE_DATADISCONTINUITY;
301
302 return NOERROR;
303}
304
308{
309 if (!pTimeStart || !pTimeEnd)
310 return E_POINTER;
311
314
315 m_MediaStart = *pTimeStart;
316 m_MediaStop = *pTimeEnd;
317
318 return NOERROR;
319}
320
324{
325 if (!pTimeStart || !pTimeEnd)
326 {
327 m_bMediaTimeValid = false;
328 return NOERROR;
329 }
330
331 m_MediaStart = *pTimeStart;
332 m_MediaStop = *pTimeEnd;
333
334 return NOERROR;
335}
336
337
338
339
341WINAPI
343 IMemAllocator* Allocator,
344 BYTE* pBuffer,
346 REFIID riid,
347 LPVOID * ppv)
348{
349#ifdef KSPROXY_TRACE
350 OutputDebugStringW(L"CMediaSample_Constructor\n");
351#endif
352
354
355 if (!handler)
356 return E_OUTOFMEMORY;
357
358 if (FAILED(handler->QueryInterface(riid, ppv)))
359 {
360 /* not supported */
361 delete handler;
362 return E_NOINTERFACE;
363 }
364
365 return NOERROR;
366}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
@ AM_SAMPLE_TIMEVALID
Definition: axcore.idl:441
@ AM_SAMPLE_STOPVALID
Definition: axcore.idl:444
@ AM_SAMPLE_DATADISCONTINUITY
Definition: axcore.idl:439
@ AM_SAMPLE_PREROLL
Definition: axcore.idl:438
@ AM_SAMPLE_SPLICEPOINT
Definition: axcore.idl:437
#define STDMETHODIMP
Definition: basetyps.h:43
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
Definition: bufpool.h:45
REFERENCE_TIME m_StartTime
Definition: mediasample.cpp:65
ULONG m_TypeFlags
Definition: mediasample.cpp:59
STDMETHODIMP_(ULONG) Release()
Definition: mediasample.cpp:21
CMediaSample * m_Next
Definition: mediasample.cpp:64
HRESULT STDMETHODCALLTYPE GetTime(REFERENCE_TIME *pTimeStart, REFERENCE_TIME *pTimeEnd)
LONGLONG m_MediaStart
Definition: mediasample.cpp:67
HRESULT STDMETHODCALLTYPE IsSyncPoint()
BYTE * m_Buffer
Definition: mediasample.cpp:60
STDMETHODIMP_(ULONG) AddRef()
Definition: mediasample.cpp:16
IMemAllocator * m_Allocator
Definition: mediasample.cpp:63
long STDMETHODCALLTYPE GetSize(void)
REFERENCE_TIME m_StopTime
Definition: mediasample.cpp:66
HRESULT STDMETHODCALLTYPE SetPreroll(BOOL bIsPreroll)
HRESULT STDMETHODCALLTYPE SetMediaTime(LONGLONG *pTimeStart, LONGLONG *pTimeEnd)
HRESULT STDMETHODCALLTYPE GetPointer(BYTE **ppBuffer)
HRESULT STDMETHODCALLTYPE SetActualDataLength(long Length)
HRESULT STDMETHODCALLTYPE SetMediaType(AM_MEDIA_TYPE *pMediaType)
long STDMETHODCALLTYPE GetActualDataLength()
virtual ~CMediaSample()
Definition: mediasample.cpp:55
HRESULT STDMETHODCALLTYPE SetSyncPoint(BOOL bIsSyncPoint)
HRESULT STDMETHODCALLTYPE SetTime(REFERENCE_TIME *pTimeStart, REFERENCE_TIME *pTimeEnd)
CMediaSample(IMemAllocator *Allocator, BYTE *Buffer, LONG BufferSize)
Definition: mediasample.cpp:80
HRESULT STDMETHODCALLTYPE GetMediaType(AM_MEDIA_TYPE **ppMediaType)
ULONG m_StreamId
Definition: mediasample.cpp:70
LONG m_ActualLength
Definition: mediasample.cpp:61
BOOL m_bMediaTimeValid
Definition: mediasample.cpp:75
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
AM_MEDIA_TYPE * m_MediaType
Definition: mediasample.cpp:69
HRESULT STDMETHODCALLTYPE IsPreroll()
HRESULT STDMETHODCALLTYPE SetDiscontinuity(BOOL bDiscontinuity)
HRESULT STDMETHODCALLTYPE GetMediaTime(LONGLONG *pTimeStart, LONGLONG *pTimeEnd)
LONGLONG m_MediaStop
Definition: mediasample.cpp:68
HRESULT STDMETHODCALLTYPE IsDiscontinuity()
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512
#define assert(x)
Definition: debug.h:53
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
unsigned int BOOL
Definition: ntddk_ex.h:94
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT ReleaseBuffer([in] IMediaSample *pBuffer)
ULONG AddRef()
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define GetTime(fmt)
Definition: lcformat.c:111
HRESULT WINAPI CMediaSample_Constructor(IMemAllocator *Allocator, BYTE *pBuffer, ULONG BufferSize, REFIID riid, LPVOID *ppv)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
PVOID pBuffer
@ Output
Definition: arc.h:85
HRESULT hr
Definition: shlfolder.c:183
int64_t LONGLONG
Definition: typedefs.h:68
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define VFW_E_SAMPLE_TIME_NOT_SET
Definition: vfwmsgs.h:104
#define VFW_E_MEDIA_TIME_NOT_SET
Definition: vfwmsgs.h:105
#define VFW_S_NO_STOP_TIME
Definition: vfwmsgs.h:34
#define VFW_E_BUFFER_OVERFLOW
Definition: vfwmsgs.h:52
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define NOERROR
Definition: winerror.h:2354
#define E_POINTER
Definition: winerror.h:2365
unsigned char BYTE
Definition: xxhash.c:193