接入声网四路视频

This commit is contained in:
2026-11-21 14:52:13 +08:00
parent 04fffd2267
commit 739d588a16
26 changed files with 1637 additions and 15 deletions

View File

@@ -0,0 +1,40 @@
import 'package:dio/dio.dart';
import 'package:fpdart/fpdart.dart';
import '../../../../core/error/failure.dart';
import '../../../../core/network/error_handler.dart';
import '../../domain/repositories/pv_agora_repository.dart';
import '../../domain/video/pv_agora_credentials.dart';
import '../datasources/pv_agora_remote_datasource.dart';
class PvAgoraRepositoryImpl implements PvAgoraRepository {
const PvAgoraRepositoryImpl(this.remote);
final PvAgoraRemoteDataSource remote;
@override
Future<Either<Failure, Unit>> startVideoStream(String deviceSn) async {
try {
await remote.startVideoStream(deviceSn);
return const Right(unit);
} on FormatException catch (error) {
return Left(ServerFailure('开启推流失败(${error.message})'));
} on DioException catch (error) {
final reason = ErrorHandler.getErrorMessage(error);
return Left(NetworkFailure('开启推流失败($reason)'));
}
}
@override
Future<Either<Failure, PvAgoraCredentials>> getCredentials(
String deviceSn,
) async {
try {
return Right(await remote.getCredentials(deviceSn));
} on FormatException catch (error) {
return Left(ServerFailure(error.message));
} on DioException catch (error) {
return Left(NetworkFailure(ErrorHandler.getErrorMessage(error)));
}
}
}