NIM C# SDK  6.3.0
NIM.DeviceAPI Class Reference

Static Public Member Functions

static void StartDevice (NIMDeviceType type, string devicePath, uint fps, NIMStartDeviceJsonEX StartDeviceInfo, StartDeviceResultHandler handler)
 启动设备,同一NIMDeviceType下设备将不重复启动,不同的设备会先关闭前一个设备开启新设备 More...
 
static void EndDevice (NIMDeviceType type)
 结束设备 More...
 
static void SetAudioCaptureDataCb (AudioDataHandler handler, NIMVChatCustomAudioJsonEx audioJsonEx)
 监听采集音频数据(可以不监听,通过启动设备kNIMDeviceTypeAudioOut由底层播放) More...
 
static void SetAudioReceiveDataCb (AudioDataHandler handler, NIMVChatCustomAudioJsonEx audioJsonEx)
 监听接收音频数据(可以不监听,通过启动设备kNIMDeviceTypeAudioOutChat由底层播放) More...
 
static bool CustomAudioData (ulong time, IntPtr data, uint size, NIMCustomAudioDataInfo info)
 自定义音频数据接口, 采样位深只支持16或32(Unity PC只支持16),kNIMDeviceSampleRate支持8000,16000,32000,44100.PC下有效 More...
 
static NIMDeviceInfoList GetDeviceList (NIMDeviceType type)
 遍历设备 More...
 
static void StartExtendCamera (string id, string device_path, uint fps, string json_extension, StartDeviceResultHandler handler)
 启动辅助的摄像头,摄像头数据通过SetVideoCaptureDataCb设置采集回调返回,不直接通过视频通话发送给对方,并且不参与设备监听检测 More...
 
static void StopExtendCamera (string id)
 结束辅助摄像头 More...
 
static void AddDeviceStatusCb (NIMDeviceType type, DeviceStatusHandler handler)
 添加设备监听(摄像头和麦克风) 注意监听设备后底层会定时检查设备情况,在不需要监听后请移除 More...
 
static void RemoveDeviceStatusCb (NIMDeviceType type)
 移除设备监听(摄像头和麦克风) More...
 
static void SetVideoCaptureDataCb (VideoDataHandler handler, NIMVChatCustomVideoJsonEx videoJsonEx)
 监听采集的视频数据 More...
 
static void SetVideoReceiveDataCb (VideoDataHandler handler, NIMVChatCustomVideoJsonEx videoJsonEx)
 监听接收的视频数据 More...
 
static bool CustomVideoData (ulong time, IntPtr data, uint size, uint width, uint height, NIMCustomVideoDataInfo info)
 
static void SetAudioProcessInfo (bool aec, bool ns, bool vid)
 设置底层针对麦克风采集数据处理开关接口,默认全开(此接口是全局接口,在sdk初始化后设置一直有效) More...
 
static void SetAudioDataCbEx (NIMAudioDataCbType type, string json_extension, AudioDataExHandler handler)
 监听音频数据(可以不监听,通过启动设备kNIMDeviceTypeAudioOut和kNIMDeviceTypeAudioOutChat由底层播放) More...
 
static bool NimVchatAccompanyingSound (Byte id, UInt64 time, IntPtr data, UInt32 size, UInt32 rate, UInt32 channels, string json_extension)
 设置底层针对麦克风采集数据处理开关接口,默认关闭啸叫检测(此接口是全局接口,在sdk初始化后设置一直有效) More...
 

Properties

static byte AudioCaptureVolumn [get, set]
 音频采集音量,默认255 More...
 
static byte AudioPlayVolumn [get, set]
 音频播放音量,默认255 More...
 
static bool AudioCaptureAutoVolumn [get, set]
 设置麦克风音量自动调节, 默认不自动调节 More...
 

Member Function Documentation

◆ AddDeviceStatusCb()

