Agora C++ API Reference for All Platforms

audio_node_stat_i.h
1 //
2 // Agora Engine SDK
3 //
4 // Created by ChenZhipeng in 2022-08.
5 // Copyright (c) 2022 Agora.io. All rights reserved.
6 //
7 #pragma once
8
9
10 #include <stddef.h>
11
12 #include <algorithm>
13 #include <cstring>
14 #include <map>
15 #include <string>
16
17 namespace agora {
18 namespace rtc {
19
20 const static int kNoSourceValidForDownlink = -1379;
21
22 enum class AUDIO_FRAME_SOURCE_TYPE {
23 UNKNOWN = 0,
24 RECORD = 1 << 0,
25 PUSH_DIRECT = 1 << 1,
26 PUSH_EXTERNAL = 1 << 2,
27 SIMPLE_MEDIA_PLAYER = 1 << 3,
28 FFMPEG_MEDIA_PLAYER = 1 << 4,
29 KNOWN_TYPE_COUNT = 5,
30 };
31
32 struct AudioFrameHandleInfo {
33 enum AUDIO_UPLINK_HANDLE_TIMING {
34 FRAME_PTS,
35 DATA_READY,
36 FORMAT_FRAME,
37 POST_TO_ENCODER_QUEUE,
38 PRE_ENCODE,
39 START_ENCODE,
40 ENCODED,
41 POST_TO_SEND_QUEUE,
42 READY_SEND,
43 VOS_SEND,
44 TIMING_COUNT,
45 };
46
47 bool source_mute = false;
48 int64_t time_us[TIMING_COUNT]{};
49 int source_type = static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::UNKNOWN);
50
51 AudioFrameHandleInfo() {}
52
53 AudioFrameHandleInfo(const AudioFrameHandleInfo& info) {
54 source_type = info.source_type;
55 source_mute = info.source_mute;
56 std::copy(info.time_us, info.time_us + TIMING_COUNT, time_us);
57 }
58
59 AudioFrameHandleInfo& operator=(const AudioFrameHandleInfo& rhs) {
60 source_type = rhs.source_type;
61 source_mute = rhs.source_mute;
62 std::copy(rhs.time_us, rhs.time_us + TIMING_COUNT, time_us);
63 return *this;
64 }
65
66 bool valid() const {
67 return (source_type >= 0 && time_us[FORMAT_FRAME] > 0 &&
68 time_us[VOS_SEND] > time_us[FORMAT_FRAME]);
69 }
70
71 static std::string getAudioFrameSourceName(int type) {
72 std::map<int, const char*> source_name = {
73 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::UNKNOWN), "unknown"},
74 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::RECORD), "record"},
75 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::PUSH_DIRECT), "push-direct"},
76 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::PUSH_EXTERNAL),
77 "push-external"},
78 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::SIMPLE_MEDIA_PLAYER),
79 "simple_media_player"},
80 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::FFMPEG_MEDIA_PLAYER),
81 "ffmpeg_media_player"},
82 };
83
84 std::string name;
85 int cnt = static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::KNOWN_TYPE_COUNT);
86 for (int i = 0; i < cnt; ++i) {
87 if (type & (1 << i)) {
88 auto iter = source_name.find(1 << i);
89 if (iter != source_name.end()) {
90 if (!name.empty()) {
91 name.push_back('|');
92 }
93 name.append(iter->second);
94 }
95 }
96 }
97 if (name.empty()) {
98 return "unknown";
99 }
100 return name;
101 }
102 };
103
104 } // namespace rtc
105 } // namespace agora
agora::rtc::AudioFrameHandleInfo::getAudioFrameSourceName
static std::string getAudioFrameSourceName(int type)
Definition: audio_node_stat_i.h:71
agora::rtc::AudioFrameHandleInfo::AUDIO_UPLINK_HANDLE_TIMING
AUDIO_UPLINK_HANDLE_TIMING
Definition: audio_node_stat_i.h:33
agora::rtc::AudioFrameHandleInfo::POST_TO_ENCODER_QUEUE
@ POST_TO_ENCODER_QUEUE
Definition: audio_node_stat_i.h:37
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::SIMPLE_MEDIA_PLAYER
@ SIMPLE_MEDIA_PLAYER
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::RECORD
@ RECORD
agora::rtc::kNoSourceValidForDownlink
static const int kNoSourceValidForDownlink
Definition: audio_node_stat_i.h:20
agora::rtc::AudioFrameHandleInfo::ENCODED
@ ENCODED
Definition: audio_node_stat_i.h:40
agora::rtc::AudioFrameHandleInfo::DATA_READY
@ DATA_READY
Definition: audio_node_stat_i.h:35
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::FFMPEG_MEDIA_PLAYER
@ FFMPEG_MEDIA_PLAYER
agora::rtc::AudioFrameHandleInfo::TIMING_COUNT
@ TIMING_COUNT
Definition: audio_node_stat_i.h:44
agora::rtc::AudioFrameHandleInfo::FORMAT_FRAME
@ FORMAT_FRAME
Definition: audio_node_stat_i.h:36
agora::rtc::AudioFrameHandleInfo::source_type
int source_type
Definition: audio_node_stat_i.h:49
agora
Definition: AgoraAtomicOps.h:21
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::KNOWN_TYPE_COUNT
@ KNOWN_TYPE_COUNT
agora::rtc::AudioFrameHandleInfo::AudioFrameHandleInfo
AudioFrameHandleInfo()
Definition: audio_node_stat_i.h:51
agora::rtc::AudioFrameHandleInfo::START_ENCODE
@ START_ENCODE
Definition: audio_node_stat_i.h:39
agora::rtc::AudioFrameHandleInfo::AudioFrameHandleInfo
AudioFrameHandleInfo(const AudioFrameHandleInfo &info)
Definition: audio_node_stat_i.h:53
agora::rtc::AudioFrameHandleInfo
Definition: audio_node_stat_i.h:32
agora::rtc::AudioFrameHandleInfo::READY_SEND
@ READY_SEND
Definition: audio_node_stat_i.h:42
agora::rtc::AudioFrameHandleInfo::POST_TO_SEND_QUEUE
@ POST_TO_SEND_QUEUE
Definition: audio_node_stat_i.h:41
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::PUSH_EXTERNAL
@ PUSH_EXTERNAL
agora::rtc::AudioFrameHandleInfo::valid
bool valid() const
Definition: audio_node_stat_i.h:66
agora::rtc::AudioFrameHandleInfo::time_us
int64_t time_us[TIMING_COUNT]
Definition: audio_node_stat_i.h:48
agora::rtc::AudioFrameHandleInfo::FRAME_PTS
@ FRAME_PTS
Definition: audio_node_stat_i.h:34
agora::rtc::AudioFrameHandleInfo::VOS_SEND
@ VOS_SEND
Definition: audio_node_stat_i.h:43
agora::rtc::AudioFrameHandleInfo::source_mute
bool source_mute
Definition: audio_node_stat_i.h:47
agora::rtc::AudioFrameHandleInfo::operator=
AudioFrameHandleInfo & operator=(const AudioFrameHandleInfo &rhs)
Definition: audio_node_stat_i.h:59
agora::rtc::AUDIO_FRAME_SOURCE_TYPE
AUDIO_FRAME_SOURCE_TYPE
Definition: audio_node_stat_i.h:22
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::PUSH_DIRECT
@ PUSH_DIRECT
agora::rtc::AudioFrameHandleInfo::PRE_ENCODE
@ PRE_ENCODE
Definition: audio_node_stat_i.h:38
rtc
Definition: video_node_i.h:28
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::UNKNOWN
@ UNKNOWN