| FFmpegKit iOS / macOS / tvOS API 6.0

Loading...
Searching...
No Matches
FFmpegKit.m
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2022 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 create:arguments];
39 [FFmpegKitConfig ffmpegExecute:session];
40 return session;
41}
42
43+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback {
44 FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback];
45 [FFmpegKitConfig asyncFFmpegExecute:session];
46 return session;
47}
48
49+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
50 FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
51 [FFmpegKitConfig asyncFFmpegExecute:session];
52 return session;
53}
54
55+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue {
56 FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback];
57 [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
58 return session;
59}
60
61+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue {
62 FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
63 [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
64 return session;
65}
66
67+ (FFmpegSession*)execute:(NSString*)command {
68 FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command]];
69 [FFmpegKitConfig ffmpegExecute:session];
70 return session;
71}
72
73+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback {
74 FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback];
75 [FFmpegKitConfig asyncFFmpegExecute:session];
76 return session;
77}
78
79+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
80 FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
81 [FFmpegKitConfig asyncFFmpegExecute:session];
82 return session;
83}
84
85+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue {
86 FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback];
87 [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
88 return session;
89}
90
91+ (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue {
92 FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback 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
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