更新時間:2019-11-20
管理音視頻設(shè)備,包括麥克風(fēng)、揚聲器和攝像頭。
應(yīng)用程序在任何階段均可以獲取當(dāng)前可用的音視頻設(shè)備信息,為更方便地進(jìn)行后繼具體設(shè)備管理,建議應(yīng)用程序在初始化階段和系統(tǒng)檢測到設(shè)備變化時,獲取設(shè)備信息并保存維護(hù)。
代碼示例:
-(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; }
管理音頻設(shè)備
一般用于用戶對音頻設(shè)備(麥克風(fēng)和揚聲器)進(jìn)行設(shè)置和切換。
移動的音頻設(shè)備包括:藍(lán)牙、聽筒和耳機
代碼示例:
-(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; }
管理視頻設(shè)備
一般用于用戶對攝像頭進(jìn)行設(shè)置和切換。
代碼示例:
-(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; }
預(yù)覽本地視頻
一般用于設(shè)備設(shè)置時,檢測本地攝像頭工作狀態(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(); }
無。