Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cAVSink.h
Go to the documentation of this file.
1 //
5 
6 #ifndef _INC_cAVSink_H
7 #define _INC_cAVSink_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
17 
18 namespace GrayLib
19 {
20  class cSurfaceBitmapInfo;
21  class cWaveFormatEx;
22  typedef short AV_QUALITY_t;
23 
25  {
36  // Any extra bits are used to id a stream. can be multiple streams of the same type ?
37  // AV_STREAM_KEYFRAME = 0x80, //!< bitmask indicates a frame is a key frame.
38  };
39  typedef BYTE AV_STREAM_t;
40  typedef BYTE AV_STREAMS_t;
41 
42 #pragma pack(1)
44  {
47  public:
48  WORD m_wVersion;
51  public:
52  cAVHeader(float fFramesPerSec = 0.0f, UINT32 dwTotalTimeSec = 0)
53  : m_wVersion(1)
54  , m_fFramesPerSec(fFramesPerSec)
55  , m_dwTotalTimeSec(dwTotalTimeSec)
56  {
57  }
58  };
60  {
64  public:
67  public:
68  cAVHeaderStream(AV_STREAM_TYPE bTypeId, AV_QUALITY_t nQuality = 10000) noexcept
69  : m_bTypeId((AV_STREAM_t)bTypeId)
70  , m_nQuality(nQuality)
71  {
72  }
73  AV_STREAM_TYPE get_Type() const noexcept
74  {
75  return (AV_STREAM_TYPE)(m_bTypeId & AV_STREAM_MASK);
76  }
77  };
78 
80  {
83 
84  public:
85  static const BYTE k_FLAG_KeyFrame = 0x80;
87 
88  public:
89  cAVHeaderFrame(AV_STREAM_TYPE bTypeId) noexcept
90  : m_bTypeId((AV_STREAM_t)bTypeId)
91  {
92  // e.g. ( m_bType & AV_STREAM_MASK ) = AV_STREAM_Audio
93  }
94  AV_STREAM_TYPE get_Type() const noexcept
95  {
96  return (AV_STREAM_TYPE)(m_bTypeId & AV_STREAM_MASK);
97  }
98  bool isAudio() const noexcept
99  {
100  return get_Type() == AV_STREAM_Audio;
101  }
102  bool isVideo() const noexcept
103  {
104  return get_Type() == AV_STREAM_Video;
105  }
106  bool isKeyFrame() const noexcept
107  {
108  return (m_bTypeId & k_FLAG_KeyFrame) ? true : false;
109  }
110  };
111 #pragma pack()
112 
113  class cAVFrame : public cRefBase
114  {
117  public:
120  public:
121  cAVFrame(const cAVHeaderFrame& head, const cHeapBlock& data)
122  : m_head(head), m_data(data)
123  {
124  }
125  };
126 
127  //*************************************************************
128 
130  {
133  // IGNORE_WARN_ABSTRACT(cAVSink);
134 
135  public:
136  virtual ~cAVSink()
137  {
138  }
139 
140  virtual HRESULT OnHeaderOpen(const cAVHeader& head)
141  {
144  return S_OK;
145  }
146  virtual HRESULT OnHeaderStream(const cAVHeaderStream& head, const void* pForm, size_t nSizeForm)
147  {
150  UNREFERENCED_PARAMETER(pForm);
151  UNREFERENCED_PARAMETER(nSizeForm);
152  return S_OK;
153  }
155  {
157  return S_OK;
158  }
159  virtual HRESULT OnFrame(const cAVHeaderFrame& head, const void* pData, size_t nSizeData)
160  {
163  UNREFERENCED_PARAMETER(pData);
164  UNREFERENCED_PARAMETER(nSizeData);
165  return S_OK;
166  }
167  virtual HRESULT OnClose()
168  {
170  return S_OK;
171  }
172  };
173 
175  {
178  };
179 
181  {
184 
185  protected:
188 
189  public:
191  : m_pStreamInput(&stmIn)
192  , m_pAVSink(pSink)
193  {
194  }
195  virtual ~cAVReader()
196  {
197  }
198 
199  virtual HRESULT ReadStream() = 0;
200  };
201 
202  //*************************************************************
203 
205  {
208  public:
209  enum CTL_TYPE
210  {
213  CTL_UNK = 0,
222  CTL_QTY
223  };
224  virtual ~cAVControl()
225  {
226  }
227  virtual HRESULT OnControl(CTL_TYPE eType, const void* pData = nullptr, size_t nSizeData = 0) = 0;
228  };
229 
231  {
235 
236  public:
237  virtual HRESULT BuildCompFrame(TIMESYS_t tWhenLast, const void*& rpCompRet, size_t& rnSizeRet) = 0;
238  };
239 };
240 
241 #endif
#define CATTR_PACKED
Definition: GrayCore.h:87
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
Using X files without the sources and the makefile How to use you just create a debug directory e the sample3 directory must contain Sample3 Final Sample3 exe Sample3 Final Debug Sample3 Final Gfx OpenGL bmp Sample3 Final Gfx tiny_skin bmp Sample3 Final Gfx tiny_4anim x The source files have the DevCpp project file plus the makefile The demos use standard FreeGlut functions Technical without warranty Neither Paul Coppens nor GameDev net make any or either express or with respect to the their or fitness for a specific purpose neither Paul Coppens nor GameDev net shall have any liability to you or any other person or entity with respect to any or damage caused or alleged to have been caused directly or indirectly by the programs provided by Paul Coppens and GameDev net This but is not limited interruption of loss of data
Definition: Readme.txt:39
#define UNREFERENCED_PARAMETER(P)
< _WIN32 type thing. get rid of stupid warning.
Definition: SysTypes.h:299
#define UNREFERENCED_REFERENCE(x)
Definition: SysTypes.h:318
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cAVSink.h:205
virtual ~cAVControl()
Definition: cAVSink.h:224
CTL_TYPE
Definition: cAVSink.h:210
@ CTL_Source
0x01 = request alternate video Source. "{ #stream (0=all), 'source string' }"
Definition: cAVSink.h:214
@ CTL_Position
0x06 = my view/listen position has changed. (for 3d audio mixing, if applicable)
Definition: cAVSink.h:219
@ CTL_Stop
0x04 = send control messages to the AV source. "{ 0=Stop, 1=Start, 2=Pause, 3=Unpause....
Definition: cAVSink.h:217
@ CTL_Channel
0x02 = request alternate video Channel. "{ #stream (0=all), channel # }"
Definition: cAVSink.h:215
@ CTL_Keys
0x08 = send input messages back to the AV source. keyboard or mouse buttons. "{ key code,...
Definition: cAVSink.h:221
@ CTL_Mouse
0x07 = send input messages back to the AV source. Mouse position. "{ x, y }"
Definition: cAVSink.h:220
@ CTL_Seek
0x05 = attempt to time seek on the AV stream if possible. "{ #mSec }"
Definition: cAVSink.h:218
@ CTL_Quality
0x03 = request a AV_QUALITY_t level change on a stream (or all streams). "{ #stream (0=all),...
Definition: cAVSink.h:216
virtual HRESULT OnControl(CTL_TYPE eType, const void *pData=nullptr, size_t nSizeData=0)=0
Definition: cAVSink.h:114
cHeapBlock m_data
Definition: cAVSink.h:119
cAVFrame(const cAVHeaderFrame &head, const cHeapBlock &data)
Definition: cAVSink.h:121
cAVHeaderFrame m_head
Definition: cAVSink.h:118
Definition: cAVSink.h:80
bool isVideo() const noexcept
Definition: cAVSink.h:102
cAVHeaderFrame(AV_STREAM_TYPE bTypeId) noexcept
Definition: cAVSink.h:89
AV_STREAM_TYPE get_Type() const noexcept
Definition: cAVSink.h:94
bool isKeyFrame() const noexcept
Definition: cAVSink.h:106
AV_STREAM_t m_bTypeId
AV_STREAM_TYPE | FLAG_KeyFrame = what frame type/channel/stream is this?
Definition: cAVSink.h:86
bool isAudio() const noexcept
Definition: cAVSink.h:98
Definition: cAVSink.h:60
AV_STREAM_t m_bTypeId
AV_STREAM_TYPE as BYTE. AV_STREAM_MASK allows extra bits.
Definition: cAVSink.h:65
AV_QUALITY_t m_nQuality
10000 = best. Holdover from VFW. probably not used. ICQUALITY_HIGH
Definition: cAVSink.h:66
cAVHeaderStream(AV_STREAM_TYPE bTypeId, AV_QUALITY_t nQuality=10000) noexcept
Definition: cAVSink.h:68
AV_STREAM_TYPE get_Type() const noexcept
Definition: cAVSink.h:73
Definition: cAVSink.h:44
cAVHeader(float fFramesPerSec=0.0f, UINT32 dwTotalTimeSec=0)
Definition: cAVSink.h:52
UINT32 m_dwTotalTimeSec
How long does the stream play (seconds)? 0=unknown length. REFTIME.
Definition: cAVSink.h:50
WORD m_wVersion
1 = the first version of this header format.
Definition: cAVSink.h:48
float m_fFramesPerSec
frames per sec. suggested rate. 0=real time. for AVI compatibility.
Definition: cAVSink.h:49
Definition: cAVSink.h:231
virtual HRESULT BuildCompFrame(TIMESYS_t tWhenLast, const void *&rpCompRet, size_t &rnSizeRet)=0
Definition: cAVSink.h:181
cAVSink * m_pAVSink
Output to this destination cAVSink.
Definition: cAVSink.h:187
cStreamInput * m_pStreamInput
read from this file or memory stream
Definition: cAVSink.h:186
virtual ~cAVReader()
Definition: cAVSink.h:195
virtual HRESULT ReadStream()=0
cAVReader(cStreamInput &stmIn, cAVSink *pSink)
Definition: cAVSink.h:190
Definition: cAVSink.h:175
Definition: cAVSink.h:130
virtual HRESULT OnClose()
Definition: cAVSink.h:167
virtual HRESULT OnHeaderClose()
Definition: cAVSink.h:154
virtual HRESULT OnHeaderOpen(const cAVHeader &head)
Definition: cAVSink.h:140
virtual HRESULT OnHeaderStream(const cAVHeaderStream &head, const void *pForm, size_t nSizeForm)
Definition: cAVSink.h:146
virtual ~cAVSink()
Definition: cAVSink.h:136
virtual HRESULT OnFrame(const cAVHeaderFrame &head, const void *pData, size_t nSizeData)
Definition: cAVSink.h:159
Definition: cHeap.h:156
Definition: cRefPtr.h:22
Definition: cStream.h:306
Definition: cMesh.h:22
BYTE AV_STREAM_t
a single type as a BYTE.
Definition: cAVSink.h:39
short AV_QUALITY_t
0 to 10000 e.g. 9900 = 99%. same as ICQUALITY_LOW,ICQUALITY_HIGH
Definition: cAVSink.h:21
AV_STREAM_TYPE
Definition: cAVSink.h:25
@ AV_STREAM_MASK
Definition: cAVSink.h:35
@ AV_STREAM_Meta
Other meta type info. XML?
Definition: cAVSink.h:33
@ AV_STREAM_QTY
Definition: cAVSink.h:34
@ AV_STREAM_Video
Video needs cSurfaceBitmapInfo header.
Definition: cAVSink.h:29
@ AV_STREAM_UNK
not set yet.
Definition: cAVSink.h:28
@ AV_STREAM_Location
3d location info. usually for Audio. or GPS for real world location ?
Definition: cAVSink.h:32
@ AV_STREAM_Audio
Audio needs cWaveFormatEx header.
Definition: cAVSink.h:30
@ AV_STREAM_Text
Text, Lyrics or Close Caption info. Needs cLanguageID Header.
Definition: cAVSink.h:31
BYTE AV_STREAMS_t
bitmask of AV_STREAM_t ..
Definition: cAVSink.h:40
UINT32 TIMESYS_t
TIMESYS_t = The normal system tick timer. milli-seconds since start of system/app ?
Definition: cTimeSys.h:27