commit 1769e4193876ce85bc40c063eb4d7419b4575817 Author: wangjiyu Date: Wed Apr 9 10:34:51 2025 +0800 repo init diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/include/IMRTCEngine.hpp b/include/IMRTCEngine.hpp new file mode 100644 index 0000000..b6f699b --- /dev/null +++ b/include/IMRTCEngine.hpp @@ -0,0 +1,872 @@ +/****************************************************************************************************************** +* Copyright(C): 本代码所有版权归MIGU所有 +* @file : IMRTCEngine.hpp +* @brief : MrtcSdk接口 +* @version : 1.8.0 +* @date : 2022/01/19 +******************************************************************************************************************/ + +#ifndef __I_RTC_ENGINE_HPP__ +#define __I_RTC_ENGINE_HPP__ + +#include "MRTCEngineDefine.hpp" + +RTCENGINE_NAMESPACE_BEGIN + +class RTCENGINE_API RTCENGINE_API_CPP IMRTCEngine +{ +public: + DELETE_CTOR_COPY(IMRTCEngine); + /** + * @brief 构造函数 + */ + IMRTCEngine() = default; + + /** + * @brief 析构函数 + */ + virtual ~IMRTCEngine() = default; + +public: + /** + * @brief 引擎初始化函数 + * @param engineConfig 引擎配置结构体 + * @param pCallBack 消息回调指针 + * @return 返回0代表成功 + */ + virtual int16_t init(MRTCEngineConfig& engineConfig, IMRTCMessageCallBack* pCallBack) = 0; + + /** + * @brief 引擎资源销毁 + * @return 返回0代表成功 + */ + virtual int16_t destroy() = 0; + + /** + * @brief 设置用户信息 + * @param userId 用户id + * @param displayName 用户昵称 + * @param roomId 房间id + * @return 返回0代表成功 + */ + virtual int16_t setUserInfo(const char* userId, const char* displayName, const char* roomId) = 0; + + /** + * @brief 注册监听回调 + * @param eType 监听类型 + * @param pFun 回调基函数指针 + * @return 返回0代表成功 + */ + virtual int16_t registerListener(MRTCListenerType eType, IMRTCBaseCallBack* pFun) = 0; + + /** + * @brief 注册视频数据回调 + * @param listenerType 视频回调类型 + * @param dataType 视频数据格式 + * @param userId 视频生产方的用户id + * @param callBack 视频渲染回调指针 + * @param MRTCVideoView* view windows专用 + * @return 返回0代表成功 + */ + virtual int16_t registerVideoListener(MRTCVideoListenerType listenerType, MRTCVideoDataType dataType, const char* userId, IMRTCVideoRenderCallBack* callBack, MRTCVideoView* pView = nullptr) = 0; + + /** + * @brief 注册远端视频编码后数据回调 + * @param roomId 视频生产方的房间Id + * @param userId 视频生产方的用户id + * @param channelIndex 视频生产方的通道id + * @param callBack 视频渲染回调指针 + * @return 返回0代表成功 + */ + virtual int16_t registerRemoteEncodedVideoListener(MRTCVideoListenerType eListenerType, const char* roomId, const char* userId, const int16_t channelIndex, IMRTCRemoteEncodedVideoCallBack* pCallBack) = 0; + + /** + * @brief 注册音频声浪值回调 + * @param audioSourceType 音频类型 + * @param userId 用户id + * @param callBack 音频声浪值回调指针 + * @return 返回0代表成功 + */ + virtual int16_t registerSoundLevelListener(MRTCAudioSourceType audioSourceType, const char* roomId, const char* peerId, const int16_t channelIndex, IMRTCReceivedAudioInfoCallBack* callBack) = 0; + + /** + * @brief 进入房间 + * @param authority 鉴权参数 + * @param loginConfig 加入房间参数 + * @return 返回0代表成功 + */ + virtual int16_t joinRoom(MRTCJoinAuthority& authority, MRTCJoinConfig& loginConfig) = 0; + + /** + * @brief 离开房间 + * @return 返回0代表成功 + */ + virtual int16_t leaveRoom() = 0; + + /** + * @brief 进入房间 + * @param address 房间地址 + * @param port 房间端口 + * @param authority 鉴权参数 + * @param loginConfig 加入房间参数 + * @return 返回0代表成功 + */ + virtual int16_t joinIMRoom(const char* address, const unsigned short port, MRTCJoinAuthority& authority, MRTMJoinConfig& loginConfig, const char* roomId = "") = 0; + + /** + * @brief 离开房间 + * @return 返回0代表成功 + */ + virtual int16_t leaveIMRoom(const char* roomId = "") = 0; + + /** + * @brief 加入多房间 + * @param roomId 加入的房间ID + * @return 返回0代表成功 + */ + virtual int16_t joinMultiRoom(const char* roomId = "") = 0; + + /** + * @brief 离开多房间 + * @param loginConfig 离开的房间ID + * @return 返回0代表成功 + */ + virtual int16_t leaveMultiRoom(const char* roomId = "") = 0; + + /** + * @brief 开启摄像头本地预览 + * @param option 摄像头预览参数 + * @return 返回0代表成功 + */ + virtual int16_t startLocalPreview(const MRTCCameraOption& option) = 0; + + /** + * @brief 关闭摄像头本地预览 + * @return 返回0代表成功 + */ + virtual int16_t stopLocalPreview() = 0; + + /** + * @brief 开始摄像头推流 + * @param option 摄像头推流参数 + * @return 返回0代表成功 + */ + virtual int16_t startPublishing(const MRTCPublishOption& option) = 0; + + /** + * @brief 关闭摄像头推流 + * @return 返回0代表成功 + */ + virtual int16_t stopPublishing() = 0; + + /** + * @brief 开启屏幕分享 + * @param option 屏幕分享参数 + * @return 返回0代表成功 + */ + virtual int16_t startScreenSharing(const MRTCScreenOption& option) = 0; + + /** + * @brief 关闭屏幕分享 + * @return 返回0代表成功 + */ + virtual int16_t stopScreenSharing() = 0; + + /** + * @brief 修改共享流模式 + * @return 返回0代表成功 + */ + virtual int16_t changeVideoStreamMode(MRTCVideoSourceType videoSourceType,MRTCContentHint mode, int channelIndex = 0) = 0; + + /** + * @brief 动态设置视频编码参数 + * @return 返回0代表成功 + */ + virtual int16_t setVideoEncodeConfig(MRTCVideoSourceType videoSourceType, const MRTCVideoEncodeOption& option) = 0; + + /** + * @brief 开启麦克风 + * @param option 音频参数 + * @return 返回0代表成功 + */ + virtual int16_t startMicStreaming(const MRTCAudioOption& option) = 0; + + /** + * @brief 关闭麦克风 + * @return 返回0代表成功 + */ + virtual int16_t stopMicStreaming() = 0; + + /** + * @brief 设置模式(摄像头镜像、前后摄像头、扬声器开/关等) + * @param type 模式类型 + * @return 返回0代表成功 + */ + virtual int16_t setMode(MRTCModeType type) = 0; + + /** + * @brief 暂停/继续消费者或自身摄像头/屏幕分享的视频流 + * @param userId 用户id + * @param videoSourceType 视频类型 + * @param channelIndex 通道编号 + * @param enable 暂停(true)或继续(false) + * @return 返回0代表成功 + */ + virtual int16_t muteVideo(const char* roomId, const char* userId, MRTCVideoSourceType videoSourceType, bool bEnable = false, uint8_t channelIndex = 0) = 0; + + /** + * @brief 暂停/继续消费者或自身摄像头/屏幕分享的音频流 + * @param userId 用户id + * @param audioSourceType 音频类型 + * @param channelIndex 通道编号 + * @param enable 暂停(true)或继续(false) + * @return 返回0代表成功 + */ + virtual int16_t muteAudio(const char* roomId, const char* userId, MRTCAudioSourceType audioSourceType, bool bEnable = false, uint8_t channelIndex = 0) = 0; + + /** + * @brief 设置音效/滤镜插件 + * @param pluginIndex 插件序号,任意大于0的自然数 + * @param type 插件类型 + * @param plugin 插件回调基函数指针 + * @return 返回0代表成功 + */ + virtual int16_t addEffectPlugin(int pluginIndex, MRTCPluginType type, IMRTCEffectPlugin* plugin) = 0; + + /** + * @brief 移除音效/滤镜插件 + * @param pluginIndex 插件序号 + * @return 返回0代表成功 + */ + virtual int16_t removeEffectPlugin(int pluginIndex) = 0; + + /** + * @brief 获取屏幕源/窗口源个数 + * @param type 屏幕分享类型 + * @param count 获取到的个数 + * @return 返回0代表成功 + */ + virtual int16_t getShareSourceCount(MRTCScreenShareType type, uint16_t& count) = 0; + + /** + * @brief 获取屏幕源/窗口源列表 + * @param type 屏幕分享类型 + * @param count 个数 + * @param souceList 屏幕分享列表 + * @return 返回0代表成功 + */ + virtual int16_t getShareSourceList(MRTCScreenShareType type, uint16_t count, MRTCShareSource* souceList) = 0; + + /********************************************************************************************* + * 麦克风/扬声器操作接口 * + ********************************************************************************************/ + /** + * @brief 设置音频输入/音频输出设备 + * @param type 硬件设备类型 + * @param setting 音频设备设置 + * @return 返回0代表成功 + */ + virtual int16_t setAudioDevice(MRTCMediaDeviceType type, MRTCAudioDeviceOption setting) = 0; + + /** + * @brief 设置本地音频的采集音量 + * @param volume 0~100,默认值100;Android、iOS可超过100,超过100的volume会有爆音的风险,请谨慎操作 + * @return 返回0代表成功 + */ + virtual int16_t setAudioCaptureVolume(uint32_t volume) = 0; + + /** + * @brief 获取本地音频的采集音量 + * @param volume 获取到的音量值 + * @return 返回0代表成功 + */ + virtual int16_t getAudioCaptureVolume(uint32_t& volume) = 0; + + /** + * @brief 设置音频的播放音量 + * @param volume 0-100,默认值100;Android、iOS可超过100,超过100的volume会有爆音的风险,请谨慎操作 + * @return 返回0代表成功 + */ + virtual int16_t setAudioPlayoutVolume(uint32_t volume) = 0; + + /** + * @brief 获取音频的播放音量 + * @param volume 获取到的音量值 + * @return 返回0代表成功 + */ + virtual int16_t getAudioPlayoutVolume(uint32_t& volume) = 0; + + /** + * @brief 获取音频播放设备/音频输入设备/摄像头数量(摄像头仅支持Windows) + * @param type 硬件设备类型 + * @param number 获取到的数量值 + * @return 返回0代表成功 + */ + virtual int16_t getDevicesCount(MRTCMediaDeviceType type, uint32_t& number) = 0; + + /** + * @brief 获取音频播放设备/音频输入设备名称 + * @param type 硬件设备类型 + * @param index 设备索引 + * @param name 设备名称列表 + * @param guid 设备id列表 + * @return 返回0代表成功 + */ + virtual int16_t getAudioDeviceName(MRTCMediaDeviceType type, uint16_t index, char name[MAX_DEVICE_NAME_SIZE], char guid[MAX_DEVICE_GUID_SIZE]) = 0; + + + /** + * @brief 获取音频播放设备/音频输入设备选择序号 + * @param type 硬件设备类型 + * @param index 设备索引 + * @return 返回0代表成功 + */ + virtual int16_t getMediaDeviceIndex(MRTCMediaDeviceType type, uint16_t& index) = 0; + + /** + * @brief 获取摄像头设备名称(deviceUniqueId、productUniqueId为UTF8字符串) + * @param index 设备索引 + * @param name 设备名称列表 + * @param deviceUniqueId 设备id列表 + * @param productUniqueId 产品id列表 + * @return 返回0代表成功 + */ + virtual int16_t getCameraDeviceName(uint16_t index, char name[MAX_DEVICE_NAME_SIZE], char deviceUniqueId[MAX_DEVICE_GUID_SIZE], char productUniqueId[MAX_DEVICE_GUID_SIZE]) = 0; + + /** + * @brief 切换扬声器/麦克风/摄像头设备 + * @param type 硬件设备类型 + * @param device 设备名称 + * @param index 设备序号 + * @return 返回0代表成功 + */ + virtual int16_t switchDevice(MRTCMediaDeviceType type, const char* device, int index = -1000) = 0; + + /** + * @brief 设置重连次数或者时间(若maxTimes、maxSeconds都为设置-1,则无限次重连,直到连上) + * @param maxTimes 重连最大次数,-1为不限制次数 + * @param maxSeconds 重连最大秒数,-1为不限制时间 + * @return 返回0代表成功 + */ + virtual int16_t setReConnectLimit(int32_t maxTimes = -1, int32_t maxSeconds = -1) = 0; + + /** + * @brief 设置拉流方式 + * @param roomId 房间id + * @param userId 用户id + * @param sourceType 视频类型 + * @param type 视频流类型 + * @param channelIndex 流通道 + * @return 返回0代表成功 + */ + virtual int16_t setPlayVideoStreamType(const char* roomId, const char* userId, MRTCVideoSourceType eSourceType, MRTCVideoStreamType eType , uint8_t channelIndex) = 0; + + /********************************************************************************************* + * 视频分享接口 * + ********************************************************************************************/ + /** + * @brief 注册视频分享进度回调 + * @param callBack 视频分享进度回调指针 + * @return 返回0代表成功 + */ + virtual int16_t registerVideoCallBack(IMRTCVideoProcessCallBack* callBack) = 0; + + /** + * @brief 启动分享视频 + * @param option 视频文件分享参数 + * @param path 视频文件路径 + * @param loop 是否循环播放 + * @return 返回0代表成功 + */ + virtual int16_t startPlayVideo(const MRTCVideoFileOption& option, const char* path, bool loop = true) = 0; + + /** + * @brief 停止分享视频 + * @return 返回0代表成功 + */ + virtual int16_t stopPlayVideo() = 0; + + /** + * @brief 暂停播放视频文件 + * @return 返回0代表成功 + */ + virtual int16_t pausePlayVideo() = 0; + + /** + * @brief 继续播放视频文件 + * @return 返回0代表成功 + */ + virtual int16_t resumePlayVideo() = 0; + + /** + * @brief 获取视频文件总时长,单位毫秒 + * @param path 视频文件路径 + * @param duration 获取到的文件时长 + * @return 返回0代表成功 + */ + virtual int16_t getVideoDurationInMS(const char* path, uint32_t& duration) = 0; + + /** + * @brief 设置视频播放进度 + * @param pos 播放位置 + * @return 返回0代表成功 + */ + virtual int16_t seekVideoToPosInMS(uint32_t pos) = 0; + + /** + * @brief 设置视频播放的音量 + * @param volume 0~100 + * @return 返回0代表成功 + */ + virtual int16_t setVideoPlayoutVolume(int16_t volume) = 0; + + /** + * @brief 设置视频远端播放音量 + * @param volume 0~100 + * @return 返回0代表成功 + */ + virtual int16_t setVideoPublishVolume(int16_t volume) = 0; + + +/************************************************************************************************* + * + * 以下接口Windows平台暂不可用 * + * + *************************************************************************************************/ +//#ifndef WIN32 + /** + * @brief 开启音频共享 + * @param option 音频参数 + * @return 返回0代表成功 + */ + virtual int16_t startShareAudioStreaming(const MRTCAudioOption& option) = 0; + + /** + * @brief 关闭音频共享 + * @return 返回0代表成功 + */ + virtual int16_t stopShareAudioStreaming() = 0; + + /** + * @brief 开启耳返功能 + * @param enable 开启(true)或关闭(false) + * @return 返回0代表成功 + */ + virtual int16_t setInearMonitoring(bool enable) = 0; + + /** + * @brief 设置耳返音量 + * @param volume 0~100 + * @return 返回0代表成功 + */ + virtual int16_t setInEarMonitoringVolume(int16_t volume) = 0; + + + /********************************************************************************************* + * 背景音乐操作接口 * + ********************************************************************************************/ + /** + * @brief 注册背景音乐进度回调 + * @param callBack 背景音乐进度回调函数指针 + * @return 返回0代表成功 + */ + virtual int16_t registerMusicCallBack(IMRTCMusicProcessCallBack* callBack) = 0; + + /** + * @brief 启动播放背景音乐 + * @param path 背景音乐路径 + * @param loop 是否循环播放 + * @return 返回0代表成功 + */ + virtual int16_t startPlayMusic(const char* path, bool loop = true) = 0; + /** + * @brief 停止播放背景音乐 + * @return 返回0代表成功 + */ + virtual int16_t stopPlayMusic() = 0; + /** + * @brief 暂停播放背景音乐 + * @return 返回0代表成功 + */ + virtual int16_t pausePlayMusic() = 0; + + /** + * @brief 继续播放背景音乐 + * @return 返回0代表成功 + */ + virtual int16_t resumePlayMusic() = 0; + + /** + * @brief 获取音乐文件总时长,单位毫秒 + * @param path 音乐文件路径 + * @param duration 获取到的时长 + * @return 返回0代表成功 + */ + virtual int16_t getMusicDurationInMS(const char* path, uint32_t& duration) = 0; + + /** + * @brief 设置音乐播放进度 + * @param pos 播放位置 + * @return 返回0代表成功 + */ + virtual int16_t seekMusicToPosInMS(uint32_t pos) = 0; + /** + * @brief 设置音乐播放的音量 + * @param volume 0~100 + * @return 返回0代表成功 + */ + virtual int16_t setMusicPlayoutVolume(int16_t volume) = 0; + /** + * @brief 设置音乐远端播放音量 + * @param volume 0~100 + * @return 返回0代表成功 + */ + virtual int16_t setMusicPublishVolume(int16_t volume) = 0; + + + /********************************************************************************************* + * 自定义视频接口 * + ********************************************************************************************/ + /** + * @brief 开启自定义视频 + * @param option 自定义视频流参数 + * @return 返回0代表成功 + */ + virtual int16_t StartCustomVideo(const MRTCCustomVideoOption& option) = 0; + + /** + * @brief 关闭摄像头推流 + * @return 返回0代表成功 + */ + virtual int16_t stopCustomVideo() = 0; + + /** + * @brief 发送自定义视频数据 + * @param frame 视频帧数据 + * @return 返回0代表成功 + */ + virtual int16_t sendCustomVideoData(const MRTCVideoFrame& frame) = 0; + + // + // 开启多路自定义视频 + // + virtual int16_t StartCustomVideo(const MRTCCustomVideoOption& objOption,MRTCPublishChannel channel) = 0; + + // + // 关闭指定某通道推流 + // + virtual int16_t stopCustomVideo(MRTCPublishChannel channel) = 0; + + // + // 指定发送多路自定义视频数据 + // + virtual int16_t sendCustomVideoData(const MRTCVideoFrame& objFrame,MRTCPublishChannel channel) = 0; + + + /********************************************************************************************* + * 自定义音频接口 * + ********************************************************************************************/ + /** + * @brief 开启自定义音频 + * @param option 音频参数 + * @return 返回0代表成功 + */ + virtual int16_t startCustomAudio(const MRTCAudioOption& option) = 0; + + /** + * @brief 关闭自定义音频 + * @param channeIndex 通道 + * @return 返回0代表成功 + */ + virtual int16_t stopCustomAudio(uint8_t channelIndex = 0) = 0; + + /** + * @brief 发送自定义音频数据 + * @param channeIndex 通道 + * @param data 音频数据,默认采用16bit的位深进行采样 + * @param sampleRate 采样率 + * @param numberOfChannels 通道数 + * @param dataLength 数据长度 + * @return 返回0代表成功 + */ + virtual int16_t sendCustomAudioData(uint8_t channelIndex = 0, const void* pData = nullptr, int32_t nSampleRate = 48000, uint64_t nNumberOfChannels = 2, uint64_t dataLength = 0) = 0; + + /** + * @brief 发送自定义AAC音频数据 + * @param channeIndex 通道 + * @param data AAC音频数据 + * @param dataLength 数据长度 + * @param sampleRate 采样率 + * @param channels 通道数 + * @return 返回0代表成功 + */ + virtual int16_t sendCustomAudioAACData(uint8_t channelIndex = 0, const unsigned char* pData = nullptr, unsigned int nDataLength = 0, uint32_t sampleRate = 48000, uint32_t channels = 2) = 0; + + /** + * @brief 设置自定义音频推流音量 + * @param volume 0~100 + * @return 返回0代表成功 + */ + virtual int16_t setCustomAudioPublishVolume(int16_t volume) = 0; + + /********************************************************************************************* + * 自定义裸视频流接口 * + ********************************************************************************************/ + /** + * @brief 开启自定义裸视频 + * @param option 自定义裸视频流参数 + * @return 返回0代表成功 + */ + virtual int16_t startCustomRawVideo(const MRTCCustomRawVideoOption& option) = 0; + + /** + * @brief 关闭自定义裸视频推流 + * @return 返回0代表成功 + */ + virtual int16_t stopCustomRawVideo(uint8_t channelIndex = 0) = 0; + + /** + * @brief 发送自定义裸视频数据 + * @param + * @return 返回0代表成功 + */ + virtual int16_t sendCustomRawVideoData(const MRTCRawVideoFrame& frame) = 0; + + /** + * @brief 切换用户角色 + * @inparam role 角色 + * @return 返回0代表成功 + */ + virtual int16_t switchClientRole(const MRTCClientRole& role) = 0; + + /** + * @brief 获取房间总人数 + * @outparam nCount + * @return 返回0代表成功 + */ + virtual int16_t getUserCount(int32_t& nCount) = 0; + + /** + * @brief 分页获取房间用户列表 + * @outparam peerList 人员列表 + * @outparam nCount 个数 + * @inparam page 页数 默认 0 + * @inparam limit 每页人数限制 0-100 默认 10 + * @return 返回0代表成功 + */ + virtual int16_t getRoomUsers(MRTCRoomUserInfo* peerList, int32_t& nCount, const int32_t page = 0, const int32_t limit = 10) = 0; + + /** + * @brief 分页获取房间用户列表 + * @outparam peerList 人员列表 + * @outparam nCount 个数 + * @inparam page 页数 默认 0 + * @inparam limit 每页人数限制 0-100 默认 10 + * @return 返回0代表成功 + */ + virtual int16_t getRTMRoomUsers(MRTMRoomUserInfo* peerList, int32_t& nCount, const char* roomId, const int32_t page = 0, const int32_t limit = 10) = 0; + + +//#endif + + +/************************************************************************************************* + * + * 以下是其他平台特性接口 * + * + *************************************************************************************************/ + + /** + * @brief 同步网络状态 + */ + virtual void synNetworkStaus(bool enable, const char* networkType) = 0; + + /** + * @brief 开始播放设备 + */ + virtual int16_t StartPlayout() = 0; + + /** + * @brief 停止播放设备 + */ + virtual int16_t StopPlayout()= 0; + +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) + // + // 设置使用通话、媒体 + // + virtual int16_t setUseMedia(bool bPlayoutUseMedia, bool bRecordUseMedia) = 0; +#endif + // + // 安卓音视频启动、采集错误上报 + // + virtual void getWebrtcVideoAndAudioDeviceError(int16_t sourceType, const char * errorMsg) = 0; + + + // + // 设置混流推流 + // + virtual int16_t startLiveStreaming(MRTCLiveStreamingInfo& liveStreamingInfo, + MRTCPublishAndMixEncoding& encoding, + std::vector userList) = 0; + + // + // 更新混流推流 + // + virtual int16_t updateLiveStreaming(std::vector userList, + MRTCLiveStreamMode mode) = 0; + // + // 停止混流推流 + // + virtual int16_t stopLiveStreaming() = 0; + + // + // 发送自定义消息 + // + virtual int16_t sendCustomMessage(const char* roomid, const char* peerid,std::vector m_Peers,const char* content) = 0; + + // + // 设置硬编码 + // + virtual int16_t requireHardwareEncoder(bool enable = true) = 0; + + // + // 设置硬解码 + // + virtual int16_t requireHardwareDecoder(bool enable = true) = 0; + + // + // 设置是否打开丢帧 + // + virtual int16_t setEnableIgnoreFrame(bool enable = true) = 0; + + // + // 根据StreamID 调整音量 + // + virtual int16_t SetPlayVolume(const std::string peerId, const std::string dataType, int16_t audioSourceType, int16_t videoSourceType, int16_t volume) = 0; + + // + // 上传Dump文件 + // + virtual int16_t uploadDump(const char*& errorMessage) = 0; + + virtual int16_t setVerbose(bool on) = 0; + + // + // 开启自定义数据传输 + // + virtual int16_t StartCustomData(const char* customParam) = 0; + + // + // 关闭自定义数据传输 + // + virtual int16_t StopCustomData() = 0; + + // + // 发送自定义数据 + // + virtual int16_t SendCustomData(const MRTCCustomDataObject &object) = 0; + + // + // 设置特定某路视频流超分的开关 + // + virtual int16_t EnableSuperResolution(MRTCSuperResolutionOption& srOption) = 0; + + // + // 开启H265编码,接口已废弃 + // + virtual int16_t EnableH265(bool enable) = 0; + + // 开启安全模式,限制某些特性 + virtual void EnterMRTCSafeMode(MRTCSafeMode safeMode,bool isEnable) = 0; + + // 外部创建混音能力 + virtual void enableAudioMixCapablity(bool enable,int audioSampleRate, int audioChannel) = 0; + + // 外部发送混音音频数据 + virtual int16_t sendAudioMixData(const int16_t* audioData, int32_t dataLength, int32_t audioVolume) = 0; + + // 设置关键帧间隔 + virtual int16_t setVideoKeyFrameInterval(int interval) = 0; + + // 设置音频信息回调间隔 + virtual int16_t setAudioInfoInterval(int interval) = 0; + + // 设置质量回调间隔 + virtual int16_t setQualityInterval(int interval) = 0; + + // 设置Vad开关 + virtual int16_t enabelVad(bool enable) = 0; + + // 设置mic静音 + virtual int16_t SetMicMute(bool bMute) = 0; + + // 获取Mic是否静音 + virtual bool IsMicMuted() = 0; + + // 获取SDK能力清单 + virtual const char* SDKCapability() = 0; + + // 获取摄像头能力 pCamList传入最大10数组指针 + virtual int16_t getCameraCapabilities(MRTCCameraCapabilities* pCamList, int& nCount) = 0; + +// 这里是兼容处理,正常情况这个宏是预编译就定义好的 +// 防止某个平台未定义,定义默认值为使用异步 +#ifndef API_SYNC +#define API_SYNC 0 +#endif +// static void setUseSyncApi(bool enable) { +//// 这个方法只能这么写,否则define会报警告,有可能执行错误 +//// 需要重新定义API_SYNC 的值 +// if (enable){ +//#ifdef API_SYNC +//#undef API_SYNC +//#endif +//#define API_SYNC 1 +// SL_LOG_DEBUG2("Engine::setUseSyncApi", "Use sync api."); +// } else { +//#ifdef API_SYNC +//#undef API_SYNC +//#endif +//#define API_SYNC 0 +// SL_LOG_DEBUG2("Engine::setUseSyncApi", "Use async api."); +// } +// } +}; + +/** + * @brief 获取SDK版本H265H26 + */ +RTCENGINE_API const char* getSDKVersion(); + +/** + * @brief 获取Git版本 + */ +RTCENGINE_API const char* getGitVersion(); + +/** + * @brief 获取编译时间 + */ +RTCENGINE_API const char* getBuildTime(); + +/** + * @brief 上传日志 + */ +RTCENGINE_API int16_t uploadLog(const char* applicationId, const char* userId, const char* userName, const char*& errorMessage); + +/** + * @brief 设置日志路径 + */ +RTCENGINE_API void setSDKLogDirectory(const char* logDirectory); + + +#ifdef __ANDROID__ + RTCENGINE_API void InitJavaVM(jobject context, jobject activity); + RTCENGINE_API void UnInitJavaVM(); + RTCENGINE_API void* GetPCClient(); + RTCENGINE_API void RequestScreenShare(IMRTCRequestCallBack* callbak); +#endif + +RTCENGINE_NAMESPACE_END + +#endif //__I_RTC_ENGINE_HPP__ diff --git a/include/IMRTCEngineFactory.hpp b/include/IMRTCEngineFactory.hpp new file mode 100644 index 0000000..8081d7b --- /dev/null +++ b/include/IMRTCEngineFactory.hpp @@ -0,0 +1,45 @@ +#ifndef __I_RTC_ENGINE_FACTORY_HPP__ +#define __I_RTC_ENGINE_FACTORY_HPP__ + +#include "IMRTCEngine.hpp" + +RTCENGINE_NAMESPACE_BEGIN + +class RTCENGINE_API IMRTCEngineFactory +{ +public: + DELETE_CTOR_COPY(IMRTCEngineFactory); + // + // Constructor. + // + IMRTCEngineFactory() = default; + + // + // Destructor. + // + virtual ~IMRTCEngineFactory() = default; + +public: + // + // Create MRTCEngine. + // + virtual IMRTCEngine* produceMRTCEngine() = 0; + + // + // Release MRTCEngine. + // + virtual void releaseMRTCEngine() = 0; +}; + +// +// Get MRTCEngine Factory. +// +RTCENGINE_API IMRTCEngineFactory* getMRTCEngineFactory(); + +// +// Relase MRTCEngine Factory. +// +RTCENGINE_API void releaseMRTCEngineFactory(IMRTCEngineFactory*& factory); + +RTCENGINE_NAMESPACE_END +#endif \ No newline at end of file diff --git a/include/MRTCEngineDefine.hpp b/include/MRTCEngineDefine.hpp new file mode 100644 index 0000000..6cf2c28 --- /dev/null +++ b/include/MRTCEngineDefine.hpp @@ -0,0 +1,2356 @@ +#ifndef __RTC_ENGINE_DEFINE_HPP___ +#define __RTC_ENGINE_DEFINE_HPP___ + +#include +#include +#ifdef WIN32 +#include "MRTCEnginePlatForm.hpp" +#endif +#include +#include +#include + +// namespace +////////////////////////////////////////////////////////////////////////// +#define RTCENGINE_NAMESPACE_BEGIN namespace mrtc { +#define RTCENGINE_NAMESPACE mrtc +#define RTCENGINE_NAMESPACE_END } + +// macro WIN32 +////////////////////////////////////////////////////////////////////////// +#ifdef WIN32 +#ifdef RTCENGINE_DLL +#ifdef RTCENGINE_EXPORTS +#define RTCENGINE_API __declspec(dllexport) +#define RTCENGINE_API_CPP +#else +#define RTCENGINE_API __declspec(dllimport) +#define RTCENGINE_API_CPP +#endif +#else +#define RTCENGINE_API +#define RTCENGINE_API_CPP +#endif +#elif defined(__ANDROID__) +#define RTCENGINE_API +#define RTCENGINE_API_CPP __attribute__ ((visibility ("default"))) +#else +#define RTCENGINE_API +#define RTCENGINE_API_CPP +#endif + +// Macos Or IOS. +////////////////////////////////////////////////////////////////////////// +#ifdef __APPLE__ +#include +#include +#if TARGET_OS_OSX +/// 单元测试现在仅mac可用 +#define MRTC_TEST_ABILITY_AVAILABLE 1 +#endif +#ifdef __OBJC__ +using PixelBufferRef = CVPixelBufferRef; +#else +using PixelBufferRef = void*; +#endif + +#endif //__APPLE__ + +// Disable copy funciton. +#ifndef DELETE_CTOR_COPY +#define DELETE_CTOR_COPY(className) \ + className(const className &) = delete; \ + className &operator=(const className &) = delete +#endif + +// Disable constructor and copy function. +#ifndef DELETE_COPY +#define DELETE_COPY(className) \ + className() = default; \ + DELETE_CTOR_COPY(className) +#endif + +#ifdef WIN32 +#define INLINE __forceinline +#else +#define INLINE inline +#endif + +#if defined(__ANDROID__) +#include "jni.h" +#endif +RTCENGINE_NAMESPACE_BEGIN + +// 回调基函数 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCBaseCallBack +{ +public: + virtual ~IMRTCBaseCallBack() = default; +}; + +struct MRTCCustomDataObject final +{ + std::string peerId; + uint8_t* data = nullptr; + size_t data_length = 0; + uint64_t delay_time = 0; +}; + +// 消息回调 引擎异步消息通知 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCMessageCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCMessageCallBack); + virtual ~IMRTCMessageCallBack() override = default; + virtual void onCallBackMessage(uint32_t msgId, const char* msg) = 0; + virtual void onCallBackCustomData(MRTCCustomDataObject object) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP IMRTCCallBackMessageNULL final : public IMRTCMessageCallBack +{ +public: + DELETE_COPY(IMRTCCallBackMessageNULL); + virtual void onCallBackMessage(uint32_t msgId, const char* mssg) override + { + } + virtual void onCallBackCustomData(MRTCCustomDataObject object) override { + + } +}; + +// 监听类型 +enum MRTCListenerType +{ + TYPE_LISTENER_ROOM = 0x00, // 房间状态 + TYPE_LISTENER_PRODUCER = 0x01, // 生产者状态 + TYPE_LISTENER_CONSUMER = 0x02, // 消费者状态 + TYPE_LISTENER_DATA_PRODUCER = 0x03, // 数据生产者状态 + TYPE_LISTENER_DATA_CONSUMER = 0x04, // 数据消费者状态 + + TYPE_LISTENER_REPORT_MONITOR = 0x05, // 报告监控回调消息 + TYPE_LISTENER_DEVICE_MONITOR = 0x06, // 设备变动回调消息 + TYPE_LISTENER_REPORT_STATISTICS = 0x07, // 回调音视频质量数据 + TYPE_LISTENER_RTM_ROOM = 0x08, // RTM 房间状态 + TYPE_LISTENER_REPORT_NETWORKING_STATUS = 0x09, // 回调网络状态 +}; + +// 视频回调类型 +enum MRTCVideoListenerType +{ + TYPE_CAMERA_PRODUCER = 0x00, // 摄像头生产者 + TYPE_SCREEN_PRODUCER, // 屏幕分享生产者 + TYPE_CAMERA_CONSUMER, // 摄像头消费者 + TYPE_SCREEN_CONSUMER, // 屏幕分享消费者 + TYPE_FILE_VIDEO_PRODUCER, // 视频分享的视频生产者 + TYPE_FILE_VIDEO_CONSUMER, // 视频分享的视频消费者 + TYPE_CUSTOM_VIDEO_PRODUCER, // 自定义视频生产者 + TYPE_CUSTOM_VIDEO_CONSUMER, // 自定义视频消费者 + TYPE_CUSTOM_SECOND_VIDEO_PRODUCER, // 自定义第二路视频生产者 + TYPE_CUSTOM_SECOND_VIDEO_CONSUMER, // 自定义第二路视频消费者 + TYPE_CUSTOM_RAW_VIDEO_CONSUMER, // 自定义编码后视频消费者 +}; + +// 视频数据格式 +enum MRTCVideoDataType +{ + TYPE_VIDEO_I420, + TYPE_VIDEO_ARGB, +}; + +enum MRTCVideoEncodedCodecType +{ + TYPE_VIDEO_H264, + TYPE_VIDEO_H265 +}; + +// 视频裸数据格式 +enum MRTCVideoRawDataType +{ + TYPE_VIDEO_RAW_H264, + TYPE_VIDEO_RAW_H265, +}; + +enum MRTCVideoEncodedFrameType +{ + TYPE_VIDEO_FRAME_I, + TYPE_VIDEO_FRAME_P, + TYPE_VIDEO_FRAME_B +}; + +// 视频类型 +enum MRTCVideoSourceType +{ + TYPE_VIDEO_SOURCE_NONE = 0x00, + TYPE_VIDEO_SOURCE_CAMERA = 0x01, // 摄像头 + TYPE_VIDEO_SOURCE_SCREEN = 0x02, // 屏幕分享 + TYPE_VIDEO_SOURCE_VIDEO = 0x03, // 视频文件 + TYPE_VIDEO_SOURCE_CUSTOM = 0x04, // 外部传入视频 + TYPE_VIDEO_SOURCE_CUSTOM_SECOND = 0x05, // 外部传入第二路视频 + TYPE_VIDEO_SOURCE_RAW = 0x06, // 外部传入裸视频流 +}; + +// 音频类型 +enum MRTCAudioSourceType +{ + TYPE_AUDIO_SOURCE_NONE = 0x00, + TYPE_AUDIO_SOURCE_MIC = 0x01, // 麦克风 + TYPE_AUDIO_SOURCE_DESKTOP = 0x02, // 桌面音频 + TYPE_AUDIO_SOURCE_MUSIC = 0x03, // 背景音乐 + TYPE_AUDIO_SOURCE_VIDEO = 0x04, // 视频分享 + TYPE_AUDIO_SOURCE_EFFECT = 0x05, // 音频特效 + TYPE_AUDIO_SOURCE_CUSTOM = 0x06, // 外部传入音频 + TYPE_AUDIO_SOURCE_CUSTOM_DATA = 0x07, // dataChannel通道传入音频数据 +}; + + +// 自定义视频通道id +enum MRTCPublishChannel { + MRTCPublishChannelOne = 0x00, + MRTCPublishChannelTwo = 0x01, +}; + +// 视频流类型 +enum MRTCVideoStreamType +{ + TYPE_VIDEO_STREAM_DEFAULT = 0x00, // 默认自适应 + TYPE_VIDEO_STREAM_SMALL = 0x01, // 小流 + TYPE_VIDEO_STREAM_BIG = 0x02, // 大流 +}; + +struct MRTCRoomStatus final +{ + DELETE_COPY(MRTCRoomStatus); + char reason[256] = { 0 }; +}; + +// 房间回调类型 +enum MRTCRoomStatusType +{ + TYPE_STATUS_ROOM_JOIN = 0x00, // 进入房间 + TYPE_STATUS_ROOM_LEAVE = 0x01, // 离开房间 + + TYPE_STATUS_ROOM_RECONNECT_BEGIN = 0x02,// 重连开始 + TYPE_STATUS_ROOM_RECONNECT_END = 0x03, // 重连结束 + TYPE_STATUS_ROOM_RECONNECT_FAILED = 0x04,// 重连失败 + + TYPE_STATUS_ROOM_CLEAR_USER_LIST = 0x05,// 清理房间用户列表 和 视频窗口 + TYPE_EVENT_ROOM_JOIN_FAILED = 0x06, // 加入房间失败 + + TYPE_STATUS_ROOM_REJOIN_CONNECT_BEGIN = 0x07,// ReJoin重连开始 + TYPE_STATUS_ROOM_REJOIN_CONNECT_END = 0x08, // ReJoin重连结束 + TYPE_STATUS_ROOM_REJOIN_CONNECT_FAILED = 0x09,// ReJoin重连失败 + + TYPE_STATUS_ROOM_CLOSE_CONFIRM = 0x0A, // 房间关闭 + TYPE_STATUS_ROOM_USER_KICKED_OUT = 0x0B, // 用户被踢 + TYPE_STATUS_ROOM_PEER_LIST = 0x0C, // 加入房间时,房间内已有有用户列表 + +}; +// 房间回调类型 +enum MRTMRoomStatusType +{ + TYPE_STATUS_RTM_ROOM_JOIN = 0x00, // 进入房间 + TYPE_STATUS_RTM_ROOM_LEAVE = 0x01, // 离开房间 + + TYPE_STATUS_RTM_ROOM_RECONNECT_BEGIN = 0x02,// 重连开始 + TYPE_STATUS_RTM_ROOM_RECONNECT_END = 0x03, // 重连结束 + TYPE_STATUS_RTM_ROOM_RECONNECT_FAILED = 0x04,// 重连失败 + + TYPE_STATUS_RTM_ROOM_CLEAR_USER_LIST = 0x05,// 清理房间用户列表 和 视频窗口 + TYPE_EVENT_RTM_ROOM_JOIN_FAILED = 0x06, // 加入房间失败 + + TYPE_STATUS_RTM_ROOM_REJOIN_CONNECT_BEGIN = 0x07,// ReJoin重连开始 + TYPE_STATUS_RTM_ROOM_REJOIN_CONNECT_END = 0x08, // ReJoin重连结束 + TYPE_STATUS_RTM_ROOM_REJOIN_CONNECT_FAILED = 0x09,// ReJoin重连失败 + + TYPE_STATUS_RTM_ROOM_CLOSE_CONFIRM = 0x0A, // 房间关闭 + + TYPE_ROOM_USER_LIST_RESULT = 0x0B, // 用户列表 +}; + +// 消费者回调类型 +enum MRTCConsumerStatusType +{ + // Consumer Start Or Stop + TYPE_STATUS_CONSUMER_START = 0x00, // 消费者开始 若是视频Consumer此处需注册视频显示回调窗口 + TYPE_STATUS_CONSUMER_STOP, // 消费者停止 + TYPE_STATUS_CONSUMER_PAUSE, // 消费者暂停状态 + TYPE_STATUS_CONSUMER_RESUME, // 消费者继续状态 + TYPE_STATUS_CONSUMER_LAYERS_CHANGE, // 消费者分层信息改变 + TYPE_STATUS_CONSUMER_SCORE, // 消费者视频得分 + TYPE_STATUS_CONSUMER_ACTIVE_SPEAKER, // 消费者麦克强度信息 + + // Data Consumer Start Or Stop + TYPE_STATUS_DATA_CONSUMER_START, // 数据消费者开启 + TYPE_STATUS_DATA_CONSUEMR_STOP, // 数据消费者关闭 + + // User Join Or Leave + TYPE_STATUS_USER_JOIN, // 用户加入房间 + TYPE_STATUS_USER_LEAVE, // 用户离开房间 + TYPE_STATUS_USER_DISPLAYNAME_CHAGE, // DisplayName改变 +}; + +// 生产者回调类型 +enum MRTCProducerStatusType +{ + TYPE_PRODUCER_STATUS_SCORE, // 生产者视频得分 + TYPE_PRODUCER_STATUS_SUCCESS, // 生产者开启成功 + TYPE_PRODUCER_STATUS_FAILURE, // 生产者开启失败 + TYPE_PRODUCER_STATUS_FORBIDDEN, // 生产者被禁止 + TYPE_PRODUCER_STATUS_RESUMED, // 生产者被回复 +}; + +// 设备监控类型 +enum MRTCDeviceMonitorType +{ + TYPE_DEVICE_AUDIO_CAPTURE_CHANGED, // 音频采集设备状态改变 + TYPE_DEVICE_AUDIO_RENDER_CHANGED, // 音频播放设备状态改变 + TYPE_DEVICE_AUDIO_CAPTURE_ADD, // 音频采集设备新增 + TYPE_DEVICE_AUDIO_CAPTURE_REMOVE, // 音频采集设备移除 + TYPE_DEVICE_AUDIO_RENDER_ADD, // 音频播放设备新增 + TYPE_DEVICE_AUDIO_RENDER_REMOVE, // 音频播放设备移除 + TYPE_DEVICE_VIDEO_CAPTURE_CHANGED, // 视频设备状态改变 + TYPE_DEVICE_VIDEO_CAPTURE_ADD, // 视频采集设备新增 + TYPE_DEVICE_VIDEO_CAPTURE_REMOVE, // 视频采集设备移除 +}; + +// 房间用户回调信息 +struct MRTCRoomUserInfo final +{ + //DELETE_COPY(MRTCRoomUserInfo); + char deviceFlag[256] = { 0 }; + char deviceName[256] = { 0 }; + char deviceVersion[256] = { 0 }; + char displayName[256] = { 0 }; + char userId[256] = { 0 }; + char roomId[256] = { 0 }; +}; + +struct MRTCRoomInfo final { + char roomId[256] = { 0 }; + char displayName[256] = { 0 }; + char userId[256] = { 0 }; + // 加入类型会有此参数值 + std::vector userInfo; + // 部分接口可能会有值 + char message[256] = { 0 }; +}; + +// 房间用户回调信息 +struct MRTMRoomUserInfo final +{ + //DELETE_COPY(MRTCRoomUserInfo); + char displayName[256] = { 0 }; + char userId[256] = { 0 }; +}; + +struct MRTMRoomInfo final { + char roomId[256] = { 0 }; + // 部分接口可能会有值 + char reason[256] = { 0 }; + char displayName[256] = { 0 }; + char userId[256] = { 0 }; +}; + +// 用户角色 +enum MRTCClientRole +{ + TYPE_CLIENT_ROLE_ANCHOR, // 主播 + TYPE_CLIENT_ROLE_AUDIENCE, // 观众 +}; + +// 房间状态 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCRoomCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCRoomCallBack); + virtual ~IMRTCRoomCallBack() override = default; + virtual void onRoom(uint32_t typeId, MRTCRoomInfo& roomInfo) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP MRTCRoomNULLCallBack final : public IMRTCRoomCallBack +{ +public: + DELETE_COPY(MRTCRoomNULLCallBack); + void onRoom(uint32_t typeId, MRTCRoomInfo& roomInfo) override + { + } +}; + +// RTM 房间状态 +class RTCENGINE_API RTCENGINE_API_CPP IMRTMRoomCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTMRoomCallBack); + virtual ~IMRTMRoomCallBack() override = default; + virtual void onRTMRoom(uint32_t typeId, MRTMRoomInfo& roomInfo) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP MRTMRoomNULLCallBack final : public IMRTMRoomCallBack +{ +public: + DELETE_COPY(MRTMRoomNULLCallBack); + void onRTMRoom(uint32_t typeId, MRTMRoomInfo& roomInfo) override + { + } +}; + +// Producer Score +struct MRTCScoreData final +{ +// DELETE_COPY(MRTCScoreData); + char rId[20] = { 0 }; + int8_t score = 0; + int32_t ssrc = 0; +}; + +// TYPE_PRODUCER_STATUS_SCORE +struct MRTCProducerScore final +{ +// DELETE_COPY(MRTCProducerScore); + size_t arrayLen = 0; + std::unique_ptr scoreData{ nullptr }; +}; + +// Producer回调数据结构 +//TYPE_STATUS_PRODUCER_INFO +struct MRTCProducerInfo final +{ +// DELETE_COPY(MRTCProducerInfo); + char producerId[256] = { 0 }; + char kind[50] = { 0 }; + char peerId[256] = { 0 }; + MRTCAudioSourceType audioSourceType = TYPE_AUDIO_SOURCE_NONE; + MRTCVideoSourceType videoSourceType = TYPE_VIDEO_SOURCE_NONE; + + // 某个生产者视频得分 + MRTCProducerScore score; + uint8_t channelIndex = 0; + char roomId[256] = { 0 }; + char streamId[256] = { 0 }; +}; + // 生产者状态回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCProduerCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCProduerCallBack); + virtual ~IMRTCProduerCallBack() override = default; + virtual void onProducer(uint32_t msgId, MRTCProducerInfo& info) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP MRTCProduerNULLCallBack final : public IMRTCProduerCallBack +{ +public: + DELETE_COPY(MRTCProduerNULLCallBack); + void onProducer(uint32_t msgId, MRTCProducerInfo& info) override + { + } +}; + +// 消费者媒体类型 +enum MRTCConsumerMediaType +{ + TYPE_CONSUMER_MEDIA_AUDIO = 0x00, // 音频 + TYPE_CONSUMER_MEDIA_VIDEO = 0x01, // 视频 +}; + +// Consumer 回调数据结构 +//TYPE_STATUS_CONSUMER_INFO +struct MRTCConsumerInfo final +{ +// DELETE_COPY(MRTCConsumerInfo); + char producerId[256] = { 0 }; + char kind[50] = { 0 }; + char type[50] = { 0 }; + bool producerPaused; + char consumerId[256] = { 0 }; + char roomId[256] = { 0 }; + const char* m_customDataParam = nullptr; + const char* m_streamID = nullptr; + char displayName[256] = { 0 }; + // 需要默认值,否则部分情况下解析有异常 + MRTCConsumerMediaType mediaType = TYPE_CONSUMER_MEDIA_AUDIO; + MRTCAudioSourceType audioSourceType = TYPE_AUDIO_SOURCE_NONE; + MRTCVideoSourceType videoSourceType = TYPE_VIDEO_SOURCE_NONE; + + // 某个消费者分层信息改变 + int spatiaLayer; + int temporalLayer; + // 某个消费者视频得分 + int8_t producerScore; + int8_t score; + uint8_t channelIndex = 0; + + char m_extraParam[521] = { 0 }; +}; + +// 消费者状态回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCConsumerCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCConsumerCallBack); + virtual ~IMRTCConsumerCallBack() override = default; + virtual void onConsumer(uint32_t msgId, const char* roomId, const char* peerId, MRTCConsumerInfo& consumerInfo) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP MRTCConsumerNULLCallBack final : public IMRTCConsumerCallBack +{ +public: + DELETE_COPY(MRTCConsumerNULLCallBack); + void onConsumer(uint32_t msgId, const char* roomId, const char* peerId, MRTCConsumerInfo& consumerInfo) override + { + } +}; + +// 数据生产者回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCDataProduerCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCDataProduerCallBack); + virtual ~IMRTCDataProduerCallBack() override = default; + virtual void onDataProducer(uint32_t msgId, void* param) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP MRTCDataProduerNULLCallBack final : public IMRTCDataProduerCallBack +{ +public: + DELETE_COPY(MRTCDataProduerNULLCallBack); + void onDataProducer(uint32_t msgId, void* param) override + { + } +}; + +// 数据消费者回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCDataConsumerCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCDataConsumerCallBack); + virtual ~IMRTCDataConsumerCallBack() override = default; + virtual void onDataConsumer(uint32_t msgId, const char* userId, void* param) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP MRTCDataConsumerNULLCallBack final : public IMRTCDataConsumerCallBack +{ +public: + DELETE_COPY(MRTCDataConsumerNULLCallBack); + void onDataConsumer(uint32_t msgId, const char* userId, void* param) override + { + } +}; + +// 权限请求回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCRequestCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCRequestCallBack); + virtual ~IMRTCRequestCallBack() override = default; + virtual void onRequest() = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP IMRTCRequestCallBackNULL final : public IMRTCRequestCallBack +{ +public: + DELETE_COPY(IMRTCRequestCallBackNULL); + void onRequest() override + { + } +}; + +// 音频数据帧 +struct MRTCAudioFrame final +{ +// DELETE_COPY(MRTCAudioFrame); + int16_t* data = nullptr; + int dataCount = 0; + int sampleRate = 48000; + int numChannels = 1; + int channelIndex = 0; +}; + +// 视频帧数据 +struct MRTCVideoFrame final +{ +// DELETE_COPY(MRTCVideoFrame); + MRTCVideoDataType dataType; + uint8_t* data = nullptr; + uint8_t* datau = nullptr; + uint8_t* datav = nullptr; + + int width = 0; + int height = 0; + int rotation = 0; + void* extra = nullptr; + int64_t timestampus = 0; + char szInternalSeiInfo[2048] = {0}; + char szExternalSeiInfo[2048] = { 0 }; + uint8_t channelIndex = 0; +#ifdef __APPLE__ + PixelBufferRef pixelBufferRef; +#endif +#ifdef __ANDROID__ + jobject androidVideoFrameBuffer; +#endif +#ifdef __LINUX__ +#endif +}; + +struct MRTCVideoEncodedFrame final +{ + DELETE_COPY(MRTCVideoEncodedFrame); + MRTCVideoEncodedCodecType codecType; + uint8_t* data = nullptr; //回调返回后, data会被释放,避免指向此内存 + uint32_t size = 0; + int width = 0; + int height = 0; + bool isKeyFrame = false; + int64_t timestampus = 0; + uint8_t channelIndex = 0; +}; + +// 视频帧数据 +struct MRTCRawVideoFrame final +{ + DELETE_COPY(MRTCRawVideoFrame); + MRTCVideoRawDataType dataType; + uint8_t* data = nullptr; + int len = 0; + int width = 0; + int height = 0; + int64_t timestampus = 0; + uint8_t channelIndex = 0; +}; + +// 渲染模式 +enum MRTCRenderModeType +{ + TYPE_RENDER_MODE_SCALE_ASPECTFIT = 0x00, ///< 等比缩放,可能有黑边 + TYPE_RENDER_MODE_SCALE_ASPECTFILL = 0x01, ///< 等比缩放填充整View,可能有部分被裁减 + TYPE_RENDER_MODE_SCALE_TO_FILL = 0x02, ///< 填充整个View +}; + +// 视频窗口View +struct MRTCVideoView final +{ + void* hWnd = nullptr; // windows窗口句柄 + uint8_t channelIndex = 0; + char roomId[256] = { 0 }; + MRTCRenderModeType eRenderMode = TYPE_RENDER_MODE_SCALE_ASPECTFIT; //渲染模式 +}; + +// Video Render数据回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCVideoRenderCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCVideoRenderCallBack); + virtual ~IMRTCVideoRenderCallBack() override = default; + virtual void onRender(const char* roomId, const char* peerId, MRTCVideoSourceType sourceType, const MRTCVideoFrame& videoFrame) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP MRTCVideoRenderNULLCallBack final : public IMRTCVideoRenderCallBack +{ +public: + DELETE_COPY(MRTCVideoRenderNULLCallBack); + void onRender(const char* roomId, const char* peerId, MRTCVideoSourceType sourceType, const MRTCVideoFrame& videoFrame) override + { + } +}; + +// 远端视频编码数据回调 +class RTCENGINE_API IMRTCRemoteEncodedVideoCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCRemoteEncodedVideoCallBack); + virtual ~IMRTCRemoteEncodedVideoCallBack() override = default; + virtual void onRemoteVideoEncodedData(const char* roomId, const char* userId, MRTCVideoSourceType sourceType, const MRTCVideoEncodedFrame& videoEncodedFrame) = 0; +}; + +// 报告监控信息回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCReportMonitorCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCReportMonitorCallBack); + virtual ~IMRTCReportMonitorCallBack() override = default; + virtual void onReportMonitorData(const char* key, const char* value) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP MRTCReportMonitoNULLCallBack final : public IMRTCReportMonitorCallBack +{ +public: + DELETE_COPY(MRTCReportMonitoNULLCallBack); + void onReportMonitorData(const char* key, const char* value) override + { + } +}; + +// 设备监控信息回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCDeviceMonitorCallBack : virtual public IMRTCBaseCallBack + { + public: + DELETE_COPY(IMRTCDeviceMonitorCallBack); + virtual ~IMRTCDeviceMonitorCallBack() override = default; + virtual void onDeviceMonitorData(MRTCDeviceMonitorType type, void* param) = 0; + }; + +class RTCENGINE_API RTCENGINE_API_CPP MRTCDeviceMonitorNULLCallBack final : public IMRTCDeviceMonitorCallBack + { + public: + DELETE_COPY(MRTCDeviceMonitorNULLCallBack); + virtual void onDeviceMonitorData(MRTCDeviceMonitorType type, void* param) override + { + } + }; + +// 音量声浪值回调 +class RTCENGINE_API IMRTCReceivedAudioInfoCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCReceivedAudioInfoCallBack); + virtual ~IMRTCReceivedAudioInfoCallBack() override = default; + virtual void onSoundLevelUpdate(const char* roomId, const char* peerId, uint16_t audioSourceType,uint8_t channelIndex, uint16_t volume, int32_t vad) = 0; + virtual void onAudioProcess(const char* roomId, const char* peerId, MRTCAudioFrame& audioFrame, MRTCAudioSourceType audioSourceType) = 0; +}; + +class MRTCAudioReceiveNULLCallBack final : public IMRTCReceivedAudioInfoCallBack +{ +public: + DELETE_COPY(MRTCAudioReceiveNULLCallBack); + virtual void onSoundLevelUpdate(const char* roomId, const char* peerId, uint16_t audioSourceType,uint8_t channelIndex, uint16_t volume, int32_t vad) override + { + } + + virtual void onAudioProcess(const char* roomId, const char* peerId, MRTCAudioFrame& audioFrame, MRTCAudioSourceType audioSourceType) override + { + } +}; + + +// 背景音乐进度回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCMusicProcessCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCMusicProcessCallBack); + virtual ~IMRTCMusicProcessCallBack() override = default; + virtual void onMusicProcess(uint64_t pos, uint64_t totalTime) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP IMRTCMusicProcessNULLCallBack final : public IMRTCMusicProcessCallBack +{ +public: + DELETE_COPY(IMRTCMusicProcessNULLCallBack); + void onMusicProcess(uint64_t pos, uint64_t totalTime) override + { + } +}; + +// 视频分享进度回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCVideoProcessCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCVideoProcessCallBack); + virtual ~IMRTCVideoProcessCallBack() override = default; + virtual void onVideoProcess(uint64_t pos, uint64_t totalTime) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP IMRTCVideoProcessNULLCallBack final : public IMRTCVideoProcessCallBack +{ +public: + DELETE_COPY(IMRTCVideoProcessNULLCallBack); + void onVideoProcess(uint64_t pos, uint64_t totalTime) override + { + } +}; + +// 音效播放器回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCAudioEffectCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCAudioEffectCallBack); + virtual ~IMRTCAudioEffectCallBack() override = default; + virtual void onAudioEffectProcess(int32_t audioEffectID, uint64_t pos, uint64_t totalTime) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP IMRTCAudioEffectNULLCallBack : public IMRTCAudioEffectCallBack +{ +public: + DELETE_COPY(IMRTCAudioEffectNULLCallBack); + virtual ~IMRTCAudioEffectNULLCallBack() override = default; + virtual void onAudioEffectProcess(int32_t audioEffectID, uint64_t pos, uint64_t totalTime) override + { + } +}; + +// 音效播放器加载资源回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCAudioEffectLoadResourceCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCAudioEffectLoadResourceCallBack); + virtual ~IMRTCAudioEffectLoadResourceCallBack() override = default; + virtual void onLoadResourceProcess(int32_t audioEffectID, uint32_t process, int32_t errorCode) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP IMRTCAudioEffectLoadResourceNULLCallBack : public IMRTCAudioEffectLoadResourceCallBack +{ +public: + DELETE_COPY(IMRTCAudioEffectLoadResourceNULLCallBack); + virtual ~IMRTCAudioEffectLoadResourceNULLCallBack() override = default; + virtual void onLoadResourceProcess(int32_t audioEffectID, uint32_t process, int32_t errorCode) override + { + } +}; + +// 数据结构 +////////////////////////////////////////////////////////////////////////// +// 音效播放器配置 +struct MRTCAudioEffectPlayConfig final +{ +}; + +// 引擎配置 +struct MRTCEngineConfig final +{ + char applicationId[256] = { 0 }; + char appSecrectKey[256] = { 0 }; + char domain[256] = { 0 }; + unsigned short port; + int nMaxTries = -1; + int nFactor = 2; + int nMinTimeout = 1000; + int nMaxTimeout = 8 * 1000; +}; + +// 登录授权 +struct MRTCJoinAuthority final +{ + //DELETE_COPY(MRTCJoinAuthority); + char applicationId[256] = { 0 }; + char appSecretKey[256] = { 0 }; + char token[256] = { 0 }; + + long long startTime = 0 ; + long expiredTime = 0; + + // V2鉴权参数 + char invokeRoomId[256] = "null"; + long invokeStartTs = 0; + int invokeExpireTime = 10; +}; + +// 协议类型 +enum MRTCProtocolType +{ + TYPE_PROTOCOL_INVALID = 0x00, + TYPE_PROTOCOL_WEBSOCKET = 0x01, + TYPE_PROTOCOL_SOCKETIO = 0x02, + TYPE_PROTOCOL_DATACHANNEL = 0x03, +}; + +// RTC場景类型 +enum MRTCSceneType +{ + SCENE_MEETING = 0x00, // 会议场景 + SCENE_LIVESTREAM = 0x01, // 直播场景 +}; + +// 强制视频类型 +enum MRTCForceVideoType +{ + TYPE_FORCE_DEFAULT = 0x00, + TYPE_FORCE_H264 = 0x01, +}; + +// 登录参数配置 +constexpr auto STREAM_LEVEL_DEFAULT_VALUE = 3; +struct MRTCJoinConfig final +{ + int streamLeavel = STREAM_LEVEL_DEFAULT_VALUE; + MRTCForceVideoType forceType = TYPE_FORCE_DEFAULT; //废弃 + MRTCProtocolType protocolType = TYPE_PROTOCOL_INVALID; + MRTCSceneType rtcScene = MRTCSceneType::SCENE_MEETING; + MRTCClientRole clientRole = MRTCClientRole::TYPE_CLIENT_ROLE_ANCHOR; + bool audioChannelsStereo = false; + bool enablePlayout = true; + char m_nUrlConnectTs[50] = { 0 }; + bool enableFec = false; // 是否开启fec,默认开启后,会关闭大小流,目前两路流不支持同时fec + bool enableRobot = false; // 是否为机器人,默认为false。机器人加入房间不会被其他用户看到,用于拨测、审核等特殊场景 +#if defined(__APPLE__) && TARGET_OS_IPHONE + bool useMediaVolume = false; // 使用媒体音量 (默认false 使用通话音量) 【如果设置过-setAlwaysDisableMediaVolum:为true,此功能失效】 + bool reduceOthersVolume = false; // 是否压低其它音量 (默认true) +#endif +}; + +struct MRTMJoinConfig final +{ + MRTCProtocolType protocolType = TYPE_PROTOCOL_INVALID; + char m_nUrlConnectTs[50] = {0}; +}; + +enum AecFilterLength { + kNormal, //(Default) 48ms for normal environment. + kLong, //200ms for reverberant environment. + kLongest //480ms for highly reverberant environment. +}; + +enum AnsSuppressionMode { + kMild, //(Default) Low suppression level with only statistical ns enabled. + kModerate, //Moderate suppression level with both statistical and ai ns enabled. + kAggressive //High suppression level with both statistical and ai ns enabled. +}; + +enum MRTCAudioEncodeType +{ + MRTCAudioEncodeAac = 0x00, + MRTCAudioEncodeOpus = 0x01, +}; + +// 音频参数 +struct MRTCAudioOption +{ + uint32_t sampleRate = 48000; + uint8_t channel = 2; + bool echoCancellation = true; + bool autoGain = true; + bool highPass = true; + bool noiseSuppression = true; + bool experAgc = true; + bool experNS = true; + bool bReconnectRecoverSharedAudio = false; + char streamID[256] = { 0 }; + MRTCAudioSourceType sourceType = TYPE_AUDIO_SOURCE_NONE; + // 通道号,pugc linux 在使用时channelIndex从1开始,0预留给类前端外部采集封装接口 + uint8_t channelIndex = 0; + // 推流房间号 + char dstRoomId[256] = { 0 }; + bool externalProcess = false; //使用独立的3A处理 +// bool enableAudioDump = false; //打开音频文件pcm存储 +// char dumpPath[512] = { 0 }; //音频文件存储路径 + AecFilterLength aecOption = kNormal; //独立3A处理的回声消除参数 + AnsSuppressionMode ansOption = kMild; //独立3A处理的智能降噪参数 + MRTCAudioEncodeType audioEncodeType = MRTCAudioEncodeOpus; + + char extraParam[256] = { 0 }; // 额外参数 +}; + + +struct MRTCSuperResolutionOption +{ + char peerId[256] = { 0 }; + bool enable = false; + MRTCVideoSourceType sourceType = TYPE_VIDEO_SOURCE_NONE; +}; + +// 硬件设备类型 +enum MRTCMediaDeviceType +{ + TYPE_HW_AUDIO_MICROPHONE = 0x00, // 麦克风 + TYPE_HW_AUDIO_SPEAKER = 0x01, // 扬声器 + TYPE_HW_VIDEO_CAMERA = 0x02, // 摄像头 +}; + +// 屏幕分享类型 +enum MRTCScreenShareType +{ + TYPE_SHARE_SCREEN = 0x01, // 屏幕分享 + TYPE_SHARE_WINDOW = 0x02, // 分享窗口 +}; + +// 编码画质等级 +enum MRTCVideoEncodeQuality +{ + DEFAULT_VIDEO_ENCODE_QUALITY = 0x00, + LOW_VIDEO_ENCODE_QUALITY = 0x01, + MEDIUM_VIDEO_ENCODE_QUALITY = 0x02, + HIGH_VIDEO_ENCODE_QUALITY = 0x03, +}; + +enum MRTCSafeMode { + LIMIT_IP_FREQUENCY = 0x00,// 控制IP请求频次,一分钟两次,原来2s一次,可能会降低网络监测敏感度 +}; + +enum MRTCNetworkState +{ + MRTCNetworkStateGood = 0, + MRTCNetworkStateNormal, + MRTCNetworkStateBad, + MRTCNetworkStateTerrible, + MRTCNetworkStateInvalid, +}; + +// 视频参数基类 +struct RTCENGINE_API MRTCVideoOption +{ + MRTCVideoOption(MRTCVideoSourceType type = TYPE_VIDEO_SOURCE_NONE) { sourceType = type; } + MRTCVideoSourceType sourceType = TYPE_VIDEO_SOURCE_NONE; + + int16_t width = 0; + int16_t height = 0; + int16_t fps = 15; + int32_t maxVideoBW = 0; + int32_t minVideoBW = 0; + bool mirror = false; + int32_t startVideoBW = 0; + int32_t noLayersBW = 0; + mutable int16_t numSpatialLayers = 2; + + // 控制自适应网络带宽变化引起的分辨率降低至的最小宽高值 + int limitMinAdaptResolutionWidth = 0; + int limitMinAdaptResolutionHeight = 0; + // 编码画质等级 + MRTCVideoEncodeQuality videoEncodeQuality = MEDIUM_VIDEO_ENCODE_QUALITY; + char streamID[256] = { 0 }; // 推流流ID标识 + uint8_t channelIndex = 0; // 通道号 + char dstRoomId[256] = { 0 }; // 推流房间号 + char extraParam[256] = { 0 }; // 额外参数 + + int gop = -1; // GOP,单位:s + + int nVideoType = 0; //0 H264 1 H265 + bool isAbsoluteRatio = false; +}; + +// 打开摄像头推流参数 +struct RTCENGINE_API MRTCPublishOption : public MRTCVideoOption +{ + MRTCPublishOption() : MRTCVideoOption(TYPE_VIDEO_SOURCE_CAMERA) {} +}; + + +// 打开摄像头预览参数 +struct RTCENGINE_API MRTCCameraOption : public MRTCVideoOption +{ + MRTCCameraOption() : MRTCVideoOption(TYPE_VIDEO_SOURCE_CAMERA) {} + intptr_t cameraId = -1; +#if defined(__ANDROID__) + jobject pAndroidCameraProxyObj = nullptr; // android业务层代理 +#endif +}; + +// 打开屏幕分享参数 +struct RTCENGINE_API MRTCScreenOption final : public MRTCVideoOption +{ + MRTCScreenOption() : MRTCVideoOption(TYPE_VIDEO_SOURCE_SCREEN) {} + intptr_t screenOrWindowId = -1; + MRTCScreenShareType type = TYPE_SHARE_SCREEN; + bool bReconnectRecoverSharedScreen = false; + bool enableHighPrecisionCapture = false;//是否开启高精度捕获 + bool enableCroppingWindow = false; + bool enableBorder = false; + bool enableCursor = true; +#if defined(__ANDROID__) + jobject pAndroidCameraProxyObj = nullptr; // android业务层代理 +#endif +}; + +// 打开视频文件分享参数 +struct RTCENGINE_API MRTCVideoFileOption final : public MRTCVideoOption +{ + MRTCVideoFileOption() : MRTCVideoOption(TYPE_VIDEO_SOURCE_VIDEO) {} +}; + +// 打开自定义视频流参数 +struct RTCENGINE_API MRTCCustomVideoOption : public MRTCVideoOption +{ + MRTCCustomVideoOption() : MRTCVideoOption(TYPE_VIDEO_SOURCE_CUSTOM) {} +}; + +// 打开自定义视频流参数 +struct RTCENGINE_API MRTCCustomRawVideoOption : public MRTCVideoOption +{ + MRTCCustomRawVideoOption() : MRTCVideoOption(TYPE_VIDEO_SOURCE_RAW){} + //int nVideoType = 1; //0 H264 1 V264 2 v265 3 H265 +}; + +// 视频编码参数 +struct RTCENGINE_API MRTCVideoEncodeOption : public MRTCVideoOption { +}; + +struct RTCENGINE_API MRTCMultiRoomOption final +{ + char roomId[256] = { 0 }; + char authDays[256] = { 0 }; + char authCurTime[256] = { 0 }; + char sign[256] = { 0 }; + bool reconnect = false; +}; + +// +// To String 方法,使用 +// +inline std::string formatString(const char* format, ...) { + va_list args; + va_start(args, format); + int iLen = vsnprintf(nullptr, 0, format, args); + va_end(args); + char* pLogBuffer; + pLogBuffer = reinterpret_cast(malloc(iLen * 4 + 4)); + if (!pLogBuffer) { + return ""; + } + + pLogBuffer[0] = '\0'; + va_start(args, format); + vsnprintf(pLogBuffer, iLen + 1, format, args); + va_end(args); + + std::string result = std::string(pLogBuffer); + + free(pLogBuffer); + return result; +} + +// 音视频质量数据 +////////////////////////////////////////////////////////////////////////// +// 本地音频质量数据 +struct MRTCLocalAudioStats final +{ + char userId[256] = { 0 }; + char roomId[256] = { 0 }; + char srcRoomId[256] = { 0 }; + int audioRtt = 0; + int audioLostRate = 0; + int audioTotalLostRate = 0; + uint8_t channelIndex = 0; + int64_t audioSendbytes = 0; + int64_t audioSendBitrate = 0; + MRTCAudioSourceType audioSourceType = TYPE_AUDIO_SOURCE_NONE; + MRTCNetworkState networkState = MRTCNetworkStateInvalid; + + // 20241121 视讯要求新增 + double sysCpuUsage = 0; + double appCpuUsage = 0; + int32_t appMemUsage = 0; + int32_t sysMemUsage = 0; + char streamId[256] = { 0 }; + + std::string ToString(){ + return formatString("userId:%s, roomId:%s, srcRoomId:%s, audioRtt:%d, audioLostRate:%d, audioTotalLostRate:%d, channelIndex:%d, audioSendbytes:%lld, audioSendBitrate:%lld, audioSourceType:%d", + userId, roomId, srcRoomId, audioRtt, audioLostRate, audioTotalLostRate, channelIndex, audioSendbytes, audioSendBitrate, audioSourceType); + } +}; + +// 本地视频质量数据 +struct MRTCLocalVideoStats final +{ + char userId[256] = { 0 }; + char roomId[256] = { 0 }; + char srcRoomId[256] = { 0 }; + int frameWidth = 0; + int frameHeight = 0; + int videoInputFrameRate = 0; + int videoSendFrameRate = 0; + int videoRtt = 0; + int videoLostRate = 0; + int videoTotalLostRate = 0; + uint8_t channelIndex = 0; + int64_t videoSendbytes = 0; + int64_t videoSendBitrate = 0; + int layerIndex = 0; + MRTCVideoSourceType videoSourceType = TYPE_VIDEO_SOURCE_NONE; + MRTCNetworkState networkState = MRTCNetworkStateInvalid; + + // 20241121 视讯要求新增 + double_t sysCpuUsage = 0; + double_t appCpuUsage = 0; + int32_t sysMemUsage = 0; + int32_t appMemUsage = 0; + char streamId[256] = { 0 }; + + std::string ToString() { + return formatString( + "userId:%s, roomId:%s, srcRoomId:%s, videoRtt:%d, videoLostRate:%d, audioTotalLostRate:%d, channelIndex:%d, videoSendbytes:%lld, videoSendBitrate:%lld, videoSourceType:%d, frameWidth:%d, frameHeight:%d, videoInputFrameRate:%d, videoSendFrameRate:%d, layerIndex:%d", + userId, roomId, srcRoomId, videoRtt, videoLostRate, videoTotalLostRate, channelIndex, videoSendbytes, videoSendBitrate, videoSourceType, frameWidth, frameHeight, videoInputFrameRate, + videoSendFrameRate, layerIndex); + } +}; + +// 远端音频质量数据 +struct MRTCRemoteAudioStats final +{ + char localUserId[256] = { 0 }; + char userId[256] = { 0 }; + char roomId[256] = { 0 }; + char srcRoomId[256] = { 0 }; + int audioRtt = 0; + int audioLostRate = 0; + int audioTotalLostRate = 0; + uint8_t channelIndex = 0; + int64_t audioRecvbytes = 0; + int64_t audioRecvBitrate = 0; + MRTCAudioSourceType audioSourceType = TYPE_AUDIO_SOURCE_NONE; + MRTCNetworkState networkState = MRTCNetworkStateInvalid; + + // 20241121 视讯要求新增 + double sysCpuUsage = 0; + double appCpuUsage = 0; + int32_t sysMemUsage = 0; + int32_t appMemUsage = 0; + char streamId[256] = { 0 }; + + std::string ToString(){ + return formatString("userId:%s, roomId:%s, srcRoomId:%s, audioRtt:%d, audioLostRate:%d, audioTotalLostRate:%d, channelIndex:%d, audioRecvbytes:%lld, audioRecvBitrate:%lld, audioSourceType:%d", + userId, roomId, srcRoomId, audioRtt, audioLostRate, audioTotalLostRate, channelIndex, audioRecvbytes, audioRecvBitrate, audioSourceType); + } +}; + +// 远端视频质量数据 +struct MRTCRemoteVideoStats final +{ + char localUserId[256] = { 0 }; + char userId[256] = { 0 }; + char roomId[256] = { 0 }; + char srcRoomId[256] = { 0 }; + int frameWidth = 0; + int frameHeight = 0; + int videoRecvFrameRate = 0; + int videoRtt = 0; + int videoLostRate = 0; + int videoTotalLostRate = 0; + uint8_t channelIndex = 0; + int64_t videoRecvbytes = 0; + int64_t videoRecvBitrate = 0; + long videoReceiveDelayMs = 0; + MRTCVideoSourceType videoSourceType = TYPE_VIDEO_SOURCE_NONE; + MRTCNetworkState networkState = MRTCNetworkStateInvalid; + + // 20241121 视讯要求新增 + double sysCpuUsage = 0; + double appCpuUsage = 0; + int32_t appMemUsage = 0; + int32_t sysMemUsage = 0; + char streamId[256] = { 0 }; + + std::string ToString(){ + return formatString( + "userId:%s, roomId:%s, srcRoomId:%s, videoRtt:%d, videoLostRate:%d, audioTotalLostRate:%d, channelIndex:%d, videoRecvbytes:%lld, videoRecvBitrate:%lld, videoSourceType:%d, frameWidth:%d, frameHeight:%d, videoRecvFrameRate:%d, videoReceiveDelayMs:%ld", + userId, roomId, srcRoomId, videoRtt, videoLostRate, videoTotalLostRate, channelIndex, videoRecvbytes, videoRecvBitrate, videoSourceType, frameWidth, frameHeight, videoRecvFrameRate, + videoReceiveDelayMs); + } +}; + +// 音视频质量数据回调 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCStatisticsCallBack : virtual public IMRTCBaseCallBack +{ +public: + DELETE_COPY(IMRTCStatisticsCallBack); + virtual ~IMRTCStatisticsCallBack() override = default; + // 本地音频质量回调 + virtual void onLocalAudioStats(MRTCLocalAudioStats& stats) = 0; + // 本地视频质量回调 + virtual void onLocalVideoStats(MRTCLocalVideoStats& stats) = 0; + // 远端音频质量回调 + virtual void onRemoteAudioStats(MRTCRemoteAudioStats& stats) = 0; + // 远端视频质量回调 + virtual void onRemoteVideoStats(MRTCRemoteVideoStats& stats) = 0; +}; + +class RTCENGINE_API RTCENGINE_API_CPP MRTCStatisticsNULLCallBack final : public IMRTCStatisticsCallBack +{ +public: + DELETE_COPY(MRTCStatisticsNULLCallBack); + void onLocalAudioStats(MRTCLocalAudioStats& stats) override + { + } + void onLocalVideoStats(MRTCLocalVideoStats& stats) override + { + } + void onRemoteAudioStats(MRTCRemoteAudioStats& stats) override + { + } + void onRemoteVideoStats(MRTCRemoteVideoStats& stats) override + { + } +}; + +// 混流 +////////////////////////////////////////////////////////////////////////// + +enum MRTCLiveStreamTransferType +{ + TYPE_RTMP = 0x01, +}; + +enum MRTCLiveStreamVideoEncoding { + TYPE_H264 = 0x00, +}; + +enum MRTCLiveStreamAudioEncoding { + TYPE_AAC = 0x00, +}; + +enum MRTCLiveStreamMode { + TYPE_PARTITIONING_MODE = 0x00, // 均分模式,即两宫格、四宫格、九宫格等,不传和userList为空时0为默认值 + TYPE_SUSPENSION_MODE = 0x01, //悬浮模式,主画面全屏,小画面则横排或竖排悬浮在主画面上,横排或竖排是由输出背景的宽高关系决定的, + // 若宽大于高,为竖排,反之则为横排 + TYPE_CUSTOM_MODE = 0x02, //自定义布局根据下面的UserList内容进行布局,不传和userList为非空时2为默认值 +}; + +enum MRTCLiveStreamMixType { + TYPE_MIX_ALL = 0x01, // 混所有摄像头和所有麦克风,不传时的默认值 + TYPE_MIX_DESKTOP_AND_ALL_MIC = 0x02, // 混一个共享桌面,和所有麦克风 + TYPE_MIX_DESKTOP_ONECAM_AND_ALL_MIC =0x03, //混一个共享桌面、一个共享者的摄像头,和所有麦克风, + // 共享桌面画面会在渲染摄影头画面之后渲染,可以制作画中画的效果。 +}; + +enum MRTCLiveStreamLayoutScale { + TYPE_KEEP_ORIGINAL = 0x00, // 保持原长宽比例 + TYPE_DO_NOT_ZOOM_EXTRA = 0x01, // 不缩放剧中剪切多出来的部分 +}; + +enum MRTCLiveStreamRole { + INTERACTIVE_AUDIENCE = 0x00, // 互动观众 + HOST = 0x01, // 主播 + HOST_SHARED_SCREEN = 0x02, // 主播共享的画面 +}; + +struct MRTCPublishAndMixEncoding final +{ + int16_t transfer_type = TYPE_RTMP; //推流方式,目前支持:1:RTMP + int16_t video = TYPE_H264; //video - 视频编码类型,整型,目前支持:0:H264 + int16_t audio = TYPE_AAC; //音频编码类型,整型,目前支持:0:AAC + int16_t videoBitrate = 1500; //视频编码码率,默认1500,最小400,最大12000 + int16_t videoFramerate = 15; //视频编码帧率,默认30,只能设置:15、20、25、30这几个帧率。 + int16_t videoGop = 30; //视频编码gop长度,默认和帧率一样,最小10,最大120。 + int32_t audioSampleRate = 48000; //音频编码采样率,默认48000,只能设置48000、44100、32000、16000这几个采样率 + int16_t audioChannels = 2; //音频编码声道数,默认2,只能设置1、2这两种声道数 + int16_t audioBirate = 128; //音频编码码率,默认128,最小16,最大256 +}; + +struct MRTCPublishAndMixUserList final +{ + char userId[256] = { 0 }; + int8_t role; + int8_t layout_scale; //缩放模式,目前支持:0:保持原长宽比例 1:不缩放剧中剪切多出来的部分(2.0新增) + int16_t canvas_left; + int16_t canvas_top; + int16_t canvas_width; + int16_t canvas_height; + char canvas_color[256] = { 0 }; +}; + +struct MRTCConsumerStatus final +{ + char peerId[256] = { 0 }; + MRTCVideoSourceType videoKind =TYPE_VIDEO_SOURCE_NONE; + MRTCAudioSourceType audioKind = TYPE_AUDIO_SOURCE_NONE; + int8_t videoMuteKind; + int8_t audioMuteKind; + bool isAudioMute = true; + bool isTopNSelected = true; + uint64_t topNSelectedChangeTs = 0; + bool isVideoMute = true; + int videoTotalData = 0; + int audioTotalData = 0; + bool isMe = false; +}; + +struct MRTCLiveStreamingInfo final +{ + int16_t mixType = TYPE_MIX_ALL; + int16_t mode = TYPE_PARTITIONING_MODE; + int16_t outputWidth = 720; // 指定混流输出流的宽,不传时的默认值为720 + int16_t outputHeight = 1080; // 指定混流输出流的高,不传时的默认值为1080 + char streamUrl[256] = {0}; +}; + +enum MRTCContentHint +{ + kFluid = 0x00, // 流畅模式 + kDetailed = 0x01, // 清晰模式 + +}; +////////////////////////////////////////////////////////////////////////// + +// 屏幕分享 +////////////////////////////////////////////////////////////////////////// +struct MRTCShareSource final +{ + DELETE_COPY(MRTCShareSource); + intptr_t sourceId = 0; + char title[256] = { 0 }; +}; + +////////////////////////////////////////////////////////////////////////// +// 视频设备类型 +enum MRTCAudioDeviceType +{ +#ifdef WIN32 // Windows + TYPE_DEFAULT_CONNUNICATION_DEVICE = -1, + TYPE_DEFAULT_DEVICE = -2 +#else + TYPE_DEFAULT_DEVICE = 0, +#endif +}; + +// 音频设备设置 +struct MRTCAudioDeviceOption final +{ + uint32_t deviceIndex; //speaker or playout device index + MRTCAudioDeviceType deviceType = TYPE_DEFAULT_DEVICE; +}; + +constexpr int MAX_DEVICE_NAME_SIZE = 128; +constexpr int MAX_DEVICE_GUID_SIZE = 256; +constexpr int MAX_CAP_INFO_SIZE = 20; + +struct MRTCCapFormatInfo +{ + uint32_t width; ///< width in pixels + uint32_t height; ///< height in pixels + uint32_t fps; ///< frames per second +}; + +// 摄像头能力 +struct MRTCCameraCapabilities final +{ + uint16_t index; + char name[MAX_DEVICE_NAME_SIZE]; + char deviceUniqueId[MAX_DEVICE_GUID_SIZE]; + char productUniqueId[MAX_DEVICE_GUID_SIZE]; + + uint16_t iFormatCount; + MRTCCapFormatInfo formatInfo[MAX_CAP_INFO_SIZE]; +}; + +// 模式类型 +enum MRTCModeType +{ + TYPE_MODE_INVALID = 0x00, + TYPE_MODE_CAMERA_PREVIEW_MIRROR = 0x01, // 摄像头预览镜像 + TYPE_MODE_CAMERA_PREVIEW_NORMAL = 0x02, // 摄像头预览不镜像 + TYPE_MODE_CAMERA_PUBLISH_MIRROR = 0x03, // 摄像头推流镜像 + TYPE_MODE_CAMERA_PUBLISH_NORMAL = 0x04, // 摄像头推流不镜像 + TYPE_MODE_CAMERA_FRONT = 0x05, // 前置摄像头 + TYPE_MODE_CAMERA_BACK = 0x06, // 后置摄像头 + TYPE_MODE_SPEAKER_OPEN = 0x07, // 扬声器开 + TYPE_MODE_SPEAKER_CLOSE = 0x08, // 扬声器关 + TYPE_MODE_RESET_PLAYOUT = 0x09, // 重置播放设备 + TYPE_MODE_RESET_MICROPHONE = 0x0A, // 重置麦克风 + TYPE_MODE_MUTE_ALL_CONSUMER_AUDIO = 0x0B, // 静音所有音频对象 + TYPE_MODE_UNMUTE_ALL_CONSUMER_AUDIO = 0x0C, // 取消静音所有对象 +}; + +// 插件类型 +enum MRTCPluginType +{ + TYPE_PLUGIN_NONE = 0x00, + TYPE_PLUGIN_AUDIO_RECORD_EFFECT_RAW_BEFORE = 0x11, // 音频采集设备采集到的原始音频数据,没有分帧, 不是10毫秒为单位的数据 + TYPE_PLUGIN_AUDIO_RECORD_EFFECT_BEFORE = 0x12, // 插件音效在默认音效之前处理 + TYPE_PLUGIN_AUDIO_RECORD_EFFECT_AFTER = 0x13, // 插件音效在默认音效之后处理 + TYPE_PLUGIN_AUDIO_PLAYOUT_EFFECT_RAW_DATA = 0x14, // 插件音效在扬声器端混音多路裸数据处理 ---- 仅支持一个注册,其他支持多个注册 + TYPE_PLUGIN_AUDIO_PLAYOUT_EFFECT_BEFORE = 0x15, // 插件音效在扬声器端播放之前的数据处理 + + TYPE_PLUGIN_CAMERA_ENCODE_BEFORE = 0x20, // 视频特效在摄像头编码之前预处理 + TYPE_PLUGIN_CAMERA_DECODE_RENDER = 0x21, // 视频特效在摄像头解码之后渲染之前 + TYPE_PLUGIN_SCREEN_ENCODE_BEFORE = 0x22, // 视频特效在屏幕分享编码之前预处理 + TYPE_PLUGIN_SCREEN_ENCODE_RENDER = 0x23, // 视频特效在屏幕分享编码之渲染之前 + + TYPE_PLUGIN_VIDEO_FRAME_SEI_MODIFIER = 0x24, // 视频帧的sei修改器类型 +}; + +// 插件回调基函数 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCEffectPlugin +{ +public: + DELETE_CTOR_COPY(IMRTCEffectPlugin); + IMRTCEffectPlugin() {} + virtual ~IMRTCEffectPlugin() {} + virtual int16_t onInit(void* param) = 0; // 插件初始化 + virtual int16_t onDestroy() = 0; // 插件卸载 + virtual int16_t onStart() = 0; // 插件开始 + virtual int16_t onStop() = 0; // 插件停止 + virtual int16_t onUpdate() = 0; // 插件状态变化 + virtual int16_t onGetPluginInfo(const char* pName) = 0; // 插件信息 名称等 +}; + +// sei插件 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCSeiPlugin : public IMRTCEffectPlugin +{ +public: + IMRTCSeiPlugin() :IMRTCEffectPlugin() {} + virtual ~IMRTCSeiPlugin() override {} + + // + // Audio Effect Process. + // + virtual void onSEIProcess(const char *roomId, const char *peerId, MRTCVideoSourceType sourceType,MRTCVideoFrame& videoFrame) = 0; +}; + + +// 音频插件 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCAudioEffectPlugin : public IMRTCEffectPlugin +{ +public: + IMRTCAudioEffectPlugin() :IMRTCEffectPlugin() {} + virtual ~IMRTCAudioEffectPlugin() override {} + + // + // Audio Effect Process. + // + virtual int16_t onProcess(MRTCAudioFrame& audioFrame) = 0; +}; + +// 音频原始数据插件 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCRawAudioEffectPlugin : public IMRTCEffectPlugin +{ +public: + // + // Audio Effect Process. + // + virtual int16_t onProcess(const int16_t** const srcData, const int* ssrc, int numberOfStream, int numChannels, int samplesPerChannel, int16_t* dstData, int dstNumChannels) = 0; +}; + +// 摄像头特效插件 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCCameraEffectPlugin : public IMRTCEffectPlugin +{ +public: + // + // Camera Effect Process Before. + // + virtual int16_t onCameraProcessBefore(const char *roomId, const char *peerId, MRTCVideoSourceType sourceType, MRTCVideoFrame& videoFrame) = 0; + + // + // Camera Effect Process Render. + // + virtual int16_t onCameraProcessRender(const char *roomId, const char *peerId, MRTCVideoSourceType sourceType, MRTCVideoFrame& videoFrame) = 0; +}; + +// 屏幕分享特效插件 +class RTCENGINE_API RTCENGINE_API_CPP IMRTCScreenEffectPlugin : public IMRTCEffectPlugin +{ +public: + // + // Screen Effect Process Before. + // + virtual int16_t onScreenProcessBefore(const char *roomId, const char *peerId, MRTCVideoSourceType sourceType, MRTCVideoFrame& videoFrame) = 0; + + // + // Screen Effect Process Render. + // + virtual int16_t onScreenProcessRender(const char *roomId, const char *peerId, MRTCVideoSourceType sourceType, MRTCVideoFrame& videoFrame) = 0; +}; + +// Return Code. +////////////////////////////////////////////////////////////////////////// +enum RetCode : int16_t +{ + ERR_NOERR = 0x00, // 没有错误 + ERR_DATA_EXISTS = 0x01, // 数据已经存在 + ERR_VARIABLE_EMPTY = 0x02, // 变量为空 + ERR_MSG_TYPE_WRONG = 0x03, // 消息类型错误 + ERR_MODULE_ID_ERROR = 0x04, // 模块ID错误 + ERR_MODULE_NOT_EXISTS = 0x05, // 模块不存在 + ERR_MSG_NOT_CURMODULE = 0x06, // 收到不是当前模块消息 + ERR_EVENT_NOT_CURMODULE = 0x07, // 收到不是当前模块事件 + ERR_ENGINE_STATUS_ERR = 0x08, // 引擎状态错误 + ERR_LISTENER_TYPE_ERROR = 0x09, // 监听函数类型错误 + ERR_LOAD_DEVICE_FAILED = 0x0A, // 加载设备失败 + ERR_GET_CAPABILITY_FAILED = 0x0B, // 获取能力失败 + ERR_WS_CREATE_SEND_TRANSPORT = 0x0C, // Websocket创建Send Transport失败。 + ERR_CREATE_SENDTRANSPORT_FAILED = 0x0D, // Device 创建SendTransport失败 + ERR_WS_CREATE_RECV_TRANSPORT = 0x0E, // Websocket创建Recv Transport失败。 + ERR_CREATE_RECVTRANSPORT_FAILED = 0x0F, // Device 创建RecvTransport失败 + ERR_GET_JOIN_ROOM_FAILED = 0x10, // 获取加入房间失败 + ERR_GET_SENDTRANSPORT_PRODUCE_FAILED = 0x11, // Produce获取数据失败 + ERR_GET_SENDTRANSPORT_PRODUCE_DATA_FAILED = 0x12, // ProduceData获取数据失败 + ERR_GET_FROM_CONSUMERID_TO_USERID_FAILED = 0x13, // ComsumerId换换UserId失败 + ERR_GET_FROM_USERID_TO_CONSUMERID_FAILD = 0x14, // UserId转换ConsumerId失败 + ERR_ENGINE_REPEAT_JOIN_ROOM = 0x15, // 已经加入房间,重复加入 + ERR_REPEAT_START_PREVIEW_LOCAL_CAMERA = 0x16, // 重复打开预览摄像头 + ERR_REPEAT_STOP_PREVIEW_LOCAL_CAMERA = 0x17, // 重复关闭摄像头 + ERR_REPEAT_OPEN_MICRO = 0x18, // 重复打开麦克风 + ERR_REPEAT_CLOSE_MICRO = 0x19, // 重复关闭麦克风 + ERR_CAPABILITY_CONTENT_ERROR = 0x1A, // 能力内容错误 + ERR_CREATE_SENDTRANSPORT_RESPONSE_ERR = 0x1B, // 创建send transport 返回数据错误 + ERR_CREATE_RECVTRANSPORT_RESPONSE_ERR = 0x1C, // 创建Recv transport 返回数据错误 + ERR_NEW_CONSUMER_RESPONSE_DATA_ERR = 0x1D, // newConsumer 返回数据错误 + ERR_CREATE_WEBSOCKET_FAILED = 0x1E, // websocket创建失败 + ERR_RECONNECT_ROOM_DURING = 0x1F, // 重连过程中,不能进行操作 + ERR_OPEN_CAMERA_FAILED = 0x20, // 打开摄像头失败 + ERR_GET_CAMERA_INFO_FAILED = 0x21, // 获取摄像头信息失败 + ERR_VOLUME_OUT_OF_RANGE = 0x22, // 音量范围0-1.0 + ERR_CREATE_MIC_PRODUCER_FAILED = 0x23, // Mic生产者对象创建失败 + ERR_CREATE_CAMERA_TRACK_FAILED = 0x24, // 摄像头VideoTrack创建失败 + ERR_VARIABLE_VIDEOTRACK_INVALID = 0x25, // VideoTrack变量无效 + ERR_CREATE_VIDEO_PRODUCER_FAILED = 0x26, // Video生产者创建失败 + ERR_CREATE_NEW_CONSUMER_FAILED = 0x27, // Consumer创建失败 + ERR_RESPONSE_SWITCH_MEDIA = 0x28, // SwitchMedia请求返回失败 + ERR_RESPONSE_SET_VIDEO_LAYERS = 0x29, // SetVideoLayer请求返回失败 + ERR_RESPONSE_ENABLE_CONSUMER_AUDIO = 0x2A, // EnableConsumerAudio请求返回失败 + ERR_RESPONSE_ENABLE_CONSUMER_VIDEO = 0x2B, // EnableConsumerVIdeo请求返回失败 + ERR_RESPONSE_ENABLE_CONSUMER_AUDIO2 = 0x2C, // EnableConsumerAudio2请求返回失败 + ERR_RESPONSE_ENABLE_CONSUMER_VIDEO2 = 0x2D, // EnableConsumerVIdeo2请求返回失败 + ERR_RESPONSE_CLOSE_ROOM = 0x2E, // CloseRooom请求返回失败 + ERR_RESPONSE_SEND_TRANSPORT_CONNECT = 0x2F, // SendTransportConnect请求返回失败 + ERR_RESPONSE_RECV_TRANSPORT_CONNECT = 0x30, // RecvTransportConnect请求返回失败 + ERR_EXCEED_STREAM_LEVEL_LIMIT = 0x31, // 采集的视频尺寸超过了StreamLeave的限制 + ERR_WEBSOCKET_WAS_CLOSED = 0x32, // websocket已经关闭 + ERR_DEVICE_TYPE_WRONG = 0x33, // 设备类型错误 + ERR_EFFECT_REGISTER_FAILED = 0x34, // 特效注册失败 + ERR_AUDIO_DEVICE_IS_IN_USE = 0x35, // 音频设备正在使用 + ERR_REPEAT_OPEN_SCREEN = 0x36, // 重复打开屏幕分享 + ERR_REPEAT_CLOSE_SCREEN = 0x37, // 重复关闭屏幕分享 + ERR_CONNECT_SERVER_FAILED = 0x38, // 连接服务器错误 + ERR_DO_FAILED_FOR_WILL_LEAVE = 0x39, // 将要离开房间,操作失败 + ERR_LOAD_AUDIO_MONITOR_FAILED = 0x3A, // 加载音频设备监控失败 + ERR_UNLOAD_AUDIO_MONITOR_FAILED = 0x3B, // 卸载音频设备监控失败 + ERR_REGISTER_AUDIO_MONITOR_FAILED = 0x3C, // 注册音频设备监控失败 + ERR_REGISTER_WINDOWS_CLASS_FAILED = 0x3D, // 注册Windows窗口类失败 + ERR_CREATE_WINDOWS_WINDOW_FAILED = 0x3E, // 创建windows窗口失败 + ERR_REGISTER_DEVICE_NOTIFY_FAILED = 0x3F, // 注册设备Notify失败 + ERR_REPEAT_START_PUBLISHING = 0x40, // 重复开始预览 + ERR_REPEAT_STOP_PUBLISHING = 0x41, // 重复停止预览 + ERR_REPEAT_OPEN_SCREEN_SHAREING = 0x42, // 重复打开屏幕分享 + ERR_REPEAT_STOP_SCREEN_SHAREING = 0x43, // 重复关闭屏幕分享 + ERR_BACKGROUND_MUSIC_NOT_PLAYING = 0x44, // 背景音乐没有在播放 + ERR_BACKGROUND_MUSIC_NOT_PAUSED = 0x45, // 背景音乐不是pause状态 + ERR_MUSIC_PLAYER_ALREADY_INIT = 0x46, // 背景音乐播放器已经初始化 + ERR_MUSIC_PLAYER_ALREADY_UNINIT = 0x47, // 背景音乐播放器已经释放 + ERR_MUSIC_PLAYER_DO_NOT_INIT = 0x48, // 背景音乐播放器还没有初始化 + ERR_MUSIC_PLAYER_HAVE_STOPED = 0x49, // 背景音乐播放器已经停止 + ERR_MUSIC_PLAYER_IS_PLAYING = 0x4A, // 背景音乐播放器正在播放状态 + ERR_MUSIC_PLAYER_IS_PAUSED = 0x4B, // 背景音乐播放器正在暂停状态 + ERR_MUSIC_PLAYER_IS_STOPED = 0x4C, // 背景音乐播放器正在停止状态 + ERR_MUSIC_PLAYER_FILE_PATH_EMPTY = 0x4D, // 背景音乐播放路径不能为空 + ERR_MUSIC_PLAYER_FILE_READ_FAILED = 0x4E, // 背景音乐文件不存在或者不可读 + ERR_MUSIC_PLAYER_DO_NOT_PLAYING = 0x4F, // 背景音乐播放器不在播放状态 + ERR_MUSIC_PLAYER_DO_NOT_PAUSED = 0x50, // 背景音乐播放器不在暂停状态 + ERR_FIND_AUDIO_STREAM_FAILED = 0x51, // 查找音频流失败! + ERR_FIND_DECODE_CODEC_FAILED = 0x52, // 查找解码器失败! + ERR_FAILED_ALLOC_DECODE_CTX = 0x53, // 申请Decoder Context失败! + ERR_FAILED_COPY_PARAM_TO_DEC = 0x54, // 拷贝Decoder Param失败! + ERR_FAILED_OPEN_DECODEC = 0x55, // 打开解码器失败! + ERR_RETURN_FAILED_FIND_VIDEO_STREAM = 0x56, // 获取视频流失败! + ERR_RETURN_FAILED_FIND_AUDIO_STREAM = 0x57, // 获取音频流失败! + ERR_RETURN_FILE_CANNOT_OPEN = 0x58, // 打开媒体文件失败! + ERR_RETURN_NOT_FIND_STREAM = 0x59, // 没有发现媒体流! + ERR_RETURN_NOT_AVAILABLE = 0x5A, // 媒体文件没有获取到需要的信息. + ERR_MEDIA_FILE_CANNOT_OPEN = 0x5B, // 媒体文件无法打开 + ERR_CANNOT_FIND_STREAM = 0x5C, // 查找不到媒体文件流信息 + ERR_INVALID_PARAMETER = 0x5D, // 参数错误 + ERR_UPLOAD_LOG_FILE_FAILED = 0x5E, // 上传日志文件失败 + ERR_OPEN_ZIP_FILE_FAILED = 0x5F, // 打开Zip文件错误 + ERR_OPEN_SCREEN_FAILED = 0x60, // 打开屏幕分享失败 + ERR_OPEN_SHARE_AUDIO_FAILED = 0x61, // 打开音频分享失败 + ERR_REPEAT_CLOSE_SHARE_AUDIO = 0x62, // 重复关闭音频分享 + ERR_VIDEO_FILE_NOT_PLAYING = 0x63, // 视频文件没有在播放 + ERR_VIDEO_FILE_NOT_PAUSED = 0x64, // 视频文件不是pause状态 + ERR_VIDEO_PLAYER_ALREADY_INIT = 0x65, // 视频播放器已经初始化 + ERR_VIDEO_PLAYER_ALREADY_UNINIT = 0x66, // 视频播放器已经释放 + ERR_VIDEO_PLAYER_DO_NOT_INIT = 0x67, // 视频播放器还没有初始化 + ERR_VIDEO_PLAYER_HAVE_STOPED = 0x68, // 视频播放器已经停止 + ERR_VIDEO_PLAYER_IS_PLAYING = 0x69, // 视频播放器正在播放状态 + ERR_VIDEO_PLAYER_IS_PAUSED = 0x6A, // 视频播放器正在暂停状态 + ERR_VIDEO_PLAYER_IS_STOPED = 0x6B, // 视频播放器正在停止状态 + ERR_VIDEO_PLAYER_FILE_PATH_EMPTY = 0x6C, // 视频播放路径不能为空 + ERR_VIDEO_PLAYER_FILE_READ_FAILED = 0x6D, // 视频文件不存在或者不可读 + ERR_VIDEO_PLAYER_DO_NOT_PLAYING = 0x6E, // 视频播放器不在播放状态 + ERR_VIDEO_PLAYER_DO_NOT_PAUSED = 0x6F, // 视频播放器不在暂停状态 + ERR_EXCEED_ROOM_MEMBER_LIMIT = 0x70, // 加入房间人数超过服务端最大限制 + ERR_EXCEED_VIDEO_PRODUCE_NUMBER_LIMIT = 0x71, // 开启视频人数超过服务端最大限制 + EER_AUDIO_DATA_REACHED_END = 0x72, // 音频数据已经到末尾 + ERR_AUDIO_DATA_NOT_ENOUGH = 0x73, // 没有足够长度的音频数据 + ERR_OPEN_DESKTOP_FAILED = 0x74, // 打开桌面声音分享失败 + ERR_OPEN_BGMUSIC_FAILED = 0x75, // 打开背景音乐失败 + ERR_REPEAT_OPEN_BGMUSIC = 0x76, // 重复打开背景音乐 + ERR_REPEAT_CLOSE_BGMUSIC = 0x77, // 重复关闭背景音乐 + ERR_OPEN_FILE_AUDIO_FAILED = 0x78, // 打开视频分享音频失败 + ERR_OPEN_AUDIO_EFFECT_FAILED = 0x79, // 打开音效音频失败 + ERR_CREATE_SCREEN_TRACK_FAILED = 0x7A, // 屏幕分享VideoTrack创建失败 + ERR_CREATE_SHARE_AUDIO_PRODUCER_FAILED = 0x7B, // 创建屏幕声音分享生产者失败 + ERR_CREATE_MUSIC_PRODUCER_FAILED = 0x7C, // 创建背景音乐生产者失败 + ERR_CREATE_FILE_AUDIO_PRODUCER_FAILED = 0x7D, // 创建视频分享音频生产者失败 + ERR_CREATE_AUDIO_EFFECT_PRODUCER_FAILED = 0x7E, // 创建音效音频生产者失败 + ERR_REPEAT_OPEN_FILE_AUDIO = 0x7F, // 重复打开视频分享文件音频 + ERR_REPEAT_OPEN_AUDIO_EFFECT = 0x80, // 重复打开音效文件音频 + ERR_REPEAT_CLOSE_FILE_AUDIO = 0x81, // 重复关闭视频分享文件音频 + ERR_REPEAT_CLOSE_AUDIO_EFFECT = 0x82, // 重复关闭音频文件音频 + ERR_REPEAT_OPEN_DESKTOP = 0x83, // 重复打开桌面声音分享 + ERR_REPEAT_CLOSE_DESKTOP = 0x84, // 重复关闭桌面声音分享 + ERR_OPERATION_FAILED = 0x85, // 操作失败 + ERR_OPEN_CUSTOM_AUDIO_FAILED = 0x86, // 打开自定义音频失败 + ERR_CREATE_FILE_VIDEO_TRACK_FAILED = 0x87, // 视频分享VideoTrack创建失败 + ERR_REPEAT_CLOSE_FILE_VIDEO = 0x88, // 重复关闭视频分享文件视频 + ERR_CREATE_CUSTOM_VIDEO_TRACK_FAILED = 0x89, // 自定义视频VideoTrack创建失败 + ERR_OPEN_CUSTOM_VIDEO_FAILED = 0x8A, // 打开自定义视频失败 + ERR_OPEN_FILE_VIDEO_FAILED = 0x8B, // 打开视频分享文件视频失败 + ERR_REPEAT_OPEN_CUSTOM_AUDIO = 0x8C, // 重复打开自定义音频 + ERR_REPEAT_CLOSE_CUSTOM_AUDIO = 0x8D, // 重复关闭自定义音频 + ERR_PRE_INSTANCE_NOT_DESTROY = 0x8E, // MRTCEngine 前一个实例没有调用destroy销毁,不能同时运行多份实例! + ERR_EXCEED_MIC_PRODUCE_NUMBER_LIMIT = 0x8F, // 麦克风人数超过限制 + ERR_GET_RESTART_ICE_PARAMETERS_FAILED = 0x90, // 获取ReStartICE参数错误 + ERR_RESTARTICE_PARAM_INVALID = 0x91, // ReStartICE参数错误 + ERR_DOMAIN_CURL_REQUEST_FAILED = 0x92, // 就近接入请求CURL失败 + ERR_DOMAIN_REQUEST_CODE_FAILED = 0x93, // 就近接入获取CODE错误 + DOMAIN_REQUEST_CODE_READY = 0x94, // 就近接入准备就绪 + DOMAIN_REQUEST_EMPTY = 0x95, // 就近接入传入地址为空 + DOMAIN_REQUEST_DATA_EMPTY = 0x96, // 就近接入获取环境为空 + UPLOAD_REQUEST_READY = 0x97, // 日志上传请求就绪 + UPLOAD_CURL_CONNECT_FAILED = 0x98, // 日志上传CURL连接失败 + UPLOAD_CURL_REQUEST_FAILED = 0x99, // 日志上传CURL请求失败 + UPLOAD_CURL_REQUEST_DATA_FAILED = 0x9A, // 日志上传CURL请求数据错误 + DOMAIN_REQUEST_CURL_FAILED = 0x9B, // 就近接入CURL初始化失败 + DOMAIN_GET_RESPONSE_FAILED = 0x9C, // 就近接入解析response错误 + ERR_AUDIO_DEVICE_START_EXCEPTION = 0x9D, // 音频设备启动异常 + ERR_VIDEO_DEVICE_START_EXCEPTION = 0x9E, // 视频设备启动异常 + TOKEN_REQUEST_CODE_READY = 0x9F, // 获取token准备就绪 + REQUEST_TOKEN_FAILED = 0xA0, // 获取token获取失败 + LIVE_STREAMING_REQUEST_CODE_READY = 0xA1, // 拉流混流准备就绪 + REQUEST_LIVE_STREAMING_FAILED = 0xA2, // 请求拉流混流失败失败 + LIVE_STREAMING_UPDATE_CODE_READY = 0xA3, // 更新拉流混流准备就绪 + UPDATE_LIVE_STREAMING_FAILED = 0xA4, // 更新拉流混流失败失败 + LIVE_STREAMING_STOP_CODE_READY = 0xA5, // 停止拉流混流准备就绪 + STOP_LIVE_STREAMING_FAILED = 0xA6, // 停止拉流混流失败失败 + ERR_CONNECT_SERVER_TO_FAILED = 0xA7, // 停止拉流混流失败失败 + RECEIVE_CUSTOM_MESSAGE = 0xA8, // 接收到自定义信令 + RECEIVE_KICKOUT_MESSAGE = 0xA9, // 接收到服务端踢人信令 + RECEIVE_FORBID_RTC_PUSH = 0xAA, // 接收到禁止推流信令 + RECEIVE_RESUME_RTC_PUSH = 0xAB, // 接收到恢复推流信令 + RECEIVE_FORBID_RTC_PULL = 0xAD, // 接收到禁止拉流信令 + RECEIVE_RESUME_RTC_PULL = 0xAE, // 接收到恢复拉流信令 + MEDIA_PUBLISH_SUCCESS = 0xAF, // 音视频推流成功 + MEDIA_PUBLISH_FAILED = 0xB0, // 音视频推流失败 + WINDOW_CAPTURE_FAILED_MINIATURIZED = 0xB1, // 窗口缩小引起采集失败 + WINDOW_CAPTURE_FAILED_CLOSED = 0xB2, // 窗口关闭引起采集失败 + ERR_REPEAT_OPEN_DATACHANNEL = 0xB3, // 重复打开dataChannel + ERR_CREATE_NEW_DATA_CONSUMER_FAILED = 0xB4, // customData 能力创建失败 + DATA_CHANNEL_PRODUCE_OPEN = 0xB5, // customData produce 通道开启 + DATA_CHANNEL_PRODUCE_CLOSEED = 0xB6, // customData produce 通道关闭 + DATA_CHANNEL_CONSUMER_OPEN = 0xB7, // customData consuemr 通道开启 + DATA_CHANNEL_CONSUMER_CLOSEED = 0xB8, // customData consuemr 通道关闭 + ERR_CREATE_DATA_CHANNEL_PRODUCER_FAILED = 0xB9, // 创建customData生产者失败 + ERR_SATRT_SUPER_RESOLUTION_REPEAT = 0xBA, // 已经设置过此peerid对应类型的超分,重复设置 + ERR_STOP_SUPER_RESOLUTION_INVALID = 0xBB, // 未设置过此peerId对应类型的超分,取消超分无效 + RECEIVE_REPEAT_KICKOUT_MESSAGE = 0xBC, // 接收到自己在不同设备重复入会,被自己踢掉信令 + ERR_CREATE_SEND_TRANSPORT_ERROR_ADD_TRACK = 0xBD, // createWebRtcTransport 信令失败,导致添加音视频Track失败 + ERR_REPEAT_STOP_DATACHANNEL = 0xBE, // 重复停止DataChannel + ERR_CONNECT_RTM_SERVER_TO_FAILED = 0xC0, // RTM 返回 605错误,重试之后关闭 + ERR_CONNECT_RTM_SERVER_FAILED = 0xC1, // 连接RTM服务器出错 + ERR_EXCEED_RTM_ROOM_MEMBER_LIMIT = 0xC2, // RTM 超出上限 + JOIN_MULTI_ROOM_SUCCESS = 0xC3, // 加入多房间成功 + ERR_JOIN_MULTI_ROOM = 0xC4, // 加入多房间失败 + LEAVE_MULTI_ROOM_SUCCESS = 0xC5, // 离开多房间成功 + ERR_LEAVE_MULTI_ROOM = 0xC6, // 离开多房间失败 + RECONNECT_JOIN_MULTI_ROOM_SUCCESS = 0xC7, // 重连加入多房间成功 + ERR_RECONNECT_JOIN_MULTI_ROOM = 0xC8, // 重连加入多房间失败 + ERR_REPEAT_JOIN_MULTI_ROOM = 0xC9, // 重复加入多房间 + ERR_JOIN_MULTI_HOST_ROOM = 0xCA, // 使用主房间Id调用加入多房间接口 + ERR_LEAVE_MULTI_HOST_ROOM = 0xCB, // 使用主房间Id调用离开多房间接口 + ERR_REQUEST_ROOM_USER_LIST_TOO_FREQUENCY = 0xCC, // 过于频繁的调用房间人员列表接口 + ERR_GET_ROOM_USERS_TOO_OFTEN = 0xCD, // 调用获取房间成员列表太频繁 + ERR_ROOM_MODE_MISMATCH = 0xCE, // 房间mode不匹配 + ERR_INVALID_ROOM_MODE = 0xCF, // 无效的房间mode + ERR_REQUEST_RS_BEYOND_MAX = 0xD0, // 请求RS超时 + ERR_RS_EXCEPTION = 0xD1, // RS服务内部错误 + ERR_JOIN_ROOM_BEYOND_MAX = 0xD2, // 加多房间超出加入房间限制 + ERR_ROOM_CLOSED = 0xD3, // 房间已被关闭,90s内用户无法加入 + ERR_EXCESSIVE_REQUESTS = 0xD4, // 请求房间用户或房间用户数过于频繁 + ERR_UNKNOWN_ROLE = 0xD5, // 无效的用户role + ERR_TRANSPORT_ERROR = 0xD6, // transport异常 + ERR_REPEAT_USER = 0xD7, // 用户重复登录 + ERR_REPEAT_START_CUSTOM_AUDIO = 0xD8, // 重复打开自定义音频 + ERR_REPEAT_STOP_CUSTOM_AUDIO = 0xD9, // 重复关闭自定义音频 + // RAW video 相关 + ERR_REPEAT_OPEN_RAW_VIDEO = 0xDA, // 重复打开自定义裸视频 + ERR_REPEAT_CLOSE_RAW_VIDEO = 0xDB, // 重复关闭自定义裸视频 + ERR_CREATE_CUSTOM_RAW_VIDEO_TRACK_FAILED = 0xDC, // 创建视频裸流VideoTrackProduct失败 + ERR_VIDEO_CHANNEL = 0xDD, // 发送视频流的通道不存在 + ERR_AUDIO_CHNNAEL = 0xDE, // 发送视音流的通道不存在 + ERR_VIDEO_CHNNAEL_INDEX = 0xDF, // 视频多路流通道数不在0-100区间 + ERR_AUDIO_CHNNAEL_INDEX = 0xE0, // 音频多路流通道数不在0-100区间 + ERR_CREATE_CUSTOM_SECOND_VIDEO_TRACK_FAILED = 0xE1, // 自定义第二路视频VideoTrack创建失败 + ERR_CREATE_CUSTOM_AUDIO_PRODUCER_FAILED = 0xE2, // 创建视频自定义音频生产者失败 + + ERR_PUSH_MEDIA_TIMEOUT = 0xE3, // 推流超时 + ERR_AUTO_UPLOAD_ENABLED_CANT_USE_API = 0xE4, // 自动上传开启,上传日志API无效化 + AUTO_UPLOAD_SUCCEED = 0xE5, // 自动上传成功 + + ERR_OPERATION_TOO_FREQUENT = 0xE6, // 操作过于频繁 + CAMERA_OPEN_SUCCESS = 0xE7, // 摄像头打开成功 + MIC_OPEN_SUCCESS = 0xE8, // 麦克风打开成功 + + ERR_ENGINE_STATUS_ERR_NOT_INITED = 0xE9, // 引擎状态错误,子码,未初始化 + ERR_ENGINE_STATUS_ERR_NOT_IN_ROOM= 0xEA, // 引擎状态错误,子码,未加入房间 + + ERR_TRANSPORT_AUDIO_MIXER_ADD = 0xEB, // transport未创建,添加混音能力失败 + ERR_REPEAT_AUDIO_MIXER_ADD = 0xEC, // 重复添加混音能力 + ERR_TRANSPORT_AUDIO_MIXER_DELETE = 0xED, // transport未创建,删除混音能力失败 + ERR_REPEAT_AUDIO_MIXER_DELETE = 0xEE, // 重复删除混音能力 + + ERR_VIDEO_H265_HARDWARE_ENCODE_FAILED_AND_SWITCH_TO_SOFTWARE = 0xED, // H265硬编码失败切换软编 + ERR_VIDEO_H264_HARDWARE_ENCODE_FAILED_AND_SWITCH_TO_SOFTWARE = 0xEE, // H264硬编码失败切换软编 + + ERR_AUDIO_PUSH_AAC_ERROR = 0xEF, // 推送AAC音频失败 +}; + +static constexpr const char* GetErrorDescription(RetCode e) +{ + const char* pDescription = nullptr; + switch (e) + { + case ERR_NOERR: + pDescription = "success"; + break; + case ERR_DATA_EXISTS: + pDescription = "Data already exists."; + break; + case ERR_VARIABLE_EMPTY: + pDescription = "Variable is empty."; + break; + case ERR_MSG_TYPE_WRONG: + pDescription = "Wrong message type."; + break; + case ERR_MODULE_ID_ERROR: + pDescription = "Module ID error."; + break; + case ERR_MODULE_NOT_EXISTS: + pDescription = "Module does not exist."; + break; + case ERR_MSG_NOT_CURMODULE: + pDescription = "Received a message that is not the current module"; + break; + case ERR_EVENT_NOT_CURMODULE: + pDescription = "Received a event that is not the current module"; + break; + case ERR_ENGINE_STATUS_ERR: + pDescription = "Engine status error."; + break; + case ERR_LISTENER_TYPE_ERROR: + pDescription = "Wrong monitoring function type."; + break; + case ERR_LOAD_DEVICE_FAILED: + pDescription = "Failed to load device."; + break; + case ERR_OPERATION_TOO_FREQUENT: + pDescription = "Operation is too frequent, please try again later."; + break; + case ERR_GET_CAPABILITY_FAILED: + pDescription = "Failed to acquire ability."; + break; + case ERR_WS_CREATE_SEND_TRANSPORT: + pDescription = "WebSocket failed to create Send Transport."; + break; + case ERR_CREATE_SENDTRANSPORT_FAILED: + pDescription = "Device failed to create SendTransport."; + break; + case ERR_WS_CREATE_RECV_TRANSPORT: + pDescription = "WebSocket failed to create Recv Transport."; + break; + case ERR_CREATE_RECVTRANSPORT_FAILED: + pDescription = "Device failed to create RecvTransport."; + break; + case ERR_GET_JOIN_ROOM_FAILED: + pDescription = "Failed to get join room."; + break; + case ERR_GET_SENDTRANSPORT_PRODUCE_FAILED: + pDescription = "SendTransport produce failed to get data."; + break; + case ERR_GET_SENDTRANSPORT_PRODUCE_DATA_FAILED: + pDescription = "SendTransport producedata failed to get data."; + break; + case ERR_GET_FROM_CONSUMERID_TO_USERID_FAILED: + pDescription = "ComsumerId change to UserId failed"; + break; + case ERR_GET_FROM_USERID_TO_CONSUMERID_FAILD: + pDescription = "UserId change to ConsumerId failed"; + break; + case ERR_ENGINE_REPEAT_JOIN_ROOM: + pDescription = "Already joined the room, repeat to join the room"; + break; + case ERR_REPEAT_START_PREVIEW_LOCAL_CAMERA: + pDescription = "Start the camera preview repeatedly"; + break; + case ERR_REPEAT_STOP_PREVIEW_LOCAL_CAMERA: + pDescription = "Stop the camera preview repeatedly"; + break; + case ERR_REPEAT_START_PUBLISHING: + pDescription = "Start the camera publishing repeatedly"; + break; + case ERR_REPEAT_STOP_PUBLISHING: + pDescription = "Stop the camera publishing repeatedly"; + break; + case ERR_REPEAT_OPEN_MICRO: + pDescription = "Repeat to turn on the microphone"; + break; + case ERR_REPEAT_CLOSE_MICRO: + pDescription = "Repeatedly turn off the microphone"; + break; + case ERR_CAPABILITY_CONTENT_ERROR: + pDescription = "Ability to obtain content error"; + break; + case ERR_CREATE_SENDTRANSPORT_RESPONSE_ERR: + pDescription = "create sendtransport returns data errorr"; + break; + case ERR_CREATE_RECVTRANSPORT_RESPONSE_ERR: + pDescription = "create recvtransport returns data errorr"; + break; + case ERR_NEW_CONSUMER_RESPONSE_DATA_ERR: + pDescription = "newConsumer returns data errorr"; + break; + case ERR_CREATE_WEBSOCKET_FAILED: + pDescription = "websocket creation failed."; + break; + case ERR_RECONNECT_ROOM_DURING: + pDescription = "Cannot operate during reconnection."; + break; + case ERR_OPEN_CAMERA_FAILED: + pDescription = "Failed to open camera."; + break; + case ERR_GET_CAMERA_INFO_FAILED: + pDescription = "Failed to get camera information."; + break; + case ERR_VOLUME_OUT_OF_RANGE: + pDescription = "The volume range is out of range 0-1.0."; + break; + case ERR_CREATE_MIC_PRODUCER_FAILED: + pDescription = "Mic producer object creation failed."; + break; + case ERR_CREATE_CAMERA_TRACK_FAILED: + pDescription = "Camera videotrack creation failed."; + break; + case ERR_VARIABLE_VIDEOTRACK_INVALID: + pDescription = "The variable videotrack is not valid."; + break; + case ERR_CREATE_VIDEO_PRODUCER_FAILED: + pDescription = "Video producer object creation failed."; + break; + case ERR_CREATE_NEW_CONSUMER_FAILED: + pDescription = "Consumer creation failed."; + break; + case ERR_RESPONSE_SWITCH_MEDIA: + pDescription = "SwitchMedia request failed."; + break; + case ERR_RESPONSE_SET_VIDEO_LAYERS: + pDescription = "SetVideoLayer request failed to return."; + break; + case ERR_RESPONSE_ENABLE_CONSUMER_AUDIO: + pDescription = "EnableConsumerAudio request failed to return."; + break; + case ERR_RESPONSE_ENABLE_CONSUMER_VIDEO: + pDescription = "EnableConsumerVideo request failed to return."; + break; + case ERR_RESPONSE_ENABLE_CONSUMER_AUDIO2: + pDescription = "EnableConsumerAudio2 request failed to return."; + break; + case ERR_RESPONSE_ENABLE_CONSUMER_VIDEO2: + pDescription = "EnableConsumerVideo2 request failed to return."; + break; + case ERR_RESPONSE_CLOSE_ROOM: + pDescription = "CloseRoom request failed to return."; + break; + case ERR_RESPONSE_SEND_TRANSPORT_CONNECT: + pDescription = "SendTransportConnect request failed to return."; + break; + case ERR_RESPONSE_RECV_TRANSPORT_CONNECT: + pDescription = "RecvTransportConnect request failed to return."; + break; + case ERR_EXCEED_STREAM_LEVEL_LIMIT: + pDescription = "The size of the captured video exceeds the limit of StreamLeave"; + break; + case ERR_WEBSOCKET_WAS_CLOSED: + pDescription = "WebSocket was closed."; + break; + case ERR_DEVICE_TYPE_WRONG: + pDescription = "Wrong device type."; + break; + case ERR_EFFECT_REGISTER_FAILED: + pDescription = "Special effects registration failed."; + break; + case ERR_AUDIO_DEVICE_IS_IN_USE: + pDescription = "Audio device is in use."; + break; + case ERR_REPEAT_OPEN_SCREEN: + pDescription = "Turn on the share screen repeatedly."; + break; + case ERR_REPEAT_CLOSE_SCREEN: + pDescription = "Close the share screen repeatedly."; + break; + case ERR_CONNECT_SERVER_FAILED: + pDescription = "Connect To Server Failed."; + break; + case ERR_DO_FAILED_FOR_WILL_LEAVE: + pDescription = "About to leave the room, the operation failed."; + break; + case ERR_LOAD_AUDIO_MONITOR_FAILED: + pDescription = "Failed to load audio device monitoring."; + break; + case ERR_UNLOAD_AUDIO_MONITOR_FAILED: + pDescription = "Failed to uninstall audio device monitor."; + break; + case ERR_REGISTER_AUDIO_MONITOR_FAILED: + pDescription = "Failed to register audio device monitor."; + break; + case ERR_REGISTER_WINDOWS_CLASS_FAILED: + pDescription = "Failed to register windows window class."; + break; + case ERR_CREATE_WINDOWS_WINDOW_FAILED: + pDescription = "Failed to create Windows window."; + break; + case ERR_REGISTER_DEVICE_NOTIFY_FAILED: + pDescription = "Failed to register device notification."; + break; + case ERR_REPEAT_OPEN_SCREEN_SHAREING: + pDescription = "Open the screen sharing repeatedly."; + break; + case ERR_REPEAT_STOP_SCREEN_SHAREING: + pDescription = "Stop the screen sharing repeatedly."; + break; + case ERR_BACKGROUND_MUSIC_NOT_PLAYING: + pDescription = "Background music is not playing."; + break; + case ERR_BACKGROUND_MUSIC_NOT_PAUSED: + pDescription = "The background music is not paused."; + break; + case ERR_MUSIC_PLAYER_ALREADY_INIT: + pDescription = "The background music player has been initialized."; + break; + case ERR_MUSIC_PLAYER_ALREADY_UNINIT: + pDescription = "The background music player has been released."; + break; + case ERR_MUSIC_PLAYER_DO_NOT_INIT: + pDescription = "The background music player has not been initialized."; + break; + case ERR_MUSIC_PLAYER_IS_PLAYING: + pDescription = "Background music player is playing."; + break; + case ERR_MUSIC_PLAYER_IS_PAUSED: + pDescription = "The background music player is paused."; + break; + case ERR_MUSIC_PLAYER_FILE_PATH_EMPTY: + pDescription = "The background music playback path cannot be empty."; + break; + case ERR_MUSIC_PLAYER_FILE_READ_FAILED: + pDescription = "The background music file does not exist or is unreadable."; + break; + case ERR_MUSIC_PLAYER_DO_NOT_PLAYING: + pDescription = "The background music player is not playing."; + break; + case ERR_MUSIC_PLAYER_DO_NOT_PAUSED: + pDescription = "The background music player is not paused."; + break; + case ERR_FIND_AUDIO_STREAM_FAILED: + pDescription = "Find Audio Stream Failed."; + break; + case ERR_FIND_DECODE_CODEC_FAILED: + pDescription = "Find Decode Codec Failed."; + break; + case ERR_FAILED_ALLOC_DECODE_CTX: + pDescription = "Failed to allocate the decoder context."; + break; + case ERR_FAILED_COPY_PARAM_TO_DEC: + pDescription = "Failed to copy decoder parameters to input decoder context"; + break; + case ERR_FAILED_OPEN_DECODEC: + pDescription = "Failed to open decoder"; + break; + case ERR_RETURN_FAILED_FIND_VIDEO_STREAM: + pDescription = "Could not find video stream."; + break; + case ERR_RETURN_FAILED_FIND_AUDIO_STREAM: + pDescription = "Could not find audio stream."; + break; + case ERR_RETURN_FILE_CANNOT_OPEN: + pDescription = "Cannot open media file."; + break; + case ERR_RETURN_NOT_FIND_STREAM: + pDescription = "Cannot find stream information."; + break; + case ERR_RETURN_NOT_AVAILABLE: + pDescription = "The current media file does not get the required information."; + break; + case ERR_MEDIA_FILE_CANNOT_OPEN: + pDescription = "Cannot open input media file."; + break; + case ERR_CANNOT_FIND_STREAM: + pDescription = "Cannot find stream information."; + break; + case ERR_INVALID_PARAMETER: + pDescription = "Parameter error."; + break; + case ERR_UPLOAD_LOG_FILE_FAILED: + pDescription = "Failed to upload log file."; + break; + case ERR_OPEN_ZIP_FILE_FAILED: + pDescription = "Failed to open zip file."; + break; + case ERR_OPEN_SCREEN_FAILED: + pDescription = "Failed to open screen sharing."; + break; + case ERR_VIDEO_FILE_NOT_PLAYING: + pDescription = "Video file is not playing."; + break; + case ERR_VIDEO_FILE_NOT_PAUSED: + pDescription = "The video player is not paused."; + break; + case ERR_VIDEO_PLAYER_ALREADY_INIT: + pDescription = "The video player has been initialized."; + break; + case ERR_VIDEO_PLAYER_ALREADY_UNINIT: + pDescription = "The video player has been released."; + break; + case ERR_VIDEO_PLAYER_DO_NOT_INIT: + pDescription = "The video player has not been initialized."; + break; + case ERR_MUSIC_PLAYER_HAVE_STOPED: + pDescription = "The background music player has stopped."; + break; + case ERR_VIDEO_PLAYER_HAVE_STOPED: + pDescription = "The video player has stopped."; + break; + case ERR_VIDEO_PLAYER_IS_PLAYING: + pDescription = "The video player is playing."; + break; + case ERR_VIDEO_PLAYER_IS_PAUSED: + pDescription = "The video player is paused."; + break; + case ERR_VIDEO_PLAYER_FILE_PATH_EMPTY: + pDescription = "The video playback path cannot be empty."; + break; + case ERR_MUSIC_PLAYER_IS_STOPED: + pDescription = "The background music player is stoped."; + break; + case ERR_VIDEO_PLAYER_IS_STOPED: + pDescription = "The video player is stoped."; + break; + case ERR_VIDEO_PLAYER_FILE_READ_FAILED: + pDescription = "The video file does not exist or is unreadable."; + break; + case ERR_VIDEO_PLAYER_DO_NOT_PLAYING: + pDescription = "The video player is not playing."; + break; + case ERR_VIDEO_PLAYER_DO_NOT_PAUSED: + pDescription = "The video player is not paused."; + break; + case ERR_EXCEED_ROOM_MEMBER_LIMIT: + pDescription = "The number of people joining the room exceeds the maximum limit of the server."; + break; + case ERR_EXCEED_VIDEO_PRODUCE_NUMBER_LIMIT: + pDescription = "The number of people who have opened the video exceeds the maximum limit of the server."; + break; + case EER_AUDIO_DATA_REACHED_END: + pDescription = "Audio data has reached the end."; + break; + case ERR_AUDIO_DATA_NOT_ENOUGH: + pDescription = "Not enough audio data."; + break; + case ERR_OPEN_DESKTOP_FAILED: + pDescription = "Failed to open desktop sound sharing."; + break; + case ERR_OPEN_BGMUSIC_FAILED: + pDescription = "Failed to open background music."; + break; + case ERR_REPEAT_OPEN_BGMUSIC: + pDescription = "Repeat to open the BGMusic"; + break; + case ERR_REPEAT_CLOSE_BGMUSIC: + pDescription = "Repeat to close the BGMusic"; + break; + case ERR_OPEN_FILE_AUDIO_FAILED: + pDescription = "Failed to open video sharing audio"; + break; + case ERR_OPEN_AUDIO_EFFECT_FAILED: + pDescription = "Failed to open sound effect audio"; + break; + case ERR_CREATE_SCREEN_TRACK_FAILED: + pDescription = "Screen sharing VideoTrack creation failed"; + break; + case ERR_CREATE_FILE_VIDEO_TRACK_FAILED: + pDescription = "Video file sharing VideoTrack creation failed"; + break; + case ERR_CREATE_CUSTOM_VIDEO_TRACK_FAILED: + pDescription = "Custom video sharing VideoTrack creation failed"; + break; + case ERR_CREATE_CUSTOM_SECOND_VIDEO_TRACK_FAILED: + pDescription = "Custom second video sharing VideoTrack creation failed"; + break; + case ERR_CREATE_SHARE_AUDIO_PRODUCER_FAILED: + pDescription = "Failed to create screen sound sharing producer"; + break; + case ERR_CREATE_MUSIC_PRODUCER_FAILED: + pDescription = "Failed to create background music producer"; + break; + case ERR_CREATE_FILE_AUDIO_PRODUCER_FAILED: + pDescription = "Failed to create video sharing audio producer"; + break; + case ERR_CREATE_CUSTOM_AUDIO_PRODUCER_FAILED: + pDescription = "Failed to create custom audio producer"; + break; + case ERR_CREATE_AUDIO_EFFECT_PRODUCER_FAILED: + pDescription = "Failed to create sound effect audio producer"; + break; + case ERR_REPEAT_OPEN_FILE_AUDIO: + pDescription = "Open the video repeatedly to share the file audio"; + break; + case ERR_REPEAT_OPEN_AUDIO_EFFECT: + pDescription = "Repeatedly open the sound effect file audio"; + break; + case ERR_REPEAT_CLOSE_FILE_VIDEO: + pDescription = "Repeatedly open the sound effect file video"; + break; + case ERR_REPEAT_CLOSE_FILE_AUDIO: + pDescription = "Close the video file audio repeatedly"; + break; + case ERR_REPEAT_CLOSE_AUDIO_EFFECT: + pDescription = "Close the video file video repeatedly"; + break; + case ERR_REPEAT_OPEN_DESKTOP: + pDescription = "Repeatedly open desktop sound sharing."; + break; + case ERR_REPEAT_CLOSE_DESKTOP: + pDescription = "Repeatedly close desktop sound sharing."; + break; + case ERR_OPERATION_FAILED: + pDescription = "operation failed."; + break; + case ERR_OPEN_CUSTOM_AUDIO_FAILED: + pDescription = "Failed to open custom audio."; + break; + case ERR_OPEN_CUSTOM_VIDEO_FAILED: + pDescription = "Failed to open custom video."; + break; + case ERR_OPEN_FILE_VIDEO_FAILED: + pDescription = "Failed to open video sharing file video."; + break; + case ERR_REPEAT_OPEN_CUSTOM_AUDIO: + pDescription = "Repeat to open custom audio."; + break; + case ERR_REPEAT_CLOSE_CUSTOM_AUDIO: + pDescription = "Repeat to close custom audio."; + break; + case ERR_PRE_INSTANCE_NOT_DESTROY: + pDescription = "The previous instance of MRTCEngine did not call destroy, and multiple instances cannot be run at the same time!"; + break; + case ERR_GET_RESTART_ICE_PARAMETERS_FAILED: + pDescription = "Get ReStartICE parameter error."; + break; + case ERR_RESTARTICE_PARAM_INVALID: + pDescription = "ReStartICE parameter error."; + break; + case ERR_DOMAIN_REQUEST_CODE_FAILED: + pDescription = "Request signal url failed."; + break; + case DOMAIN_REQUEST_CURL_FAILED: + pDescription = "curl init failed!!"; + break; + case ERR_DOMAIN_CURL_REQUEST_FAILED: + pDescription = "The nearest access request CURL failed."; + break; + case DOMAIN_REQUEST_DATA_EMPTY: + pDescription = "vec is empty in response"; + break; + case DOMAIN_GET_RESPONSE_FAILED: + pDescription = "Parse response error."; + break; + case ERR_CREATE_SEND_TRANSPORT_ERROR_ADD_TRACK: + pDescription = "Add track failed, because of create send transport error."; + break; + case JOIN_MULTI_ROOM_SUCCESS: + pDescription = "join Multi Room success"; + break; + case ERR_JOIN_MULTI_ROOM: + pDescription = "join Multi Room failed"; + break; + case LEAVE_MULTI_ROOM_SUCCESS: + pDescription = "leave Multi Room success"; + break; + case ERR_LEAVE_MULTI_ROOM: + pDescription = "leave Multi Room failed"; + break; + case ERR_REPEAT_JOIN_MULTI_ROOM: + pDescription = "repeat join Multi Room"; + break; + case RECONNECT_JOIN_MULTI_ROOM_SUCCESS: + pDescription = "reconnect join Multi Room success"; + break; + case ERR_RECONNECT_JOIN_MULTI_ROOM: + pDescription = "reconnect join Multi Room failed"; + break; + case ERR_JOIN_MULTI_HOST_ROOM: + pDescription = "join Multi Room can not used host roomId"; + break; + case ERR_LEAVE_MULTI_HOST_ROOM: + pDescription = "leave Multi Room can not used host roomId"; + break; + case ERR_REPEAT_OPEN_RAW_VIDEO: + pDescription = "Repeat to open custom raw video."; + break; + case ERR_REPEAT_CLOSE_RAW_VIDEO: + pDescription = "Repeat to close custom raw video."; + break; + case ERR_CREATE_CUSTOM_RAW_VIDEO_TRACK_FAILED: + pDescription = "Custom naked video VideoTrack creation failed."; + break; + case ERR_REQUEST_ROOM_USER_LIST_TOO_FREQUENCY: + pDescription = "Get Room Member List too frequent"; + break; + case ERR_GET_ROOM_USERS_TOO_OFTEN: + pDescription = "Get Room Member List too frequent"; + break; + case ERR_ROOM_MODE_MISMATCH: + pDescription = "Room mode mismatch"; + break; + case ERR_INVALID_ROOM_MODE: + pDescription = "Invalid room mode"; + break; + case ERR_REQUEST_RS_BEYOND_MAX: + pDescription = "request RS beyond max time"; + break; + case ERR_RS_EXCEPTION: + pDescription = "RS exception"; + break; + case ERR_JOIN_ROOM_BEYOND_MAX: + pDescription = "Join multiroom beyond max room number"; + break; + case ERR_ROOM_CLOSED: + pDescription = "Room closed"; + break; + case ERR_EXCESSIVE_REQUESTS: + pDescription = "Request peers or peer number too frequent"; + break; + case ERR_UNKNOWN_ROLE: + pDescription = "Unknow role"; + break; + case ERR_TRANSPORT_ERROR: + pDescription = "transport error"; + break; + case ERR_REPEAT_USER: + pDescription = "Join multiroom Repeat"; + break; + case ERR_PUSH_MEDIA_TIMEOUT: + pDescription = "push stream timeout"; + break; + case ERR_AUTO_UPLOAD_ENABLED_CANT_USE_API: + pDescription = "Enable auto upload log, forbbiden to call uploadLog api"; + break; + case AUTO_UPLOAD_SUCCEED: + pDescription = "Auto upload log success"; + break; + case ERR_ENGINE_STATUS_ERR_NOT_INITED: + pDescription = "Engine status error: Not INITED"; + break; + case ERR_ENGINE_STATUS_ERR_NOT_IN_ROOM: + pDescription = "Engine status error: Not IN ROOM"; + break; + case ERR_VIDEO_H264_HARDWARE_ENCODE_FAILED_AND_SWITCH_TO_SOFTWARE: + pDescription = "h264 hard encoder fallback to soft encoder"; + break; + case ERR_VIDEO_H265_HARDWARE_ENCODE_FAILED_AND_SWITCH_TO_SOFTWARE: + pDescription = "h265 hard encoder fallback to soft encoder"; + break; + default: + pDescription = "Error: Error Return Code."; + break; + } + return pDescription; +} + +enum EngineStatus +{ + ENGINE_STATUS_IDL = -0x01, // 初始状态 + ENGINE_STATUS_INIT = 0x00, // 初始化状态 + ENGINE_STATUS_JOINROOMING = 0x01, // 正在加入房间 + ENGINE_STATUS_JOINROOM = 0x02, // 加入房间 + ENGINE_STATUS_LEAVEROOM = 0x03, // 离开房间 + ENGINE_STATUS_UNINIT = 0x04, // 卸载状态 +}; + +RTCENGINE_NAMESPACE_END + +#endif // __RTC_ENGINE_DEFINE_HPP___ diff --git a/include/MRTCEnginePlatForm.hpp b/include/MRTCEnginePlatForm.hpp new file mode 100644 index 0000000..ee9d588 --- /dev/null +++ b/include/MRTCEnginePlatForm.hpp @@ -0,0 +1,20 @@ +#ifndef __RTC_ENGINE_PLATFORM_HPP__ +#define __RTC_ENGINE_PLATFORM_HPP__ + +#ifdef WIN32 + +#ifndef NOMINMAX +#define NOMINMAX +#endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#pragma warning(disable : 5039) +#include +#include + +#endif + +#include + +#endif //__RTC_ENGINE_PLATFORM_HPP_ \ No newline at end of file diff --git a/lib/libMRTCEngine.dylib b/lib/libMRTCEngine.dylib new file mode 100755 index 0000000..2f8b87c Binary files /dev/null and b/lib/libMRTCEngine.dylib differ diff --git a/lib/libMRTCEngine.so b/lib/libMRTCEngine.so new file mode 100755 index 0000000..2f8b87c Binary files /dev/null and b/lib/libMRTCEngine.so differ diff --git a/rtc_plugins.cpp b/rtc_plugins.cpp new file mode 100644 index 0000000..858af84 --- /dev/null +++ b/rtc_plugins.cpp @@ -0,0 +1,11 @@ +#include "./include/IMRTCEngine.hpp" +#include "./include/IMRTCEngineFactory.hpp" +#include "./include/MRTCEngineDefine.hpp" +#include "./include/MRTCEnginePlatForm.hpp" +#include +#include + +int main() { + std::cout << "aaaaaaaaaaaaaa" << std::endl; + return 0; +}