From 06a736fda4e78fee9a7fc1e581314c51d49d34f7 Mon Sep 17 00:00:00 2001 From: Taner Sener Date: Tue, 16 Feb 2021 13:15:00 +0000 Subject: [PATCH] replace delegates with callback blocks on objective c api --- apple/src/AbstractSession.h | 6 +- apple/src/AbstractSession.m | 22 +-- .../{ExecuteDelegate.h => ExecuteCallback.h} | 23 +-- apple/src/FFmpegKit.h | 60 ++++---- apple/src/FFmpegKit.m | 32 ++--- apple/src/FFmpegKitConfig.h | 38 ++--- apple/src/FFmpegKitConfig.m | 132 +++++++++--------- apple/src/FFmpegSession.h | 28 ++-- apple/src/FFmpegSession.m | 34 ++--- apple/src/FFprobeKit.h | 72 +++++----- apple/src/FFprobeKit.m | 52 +++---- apple/src/FFprobeSession.h | 16 +-- apple/src/FFprobeSession.m | 18 +-- apple/src/{LogDelegate.h => LogCallback.h} | 18 +-- apple/src/LogRedirectionStrategy.h | 6 +- apple/src/Makefile.am | 6 +- apple/src/Makefile.in | 6 +- apple/src/MediaInformationSession.h | 10 +- apple/src/MediaInformationSession.m | 14 +- apple/src/Session.h | 18 ++- ...tisticsDelegate.h => StatisticsCallback.h} | 18 +-- scripts/function-apple.sh | 22 ++- 22 files changed, 318 insertions(+), 333 deletions(-) rename apple/src/{ExecuteDelegate.h => ExecuteCallback.h} (79%) rename apple/src/{LogDelegate.h => LogCallback.h} (74%) rename apple/src/{StatisticsDelegate.h => StatisticsCallback.h} (71%) diff --git a/apple/src/AbstractSession.h b/apple/src/AbstractSession.h index d1e2566..31dfc9a 100644 --- a/apple/src/AbstractSession.h +++ b/apple/src/AbstractSession.h @@ -38,11 +38,11 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; * Creates a new abstract session. * * @param arguments command arguments - * @param executeDelegate session specific execute delegate - * @param logDelegate session specific log delegate + * @param executeCallback session specific execute callback + * @param logCallback session specific log callback * @param logRedirectionStrategy session specific log redirection strategy */ -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; /** * Waits for all asynchronous messages to be transmitted until the given timeout. diff --git a/apple/src/AbstractSession.m b/apple/src/AbstractSession.m index f7b17d0..8fadf9e 100644 --- a/apple/src/AbstractSession.m +++ b/apple/src/AbstractSession.m @@ -19,10 +19,10 @@ #import "AbstractSession.h" #import "AtomicLong.h" -#import "ExecuteDelegate.h" +#import "ExecuteCallback.h" #import "FFmpegKit.h" #import "FFmpegKitConfig.h" -#import "LogDelegate.h" +#import "LogCallback.h" #import "ReturnCode.h" int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit = 5000; @@ -31,8 +31,8 @@ static AtomicLong *sessionIdGenerator = nil; @implementation AbstractSession { long _sessionId; - id _executeDelegate; - id _logDelegate; + ExecuteCallback _executeCallback; + LogCallback _logCallback; NSDate* _createTime; NSDate* _startTime; NSDate* _endTime; @@ -49,12 +49,12 @@ static AtomicLong *sessionIdGenerator = nil; sessionIdGenerator = [[AtomicLong alloc] initWithValue:1]; } -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { self = [super init]; if (self) { _sessionId = [sessionIdGenerator incrementAndGet]; - _executeDelegate = executeDelegate; - _logDelegate = logDelegate; + _executeCallback = executeCallback; + _logCallback = logCallback; _createTime = [NSDate date]; _startTime = nil; _endTime = nil; @@ -70,12 +70,12 @@ static AtomicLong *sessionIdGenerator = nil; return self; } -- (id)getExecuteDelegate { - return _executeDelegate; +- (ExecuteCallback)getExecuteCallback { + return _executeCallback; } -- (id)getLogDelegate { - return _logDelegate; +- (LogCallback)getLogCallback { + return _logCallback; } - (long)getSessionId { diff --git a/apple/src/ExecuteDelegate.h b/apple/src/ExecuteCallback.h similarity index 79% rename from apple/src/ExecuteDelegate.h rename to apple/src/ExecuteCallback.h index 706fab9..44e113d 100644 --- a/apple/src/ExecuteDelegate.h +++ b/apple/src/ExecuteCallback.h @@ -17,18 +17,15 @@ * along with FFmpegKit. If not, see . */ -#ifndef FFMPEG_KIT_EXECUTE_DELEGATE_H -#define FFMPEG_KIT_EXECUTE_DELEGATE_H - -#import -#import "Session.h" +#ifndef FFMPEG_KIT_EXECUTE_CALLBACK_H +#define FFMPEG_KIT_EXECUTE_CALLBACK_H @protocol Session; /** - *

Delegate invoked when an asynchronous session ends running. + *

Callback invoked when an asynchronous session ends running. *

Session has either SessionStateCompleted or SessionStateFailed state when - * the delegate is invoked. + * the callback is invoked. *

If it has SessionStateCompleted state, ReturnCode should be checked to * see the execution result. *

If getState returns SessionStateFailed then @@ -43,17 +40,11 @@ * break; * } * - */ -@protocol ExecuteDelegate -@required - -/** - * Called when an execution is completed. * * @param session session of the completed execution */ -- (void)executeCallback:(id)session; +typedef void (^ExecuteCallback)(id session); -@end +#import "Session.h" -#endif // FFMPEG_KIT_EXECUTE_DELEGATE_H +#endif // FFMPEG_KIT_EXECUTE_CALLBACK_H diff --git a/apple/src/FFmpegKit.h b/apple/src/FFmpegKit.h index 50be34f..f90a15f 100644 --- a/apple/src/FFmpegKit.h +++ b/apple/src/FFmpegKit.h @@ -23,10 +23,10 @@ #import #import #import -#import "ExecuteDelegate.h" -#import "LogDelegate.h" +#import "ExecuteCallback.h" +#import "LogCallback.h" #import "FFmpegSession.h" -#import "StatisticsDelegate.h" +#import "StatisticsCallback.h" /** *

