Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cDirectMediaType.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cDirectMediaType_H
7 #define _INC_cDirectMediaType_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
13 #include "GrayCore/include/cMem.h"
14 
15 #if defined(USE_DX_SHOW)
16 #include <uuids.h> // CLSID_FilterGraph, CLSID_SystemDeviceEnum
17 #include <strmif.h> // IID_IGraphBuilder, ICreateDevEnum
18 #include <control.h> // IID_IMediaControl
19 
20 // #include <evcode.h> // EC_DEVICE_LOST // EC_COMPLETE in M$ SDK 7.0 ?
21 #ifndef EC_COMPLETE
22 #define EC_COMPLETE 0x01
23 #endif
24 #ifndef EC_DEVICE_LOST
25 #define EC_DEVICE_LOST 1
26 #define EC_USERABORT 2
27 #define EC_ERRORABORT 3
28 #endif
29 #ifndef OATRUE
30 #define OATRUE (-1)
31 #endif // OATRUE
32 
33 namespace GrayLib
34 {
35  class cDirectMediaType : public ::AM_MEDIA_TYPE
36  {
40  public:
41  cDirectMediaType() noexcept
42  {
43  cMem::Zero(static_cast<::AM_MEDIA_TYPE*>(this), sizeof(::AM_MEDIA_TYPE));
44  }
45  ~cDirectMediaType()
46  {
47  FreeMediaType();
48  }
49  void FreeMediaType()
50  {
51  FreeMediaType(*this);
52  }
53  static inline void FreeMediaType(::AM_MEDIA_TYPE& mt)
54  {
55  if (mt.cbFormat != 0 && mt.pbFormat != nullptr)
56  {
57  ::CoTaskMemFree((PVOID)mt.pbFormat);
58  mt.cbFormat = 0;
59  mt.pbFormat = nullptr;
60  }
61  if (mt.pUnk != nullptr)
62  {
63  mt.pUnk->Release();
64  mt.pUnk = nullptr;
65  }
66  }
67  };
68 }
69 #endif
70 #endif
Definition: cMesh.h:22
static void Zero(void *pData, size_t nSizeBlock) noexcept
Definition: cMem.h:100