FFmpegKit iOS / macOS / tvOS API 4.5
FFmpegKit.m
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2021 Taner Sener
3 *
4 * This file is part of FFmpegKit.
5 *
6 * FFmpegKit is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpegKit is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#import "fftools_ffmpeg.h"
21#import "ArchDetect.h"
22#import "AtomicLong.h"
23#import "FFmpegKit.h"
24#import "FFmpegKitConfig.h"
25#import "Packages.h"
26
27@implementation FFmpegKit
28
29+ (void)initialize {
30 NSLog(@"Loading ffmpeg-kit.\n");
31
32 [FFmpegKitConfig class];
33
34 NSLog(@"Loaded ffmpeg-kit-%@-%@-%@-%@\n", [Packages getPackageName], [ArchDetect getArch], [FFmpegKitConfig getVersion], [FFmpegKitConfig getBuildDate]);
35}
36
37+ (FFmpegSession*)executeWithArguments:(NSArray*)arguments {
38 FFmpegSession* session = [[FFmpegSession alloc] init:arguments];
40 return session;
41}
42
43+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback {
44 FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback];
46 return session;
47}
48
49+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
50 FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
52 return session;
53}
54
55+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue {
56 FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback];
58 return session;
59}
60
61+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue {
62 FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
64 return session;
65}
66
67+ (FFmpegSession*)execute:(NSString*)command {
68 FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command]];
70 return session;
71}
72
73+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback {
74 FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback];
76 return session;
77}
78
79+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
80 FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
82 return session;
83}
84
85+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue {
86 FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback];
88 return session;
89}
90
91+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue {
92 FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
94 return session;
95}
96
97+ (void)cancel {
98
99 /*
100 * ZERO (0) IS A SPECIAL SESSION ID
101 * WHEN IT IS PASSED TO THIS METHOD, A SIGINT IS GENERATED WHICH CANCELS ALL ONGOING SESSIONS
102 */
104}
105
106+ (void)cancel:(long)sessionId {
107 cancel_operation(sessionId);
108}
109
110+ (NSArray*)listSessions {
112}
113
114@end
void(^ ExecuteCallback)(id< Session > session)
void(^ LogCallback)(Log *log)
Definition: LogCallback.h:31
void(^ StatisticsCallback)(Statistics *statistics)
void cancel_operation(long id)
void asyncFFmpegExecute:onDispatchQueue:(FFmpegSession *ffmpegSession,[onDispatchQueue] dispatch_queue_t queue)
NSArray * getFFmpegSessions()
void asyncFFmpegExecute:(FFmpegSession *ffmpegSession)
void ffmpegExecute:(FFmpegSession *ffmpegSession)
NSArray * parseArguments:(NSString *command)
NSArray * listSessions()
Definition: FFmpegKit.m:110
void initialize()
Definition: FFmpegKit.m:29
void cancel()
Definition: FFmpegKit.m:97