| 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];
39 [FFmpegKitConfig ffmpegExecute:session];
40 return session;
41}
42
43+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback {
44 FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback];
45 [FFmpegKitConfig asyncFFmpegExecute:session];
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];
51 [FFmpegKitConfig asyncFFmpegExecute:session];
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];
57 [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
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];
63 [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
64 return session;
65}
66
67+ (FFmpegSession*)execute:(NSString*)command {
68 FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command]];
69 [FFmpegKitConfig ffmpegExecute:session];
70 return session;
71}
72
73+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback {
74 FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback];
75 [FFmpegKitConfig asyncFFmpegExecute:session];
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];
81 [FFmpegKitConfig asyncFFmpegExecute:session];
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];
87 [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
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];
93 [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
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 */
103 cancel_operation(0);
104}
105
106+ (void)cancel:(long)sessionId {
107 cancel_operation(sessionId);
108}
109
110+ (NSArray*)listSessions {
111 return [FFmpegKitConfig getFFmpegSessions];
112}
113
114@end
ArchDetect.h
AtomicLong.h
ExecuteCallback
void(^ ExecuteCallback)(id< Session > session)
Definition: ExecuteCallback.h:46
FFmpegKit.h
FFmpegKitConfig.h
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:5198
fftools_ffmpeg.h
ArchDetect
Definition: ArchDetect.h:29
FFmpegKitConfig
Definition: FFmpegKitConfig.h:50
+[FFmpegKitConfig asyncFFmpegExecute:onDispatchQueue:]
void asyncFFmpegExecute:onDispatchQueue:(FFmpegSession *ffmpegSession,[onDispatchQueue] dispatch_queue_t queue)
Definition: FFmpegKitConfig.m:918
+[FFmpegKitConfig getFFmpegSessions]
NSArray * getFFmpegSessions()
Definition: FFmpegKitConfig.m:1083
+[FFmpegKitConfig asyncFFmpegExecute:]
void asyncFFmpegExecute:(FFmpegSession *ffmpegSession)
Definition: FFmpegKitConfig.m:914
+[FFmpegKitConfig ffmpegExecute:]
void ffmpegExecute:(FFmpegSession *ffmpegSession)
Definition: FFmpegKitConfig.m:873
+[FFmpegKitConfig parseArguments:]
NSArray * parseArguments:(NSString *command)
Definition: FFmpegKitConfig.m:1156
FFmpegKit
Definition: FFmpegKit.h:45
+[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:31
Packages
Definition: Packages.h:29