音视频通讯SDK API参考手册  Windows 1.6.0
tencent::av::AVDeviceMgr类 参考abstract

设备管理器的封装类。 更多...

#include <av_device_mgr.h>

Public 类型

typedef void(* DeviceOperationCallback) (AVDeviceMgr *device_mgr, AVDevice::DeviceOperation oper, const std::string &device_id, int32 result, void *custom_data)
 SetDeviceOperationCallback()的回调函数。 更多...
 
typedef void(* DeviceChangeCallback) (AVDeviceMgr *device_mgr, void *custom_data)
 SetDeviceChangeCallback()的回调函数。 更多...
 
typedef void(* OnDeviveDetectNotify) (AVDeviceMgr *device_mgr, DetectedDeviceInfo &info, bool *pbSelect, void *custom_data)
 SetDeviceDetectNotify()的回调函数。 更多...
 

Public 成员函数

virtual void SetDeviceOperationCallback (DeviceOperationCallback device_operation_callback, void *custom_data=NULL)=0
 设置设备操作回调。 更多...
 
virtual void SetDeviceChangeCallback (DeviceChangeCallback device_change_callback, void *custom_data=NULL)=0
 设置设备变更回调。 更多...
 
virtual void SetDeviceDetectNotify (OnDeviveDetectNotify notify, void *custom_data=NULL)=0
 设置设备热插拔通知回调。 更多...
 
virtual void EnableInputDevice (bool is_enable=true)=0
 打开所有选中的输入设备。 更多...
 
virtual void EnableOutputDevice (bool is_enable=true)=0
 打开所有选中的输出设备。 更多...
 
virtual bool IsInputDeviceEnabled ()=0
 输入设备是否打开。 更多...
 
virtual bool IsOutputDeviceEnabled ()=0
 输出设备是否打开。 更多...
 
virtual int32 GetInputDeviceCount ()=0
 获得输入设备数量。 更多...
 
virtual AVDeviceGetInputDevice (int32 index)=0
 获得输入设备。 更多...
 
virtual int32 GetOutputDeviceCount ()=0
 获得输出设备数量。 更多...
 
virtual AVDeviceGetOutputDevice (int32 index)=0
 获取输出设备。 更多...
 
virtual int32 SelectInputDevice (const std::string &device_id, bool is_select=true)=0
 选中/取消选中输入设备。 更多...
 
virtual int32 SelectOutputDevice (const std::string &device_id, bool is_select=true)=0
 选中/取消选中输出设备。 更多...
 
virtual void ClearSelectedDevice (bool is_output)=0
 清空已选设备。 更多...
 
virtual int32 GetSelectedInputDeviceCount ()=0
 获得处于选中状态的输入设备数量。 更多...
 
virtual AVDeviceGetSelectedInputDevice (int32 index)=0
 获取处于选中状态的输入设备。 更多...
 
virtual int32 GetSelectedOutputDeviceCount ()=0
 获取处于选中状态的输出设备数量。 更多...
 
virtual AVDeviceGetSelectedOutputDevice (int32 index)=0
 获得处于选中状态的输出设备。 更多...
 
virtual AVDeviceGetDeviceById (const std::string &device_id)=0
 根据设备ID获取设备。 更多...
 
virtual int32 GetDeviceByType (const std::string &device_type, AVDevice **device_array[])=0
 根据设备类型获取设备。 更多...
 

Protected 成员函数

virtual ~AVDeviceMgr ()
 

详细描述

AVContext::StartContext()执行成功之后,App可以:

  • 通过AVContext::GetAudioDeviceMgr()获得音频对应的AVDeviceMgr对象;
  • 通过AVContext::GetVideoDeviceMgr()获得视频对应的AVDeviceMgr对象。

成员类型定义说明

typedef void(* tencent::av::AVDeviceMgr::DeviceChangeCallback) (AVDeviceMgr *device_mgr, void *custom_data)

此函数是和SetDeviceChangeCallback()一起使用的回调函数,用来通知App发生设备变更。

