Agora C++ API Reference for All Platforms

Loading...
Searching...
No Matches
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 START_ENCODE,
38 ENCODED,
39 VOS_SEND,
40 TIMING_COUNT,
41 };
42 enum AUDIO_FRAME_EXTRA_INFO {
43 REC_DELAY,
44 APM_DELAY,
45 FRAME_RMS,
46 EXTRA_INFO_COUNT
47 };
48
49 bool source_mute = false;
50 int64_t time_us[TIMING_COUNT]{};
51 int32_t extra_info[EXTRA_INFO_COUNT]{};
52 int source_type = static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::UNKNOWN);
53
54 AudioFrameHandleInfo() {}
55
56 AudioFrameHandleInfo(const AudioFrameHandleInfo& info) {
57 source_type = info.source_type;
58 source_mute = info.source_mute;
59 std::memcpy(time_us, info.time_us, sizeof(time_us));
60 std::memcpy(extra_info, info.extra_info, sizeof(extra_info));
61 }
62
63 AudioFrameHandleInfo& operator=(const AudioFrameHandleInfo& rhs) {
64 source_type = rhs.source_type;
65 source_mute = rhs.source_mute;
66 std::memcpy(time_us, rhs.time_us, sizeof(time_us));
67 std::memcpy(extra_info, rhs.extra_info, sizeof(extra_info));
68 return *this;
69 }
70
71 bool valid() const {
72 return (source_type >= 0 && time_us[FORMAT_FRAME] > 0 &&
73 time_us[VOS_SEND] > time_us[FORMAT_FRAME]);
74 }
75
76 static std::string getAudioFrameSourceName(int type) {
77 std::map<int, const char*> source_name = {
78 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::UNKNOWN), "unknown"},
79 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::RECORD), "record"},
80 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::PUSH_DIRECT), "push-direct"},
81 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::PUSH_EXTERNAL),
82 "push-external"},
83 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::SIMPLE_MEDIA_PLAYER),
84 "simple_media_player"},
85 {static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::FFMPEG_MEDIA_PLAYER),
86 "ffmpeg_media_player"},
87 };
88
89 std::string name;
90 int cnt = static_cast<int>(AUDIO_FRAME_SOURCE_TYPE::KNOWN_TYPE_COUNT);
91 for (int i = 0; i < cnt; ++i) {
92 if (type & (1 << i)) {
93 auto iter = source_name.find(1 << i);
94 if (iter != source_name.end()) {
95 if (!name.empty()) {
96 name.push_back('|');
97 }
98 name.append(iter->second);
99 }
100 }
101 }
102 if (name.empty()) {
103 return "unknown";
104 }
105 return name;
106 }
107};
108
109} // namespace rtc
110} // namespace agora
agora::rtc
Definition AgoraExtensionVersion.h:12
agora::rtc::kNoSourceValidForDownlink
static const int kNoSourceValidForDownlink
Definition audio_node_stat_i.h:20
agora::rtc::AUDIO_FRAME_SOURCE_TYPE
AUDIO_FRAME_SOURCE_TYPE
Definition audio_node_stat_i.h:22
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::PUSH_EXTERNAL
@ PUSH_EXTERNAL
Definition audio_node_stat_i.h:26
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::KNOWN_TYPE_COUNT
@ KNOWN_TYPE_COUNT
Definition audio_node_stat_i.h:29
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::UNKNOWN
@ UNKNOWN
Definition audio_node_stat_i.h:23
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::FFMPEG_MEDIA_PLAYER
@ FFMPEG_MEDIA_PLAYER
Definition audio_node_stat_i.h:28
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::RECORD
@ RECORD
Definition audio_node_stat_i.h:24
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::SIMPLE_MEDIA_PLAYER
@ SIMPLE_MEDIA_PLAYER
Definition audio_node_stat_i.h:27
agora::rtc::AUDIO_FRAME_SOURCE_TYPE::PUSH_DIRECT
@ PUSH_DIRECT
Definition audio_node_stat_i.h:25
agora
Definition AgoraAtomicOps.h:21
agora::rtc::AudioFrameHandleInfo::AudioFrameHandleInfo
AudioFrameHandleInfo()
Definition audio_node_stat_i.h:54
agora::rtc::AudioFrameHandleInfo::source_type
int source_type
Definition audio_node_stat_i.h:52
agora::rtc::AudioFrameHandleInfo::valid
bool valid() const
Definition audio_node_stat_i.h:71
agora::rtc::AudioFrameHandleInfo::source_mute
bool source_mute
Definition audio_node_stat_i.h:49
agora::rtc::AudioFrameHandleInfo::extra_info
int32_t extra_info[EXTRA_INFO_COUNT]
Definition audio_node_stat_i.h:51
agora::rtc::AudioFrameHandleInfo::getAudioFrameSourceName
static std::string getAudioFrameSourceName(int type)
Definition audio_node_stat_i.h:76
agora::rtc::AudioFrameHandleInfo::operator=
AudioFrameHandleInfo & operator=(const AudioFrameHandleInfo &rhs)
Definition audio_node_stat_i.h:63
agora::rtc::AudioFrameHandleInfo::AUDIO_FRAME_EXTRA_INFO
AUDIO_FRAME_EXTRA_INFO
Definition audio_node_stat_i.h:42
agora::rtc::AudioFrameHandleInfo::FRAME_RMS
@ FRAME_RMS
Definition audio_node_stat_i.h:45
agora::rtc::AudioFrameHandleInfo::REC_DELAY
@ REC_DELAY
Definition audio_node_stat_i.h:43
agora::rtc::AudioFrameHandleInfo::EXTRA_INFO_COUNT
@ EXTRA_INFO_COUNT
Definition audio_node_stat_i.h:46
agora::rtc::AudioFrameHandleInfo::APM_DELAY
@ APM_DELAY
Definition audio_node_stat_i.h:44
agora::rtc::AudioFrameHandleInfo::AUDIO_UPLINK_HANDLE_TIMING
AUDIO_UPLINK_HANDLE_TIMING
Definition audio_node_stat_i.h:33
agora::rtc::AudioFrameHandleInfo::DATA_READY
@ DATA_READY
Definition audio_node_stat_i.h:35
agora::rtc::AudioFrameHandleInfo::FORMAT_FRAME
@ FORMAT_FRAME
Definition audio_node_stat_i.h:36
agora::rtc::AudioFrameHandleInfo::FRAME_PTS
@ FRAME_PTS
Definition audio_node_stat_i.h:34
agora::rtc::AudioFrameHandleInfo::TIMING_COUNT
@ TIMING_COUNT
Definition audio_node_stat_i.h:40
agora::rtc::AudioFrameHandleInfo::ENCODED
@ ENCODED
Definition audio_node_stat_i.h:38
agora::rtc::AudioFrameHandleInfo::VOS_SEND
@ VOS_SEND
Definition audio_node_stat_i.h:39
agora::rtc::AudioFrameHandleInfo::START_ENCODE
@ START_ENCODE
Definition audio_node_stat_i.h:37
agora::rtc::AudioFrameHandleInfo::AudioFrameHandleInfo
AudioFrameHandleInfo(const AudioFrameHandleInfo &info)
Definition audio_node_stat_i.h:56
agora::rtc::AudioFrameHandleInfo::time_us
int64_t time_us[TIMING_COUNT]
Definition audio_node_stat_i.h:50