AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
ntv2encodehevcfileac.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 #ifndef _NTV2ENCODEHEVCFILEAC_H
10 #define _NTV2ENCODEHEVCFILEAC_H
11 
12 #include "ntv2enums.h"
13 #include "ntv2devicefeatures.h"
14 #include "ntv2devicescanner.h"
15 #include "ntv2demohevccommon.h"
16 
17 #include "ntv2m31enums.h"
18 
24 #include "ajabase/system/thread.h"
25 
26 #include "ntv2m31.h"
27 
28 #define VIDEO_RING_SIZE 60
29 #define AUDIO_RING_SIZE (3*VIDEO_RING_SIZE)
30 
31 
38 {
39  // Public Instance Methods
40  public:
63  NTV2EncodeHEVCFileAc (const std::string inDeviceSpecifier = "0",
64  const NTV2Channel inChannel = NTV2_CHANNEL1,
67  const bool inQuadMode = false,
68  const uint32_t inAudioChannels = 0,
69  const bool inTimeCodeBurn = false,
70  const bool inInfoData = false,
71  const uint32_t inMaxFrames = 0xffffffff);
72 
73  virtual ~NTV2EncodeHEVCFileAc ();
74 
78  virtual AJAStatus Init (void);
79 
84  virtual AJAStatus Run (void);
85 
89  virtual void Quit (void);
90 
95  virtual void GetStatus (AVHevcStatus & outStatus);
96 
100  virtual M31VideoPreset GetCodecPreset (void);
101 
102  // Protected Instance Methods
103  protected:
107  virtual AJAStatus SetupVideo (void);
108 
112  virtual AJAStatus SetupAudio (void);
113 
117  virtual void RouteInputSignal (void);
118 
122  virtual void SetupHostBuffers (void);
123 
127  virtual void SetupAutoCirculate (void);
128 
132  virtual void StartVideoInputThread (void);
133 
137  virtual void StartVideoProcessThread (void);
138 
142  virtual void StartCodecRawThread (void);
143 
147  virtual void StartCodecHevcThread (void);
148 
152  virtual void StartVideoFileThread (void);
153 
157  virtual void StartAudioFileThread (void);
158 
163  virtual void VideoInputWorker (void);
164 
169  virtual void VideoProcessWorker (void);
170 
175  virtual void CodecRawWorker (void);
176 
181  virtual void CodecHevcWorker (void);
182 
187  virtual void VideoFileWorker (void);
188 
193  virtual void AudioFileWorker (void);
194 
198  virtual AJAStatus ProcessVideoFrame (AVHevcDataBuffer * pSrcFrame, AVHevcDataBuffer * pDstFrame, uint32_t frameNumber);
199 
200  // Protected Class Methods
201  protected:
208  static void VideoInputThreadStatic (AJAThread * pThread, void * pContext);
209 
216  static void VideoProcessThreadStatic (AJAThread * pThread, void * pContext);
217 
224  static void CodecRawThreadStatic (AJAThread * pThread, void * pContext);
225 
232  static void CodecHevcThreadStatic (AJAThread * pThread, void * pContext);
233 
240  static void VideoFileThreadStatic (AJAThread * pThread, void * pContext);
241 
248  static void AudioFileThreadStatic (AJAThread * pThread, void * pContext);
249 
250  // Private Member Data
251  private:
252  AJAThread mVideoInputThread;
253  AJAThread mVideoProcessThread;
254  AJAThread mCodecRawThread;
255  AJAThread mCodecHevcThread;
256  AJAThread mVideoFileThread;
257  AJAThread mAudioFileThread;
258  CNTV2m31 * mM31;
259  CNTV2DemoHevcCommon * mHevcCommon;
260 
261  CNTV2Card mDevice;
262  NTV2DeviceID mDeviceID;
263  const std::string mDeviceSpecifier;
264  bool mWithAudio;
265  NTV2Channel mInputChannel;
266  M31Channel mEncodeChannel;
267  M31VideoPreset mPreset;
268  NTV2InputSource mInputSource;
269  NTV2VideoFormat mVideoFormat;
270  NTV2FrameBufferFormat mPixelFormat;
271  bool mQuad;
272  bool mInterlaced;
273  bool mMultiStream;
274  bool mWithInfo;
275  bool mWithAnc;
276  NTV2AudioSystem mAudioSystem;
277  NTV2EveryFrameTaskMode mSavedTaskMode;
278  uint32_t mNumAudioChannels;
279  uint32_t mFileAudioChannels;
280  uint32_t mMaxFrames;
281 
282  bool mLastFrame;
283  bool mLastFrameInput;
284  bool mLastFrameRaw;
285  bool mLastFrameHevc;
286  bool mLastFrameVideo;
287  bool mLastFrameAudio;
288  bool mGlobalQuit;
289  uint32_t mQueueSize;
290  uint32_t mVideoBufferSize;
291  uint32_t mPicInfoBufferSize;
292  uint32_t mEncInfoBufferSize;
293  uint32_t mAudioBufferSize;
294 
295  AVHevcDataBuffer mVideoInputBuffer [VIDEO_RING_SIZE];
296  AJACircularBuffer <AVHevcDataBuffer *> mVideoInputCircularBuffer;
297 
298  AVHevcDataBuffer mVideoRawBuffer [VIDEO_RING_SIZE];
299  AJACircularBuffer <AVHevcDataBuffer *> mVideoRawCircularBuffer;
300 
301  AVHevcDataBuffer mVideoHevcBuffer [VIDEO_RING_SIZE];
302  AJACircularBuffer <AVHevcDataBuffer *> mVideoHevcCircularBuffer;
303 
304  AVHevcDataBuffer mAudioInputBuffer [AUDIO_RING_SIZE];
305  AJACircularBuffer <AVHevcDataBuffer *> mAudioInputCircularBuffer;
306 
307  uint32_t mVideoInputFrameCount;
308  uint32_t mVideoProcessFrameCount;
309  uint32_t mCodecRawFrameCount;
310  uint32_t mCodecHevcFrameCount;
311  uint32_t mVideoFileFrameCount;
312  uint32_t mAudioFileFrameCount;
313 
314  AJATimeBase mTimeBase;
315  AJATimeCode mTimeCode;
316  AJATimeCodeBurn mTimeCodeBurn;
317 
318 }; // NTV2EncodeHEVCFileAc
319 
320 #endif // _NTV2ENCODEHEVCFILEAC_H
NTV2EncodeHEVCFileAc::StartCodecRawThread
virtual void StartCodecRawThread(void)
Start the codec raw thread.
Definition: ntv2encodehevcfileac.cpp:944
NTV2_FBF_10BIT_YCBCR_420PL2
@ NTV2_FBF_10BIT_YCBCR_420PL2
10-Bit 4:2:0 2-Plane YCbCr
Definition: ntv2enums.h:242
NTV2EncodeHEVCFileAc::CodecHevcWorker
virtual void CodecHevcWorker(void)
Repeatedly transfers hevc frames from the codec and adds them to the hevc ring.
Definition: ntv2encodehevcfileac.cpp:1073
NTV2EncodeHEVCFileAc::StartVideoProcessThread
virtual void StartVideoProcessThread(void)
Start the video process thread.
Definition: ntv2encodehevcfileac.cpp:893
ntv2devicefeatures.h
Declares device capability functions.
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
Definition: ntv2enums.h:1334
ntv2demohevccommon.h
This file contains some structures, constants, classes and functions that are used in some of the hev...
NTV2EncodeHEVCFileAc::VideoFileThreadStatic
static void VideoFileThreadStatic(AJAThread *pThread, void *pContext)
This is the video file writer thread's static callback function that gets called when the thread star...
Definition: ntv2encodehevcfileac.cpp:1201
CNTV2DemoHevcCommon
Definition: ntv2demohevccommon.h:56
NTV2EncodeHEVCFileAc::SetupVideo
virtual AJAStatus SetupVideo(void)
Sets up everything I need for capturing video.
Definition: ntv2encodehevcfileac.cpp:419
NTV2DeviceID
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
NTV2FrameBufferFormat
NTV2FrameBufferFormat
Identifies a particular video frame buffer format. See Device Frame Buffer Formats for details.
Definition: ntv2enums.h:210
NTV2EncodeHEVCFileAc::VideoProcessThreadStatic
static void VideoProcessThreadStatic(AJAThread *pThread, void *pContext)
This is the video process thread's static callback function that gets called when the thread starts....
Definition: ntv2encodehevcfileac.cpp:903
timecode.h
Declares the AJATimeCode class.
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1336
NTV2EncodeHEVCFileAc::SetupAutoCirculate
virtual void SetupAutoCirculate(void)
Initializes AutoCirculate.
Definition: ntv2encodehevcfileac.cpp:696
NTV2EncodeHEVCFileAc::GetCodecPreset
virtual M31VideoPreset GetCodecPreset(void)
Get the codec preset.
Definition: ntv2encodehevcfileac.cpp:413
NTV2EncodeHEVCFileAc::ProcessVideoFrame
virtual AJAStatus ProcessVideoFrame(AVHevcDataBuffer *pSrcFrame, AVHevcDataBuffer *pDstFrame, uint32_t frameNumber)
Default do-nothing function for processing the captured frames.
Definition: ntv2encodehevcfileac.cpp:1313
NTV2EncodeHEVCFileAc::CodecRawWorker
virtual void CodecRawWorker(void)
Repeatedly removes video frames from the raw video ring and transfers them to the codec.
Definition: ntv2encodehevcfileac.cpp:964
AJAThread
Definition: thread.h:69
NTV2EncodeHEVCFileAc::CodecRawThreadStatic
static void CodecRawThreadStatic(AJAThread *pThread, void *pContext)
This is the codec raw thread's static callback function that gets called when the thread starts....
Definition: ntv2encodehevcfileac.cpp:954
timecodeburn.h
Declares the AJATimeCodeBurn class.
NTV2EncodeHEVCFileAc::GetStatus
virtual void GetStatus(AVHevcStatus &outStatus)
Provides status information about my input (capture) process.
Definition: ntv2encodehevcfileac.cpp:1303
AJAStatus
AJAStatus
Definition: types.h:378
NTV2EncodeHEVCFileAc::StartVideoFileThread
virtual void StartVideoFileThread(void)
Start the video file writer thread.
Definition: ntv2encodehevcfileac.cpp:1191
AJATimeBase
Definition: timebase.h:18
ntv2devicescanner.h
Declares the CNTV2DeviceScanner class.
NTV2EncodeHEVCFileAc::Run
virtual AJAStatus Run(void)
Runs me.
Definition: ntv2encodehevcfileac.cpp:706
ntv2enums.h
Enumerations for controlling NTV2 devices.
NTV2EncodeHEVCFileAc::VideoProcessWorker
virtual void VideoProcessWorker(void)
Repeatedly removes video frames from the video input ring, calls a custom video process method and ad...
Definition: ntv2encodehevcfileac.cpp:913
NTV2EncodeHEVCFileAc::CodecHevcThreadStatic
static void CodecHevcThreadStatic(AJAThread *pThread, void *pContext)
This is the codec hevc thread's static callback function that gets called when the thread starts....
Definition: ntv2encodehevcfileac.cpp:1063
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
NTV2EncodeHEVCFileAc::StartVideoInputThread
virtual void StartVideoInputThread(void)
Start the video input thread.
Definition: ntv2encodehevcfileac.cpp:728
M31_FILE_1280X720_420_8_5994p
@ M31_FILE_1280X720_420_8_5994p
Definition: ntv2m31enums.h:35
NTV2EncodeHEVCFileAc::Init
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
Definition: ntv2encodehevcfileac.cpp:254
VIDEO_RING_SIZE
#define VIDEO_RING_SIZE
Definition: ntv2encodehevcfileac.h:28
M31VideoPreset
M31VideoPreset
Definition: ntv2m31enums.h:12
NTV2EncodeHEVCFileAc::SetupAudio
virtual AJAStatus SetupAudio(void)
Sets up everything I need for capturing audio.
Definition: ntv2encodehevcfileac.cpp:545
NTV2EncodeHEVCFileAc::VideoInputThreadStatic
static void VideoInputThreadStatic(AJAThread *pThread, void *pContext)
This is the video input thread's static callback function that gets called when the thread starts....
Definition: ntv2encodehevcfileac.cpp:738
NTV2InputSource
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1244
NTV2EncodeHEVCFileAc::RouteInputSignal
virtual void RouteInputSignal(void)
Sets up device routing for capture.
Definition: ntv2encodehevcfileac.cpp:639
AUDIO_RING_SIZE
#define AUDIO_RING_SIZE
Definition: ntv2encodehevcfileac.h:29
videotypes.h
Declares the enumeration constants used in the ajabase library.
NTV2EncodeHEVCFileAc::StartCodecHevcThread
virtual void StartCodecHevcThread(void)
Start the codec hevc thread.
Definition: ntv2encodehevcfileac.cpp:1053
NTV2EncodeHEVCFileAc::AudioFileThreadStatic
static void AudioFileThreadStatic(AJAThread *pThread, void *pContext)
This is the audio file writer thread's static callback function that gets called when the thread star...
Definition: ntv2encodehevcfileac.cpp:1260
ntv2m31enums.h
Enumerations for controlling NTV2 devices with m31 HEVC encoders.
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
AVHevcStatus
Definition: ntv2demohevccommon.h:48
NTV2EncodeHEVCFileAc::~NTV2EncodeHEVCFileAc
virtual ~NTV2EncodeHEVCFileAc()
Definition: ntv2encodehevcfileac.cpp:80
M31Channel
M31Channel
Definition: ntv2m31enums.h:225
NTV2EveryFrameTaskMode
NTV2EveryFrameTaskMode
Describes the task mode state. See also: Sharing AJA Devices With Other Applications.
Definition: ntv2publicinterface.h:4288
NTV2EncodeHEVCFileAc::StartAudioFileThread
virtual void StartAudioFileThread(void)
Start the audio file writer thread.
Definition: ntv2encodehevcfileac.cpp:1250
NTV2EncodeHEVCFileAc::AudioFileWorker
virtual void AudioFileWorker(void)
Repeatedly removes audio samples from the audio input ring and writes them to the audio output file.
Definition: ntv2encodehevcfileac.cpp:1270
NTV2EncodeHEVCFileAc::VideoFileWorker
virtual void VideoFileWorker(void)
Repeatedly removes hevc frame from the hevc ring and writes them to the hevc output file.
Definition: ntv2encodehevcfileac.cpp:1211
NTV2EncodeHEVCFileAc::VideoInputWorker
virtual void VideoInputWorker(void)
Repeatedly captures video frames using AutoCirculate and add them to the video input ring.
Definition: ntv2encodehevcfileac.cpp:748
circularbuffer.h
Declaration of AJACircularBuffer template class.
AJATimeCodeBurn
Definition: timecodeburn.h:19
NTV2AudioSystem
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information.
Definition: ntv2enums.h:3848
AVHevcDataBuffer
This structure encapsulates the video and audio buffers used by the HEVC demo applications....
Definition: ntv2demohevccommon.h:27
thread.h
Declares the AJAThread class.
NTV2EncodeHEVCFileAc
Instances of me capture frames in real time from a video signal provided to an input of an AJA device...
Definition: ntv2encodehevcfileac.h:37
NTV2EncodeHEVCFileAc::SetupHostBuffers
virtual void SetupHostBuffers(void)
Sets up my circular buffers.
Definition: ntv2encodehevcfileac.cpp:567
NTV2EncodeHEVCFileAc::NTV2EncodeHEVCFileAc
NTV2EncodeHEVCFileAc(const std::string inDeviceSpecifier="0", const NTV2Channel inChannel=NTV2_CHANNEL1, const M31VideoPreset inM31Preset=M31_FILE_1280X720_420_8_5994p, const NTV2FrameBufferFormat inPixelFormat=NTV2_FBF_10BIT_YCBCR_420PL2, const bool inQuadMode=(0), const uint32_t inAudioChannels=0, const bool inTimeCodeBurn=(0), const bool inInfoData=(0), const uint32_t inMaxFrames=0xffffffff)
Constructs me using the given settings.
Definition: ntv2encodehevcfileac.cpp:21
AJACircularBuffer< AVHevcDataBuffer * >
AJATimeCode
Utility class for timecodes.
Definition: timecode.h:17
timebase.h
Declares the AJATimeBase class.
NTV2EncodeHEVCFileAc::Quit
virtual void Quit(void)
Gracefully stops me from running.
Definition: ntv2encodehevcfileac.cpp:176