Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.7 KiB

  1. //------------------------------------------------------------------------------
  2. // File: MediaBuf.h
  3. //
  4. // Desc: Definition of CBaseMediaBuffer class.
  5. //
  6. // Copyright (c) 1999-2000, Microsoft Corporation. All rights reserved.
  7. //------------------------------------------------------------------------------
  8. #ifndef __MEDIABUF_H__
  9. #define __MEDIABUF_H__
  10. class CBaseMediaBuffer : public IMediaBuffer {
  11. public:
  12. CBaseMediaBuffer() {}
  13. CBaseMediaBuffer(BYTE *pData, ULONG ulSize, ULONG ulData) :
  14. m_pData(pData), m_ulSize(ulSize), m_ulData(ulData), m_cRef(1) {}
  15. STDMETHODIMP_(ULONG) AddRef() {
  16. return InterlockedIncrement((long*)&m_cRef);
  17. }
  18. STDMETHODIMP_(ULONG) Release() {
  19. long l = InterlockedDecrement((long*)&m_cRef);
  20. if (l == 0)
  21. delete this;
  22. return l;
  23. }
  24. STDMETHODIMP QueryInterface(REFIID riid, void **ppv) {
  25. if (riid == IID_IUnknown) {
  26. AddRef();
  27. *ppv = (IUnknown*)this;
  28. return NOERROR;
  29. }
  30. else if (riid == IID_IMediaBuffer) {
  31. AddRef();
  32. *ppv = (IMediaBuffer*)this;
  33. return NOERROR;
  34. }
  35. else
  36. return E_NOINTERFACE;
  37. }
  38. STDMETHODIMP SetLength(DWORD ulLength) {m_ulData = ulLength; return NOERROR;}
  39. STDMETHODIMP GetMaxLength(DWORD *pcbMaxLength) {*pcbMaxLength = m_ulSize; return NOERROR;}
  40. STDMETHODIMP GetBufferAndLength(BYTE **ppBuffer, DWORD *pcbLength) {
  41. if (ppBuffer) *ppBuffer = m_pData;
  42. if (pcbLength) *pcbLength = m_ulData;
  43. return NOERROR;
  44. }
  45. protected:
  46. BYTE *m_pData;
  47. ULONG m_ulSize;
  48. ULONG m_ulData;
  49. ULONG m_cRef;
  50. };
  51. #endif __MEDIABUF_H__