FFmpegKit iOS / macOS / tvOS API 6.0
Loading...
Searching...
No Matches
Packages.m
Go to the documentation of this file.
1/*
2 * Copyright (c) 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 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 License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General License
17 * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#import "config.h"
21#import "libavutil/ffversion.h"
22#import "FFmpegKitConfig.h"
23#import "Packages.h"
24
25static NSMutableArray *supportedExternalLibraries;
26
27@implementation Packages
28
29+ (void)initialize {
30 supportedExternalLibraries = [[NSMutableArray alloc] init];
31 [supportedExternalLibraries addObject:@"dav1d"];
32 [supportedExternalLibraries addObject:@"fontconfig"];
33 [supportedExternalLibraries addObject:@"freetype"];
34 [supportedExternalLibraries addObject:@"fribidi"];
35 [supportedExternalLibraries addObject:@"gmp"];
36 [supportedExternalLibraries addObject:@"gnutls"];
37 [supportedExternalLibraries addObject:@"kvazaar"];
38 [supportedExternalLibraries addObject:@"mp3lame"];
39 [supportedExternalLibraries addObject:@"libaom"];
40 [supportedExternalLibraries addObject:@"libass"];
41 [supportedExternalLibraries addObject:@"iconv"];
42 [supportedExternalLibraries addObject:@"libilbc"];
43 [supportedExternalLibraries addObject:@"libtheora"];
44 [supportedExternalLibraries addObject:@"libvidstab"];
45 [supportedExternalLibraries addObject:@"libvorbis"];
46 [supportedExternalLibraries addObject:@"libvpx"];
47 [supportedExternalLibraries addObject:@"libwebp"];
48 [supportedExternalLibraries addObject:@"libxml2"];
49 [supportedExternalLibraries addObject:@"opencore-amr"];
50 [supportedExternalLibraries addObject:@"openh264"];
51 [supportedExternalLibraries addObject:@"opus"];
52 [supportedExternalLibraries addObject:@"rubberband"];
53 [supportedExternalLibraries addObject:@"sdl2"];
54 [supportedExternalLibraries addObject:@"shine"];
55 [supportedExternalLibraries addObject:@"snappy"];
56 [supportedExternalLibraries addObject:@"soxr"];
57 [supportedExternalLibraries addObject:@"speex"];
58 [supportedExternalLibraries addObject:@"tesseract"];
59 [supportedExternalLibraries addObject:@"twolame"];
60 [supportedExternalLibraries addObject:@"x264"];
61 [supportedExternalLibraries addObject:@"x265"];
62 [supportedExternalLibraries addObject:@"xvid"];
63}
64
65+ (NSString*)getBuildConf {
66 return [NSString stringWithUTF8String:FFMPEG_CONFIGURATION];
67}
68
69+ (NSString*)getPackageName {
70 NSArray *enabledLibraryArray = [Packages getExternalLibraries];
71 Boolean speex = [enabledLibraryArray containsObject:@"speex"];
72 Boolean fribidi = [enabledLibraryArray containsObject:@"fribidi"];
73 Boolean gnutls = [enabledLibraryArray containsObject:@"gnutls"];
74 Boolean xvid = [enabledLibraryArray containsObject:@"xvid"];
75
76 Boolean minGpl = false;
77 Boolean https = false;
78 Boolean httpsGpl = false;
79 Boolean audio = false;
80 Boolean video = false;
81 Boolean full = false;
82 Boolean fullGpl = false;
83
84 if (speex && fribidi) {
85 if (xvid) {
86 fullGpl = true;
87 } else {
88 full = true;
89 }
90 } else if (speex) {
91 audio = true;
92 } else if (fribidi) {
93 video = true;
94 } else if (xvid) {
95 if (gnutls) {
96 httpsGpl = true;
97 } else {
98 minGpl = true;
99 }
100 } else {
101 if (gnutls) {
102 https = true;
103 }
104 }
105
106 if (fullGpl) {
107 if ([enabledLibraryArray containsObject:@"dav1d"] &&
108 [enabledLibraryArray containsObject:@"fontconfig"] &&
109 [enabledLibraryArray containsObject:@"freetype"] &&
110 [enabledLibraryArray containsObject:@"fribidi"] &&
111 [enabledLibraryArray containsObject:@"gmp"] &&
112 [enabledLibraryArray containsObject:@"gnutls"] &&
113 [enabledLibraryArray containsObject:@"kvazaar"] &&
114 [enabledLibraryArray containsObject:@"mp3lame"] &&
115 [enabledLibraryArray containsObject:@"libass"] &&
116 [enabledLibraryArray containsObject:@"iconv"] &&
117 [enabledLibraryArray containsObject:@"libilbc"] &&
118 [enabledLibraryArray containsObject:@"libtheora"] &&
119 [enabledLibraryArray containsObject:@"libvidstab"] &&
120 [enabledLibraryArray containsObject:@"libvorbis"] &&
121 [enabledLibraryArray containsObject:@"libvpx"] &&
122 [enabledLibraryArray containsObject:@"libwebp"] &&
123 [enabledLibraryArray containsObject:@"libxml2"] &&
124 [enabledLibraryArray containsObject:@"opencore-amr"] &&
125 [enabledLibraryArray containsObject:@"opus"] &&
126 [enabledLibraryArray containsObject:@"shine"] &&
127 [enabledLibraryArray containsObject:@"snappy"] &&
128 [enabledLibraryArray containsObject:@"soxr"] &&
129 [enabledLibraryArray containsObject:@"speex"] &&
130 [enabledLibraryArray containsObject:@"twolame"] &&
131 [enabledLibraryArray containsObject:@"x264"] &&
132 [enabledLibraryArray containsObject:@"x265"] &&
133 [enabledLibraryArray containsObject:@"xvid"]) {
134 return @"full-gpl";
135 } else {
136 return @"custom";
137 }
138 }
139
140 if (full) {
141 if ([enabledLibraryArray containsObject:@"dav1d"] &&
142 [enabledLibraryArray containsObject:@"fontconfig"] &&
143 [enabledLibraryArray containsObject:@"freetype"] &&
144 [enabledLibraryArray containsObject:@"fribidi"] &&
145 [enabledLibraryArray containsObject:@"gmp"] &&
146 [enabledLibraryArray containsObject:@"gnutls"] &&
147 [enabledLibraryArray containsObject:@"kvazaar"] &&
148 [enabledLibraryArray containsObject:@"mp3lame"] &&
149 [enabledLibraryArray containsObject:@"libass"] &&
150 [enabledLibraryArray containsObject:@"iconv"] &&
151 [enabledLibraryArray containsObject:@"libilbc"] &&
152 [enabledLibraryArray containsObject:@"libtheora"] &&
153 [enabledLibraryArray containsObject:@"libvorbis"] &&
154 [enabledLibraryArray containsObject:@"libvpx"] &&
155 [enabledLibraryArray containsObject:@"libwebp"] &&
156 [enabledLibraryArray containsObject:@"libxml2"] &&
157 [enabledLibraryArray containsObject:@"opencore-amr"] &&
158 [enabledLibraryArray containsObject:@"opus"] &&
159 [enabledLibraryArray containsObject:@"shine"] &&
160 [enabledLibraryArray containsObject:@"snappy"] &&
161 [enabledLibraryArray containsObject:@"soxr"] &&
162 [enabledLibraryArray containsObject:@"speex"] &&
163 [enabledLibraryArray containsObject:@"twolame"]) {
164 return @"full";
165 } else {
166 return @"custom";
167 }
168 }
169
170 if (video) {
171 if ([enabledLibraryArray containsObject:@"dav1d"] &&
172 [enabledLibraryArray containsObject:@"fontconfig"] &&
173 [enabledLibraryArray containsObject:@"freetype"] &&
174 [enabledLibraryArray containsObject:@"fribidi"] &&
175 [enabledLibraryArray containsObject:@"kvazaar"] &&
176 [enabledLibraryArray containsObject:@"libass"] &&
177 [enabledLibraryArray containsObject:@"iconv"] &&
178 [enabledLibraryArray containsObject:@"libtheora"] &&
179 [enabledLibraryArray containsObject:@"libvpx"] &&
180 [enabledLibraryArray containsObject:@"libwebp"] &&
181 [enabledLibraryArray containsObject:@"snappy"]) {
182 return @"video";
183 } else {
184 return @"custom";
185 }
186 }
187
188 if (audio) {
189 if ([enabledLibraryArray containsObject:@"mp3lame"] &&
190 [enabledLibraryArray containsObject:@"libilbc"] &&
191 [enabledLibraryArray containsObject:@"libvorbis"] &&
192 [enabledLibraryArray containsObject:@"opencore-amr"] &&
193 [enabledLibraryArray containsObject:@"opus"] &&
194 [enabledLibraryArray containsObject:@"shine"] &&
195 [enabledLibraryArray containsObject:@"soxr"] &&
196 [enabledLibraryArray containsObject:@"speex"] &&
197 [enabledLibraryArray containsObject:@"twolame"]) {
198 return @"audio";
199 } else {
200 return @"custom";
201 }
202 }
203
204 if (httpsGpl) {
205 if ([enabledLibraryArray containsObject:@"gmp"] &&
206 [enabledLibraryArray containsObject:@"gnutls"] &&
207 [enabledLibraryArray containsObject:@"libvidstab"] &&
208 [enabledLibraryArray containsObject:@"x264"] &&
209 [enabledLibraryArray containsObject:@"x265"] &&
210 [enabledLibraryArray containsObject:@"xvid"]) {
211 return @"https-gpl";
212 } else {
213 return @"custom";
214 }
215 }
216
217 if (https) {
218 if ([enabledLibraryArray containsObject:@"gmp"] &&
219 [enabledLibraryArray containsObject:@"gnutls"]) {
220 return @"https";
221 } else {
222 return @"custom";
223 }
224 }
225
226 if (minGpl) {
227 if ([enabledLibraryArray containsObject:@"libvidstab"] &&
228 [enabledLibraryArray containsObject:@"x264"] &&
229 [enabledLibraryArray containsObject:@"x265"] &&
230 [enabledLibraryArray containsObject:@"xvid"]) {
231 return @"min-gpl";
232 } else {
233 return @"custom";
234 }
235 }
236
237 return @"min";
238}
239
240+ (NSArray*)getExternalLibraries {
241 NSString *buildConfiguration = [Packages getBuildConf];
242 NSMutableArray *enabledLibraryArray = [[NSMutableArray alloc] init];
243
244 for (int i=0; i < [supportedExternalLibraries count]; i++) {
245 NSString *supportedExternalLibrary = [supportedExternalLibraries objectAtIndex:i];
246
247 NSString *libraryName1 = [NSString stringWithFormat:@"enable-%@", supportedExternalLibrary];
248 NSString *libraryName2 = [NSString stringWithFormat:@"enable-lib%@", supportedExternalLibrary];
249
250 if ([buildConfiguration rangeOfString:libraryName1].location != NSNotFound || [buildConfiguration rangeOfString:libraryName2].location != NSNotFound) {
251 [enabledLibraryArray addObject:supportedExternalLibrary];
252 }
253 }
254
255 [enabledLibraryArray sortUsingSelector:@selector(compare:)];
256
257 return enabledLibraryArray;
258}
259
260@end
static NSMutableArray * supportedExternalLibraries
Definition Packages.m:25
void initialize()
Definition Packages.m:29
NSString * getPackageName()
Definition Packages.m:69
NSString * getBuildConf()
Definition Packages.m:65
NSArray * getExternalLibraries()
Definition Packages.m:240