参数
device_mgr发生设备变更的AVDeviceMgr对象。
custom_data值等于调用SetDeviceOperationCallback()时的入参custom_data。
typedef void(* tencent::av::AVDeviceMgr::DeviceOperationCallback) (AVDeviceMgr *device_mgr, AVDevice::DeviceOperation oper, const std::string &device_id, int32 result, void *custom_data)

此函数是和SetDeviceOperationCallback()一起使用的回调函数,用来异步返回设备操作的执行结果。 大部分设备操作都包含异步执行流程。为了避免App设置大量的异步回调,SDK统一把所有设备的异步回调集中到一起。

参数
device_mgr执行设备操作的AVDeviceMgr对象。
operation设备操作类型,详情见DeviceOperation的定义。
device_id操作对应的设备Id。
result错误码。
custom_data值等于调用SetDeviceOperationCallback()时的入参custom_data。
typedef void(* tencent::av::AVDeviceMgr::OnDeviveDetectNotify) (AVDeviceMgr *device_mgr, DetectedDeviceInfo &info, bool *pbSelect, void *custom_data)

此函数是和SetDeviceDetectNotify()一起使用的回调函数,用来通知App发生设备热插拔的通知。

参数
device_mgr发生设备变更的AVDeviceMgr对象。
info热插拔的设备信息 具体可以查看DetectedDeviceInfo。
pbSelect当新插入设备时,这个值表示是否自动选上新的设备。 当拔除设备时,这个值指的是第一个设备是否自动选上。 这里可以根据info.isUsedDevice和info.isNewDevice做处理,如果这两个都是true的话,就代表当前使用的设备被拔掉。
custom_data值等于调用SetDeviceOperationCallback()时的入参custom_data。

构造及析构函数说明

virtual tencent::av::AVDeviceMgr::~AVDeviceMgr ( )
protectedvirtual

成员函数说明

virtual void tencent::av::AVDeviceMgr::ClearSelectedDevice ( bool  is_output)
pure virtual
参数
is_outputtrue停用输出设备,false停用输入设备。
virtual void tencent::av::AVDeviceMgr::EnableInputDevice ( bool  is_enable = true)
pure virtual

同步返回结果。如果没有特别需要,App不需要调用此接口。平时在进入房间之后,SDK内部 默认会打开所有选中的设备。

参数
[in]is_enabletrue打开,false关闭。
virtual void tencent::av::AVDeviceMgr::EnableOutputDevice ( bool  is_enable = true)
pure virtual

同步返回结果。如果没有特别需要,App不需要调用此接口。平时在进入房间之后,SDK内部 默认会打开所有选中的设备。

参数
[in]is_enabletrue打开,false关闭。
virtual AVDevice* tencent::av::AVDeviceMgr::GetDeviceById ( const std::string &  device_id)
pure virtual
参数
[in]device_id设备Id。
返回
如果存在对应ID的设备,则返回设备,否则返回NULL。
virtual int32 tencent::av::AVDeviceMgr::GetDeviceByType ( const std::string &  device_type,
AVDevice **  device_array[] 
)
pure virtual
参数
[in]device_type设备类型。
[out]device_array设备列表。
返回
device_array对应的size。
备注
device_array的内存由SDK内部分配,App在使用完device_array应该释放对应的内存。
virtual AVDevice* tencent::av::AVDeviceMgr::GetInputDevice ( int32  index)
pure virtual
参数
[in]index设备索引,不能超过GetInputDeviceCount()。
返回
成功返回AVDevice对象,超出索引返回NULL。
virtual int32 tencent::av::AVDeviceMgr::GetInputDeviceCount ( )
pure virtual
返回
输入设备数量。
virtual AVDevice* tencent::av::AVDeviceMgr::GetOutputDevice ( int32  index)
pure virtual
参数
[in]index设备索引,不能超过GetOutputDeviceCount()。
返回
成功返回AVDevice对象,超出索引返回NULL。
virtual int32 tencent::av::AVDeviceMgr::GetOutputDeviceCount ( )
pure virtual
返回
输出设备数量。
virtual AVDevice* tencent::av::AVDeviceMgr::GetSelectedInputDevice ( int32  index)
pure virtual
参数
[in]index设备索引。
返回
成功返回索引对应的设备,否则返回NULL。
virtual int32 tencent::av::AVDeviceMgr::GetSelectedInputDeviceCount ( )
pure virtual
返回
输入设备数量。
virtual AVDevice* tencent::av::AVDeviceMgr::GetSelectedOutputDevice ( int32  index)
pure virtual
参数
index设备索引。
返回
成功则返回索引对应的设备,否则返回NULL。
virtual int32 tencent::av::AVDeviceMgr::GetSelectedOutputDeviceCount ( )
pure virtual
返回
输出设备数量。
virtual bool tencent::av::AVDeviceMgr::IsInputDeviceEnabled ( )
pure virtual
返回
true表示打开,false表示没打开。
virtual bool tencent::av::AVDeviceMgr::IsOutputDeviceEnabled ( )
pure virtual
返回
true表示打开,false表示没打开。
virtual int32 tencent::av::AVDeviceMgr::SelectInputDevice ( const std::string &  device_id,
bool  is_select = true 
)
pure virtual

