Agora C++ API Reference for All Platforms

Loading...
Searching...
No Matches
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
14extern "C" {
15#endif
16
17typedef 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
27namespace agora {
28namespace media {
29class IMediaRecorderObserverEx;
30}
31namespace 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::media::IAudioFrameObserver
Definition AgoraMediaBase.h:1815
agora::media::IMediaRecorderObserverEx
Definition rtc_engine_i.h:47
agora::media::IVideoEncodedFrameObserver
Definition AgoraMediaBase.h:1920
agora::rtc::IAVDataObserver
Definition media_recorder_i.h:35
agora::rtc::IAVDataObserver::onAVDataReady
virtual bool onAVDataReady(const AVData &avdata)=0
agora::rtc::IAVDataObserver::~IAVDataObserver
virtual ~IAVDataObserver()
Definition media_recorder_i.h:138
agora::rtc::IAVDataObserver::CODEC_VIDEO
CODEC_VIDEO
Definition media_recorder_i.h:55
agora::rtc::IAVDataObserver::CODEC_VIDEO_HEVC
@ CODEC_VIDEO_HEVC
Definition media_recorder_i.h:61
agora::rtc::IAVDataObserver::CODEC_VIDEO_VP8
@ CODEC_VIDEO_VP8
Definition media_recorder_i.h:64
agora::rtc::IAVDataObserver::CODEC_VIDEO_AVC
@ CODEC_VIDEO_AVC
Definition media_recorder_i.h:58
agora::rtc::IAVDataObserver::AVDATA_TYPE
AVDATA_TYPE
Definition media_recorder_i.h:40
agora::rtc::IAVDataObserver::AVDATA_AUDIO_MUTE
@ AVDATA_AUDIO_MUTE
Definition media_recorder_i.h:52
agora::rtc::IAVDataObserver::AVDATA_AUDIO
@ AVDATA_AUDIO
Definition media_recorder_i.h:49
agora::rtc::IAVDataObserver::AVDATA_VIDEO
@ AVDATA_VIDEO
Definition media_recorder_i.h:46
agora::rtc::IAVDataObserver::AVDATA_UNKNOWN
@ AVDATA_UNKNOWN
Definition media_recorder_i.h:43
agora::rtc::IAVDataObserver::CODEC_AUDIO
CODEC_AUDIO
Definition media_recorder_i.h:67
agora::rtc::IAVDataObserver::CODEC_AUDIO_AAC
@ CODEC_AUDIO_AAC
Definition media_recorder_i.h:73
agora::rtc::IAVDataObserver::CODEC_AUDIO_G722
@ CODEC_AUDIO_G722
Definition media_recorder_i.h:76
agora::rtc::IAVDataObserver::CODEC_AUDIO_PCM
@ CODEC_AUDIO_PCM
Definition media_recorder_i.h:70
agora::rtc::IMediaRecorderEx
Definition media_recorder_i.h:145
agora::rtc::IMediaRecorderEx::onEarMonitoringAudioFrame
bool onEarMonitoringAudioFrame(AudioFrame &audioFrame) override
Gets the in-ear monitoring audio frame.
Definition media_recorder_i.h:159
agora::rtc::IMediaRecorderEx::getRecordAudioParams
AudioParams getRecordAudioParams() override
Sets the audio format for the onRecordAudioFrame callback.
Definition media_recorder_i.h:163
agora::rtc::IMediaRecorderEx::startRecording
virtual int startRecording(const media::MediaRecorderConfiguration &config)=0
agora::rtc::IMediaRecorderEx::setSysVersion
virtual void setSysVersion(int sys_version)=0
agora::rtc::IMediaRecorderEx::release
virtual void release()=0
agora::rtc::IMediaRecorderEx::getMixedAudioParams
AudioParams getMixedAudioParams() override
Sets the audio format for the onMixedAudioFrame callback.
Definition media_recorder_i.h:165
agora::rtc::IMediaRecorderEx::setMediaRecorderObserver
virtual void setMediaRecorderObserver(media::IMediaRecorderObserverEx *observer)=0
agora::rtc::IMediaRecorderEx::getPlaybackAudioParams
AudioParams getPlaybackAudioParams() override
Sets the audio format for the onPlaybackAudioFrame callback.
Definition media_recorder_i.h:161
agora::rtc::IMediaRecorderEx::getEarMonitoringAudioParams
AudioParams getEarMonitoringAudioParams() override
Sets the audio format for the onEarMonitoringAudioFrame callback.
Definition media_recorder_i.h:167
agora::rtc::IMediaRecorderEx::onPlaybackAudioFrame
bool onPlaybackAudioFrame(const char *channelId, AudioFrame &audioFrame) override
Gets the raw audio frame for playback.
Definition media_recorder_i.h:157
agora::rtc::IMediaRecorderEx::stopRecording
virtual int stopRecording()=0
agora::rtc::IMediaRecorderEx::onMixedAudioFrame
bool onMixedAudioFrame(const char *channelId, AudioFrame &audioFrame) override
Retrieves the mixed captured and playback audio frame.
Definition media_recorder_i.h:158
agora::media
Definition content_inspect_i.h:15
agora::rtc
Definition AgoraExtensions.h:5
agora::rtc::RAW_AUDIO_FRAME_OP_MODE_READ_ONLY
@ RAW_AUDIO_FRAME_OP_MODE_READ_ONLY
Definition AgoraMediaBase.h:267
agora
Definition AgoraAtomicOps.h:21
agora::media::IAudioFrameObserverBase::AudioFrame
Raw audio data.
Definition AgoraMediaBase.h:1429
agora::media::IAudioFrameObserverBase::AudioParams
Audio data format.
Definition AgoraMediaBase.h:1539
agora::media::MediaRecorderConfiguration
Configuration for audio and video stream recording.
Definition AgoraMediaBase.h:2355
agora::rtc::IAVDataObserver::ADataInfo
Definition media_recorder_i.h:93
agora::rtc::IAVDataObserver::ADataInfo::ADataInfo
ADataInfo()
Definition media_recorder_i.h:105
agora::rtc::IAVDataObserver::ADataInfo::equal
bool equal(const ADataInfo &ainfo) const
Definition media_recorder_i.h:100
agora::rtc::IAVDataObserver::ADataInfo::sample_size
unsigned int sample_size
Definition media_recorder_i.h:98
agora::rtc::IAVDataObserver::ADataInfo::bitwidth
unsigned int bitwidth
Definition media_recorder_i.h:95
agora::rtc::IAVDataObserver::ADataInfo::codec
unsigned int codec
Definition media_recorder_i.h:94
agora::rtc::IAVDataObserver::ADataInfo::channel
unsigned int channel
Definition media_recorder_i.h:97
agora::rtc::IAVDataObserver::ADataInfo::sample_rate
unsigned int sample_rate
Definition media_recorder_i.h:96
agora::rtc::IAVDataObserver::AVData
Definition media_recorder_i.h:108
agora::rtc::IAVDataObserver::AVData::vinfo
VDataInfo vinfo
Definition media_recorder_i.h:129
agora::rtc::IAVDataObserver::AVData::ainfo
ADataInfo ainfo
Definition media_recorder_i.h:133
agora::rtc::IAVDataObserver::AVData::type
enum AVDATA_TYPE type
Definition media_recorder_i.h:116
agora::rtc::IAVDataObserver::AVData::buffer
unsigned char * buffer
Definition media_recorder_i.h:122
agora::rtc::IAVDataObserver::AVData::AVData
AVData()
Definition media_recorder_i.h:135
agora::rtc::IAVDataObserver::AVData::size
unsigned int size
Definition media_recorder_i.h:119
agora::rtc::IAVDataObserver::AVData::timestamp
unsigned int timestamp
Definition media_recorder_i.h:125
agora::rtc::IAVDataObserver::AVData::uid
unsigned int uid
Definition media_recorder_i.h:112
agora::rtc::IAVDataObserver::VDataInfo
Definition media_recorder_i.h:79
agora::rtc::IAVDataObserver::VDataInfo::height
unsigned int height
Definition media_recorder_i.h:82
agora::rtc::IAVDataObserver::VDataInfo::width
unsigned int width
Definition media_recorder_i.h:81
agora::rtc::IAVDataObserver::VDataInfo::frameType
int frameType
Definition media_recorder_i.h:83
agora::rtc::IAVDataObserver::VDataInfo::VDataInfo
VDataInfo()
Definition media_recorder_i.h:90
agora::rtc::IAVDataObserver::VDataInfo::rotation
int rotation
Definition media_recorder_i.h:84
agora::rtc::IAVDataObserver::VDataInfo::equal
bool equal(const VDataInfo &vinfo) const
Definition media_recorder_i.h:85
agora::rtc::IAVDataObserver::VDataInfo::codec
unsigned int codec
Definition media_recorder_i.h:80