更新時間:2019-11-20
管理音視頻設備,包括麥克風、揚聲器和攝像頭。
應用程序在任何階段均可以獲取當前可用的音視頻設備信息,為更方便地進行后繼具體設備管理,建議應用程序在初始化階段和系統(tǒng)檢測到設備變化時,獲取設備信息并保存維護。
代碼示例:
-(BOOL)obtainDeviceListWityType:(DEVICE_TYPE)deviceType { TSDK_UINT32 deviceNum = 0; TSDK_S_DEVICE_INFO *deviceInfo = nullptr; memset(deviceInfo, 0, sizeof(TSDK_S_DEVICE_INFO)); TSDK_RESULT ret = tsdk_get_devices((TSDK_E_DEVICE_TYPE)deviceType, &deviceNum, deviceInfo); DDLogInfo(@"Call_Log: tsdk_get_devices = %#x,count:%d",ret,deviceNum); if (deviceNum>0) { DDLogInfo(@"again"); deviceInfo = new TSDK_S_DEVICE_INFO[deviceNum]; TSDK_RESULT rets = tsdk_get_devices((TSDK_E_DEVICE_TYPE)deviceType, &deviceNum, deviceInfo); DDLogInfo(@"Call_Log: tsdk_get_devices = %#x,count:%d",rets,deviceNum); for (int i = 0; i<deviceNum; i++) { DDLogInfo(@"Call_Log: ulIndex:%d,strName:%s,string:%@",deviceInfo[i].index,deviceInfo[i].device_name,[NSString stringWithUTF8String:deviceInfo[i].device_name]); } } delete [] deviceInfo; return ret == TSDK_SUCCESS ? YES : NO; }
管理音頻設備
一般用于用戶對音頻設備(麥克風和揚聲器)進行設置和切換。
移動的音頻設備包括:藍牙、聽筒和耳機
代碼示例:
-(BOOL)configAudioRoute:(ROUTE_TYPE)route { TSDK_E_MOBILE_AUIDO_ROUTE audioRoute = (TSDK_E_MOBILE_AUIDO_ROUTE)route; TSDK_RESULT result = tsdk_set_mobile_audio_route(audioRoute); DDLogInfo(@"tsdk_set_mobile_audio_route result is %@, audioRoute is :%d",result == TSDK_SUCCESS ? @"YES" : @"NO",audioRoute); return result == TSDK_SUCCESS ? YES : NO; }
代碼示例:
-(ROUTE_TYPE)obtainMobileAudioRoute { TSDK_E_MOBILE_AUIDO_ROUTE route; TSDK_RESULT result = tsdk_get_mobile_audio_route(&route); DDLogInfo(@"tsdk_get_mobile_audio_route result is %d, audioRoute is :%d",result,route); return (ROUTE_TYPE)route; }
管理視頻設備
一般用于用戶對攝像頭進行設置和切換。
代碼示例:
-(BOOL)switchCameraIndex:(NSUInteger)cameraCaptureIndex callId:(unsigned int)callId { TSDK_S_VIDEO_ORIENT orient; memset(&orient, 0, sizeof(TSDK_S_VIDEO_ORIENT)); orient.choice = 1; orient.portrait = 0; orient.landscape = 0; orient.seascape = 1; TSDK_RESULT result = tsdk_set_video_orient(callId, (TSDK_UINT32)cameraCaptureIndex, &orient); if (result == TSDK_SUCCESS) { _cameraCaptureIndex = cameraCaptureIndex == 1 ? CameraIndexFront : CameraIndexBack; } [self updateVideoRenderInfoWithVideoIndex:(CameraIndex)cameraCaptureIndex withRenderType:TSDK_E_VIDEO_WND_LOCAL andCallId:callId]; return result == TSDK_SUCCESS ? YES : NO; }
預覽本地視頻
一般用于設備設置時,檢測本地攝像頭工作狀態(tài)是否正常。
代碼示例:
- (BOOL)videoPreview:(unsigned int)cameraIndex toView:(id) viewHandler { _videoPreview = viewHandler; TSDK_RESULT ret = tsdk_open_video_preview((TSDK_UPTR)viewHandler, (TSDK_UINT32)cameraIndex); DDLogInfo(@"Camera_Log:tsdk_open_video_preview result is %d", ret); return ret == TSDK_SUCCESS ? YES : NO; }
代碼示例:
-(void)stopVideoPreview { tsdk_close_video_preview(); }
無。