Commit | Line | Data |
---|---|---|
94e96f7f MW |
1 | Support building with system media libraries. |
2 | See <https://bugzilla.mozilla.org/show_bug.cgi?id=517422> | |
3 | ||
4 | Based on: | |
5 | https://svnweb.freebsd.org/ports/head/www/firefox-esr/files/patch-z-bug517422?revision=472833&view=markup | |
6 | ||
7 | Changes to files within the bundled libraries are omitted, since those files | |
8 | are removed from Guix sources. Modified for use with patch -p1, and to apply | |
9 | cleanly to GNU IceCat. | |
10 | ||
11 | --- icecat-60.2.0/build/moz.configure/old.configure | |
12 | +++ icecat-60.2.0/build/moz.configure/old.configure | |
13 | @@ -273,7 +273,12 @@ | |
14 | '--with-system-libvpx', | |
15 | '--with-system-nspr', | |
16 | '--with-system-nss', | |
17 | + '--with-system-ogg', | |
18 | '--with-system-png', | |
19 | + '--with-system-soundtouch', | |
20 | + '--with-system-theora', | |
21 | + '--with-system-tremor', | |
22 | + '--with-system-vorbis', | |
23 | '--with-system-zlib', | |
24 | '--with-thumb', | |
25 | '--with-thumb-interwork', | |
26 | --- icecat-60.2.0/config/external/moz.build | |
27 | +++ icecat-60.2.0/config/external/moz.build | |
28 | @@ -23,12 +23,21 @@ | |
29 | ||
30 | external_dirs += ['modules/xz-embedded'] | |
31 | ||
32 | -if CONFIG['MOZ_VORBIS']: | |
33 | +if not CONFIG['MOZ_SYSTEM_OGG']: | |
34 | + external_dirs += ['media/libogg'] | |
35 | + | |
36 | +if CONFIG['MOZ_VORBIS'] and not CONFIG['MOZ_SYSTEM_VORBIS']: | |
37 | external_dirs += ['media/libvorbis'] | |
38 | ||
39 | -if CONFIG['MOZ_TREMOR']: | |
40 | +if CONFIG['MOZ_TREMOR'] and not CONFIG['MOZ_SYSTEM_TREMOR']: | |
41 | external_dirs += ['media/libtremor'] | |
42 | ||
43 | +if not CONFIG['MOZ_SYSTEM_THEORA']: | |
44 | + external_dirs += ['media/libtheora'] | |
45 | + | |
46 | +if not CONFIG['MOZ_SYSTEM_SOUNDTOUCH']: | |
47 | + external_dirs += ['media/libsoundtouch'] | |
48 | + | |
49 | if CONFIG['MOZ_WEBM_ENCODER']: | |
50 | external_dirs += ['media/libmkv'] | |
51 | ||
52 | @@ -51,11 +60,8 @@ | |
53 | 'media/kiss_fft', | |
54 | 'media/libcubeb', | |
55 | 'media/libnestegg', | |
56 | - 'media/libogg', | |
57 | 'media/libopus', | |
58 | - 'media/libtheora', | |
59 | 'media/libspeex_resampler', | |
60 | - 'media/libsoundtouch', | |
61 | 'media/mp4parse-rust', | |
62 | 'media/psshparser' | |
63 | ] | |
64 | --- icecat-60.2.0/config/system-headers.mozbuild | |
65 | +++ icecat-60.2.0/config/system-headers.mozbuild | |
66 | @@ -1324,6 +1324,28 @@ | |
67 | 'harfbuzz/hb.h', | |
68 | ] | |
69 | ||
70 | +if CONFIG['MOZ_SYSTEM_OGG']: | |
71 | + system_headers += [ | |
72 | + 'ogg/ogg.h', | |
73 | + 'ogg/os_types.h', | |
74 | + ] | |
75 | + | |
76 | +if CONFIG['MOZ_SYSTEM_THEORA']: | |
77 | + system_headers += [ | |
78 | + 'theora/theoradec.h', | |
79 | + ] | |
80 | + | |
81 | +if CONFIG['MOZ_SYSTEM_VORBIS']: | |
82 | + system_headers += [ | |
83 | + 'vorbis/codec.h', | |
84 | + 'vorbis/vorbisenc.h', | |
85 | + ] | |
86 | + | |
87 | +if CONFIG['MOZ_SYSTEM_TREMOR']: | |
88 | + system_headers += [ | |
89 | + 'tremor/ivorbiscodec.h', | |
90 | + ] | |
91 | + | |
92 | if CONFIG['MOZ_SYSTEM_LIBVPX']: | |
93 | system_headers += [ | |
94 | 'vpx_mem/vpx_mem.h', | |
95 | --- icecat-60.2.0/dom/media/AudioStream.cpp | |
96 | +++ icecat-60.2.0/dom/media/AudioStream.cpp | |
97 | @@ -121,7 +121,9 @@ | |
98 | : mMonitor("AudioStream") | |
99 | , mChannels(0) | |
100 | , mOutChannels(0) | |
101 | +#ifndef MOZ_SYSTEM_SOUNDTOUCH | |
102 | , mTimeStretcher(nullptr) | |
103 | +#endif | |
104 | , mDumpFile(nullptr) | |
105 | , mState(INITIALIZED) | |
106 | , mDataSource(aSource) | |
107 | @@ -142,9 +144,11 @@ | |
108 | if (mDumpFile) { | |
109 | fclose(mDumpFile); | |
110 | } | |
111 | +#ifndef MOZ_SYSTEM_SOUNDTOUCH | |
112 | if (mTimeStretcher) { | |
113 | soundtouch::destroySoundTouchObj(mTimeStretcher); | |
114 | } | |
115 | +#endif | |
116 | #if defined(XP_WIN) | |
117 | if (XRE_IsContentProcess()) { | |
118 | audio::AudioNotificationReceiver::Unregister(this); | |
119 | @@ -168,7 +172,11 @@ | |
120 | { | |
121 | mMonitor.AssertCurrentThreadOwns(); | |
122 | if (!mTimeStretcher) { | |
123 | +#ifdef MOZ_SYSTEM_SOUNDTOUCH | |
124 | + mTimeStretcher = new soundtouch::SoundTouch(); | |
125 | +#else | |
126 | mTimeStretcher = soundtouch::createSoundTouchObj(); | |
127 | +#endif | |
128 | mTimeStretcher->setSampleRate(mAudioClock.GetInputRate()); | |
129 | mTimeStretcher->setChannels(mOutChannels); | |
130 | mTimeStretcher->setPitch(1.0); | |
131 | --- icecat-60.2.0/dom/media/AudioStream.h | |
132 | +++ icecat-60.2.0/dom/media/AudioStream.h | |
133 | @@ -15,7 +15,11 @@ | |
134 | #include "mozilla/TimeStamp.h" | |
135 | #include "mozilla/UniquePtr.h" | |
136 | #include "CubebUtils.h" | |
137 | +#ifdef MOZ_SYSTEM_SOUNDTOUCH | |
138 | +#include "soundtouch/SoundTouch.h" | |
139 | +#else | |
140 | #include "soundtouch/SoundTouchFactory.h" | |
141 | +#endif | |
142 | ||
143 | #if defined(XP_WIN) | |
144 | #include "mozilla/audio/AudioNotificationReceiver.h" | |
145 | @@ -297,7 +301,11 @@ | |
146 | uint32_t mChannels; | |
147 | uint32_t mOutChannels; | |
148 | AudioClock mAudioClock; | |
149 | +#ifdef MOZ_SYSTEM_SOUNDTOUCH | |
150 | + nsAutoPtr<soundtouch::SoundTouch> mTimeStretcher; | |
151 | +#else | |
152 | soundtouch::SoundTouch* mTimeStretcher; | |
153 | +#endif | |
154 | ||
155 | // Output file for dumping audio | |
156 | FILE* mDumpFile; | |
157 | --- icecat-60.2.0/dom/media/moz.build | |
158 | +++ icecat-60.2.0/dom/media/moz.build | |
159 | @@ -327,6 +327,21 @@ | |
160 | ||
161 | DEFINES['MOZILLA_INTERNAL_API'] = True | |
162 | ||
163 | +if CONFIG['MOZ_SYSTEM_OGG']: | |
164 | + CXXFLAGS += CONFIG['MOZ_OGG_CFLAGS'] | |
165 | + | |
166 | +if CONFIG['MOZ_SYSTEM_THEORA']: | |
167 | + CXXFLAGS += CONFIG['MOZ_THEORA_CFLAGS'] | |
168 | + | |
169 | +if CONFIG['MOZ_SYSTEM_VORBIS']: | |
170 | + CXXFLAGS += CONFIG['MOZ_VORBIS_CFLAGS'] | |
171 | + | |
172 | +if CONFIG['MOZ_SYSTEM_TREMOR']: | |
173 | + CXXFLAGS += CONFIG['MOZ_TREMOR_CFLAGS'] | |
174 | + | |
175 | +if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']: | |
176 | + CXXFLAGS += CONFIG['MOZ_SOUNDTOUCH_CFLAGS'] | |
177 | + | |
178 | if CONFIG['MOZ_ANDROID_HLS_SUPPORT']: | |
179 | DEFINES['MOZ_ANDROID_HLS_SUPPORT'] = True | |
180 | ||
181 | --- icecat-60.2.0/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp | |
182 | +++ icecat-60.2.0/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp | |
183 | @@ -15,9 +15,13 @@ | |
184 | #include <windows.h> | |
185 | #endif | |
186 | ||
187 | +#ifdef MOZ_SYSTEM_SOUNDTOUCH | |
188 | +#include "nsXPCOMPrivate.h" // for XUL_DLL | |
189 | +#else | |
190 | // We use a known symbol located in lgpllibs to determine its location. | |
191 | // soundtouch happens to be always included in lgpllibs | |
192 | #include "soundtouch/SoundTouch.h" | |
193 | +#endif | |
194 | ||
195 | namespace mozilla { | |
196 | ||
197 | @@ -64,6 +68,12 @@ | |
198 | ||
199 | sLinkStatus = LinkStatus_FAILED; | |
200 | ||
201 | +#ifdef MOZ_SYSTEM_SOUNDTOUCH | |
202 | + // We retrieve the path of the XUL library as this is where mozavcodec and | |
203 | + // mozavutil libs are located. | |
204 | + char* path = | |
205 | + PR_GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Init); | |
206 | +#else | |
207 | // We retrieve the path of the lgpllibs library as this is where mozavcodec | |
208 | // and mozavutil libs are located. | |
209 | PathString lgpllibsname = GetLibraryName(nullptr, "lgpllibs"); | |
210 | @@ -73,6 +83,7 @@ | |
211 | PathString path = | |
212 | GetLibraryFilePathname(lgpllibsname.get(), | |
213 | (PRFuncPtr)&soundtouch::SoundTouch::getVersionId); | |
214 | +#endif | |
215 | if (path.IsEmpty()) { | |
216 | return false; | |
217 | } | |
218 | --- icecat-60.2.0/old-configure.in | |
219 | +++ icecat-60.2.0/old-configure.in | |
220 | @@ -2451,6 +2451,111 @@ | |
221 | fi | |
222 | fi # COMPILE_ENVIRONMENT | |
223 | ||
224 | +dnl ======================================================== | |
225 | +dnl Check for libogg | |
226 | +dnl ======================================================== | |
227 | + | |
228 | +MOZ_ARG_WITH_BOOL(system-ogg, | |
229 | +[ --with-system-ogg Use system libogg (located with pkgconfig)], | |
230 | +MOZ_SYSTEM_OGG=1, | |
231 | +MOZ_SYSTEM_OGG=) | |
232 | + | |
233 | +if test -n "$MOZ_SYSTEM_OGG"; then | |
234 | + PKG_CHECK_MODULES(MOZ_OGG, ogg >= 1.3.3) | |
235 | + | |
236 | + _SAVE_LIBS=$LIBS | |
237 | + LIBS="$LIBS $MOZ_OGG_LIBS" | |
238 | + AC_CHECK_FUNC(ogg_set_mem_functions, [], | |
239 | + [AC_DEFINE(MOZ_OGG_NO_MEM_REPORTING)]) | |
240 | + LIBS=$_SAVE_LIBS | |
241 | +fi | |
242 | + | |
243 | +AC_SUBST(MOZ_SYSTEM_OGG) | |
244 | + | |
245 | +dnl ======================================================== | |
246 | +dnl Check for libvorbis | |
247 | +dnl ======================================================== | |
248 | + | |
249 | +MOZ_ARG_WITH_BOOL(system-vorbis, | |
250 | +[ --with-system-vorbis Use system libvorbis (located with pkgconfig)], | |
251 | +MOZ_SYSTEM_VORBIS=1, | |
252 | +MOZ_SYSTEM_VORBIS=) | |
253 | + | |
254 | +if test -n "$MOZ_SYSTEM_VORBIS"; then | |
255 | + PKG_CHECK_MODULES(MOZ_VORBIS, vorbis vorbisenc >= 1.3.6) | |
256 | +fi | |
257 | + | |
258 | +AC_SUBST(MOZ_SYSTEM_VORBIS) | |
259 | + | |
260 | +dnl ======================================================== | |
261 | +dnl Check for integer-only libvorbis aka tremor | |
262 | +dnl ======================================================== | |
263 | + | |
264 | +MOZ_ARG_WITH_BOOL(system-tremor, | |
265 | +[ --with-system-tremor Use system libtremor (located with pkgconfig)], | |
266 | +MOZ_SYSTEM_TREMOR=1, | |
267 | +MOZ_SYSTEM_TREMOR=) | |
268 | + | |
269 | +if test -n "$MOZ_SYSTEM_TREMOR"; then | |
270 | + PKG_CHECK_MODULES(MOZ_TREMOR, vorbisidec >= 1.2.1) | |
271 | +fi | |
272 | + | |
273 | +AC_SUBST(MOZ_SYSTEM_TREMOR) | |
274 | + | |
275 | +dnl ======================================================== | |
276 | +dnl Check for libtheora | |
277 | +dnl ======================================================== | |
278 | + | |
279 | +MOZ_ARG_WITH_BOOL(system-theora, | |
280 | +[ --with-system-theora Use system libtheora (located with pkgconfig)], | |
281 | +MOZ_SYSTEM_THEORA=1, | |
282 | +MOZ_SYSTEM_THEORA=) | |
283 | + | |
284 | +if test -n "$MOZ_SYSTEM_THEORA"; then | |
285 | + PKG_CHECK_MODULES(MOZ_THEORA, theora >= 1.2) | |
286 | +fi | |
287 | + | |
288 | +AC_SUBST(MOZ_SYSTEM_THEORA) | |
289 | + | |
290 | +dnl ======================================================== | |
291 | +dnl Check for libSoundTouch | |
292 | +dnl ======================================================== | |
293 | + | |
294 | +MOZ_ARG_WITH_BOOL(system-soundtouch, | |
295 | +[ --with-system-soundtouch Use system libSoundTouch (located with pkgconfig)], | |
296 | +MOZ_SYSTEM_SOUNDTOUCH=1, | |
297 | +MOZ_SYSTEM_SOUNDTOUCH=) | |
298 | + | |
299 | +if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then | |
300 | + PKG_CHECK_MODULES(MOZ_SOUNDTOUCH, soundtouch >= 1.9.0) | |
301 | + | |
302 | + AC_LANG_SAVE | |
303 | + AC_LANG_CPLUSPLUS | |
304 | + _SAVE_CXXFLAGS=$CXXFLAGS | |
305 | + CXXFLAGS="$CXXFLAGS $MOZ_SOUNDTOUCH_CFLAGS" | |
306 | + AC_CACHE_CHECK(for soundtouch sample type, | |
307 | + ac_cv_soundtouch_sample_type, | |
308 | + [AC_TRY_COMPILE([#include <SoundTouch.h> | |
309 | + #ifndef SOUNDTOUCH_INTEGER_SAMPLES | |
310 | + #error soundtouch expects float samples | |
311 | + #endif], | |
312 | + [], | |
313 | + [ac_cv_soundtouch_sample_type=short], | |
314 | + [ac_cv_soundtouch_sample_type=float])]) | |
315 | + CXXFLAGS=$_SAVE_CXXFLAGS | |
316 | + AC_LANG_RESTORE | |
317 | + | |
318 | + if test \( -n "$MOZ_SAMPLE_TYPE_S16" -a "$ac_cv_soundtouch_sample_type" != short \) \ | |
319 | + -o \( -n "$MOZ_SAMPLE_TYPE_FLOAT32" -a "$ac_cv_soundtouch_sample_type" != float \) ; then | |
320 | + AC_MSG_ERROR([SoundTouch library is built with incompatible sample type. Either rebuild the library with/without --enable-integer-samples, chase default Mozilla sample type or remove --with-system-soundtouch.]) | |
321 | + fi | |
322 | +fi | |
323 | + | |
324 | +if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then | |
325 | + AC_DEFINE(MOZ_SYSTEM_SOUNDTOUCH) | |
326 | +fi | |
327 | +AC_SUBST(MOZ_SYSTEM_SOUNDTOUCH) | |
328 | + | |
329 | dnl system libvpx Support | |
330 | dnl ======================================================== | |
331 | MOZ_ARG_WITH_BOOL(system-libvpx, | |
332 | --- icecat-60.2.0/toolkit/library/moz.build | |
333 | +++ icecat-60.2.0/toolkit/library/moz.build | |
334 | @@ -244,6 +244,21 @@ | |
335 | if CONFIG['MOZ_SYSTEM_HUNSPELL']: | |
336 | OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS'] | |
337 | ||
338 | +if CONFIG['MOZ_SYSTEM_OGG']: | |
339 | + OS_LIBS += CONFIG['MOZ_OGG_LIBS'] | |
340 | + | |
341 | +if CONFIG['MOZ_SYSTEM_THEORA']: | |
342 | + OS_LIBS += CONFIG['MOZ_THEORA_LIBS'] | |
343 | + | |
344 | +if CONFIG['MOZ_SYSTEM_VORBIS']: | |
345 | + OS_LIBS += CONFIG['MOZ_VORBIS_LIBS'] | |
346 | + | |
347 | +if CONFIG['MOZ_SYSTEM_TREMOR']: | |
348 | + OS_LIBS += CONFIG['MOZ_TREMOR_LIBS'] | |
349 | + | |
350 | +if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']: | |
351 | + OS_LIBS += CONFIG['MOZ_SOUNDTOUCH_LIBS'] | |
352 | + | |
353 | if CONFIG['MOZ_SYSTEM_LIBEVENT']: | |
354 | OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS'] | |
355 | ||
356 | --- icecat-60.2.0/xpcom/build/XPCOMInit.cpp | |
357 | +++ icecat-60.2.0/xpcom/build/XPCOMInit.cpp | |
358 | @@ -138,7 +138,9 @@ | |
359 | ||
360 | #include "mozilla/ipc/GeckoChildProcessHost.h" | |
361 | ||
362 | +#ifndef MOZ_OGG_NO_MEM_REPORTING | |
363 | #include "ogg/ogg.h" | |
364 | +#endif | |
365 | #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING) | |
366 | #if defined(HAVE_STDINT_H) | |
367 | // mozilla-config.h defines HAVE_STDINT_H, and then it's defined *again* in | |
368 | @@ -639,11 +641,13 @@ | |
369 | // this oddness. | |
370 | mozilla::SetICUMemoryFunctions(); | |
371 | ||
372 | +#ifndef MOZ_OGG_NO_MEM_REPORTING | |
373 | // Do the same for libogg. | |
374 | ogg_set_mem_functions(OggReporter::CountingMalloc, | |
375 | OggReporter::CountingCalloc, | |
376 | OggReporter::CountingRealloc, | |
377 | OggReporter::CountingFree); | |
378 | +#endif | |
379 | ||
380 | #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING) | |
381 | // And for VPX. |