NIM PC Cross Platform SDK
nim_cpp_vchat.h
Go to the documentation of this file.
1
7#ifndef _NIM_SDK_CPP_VCHAT_H_
8#define _NIM_SDK_CPP_VCHAT_H_
9
10#include <functional>
11#include <string>
13#include "nim_define_include.h"
14#include "public_defines.h"
19namespace nim {
21struct NIM_SDK_CPPWRAPPER_DLL_API NetDetectCbInfo {
23 int32_t res_code_;
24 int32_t loss_;
25 int32_t rtt_max_;
26 int32_t rtt_min_;
27 int32_t rtt_avg_;
28 int32_t rtt_mdev_;
29 std::string expand_info_;
30
32 res_code_ = 0;
33 loss_ = 0;
34 rtt_max_ = 0;
35 rtt_min_ = 0;
36 rtt_avg_ = 0;
37 rtt_mdev_ = 0;
38 }
39};
40class NIM_SDK_CPPWRAPPER_DLL_API VChat {
41public:
43 typedef std::function<void(int, NetDetectCbInfo)> NetDetectCallback;
45 typedef std::function<void(bool ret, int code, const std::string& file, int64_t time)> Mp4OptCallback;
49 typedef std::function<void(bool ret, int code, const std::string& json_extension)> OptCallback;
51 typedef std::function<void(int code, int64_t channel_id, const std::string& json_extension)> Opt2Callback;
53 typedef std::function<void(int id, bool ret, int code, const std::string& json_extension)> EffectOptCallback;
54 typedef std::function<void(const std::string& accid, uint64_t time, const char* data, uint32_t size, int32_t channels, int32_t rate)>
57
63 static bool Init(const std::string& server_setting_path);
64
74 static void SetProxy(NIMProxyType type, const std::string& host, int port, const std::string& user, const std::string& password);
75
80 static void Cleanup();
81
96 static uint64_t NetDetect(NetDetectCallback cb);
97
115 static uint64_t NetDetectEx(int32_t ms_limit, nim::NIMNetDetectType type, nim::NIMNetDetectVideoQuality quality_type, NetDetectCallback cb);
116
124 static void VChatRate(int rating, const std::string& description, OptCallback cb);
125
132 static void EnumDeviceDevpath(nim::NIMDeviceType type, nim_vchat_enum_device_devpath_sync_cb_func cb);
133
144 static void StartDevice(nim::NIMDeviceType type,
145 const std::string& device_path,
146 unsigned fps,
147 int width,
148 int height,
150
156 static void EndDevice(nim::NIMDeviceType type);
157
164 static void AddDeviceStatusCb(nim::NIMDeviceType type, nim_vchat_device_status_cb_func cb);
165
171 static void RemoveDeviceStatusCb(nim::NIMDeviceType type);
172
179 static void SetAudioDataCb(bool capture, nim_vchat_audio_data_cb_func cb);
180
188 static void SetAudioDataCbEx(int type, std::string json_extension, nim_vchat_audio_data_cb_func_ex cb);
189
196 static void SetVideoDataCb(bool capture, nim_vchat_video_data_cb_func cb);
197
204 static void SetAudioVolumn(unsigned char volumn, bool capture);
205
211 static unsigned char GetAudioVolumn(bool capture);
212
218 static void SetAudioInputAutoVolumn(bool auto_volumn);
219
224 static bool GetAudioInputAutoVolumn();
225
233 static void SetAudioProcess(bool aec, bool ns, bool vad);
234
242 static void PreloadEffect(int id, const std::string& path, EffectOptCallback cb);
243
251 static void PlayEffect(int id, int loop_count, EffectOptCallback cb);
252
259 static void StopEffect(int id, EffectOptCallback cb);
260
269 static void SetCbFunc(nim_vchat_cb_func cb);
270
280 static bool Start(NIMVideoChatMode mode, const std::string& apns_text, const std::string& custom_info, const std::string& json_info);
281
288 static bool SetTalkingMode(NIMVideoChatMode mode, const std::string& json_extension);
289
298 static bool CalleeAck(uint64_t channel_id, bool accept, const std::string& json_extension);
299
306 static bool Control(uint64_t channel_id, NIMVChatControlType type);
307
319 static void StartRecord(const std::string& path, const std::string& uid, Mp4OptCallback cb);
320
329 static void StopRecord(const std::string& uid, Mp4OptCallback cb);
330
341 static void StartAudioRecord(const std::string& path, AudioRecordCallback cb);
342
350 static void StopAudioRecord(AudioRecordCallback cb);
351
357 static void End(const std::string& json_extension);
358
365 static void Relogin(const std::string& session_id, OptCallback cb);
366
374 static void SetVideoQuality(int video_quality);
375
383 static void SetVideoBitrate(int video_bitrate);
384
392 static void SetFrameRate(NIMVChatVideoFrameRate frame_rate);
393
402 static void SetCustomData(bool custom_audio, bool custom_video);
403
412 static bool CustomAudioData(uint64_t time, const char* data, unsigned int size, const char* json_extension);
413
429 static bool CustomVideoData(uint64_t time,
430 const char* data,
431 unsigned int size,
432 unsigned int width,
433 unsigned int height,
434 const char* json_extension);
435
453 static bool AccompanyingSound(unsigned char id,
454 uint64_t time,
455 const char* data,
456 unsigned int size,
457 unsigned int rate,
458 unsigned int channels,
459 const char* json_extension);
460
466 static void SetViewerMode(bool viewer);
467
472 static bool GetViewerMode();
473
479
485 static void SetAudioMuted(bool muted);
486
491 static bool GetAudioMuteEnabled();
492
498 static void SetAudioPlayMuted(bool muted);
499
504 static bool GetAudioMutePlayEnabled();
505
511 static void SetRotateRemoteVideo(bool rotate);
512
517 static bool IsRotateRemoteVideo();
518
524 static void SetVideoFrameScaleType(NIMVChatVideoFrameScaleType type);
525
530 static int GetVideoFrameScaleType();
531
543 static void SetMemberBlacklist(const std::string& uid, bool add, bool audio, const std::string& json_extension, OptCallback cb);
544
556 static void CreateRoom(const std::string& room_name, const std::string& custom_info, const std::string& json_extension, Opt2Callback cb);
557
567 static bool JoinRoom(NIMVideoChatMode mode, const std::string& room_name, const std::string& json_extension, Opt2Callback cb);
568
577 static void UpdateRtmpUrl(const std::string& rtmp_url, OptCallback cb);
578
587 static void SelectVideoAdaptiveStrategy(NIMVChatVideoEncodeMode mode, const std::string& json_extension, OptCallback cb);
588
605 static void SetUidAsMainPicture(const std::string& uid, const std::string& json_extension, OptCallback cb);
606
607 // 订阅
614 static bool SetAutoPublish(bool auto_pub, bool auto_sub);
615
620 static bool IsAutoPublishVideo();
621
626 static bool IsAutoSubscribeVideo();
627
632 static bool IsAutoSubscribeAudio();
633
639 static bool SetLocalVideoSimulcastMode(NIMVChatPublishVideoStreamMode video_stream_mode);
640
647 static void PublishVideo(OptCallback cb);
648
655 static void UnpublishVideo(OptCallback cb);
656
664 static void SubscribeVideo(const std::string& uid, OptCallback cb);
665
673 static void UnsubscribeVideo(const std::string& uid, OptCallback cb);
674
682 static void SubscribeAudio(bool sub, OptCallback cb);
683
690 static void SetRemoteAudioDataCb(RemoteAudioDataCallback cb);
691
699 static void AddRemoteAudioDataCb(const std::string& uid, OptCallback cb);
700
708 static void RemoveRemoteAudioDataCb(const std::string& uid, OptCallback cb);
709};
710} // namespace nim
711
712#endif //_NIM_SDK_CPP_VCHAT_H_
Definition: nim_cpp_vchat.h:40
Mp4OptCallback AudioRecordCallback
音频录制事件通知回调模板
Definition: nim_cpp_vchat.h:47
std::function< void(int code, int64_t channel_id, const std::string &json_extension)> Opt2Callback
操作回调模板
Definition: nim_cpp_vchat.h:51
std::function< void(int, NetDetectCbInfo)> NetDetectCallback
网络探测回调模板
Definition: nim_cpp_vchat.h:43
std::function< void(bool ret, int code, const std::string &json_extension)> OptCallback
操作回调模板
Definition: nim_cpp_vchat.h:49
std::function< void(bool ret, int code, const std::string &file, int64_t time)> Mp4OptCallback
MP4录制事件通知回调模板
Definition: nim_cpp_vchat.h:45
std::function< void(int id, bool ret, int code, const std::string &json_extension)> EffectOptCallback
操作回调模板
Definition: nim_cpp_vchat.h:53
static NIMVChatConnectStatus GetConnectStatus()
std::function< void(const std::string &accid, uint64_t time, const char *data, uint32_t size, int32_t channels, int32_t rate)> RemoteAudioDataCallback
远端音频数据回调
Definition: nim_cpp_vchat.h:56
namespace nim
NIM 公共数据类型定义总的包含文件
void(* nim_vchat_audio_data_cb_func_ex)(uint64_t time, const char *data, uint32_t size, int channels, int rate, int volume, const char *json_extension, const void *user_data)
Definition: nim_device_def.h:146
void(* nim_vchat_device_status_cb_func)(enum NIMDeviceType type, uint32_t status, const char *device_path, const char *json_extension, const void *user_data)
Definition: nim_device_def.h:121
void(* nim_vchat_enum_device_devpath_sync_cb_func)(bool ret, enum NIMDeviceType type, const char *json_extension, const void *user_data)
Definition: nim_device_def.h:105
NIMDeviceType
Definition: nim_device_def.h:17
void(* nim_vchat_start_device_cb_func)(enum NIMDeviceType type, bool ret, const char *json_extension, const void *user_data)
Definition: nim_device_def.h:163
void(* nim_vchat_audio_data_cb_func)(uint64_t time, const char *data, uint32_t size, const char *json_extension, const void *user_data)
Definition: nim_device_def.h:175
void(* nim_vchat_video_data_cb_func)(uint64_t time, const char *data, uint32_t size, uint32_t width, uint32_t height, const char *json_extension, const void *user_data)
Definition: nim_device_def.h:190
NIMProxyType
Definition: nim_global_def.h:186
定义导出宏
NIMVChatVideoFrameRate
Definition: nim_vchat_def.h:129
NIMVChatVideoEncodeMode
Definition: nim_vchat_def.h:145
NIMVChatVideoFrameScaleType
Definition: nim_vchat_def.h:157
void(* nim_vchat_cb_func)(enum NIMVideoChatSessionType type, int64_t channel_id, int code, const char *json_extension, const void *user_data)
Definition: nim_vchat_def.h:694
NIMVChatControlType
Definition: nim_vchat_def.h:57
NIMVChatPublishVideoStreamMode
Definition: nim_vchat_def.h:408
NIMVideoChatMode
Definition: nim_vchat_def.h:89
NIMNetDetectVideoQuality
Definition: nim_vchat_def.h:340
NIMVChatConnectStatus
Definition: nim_vchat_def.h:97
NIMNetDetectType
Definition: nim_vchat_def.h:332
NIM SDK 及 NIM ChatRoom SDK 公用头文件
网络探测回调信息
Definition: nim_cpp_vchat.h:21
int32_t res_code_
返回的错误码
Definition: nim_cpp_vchat.h:23