JunkBox_Win_Lib 1.5.3
Loading...
Searching...
No Matches
WinMediaBuffer.h
Go to the documentation of this file.
1#pragma once
2
14#include "WinTools.h"
15
16#include <dmo.h> // IMediaObject
17#include <stack>
18#include <queue>
19
20
21// Lin
22#pragma comment(lib, "dmoguids.lib")
23
24
25namespace jbxwl {
26
27
28class CWinMediaBuffer : public IMediaBuffer
29{
30public:
31 CWinMediaBuffer(DWORD len=0);
32 virtual ~CWinMediaBuffer(void) { free();}
33
34 void init(DWORD len);
35 void free(void);
36 void clear(void) { m_pBuffer->vldsz = 0;}
37 //
38 Buffer* getBuffer(void) { return m_pBuffer;}
39
40public:
42 // IUnknown methods
43 //
44 STDMETHODIMP_(ULONG) AddRef() { return 2;}
45 STDMETHODIMP_(ULONG) Release() { return 1;}
46
47 STDMETHODIMP QueryInterface(REFIID riid, void** ppv)
48 {
49 if (riid==IID_IUnknown) {
50 AddRef();
51 *ppv = (IUnknown*)this;
52 return NOERROR;
53 }
54 else if (riid==IID_IMediaBuffer) {
55 AddRef();
56 *ppv = (IMediaBuffer*)this;
57 return NOERROR;
58 }
59 else return E_NOINTERFACE;
60 }
61
62public:
64 // IMediaBuffer methods
65 //
66 STDMETHODIMP SetLength(DWORD length) { m_pBuffer->vldsz = (int)length; return NOERROR;}
67 STDMETHODIMP GetMaxLength(DWORD* pMaxLength) { *pMaxLength = (DWORD)m_pBuffer->bufsz; return NOERROR;}
68
69 STDMETHODIMP GetBufferAndLength(BYTE** ppData, DWORD* pLength)
70 {
71 if (ppData!=NULL) *ppData = (BYTE*)m_pBuffer->buf;
72 if (pLength!=NULL) *pLength = (DWORD)m_pBuffer->vldsz;
73 return NOERROR;
74 }
75
76protected:
77 //
78 Buffer* m_pBuffer;
79
80};
81
82
83//
84typedef std::stack<CWinMediaBuffer*> MediaBufferStack;
85typedef std::queue<CWinMediaBuffer*> MediaBufferQueue;
86
87
88} // namespace
Buffer * getBuffer(void)
STDMETHODIMP_(ULONG) Release()
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
STDMETHODIMP GetMaxLength(DWORD *pMaxLength)
STDMETHODIMP SetLength(DWORD length)
STDMETHODIMP GetBufferAndLength(BYTE **ppData, DWORD *pLength)
STDMETHODIMP_(ULONG) AddRef()
virtual ~CWinMediaBuffer(void)
std::stack< CWinMediaBuffer * > MediaBufferStack
std::queue< CWinMediaBuffer * > MediaBufferQueue