接入声网四路视频
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user