getTalkUrl static method
语音对讲,一般直接使用预览url即可,无需单独请求 'cameraIndexCode' 监控点唯一标识
version 1表示isc1.3版本及以前,2表示isc1.4版本及以后
transmode 协议类型( 0-udp,1-tcp),默认为tcp,
isHttps 是否使用https请求,需要根据实际情况选择参数,
isHttps是否为https请求
Implementation
static Future<dynamic> getTalkUrl({
required String cameraIndexCode,
int transmode = 1,
int version = 2,
bool isHttps = false,
}) async {
if (cameraIndexCode.isEmpty) {
return;
}
///根据版本切换地址,isc1.4之后用v2版本
var talkURLs = talkURLsV2;
if (version == 1) {
talkURLs = talkURLsV1;
}
var headers = ArtemisConfig.createHeaders(talkURLs);
///根据实际服务器情况选用http或https
String url = 'http://${ArtemisConfig.host}$talkURLs';
if (isHttps) {
url = 'https://${ArtemisConfig.host}$talkURLs';
}
Map body = Map();
body['cameraIndexCode'] = cameraIndexCode;
body['transmode'] = transmode;
Dio dio = Dio();
dio.interceptors.add(LogInterceptor(requestBody: true));
// 忽略SSL认证
// (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
// (client) {
// client.badCertificateCallback =
// (X509Certificate cert, String host, int port) {
// return true;
// };
// };
(dio.httpClientAdapter as IOHttpClientAdapter).createHttpClient = (){
var client = HttpClient();
client.badCertificateCallback = (X509Certificate cert, String host, int port) {
return true;
};
return client;
};
dio.options.headers.addAll(headers);
Response response = await dio.post(url, data: body);
return response.data;
}