Agora C++ API Reference for All Platforms

media_recorder_i.h
1 //
2 // media_recorder.hpp
3 //
4 // Created by zexiong qin on 2019-06.
5 // Copyright © 2018 Agora. All rights reserved.
6 //
7
8 #pragma once
9
10 #include "AgoraMediaBase.h"
11 #include <stdint.h>
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 typedef void AyseMuxerContext;
18
19 #define AYSE_IO_FLAG_READ 0x1
20 #define AYSE_IO_FLAG_WRITE 0x2
21 #define AYSE_IO_FLAG_ODIRECT 0x4
22
23 #ifdef __cplusplus
24 }
25 #endif
26
27 namespace agora {
28 namespace media {
29 class IMediaRecorderObserverEx;
30 }
31 namespace rtc {
32
35 class IAVDataObserver {
36 public:
40 enum AVDATA_TYPE {
43 AVDATA_UNKNOWN = 0,
46 AVDATA_VIDEO = 1,
49 AVDATA_AUDIO = 2,
52 AVDATA_AUDIO_MUTE = 3,
53 };
54
55 enum CODEC_VIDEO {
58 CODEC_VIDEO_AVC = 0,
61 CODEC_VIDEO_HEVC = 1,
64 CODEC_VIDEO_VP8 = 2,
65 };
66
67 enum CODEC_AUDIO {
70 CODEC_AUDIO_PCM = 0,
73 CODEC_AUDIO_AAC = 1,
76 CODEC_AUDIO_G722 = 2,
77 };
78
79 struct VDataInfo {
80 unsigned int codec;
81 unsigned int width;
82 unsigned int height;
83 int frameType;
84 int rotation;
85 bool equal(const VDataInfo& vinfo) const {
86 return codec == vinfo.codec && width == vinfo.width && height == vinfo.height &&
87 rotation == vinfo.rotation;
88 }
89
90 VDataInfo() : codec(0), width(0), height(0), frameType(0), rotation(0) {}
91 };
92
93 struct ADataInfo {
94 unsigned int codec;
95 unsigned int bitwidth;
96 unsigned int sample_rate;
97 unsigned int channel;
98 unsigned int sample_size;
99
100 bool equal(const ADataInfo& ainfo) const {
101 return codec == ainfo.codec && bitwidth == ainfo.bitwidth &&
102 sample_rate == ainfo.sample_rate && channel == ainfo.channel;
103 };
104
105 ADataInfo() : codec(0), bitwidth(0), sample_rate(0), channel(0), sample_size(0) {}
106 };
107
108 struct AVData {
112 unsigned int uid;
116 enum AVDATA_TYPE type;
119 unsigned int size;
122 unsigned char* buffer;
125 unsigned int timestamp;
129 VDataInfo vinfo;
133 ADataInfo ainfo;
134
135 AVData() : type(AVDATA_UNKNOWN), size(0), buffer(NULL), timestamp(0) {}
136 };
137
138 virtual ~IAVDataObserver() {}
139
140 virtual bool onAVDataReady(const AVData& avdata) = 0;
141 };
142
143 class IMediaRecorderEx : public IAVDataObserver,
144 public media::IAudioFrameObserver,
145 public media::IVideoEncodedFrameObserver{
146 public:
147 virtual int startRecording(const media::MediaRecorderConfiguration& config) = 0;
148
149 virtual int stopRecording() = 0;
150
151 virtual void release() = 0;
152
153 virtual void setMediaRecorderObserver(media::IMediaRecorderObserverEx* observer) = 0;
154
155 virtual void setSysVersion(int sys_version) = 0;
156
157 bool onPlaybackAudioFrame(const char* channelId, AudioFrame& audioFrame) override{return true;}
158 bool onMixedAudioFrame(const char* channelId, AudioFrame& audioFrame) override{return true;}
159 bool onEarMonitoringAudioFrame(AudioFrame& audioFrame) override { return true; }
160
161 AudioParams getPlaybackAudioParams() override { return AudioParams(48000, 1, RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, 480); }
162
163 AudioParams getRecordAudioParams() override { return AudioParams(48000, 1, RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, 480); }
164
165 AudioParams getMixedAudioParams() override { return AudioParams(48000, 1, RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, 480); }
166
167 AudioParams getEarMonitoringAudioParams() override { return AudioParams(); }
168 };
169
170 } // namespace rtc
171 } // namespace agora
agora::rtc::IAVDataObserver::onAVDataReady
virtual bool onAVDataReady(const AVData &avdata)=0
agora::rtc::IAVDataObserver::CODEC_VIDEO_AVC
@ CODEC_VIDEO_AVC
Definition: media_recorder_i.h:58
agora::rtc::IAVDataObserver::AVData
Definition: media_recorder_i.h:108
agora::rtc::IAVDataObserver::VDataInfo::codec
unsigned int codec
Definition: media_recorder_i.h:80
agora::media::IMediaRecorderObserverEx
Definition: rtc_engine_i.h:47
agora::rtc::IMediaRecorderEx::stopRecording
virtual int stopRecording()=0
agora::rtc::IAVDataObserver::ADataInfo
Definition: media_recorder_i.h:93
agora::rtc::IMediaRecorderEx::setSysVersion
virtual void setSysVersion(int sys_version)=0
agora::rtc::IAVDataObserver::VDataInfo::VDataInfo
VDataInfo()
Definition: media_recorder_i.h:90
agora::rtc::IAVDataObserver::AVDATA_VIDEO
@ AVDATA_VIDEO
Definition: media_recorder_i.h:46
agora::rtc::IMediaRecorderEx::getEarMonitoringAudioParams
AudioParams getEarMonitoringAudioParams() override
Definition: media_recorder_i.h:167
agora::rtc::IAVDataObserver::ADataInfo::codec
unsigned int codec
Definition: media_recorder_i.h:94
agora::media::IAudioFrameObserverBase::AudioFrame
Definition: AgoraMediaBase.h:1270
agora::media::IAudioFrameObserver
Definition: AgoraMediaBase.h:1537
agora::rtc::IAVDataObserver::AVDATA_AUDIO_MUTE
@ AVDATA_AUDIO_MUTE
Definition: media_recorder_i.h:52
agora::rtc::IMediaRecorderEx::getRecordAudioParams
AudioParams getRecordAudioParams() override
Definition: media_recorder_i.h:163
agora::rtc::IAVDataObserver::ADataInfo::channel
unsigned int channel
Definition: media_recorder_i.h:97
agora::rtc::IMediaRecorderEx::onEarMonitoringAudioFrame
bool onEarMonitoringAudioFrame(AudioFrame &audioFrame) override
Definition: media_recorder_i.h:159
agora::rtc::IMediaRecorderEx::getPlaybackAudioParams
AudioParams getPlaybackAudioParams() override
Definition: media_recorder_i.h:161
agora
Definition: AgoraAtomicOps.h:21
agora::rtc::IAVDataObserver::AVData::timestamp
unsigned int timestamp
Definition: media_recorder_i.h:125
agora::rtc::IAVDataObserver::ADataInfo::equal
bool equal(const ADataInfo &ainfo) const
Definition: media_recorder_i.h:100
agora::rtc::IMediaRecorderEx::getMixedAudioParams
AudioParams getMixedAudioParams() override
Definition: media_recorder_i.h:165
agora::rtc::IAVDataObserver::CODEC_VIDEO_VP8
@ CODEC_VIDEO_VP8
Definition: media_recorder_i.h:64
agora::rtc::IAVDataObserver::AVData::uid
unsigned int uid
Definition: media_recorder_i.h:112
agora::rtc::IAVDataObserver::ADataInfo::bitwidth
unsigned int bitwidth
Definition: media_recorder_i.h:95
agora::rtc::IMediaRecorderEx
Definition: media_recorder_i.h:145
agora::rtc::IAVDataObserver::AVData::size
unsigned int size
Definition: media_recorder_i.h:119
agora::rtc::IAVDataObserver::ADataInfo::sample_rate
unsigned int sample_rate
Definition: media_recorder_i.h:96
agora::rtc::IAVDataObserver::AVData::buffer
unsigned char * buffer
Definition: media_recorder_i.h:122
agora::rtc::IAVDataObserver::AVDATA_UNKNOWN
@ AVDATA_UNKNOWN
Definition: media_recorder_i.h:43
agora::rtc::IAVDataObserver::AVData::vinfo
VDataInfo vinfo
Definition: media_recorder_i.h:129
agora::rtc::IAVDataObserver::~IAVDataObserver
virtual ~IAVDataObserver()
Definition: media_recorder_i.h:138
agora::rtc::IMediaRecorderEx::release
virtual void release()=0
agora::rtc::IAVDataObserver::VDataInfo
Definition: media_recorder_i.h:79
agora::rtc::RAW_AUDIO_FRAME_OP_MODE_READ_ONLY
@ RAW_AUDIO_FRAME_OP_MODE_READ_ONLY
Definition: AgoraMediaBase.h:232
agora::rtc::IAVDataObserver::VDataInfo::height
unsigned int height
Definition: media_recorder_i.h:82
agora::rtc::IAVDataObserver
Definition: media_recorder_i.h:35
agora::rtc::IMediaRecorderEx::startRecording
virtual int startRecording(const media::MediaRecorderConfiguration &config)=0
agora::rtc::IMediaRecorderEx::setMediaRecorderObserver
virtual void setMediaRecorderObserver(media::IMediaRecorderObserverEx *observer)=0
agora::media::IAudioFrameObserverBase::AudioParams
Definition: AgoraMediaBase.h:1365
agora::rtc::IAVDataObserver::ADataInfo::ADataInfo
ADataInfo()
Definition: media_recorder_i.h:105
agora::media::MediaRecorderConfiguration
Definition: AgoraMediaBase.h:1973
agora::rtc::IAVDataObserver::VDataInfo::width
unsigned int width
Definition: media_recorder_i.h:81
agora::rtc::IAVDataObserver::AVData::AVData
AVData()
Definition: media_recorder_i.h:135
agora::rtc::IAVDataObserver::CODEC_AUDIO
CODEC_AUDIO
Definition: media_recorder_i.h:67
agora::rtc::IAVDataObserver::AVData::ainfo
ADataInfo ainfo
Definition: media_recorder_i.h:133
agora::rtc::IAVDataObserver::CODEC_VIDEO_HEVC
@ CODEC_VIDEO_HEVC
Definition: media_recorder_i.h:61
agora::media::IVideoEncodedFrameObserver
Definition: AgoraMediaBase.h:1630
agora::rtc::IAVDataObserver::AVDATA_TYPE
AVDATA_TYPE
Definition: media_recorder_i.h:40
agora::rtc::IAVDataObserver::VDataInfo::frameType
int frameType
Definition: media_recorder_i.h:83
agora::rtc::IAVDataObserver::CODEC_AUDIO_AAC
@ CODEC_AUDIO_AAC
Definition: media_recorder_i.h:73
agora::rtc::IAVDataObserver::CODEC_AUDIO_PCM
@ CODEC_AUDIO_PCM
Definition: media_recorder_i.h:70
agora::rtc::IAVDataObserver::VDataInfo::equal
bool equal(const VDataInfo &vinfo) const
Definition: media_recorder_i.h:85
agora::rtc::IAVDataObserver::AVDATA_AUDIO
@ AVDATA_AUDIO
Definition: media_recorder_i.h:49
agora::rtc::IAVDataObserver::AVData::type
enum AVDATA_TYPE type
Definition: media_recorder_i.h:116
agora::rtc::IAVDataObserver::CODEC_AUDIO_G722
@ CODEC_AUDIO_G722
Definition: media_recorder_i.h:76
agora::rtc::IMediaRecorderEx::onMixedAudioFrame
bool onMixedAudioFrame(const char *channelId, AudioFrame &audioFrame) override
Definition: media_recorder_i.h:158
agora::rtc::IAVDataObserver::VDataInfo::rotation
int rotation
Definition: media_recorder_i.h:84
agora::rtc::IMediaRecorderEx::onPlaybackAudioFrame
bool onPlaybackAudioFrame(const char *channelId, AudioFrame &audioFrame) override
Definition: media_recorder_i.h:157
agora::rtc::IAVDataObserver::CODEC_VIDEO
CODEC_VIDEO
Definition: media_recorder_i.h:55
rtc
Definition: video_node_i.h:28
agora::rtc::IAVDataObserver::ADataInfo::sample_size
unsigned int sample_size
Definition: media_recorder_i.h:98