static void NIM.DeviceAPI.AddDeviceStatusCb ( NIMDeviceType  type,
DeviceStatusHandler  handler 
)
static

添加设备监听(摄像头和麦克风) 注意监听设备后底层会定时检查设备情况,在不需要监听后请移除

Parameters
type设备类型(kNIMDeviceTypeAudioIn和kNIMDeviceTypeVideo有效)
handler回调
Returns
无返回值

◆ CustomAudioData()

static bool NIM.DeviceAPI.CustomAudioData ( ulong  time,
IntPtr  data,
uint  size,
NIMCustomAudioDataInfo  info 
)
static

自定义音频数据接口, 采样位深只支持16或32(Unity PC只支持16),kNIMDeviceSampleRate支持8000,16000,32000,44100.PC下有效

Parameters
time时间毫秒级
data音频数据pcm格式
sizedata的数据长度 sizeof(char)
info拓展json封装类
Returns
bool true 调用成功,false 调用失败

◆ CustomVideoData()

static bool NIM.DeviceAPI.CustomVideoData ( ulong  time,
IntPtr  data,
uint  size,
uint  width,
uint  height,
NIMCustomVideoDataInfo  info 
)
static

自定义视频数据接口

Parameters
time时间毫秒级
data视频数据yuv420格式
sizedata的数据长度 sizeof(char)
width画面宽度
height画面高度
info扩展Json封装类
Returns
bool true 调用成功,false 调用失败

◆ EndDevice()

static void NIM.DeviceAPI.EndDevice ( NIMDeviceType  type)
static

结束设备

Parameters
type设备类型
Returns
无返回值

◆ GetDeviceList()

static NIMDeviceInfoList NIM.DeviceAPI.GetDeviceList ( NIMDeviceType  type)
static

遍历设备

Parameters
type设备类型
Returns
NIMDeviceInfoList 设备属性列表

◆ NimVchatAccompanyingSound()

static bool NIM.DeviceAPI.NimVchatAccompanyingSound ( Byte  id,
UInt64  time,
IntPtr  data,
UInt32  size,
UInt32  rate,
UInt32  channels,
string  json_extension 
)
static

设置底层针对麦克风采集数据处理开关接口,默认关闭啸叫检测(此接口是全局接口,在sdk初始化后设置一直有效)

Parameters
worktrue 标识打开啸叫检测功能,false 标识关闭

v5.5接口取消

自定义音频伴音数据接口,不需要打开自定义数据开关, 采样时间必须为10ms的整数倍, 采样位深只支持16

Parameters
id伴音数据id
timetime 时间毫秒级
data音频数据pcm格式
sizedata的数据长度
rate音频采样频
channels声道数
json_extensionjson_extension 扩展
Returns
bool true 调用成功,false 调用失败

◆ RemoveDeviceStatusCb()

static void NIM.DeviceAPI.RemoveDeviceStatusCb ( NIMDeviceType  type)
static

移除设备监听(摄像头和麦克风)

Parameters
type设备类型
Returns
无返回值

◆ SetAudioCaptureDataCb()

static void NIM.DeviceAPI.SetAudioCaptureDataCb ( AudioDataHandler  handler,
NIMVChatCustomAudioJsonEx  audioJsonEx 
)
static

监听采集音频数据(可以不监听,通过启动设备kNIMDeviceTypeAudioOut由底层播放)

