| FFmpegKit Linux API 6.0

Loading...
Searching...
No Matches
Packages.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 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 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#include "Packages.h"
21#include "config.h"
22#include <memory>
23#include <algorithm>
24
25std::string ffmpegkit::Packages::getPackageName() {
26 std::shared_ptr<std::set<std::string>> enabledLibrarySet = getExternalLibraries();
27 #define contains_ext_lib(element) enabledLibrarySet->find(element) != enabledLibrarySet->end()
28 bool speex = contains_ext_lib("speex");
29 bool fribidi = contains_ext_lib("fribidi");
30 bool gnutls = contains_ext_lib("gnutls");
31 bool xvid = contains_ext_lib("xvid");
32
33 bool min = false;
34 bool minGpl = false;
35 bool https = false;
36 bool httpsGpl = false;
37 bool audio = false;
38 bool video = false;
39 bool full = false;
40 bool fullGpl = false;
41
42 if (speex && fribidi) {
43 if (xvid) {
44 fullGpl = true;
45 } else {
46 full = true;
47 }
48 } else if (speex) {
49 audio = true;
50 } else if (fribidi) {
51 video = true;
52 } else if (xvid) {
53 if (gnutls) {
54 httpsGpl = true;
55 } else {
56 minGpl = true;
57 }
58 } else {
59 if (gnutls) {
60 https = true;
61 } else {
62 min = true;
63 }
64 }
65
66 if (fullGpl) {
67 if (contains_ext_lib("dav1d") &&
68 contains_ext_lib("fontconfig") &&
69 contains_ext_lib("freetype") &&
70 contains_ext_lib("fribidi") &&
71 contains_ext_lib("gmp") &&
72 contains_ext_lib("gnutls") &&
73 contains_ext_lib("kvazaar") &&
74 contains_ext_lib("mp3lame") &&
75 contains_ext_lib("libass") &&
76 contains_ext_lib("iconv") &&
77 contains_ext_lib("libilbc") &&
78 contains_ext_lib("libtheora") &&
79 contains_ext_lib("libvidstab") &&
80 contains_ext_lib("libvorbis") &&
81 contains_ext_lib("libvpx") &&
82 contains_ext_lib("libwebp") &&
83 contains_ext_lib("libxml2") &&
84 contains_ext_lib("opencore-amr") &&
85 contains_ext_lib("opus") &&
86 contains_ext_lib("shine") &&
87 contains_ext_lib("snappy") &&
88 contains_ext_lib("soxr") &&
89 contains_ext_lib("speex") &&
90 contains_ext_lib("twolame") &&
91 contains_ext_lib("x264") &&
92 contains_ext_lib("x265") &&
93 contains_ext_lib("xvid")) {
94 return "full-gpl";
95 } else {
96 return "custom";
97 }
98 }
99
100 if (full) {
101 if (contains_ext_lib("dav1d") &&
102 contains_ext_lib("fontconfig") &&
103 contains_ext_lib("freetype") &&
104 contains_ext_lib("fribidi") &&
105 contains_ext_lib("gmp") &&
106 contains_ext_lib("gnutls") &&
107 contains_ext_lib("kvazaar") &&
108 contains_ext_lib("mp3lame") &&
109 contains_ext_lib("libass") &&
110 contains_ext_lib("iconv") &&
111 contains_ext_lib("libilbc") &&
112 contains_ext_lib("libtheora") &&
113 contains_ext_lib("libvorbis") &&
114 contains_ext_lib("libvpx") &&
115 contains_ext_lib("libwebp") &&
116 contains_ext_lib("libxml2") &&
117 contains_ext_lib("opencore-amr") &&
118 contains_ext_lib("opus") &&
119 contains_ext_lib("shine") &&
120 contains_ext_lib("snappy") &&
121 contains_ext_lib("soxr") &&
122 contains_ext_lib("speex") &&
123 contains_ext_lib("twolame")) {
124 return "full";
125 } else {
126 return "custom";
127 }
128 }
129
130 if (video) {
131 if (contains_ext_lib("dav1d") &&
132 contains_ext_lib("fontconfig") &&
133 contains_ext_lib("freetype") &&
134 contains_ext_lib("fribidi") &&
135 contains_ext_lib("kvazaar") &&
136 contains_ext_lib("libass") &&
137 contains_ext_lib("iconv") &&
138 contains_ext_lib("libtheora") &&
139 contains_ext_lib("libvpx") &&
140 contains_ext_lib("libwebp") &&
141 contains_ext_lib("snappy")) {
142 return "video";
143 } else {
144 return "custom";
145 }
146 }
147
148 if (audio) {
149 if (contains_ext_lib("mp3lame") &&
150 contains_ext_lib("libilbc") &&
151 contains_ext_lib("libvorbis") &&
152 contains_ext_lib("opencore-amr") &&
153 contains_ext_lib("opus") &&
154 contains_ext_lib("shine") &&
155 contains_ext_lib("soxr") &&
156 contains_ext_lib("speex") &&
157 contains_ext_lib("twolame")) {
158 return "audio";
159 } else {
160 return "custom";
161 }
162 }
163
164 if (httpsGpl) {
165 if (contains_ext_lib("gmp") &&
166 contains_ext_lib("gnutls") &&
167 contains_ext_lib("libvidstab") &&
168 contains_ext_lib("x264") &&
169 contains_ext_lib("x265") &&
170 contains_ext_lib("xvid")) {
171 return "https-gpl";
172 } else {
173 return "custom";
174 }
175 }
176
177 if (https) {
178 if (contains_ext_lib("gmp") &&
179 contains_ext_lib("gnutls")) {
180 return "https";
181 } else {
182 return "custom";
183 }
184 }
185
186 if (minGpl) {
187 if (contains_ext_lib("libvidstab") &&
188 contains_ext_lib("x264") &&
189 contains_ext_lib("x265") &&
190 contains_ext_lib("xvid")) {
191 return "min-gpl";
192 } else {
193 return "custom";
194 }
195 }
196
197 return "min";
198}
199
200std::shared_ptr<std::set<std::string>> ffmpegkit::Packages::getExternalLibraries() {
201 const std::set<const char*> supportedExternalLibraries{
202 "dav1d",
203 "fontconfig",
204 "freetype",
205 "fribidi",
206 "gmp",
207 "gnutls",
208 "kvazaar",
209 "mp3lame",
210 "libaom",
211 "libass",
212 "iconv",
213 "libilbc",
214 "libtheora",
215 "libvidstab",
216 "libvorbis",
217 "libvpx",
218 "libwebp",
219 "libxml2",
220 "opencore-amr",
221 "openh264",
222 "opus",
223 "rubberband",
224 "sdl2",
225 "shine",
226 "snappy",
227 "soxr",
228 "speex",
229 "tesseract",
230 "twolame",
231 "x264",
232 "x265",
233 "xvid"};
234 std::string buildConfiguration(FFMPEG_CONFIGURATION);
235 char libraryName1[50];
236 char libraryName2[50];
237 std::shared_ptr<std::set<std::string>> enabledLibrarySet = std::make_shared<std::set<std::string>>();
238
239 std::for_each(supportedExternalLibraries.cbegin(), supportedExternalLibraries.cend(), [&](const char* supportedExternalLibrary) {
240 sprintf(libraryName1, "enable-%s", supportedExternalLibrary);
241 sprintf(libraryName2, "enable-lib%s", supportedExternalLibrary);
242
243 if (buildConfiguration.find(libraryName1) != std::string::npos || buildConfiguration.find(libraryName2) != std::string::npos) {
244 enabledLibrarySet->insert(supportedExternalLibrary);
245 }
246 });
247
248 return enabledLibrarySet;
249}
contains_ext_lib
#define contains_ext_lib(element)
Packages.h
ffmpegkit::Packages::getPackageName
static std::string getPackageName()
Definition Packages.cpp:25
ffmpegkit::Packages::getExternalLibraries
static std::shared_ptr< std::set< std::string > > getExternalLibraries()
Definition Packages.cpp:200