|
|
|
@ -57,7 +57,7 @@ static int const SESSION_TYPE_MEDIA_INFORMATION = 3; |
|
|
|
|
// EVENTS |
|
|
|
|
static NSString *const EVENT_LOG_CALLBACK_EVENT = @"FFmpegKitLogCallbackEvent"; |
|
|
|
|
static NSString *const EVENT_STATISTICS_CALLBACK_EVENT = @"FFmpegKitStatisticsCallbackEvent"; |
|
|
|
|
static NSString *const EVENT_EXECUTE_CALLBACK_EVENT = @"FFmpegKitCompleteCallbackEvent"; |
|
|
|
|
static NSString *const EVENT_COMPLETE_CALLBACK_EVENT = @"FFmpegKitCompleteCallbackEvent"; |
|
|
|
|
|
|
|
|
|
// ARGUMENT NAMES |
|
|
|
|
static NSString *const ARGUMENT_SESSION_ID = @"sessionId"; |
|
|
|
@ -110,9 +110,19 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)registerGlobalCallbacks { |
|
|
|
|
[FFmpegKitConfig enableExecuteCallback:^(id<Session> session){ |
|
|
|
|
[FFmpegKitConfig enableFFmpegSessionCompleteCallback:^(FFmpegSession* session){ |
|
|
|
|
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session]; |
|
|
|
|
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_EXECUTE_CALLBACK_EVENT withDictionary:dictionary]); |
|
|
|
|
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
[FFmpegKitConfig enableFFprobeSessionCompleteCallback:^(FFprobeSession* session){ |
|
|
|
|
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session]; |
|
|
|
|
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
[FFmpegKitConfig enableMediaInformationSessionCompleteCallback:^(MediaInformationSession* session){ |
|
|
|
|
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session]; |
|
|
|
|
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
[FFmpegKitConfig enableLogCallback: ^(Log* log){ |
|
|
|
@ -222,6 +232,12 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
} else { |
|
|
|
|
result([FlutterError errorWithCode:@"INVALID_ARGUMENTS" message:@"Invalid arguments array." details:nil]); |
|
|
|
|
} |
|
|
|
|
} else if ([@"getMediaInformation" isEqualToString:call.method]) { |
|
|
|
|
if (sessionId != nil) { |
|
|
|
|
[self getMediaInformation:sessionId result:result]; |
|
|
|
|
} else { |
|
|
|
|
result([FlutterError errorWithCode:@"INVALID_SESSION" message:@"Invalid session id." details:nil]); |
|
|
|
|
} |
|
|
|
|
} else if ([@"mediaInformationJsonParserFrom" isEqualToString:call.method]) { |
|
|
|
|
if (ffprobeJsonOutput != nil) { |
|
|
|
|
[self mediaInformationJsonParserFrom:ffprobeJsonOutput result:result]; |
|
|
|
@ -419,6 +435,8 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
[self getFFmpegSessions:result]; |
|
|
|
|
} else if ([@"getFFprobeSessions" isEqualToString:call.method]) { |
|
|
|
|
[self getFFprobeSessions:result]; |
|
|
|
|
} else if ([@"getMediaInformationSessions" isEqualToString:call.method]) { |
|
|
|
|
[self getMediaInformationSessions:result]; |
|
|
|
|
} else if ([@"getPackageName" isEqualToString:call.method]) { |
|
|
|
|
[self getPackageName:result]; |
|
|
|
|
} else if ([@"getExternalLibraries" isEqualToString:call.method]) { |
|
|
|
@ -545,7 +563,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
// FFmpegSession |
|
|
|
|
|
|
|
|
|
- (void)ffmpegSession:(NSArray*)arguments result:(FlutterResult)result { |
|
|
|
|
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; |
|
|
|
|
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; |
|
|
|
|
result([FFmpegKitFlutterPlugin toSessionDictionary:session]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -554,7 +572,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
if (session == nil) { |
|
|
|
|
result([FlutterError errorWithCode:@"SESSION_NOT_FOUND" message:@"Session not found." details:nil]); |
|
|
|
|
} else { |
|
|
|
|
if ([session isMemberOfClass:[FFmpegSession class]]) { |
|
|
|
|
if ([session isFFmpeg]) { |
|
|
|
|
int timeout; |
|
|
|
|
if ([FFmpegKitFlutterPlugin isValidPositiveNumber:waitTimeout]) { |
|
|
|
|
timeout = [waitTimeout intValue]; |
|
|
|
@ -574,7 +592,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
if (session == nil) { |
|
|
|
|
result([FlutterError errorWithCode:@"SESSION_NOT_FOUND" message:@"Session not found." details:nil]); |
|
|
|
|
} else { |
|
|
|
|
if ([session isMemberOfClass:[FFmpegSession class]]) { |
|
|
|
|
if ([session isFFmpeg]) { |
|
|
|
|
NSArray* statistics = [(FFmpegSession*)session getStatistics]; |
|
|
|
|
result([FFmpegKitFlutterPlugin toStatisticsArray:statistics]); |
|
|
|
|
} else { |
|
|
|
@ -586,17 +604,31 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
// FFprobeSession |
|
|
|
|
|
|
|
|
|
- (void)ffprobeSession:(NSArray*)arguments result:(FlutterResult)result { |
|
|
|
|
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; |
|
|
|
|
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; |
|
|
|
|
result([FFmpegKitFlutterPlugin toSessionDictionary:session]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MediaInformationSession |
|
|
|
|
|
|
|
|
|
- (void)mediaInformationSession:(NSArray*)arguments result:(FlutterResult)result { |
|
|
|
|
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:nil withLogCallback:nil]; |
|
|
|
|
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil]; |
|
|
|
|
result([FFmpegKitFlutterPlugin toSessionDictionary:session]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)getMediaInformation:(NSNumber*)sessionId result:(FlutterResult)result { |
|
|
|
|
AbstractSession* session = (AbstractSession*)[FFmpegKitConfig getSession:[sessionId longValue]]; |
|
|
|
|
if (session == nil) { |
|
|
|
|
result([FlutterError errorWithCode:@"SESSION_NOT_FOUND" message:@"Session not found." details:nil]); |
|
|
|
|
} else { |
|
|
|
|
if ([session isMediaInformation]) { |
|
|
|
|
MediaInformationSession *mediaInformationSession = (MediaInformationSession*)session; |
|
|
|
|
result([FFmpegKitFlutterPlugin toMediaInformationDictionary:[mediaInformationSession getMediaInformation]]); |
|
|
|
|
} else { |
|
|
|
|
result([FlutterError errorWithCode:@"NOT_MEDIA_INFORMATION_SESSION" message:@"A session is found but it does not have the correct type." details:nil]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MediaInformationJsonParser |
|
|
|
|
|
|
|
|
|
- (void)mediaInformationJsonParserFrom:(NSString*)ffprobeJsonOutput result:(FlutterResult)result { |
|
|
|
@ -733,7 +765,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
if (session == nil) { |
|
|
|
|
result([FlutterError errorWithCode:@"SESSION_NOT_FOUND" message:@"Session not found." details:nil]); |
|
|
|
|
} else { |
|
|
|
|
if ([session isMemberOfClass:[FFmpegSession class]]) { |
|
|
|
|
if ([session isFFmpeg]) { |
|
|
|
|
dispatch_async(asyncDispatchQueue, ^{ |
|
|
|
|
[FFmpegKitConfig ffmpegExecute:(FFmpegSession*)session]; |
|
|
|
|
result(nil); |
|
|
|
@ -749,7 +781,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
if (session == nil) { |
|
|
|
|
result([FlutterError errorWithCode:@"SESSION_NOT_FOUND" message:@"Session not found." details:nil]); |
|
|
|
|
} else { |
|
|
|
|
if ([session isMemberOfClass:[FFprobeSession class]]) { |
|
|
|
|
if ([session isFFprobe]) { |
|
|
|
|
dispatch_async(asyncDispatchQueue, ^{ |
|
|
|
|
[FFmpegKitConfig ffprobeExecute:(FFprobeSession*)session]; |
|
|
|
|
result(nil); |
|
|
|
@ -765,7 +797,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
if (session == nil) { |
|
|
|
|
result([FlutterError errorWithCode:@"SESSION_NOT_FOUND" message:@"Session not found." details:nil]); |
|
|
|
|
} else { |
|
|
|
|
if ([session isMemberOfClass:[MediaInformationSession class]]) { |
|
|
|
|
if ([session isMediaInformation]) { |
|
|
|
|
int timeout; |
|
|
|
|
if ([FFmpegKitFlutterPlugin isValidPositiveNumber:waitTimeout]) { |
|
|
|
|
timeout = [waitTimeout intValue]; |
|
|
|
@ -787,7 +819,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
if (session == nil) { |
|
|
|
|
result([FlutterError errorWithCode:@"SESSION_NOT_FOUND" message:@"Session not found." details:nil]); |
|
|
|
|
} else { |
|
|
|
|
if ([session isMemberOfClass:[FFmpegSession class]]) { |
|
|
|
|
if ([session isFFmpeg]) { |
|
|
|
|
[FFmpegKitConfig asyncFFmpegExecute:(FFmpegSession*)session]; |
|
|
|
|
result(nil); |
|
|
|
|
} else { |
|
|
|
@ -801,7 +833,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
if (session == nil) { |
|
|
|
|
result([FlutterError errorWithCode:@"SESSION_NOT_FOUND" message:@"Session not found." details:nil]); |
|
|
|
|
} else { |
|
|
|
|
if ([session isMemberOfClass:[FFprobeSession class]]) { |
|
|
|
|
if ([session isFFprobe]) { |
|
|
|
|
[FFmpegKitConfig asyncFFprobeExecute:(FFprobeSession*)session]; |
|
|
|
|
result(nil); |
|
|
|
|
} else { |
|
|
|
@ -815,7 +847,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
if (session == nil) { |
|
|
|
|
result([FlutterError errorWithCode:@"SESSION_NOT_FOUND" message:@"Session not found." details:nil]); |
|
|
|
|
} else { |
|
|
|
|
if ([session isMemberOfClass:[MediaInformationSession class]]) { |
|
|
|
|
if ([session isMediaInformation]) { |
|
|
|
|
int timeout; |
|
|
|
|
if ([FFmpegKitFlutterPlugin isValidPositiveNumber:waitTimeout]) { |
|
|
|
|
timeout = [waitTimeout intValue]; |
|
|
|
@ -1007,7 +1039,11 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
// FFprobeKit |
|
|
|
|
|
|
|
|
|
- (void)getFFprobeSessions:(FlutterResult)result { |
|
|
|
|
result([FFmpegKitFlutterPlugin toSessionArray:[FFprobeKit listSessions]]); |
|
|
|
|
result([FFmpegKitFlutterPlugin toSessionArray:[FFprobeKit listFFprobeSessions]]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)getMediaInformationSessions:(FlutterResult)result { |
|
|
|
|
result([FFmpegKitFlutterPlugin toSessionArray:[FFprobeKit listMediaInformationSessions]]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Packages |
|
|
|
@ -1045,16 +1081,14 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; |
|
|
|
|
dictionary[KEY_SESSION_START_TIME] = [NSNumber numberWithLong:[[session getStartTime] timeIntervalSince1970]*1000]; |
|
|
|
|
dictionary[KEY_SESSION_COMMAND] = [session getCommand]; |
|
|
|
|
|
|
|
|
|
if ([session isFFprobe]) { |
|
|
|
|
if ([(AbstractSession*)session isMemberOfClass:[MediaInformationSession class]]) { |
|
|
|
|
MediaInformationSession *mediaInformationSession = (MediaInformationSession*)session; |
|
|
|
|
dictionary[KEY_SESSION_MEDIA_INFORMATION] = [FFmpegKitFlutterPlugin toMediaInformationDictionary:[mediaInformationSession getMediaInformation]]; |
|
|
|
|
dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_MEDIA_INFORMATION]; |
|
|
|
|
} else { |
|
|
|
|
dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_FFPROBE]; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ([session isFFmpeg]) { |
|
|
|
|
dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_FFMPEG]; |
|
|
|
|
} else if ([session isFFprobe]) { |
|
|
|
|
dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_FFPROBE]; |
|
|
|
|
} else if ([session isMediaInformation]) { |
|
|
|
|
MediaInformationSession *mediaInformationSession = (MediaInformationSession*)session; |
|
|
|
|
dictionary[KEY_SESSION_MEDIA_INFORMATION] = [FFmpegKitFlutterPlugin toMediaInformationDictionary:[mediaInformationSession getMediaInformation]]; |
|
|
|
|
dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_MEDIA_INFORMATION]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return dictionary; |
|
|
|
|