cn.tee3.avd_SDK-C++  2.1.0
common.h
浏览该文件的文档.
1 #ifndef RT_COMMON_H
2 #define RT_COMMON_H
3 
4 #include "combase.h"
5 #include <string>
6 #include <vector>
7 #include <sstream>
8 
10 typedef std::string String;
11 typedef String RoomId;
12 typedef String DeviceId;
13 typedef String UserId;
14 typedef String StreamId;
15 typedef DeviceId RecordId;
16 typedef DeviceId LiveId;
22 
24 
30 struct RoomInfo {
49 public:
51  bool isMcu() const { return avd_isFlagSet(roomMode, rm_mcu); }
53  bool isFree() const { return avd_isFlagSet(roomMode, rm_free); }
55  bool isTemperary() const { return avd_isFlagSet(roomMode, rm_temperary); }
60  void setRoomMode(RoomMode flag) {
61  if (avd_isFlagSet(flag, clear_set)) {
62  uint32 dwFlag = flag;
63  avd_clearFlag(dwFlag, clear_set);
64  avd_clearFlag(roomMode, dwFlag);
65  }
66  else {
67  avd_setFlag(roomMode, flag);
68  }
69  }
70 };
74 typedef std::vector<RoomInfo> RoomInfosType;
75 
81 struct Device {
85  Device() :status(tee3::avd::ds_none) {}
87  bool isValid() const { return !id.empty(); }
88  bool operator ==(const Device& right) const { return this->id == right.id; }
89 };
90 
101  CameraCapability() :width(0), height(0), maxFPS(0), rotation(0) {}
102  CameraCapability(uint32 w, uint32 h, uint32 fps) :width(w), height(h), maxFPS(fps), rotation(0) {}
103  CameraCapability(uint32 w, uint32 h, uint32 fps, uint32 rotation) :width(w), height(h), maxFPS(fps), rotation(rotation) {}
105  bool isValid() const { return 0 != width && 0 != height; }
106  bool operator==(const CameraCapability& o) const {
107  return (width == o.width) && (height == o.height) && (maxFPS == o.maxFPS) && (rotation == o.rotation);
108  }
110  if (this != &o) {
111  width = o.width;
112  height = o.height;
113  maxFPS = o.maxFPS;
114  rotation = o.rotation;
115  }
116  return *this;
117  }
118  friend std::ostream& operator <<(std::ostream& ost, const CameraCapability& o) {
119  ost << "cap:[" << "width = " << o.width << ",height = " << o.height << ",maxFPS = " << o.maxFPS << ",rotation = " << o.rotation << "],";
120  return ost;
121  }
122 };
126 struct Speaker : public Device {};
130 typedef std::vector<Speaker> SpeakersType;
134 struct Microphone : public Device {};
138 typedef std::vector<Microphone> MicrophonesType;
139 
143 typedef std::vector<CameraCapability> CapabilitiesType;
144 
151 public:
153  VideoDeviceOptions(uint32 aoptionset);
158  bool hasQuality(VideoQuality value) const;
159  bool hasCapability(CameraCapability cap) const;
163  CapabilitiesType getCapabilities() const;
168  Result setCapabilities(const CapabilitiesType& caps);
169 public:
174  static VideoQuality getQualityByCapability(const CameraCapability& cap);
179  static VideoRatio getRatioByCapability(const CameraCapability& cap);
185  static CameraCapability getDefaultCapability(VideoQuality quality, VideoRatio ratio);
186 public:
187  uint32 optionset; // 位解析:0-1:宽高比例;2-4:视频质量;5-26: high:5-12, normal:13-20, low:21-28;
188 };
189 
196 public:
198  PublishVideoOptions(uint32 aoptionset);
199 public:
204  bool hasQuality(VideoQuality value) const;
208  VideoRatio getRatio() const;
212  void setRatio(VideoRatio value);
216  VideoRotation getRotation() const;
220  void setRotation(VideoRotation value);
221 public: // Stream options
233  Result setStreamOptions(StreamType type, VideoQuality quality, VideoCodec codec = codec_default);
241  Result setStreamOptions(StreamType type, const CameraCapability& cap, VideoCodec codec = codec_default);
243  CameraCapability getStreamCapability(StreamType type) const;
245  VideoQuality getStreamQuality(StreamType type) const;
247  VideoCodec getStreamCodec(StreamType type) const;
249  int getStreamPayload(StreamType type) const;
250 public:
252  bool hasMainStream() const;
254  bool hasAssist1() const;
256  bool hasAssist2() const;
258  void normalize(uint32 deviceOptions);
260  bool isCodecHWSupported(StreamType type) const;
262  bool isCodecSupported(StreamType type) const;
271  StreamType getPrioritySubscribeStream(VideoQuality quality, bool mustQuality) const;
272 public:
273  uint32 optionset; // 位解析:0-1:宽高比例;2-4:缺省视频质量;5-26: 主流 5-12(0-1 编码,2-7 序号),辅流1 13-20,辅流2 20-28;
274 };
275 
281 struct VideoDevice : public Device {
282  VideoDevice() :Device(), level(0) {}
283  int level;
287 public:
289  bool isPublished() const {
290  return ds_published == status || ds_muted == status;
291  }
292 };
296 typedef std::vector<VideoDevice> VideoDevicesType;
297 
301 struct ScreenWindow : public VideoDevice {
303 public:
304  ScreenWindow() :type(tee3::avd::st_unknown) {}
305 };
309 typedef std::vector<ScreenWindow> ScreensType;
310 
316 struct Camera : public VideoDevice {
318 public:
319  Camera() :type(tee3::avd::ct_unknown) {}
320 };
324 typedef std::vector<Camera> CamerasType;
325 
332 struct AudioInfo {
336  typedef std::vector<std::pair<UserId, int> > RemoteUser2LevelType;
337  RemoteUser2LevelType active_streams;
339  AudioInfo() :input_level(0), output_level(0) {}
340  AudioInfo(int il, int ol, const RemoteUser2LevelType& streams)
341  : input_level(il), output_level(ol), active_streams(streams) {}
342 };
343 
349 struct RoomStats : public NetworkStats {
355  RoomStats() :available_receive_bandwidth(0), available_send_bandwidth(0) {}
356  void Clear() {
358  available_receive_bandwidth = 0;
359  available_send_bandwidth = 0;
360  local_address.clear();
361  remote_address.clear();
362  transport_type.clear();
363  }
364 };
365 
371 struct MediaStats : public NetworkStats {
380  MediaStats() :audio_input_level(0), audio_output_level(0)
381  , frame_width(0), frame_height(0), frame_rate(0) {}
382  void Clear() {
384  audio_input_level = 0;
385  audio_output_level = 0;
386  frame_width = 0;
387  frame_height = 0;
388  frame_rate = 0;
389  media_type.clear();
390  codec_name.clear();
391  }
392 };
395 RT_API_EXPORT const String toString(const RoomStats& obj);
396 RT_API_EXPORT const String toString(const MediaStats& obj);
397 
398 //#if defined(RT_DESKTOP)
399 class WindowId {
400 public:
401  // Define WindowT for each platform.
402 #if defined(RT_LINUX) && !defined(RT_ANDROID)
403  typedef Window WindowT;
404 #elif defined(RT_WIN32)
405  typedef HWND WindowT;
406 #elif defined(RT_MAC) && !defined(RT_IOS)
407  typedef CGWindowID WindowT;
408 #else
409  typedef unsigned int WindowT;
410 #endif
411 
412  static WindowId Cast(uint64 id) {
413 #if defined(RT_WIN32)
414  return WindowId(reinterpret_cast<WindowId::WindowT>(id));
415 #else
416  return WindowId(static_cast<WindowId::WindowT>(id));
417 #endif
418  }
419 
420  static uint64 Format(const WindowT& id) {
421 #if defined(RT_WIN32)
422  return static_cast<uint64>(reinterpret_cast<uintptr_t>(id));
423 #else
424  return static_cast<uint64>(id);
425 #endif
426  }
427 
428  WindowId() : id_(0) {}
429  WindowId(const WindowT& id) : id_(id) {} // NOLINT
430  const WindowT& id() const { return id_; }
431  bool IsValid() const { return id_ != 0; }
432  bool Equals(const WindowId& other) const {
433  return id_ == other.id();
434  }
435 
436 private:
437  WindowT id_;
438 };
439 typedef std::vector<WindowId> WindowIds;
440 class DesktopId {
441 public:
442  // Define DesktopT for each platform.
443 #if defined(RT_LINUX) && !defined(RT_ANDROID)
444  typedef Window DesktopT;
445 #elif defined(RT_WIN32)
446  typedef HMONITOR DesktopT;
447 #elif defined(RT_MAC) && !defined(RT_IOS)
448  typedef CGDirectDisplayID DesktopT;
449 #else
450  typedef unsigned int DesktopT;
451 #endif
452 
453  static DesktopId Cast(int id, int index) {
454 #if defined(RT_WIN32)
455  return DesktopId(reinterpret_cast<DesktopId::DesktopT>(id), index);
456 #else
457  return DesktopId(static_cast<DesktopId::DesktopT>(id), index);
458 #endif
459  }
460 
461  DesktopId() : id_(0), index_(-1) {}
462  DesktopId(const DesktopT& id, int index) // NOLINT
463  : id_(id), index_(index) {}
464  const DesktopT& id() const { return id_; }
465  int index() const { return index_; }
466  bool IsValid() const { return index_ != -1; }
467  bool Equals(const DesktopId& other) const {
468  return id_ == other.id() && index_ == other.index();
469  }
470 
471 private:
472  // Id is the platform specific desktop identifier.
473  DesktopT id_;
474  // Index is the desktop index as enumerated by each platform.
475  // Desktop capturer typically takes the index instead of id.
476  int index_;
477 };
478 
479 //#endif
480 
481 //#if defined(RT_ANNOTATION)
497 };
502  line_arrow_end = 1 << 2,
504 };
505 
506 enum ClearType {
510 };
511 //#endif
512 
513 
520 
526 struct AudioParams {
530  AudioParams() :channel(1), sampleRate(44100), bitrate(96000) {}
531  AudioParams(uint32 c, uint32 s, uint32 b) :channel(c), sampleRate(s), bitrate(b) {}
532 
533  friend std::ostream& operator <<(std::ostream& ost, const AudioParams& o) {
534  ost << "audioParams:[" << "channel=" << o.channel << ",sampleRate=" << o.sampleRate << ",bitrate=" << o.bitrate << "],";
535  return ost;
536  }
537 };
538 
540 
541 #endif//RT_COMMON_H
const UserId AVD_userId_allUser
AVD定义的虚假用户Id,用于标识房间中所有用户
VideoDevice()
Definition: common.h:282
void Clear()
Definition: common.h:382
virtual void Clear()
Definition: combase.h:610
CameraType type
摄像头类型
Definition: common.h:317
房间统计信息结构.
Definition: common.h:349
VideoDeviceOptions deviceQualities
视频设备质量类型集:摄像头通知时包含摄像头支持的视频质量集合
Definition: common.h:285
static WindowId Cast(uint64 id)
Definition: common.h:412
uint32 sampleRate
采样率,默认44100
Definition: common.h:528
int frame_rate
视频帧率
Definition: common.h:378
unsigned int WindowT
Definition: common.h:409
mcu模式
Definition: combase.h:203
uint32 roomMode
房间模式集,可选参考RoomMode,缺省为p2p
Definition: common.h:47
DeviceId AnnotationId
直播频道ID类型
Definition: common.h:17
const uint32 AVD_supportedAnnotationTools
视频摄像头信息结构.
Definition: common.h:316
uint32 optionset
Definition: common.h:187
std::vector< WindowId > WindowIds
Definition: common.h:439
static uint64 Format(const WindowT &id)
Definition: common.h:420
int level
应用层对设备设置的数据,可用于表示视频权重等, 应用层开发可用
Definition: common.h:283
DeviceStatus
设备状态.
Definition: combase.h:128
bool operator==(const CameraCapability &o) const
Definition: common.h:106
bool isTemperary() const
判断是临时房间
Definition: common.h:55
StreamType
视频主辅流类型.
Definition: combase.h:180
Definition: common.h:490
int available_send_bandwidth
估计发送带宽
Definition: common.h:351
tee3::String transport_type
传输类型:udp : tcp
Definition: common.h:354
uint32 maxVideo
房间最大视频数限制,即同时打开摄像头数
Definition: common.h:46
语音激励信息结构.
Definition: common.h:332
ScreenWindow()
Definition: common.h:304
String hostPassword
房间主持人密码;长度取Max_Password
Definition: common.h:39
DeviceStatus status
设备状态
Definition: common.h:84
String UserId
用户号类型,唯一标识房间内一个用户,长度不大于Max_UserId定义;由应用层定义传递给AVD SDK,要求保证房间...
Definition: common.h:13
String name
设备名称,应用层可用于设备显示
Definition: common.h:83
std::vector< Camera > CamerasType
视频摄像头集合类型.
Definition: common.h:324
房间信息结构.
Definition: common.h:30
std::vector< Microphone > MicrophonesType
麦克风集合类型.
Definition: common.h:138
bool isValid() const
判断设备是否有效
Definition: common.h:87
#define NAMESPACE_TEE3_AVD_END
Definition: combase.h:117
tee3::String local_address
本地地址
Definition: common.h:352
Definition: common.h:493
视频类设备结构.
Definition: common.h:281
uint32 rotation
视频角度
Definition: common.h:100
int Result
返回值类型
Definition: combase.h:9
屏幕窗口设备信息结构.
Definition: common.h:301
bool isFree() const
判断是自由发言模式房间
Definition: common.h:53
tee3::String media_type
媒体类型:audio : video
Definition: common.h:372
CameraCapability(uint32 w, uint32 h, uint32 fps)
Definition: common.h:102
tee3::String remote_address
远端地址
Definition: common.h:353
bool isPublished() const
判断视频设备是否已处于发布状态
Definition: common.h:289
uint32 width
视频宽度
Definition: common.h:97
const WindowT & id() const
Definition: common.h:430
String DeviceId
设备号类型,唯一标识房间内一个设备,长度不大于Max_DeviceId定义;定义如下:userId+"_"+md5[os.getdeviceid() or os.getsystemid()]
Definition: common.h:12
String description
应用层对设备的描述,应用层开发可用
Definition: common.h:284
int input_level
本地语音输入能量
Definition: common.h:333
#define RT_API_EXPORT
Definition: defines.h:186
MediaStats()
Definition: common.h:380
未知类型
Definition: combase.h:195
媒体统计信息结构.
Definition: common.h:371
const RoomStats g_emptyRoomStats
uint32 duration
房间延续时间,单位是秒
Definition: common.h:42
扬声器信息结构.
Definition: common.h:126
uint32 maxAudio
房间最大音频数限制,即同时打开话筒数
Definition: common.h:45
CameraCapability & operator=(const CameraCapability &o)
Definition: common.h:109
设备打开发布状态
Definition: combase.h:132
tee3::String codec_name
媒体编码名称
Definition: common.h:373
RoomStatus status
Definition: common.h:48
int frame_width
视频宽度
Definition: common.h:376
#define avd_isFlagSet(uValue, mask)
判断uint32的某特定位是否为1
Definition: combase.h:59
unsigned int uint32
Definition: defines.h:391
Device()
Definition: common.h:85
const UserId AVD_userId_allUserWithoutMe
AVD定义的虚假用户Id,用于标识房间中除了自己外的所有用户
VideoCodec
视频编解码器类型.
Definition: combase.h:170
WindowId(const WindowT &id)
Definition: common.h:429
bool Equals(const WindowId &other) const
Definition: common.h:432
AudioParams(uint32 c, uint32 s, uint32 b)
Definition: common.h:531
已经安排好
Definition: combase.h:212
const MediaStats g_emptyMediaStats
std::string String
tee3定义的String类型
Definition: common.h:10
#define NAMESPACE_TEE3_AVD_BEGIN
Definition: combase.h:116
ScreenType type
窗口类型
Definition: common.h:302
CameraType
摄像头类型.
Definition: combase.h:188
Definition: common.h:483
未知类型
Definition: combase.h:189
unsigned int DesktopT
Definition: common.h:450
std::vector< RoomInfo > RoomInfosType
房间信息集合类型.
Definition: common.h:74
unsigned long long uint64
Definition: defines.h:380
自由发言模式
Definition: combase.h:205
Definition: common.h:488
int frame_height
视频高度
Definition: common.h:377
String StreamId
媒体流Id类型,SDK内部使用
Definition: common.h:14
视频发布选项类.
Definition: common.h:195
std::vector< Speaker > SpeakersType
扬声器集合类型.
Definition: common.h:130
ScreenType
Definition: combase.h:194
PublishVideoOptions publishedQualities
视频发布质量类型集:设备发布时包含的发布视频的质量集合
Definition: common.h:286
uint32 optionset
Definition: common.h:273
Definition: common.h:399
RoomStats()
Definition: common.h:355
Definition: common.h:501
Definition: common.h:509
bool isMcu() const
判断是mcu模式房间
Definition: common.h:51
Definition: common.h:507
void setRoomMode(RoomMode flag)
设置房间模式
Definition: common.h:60
设备静默状态
Definition: combase.h:133
RoomStatus
房间状态
Definition: combase.h:211
Definition: common.h:500
AudioParams()
Definition: common.h:530
const DesktopT & id() const
Definition: common.h:464
std::vector< CameraCapability > CapabilitiesType
视频采集集合类型.
Definition: common.h:143
Definition: combase.h:175
Definition: common.h:503
ClearType
Definition: common.h:506
uint32 channel
通道数,默认1
Definition: common.h:527
RoomInfo()
Definition: common.h:31
bool IsValid() const
Definition: common.h:466
String RoomId
房间号类型,唯一标识房间内一个房间,长度不大于Max_RoomId定义;定义如下:[RId_P|T_H|F_P|M_type_guid];...
Definition: common.h:11
bool IsValid() const
Definition: common.h:431
Camera()
Definition: common.h:319
视频设备选项类.
Definition: common.h:150
视频采集信息结构.
Definition: common.h:96
DeviceId RecordId
录制ID类型
Definition: common.h:15
String appRoomId
房间应用层Id,应用层创建房间时设置,应用层可用于标示房间;长度取Max_RoomId
Definition: common.h:35
static DesktopId Cast(int id, int index)
Definition: common.h:453
Definition: common.h:492
Definition: common.h:494
VideoRatio
视频宽高比类型.
Definition: combase.h:151
临时房间模式
Definition: combase.h:207
String confPassword
房间密码,必须与主持人密码不同;长度取Max_Password
Definition: common.h:40
int audio_input_level
音频输入音量
Definition: common.h:374
LineArrowType
Definition: common.h:499
AudioInfo(int il, int ol, const RemoteUser2LevelType &streams)
Definition: common.h:340
uint32 height
视频高度
Definition: common.h:98
std::vector< std::pair< UserId, int > > RemoteUser2LevelType
Definition: common.h:336
Definition: combase.h:202
bool Equals(const DesktopId &other) const
Definition: common.h:467
uint32 startTime
房间起始时间
Definition: common.h:41
麦克风信息结构.
Definition: common.h:134
音频参数结构.
Definition: common.h:526
#define avd_setFlag(uValue, mask)
设置uint32的某特定位为1
Definition: combase.h:65
int audio_output_level
音频输出音量
Definition: common.h:375
Definition: common.h:491
uint32 maxFPS
视频帧率
Definition: common.h:99
String ownerId
房间创建者UserId;长度取Max_UserId
Definition: common.h:37
DesktopId()
Definition: common.h:461
Definition: common.h:508
#define avd_clearFlag(uValue, mask)
清除uint32的某特定位为0
Definition: combase.h:71
设备信息结构.
Definition: common.h:81
无设备状态(如设备被拔出等)
Definition: combase.h:130
uint32 bitrate
编码比特率,默认96kbps
Definition: common.h:529
void Clear()
Definition: common.h:356
网络统计信息结构.
Definition: combase.h:596
CameraCapability VideoParams
视频参数结构.
Definition: common.h:519
AudioInfo()
Definition: common.h:339
std::vector< VideoDevice > VideoDevicesType
视频设备集合类型.
Definition: common.h:296
String roomTopic
房间主题,应用层创建房间时设置
Definition: common.h:36
String hostId
房间主持人UserId;长度取Max_UserId
Definition: common.h:38
String roomName
房间名,应用层创建房间时设置
Definition: common.h:34
Definition: common.h:489
CameraCapability()
Definition: common.h:101
Definition: audiocapture.h:5
AnnotationToolType
Definition: common.h:482
int index() const
Definition: common.h:465
DesktopId(const DesktopT &id, int index)
Definition: common.h:462
int available_receive_bandwidth
估计接收带宽
Definition: common.h:350
std::vector< ScreenWindow > ScreensType
屏幕窗口集合类型.
Definition: common.h:309
Definition: common.h:502
CameraCapability(uint32 w, uint32 h, uint32 fps, uint32 rotation)
Definition: common.h:103
#define NAMESPACE_TEE3_END
Definition: combase.h:115
Definition: common.h:485
RoomMode
房间模式
Definition: combase.h:201
Definition: common.h:496
WindowId()
Definition: common.h:428
RemoteUser2LevelType active_streams
远端用户的语音能量对应表,只包含能量大于0的用户
Definition: common.h:337
const String toString(const RoomStats &obj)
Definition: common.h:487
VideoQuality
视频质量类型.
Definition: combase.h:143
bool isValid() const
判断分辨率是否有效
Definition: common.h:105
Definition: common.h:440
DeviceId LiveId
直播频道ID类型
Definition: common.h:16
VideoRotation
视频角度类型.
Definition: combase.h:160
Definition: common.h:484
int output_level
本地语音输出能量
Definition: common.h:334
Definition: common.h:486
#define NAMESPACE_TEE3_BEGIN
Definition: combase.h:114
DeviceId id
设备Id,唯一标识一个设备;产生规则:音频设备为与用户相关唯一号;视频设备userId+deviceId(MD5(idd) or m...
Definition: common.h:82
RoomId roomId
房间Id,SDK生成,唯一标示一个房间;长度取Max_RoomId
Definition: common.h:33
uint32 bandwidth
房间带宽限制,单位是kps
Definition: common.h:43
Definition: common.h:495
uint32 maxAttendee
房间最大用户数限制
Definition: common.h:44