1#ifndef ENGINE_CLIENT_VIDEO_H
2#define ENGINE_CLIENT_VIDEO_H
7#include <libavcodec/avcodec.h>
8#include <libavformat/avformat.h>
14#include <condition_variable>
74 AVFrame *
AllocPicture(
enum AVPixelFormat PixFmt,
int Width,
int Height);
75 AVFrame *
AllocAudioFrame(
enum AVSampleFormat SampleFmt, uint64_t ChannelLayout,
int SampleRate,
int NbSamples);
81 bool AddStream(
COutputStream *pStream, AVFormatContext *pFormatContext,
const AVCodec **ppCodec,
enum AVCodecID CodecId)
const;
std::vector< AVFrame * > m_vpFrames
Definition: video.h:36
AVCodecContext * m_pCodecContext
Definition: video.h:30
int64_t m_SamplesFrameCount
Definition: video.h:34
std::vector< struct SwrContext * > m_vpSwrContexts
Definition: video.h:40
std::vector< struct SwsContext * > m_vpSwsContexts
Definition: video.h:39
std::vector< AVFrame * > m_vpTmpFrames
Definition: video.h:37
int64_t m_SamplesCount
Definition: video.h:33
AVStream * m_pStream
Definition: video.h:29
int16_t m_aBuffer[4096]
Definition: video.h:155
std::condition_variable m_Cond
Definition: video.h:127
int64_t m_SampleCountStart
Definition: video.h:136
bool m_HasAudioFrame
Definition: video.h:131
bool m_Started
Definition: video.h:129
std::mutex m_Mutex
Definition: video.h:126
std::thread m_Thread
Definition: video.h:125
bool m_Finished
Definition: video.h:130
std::condition_variable m_AudioFillCond
Definition: video.h:134
std::mutex m_AudioFillMutex
Definition: video.h:133
uint64_t m_AudioFrameToFill
Definition: video.h:135
std::vector< uint8_t > m_vBuffer
Definition: video.h:149
bool m_Started
Definition: video.h:111
std::mutex m_Mutex
Definition: video.h:108
bool m_Finished
Definition: video.h:112
std::mutex m_VideoFillMutex
Definition: video.h:115
uint64_t m_VideoFrameToFill
Definition: video.h:117
std::condition_variable m_VideoFillCond
Definition: video.h:116
bool m_HasVideoFrame
Definition: video.h:113
std::thread m_Thread
Definition: video.h:107
std::condition_variable m_Cond
Definition: video.h:109
void NextAudioFrame(ISoundMixFunc Mix) override
Definition: video.cpp:420
bool OpenVideo()
Definition: video.cpp:690
bool m_HasAudio
Definition: video.h:144
void NextVideoFrame() override
Definition: video.cpp:398
ISound * m_pSound
Definition: video.h:85
void NextAudioFrameTimeline(ISoundMixFunc Mix) override
Definition: video.cpp:407
IGraphics * m_pGraphics
Definition: video.h:83
std::vector< CVideoBuffer > m_vVideoBuffers
Definition: video.h:151
void NextVideoFrameThread() override
Definition: video.cpp:347
std::vector< std::unique_ptr< CAudioRecorderThread > > m_vpAudioThreads
Definition: video.h:139
bool m_Recording
Definition: video.h:97
void FillVideoFrame(size_t ThreadIndex) REQUIRES(!g_WriteLock)
Definition: video.cpp:613
bool OpenAudio()
Definition: video.cpp:754
size_t m_CurVideoThreadIndex
Definition: video.h:100
static void Init()
Definition: video.cpp:74
COutputStream m_AudioStream
Definition: video.h:160
void RunVideoThread(size_t ParentThreadIndex, size_t ThreadIndex) REQUIRES(!g_WriteLock)
Definition: video.cpp:569
void UpdateVideoBufferFromGraphics(size_t ThreadIndex)
Definition: video.cpp:621
std::atomic< int32_t > m_ProcessingVideoFrame
Definition: video.h:141
size_t m_CurAudioThreadIndex
Definition: video.h:102
IStorage * m_pStorage
Definition: video.h:84
uint64_t m_VideoFrameIndex
Definition: video.h:90
bool AddStream(COutputStream *pStream, AVFormatContext *pFormatContext, const AVCodec **ppCodec, enum AVCodecID CodecId) const
Definition: video.cpp:863
AVFrame * AllocAudioFrame(enum AVSampleFormat SampleFmt, uint64_t ChannelLayout, int SampleRate, int NbSamples)
Definition: video.cpp:657
void RunAudioThread(size_t ParentThreadIndex, size_t ThreadIndex) REQUIRES(!g_WriteLock)
Definition: video.cpp:480
AVFormatContext * m_pFormatContext
Definition: video.h:167
std::vector< CAudioBuffer > m_vAudioBuffers
Definition: video.h:157
size_t m_AudioThreads
Definition: video.h:101
AVDictionary * m_pOptDict
Definition: video.h:165
void CloseStream(COutputStream *pStream)
Definition: video.cpp:1078
const AVOutputFormat * m_pFormat
Definition: video.h:168
std::atomic< int32_t > m_ProcessingAudioFrame
Definition: video.h:142
void WriteFrame(COutputStream *pStream, size_t ThreadIndex) REQUIRES(g_WriteLock)
Definition: video.cpp:985
bool m_Started
Definition: video.h:95
CVideo(IGraphics *pGraphics, ISound *pSound, IStorage *pStorage, int Width, int Height, const char *pName)
Definition: video.cpp:79
size_t m_VideoThreads
Definition: video.h:99
char m_aName[256]
Definition: video.h:89
static IVideo * Current()
Definition: video.h:60
bool IsRecording() override
Definition: video.h:52
void FinishFrames(COutputStream *pStream)
Definition: video.cpp:1030
uint64_t m_AudioFrameIndex
Definition: video.h:91
void FillAudioFrame(size_t ThreadIndex)
Definition: video.cpp:525
~CVideo()
Definition: video.cpp:111
COutputStream m_VideoStream
Definition: video.h:159
std::vector< std::unique_ptr< CVideoRecorderThread > > m_vpVideoThreads
Definition: video.h:120
bool Start() override REQUIRES(!g_WriteLock)
Definition: video.cpp:116
int m_Height
Definition: video.h:88
void Stop() override
Definition: video.cpp:283
bool m_Stopped
Definition: video.h:96
const AVCodec * m_pAudioCodec
Definition: video.h:163
void Pause(bool Pause) override
Definition: video.cpp:277
AVFrame * AllocPicture(enum AVPixelFormat PixFmt, int Width, int Height)
Definition: video.cpp:631
const AVCodec * m_pVideoCodec
Definition: video.h:162
int m_FPS
Definition: video.h:93
int m_Width
Definition: video.h:87
Definition: graphics.h:183
static IVideo * ms_pCurrentVideo
Definition: video.h:34
CLock g_WriteLock
Definition: video.cpp:37
#define REQUIRES(...)
Definition: lock.h:32
std::function< void(short *pFinalOut, unsigned Frames)> ISoundMixFunc
Definition: video.h:8