Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cAVStream.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_cAVStream_H
6 #define _INC_cAVStream_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "cAVSink.h"
14 
15 namespace GrayLib
16 {
18  {
22 
23  // Outgoing messages.
26 
30 
34  };
35 
36  typedef BYTE CAVPkt_t;
37 
38 #pragma pack(1)
40  {
43  public:
44  BYTE m_eType;
45  UINT32 m_nLength;
46  public:
47  cAVStreamPacket(BYTE eType = CAVPkt_Undefined, size_t nLength = 0) noexcept
48  : m_eType(eType)
49  , m_nLength((UINT32)nLength)
50  {
51  }
52  bool isValidPacket() const noexcept
53  {
55  if (m_eType == 0 || m_eType >= 32) // CAVPkt_TYPE or CTL_TYPE
56  return false;
57  if (m_nLength > cHeap::k_ALLOC_MAX)
58  return false;
59  return true;
60  }
61  };
62 #pragma pack()
63 
65  {
69 
70  protected:
72  public:
73  cAVStreamOut(cStreamOutput* pOut) noexcept
74  : m_pOut(pOut)
75  {
76  }
77  virtual ~cAVStreamOut()
78  {
79  }
81  {
82  m_pOut = pOut;
83  }
84 
85  // cAVSink
86  virtual HRESULT OnHeaderOpen(const cAVHeader& head) override;
87  virtual HRESULT OnHeaderStream(const cAVHeaderStream& head, const void* pForm, size_t nSizeForm) override;
88  virtual HRESULT OnHeaderClose() override;
89 
90  virtual HRESULT OnFrame(const cAVHeaderFrame& head, const void* pData, size_t nSizeData) override;
91  virtual HRESULT OnClose() override;
92 
93  HRESULT WritePacket(CAVPkt_TYPE eState, const void* pHead = nullptr, size_t nSizeHead = 0, const void* pData = nullptr, size_t nSizeData = 0);
94  };
95 
97  {
101  typedef cStreamOutput SUPER_t;
102 
103  private:
104  size_t m_nReadSize;
105  cAVStreamPacket m_Packet;
106  cHeapBlock m_data;
107 
108  protected:
109  virtual HRESULT ProcessPacket(CAVPkt_TYPE eState, const void* pData, size_t nSizeData);
110  public:
111  cAVStreamInp(cStreamInput& stmIn, cAVSink* pSink);
112  virtual ~cAVStreamInp();
113 
114  HRESULT ProcessStreamPacket();
115  virtual HRESULT ReadStream() override;
116  };
117 
118  //*************************************************************
119 
121  {
124 
125  protected:
127  public:
128  cAVControlOut(cStreamOutput* pOut) noexcept
129  : m_pOut(pOut)
130  {
131  }
132  virtual ~cAVControlOut()
133  {
134  }
136  {
137  m_pOut = pOut;
138  }
139 
140  // cAVControl
141  virtual HRESULT OnControl(CTL_TYPE eType, const void* pData = nullptr, size_t nSizeData = 0);
142  };
143 
145  {
148  typedef cStreamOutput SUPER_t;
149  protected:
151  public:
153  : m_pAVControl(pControl)
154  {
155  }
156  virtual ~cAVControlInp()
157  {
158  }
159  virtual HRESULT WriteX(const void* pData, size_t nDataSize);
160  };
161 };
162 
163 #endif
#define CATTR_PACKED
Definition: GrayCore.h:87
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cAVStream.h:145
cAVControl * m_pAVControl
What to do with the AV control packets once i have them.
Definition: cAVStream.h:150
virtual ~cAVControlInp()
Definition: cAVStream.h:156
cAVControlInp(cAVControl *pControl)
Definition: cAVStream.h:152
Definition: cAVStream.h:121
void put_StreamOutput(cStreamOutput *pOut)
Definition: cAVStream.h:135
cAVControlOut(cStreamOutput *pOut) noexcept
Definition: cAVStream.h:128
cStreamOutput * m_pOut
Push the AV control serialized stream here.
Definition: cAVStream.h:126
virtual ~cAVControlOut()
Definition: cAVStream.h:132
Definition: cAVSink.h:205
Definition: cAVSink.h:80
Definition: cAVSink.h:60
Definition: cAVSink.h:44
Definition: cAVSink.h:181
Definition: cAVSink.h:130
Definition: cAVStream.h:97
Definition: cAVStream.h:65
void put_StreamOutput(cStreamOutput *pOut)
Definition: cAVStream.h:80
cAVStreamOut(cStreamOutput *pOut) noexcept
Definition: cAVStream.h:73
virtual ~cAVStreamOut()
Definition: cAVStream.h:77
cStreamOutput * m_pOut
Push the AV serialized stream here.
Definition: cAVStream.h:71
Definition: cAVStream.h:40
bool isValidPacket() const noexcept
Definition: cAVStream.h:52
BYTE m_eType
CAVPkt_TYPE or CTL_TYPE.
Definition: cAVStream.h:44
UINT32 m_nLength
Data payload length in bytes.
Definition: cAVStream.h:45
cAVStreamPacket(BYTE eType=CAVPkt_Undefined, size_t nLength=0) noexcept
Definition: cAVStream.h:47
Definition: cHeap.h:156
Definition: cStream.h:306
Definition: cStream.h:126
Definition: cMesh.h:22
CAVPkt_TYPE
Definition: cAVStream.h:18
@ CAVPkt_QTY
Definition: cAVStream.h:33
@ CAVPkt_HeaderClose
5=Indicate the CAVPkt_HeaderOpen is complete. Frames will follow.
Definition: cAVStream.h:29
@ CAVPkt_Undefined
Definition: cAVStream.h:21
@ CAVPkt_HeaderStream
4=the cAVHeaderStream + Type specific header. (cSurfaceBitmapInfo,cWaveFormatEx)
Definition: cAVStream.h:28
@ CAVPkt_Open
1=Very first message to open the stream. (Name of File?+any other data to id the stream)
Definition: cAVStream.h:24
@ CAVPkt_Error
7=Some sort of error has occurred. code + text for the message. but stream may still be active.
Definition: cAVStream.h:32
@ CAVPkt_Close
2=Tear down the whole stream nicely. done.
Definition: cAVStream.h:25
@ CAVPkt_HeaderOpen
3=the cAVHeader header.
Definition: cAVStream.h:27
@ CAVPkt_Frame
6=Write an AV_STREAM_TYPE (audio or video) frame.
Definition: cAVStream.h:31
BYTE CAVPkt_t
CAVPkt_TYPE as BYTE.
Definition: cAVStream.h:36
static const size_t k_ALLOC_MAX
256 * 64K = (arbitrary) largest reasonable single malloc.
Definition: cHeap.h:45