feat: add clearSession method for flutter ios

pull/1067/head
Hakim 7 months ago
parent d80b767768
commit 6db0d020d5
  1. 11
      flutter/flutter/ios/Classes/FFmpegKitFlutterPlugin.m
  2. 12
      flutter/flutter/lib/ffmpeg_kit_config.dart
  3. 4
      flutter/flutter_platform_interface/lib/ffmpeg_kit_flutter_platform_interface.dart
  4. 4
      flutter/flutter_platform_interface/lib/method_channel_ffmpeg_kit_flutter.dart

@ -395,6 +395,12 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
[self getSessions:result];
} else if ([@"clearSessions" isEqualToString:call.method]) {
[self clearSessions:result];
} else if ([@"clearSession" isEqualToString:call.method]) {
if (sessionId != nil) {
[self clearSession:sessionId result:result];
} else {
result([FlutterError errorWithCode:@"INVALID_SESSION" message:@"Invalid session id." details:nil]);
}
} else if ([@"getSessionsByState" isEqualToString:call.method]) {
NSNumber* stateIndex = call.arguments[@"state"];
if (stateIndex != nil) {
@ -909,6 +915,11 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
result([FFmpegKitFlutterPlugin toSessionArray:[FFmpegKitConfig getSessions]]);
}
- (void)clearSession:(NSNumber*)sessionId result:(FlutterResult)result {
[FFmpegKitConfig clearSession:[sessionId longValue]];
result(nil);
}
- (void)clearSessions:(FlutterResult)result {
[FFmpegKitConfig clearSessions];
result(nil);

@ -496,6 +496,18 @@ class FFmpegKitConfig {
}
}
/// Deletes a session from the session history.
/// Note that callbacks cannot be triggered for deleted sessions.
static Future<void> clearSession(int sessionId) async {
try {
await init();
return _platform.clearSession(sessionId);
} on PlatformException catch (e, stack) {
print("Plugin clearSession error: ${e.message}");
return Future.error("clearSession failed.", stack);
}
}
/// Clears all, including ongoing, sessions in the session history.
/// Note that callbacks cannot be triggered for deleted sessions.
static Future<void> clearSessions() async {

@ -272,6 +272,10 @@ abstract class FFmpegKitPlatform extends PlatformInterface {
'ffmpegKitConfigGetSessions() has not been implemented!');
}
Future<void> clearSession(int sessionId) async {
throw UnimplementedError('clearSession() has not been implemented!');
}
Future<void> clearSessions() async {
throw UnimplementedError('clearSessions() has not been implemented!');
}

@ -243,6 +243,10 @@ class MethodChannelFFmpegKit extends FFmpegKitPlatform {
Future<List<dynamic>?> ffmpegKitConfigGetSessions() async =>
_channel.invokeMethod<List<dynamic>>('getSessions');
@override
Future<void> clearSession(int sessionId) async =>
_channel.invokeMethod<void>('clearSession', {'sessionId': sessionId});
@override
Future<void> clearSessions() async =>
_channel.invokeMethod<void>('clearSessions');

Loading…
Cancel
Save