Main class to run FFmpeg commands. Supports executing commands both @@ -34,11 +34,11 @@ *

  * FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v libxvid file1.avi"];
  *
- * FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withExecuteDelegate:executeDelegate];
+ * FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withExecuteCallback:executeCallback];
  * 
- *

Provides overloaded execute methods to define session specific delegates. + *

Provides overloaded execute methods to define session specific callbacks. *

- * FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withStatisticsDelegate:statisticsDelegate];
+ * FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
  * 
*/ @interface FFmpegKit : NSObject @@ -55,43 +55,43 @@ *

Asynchronously executes FFmpeg with arguments provided. * * @param arguments FFmpeg command options/arguments as string array - * @param executeDelegate delegate that will be called when the execution is completed + * @param executeCallback callback that will be called when the execution is completed * @return FFmpeg session created for this execution */ -+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate; ++ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; /** *

Asynchronously executes FFmpeg with arguments provided. * * @param arguments FFmpeg command options/arguments as string array - * @param executeDelegate delegate that will be called when the execution is completed - * @param logDelegate delegate that will receive logs - * @param statisticsDelegate delegate that will receive statistics + * @param executeCallback callback that will be called when the execution is completed + * @param logCallback callback that will receive logs + * @param statisticsCallback callback that will receive statistics * @return FFmpeg session created for this execution */ -+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate; ++ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; /** *

Asynchronously executes FFmpeg with arguments provided. * * @param arguments FFmpeg command options/arguments as string array - * @param executeDelegate delegate that will be called when the execution is completed + * @param executeCallback callback that will be called when the execution is completed * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFmpeg session created for this execution */ -+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate onDispatchQueue:(dispatch_queue_t)queue; ++ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; /** *

Asynchronously executes FFmpeg with arguments provided. * * @param arguments FFmpeg command options/arguments as string array - * @param executeDelegate delegate that will be called when the execution is completed - * @param logDelegate delegate that will receive logs - * @param statisticsDelegate delegate that will receive statistics + * @param executeCallback callback that will be called when the execution is completed + * @param logCallback callback that will receive logs + * @param statisticsCallback callback that will receive statistics * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFmpeg session created for this execution */ -+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate onDispatchQueue:(dispatch_queue_t)queue; ++ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue; /** *

Synchronously executes FFmpeg command provided. Space character is used to split command @@ -109,10 +109,10 @@ * your command. * * @param command FFmpeg command - * @param executeDelegate delegate that will be called when the execution is completed + * @param executeCallback callback that will be called when the execution is completed * @return FFmpeg session created for this execution */ -+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate; ++ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback; /** *

Asynchronously executes FFmpeg command provided. Space character is used to split command @@ -120,12 +120,12 @@ * your command. * * @param command FFmpeg command - * @param executeDelegate delegate that will be called when the execution is completed - * @param logDelegate delegate that will receive logs - * @param statisticsDelegate delegate that will receive statistics + * @param executeCallback callback that will be called when the execution is completed + * @param logCallback callback that will receive logs + * @param statisticsCallback callback that will receive statistics * @return FFmpeg session created for this execution */ -+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate; ++ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; /** *

Asynchronously executes FFmpeg command provided. Space character is used to split command @@ -133,11 +133,11 @@ * your command. * * @param command FFmpeg command - * @param executeDelegate delegate that will be called when the execution is completed + * @param executeCallback callback that will be called when the execution is completed * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFmpeg session created for this execution */ -+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate onDispatchQueue:(dispatch_queue_t)queue; ++ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; /** *

Asynchronously executes FFmpeg command provided. Space character is used to split command @@ -145,13 +145,13 @@ * your command. * * @param command FFmpeg command - * @param executeDelegate delegate that will be called when the execution is completed - * @param logDelegate delegate that will receive logs - * @param statisticsDelegate delegate that will receive statistics + * @param executeCallback callback that will be called when the execution is completed + * @param logCallback callback that will receive logs + * @param statisticsCallback callback that will receive statistics * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFmpeg session created for this execution */ -+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate onDispatchQueue:(dispatch_queue_t)queue; ++ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue; /** *

Cancels all running sessions. diff --git a/apple/src/FFmpegKit.m b/apple/src/FFmpegKit.m index c5e957f..3621d5e 100644 --- a/apple/src/FFmpegKit.m +++ b/apple/src/FFmpegKit.m @@ -38,26 +38,26 @@ return session; } -+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate { - FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteDelegate:executeDelegate]; ++ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback { + FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncFFmpegExecute:session]; return session; } -+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate { - FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withStatisticsDelegate:statisticsDelegate]; ++ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback { + FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; [FFmpegKitConfig asyncFFmpegExecute:session]; return session; } -+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate onDispatchQueue:(dispatch_queue_t)queue { - FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteDelegate:executeDelegate]; ++ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue { + FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; return session; } -+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate onDispatchQueue:(dispatch_queue_t)queue { - FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withStatisticsDelegate:statisticsDelegate]; ++ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue { + FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; return session; } @@ -68,26 +68,26 @@ return session; } -+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate { - FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate]; ++ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback { + FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncFFmpegExecute:session]; return session; } -+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate { - FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withStatisticsDelegate:statisticsDelegate]; ++ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback { + FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; [FFmpegKitConfig asyncFFmpegExecute:session]; return session; } -+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate onDispatchQueue:(dispatch_queue_t)queue { - FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate]; ++ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue { + FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; return session; } -+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate onDispatchQueue:(dispatch_queue_t)queue { - FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withStatisticsDelegate:statisticsDelegate]; ++ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue { + FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; return session; } diff --git a/apple/src/FFmpegKitConfig.h b/apple/src/FFmpegKitConfig.h index dda9863..c3ebeaa 100644 --- a/apple/src/FFmpegKitConfig.h +++ b/apple/src/FFmpegKitConfig.h @@ -24,12 +24,12 @@ #import #import #import -#import "ExecuteDelegate.h" +#import "ExecuteCallback.h" #import "FFmpegSession.h" #import "FFprobeSession.h" -#import "LogDelegate.h" +#import "LogCallback.h" #import "MediaInformationSession.h" -#import "StatisticsDelegate.h" +#import "StatisticsCallback.h" /** Global library version */ extern NSString* const FFmpegKitVersion; @@ -53,7 +53,7 @@ typedef NS_ENUM(NSUInteger, Signal) { * *

When redirection is enabled FFmpeg/FFprobe logs are redirected to NSLog and sessions * collect log and statistics entries for the executions. It is possible to define global or - * session specific log/statistics delegates as well. + * session specific log/statistics callbacks as well. * *

Note that redirection is enabled by default. If you do not want to use its functionality * please use disableRedirection method to disable it. @@ -64,7 +64,7 @@ typedef NS_ENUM(NSUInteger, Signal) { *

Disables log and statistics redirection. * *

When redirection is disabled logs are printed to stderr, all logs and statistics - * delegates are disabled and FFprobe's getMediaInformation methods + * callbacks are disabled and FFprobe's getMediaInformation methods * do not work. */ + (void)disableRedirection; @@ -236,32 +236,32 @@ typedef NS_ENUM(NSUInteger, Signal) { + (void)asyncGetMediaInformationExecute:(MediaInformationSession*)mediaInformationSession onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; /** - *

Sets a global log delegate to redirect FFmpeg/FFprobe logs. + *

Sets a global log callback to redirect FFmpeg/FFprobe logs. * - * @param logDelegate log delegate or nil to disable a previously defined log delegate + * @param logCallback log callback or nil to disable a previously defined log callback */ -+ (void)enableLogDelegate:(id)logDelegate; ++ (void)enableLogCallback:(LogCallback)logCallback; /** - *

Sets a global statistics delegate to redirect FFmpeg statistics. + *

Sets a global statistics callback to redirect FFmpeg statistics. * - * @param statisticsDelegate statistics delegate or nil to disable a previously defined statistics delegate + * @param statisticsCallback statistics callback or nil to disable a previously defined statistics callback */ -+ (void)enableStatisticsDelegate:(id)statisticsDelegate; ++ (void)enableStatisticsCallback:(StatisticsCallback)statisticsCallback; /** - *

Sets a global execute delegate to receive execution results. + *

Sets a global execute callback to receive execution results. * - * @param executeDelegate execute delegate or nil to disable a previously execute delegate + * @param executeCallback execute callback or nil to disable a previously execute callback */ -+ (void)enableExecuteDelegate:(id)executeDelegate; ++ (void)enableExecuteCallback:(ExecuteCallback)executeCallback; /** - *

Returns the global execute delegate. + *

Returns the global execute callback. * - * @return global execute delegate + * @return global execute callback */ -+ (id)getExecuteDelegate; ++ (ExecuteCallback)getExecuteCallback; /** * Returns the current log level. @@ -365,11 +365,11 @@ typedef NS_ENUM(NSUInteger, Signal) { + (void)setLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; /** - *

Returns the number of async messages that are not transmitted to the delegates for + *

Returns the number of async messages that are not transmitted to the callbacks for * this session. * * @param sessionId id of the session - * @return number of async messages that are not transmitted to the delegates for this session + * @return number of async messages that are not transmitted to the callbacks for this session */ + (int)messagesInTransmit:(long)sessionId; diff --git a/apple/src/FFmpegKitConfig.m b/apple/src/FFmpegKitConfig.m index cf379ef..60bbfb8 100644 --- a/apple/src/FFmpegKitConfig.m +++ b/apple/src/FFmpegKitConfig.m @@ -60,14 +60,14 @@ static atomic_int sessionInTransitMessageCountMap[SESSION_MAP_SIZE]; static dispatch_queue_t asyncDispatchQueue; -/** Holds delegate defined to redirect logs */ -static id logDelegate; +/** Holds callback defined to redirect logs */ +static LogCallback logCallback; -/** Holds delegate defined to redirect statistics */ -static id statisticsDelegate; +/** Holds callback defined to redirect statistics */ +static StatisticsCallback statisticsCallback; -/** Holds delegate defined to redirect asynchronous execution results */ -static id executeDelegate; +/** Holds callback defined to redirect asynchronous execution results */ +static ExecuteCallback executeCallback; static LogRedirectionStrategy globalLogRedirectionStrategy; @@ -364,8 +364,8 @@ void ffmpegkit_statistics_callback_function(int frameNumber, float fps, float qu void process_log(long sessionId, int levelValue, NSString* logMessage) { int activeLogLevel = av_log_get_level(); Log* log = [[Log alloc] init:sessionId:levelValue:logMessage]; - BOOL globalDelegateDefined = false; - BOOL sessionDelegateDefined = false; + BOOL globalCallbackDefined = false; + BOOL sessionCallbackDefined = false; LogRedirectionStrategy activeLogRedirectionStrategy = globalLogRedirectionStrategy; // LevelAVLogStdErr logs are always redirected @@ -378,30 +378,31 @@ void process_log(long sessionId, int levelValue, NSString* logMessage) { if (session != nil) { activeLogRedirectionStrategy = [session getLogRedirectionStrategy]; [session addLog:log]; - - if ([session getLogDelegate] != nil) { - sessionDelegateDefined = TRUE; + + LogCallback sessionLogCallback = [session getLogCallback]; + if (sessionLogCallback != nil) { + sessionCallbackDefined = TRUE; @try { - // NOTIFY SESSION DELEGATE DEFINED - [[session getLogDelegate] logCallback:log]; + // NOTIFY SESSION CALLBACK DEFINED + sessionLogCallback(log); } @catch(NSException* exception) { - NSLog(@"Exception thrown inside session LogDelegate block. %@", [exception callStackSymbols]); + NSLog(@"Exception thrown inside session LogCallback block. %@", [exception callStackSymbols]); } } } - id activeLogDelegate = logDelegate; - if (activeLogDelegate != nil) { - globalDelegateDefined = TRUE; + LogCallback globalLogCallback = logCallback; + if (globalLogCallback != nil) { + globalCallbackDefined = TRUE; @try { - // NOTIFY GLOBAL DELEGATE DEFINED - [activeLogDelegate logCallback:log]; + // NOTIFY GLOBAL CALLBACK DEFINED + globalLogCallback(log); } @catch(NSException* exception) { - NSLog(@"Exception thrown inside global LogDelegate block. %@", [exception callStackSymbols]); + NSLog(@"Exception thrown inside global LogCallback block. %@", [exception callStackSymbols]); } } @@ -410,19 +411,19 @@ void process_log(long sessionId, int levelValue, NSString* logMessage) { case LogRedirectionStrategyNeverPrintLogs: { return; } - case LogRedirectionStrategyPrintLogsWhenGlobalDelegateNotDefined: { - if (globalDelegateDefined) { + case LogRedirectionStrategyPrintLogsWhenGlobalCallbackNotDefined: { + if (globalCallbackDefined) { return; } } break; - case LogRedirectionStrategyPrintLogsWhenSessionDelegateNotDefined: { - if (sessionDelegateDefined) { + case LogRedirectionStrategyPrintLogsWhenSessionCallbackNotDefined: { + if (sessionCallbackDefined) { return; } } - case LogRedirectionStrategyPrintLogsWhenNoDelegatesDefined: { - if (globalDelegateDefined || sessionDelegateDefined) { + case LogRedirectionStrategyPrintLogsWhenNoCallbacksDefined: { + if (globalCallbackDefined || sessionCallbackDefined) { return; } } @@ -450,30 +451,31 @@ void process_statistics(long sessionId, int videoFrameNumber, float videoFps, fl if (session != nil && [session isFFmpeg]) { FFmpegSession *ffmpegSession = (FFmpegSession*)session; [ffmpegSession addStatistics:statistics]; - - if ([ffmpegSession getStatisticsDelegate] != nil) { + + StatisticsCallback sessionStatisticsCallback = [ffmpegSession getStatisticsCallback]; + if (sessionStatisticsCallback != nil) { @try { - [[ffmpegSession getStatisticsDelegate] statisticsCallback:statistics]; + sessionStatisticsCallback(statistics); } @catch(NSException* exception) { - NSLog(@"Exception thrown inside session StatisticsDelegate block. %@", [exception callStackSymbols]); + NSLog(@"Exception thrown inside session StatisticsCallback block. %@", [exception callStackSymbols]); } } } - id activeStatisticsDelegate = statisticsDelegate; - if (activeStatisticsDelegate != nil) { + StatisticsCallback globalStatisticsCallback = statisticsCallback; + if (globalStatisticsCallback != nil) { @try { - [activeStatisticsDelegate statisticsCallback:statistics]; + globalStatisticsCallback(statistics); } @catch(NSException* exception) { - NSLog(@"Exception thrown inside global StatisticsDelegate block. %@", [exception callStackSymbols]); + NSLog(@"Exception thrown inside global StatisticsCallback block. %@", [exception callStackSymbols]); } } } /** - * Forwards asynchronous messages to Delegates. + * Forwards asynchronous messages to Callbacks. */ void callbackBlockFunction() { int activeLogLevel = av_log_get_level(); @@ -624,11 +626,11 @@ int executeFFprobe(long sessionId, NSArray* arguments) { asyncDispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); - logDelegate = nil; - statisticsDelegate = nil; - executeDelegate = nil; + logCallback = nil; + statisticsCallback = nil; + executeCallback = nil; - globalLogRedirectionStrategy = LogRedirectionStrategyPrintLogsWhenNoDelegatesDefined; + globalLogRedirectionStrategy = LogRedirectionStrategyPrintLogsWhenNoCallbacksDefined; redirectionEnabled = 0; lock = [[NSRecursiveLock alloc] init]; @@ -885,14 +887,14 @@ int executeFFprobe(long sessionId, NSArray* arguments) { + (void)asyncFFmpegExecute:(FFmpegSession*)ffmpegSession onDispatchQueue:(dispatch_queue_t)queue { dispatch_async(queue, ^{ [FFmpegKitConfig ffmpegExecute:ffmpegSession]; - id globalExecuteDelegate = [FFmpegKitConfig getExecuteDelegate]; - if (globalExecuteDelegate != nil) { - [globalExecuteDelegate executeCallback:ffmpegSession]; + ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; + if (globalExecuteCallback != nil) { + globalExecuteCallback(ffmpegSession); } - id executeDelegate = [ffmpegSession getExecuteDelegate]; - if (executeDelegate != nil) { - [executeDelegate executeCallback:ffmpegSession]; + ExecuteCallback sessionExecuteCallback = [ffmpegSession getExecuteCallback]; + if (sessionExecuteCallback != nil) { + sessionExecuteCallback(ffmpegSession); } }); } @@ -904,14 +906,14 @@ int executeFFprobe(long sessionId, NSArray* arguments) { + (void)asyncFFprobeExecute:(FFprobeSession*)ffprobeSession onDispatchQueue:(dispatch_queue_t)queue { dispatch_async(queue, ^{ [FFmpegKitConfig ffprobeExecute:ffprobeSession]; - id globalExecuteDelegate = [FFmpegKitConfig getExecuteDelegate]; - if (globalExecuteDelegate != nil) { - [globalExecuteDelegate executeCallback:ffprobeSession]; + ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; + if (globalExecuteCallback != nil) { + globalExecuteCallback(ffprobeSession); } - id executeDelegate = [ffprobeSession getExecuteDelegate]; - if (executeDelegate != nil) { - [executeDelegate executeCallback:ffprobeSession]; + ExecuteCallback sessionExecuteCallback = [ffprobeSession getExecuteCallback]; + if (sessionExecuteCallback != nil) { + sessionExecuteCallback(ffprobeSession); } }); } @@ -923,32 +925,32 @@ int executeFFprobe(long sessionId, NSArray* arguments) { + (void)asyncGetMediaInformationExecute:(MediaInformationSession*)mediaInformationSession onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { dispatch_async(queue, ^{ [FFmpegKitConfig getMediaInformationExecute:mediaInformationSession withTimeout:waitTimeout]; - id globalExecuteDelegate = [FFmpegKitConfig getExecuteDelegate]; - if (globalExecuteDelegate != nil) { - [globalExecuteDelegate executeCallback:mediaInformationSession]; + ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; + if (globalExecuteCallback != nil) { + globalExecuteCallback(mediaInformationSession); } - id executeDelegate = [mediaInformationSession getExecuteDelegate]; - if (executeDelegate != nil) { - [executeDelegate executeCallback:mediaInformationSession]; + ExecuteCallback sessionExecuteCallback = [mediaInformationSession getExecuteCallback]; + if (sessionExecuteCallback != nil) { + sessionExecuteCallback(mediaInformationSession); } }); } -+ (void)enableLogDelegate:(id)delegate { - logDelegate = delegate; ++ (void)enableLogCallback:(LogCallback)callback { + logCallback = callback; } -+ (void)enableStatisticsDelegate:(id)delegate { - statisticsDelegate = delegate; ++ (void)enableStatisticsCallback:(StatisticsCallback)callback { + statisticsCallback = callback; } -+ (void)enableExecuteDelegate:(id)delegate { - executeDelegate = delegate; ++ (void)enableExecuteCallback:(ExecuteCallback)callback { + executeCallback = callback; } -+ (id)getExecuteDelegate { - return executeDelegate; ++ (ExecuteCallback)getExecuteCallback { + return executeCallback; } + (int)getLogLevel { diff --git a/apple/src/FFmpegSession.h b/apple/src/FFmpegSession.h index e90ee33..f63d225 100644 --- a/apple/src/FFmpegSession.h +++ b/apple/src/FFmpegSession.h @@ -22,7 +22,7 @@ #import #import "AbstractSession.h" -#import "StatisticsDelegate.h" +#import "StatisticsCallback.h" /** *

An FFmpeg session. @@ -40,37 +40,37 @@ * Builds a new FFmpeg session. * * @param arguments command arguments - * @param executeDelegate session specific execute delegate + * @param executeCallback session specific execute callback */ -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate; +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; /** * Builds a new FFmpeg session. * * @param arguments command arguments - * @param executeDelegate session specific execute delegate - * @param logDelegate session specific log delegate - * @param statisticsDelegate session specific statistics delegate + * @param executeCallback session specific execute callback + * @param logCallback session specific log callback + * @param statisticsCallback session specific statistics callback */ -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate; +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; /** * Builds a new FFmpeg session. * * @param arguments command arguments - * @param executeDelegate session specific execute delegate - * @param logDelegate session specific log delegate - * @param statisticsDelegate session specific statistics delegate + * @param executeCallback session specific execute callback + * @param logCallback session specific log callback + * @param statisticsCallback session specific statistics callback * @param logRedirectionStrategy session specific log redirection strategy */ -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; /** - * Returns the session specific statistics delegate. + * Returns the session specific statistics callback. * - * @return session specific statistics delegate + * @return session specific statistics callback */ -- (id)getStatisticsDelegate; +- (StatisticsCallback)getStatisticsCallback; /** * Returns all statistics entries generated for this session. If there are asynchronous diff --git a/apple/src/FFmpegSession.m b/apple/src/FFmpegSession.m index e8f6926..c4b381e 100644 --- a/apple/src/FFmpegSession.m +++ b/apple/src/FFmpegSession.m @@ -17,24 +17,24 @@ * along with FFmpegKit. If not, see . */ -#import "ExecuteDelegate.h" +#import "ExecuteCallback.h" #import "FFmpegSession.h" #import "FFmpegKitConfig.h" -#import "LogDelegate.h" -#import "StatisticsDelegate.h" +#import "LogCallback.h" +#import "StatisticsCallback.h" @implementation FFmpegSession { - id _statisticsDelegate; + StatisticsCallback _statisticsCallback; NSMutableArray* _statistics; NSRecursiveLock* _statisticsLock; } - (instancetype)init:(NSArray*)arguments { - self = [super init:arguments withExecuteDelegate:nil withLogDelegate:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; + self = [super init:arguments withExecuteCallback:nil withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; if (self) { - _statisticsDelegate = nil; + _statisticsCallback = nil; _statistics = [[NSMutableArray alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init]; } @@ -42,12 +42,12 @@ return self; } -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate { +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback { - self = [super init:arguments withExecuteDelegate:executeDelegate withLogDelegate:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; + self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; if (self) { - _statisticsDelegate = nil; + _statisticsCallback = nil; _statistics = [[NSMutableArray alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init]; } @@ -55,12 +55,12 @@ return self; } -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate { +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback { - self = [super init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; + self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; if (self) { - _statisticsDelegate = statisticsDelegate; + _statisticsCallback = statisticsCallback; _statistics = [[NSMutableArray alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init]; } @@ -68,12 +68,12 @@ return self; } -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withStatisticsDelegate:(id)statisticsDelegate withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { - self = [super init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withLogRedirectionStrategy:logRedirectionStrategy]; + self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withLogRedirectionStrategy:logRedirectionStrategy]; if (self) { - _statisticsDelegate = statisticsDelegate; + _statisticsCallback = statisticsCallback; _statistics = [[NSMutableArray alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init]; } @@ -81,8 +81,8 @@ return self; } -- (id)getStatisticsDelegate { - return _statisticsDelegate; +- (StatisticsCallback)getStatisticsCallback { + return _statisticsCallback; } - (NSArray*)getAllStatisticsWithTimeout:(int)waitTimeout { diff --git a/apple/src/FFprobeKit.h b/apple/src/FFprobeKit.h index bf9a2df..e573311 100644 --- a/apple/src/FFprobeKit.h +++ b/apple/src/FFprobeKit.h @@ -32,11 +32,11 @@ *

  * FFprobeSession *session = [FFprobeKit execute:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4"];
  *
- * FFprobeSession *asyncSession = [FFprobeKit executeAsync:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4" withExecuteDelegate:executeDelegate];
+ * FFprobeSession *asyncSession = [FFprobeKit executeAsync:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4" withExecuteCallback:executeCallback];
  * 
- *

Provides overloaded execute methods to define session specific delegates. + *

Provides overloaded execute methods to define session specific callbacks. *

- * FFprobeSession *session = [FFprobeKit executeAsync:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4" withExecuteDelegate:executeDelegate withLogDelegate:logDelegate];
+ * FFprobeSession *session = [FFprobeKit executeAsync:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4" withExecuteCallback:executeCallback withLogCallback:logCallback];
  * 
*

It can extract media information for a file or a url, using getMediaInformation method. *

@@ -57,41 +57,41 @@
  * 

Asynchronously executes FFprobe with arguments provided. * * @param arguments FFprobe command options/arguments as string array - * @param executeDelegate delegate that will be called when the execution is completed + * @param executeCallback callback that will be called when the execution is completed * @return FFprobe session created for this execution */ -+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate; ++ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; /** *

Asynchronously executes FFprobe with arguments provided. * * @param arguments FFprobe command options/arguments as string array - * @param executeDelegate delegate that will be notified when execution is completed - * @param logDelegate delegate that will receive logs + * @param executeCallback callback that will be notified when execution is completed + * @param logCallback callback that will receive logs * @return FFprobe session created for this execution */ -+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate; ++ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback; /** *

Asynchronously executes FFprobe with arguments provided. * * @param arguments FFprobe command options/arguments as string array - * @param executeDelegate delegate that will be called when the execution is completed + * @param executeCallback callback that will be called when the execution is completed * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFprobe session created for this execution */ -+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate onDispatchQueue:(dispatch_queue_t)queue; ++ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; /** *

Asynchronously executes FFprobe with arguments provided. * * @param arguments FFprobe command options/arguments as string array - * @param executeDelegate delegate that will be notified when execution is completed - * @param logDelegate delegate that will receive logs + * @param executeCallback callback that will be notified when execution is completed + * @param logCallback callback that will receive logs * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFprobe session created for this execution */ -+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate onDispatchQueue:(dispatch_queue_t)queue; ++ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue; /** *

Synchronously executes FFprobe command provided. Space character is used to split command @@ -109,10 +109,10 @@ * your command. * * @param command FFprobe command - * @param executeDelegate delegate that will be called when the execution is completed + * @param executeCallback callback that will be called when the execution is completed * @return FFprobe session created for this execution */ -+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate; ++ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback; /** *

Asynchronously executes FFprobe command provided. Space character is used to split command @@ -120,11 +120,11 @@ * your command. * * @param command FFprobe command - * @param executeDelegate delegate that will be notified when execution is completed - * @param logDelegate delegate that will receive logs + * @param executeCallback callback that will be notified when execution is completed + * @param logCallback callback that will receive logs * @return FFprobe session created for this execution */ -+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate; ++ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback; /** *

Asynchronously executes FFprobe command provided. Space character is used to split command @@ -132,11 +132,11 @@ * your command. * * @param command FFprobe command - * @param executeDelegate delegate that will be called when the execution is completed + * @param executeCallback callback that will be called when the execution is completed * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFprobe session created for this execution */ -+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate onDispatchQueue:(dispatch_queue_t)queue; ++ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; /** *

Asynchronously executes FFprobe command provided. Space character is used to split command @@ -144,12 +144,12 @@ * your command. * * @param command FFprobe command - * @param executeDelegate delegate that will be called when the execution is completed - * @param logDelegate delegate that will receive logs + * @param executeCallback callback that will be called when the execution is completed + * @param logCallback callback that will receive logs * @param queue dispatch queue that will be used to run this asynchronous operation * @return FFprobe session created for this execution */ -+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate onDispatchQueue:(dispatch_queue_t)queue; ++ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue; /** *

Extracts media information for the file specified with path. @@ -172,43 +172,43 @@ *

Extracts media information for the file specified with path asynchronously. * * @param path path or uri of a media file - * @param executeDelegate delegate that will be called when the execution is completed + * @param executeCallback callback that will be called when the execution is completed * @return media information session created for this execution */ -+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id)executeDelegate; ++ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback; /** *

Extracts media information for the file specified with path asynchronously. * * @param path path or uri of a media file - * @param executeDelegate delegate that will be notified when execution is completed - * @param logDelegate delegate that will receive logs + * @param executeCallback callback that will be notified when execution is completed + * @param logCallback callback that will receive logs * @param waitTimeout max time to wait until media information is transmitted * @return media information session created for this execution */ -+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withTimeout:(int)waitTimeout; ++ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withTimeout:(int)waitTimeout; /** *

Extracts media information for the file specified with path asynchronously. * * @param path path or uri of a media file - * @param executeDelegate delegate that will be called when the execution is completed + * @param executeCallback callback that will be called when the execution is completed * @param queue dispatch queue that will be used to run this asynchronous operation * @return media information session created for this execution */ -+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id)executeDelegate onDispatchQueue:(dispatch_queue_t)queue; ++ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; /** *

Extracts media information for the file specified with path asynchronously. * * @param path path or uri of a media file - * @param executeDelegate delegate that will be notified when execution is completed - * @param logDelegate delegate that will receive logs + * @param executeCallback callback that will be notified when execution is completed + * @param logCallback callback that will receive logs * @param queue dispatch queue that will be used to run this asynchronous operation * @param waitTimeout max time to wait until media information is transmitted * @return media information session created for this execution */ -+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; ++ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; /** *

Extracts media information using the command provided asynchronously. @@ -222,12 +222,12 @@ *

Extracts media information using the command provided asynchronously. * * @param command FFprobe command that prints media information for a file in JSON format - * @param executeDelegate delegate that will be notified when execution is completed - * @param logDelegate delegate that will receive logs + * @param executeCallback callback that will be notified when execution is completed + * @param logCallback callback that will receive logs * @param waitTimeout max time to wait until media information is transmitted * @return media information session created for this execution */ -+ (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; ++ (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; /** *

Lists all FFprobe sessions in the session history. diff --git a/apple/src/FFprobeKit.m b/apple/src/FFprobeKit.m index 20fb136..b859d8d 100644 --- a/apple/src/FFprobeKit.m +++ b/apple/src/FFprobeKit.m @@ -34,26 +34,26 @@ return session; } -+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate { - FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteDelegate:executeDelegate]; ++ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback { + FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncFFprobeExecute:session]; return session; } -+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate { - FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; ++ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback { + FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncFFprobeExecute:session]; return session; } -+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate onDispatchQueue:(dispatch_queue_t)queue { - FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteDelegate:executeDelegate]; ++ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue { + FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; return session; } -+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate onDispatchQueue:(dispatch_queue_t)queue { - FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; ++ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue { + FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; return session; } @@ -64,26 +64,26 @@ return session; } -+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate { - FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate]; ++ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback { + FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncFFprobeExecute:session]; return session; } -+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate { - FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; ++ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback { + FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncFFprobeExecute:session]; return session; } -+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate onDispatchQueue:(dispatch_queue_t)queue { - FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate]; ++ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue { + FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; return session; } -+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate onDispatchQueue:(dispatch_queue_t)queue { - FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; ++ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue { + FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; return session; } @@ -102,30 +102,30 @@ return session; } -+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id)executeDelegate { ++ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback { NSArray* arguments = [[NSArray alloc] initWithObjects:@"-v", @"error", @"-hide_banner", @"-print_format", @"json", @"-show_format", @"-show_streams", @"-i", path, nil]; - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteDelegate:executeDelegate]; + MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit]; return session; } -+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withTimeout:(int)waitTimeout { ++ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withTimeout:(int)waitTimeout { NSArray* arguments = [[NSArray alloc] initWithObjects:@"-v", @"error", @"-hide_banner", @"-print_format", @"json", @"-show_format", @"-show_streams", @"-i", path, nil]; - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; + MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session withTimeout:waitTimeout]; return session; } -+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id)executeDelegate onDispatchQueue:(dispatch_queue_t)queue { ++ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue { NSArray* arguments = [[NSArray alloc] initWithObjects:@"-v", @"error", @"-hide_banner", @"-print_format", @"json", @"-show_format", @"-show_streams", @"-i", path, nil]; - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteDelegate:executeDelegate]; + MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit]; return session; } -+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { ++ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { NSArray* arguments = [[NSArray alloc] initWithObjects:@"-v", @"error", @"-hide_banner", @"-print_format", @"json", @"-show_format", @"-show_streams", @"-i", path, nil]; - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteDelegate:executeDelegate]; + MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout]; return session; } @@ -136,8 +136,8 @@ return session; } -+ (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; ++ (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { + MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout]; return session; } diff --git a/apple/src/FFprobeSession.h b/apple/src/FFprobeSession.h index 16d898d..4565fca 100644 --- a/apple/src/FFprobeSession.h +++ b/apple/src/FFprobeSession.h @@ -39,28 +39,28 @@ * Builds a new FFprobe session. * * @param arguments command arguments - * @param executeDelegate session specific execute delegate + * @param executeCallback session specific execute callback */ -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate; +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; /** * Builds a new FFprobe session. * * @param arguments command arguments - * @param executeDelegate session specific execute delegate - * @param logDelegate session specific log delegate + * @param executeCallback session specific execute callback + * @param logCallback session specific log callback */ -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate; +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback; /** * Builds a new FFprobe session. * * @param arguments command arguments - * @param executeDelegate session specific execute delegate - * @param logDelegate session specific log delegate + * @param executeCallback session specific execute callback + * @param logCallback session specific log callback * @param logRedirectionStrategy session specific log redirection strategy */ -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; @end diff --git a/apple/src/FFprobeSession.m b/apple/src/FFprobeSession.m index 9471456..391b2d9 100644 --- a/apple/src/FFprobeSession.m +++ b/apple/src/FFprobeSession.m @@ -17,37 +17,37 @@ * along with FFmpegKit. If not, see . */ -#import "ExecuteDelegate.h" +#import "ExecuteCallback.h" #import "FFprobeSession.h" #import "FFmpegKitConfig.h" -#import "LogDelegate.h" +#import "LogCallback.h" @implementation FFprobeSession - (instancetype)init:(NSArray*)arguments { - self = [super init:arguments withExecuteDelegate:nil withLogDelegate:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; + self = [super init:arguments withExecuteCallback:nil withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; return self; } -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate { +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback { - self = [super init:arguments withExecuteDelegate:executeDelegate withLogDelegate:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; + self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; return self; } -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate { +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback { - self = [super init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; + self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; return self; } -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { - self = [super init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withLogRedirectionStrategy:logRedirectionStrategy]; + self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withLogRedirectionStrategy:logRedirectionStrategy]; return self; } diff --git a/apple/src/LogDelegate.h b/apple/src/LogCallback.h similarity index 74% rename from apple/src/LogDelegate.h rename to apple/src/LogCallback.h index e9d9596..5505eb6 100644 --- a/apple/src/LogDelegate.h +++ b/apple/src/LogCallback.h @@ -17,25 +17,17 @@ * along with FFmpegKit. If not, see . */ -#ifndef FFMPEG_KIT_LOG_DELEGATE_H -#define FFMPEG_KIT_LOG_DELEGATE_H +#ifndef FFMPEG_KIT_LOG_CALLBACK_H +#define FFMPEG_KIT_LOG_CALLBACK_H #import #import "Log.h" /** - *

Delegate that receives logs generated for FFmpegKit sessions. - */ -@protocol LogDelegate -@required - -/** - *

Called when a log entry is received. + *

Callback that receives logs generated for FFmpegKit sessions. * * @param log log entry */ -- (void)logCallback:(Log*)log; +typedef void (^LogCallback)(Log* log); -@end - -#endif // FFMPEG_KIT_LOG_DELEGATE_H +#endif // FFMPEG_KIT_LOG_CALLBACK_H diff --git a/apple/src/LogRedirectionStrategy.h b/apple/src/LogRedirectionStrategy.h index 53c696f..1fd8b61 100644 --- a/apple/src/LogRedirectionStrategy.h +++ b/apple/src/LogRedirectionStrategy.h @@ -22,9 +22,9 @@ typedef NS_ENUM(NSUInteger, LogRedirectionStrategy) { LogRedirectionStrategyAlwaysPrintLogs, - LogRedirectionStrategyPrintLogsWhenNoDelegatesDefined, - LogRedirectionStrategyPrintLogsWhenGlobalDelegateNotDefined, - LogRedirectionStrategyPrintLogsWhenSessionDelegateNotDefined, + LogRedirectionStrategyPrintLogsWhenNoCallbacksDefined, + LogRedirectionStrategyPrintLogsWhenGlobalCallbackNotDefined, + LogRedirectionStrategyPrintLogsWhenSessionCallbackNotDefined, LogRedirectionStrategyNeverPrintLogs }; diff --git a/apple/src/Makefile.am b/apple/src/Makefile.am index 04a6e6c..9f4e8d3 100644 --- a/apple/src/Makefile.am +++ b/apple/src/Makefile.am @@ -35,7 +35,7 @@ include_HEADERS = \ AbstractSession.h \ ArchDetect.h \ AtomicLong.h \ - ExecuteDelegate.h \ + ExecuteCallback.h \ FFmpegKit.h \ FFmpegKitConfig.h \ FFmpegSession.h \ @@ -43,7 +43,7 @@ include_HEADERS = \ FFprobeSession.h \ Level.h \ Log.h \ - LogDelegate.h \ + LogCallback.h \ LogRedirectionStrategy.h \ MediaInformation.h \ MediaInformationJsonParser.h \ @@ -53,7 +53,7 @@ include_HEADERS = \ Session.h \ SessionState.h \ Statistics.h \ - StatisticsDelegate.h \ + StatisticsCallback.h \ StreamInformation.h \ ffmpegkit_exception.h \ fftools_cmdutils.h \ diff --git a/apple/src/Makefile.in b/apple/src/Makefile.in index 0ca66ae..102841a 100644 --- a/apple/src/Makefile.in +++ b/apple/src/Makefile.in @@ -411,7 +411,7 @@ include_HEADERS = \ AbstractSession.h \ ArchDetect.h \ AtomicLong.h \ - ExecuteDelegate.h \ + ExecuteCallback.h \ FFmpegKit.h \ FFmpegKitConfig.h \ FFmpegSession.h \ @@ -419,7 +419,7 @@ include_HEADERS = \ FFprobeSession.h \ Level.h \ Log.h \ - LogDelegate.h \ + LogCallback.h \ LogRedirectionStrategy.h \ MediaInformation.h \ MediaInformationJsonParser.h \ @@ -429,7 +429,7 @@ include_HEADERS = \ Session.h \ SessionState.h \ Statistics.h \ - StatisticsDelegate.h \ + StatisticsCallback.h \ StreamInformation.h \ ffmpegkit_exception.h \ fftools_cmdutils.h \ diff --git a/apple/src/MediaInformationSession.h b/apple/src/MediaInformationSession.h index 4b37dd1..3b6f2c7 100644 --- a/apple/src/MediaInformationSession.h +++ b/apple/src/MediaInformationSession.h @@ -41,18 +41,18 @@ * Creates a new media information session. * * @param arguments command arguments - * @param executeDelegate session specific execute delegate + * @param executeCallback session specific execute callback */ -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate; +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; /** * Creates a new media information session. * * @param arguments command arguments - * @param executeDelegate session specific execute delegate - * @param logDelegate session specific log delegate + * @param executeCallback session specific execute callback + * @param logCallback session specific log callback */ -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate; +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback; /** * Returns the media information extracted in this session. diff --git a/apple/src/MediaInformationSession.m b/apple/src/MediaInformationSession.m index 95b687d..0876329 100644 --- a/apple/src/MediaInformationSession.m +++ b/apple/src/MediaInformationSession.m @@ -17,8 +17,8 @@ * along with FFmpegKit. If not, see . */ -#import "ExecuteDelegate.h" -#import "LogDelegate.h" +#import "ExecuteCallback.h" +#import "LogCallback.h" #import "MediaInformation.h" #import "MediaInformationSession.h" @@ -28,21 +28,21 @@ - (instancetype)init:(NSArray*)arguments { - self = [super init:arguments withExecuteDelegate:nil withLogDelegate:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; + self = [super init:arguments withExecuteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; return self; } -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate { +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback { - self = [super init:arguments withExecuteDelegate:executeDelegate withLogDelegate:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; + self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; return self; } -- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id)executeDelegate withLogDelegate:(id)logDelegate { +- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback { - self = [super init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; + self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; return self; } diff --git a/apple/src/Session.h b/apple/src/Session.h index eb6ad79..6be9665 100644 --- a/apple/src/Session.h +++ b/apple/src/Session.h @@ -21,15 +21,13 @@ #define FFMPEG_KIT_SESSION_H #import -#import "ExecuteDelegate.h" +#import "ExecuteCallback.h" #import "Log.h" -#import "LogDelegate.h" +#import "LogCallback.h" #import "LogRedirectionStrategy.h" #import "ReturnCode.h" #import "SessionState.h" -@protocol ExecuteDelegate; - /** *

Common interface for all FFmpegKit sessions. */ @@ -38,18 +36,18 @@ @required /** - * Returns the session specific execute delegate. + * Returns the session specific execute callback. * - * @return session specific execute delegate + * @return session specific execute callback */ -- (id)getExecuteDelegate; +- (ExecuteCallback)getExecuteCallback; /** - * Returns the session specific log delegate. + * Returns the session specific log callback. * - * @return session specific log delegate + * @return session specific log callback */ -- (id)getLogDelegate; +- (LogCallback)getLogCallback; /** * Returns the session identifier. diff --git a/apple/src/StatisticsDelegate.h b/apple/src/StatisticsCallback.h similarity index 71% rename from apple/src/StatisticsDelegate.h rename to apple/src/StatisticsCallback.h index b0c5556..420d9ef 100644 --- a/apple/src/StatisticsDelegate.h +++ b/apple/src/StatisticsCallback.h @@ -17,25 +17,17 @@ * along with FFmpegKit. If not, see . */ -#ifndef FFMPEG_KIT_STATISTICS_DELEGATE_H -#define FFMPEG_KIT_STATISTICS_DELEGATE_H +#ifndef FFMPEG_KIT_STATISTICS_CALLBACK_H +#define FFMPEG_KIT_STATISTICS_CALLBACK_H #import #import "Statistics.h" /** - *

Delegate that receives statistics generated for FFmpegKit sessions. - */ -@protocol StatisticsDelegate -@required - -/** - *

Called when a statistics entry is received. + *

Callback that receives statistics generated for FFmpegKit sessions. * * @param statistics statistics entry */ -- (void)statisticsCallback:(Statistics*)statistics; +typedef void (^StatisticsCallback)(Statistics* statistics); -@end - -#endif // FFMPEG_KIT_STATISTICS_DELEGATE_H +#endif // FFMPEG_KIT_STATISTICS_CALLBACK_H diff --git a/scripts/function-apple.sh b/scripts/function-apple.sh index 2e23c8b..b58ebfd 100755 --- a/scripts/function-apple.sh +++ b/scripts/function-apple.sh @@ -1008,18 +1008,28 @@ build_modulemap() { cat >"${FILE_PATH}" <