Parameters
handler回调
audioJsonExjson封装类,SampleRate有效,(要求返回的音频数据为指定的采样频,缺省为0使用默认采样频
Returns
无返回值

◆ SetAudioDataCbEx()

static void NIM.DeviceAPI.SetAudioDataCbEx ( NIMAudioDataCbType  type,
string  json_extension,
AudioDataExHandler  handler 
)
static

监听音频数据(可以不监听,通过启动设备kNIMDeviceTypeAudioOut和kNIMDeviceTypeAudioOutChat由底层播放)

Parameters
typetype 指定NIMAudioDataCbType,监听伴音数据时,一旦监听,底层将不再混音
json_extensionjson_extension 参考NIMAudioDataCbType的说明
handler回调

◆ SetAudioProcessInfo()

static void NIM.DeviceAPI.SetAudioProcessInfo ( bool  aec,
bool  ns,
bool  vid 
)
static

设置底层针对麦克风采集数据处理开关接口,默认全开(此接口是全局接口,在sdk初始化后设置一直有效)

Parameters
aectrue 标识打开回音消除功能,false 标识关闭
nstrue 标识打开降噪功能,false 标识关闭
vidtrue 标识打开人言检测功能,false 标识关闭
Returns
无返回值

◆ SetAudioReceiveDataCb()

static void NIM.DeviceAPI.SetAudioReceiveDataCb ( AudioDataHandler  handler,
NIMVChatCustomAudioJsonEx  audioJsonEx 
)
static

监听接收音频数据(可以不监听,通过启动设备kNIMDeviceTypeAudioOutChat由底层播放)

Parameters
handler回调
Returns
无返回值

◆ SetVideoCaptureDataCb()

static void NIM.DeviceAPI.SetVideoCaptureDataCb ( VideoDataHandler  handler,
NIMVChatCustomVideoJsonEx  videoJsonEx 
)
static

监听采集的视频数据

Parameters
handler回调
videoJsonExjson 参数封装类
Returns
无返回值

◆ SetVideoReceiveDataCb()

static void NIM.DeviceAPI.SetVideoReceiveDataCb ( VideoDataHandler  handler,
NIMVChatCustomVideoJsonEx  videoJsonEx 
)
static

监听接收的视频数据

Parameters
handler回调
videoJsonExjson参数封装类
Returns
无返回值

◆ StartDevice()

static void NIM.DeviceAPI.StartDevice ( NIMDeviceType  type,
string  devicePath,
uint  fps,
NIMStartDeviceJsonEX  StartDeviceInfo,
StartDeviceResultHandler  handler 
)
static

启动设备,同一NIMDeviceType下设备将不重复启动,不同的设备会先关闭前一个设备开启新设备

Parameters
type设备类型
devicePath设备路径对应
fps摄像头为采样频率(一般传电源频率取50),其他NIMDeviceType无效(麦克风采样频率由底层控制,播放器采样频率也由底层控制)
StartDeviceInfo启动设备json封装类
handler回调
Returns
无返回值

◆ StartExtendCamera()

static void NIM.DeviceAPI.StartExtendCamera ( string  id,
string  device_path,
uint  fps,
string  json_extension,
StartDeviceResultHandler  handler 
)
static

启动辅助的摄像头,摄像头数据通过SetVideoCaptureDataCb设置采集回调返回,不直接通过视频通话发送给对方,并且不参与设备监听检测

Parameters
id摄像头标识,用于开关及数据回调时的对应,不能为空。(同一id下设备将不重复启动,如果设备device_path不同会先关闭前一个设备开启新设备)
device_path设备路径
fps摄像头为采样频率
json_extension打开摄像头是允许设置 kNIMDeviceWidth 和 kNIMDeviceHeight,并取最接近设置值的画面模式
handler回调

returns>无返回值

◆ StopExtendCamera()

static void NIM.DeviceAPI.StopExtendCamera ( string  id)
static

结束辅助摄像头

Parameters
id摄像头标识id,如果为空,则关闭所有辅助摄像头
Returns
无返回值

Property Documentation

◆ AudioCaptureAutoVolumn

bool NIM.DeviceAPI.AudioCaptureAutoVolumn
staticgetset

设置麦克风音量自动调节, 默认不自动调节

◆ AudioCaptureVolumn

byte NIM.DeviceAPI.AudioCaptureVolumn
staticgetset

音频采集音量,默认255

◆ AudioPlayVolumn

byte NIM.DeviceAPI.AudioPlayVolumn
staticgetset

音频播放音量,默认255