# FFmpegKit iOS / macOS / tvOS API: FFmpegKit.m Source File

Loading...
Searching...
No Matches
FFmpegKit.m
Go to the documentation of this file.
/*
* Copyright (c) 2018-2022 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
#import "fftools_ffmpeg.h"
#import "ArchDetect.h"
#import "AtomicLong.h"
#import "FFmpegKit.h"
#import "FFmpegKitConfig.h"
#import "Packages.h"
@implementation FFmpegKit
+ (void)initialize {
NSLog(@"Loading ffmpeg-kit.\n");
[FFmpegKitConfig class];
NSLog(@"Loaded ffmpeg-kit-%@-%@-%@-%@.\n", [Packages getPackageName], [ArchDetect getArch], [FFmpegKitConfig getVersion], [FFmpegKitConfig getBuildDate]);
}
+ (FFmpegSession*)executeWithArguments:(NSArray*)arguments {
FFmpegSession* session = [FFmpegSession create:arguments];
[FFmpegKitConfig ffmpegExecute:session];
return session;
}
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback {
FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session];
return session;
}
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session];
return session;
}
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session;
}
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session;
}
+ (FFmpegSession*)execute:(NSString*)command {
FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command]];
[FFmpegKitConfig ffmpegExecute:session];
return session;
}
+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback {
FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session];
return session;
}
+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session];
return session;
}
+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session;
}
+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session;
}
+ (void)cancel {
/*
* ZERO (0) IS A SPECIAL SESSION ID
* WHEN IT IS PASSED TO THIS METHOD, A SIGINT IS GENERATED WHICH CANCELS ALL ONGOING SESSIONS
*/
cancel_operation(0);
}
+ (void)cancel:(long)sessionId {
cancel_operation(sessionId);
}
+ (NSArray*)listSessions {
return [FFmpegKitConfig getFFmpegSessions];
}
@end
ArchDetect.h
AtomicLong.h
FFmpegKit.h
FFmpegKitConfig.h
FFmpegSessionCompleteCallback
void(^ FFmpegSessionCompleteCallback)(FFmpegSession *session)
Definition FFmpegSessionCompleteCallback.h:46
LogCallback
void(^ LogCallback)(Log *log)
Definition LogCallback.h:31
Packages.h
StatisticsCallback
void(^ StatisticsCallback)(Statistics *statistics)
Definition StatisticsCallback.h:31
cancel_operation
void cancel_operation(long id)
Definition fftools_ffmpeg.c:4367
fftools_ffmpeg.h
ArchDetect
Definition ArchDetect.h:29
FFmpegKitConfig
Definition FFmpegKitConfig.h:49
+[FFmpegKitConfig asyncFFmpegExecute:onDispatchQueue:]
void asyncFFmpegExecute:onDispatchQueue:(FFmpegSession *ffmpegSession,[onDispatchQueue] dispatch_queue_t queue)
Definition FFmpegKitConfig.m:1027
+[FFmpegKitConfig getFFmpegSessions]
NSArray * getFFmpegSessions()
Definition FFmpegKitConfig.m:1249
+[FFmpegKitConfig asyncFFmpegExecute:]
void asyncFFmpegExecute:(FFmpegSession *ffmpegSession)
Definition FFmpegKitConfig.m:1023
+[FFmpegKitConfig ffmpegExecute:]
void ffmpegExecute:(FFmpegSession *ffmpegSession)
Definition FFmpegKitConfig.m:974
+[FFmpegKitConfig parseArguments:]
NSArray * parseArguments:(NSString *command)
Definition FFmpegKitConfig.m:1339
FFmpegKit
Definition FFmpegKit.h:44
+[FFmpegKit listSessions]
NSArray * listSessions()
Definition FFmpegKit.m:110
+[FFmpegKit initialize]
void initialize()
Definition FFmpegKit.m:29
+[FFmpegKit cancel]
void cancel()
Definition FFmpegKit.m:97
FFmpegSession
Definition FFmpegSession.h:32
+[FFmpegSession create:withCompleteCallback:]
instancetype create:withCompleteCallback:(NSArray *arguments,[withCompleteCallback] FFmpegSessionCompleteCallback completeCallback)
Definition FFmpegSession.m:40
+[FFmpegSession create:withCompleteCallback:withLogCallback:withStatisticsCallback:]
instancetype create:withCompleteCallback:withLogCallback:withStatisticsCallback:(NSArray *arguments,[withCompleteCallback] FFmpegSessionCompleteCallback completeCallback,[withLogCallback] LogCallback logCallback,[withStatisticsCallback] StatisticsCallback statisticsCallback)
Definition FFmpegSession.m:44
+[FFmpegSession create:]
instancetype create:(NSArray *arguments)
Definition FFmpegSession.m:36
Packages
Definition Packages.h:29