同步返回结果。App调用此方法选中/取消设备,SDK会自动在合适的时机打开/关闭设备。 这里的时机主要分两种情况:

  • 未进入房间时,选中/取消选中设备不会产生任何变化。
  • 进入房间后,选中/取消选中设备会进行对应的打开/关闭设备。

结果会通过SetDeviceOperationCallback()传入的device_change_callback进行通知。

参数
device_id设备Id。
[in]is_selecttrue选中,false取消选中。
返回
AV_OK表示成功,其他返回值表示失败:
virtual int32 tencent::av::AVDeviceMgr::SelectOutputDevice ( const std::string &  device_id,
bool  is_select = true 
)
pure virtual

同步返回结果。App调用此方法选中/取消设备,SDK会自动在合适的时机打开/关闭设备。 这里的时机主要分两种情况:

  • 未进入房间时,选中/取消选中设备不会产生任何变化。
  • 进入房间后,选中/取消选中设备会进行对应的打开/关闭设备。

结果会通过SetDeviceOperationCallback()传入的device_change_callback进行通知。

参数
device_id设备Id。
[in]is_selecttrue选中,false取消选中。
返回
AV_OK表示成功,其他返回值表示失败。
virtual void tencent::av::AVDeviceMgr::SetDeviceChangeCallback ( DeviceChangeCallback  device_change_callback,
void *  custom_data = NULL 
)
pure virtual

App可以通过设置设备变更回调,在回调函数中处理设备变更。

参数
[in]device_change_callback函数指针,指向App定义的回调函数,NULL表示取消回调。
[in]custom_dataApp指定的一个没有类型的指针,SDK会在回调函数中把该值回传给App。
virtual void tencent::av::AVDeviceMgr::SetDeviceDetectNotify ( OnDeviveDetectNotify  notify,
void *  custom_data = NULL 
)
pure virtual

App可以通过设置设备热插拔通知回调,在回调函数中处理设备变更。 当进入房间后,mic或扬声器插拔会触发这个回调。

参数
[in]notify函数指针,指向App定义的回调函数,NULL表示取消回调。详细的说明请参考OnDeviveDetectNotify的注释
[in]custom_dataApp指定的一个没有类型的指针,SDK会在回调函数中把该值回传给App。
备注
当前仅音频设备支持。
virtual void tencent::av::AVDeviceMgr::SetDeviceOperationCallback ( DeviceOperationCallback  device_operation_callback,
void *  custom_data = NULL 
)
pure virtual

App可以通过设置设备操作回调,在回调函数中获得设备操作的执行结果。

参数
[in]device_operation_callback函数指针,指向App定义的回调函数,NULL表示取消回调。
[in]custom_dataApp指定的一个没有类型的指针,SDK会在回调函数中把该值回传给App。