接入声网四路视频
This commit is contained in:
@@ -60,6 +60,11 @@ class HttpApiConsts {
|
||||
// 一键寻车(GET,query 参数 deviceId = 设备编码 MC700-…,不是数字主键)
|
||||
static String get hostSearchDevice => "$baseUrl/iot/host/searchDevice";
|
||||
|
||||
static const hostAgoraTokenPath = '/iot/host/getAgoraToken';
|
||||
static String get hostAgoraToken => '$baseUrl$hostAgoraTokenPath';
|
||||
static const hostStartVideoStreamPath = '/iot/host/startVideoStream';
|
||||
static String get hostStartVideoStream => '$baseUrl$hostStartVideoStreamPath';
|
||||
|
||||
// GET,2=自主任务,3=远程遥控;路径 modeChage 沿用后端协议拼写。
|
||||
static String get hostModeChange => "$baseUrl/iot/host/modeChage";
|
||||
|
||||
|
||||
@@ -30,6 +30,11 @@ import '../../features/device_control_mode/data/datasources/control_mode_remote_
|
||||
import '../../features/device_control_mode/data/repositories/device_control_mode_repository_impl.dart';
|
||||
import '../../features/device_control_mode/domain/repositories/device_control_mode_repository.dart';
|
||||
import '../../features/device_control_mode/domain/usecases/device_control_mode_usecases.dart';
|
||||
import '../../features/pv_control/data/datasources/pv_agora_remote_datasource.dart';
|
||||
import '../../features/pv_control/data/repositories/pv_agora_repository_impl.dart';
|
||||
import '../../features/pv_control/domain/repositories/pv_agora_repository.dart';
|
||||
import '../../features/pv_control/domain/usecases/get_pv_agora_credentials_usecase.dart';
|
||||
import '../../features/pv_control/domain/usecases/start_pv_agora_video_stream_usecase.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -782,6 +787,16 @@ Future<void> init() async {
|
||||
sl.registerLazySingleton(
|
||||
() => ChangeDeviceControlModeUseCase(sl<DeviceControlModeRepository>()),
|
||||
);
|
||||
sl.registerLazySingleton(() => PvAgoraRemoteDataSource(sl<Dio>()));
|
||||
sl.registerLazySingleton<PvAgoraRepository>(
|
||||
() => PvAgoraRepositoryImpl(sl<PvAgoraRemoteDataSource>()),
|
||||
);
|
||||
sl.registerLazySingleton(
|
||||
() => GetPvAgoraCredentialsUseCase(sl<PvAgoraRepository>()),
|
||||
);
|
||||
sl.registerLazySingleton(
|
||||
() => StartPvAgoraVideoStreamUseCase(sl<PvAgoraRepository>()),
|
||||
);
|
||||
sl.registerLazySingleton(
|
||||
() => RegionRemoteDatasource(sl<Dio>(), sl<ILoggerService>()),
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ class DioClient {
|
||||
);
|
||||
|
||||
dio.interceptors.add(
|
||||
LogInterceptor(
|
||||
_ApiLogInterceptor(
|
||||
requestBody: true,
|
||||
responseBody: true,
|
||||
requestHeader: true,
|
||||
@@ -96,3 +96,38 @@ class DioClient {
|
||||
return dio;
|
||||
}
|
||||
}
|
||||
|
||||
class _ApiLogInterceptor extends LogInterceptor {
|
||||
_ApiLogInterceptor({
|
||||
super.requestBody,
|
||||
super.responseBody,
|
||||
super.requestHeader,
|
||||
});
|
||||
|
||||
bool _hasAgoraResponseLog(RequestOptions options) {
|
||||
final path = options.uri.path;
|
||||
return path.endsWith(HttpApiConsts.hostAgoraTokenPath) ||
|
||||
path.endsWith(HttpApiConsts.hostStartVideoStreamPath);
|
||||
}
|
||||
|
||||
@override
|
||||
void onResponse(
|
||||
Response<dynamic> response,
|
||||
ResponseInterceptorHandler handler,
|
||||
) {
|
||||
if (_hasAgoraResponseLog(response.requestOptions)) {
|
||||
handler.next(response);
|
||||
return;
|
||||
}
|
||||
super.onResponse(response, handler);
|
||||
}
|
||||
|
||||
@override
|
||||
void onError(DioException error, ErrorInterceptorHandler handler) {
|
||||
if (_hasAgoraResponseLog(error.requestOptions)) {
|
||||
handler.next(error);
|
||||
return;
|
||||
}
|
||||
super.onError(error, handler);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user