repo init

This commit is contained in:
wangjiyu 2025-04-09 10:34:51 +08:00
commit 1769e41938
8 changed files with 3304 additions and 0 deletions

0
README.md Normal file
View File

872
include/IMRTCEngine.hpp Normal file
View File

@ -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~100100AndroidiOS可超过100100volume会有爆音的风险
* @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-100100AndroidiOS可超过100100volume会有爆音的风险
* @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 (deviceUniqueIdproductUniqueId为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 (maxTimesmaxSeconds都为设置-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<mrtc::MRTCPublishAndMixUserList> userList) = 0;
//
// 更新混流推流
//
virtual int16_t updateLiveStreaming(std::vector<mrtc::MRTCPublishAndMixUserList> userList,
MRTCLiveStreamMode mode) = 0;
//
// 停止混流推流
//
virtual int16_t stopLiveStreaming() = 0;
//
// 发送自定义消息
//
virtual int16_t sendCustomMessage(const char* roomid, const char* peerid,std::vector<std::string> 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__

View File

@ -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

2356
include/MRTCEngineDefine.hpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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 <windows.h>
#include <algorithm>
#endif
#include <stdint.h>
#endif //__RTC_ENGINE_PLATFORM_HPP_

BIN
lib/libMRTCEngine.dylib Executable file

Binary file not shown.

BIN
lib/libMRTCEngine.so Executable file

Binary file not shown.

11
rtc_plugins.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "./include/IMRTCEngine.hpp"
#include "./include/IMRTCEngineFactory.hpp"
#include "./include/MRTCEngineDefine.hpp"
#include "./include/MRTCEnginePlatForm.hpp"
#include <stdio.h>
#include <iostream>
int main() {
std::cout << "aaaaaaaaaaaaaa" << std::endl;
return 0;
}