replace delegates with callback blocks on objective c api

This commit is contained in:
Taner Sener 2021-02-16 13:15:00 +00:00
parent a05fdf4e56
commit 06a736fda4
22 changed files with 318 additions and 333 deletions

View File

@ -38,11 +38,11 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
* Creates a new abstract session. * Creates a new abstract session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeDelegate session specific execute delegate * @param executeCallback session specific execute callback
* @param logDelegate session specific log delegate * @param logCallback session specific log callback
* @param logRedirectionStrategy session specific log redirection strategy * @param logRedirectionStrategy session specific log redirection strategy
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)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. * Waits for all asynchronous messages to be transmitted until the given timeout.

View File

@ -19,10 +19,10 @@
#import "AbstractSession.h" #import "AbstractSession.h"
#import "AtomicLong.h" #import "AtomicLong.h"
#import "ExecuteDelegate.h" #import "ExecuteCallback.h"
#import "FFmpegKit.h" #import "FFmpegKit.h"
#import "FFmpegKitConfig.h" #import "FFmpegKitConfig.h"
#import "LogDelegate.h" #import "LogCallback.h"
#import "ReturnCode.h" #import "ReturnCode.h"
int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit = 5000; int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit = 5000;
@ -31,8 +31,8 @@ static AtomicLong *sessionIdGenerator = nil;
@implementation AbstractSession { @implementation AbstractSession {
long _sessionId; long _sessionId;
id<ExecuteDelegate> _executeDelegate; ExecuteCallback _executeCallback;
id<LogDelegate> _logDelegate; LogCallback _logCallback;
NSDate* _createTime; NSDate* _createTime;
NSDate* _startTime; NSDate* _startTime;
NSDate* _endTime; NSDate* _endTime;
@ -49,12 +49,12 @@ static AtomicLong *sessionIdGenerator = nil;
sessionIdGenerator = [[AtomicLong alloc] initWithValue:1]; sessionIdGenerator = [[AtomicLong alloc] initWithValue:1];
} }
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { - (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy {
self = [super init]; self = [super init];
if (self) { if (self) {
_sessionId = [sessionIdGenerator incrementAndGet]; _sessionId = [sessionIdGenerator incrementAndGet];
_executeDelegate = executeDelegate; _executeCallback = executeCallback;
_logDelegate = logDelegate; _logCallback = logCallback;
_createTime = [NSDate date]; _createTime = [NSDate date];
_startTime = nil; _startTime = nil;
_endTime = nil; _endTime = nil;
@ -70,12 +70,12 @@ static AtomicLong *sessionIdGenerator = nil;
return self; return self;
} }
- (id<ExecuteDelegate>)getExecuteDelegate { - (ExecuteCallback)getExecuteCallback {
return _executeDelegate; return _executeCallback;
} }
- (id<LogDelegate>)getLogDelegate { - (LogCallback)getLogCallback {
return _logDelegate; return _logCallback;
} }
- (long)getSessionId { - (long)getSessionId {

View File

@ -17,18 +17,15 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FFMPEG_KIT_EXECUTE_DELEGATE_H #ifndef FFMPEG_KIT_EXECUTE_CALLBACK_H
#define FFMPEG_KIT_EXECUTE_DELEGATE_H #define FFMPEG_KIT_EXECUTE_CALLBACK_H
#import <Foundation/Foundation.h>
#import "Session.h"
@protocol Session; @protocol Session;
/** /**
* <p>Delegate invoked when an asynchronous session ends running. * <p>Callback invoked when an asynchronous session ends running.
* <p>Session has either SessionStateCompleted or SessionStateFailed state when * <p>Session has either SessionStateCompleted or SessionStateFailed state when
* the delegate is invoked. * the callback is invoked.
* <p>If it has SessionStateCompleted state, <code>ReturnCode</code> should be checked to * <p>If it has SessionStateCompleted state, <code>ReturnCode</code> should be checked to
* see the execution result. * see the execution result.
* <p>If <code>getState</code> returns SessionStateFailed then * <p>If <code>getState</code> returns SessionStateFailed then
@ -43,17 +40,11 @@
* break; * break;
* } * }
* </pre> * </pre>
*/
@protocol ExecuteDelegate<NSObject>
@required
/**
* Called when an execution is completed.
* *
* @param session session of the completed execution * @param session session of the completed execution
*/ */
- (void)executeCallback:(id<Session>)session; typedef void (^ExecuteCallback)(id<Session> session);
@end #import "Session.h"
#endif // FFMPEG_KIT_EXECUTE_DELEGATE_H #endif // FFMPEG_KIT_EXECUTE_CALLBACK_H

View File

@ -23,10 +23,10 @@
#import <string.h> #import <string.h>
#import <stdlib.h> #import <stdlib.h>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "ExecuteDelegate.h" #import "ExecuteCallback.h"
#import "LogDelegate.h" #import "LogCallback.h"
#import "FFmpegSession.h" #import "FFmpegSession.h"
#import "StatisticsDelegate.h" #import "StatisticsCallback.h"
/** /**
* <p>Main class to run <code>FFmpeg</code> commands. Supports executing commands both * <p>Main class to run <code>FFmpeg</code> commands. Supports executing commands both
@ -34,11 +34,11 @@
* <pre> * <pre>
* FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v libxvid file1.avi"]; * 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];
* </pre> * </pre>
* <p>Provides overloaded <code>execute</code> methods to define session specific delegates. * <p>Provides overloaded <code>execute</code> methods to define session specific callbacks.
* <pre> * <pre>
* 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];
* </pre> * </pre>
*/ */
@interface FFmpegKit : NSObject @interface FFmpegKit : NSObject
@ -55,43 +55,43 @@
* <p>Asynchronously executes FFmpeg with arguments provided. * <p>Asynchronously executes FFmpeg with arguments provided.
* *
* @param arguments FFmpeg command options/arguments as string array * @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 * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate; + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback;
/** /**
* <p>Asynchronously executes FFmpeg with arguments provided. * <p>Asynchronously executes FFmpeg with arguments provided.
* *
* @param arguments FFmpeg command options/arguments as string array * @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 logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @param statisticsDelegate delegate that will receive statistics * @param statisticsCallback callback that will receive statistics
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)statisticsDelegate; + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback;
/** /**
* <p>Asynchronously executes FFmpeg with arguments provided. * <p>Asynchronously executes FFmpeg with arguments provided.
* *
* @param arguments FFmpeg command options/arguments as string array * @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 * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate onDispatchQueue:(dispatch_queue_t)queue; + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Asynchronously executes FFmpeg with arguments provided. * <p>Asynchronously executes FFmpeg with arguments provided.
* *
* @param arguments FFmpeg command options/arguments as string array * @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 logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @param statisticsDelegate delegate that will receive statistics * @param statisticsCallback callback that will receive statistics
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)statisticsDelegate onDispatchQueue:(dispatch_queue_t)queue; + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Synchronously executes FFmpeg command provided. Space character is used to split command * <p>Synchronously executes FFmpeg command provided. Space character is used to split command
@ -109,10 +109,10 @@
* your command. * your command.
* *
* @param command FFmpeg 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 * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate; + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback;
/** /**
* <p>Asynchronously executes FFmpeg command provided. Space character is used to split command * <p>Asynchronously executes FFmpeg command provided. Space character is used to split command
@ -120,12 +120,12 @@
* your command. * your command.
* *
* @param command FFmpeg 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 logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @param statisticsDelegate delegate that will receive statistics * @param statisticsCallback callback that will receive statistics
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)statisticsDelegate; + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback;
/** /**
* <p>Asynchronously executes FFmpeg command provided. Space character is used to split command * <p>Asynchronously executes FFmpeg command provided. Space character is used to split command
@ -133,11 +133,11 @@
* your command. * your command.
* *
* @param command FFmpeg 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 * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate onDispatchQueue:(dispatch_queue_t)queue; + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Asynchronously executes FFmpeg command provided. Space character is used to split command * <p>Asynchronously executes FFmpeg command provided. Space character is used to split command
@ -145,13 +145,13 @@
* your command. * your command.
* *
* @param command FFmpeg 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 logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @param statisticsDelegate delegate that will receive statistics * @param statisticsCallback callback that will receive statistics
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)statisticsDelegate onDispatchQueue:(dispatch_queue_t)queue; + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Cancels all running sessions. * <p>Cancels all running sessions.

View File

@ -38,26 +38,26 @@
return session; return session;
} }
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate { + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteDelegate:executeDelegate]; FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session]; [FFmpegKitConfig asyncFFmpegExecute:session];
return session; return session;
} }
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)statisticsDelegate { + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withStatisticsDelegate:statisticsDelegate]; FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session]; [FFmpegKitConfig asyncFFmpegExecute:session];
return session; return session;
} }
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate onDispatchQueue:(dispatch_queue_t)queue { + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteDelegate:executeDelegate]; FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session; return session;
} }
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)statisticsDelegate onDispatchQueue:(dispatch_queue_t)queue { + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withStatisticsDelegate:statisticsDelegate]; FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session; return session;
} }
@ -68,26 +68,26 @@
return session; return session;
} }
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate { + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback {
FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate]; FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session]; [FFmpegKitConfig asyncFFmpegExecute:session];
return session; return session;
} }
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)statisticsDelegate { + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withStatisticsDelegate:statisticsDelegate]; FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session]; [FFmpegKitConfig asyncFFmpegExecute:session];
return session; return session;
} }
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate onDispatchQueue:(dispatch_queue_t)queue { + (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate]; FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session; return session;
} }
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)statisticsDelegate onDispatchQueue:(dispatch_queue_t)queue { + (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] withExecuteDelegate:executeDelegate withLogDelegate:logDelegate withStatisticsDelegate:statisticsDelegate]; FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session; return session;
} }

View File

@ -24,12 +24,12 @@
#import <pthread.h> #import <pthread.h>
#import <unistd.h> #import <unistd.h>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "ExecuteDelegate.h" #import "ExecuteCallback.h"
#import "FFmpegSession.h" #import "FFmpegSession.h"
#import "FFprobeSession.h" #import "FFprobeSession.h"
#import "LogDelegate.h" #import "LogCallback.h"
#import "MediaInformationSession.h" #import "MediaInformationSession.h"
#import "StatisticsDelegate.h" #import "StatisticsCallback.h"
/** Global library version */ /** Global library version */
extern NSString* const FFmpegKitVersion; extern NSString* const FFmpegKitVersion;
@ -53,7 +53,7 @@ typedef NS_ENUM(NSUInteger, Signal) {
* *
* <p>When redirection is enabled FFmpeg/FFprobe logs are redirected to NSLog and sessions * <p>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 * 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.
* *
* <p>Note that redirection is enabled by default. If you do not want to use its functionality * <p>Note that redirection is enabled by default. If you do not want to use its functionality
* please use disableRedirection method to disable it. * please use disableRedirection method to disable it.
@ -64,7 +64,7 @@ typedef NS_ENUM(NSUInteger, Signal) {
* <p>Disables log and statistics redirection. * <p>Disables log and statistics redirection.
* *
* <p>When redirection is disabled logs are printed to stderr, all logs and statistics * <p>When redirection is disabled logs are printed to stderr, all logs and statistics
* delegates are disabled and <code>FFprobe</code>'s <code>getMediaInformation</code> methods * callbacks are disabled and <code>FFprobe</code>'s <code>getMediaInformation</code> methods
* do not work. * do not work.
*/ */
+ (void)disableRedirection; + (void)disableRedirection;
@ -236,32 +236,32 @@ typedef NS_ENUM(NSUInteger, Signal) {
+ (void)asyncGetMediaInformationExecute:(MediaInformationSession*)mediaInformationSession onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; + (void)asyncGetMediaInformationExecute:(MediaInformationSession*)mediaInformationSession onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout;
/** /**
* <p>Sets a global log delegate to redirect FFmpeg/FFprobe logs. * <p>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>)logDelegate; + (void)enableLogCallback:(LogCallback)logCallback;
/** /**
* <p>Sets a global statistics delegate to redirect FFmpeg statistics. * <p>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>)statisticsDelegate; + (void)enableStatisticsCallback:(StatisticsCallback)statisticsCallback;
/** /**
* <p>Sets a global execute delegate to receive execution results. * <p>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>)executeDelegate; + (void)enableExecuteCallback:(ExecuteCallback)executeCallback;
/** /**
* <p>Returns the global execute delegate. * <p>Returns the global execute callback.
* *
* @return global execute delegate * @return global execute callback
*/ */
+ (id<ExecuteDelegate>)getExecuteDelegate; + (ExecuteCallback)getExecuteCallback;
/** /**
* Returns the current log level. * Returns the current log level.
@ -365,11 +365,11 @@ typedef NS_ENUM(NSUInteger, Signal) {
+ (void)setLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; + (void)setLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy;
/** /**
* <p>Returns the number of async messages that are not transmitted to the delegates for * <p>Returns the number of async messages that are not transmitted to the callbacks for
* this session. * this session.
* *
* @param sessionId id of the 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; + (int)messagesInTransmit:(long)sessionId;

View File

@ -60,14 +60,14 @@ static atomic_int sessionInTransitMessageCountMap[SESSION_MAP_SIZE];
static dispatch_queue_t asyncDispatchQueue; static dispatch_queue_t asyncDispatchQueue;
/** Holds delegate defined to redirect logs */ /** Holds callback defined to redirect logs */
static id<LogDelegate> logDelegate; static LogCallback logCallback;
/** Holds delegate defined to redirect statistics */ /** Holds callback defined to redirect statistics */
static id<StatisticsDelegate> statisticsDelegate; static StatisticsCallback statisticsCallback;
/** Holds delegate defined to redirect asynchronous execution results */ /** Holds callback defined to redirect asynchronous execution results */
static id<ExecuteDelegate> executeDelegate; static ExecuteCallback executeCallback;
static LogRedirectionStrategy globalLogRedirectionStrategy; 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) { void process_log(long sessionId, int levelValue, NSString* logMessage) {
int activeLogLevel = av_log_get_level(); int activeLogLevel = av_log_get_level();
Log* log = [[Log alloc] init:sessionId:levelValue:logMessage]; Log* log = [[Log alloc] init:sessionId:levelValue:logMessage];
BOOL globalDelegateDefined = false; BOOL globalCallbackDefined = false;
BOOL sessionDelegateDefined = false; BOOL sessionCallbackDefined = false;
LogRedirectionStrategy activeLogRedirectionStrategy = globalLogRedirectionStrategy; LogRedirectionStrategy activeLogRedirectionStrategy = globalLogRedirectionStrategy;
// LevelAVLogStdErr logs are always redirected // LevelAVLogStdErr logs are always redirected
@ -378,30 +378,31 @@ void process_log(long sessionId, int levelValue, NSString* logMessage) {
if (session != nil) { if (session != nil) {
activeLogRedirectionStrategy = [session getLogRedirectionStrategy]; activeLogRedirectionStrategy = [session getLogRedirectionStrategy];
[session addLog:log]; [session addLog:log];
if ([session getLogDelegate] != nil) { LogCallback sessionLogCallback = [session getLogCallback];
sessionDelegateDefined = TRUE; if (sessionLogCallback != nil) {
sessionCallbackDefined = TRUE;
@try { @try {
// NOTIFY SESSION DELEGATE DEFINED // NOTIFY SESSION CALLBACK DEFINED
[[session getLogDelegate] logCallback:log]; sessionLogCallback(log);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside session LogDelegate block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside session LogCallback block. %@", [exception callStackSymbols]);
} }
} }
} }
id<LogDelegate> activeLogDelegate = logDelegate; LogCallback globalLogCallback = logCallback;
if (activeLogDelegate != nil) { if (globalLogCallback != nil) {
globalDelegateDefined = TRUE; globalCallbackDefined = TRUE;
@try { @try {
// NOTIFY GLOBAL DELEGATE DEFINED // NOTIFY GLOBAL CALLBACK DEFINED
[activeLogDelegate logCallback:log]; globalLogCallback(log);
} }
@catch(NSException* exception) { @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: { case LogRedirectionStrategyNeverPrintLogs: {
return; return;
} }
case LogRedirectionStrategyPrintLogsWhenGlobalDelegateNotDefined: { case LogRedirectionStrategyPrintLogsWhenGlobalCallbackNotDefined: {
if (globalDelegateDefined) { if (globalCallbackDefined) {
return; return;
} }
} }
break; break;
case LogRedirectionStrategyPrintLogsWhenSessionDelegateNotDefined: { case LogRedirectionStrategyPrintLogsWhenSessionCallbackNotDefined: {
if (sessionDelegateDefined) { if (sessionCallbackDefined) {
return; return;
} }
} }
case LogRedirectionStrategyPrintLogsWhenNoDelegatesDefined: { case LogRedirectionStrategyPrintLogsWhenNoCallbacksDefined: {
if (globalDelegateDefined || sessionDelegateDefined) { if (globalCallbackDefined || sessionCallbackDefined) {
return; return;
} }
} }
@ -450,30 +451,31 @@ void process_statistics(long sessionId, int videoFrameNumber, float videoFps, fl
if (session != nil && [session isFFmpeg]) { if (session != nil && [session isFFmpeg]) {
FFmpegSession *ffmpegSession = (FFmpegSession*)session; FFmpegSession *ffmpegSession = (FFmpegSession*)session;
[ffmpegSession addStatistics:statistics]; [ffmpegSession addStatistics:statistics];
if ([ffmpegSession getStatisticsDelegate] != nil) { StatisticsCallback sessionStatisticsCallback = [ffmpegSession getStatisticsCallback];
if (sessionStatisticsCallback != nil) {
@try { @try {
[[ffmpegSession getStatisticsDelegate] statisticsCallback:statistics]; sessionStatisticsCallback(statistics);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside session StatisticsDelegate block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside session StatisticsCallback block. %@", [exception callStackSymbols]);
} }
} }
} }
id<StatisticsDelegate> activeStatisticsDelegate = statisticsDelegate; StatisticsCallback globalStatisticsCallback = statisticsCallback;
if (activeStatisticsDelegate != nil) { if (globalStatisticsCallback != nil) {
@try { @try {
[activeStatisticsDelegate statisticsCallback:statistics]; globalStatisticsCallback(statistics);
} }
@catch(NSException* exception) { @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() { void callbackBlockFunction() {
int activeLogLevel = av_log_get_level(); 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); asyncDispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
logDelegate = nil; logCallback = nil;
statisticsDelegate = nil; statisticsCallback = nil;
executeDelegate = nil; executeCallback = nil;
globalLogRedirectionStrategy = LogRedirectionStrategyPrintLogsWhenNoDelegatesDefined; globalLogRedirectionStrategy = LogRedirectionStrategyPrintLogsWhenNoCallbacksDefined;
redirectionEnabled = 0; redirectionEnabled = 0;
lock = [[NSRecursiveLock alloc] init]; lock = [[NSRecursiveLock alloc] init];
@ -885,14 +887,14 @@ int executeFFprobe(long sessionId, NSArray* arguments) {
+ (void)asyncFFmpegExecute:(FFmpegSession*)ffmpegSession onDispatchQueue:(dispatch_queue_t)queue { + (void)asyncFFmpegExecute:(FFmpegSession*)ffmpegSession onDispatchQueue:(dispatch_queue_t)queue {
dispatch_async(queue, ^{ dispatch_async(queue, ^{
[FFmpegKitConfig ffmpegExecute:ffmpegSession]; [FFmpegKitConfig ffmpegExecute:ffmpegSession];
id<ExecuteDelegate> globalExecuteDelegate = [FFmpegKitConfig getExecuteDelegate]; ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback];
if (globalExecuteDelegate != nil) { if (globalExecuteCallback != nil) {
[globalExecuteDelegate executeCallback:ffmpegSession]; globalExecuteCallback(ffmpegSession);
} }
id<ExecuteDelegate> executeDelegate = [ffmpegSession getExecuteDelegate]; ExecuteCallback sessionExecuteCallback = [ffmpegSession getExecuteCallback];
if (executeDelegate != nil) { if (sessionExecuteCallback != nil) {
[executeDelegate executeCallback:ffmpegSession]; sessionExecuteCallback(ffmpegSession);
} }
}); });
} }
@ -904,14 +906,14 @@ int executeFFprobe(long sessionId, NSArray* arguments) {
+ (void)asyncFFprobeExecute:(FFprobeSession*)ffprobeSession onDispatchQueue:(dispatch_queue_t)queue { + (void)asyncFFprobeExecute:(FFprobeSession*)ffprobeSession onDispatchQueue:(dispatch_queue_t)queue {
dispatch_async(queue, ^{ dispatch_async(queue, ^{
[FFmpegKitConfig ffprobeExecute:ffprobeSession]; [FFmpegKitConfig ffprobeExecute:ffprobeSession];
id<ExecuteDelegate> globalExecuteDelegate = [FFmpegKitConfig getExecuteDelegate]; ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback];
if (globalExecuteDelegate != nil) { if (globalExecuteCallback != nil) {
[globalExecuteDelegate executeCallback:ffprobeSession]; globalExecuteCallback(ffprobeSession);
} }
id<ExecuteDelegate> executeDelegate = [ffprobeSession getExecuteDelegate]; ExecuteCallback sessionExecuteCallback = [ffprobeSession getExecuteCallback];
if (executeDelegate != nil) { if (sessionExecuteCallback != nil) {
[executeDelegate executeCallback:ffprobeSession]; sessionExecuteCallback(ffprobeSession);
} }
}); });
} }
@ -923,32 +925,32 @@ int executeFFprobe(long sessionId, NSArray* arguments) {
+ (void)asyncGetMediaInformationExecute:(MediaInformationSession*)mediaInformationSession onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { + (void)asyncGetMediaInformationExecute:(MediaInformationSession*)mediaInformationSession onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout {
dispatch_async(queue, ^{ dispatch_async(queue, ^{
[FFmpegKitConfig getMediaInformationExecute:mediaInformationSession withTimeout:waitTimeout]; [FFmpegKitConfig getMediaInformationExecute:mediaInformationSession withTimeout:waitTimeout];
id<ExecuteDelegate> globalExecuteDelegate = [FFmpegKitConfig getExecuteDelegate]; ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback];
if (globalExecuteDelegate != nil) { if (globalExecuteCallback != nil) {
[globalExecuteDelegate executeCallback:mediaInformationSession]; globalExecuteCallback(mediaInformationSession);
} }
id<ExecuteDelegate> executeDelegate = [mediaInformationSession getExecuteDelegate]; ExecuteCallback sessionExecuteCallback = [mediaInformationSession getExecuteCallback];
if (executeDelegate != nil) { if (sessionExecuteCallback != nil) {
[executeDelegate executeCallback:mediaInformationSession]; sessionExecuteCallback(mediaInformationSession);
} }
}); });
} }
+ (void)enableLogDelegate:(id<LogDelegate>)delegate { + (void)enableLogCallback:(LogCallback)callback {
logDelegate = delegate; logCallback = callback;
} }
+ (void)enableStatisticsDelegate:(id<StatisticsDelegate>)delegate { + (void)enableStatisticsCallback:(StatisticsCallback)callback {
statisticsDelegate = delegate; statisticsCallback = callback;
} }
+ (void)enableExecuteDelegate:(id<ExecuteDelegate>)delegate { + (void)enableExecuteCallback:(ExecuteCallback)callback {
executeDelegate = delegate; executeCallback = callback;
} }
+ (id<ExecuteDelegate>)getExecuteDelegate { + (ExecuteCallback)getExecuteCallback {
return executeDelegate; return executeCallback;
} }
+ (int)getLogLevel { + (int)getLogLevel {

View File

@ -22,7 +22,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "AbstractSession.h" #import "AbstractSession.h"
#import "StatisticsDelegate.h" #import "StatisticsCallback.h"
/** /**
* <p>An FFmpeg session. * <p>An FFmpeg session.
@ -40,37 +40,37 @@
* Builds a new FFmpeg session. * Builds a new FFmpeg session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeDelegate session specific execute delegate * @param executeCallback session specific execute callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate; - (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback;
/** /**
* Builds a new FFmpeg session. * Builds a new FFmpeg session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeDelegate session specific execute delegate * @param executeCallback session specific execute callback
* @param logDelegate session specific log delegate * @param logCallback session specific log callback
* @param statisticsDelegate session specific statistics delegate * @param statisticsCallback session specific statistics callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)statisticsDelegate; - (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback;
/** /**
* Builds a new FFmpeg session. * Builds a new FFmpeg session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeDelegate session specific execute delegate * @param executeCallback session specific execute callback
* @param logDelegate session specific log delegate * @param logCallback session specific log callback
* @param statisticsDelegate session specific statistics delegate * @param statisticsCallback session specific statistics callback
* @param logRedirectionStrategy session specific log redirection strategy * @param logRedirectionStrategy session specific log redirection strategy
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)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<StatisticsDelegate>)getStatisticsDelegate; - (StatisticsCallback)getStatisticsCallback;
/** /**
* Returns all statistics entries generated for this session. If there are asynchronous * Returns all statistics entries generated for this session. If there are asynchronous

View File

@ -17,24 +17,24 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
#import "ExecuteDelegate.h" #import "ExecuteCallback.h"
#import "FFmpegSession.h" #import "FFmpegSession.h"
#import "FFmpegKitConfig.h" #import "FFmpegKitConfig.h"
#import "LogDelegate.h" #import "LogCallback.h"
#import "StatisticsDelegate.h" #import "StatisticsCallback.h"
@implementation FFmpegSession { @implementation FFmpegSession {
id<StatisticsDelegate> _statisticsDelegate; StatisticsCallback _statisticsCallback;
NSMutableArray* _statistics; NSMutableArray* _statistics;
NSRecursiveLock* _statisticsLock; NSRecursiveLock* _statisticsLock;
} }
- (instancetype)init:(NSArray*)arguments { - (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) { if (self) {
_statisticsDelegate = nil; _statisticsCallback = nil;
_statistics = [[NSMutableArray alloc] init]; _statistics = [[NSMutableArray alloc] init];
_statisticsLock = [[NSRecursiveLock alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init];
} }
@ -42,12 +42,12 @@
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)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) { if (self) {
_statisticsDelegate = nil; _statisticsCallback = nil;
_statistics = [[NSMutableArray alloc] init]; _statistics = [[NSMutableArray alloc] init];
_statisticsLock = [[NSRecursiveLock alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init];
} }
@ -55,12 +55,12 @@
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)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) { if (self) {
_statisticsDelegate = statisticsDelegate; _statisticsCallback = statisticsCallback;
_statistics = [[NSMutableArray alloc] init]; _statistics = [[NSMutableArray alloc] init];
_statisticsLock = [[NSRecursiveLock alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init];
} }
@ -68,12 +68,12 @@
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withStatisticsDelegate:(id<StatisticsDelegate>)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) { if (self) {
_statisticsDelegate = statisticsDelegate; _statisticsCallback = statisticsCallback;
_statistics = [[NSMutableArray alloc] init]; _statistics = [[NSMutableArray alloc] init];
_statisticsLock = [[NSRecursiveLock alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init];
} }
@ -81,8 +81,8 @@
return self; return self;
} }
- (id<StatisticsDelegate>)getStatisticsDelegate { - (StatisticsCallback)getStatisticsCallback {
return _statisticsDelegate; return _statisticsCallback;
} }
- (NSArray*)getAllStatisticsWithTimeout:(int)waitTimeout { - (NSArray*)getAllStatisticsWithTimeout:(int)waitTimeout {

View File

@ -32,11 +32,11 @@
* <pre> * <pre>
* FFprobeSession *session = [FFprobeKit execute:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4"]; * 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];
* </pre> * </pre>
* <p>Provides overloaded <code>execute</code> methods to define session specific delegates. * <p>Provides overloaded <code>execute</code> methods to define session specific callbacks.
* <pre> * <pre>
* 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];
* </pre> * </pre>
* <p>It can extract media information for a file or a url, using getMediaInformation method. * <p>It can extract media information for a file or a url, using getMediaInformation method.
* <pre> * <pre>
@ -57,41 +57,41 @@
* <p>Asynchronously executes FFprobe with arguments provided. * <p>Asynchronously executes FFprobe with arguments provided.
* *
* @param arguments FFprobe command options/arguments as string array * @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 * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate; + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback;
/** /**
* <p>Asynchronously executes FFprobe with arguments provided. * <p>Asynchronously executes FFprobe with arguments provided.
* *
* @param arguments FFprobe command options/arguments as string array * @param arguments FFprobe command options/arguments as string array
* @param executeDelegate delegate that will be notified when execution is completed * @param executeCallback callback that will be notified when execution is completed
* @param logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate; + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback;
/** /**
* <p>Asynchronously executes FFprobe with arguments provided. * <p>Asynchronously executes FFprobe with arguments provided.
* *
* @param arguments FFprobe command options/arguments as string array * @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 * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate onDispatchQueue:(dispatch_queue_t)queue; + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Asynchronously executes FFprobe with arguments provided. * <p>Asynchronously executes FFprobe with arguments provided.
* *
* @param arguments FFprobe command options/arguments as string array * @param arguments FFprobe command options/arguments as string array
* @param executeDelegate delegate that will be notified when execution is completed * @param executeCallback callback that will be notified when execution is completed
* @param logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate onDispatchQueue:(dispatch_queue_t)queue; + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Synchronously executes FFprobe command provided. Space character is used to split command * <p>Synchronously executes FFprobe command provided. Space character is used to split command
@ -109,10 +109,10 @@
* your command. * your command.
* *
* @param command FFprobe 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 * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate; + (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback;
/** /**
* <p>Asynchronously executes FFprobe command provided. Space character is used to split command * <p>Asynchronously executes FFprobe command provided. Space character is used to split command
@ -120,11 +120,11 @@
* your command. * your command.
* *
* @param command FFprobe command * @param command FFprobe command
* @param executeDelegate delegate that will be notified when execution is completed * @param executeCallback callback that will be notified when execution is completed
* @param logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate; + (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback;
/** /**
* <p>Asynchronously executes FFprobe command provided. Space character is used to split command * <p>Asynchronously executes FFprobe command provided. Space character is used to split command
@ -132,11 +132,11 @@
* your command. * your command.
* *
* @param command FFprobe 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 * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate onDispatchQueue:(dispatch_queue_t)queue; + (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Asynchronously executes FFprobe command provided. Space character is used to split command * <p>Asynchronously executes FFprobe command provided. Space character is used to split command
@ -144,12 +144,12 @@
* your command. * your command.
* *
* @param command FFprobe 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 logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate onDispatchQueue:(dispatch_queue_t)queue; + (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Extracts media information for the file specified with path. * <p>Extracts media information for the file specified with path.
@ -172,43 +172,43 @@
* <p>Extracts media information for the file specified with path asynchronously. * <p>Extracts media information for the file specified with path asynchronously.
* *
* @param path path or uri of a media file * @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 * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate; + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback;
/** /**
* <p>Extracts media information for the file specified with path asynchronously. * <p>Extracts media information for the file specified with path asynchronously.
* *
* @param path path or uri of a media file * @param path path or uri of a media file
* @param executeDelegate delegate that will be notified when execution is completed * @param executeCallback callback that will be notified when execution is completed
* @param logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withTimeout:(int)waitTimeout; + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withTimeout:(int)waitTimeout;
/** /**
* <p>Extracts media information for the file specified with path asynchronously. * <p>Extracts media information for the file specified with path asynchronously.
* *
* @param path path or uri of a media file * @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 * @param queue dispatch queue that will be used to run this asynchronous operation
* @return media information session created for this execution * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate onDispatchQueue:(dispatch_queue_t)queue; + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Extracts media information for the file specified with path asynchronously. * <p>Extracts media information for the file specified with path asynchronously.
* *
* @param path path or uri of a media file * @param path path or uri of a media file
* @param executeDelegate delegate that will be notified when execution is completed * @param executeCallback callback that will be notified when execution is completed
* @param logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)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;
/** /**
* <p>Extracts media information using the command provided asynchronously. * <p>Extracts media information using the command provided asynchronously.
@ -222,12 +222,12 @@
* <p>Extracts media information using the command provided asynchronously. * <p>Extracts media information using the command provided asynchronously.
* *
* @param command FFprobe command that prints media information for a file in JSON format * @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 executeCallback callback that will be notified when execution is completed
* @param logDelegate delegate that will receive logs * @param logCallback callback that will receive logs
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)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;
/** /**
* <p>Lists all FFprobe sessions in the session history. * <p>Lists all FFprobe sessions in the session history.

View File

@ -34,26 +34,26 @@
return session; return session;
} }
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate { + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteDelegate:executeDelegate]; FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback];
[FFmpegKitConfig asyncFFprobeExecute:session]; [FFmpegKitConfig asyncFFprobeExecute:session];
return session; return session;
} }
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate { + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncFFprobeExecute:session]; [FFmpegKitConfig asyncFFprobeExecute:session];
return session; return session;
} }
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate onDispatchQueue:(dispatch_queue_t)queue { + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteDelegate:executeDelegate]; FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback];
[FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue];
return session; return session;
} }
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate onDispatchQueue:(dispatch_queue_t)queue { + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue];
return session; return session;
} }
@ -64,26 +64,26 @@
return session; return session;
} }
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate { + (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback {
FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate]; FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback];
[FFmpegKitConfig asyncFFprobeExecute:session]; [FFmpegKitConfig asyncFFprobeExecute:session];
return session; return session;
} }
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate { + (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback {
FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncFFprobeExecute:session]; [FFmpegKitConfig asyncFFprobeExecute:session];
return session; return session;
} }
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate onDispatchQueue:(dispatch_queue_t)queue { + (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue {
FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate]; FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback];
[FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue];
return session; return session;
} }
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate onDispatchQueue:(dispatch_queue_t)queue { + (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue {
FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKit parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue];
return session; return session;
} }
@ -102,30 +102,30 @@
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id<ExecuteDelegate>)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]; 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]; [FFmpegKitConfig asyncGetMediaInformationExecute:session withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit];
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)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]; 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]; [FFmpegKitConfig asyncGetMediaInformationExecute:session withTimeout:waitTimeout];
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id<ExecuteDelegate>)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]; 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]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit];
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)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]; 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]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout];
return session; return session;
} }
@ -136,8 +136,8 @@
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { + (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout {
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteDelegate:executeDelegate withLogDelegate:logDelegate]; MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout];
return session; return session;
} }

View File

@ -39,28 +39,28 @@
* Builds a new FFprobe session. * Builds a new FFprobe session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeDelegate session specific execute delegate * @param executeCallback session specific execute callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate; - (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback;
/** /**
* Builds a new FFprobe session. * Builds a new FFprobe session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeDelegate session specific execute delegate * @param executeCallback session specific execute callback
* @param logDelegate session specific log delegate * @param logCallback session specific log callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate; - (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback;
/** /**
* Builds a new FFprobe session. * Builds a new FFprobe session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeDelegate session specific execute delegate * @param executeCallback session specific execute callback
* @param logDelegate session specific log delegate * @param logCallback session specific log callback
* @param logRedirectionStrategy session specific log redirection strategy * @param logRedirectionStrategy session specific log redirection strategy
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; - (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy;
@end @end

View File

@ -17,37 +17,37 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
#import "ExecuteDelegate.h" #import "ExecuteCallback.h"
#import "FFprobeSession.h" #import "FFprobeSession.h"
#import "FFmpegKitConfig.h" #import "FFmpegKitConfig.h"
#import "LogDelegate.h" #import "LogCallback.h"
@implementation FFprobeSession @implementation FFprobeSession
- (instancetype)init:(NSArray*)arguments { - (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; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)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; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)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; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)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; return self;
} }

View File

@ -17,25 +17,17 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FFMPEG_KIT_LOG_DELEGATE_H #ifndef FFMPEG_KIT_LOG_CALLBACK_H
#define FFMPEG_KIT_LOG_DELEGATE_H #define FFMPEG_KIT_LOG_CALLBACK_H
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "Log.h" #import "Log.h"
/** /**
* <p>Delegate that receives logs generated for <code>FFmpegKit</code> sessions. * <p>Callback that receives logs generated for <code>FFmpegKit</code> sessions.
*/
@protocol LogDelegate<NSObject>
@required
/**
* <p>Called when a log entry is received.
* *
* @param log log entry * @param log log entry
*/ */
- (void)logCallback:(Log*)log; typedef void (^LogCallback)(Log* log);
@end #endif // FFMPEG_KIT_LOG_CALLBACK_H
#endif // FFMPEG_KIT_LOG_DELEGATE_H

View File

@ -22,9 +22,9 @@
typedef NS_ENUM(NSUInteger, LogRedirectionStrategy) { typedef NS_ENUM(NSUInteger, LogRedirectionStrategy) {
LogRedirectionStrategyAlwaysPrintLogs, LogRedirectionStrategyAlwaysPrintLogs,
LogRedirectionStrategyPrintLogsWhenNoDelegatesDefined, LogRedirectionStrategyPrintLogsWhenNoCallbacksDefined,
LogRedirectionStrategyPrintLogsWhenGlobalDelegateNotDefined, LogRedirectionStrategyPrintLogsWhenGlobalCallbackNotDefined,
LogRedirectionStrategyPrintLogsWhenSessionDelegateNotDefined, LogRedirectionStrategyPrintLogsWhenSessionCallbackNotDefined,
LogRedirectionStrategyNeverPrintLogs LogRedirectionStrategyNeverPrintLogs
}; };

View File

@ -35,7 +35,7 @@ include_HEADERS = \
AbstractSession.h \ AbstractSession.h \
ArchDetect.h \ ArchDetect.h \
AtomicLong.h \ AtomicLong.h \
ExecuteDelegate.h \ ExecuteCallback.h \
FFmpegKit.h \ FFmpegKit.h \
FFmpegKitConfig.h \ FFmpegKitConfig.h \
FFmpegSession.h \ FFmpegSession.h \
@ -43,7 +43,7 @@ include_HEADERS = \
FFprobeSession.h \ FFprobeSession.h \
Level.h \ Level.h \
Log.h \ Log.h \
LogDelegate.h \ LogCallback.h \
LogRedirectionStrategy.h \ LogRedirectionStrategy.h \
MediaInformation.h \ MediaInformation.h \
MediaInformationJsonParser.h \ MediaInformationJsonParser.h \
@ -53,7 +53,7 @@ include_HEADERS = \
Session.h \ Session.h \
SessionState.h \ SessionState.h \
Statistics.h \ Statistics.h \
StatisticsDelegate.h \ StatisticsCallback.h \
StreamInformation.h \ StreamInformation.h \
ffmpegkit_exception.h \ ffmpegkit_exception.h \
fftools_cmdutils.h \ fftools_cmdutils.h \

View File

@ -411,7 +411,7 @@ include_HEADERS = \
AbstractSession.h \ AbstractSession.h \
ArchDetect.h \ ArchDetect.h \
AtomicLong.h \ AtomicLong.h \
ExecuteDelegate.h \ ExecuteCallback.h \
FFmpegKit.h \ FFmpegKit.h \
FFmpegKitConfig.h \ FFmpegKitConfig.h \
FFmpegSession.h \ FFmpegSession.h \
@ -419,7 +419,7 @@ include_HEADERS = \
FFprobeSession.h \ FFprobeSession.h \
Level.h \ Level.h \
Log.h \ Log.h \
LogDelegate.h \ LogCallback.h \
LogRedirectionStrategy.h \ LogRedirectionStrategy.h \
MediaInformation.h \ MediaInformation.h \
MediaInformationJsonParser.h \ MediaInformationJsonParser.h \
@ -429,7 +429,7 @@ include_HEADERS = \
Session.h \ Session.h \
SessionState.h \ SessionState.h \
Statistics.h \ Statistics.h \
StatisticsDelegate.h \ StatisticsCallback.h \
StreamInformation.h \ StreamInformation.h \
ffmpegkit_exception.h \ ffmpegkit_exception.h \
fftools_cmdutils.h \ fftools_cmdutils.h \

View File

@ -41,18 +41,18 @@
* Creates a new media information session. * Creates a new media information session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeDelegate session specific execute delegate * @param executeCallback session specific execute callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate; - (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback;
/** /**
* Creates a new media information session. * Creates a new media information session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeDelegate session specific execute delegate * @param executeCallback session specific execute callback
* @param logDelegate session specific log delegate * @param logCallback session specific log callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)logDelegate; - (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback;
/** /**
* Returns the media information extracted in this session. * Returns the media information extracted in this session.

View File

@ -17,8 +17,8 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
#import "ExecuteDelegate.h" #import "ExecuteCallback.h"
#import "LogDelegate.h" #import "LogCallback.h"
#import "MediaInformation.h" #import "MediaInformation.h"
#import "MediaInformationSession.h" #import "MediaInformationSession.h"
@ -28,21 +28,21 @@
- (instancetype)init:(NSArray*)arguments { - (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; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)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; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteDelegate:(id<ExecuteDelegate>)executeDelegate withLogDelegate:(id<LogDelegate>)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; return self;
} }

View File

@ -21,15 +21,13 @@
#define FFMPEG_KIT_SESSION_H #define FFMPEG_KIT_SESSION_H
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "ExecuteDelegate.h" #import "ExecuteCallback.h"
#import "Log.h" #import "Log.h"
#import "LogDelegate.h" #import "LogCallback.h"
#import "LogRedirectionStrategy.h" #import "LogRedirectionStrategy.h"
#import "ReturnCode.h" #import "ReturnCode.h"
#import "SessionState.h" #import "SessionState.h"
@protocol ExecuteDelegate;
/** /**
* <p>Common interface for all <code>FFmpegKit</code> sessions. * <p>Common interface for all <code>FFmpegKit</code> sessions.
*/ */
@ -38,18 +36,18 @@
@required @required
/** /**
* Returns the session specific execute delegate. * Returns the session specific execute callback.
* *
* @return session specific execute delegate * @return session specific execute callback
*/ */
- (id<ExecuteDelegate>)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<LogDelegate>)getLogDelegate; - (LogCallback)getLogCallback;
/** /**
* Returns the session identifier. * Returns the session identifier.

View File

@ -17,25 +17,17 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FFMPEG_KIT_STATISTICS_DELEGATE_H #ifndef FFMPEG_KIT_STATISTICS_CALLBACK_H
#define FFMPEG_KIT_STATISTICS_DELEGATE_H #define FFMPEG_KIT_STATISTICS_CALLBACK_H
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "Statistics.h" #import "Statistics.h"
/** /**
* <p>Delegate that receives statistics generated for <code>FFmpegKit</code> sessions. * <p>Callback that receives statistics generated for <code>FFmpegKit</code> sessions.
*/
@protocol StatisticsDelegate<NSObject>
@required
/**
* <p>Called when a statistics entry is received.
* *
* @param statistics statistics entry * @param statistics statistics entry
*/ */
- (void)statisticsCallback:(Statistics*)statistics; typedef void (^StatisticsCallback)(Statistics* statistics);
@end #endif // FFMPEG_KIT_STATISTICS_CALLBACK_H
#endif // FFMPEG_KIT_STATISTICS_DELEGATE_H

View File

@ -1008,18 +1008,28 @@ build_modulemap() {
cat >"${FILE_PATH}" <<EOF cat >"${FILE_PATH}" <<EOF
framework module ffmpegkit { framework module ffmpegkit {
header "AbstractSession.h"
header "ArchDetect.h" header "ArchDetect.h"
header "AtomicLong.h" header "AtomicLong.h"
header "ExecuteDelegate.h" header "ExecuteCallback.h"
header "FFmpegExecution.h"
header "LogDelegate.h"
header "MediaInformation.h"
header "MediaInformationParser.h"
header "FFmpegKit.h" header "FFmpegKit.h"
header "FFmpegKitConfig.h" header "FFmpegKitConfig.h"
header "FFmpegSession.h"
header "FFprobeKit.h" header "FFprobeKit.h"
header "FFprobeSession.h"
header "Level.h"
header "Log.h"
header "LogCallback.h"
header "LogRedirectionStrategy.h"
header "MediaInformation.h"
header "MediaInformationJsonParser.h"
header "MediaInformationSession.h"
header "Packages.h"
header "ReturnCode.h"
header "Session.h"
header "SessionState.h"
header "Statistics.h" header "Statistics.h"
header "StatisticsDelegate.h" header "StatisticsCallback.h"
header "StreamInformation.h" header "StreamInformation.h"
header "ffmpegkit_exception.h" header "ffmpegkit_exception.h"