aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/icecat-use-system-media-libs.patch
blob: 648585a6f0059fa04ecd29156b6c6f4aa98894af (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
Support building with system media libraries.
See <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>

Based on:
  https://svnweb.freebsd.org/ports/head/www/firefox-esr/files/patch-z-bug517422?revision=472833&view=markup

Changes to files within the bundled libraries are omitted, since those files
are removed from Guix sources.  Modified for use with patch -p1, and to apply
cleanly to GNU IceCat.

--- icecat-60.2.0/build/moz.configure/old.configure
+++ icecat-60.2.0/build/moz.configure/old.configure
@@ -273,7 +273,12 @@
     '--with-system-libvpx',
     '--with-system-nspr',
     '--with-system-nss',
+    '--with-system-ogg',
     '--with-system-png',
+    '--with-system-soundtouch',
+    '--with-system-theora',
+    '--with-system-tremor',
+    '--with-system-vorbis',
     '--with-system-zlib',
     '--with-thumb',
     '--with-thumb-interwork',
--- icecat-60.2.0/config/external/moz.build
+++ icecat-60.2.0/config/external/moz.build
@@ -23,12 +23,21 @@
 
 external_dirs += ['modules/xz-embedded']
 
-if CONFIG['MOZ_VORBIS']:
+if not CONFIG['MOZ_SYSTEM_OGG']:
+    external_dirs += ['media/libogg']
+
+if CONFIG['MOZ_VORBIS'] and not CONFIG['MOZ_SYSTEM_VORBIS']:
     external_dirs += ['media/libvorbis']
 
-if CONFIG['MOZ_TREMOR']:
+if CONFIG['MOZ_TREMOR'] and not CONFIG['MOZ_SYSTEM_TREMOR']:
     external_dirs += ['media/libtremor']
 
+if not CONFIG['MOZ_SYSTEM_THEORA']:
+    external_dirs += ['media/libtheora']
+
+if not CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
+    external_dirs += ['media/libsoundtouch']
+
 if CONFIG['MOZ_WEBM_ENCODER']:
     external_dirs += ['media/libmkv']
 
@@ -51,11 +60,8 @@
     'media/kiss_fft',
     'media/libcubeb',
     'media/libnestegg',
-    'media/libogg',
     'media/libopus',
-    'media/libtheora',
     'media/libspeex_resampler',
-    'media/libsoundtouch',
     'media/mp4parse-rust',
     'media/psshparser'
 ]
--- icecat-60.2.0/config/system-headers.mozbuild
+++ icecat-60.2.0/config/system-headers.mozbuild
@@ -1324,6 +1324,28 @@
         'harfbuzz/hb.h',
     ]
 
+if CONFIG['MOZ_SYSTEM_OGG']:
+    system_headers += [
+        'ogg/ogg.h',
+        'ogg/os_types.h',
+    ]
+
+if CONFIG['MOZ_SYSTEM_THEORA']:
+    system_headers += [
+        'theora/theoradec.h',
+    ]
+
+if CONFIG['MOZ_SYSTEM_VORBIS']:
+    system_headers += [
+        'vorbis/codec.h',
+        'vorbis/vorbisenc.h',
+    ]
+
+if CONFIG['MOZ_SYSTEM_TREMOR']:
+    system_headers += [
+        'tremor/ivorbiscodec.h',
+    ]
+
 if CONFIG['MOZ_SYSTEM_LIBVPX']:
     system_headers += [
         'vpx_mem/vpx_mem.h',
--- icecat-60.2.0/dom/media/AudioStream.cpp
+++ icecat-60.2.0/dom/media/AudioStream.cpp
@@ -121,7 +121,9 @@
   : mMonitor("AudioStream")
   , mChannels(0)
   , mOutChannels(0)
+#ifndef MOZ_SYSTEM_SOUNDTOUCH
   , mTimeStretcher(nullptr)
+#endif
   , mDumpFile(nullptr)
   , mState(INITIALIZED)
   , mDataSource(aSource)
@@ -142,9 +144,11 @@
   if (mDumpFile) {
     fclose(mDumpFile);
   }
+#ifndef MOZ_SYSTEM_SOUNDTOUCH
   if (mTimeStretcher) {
     soundtouch::destroySoundTouchObj(mTimeStretcher);
   }
+#endif
 #if defined(XP_WIN)
   if (XRE_IsContentProcess()) {
     audio::AudioNotificationReceiver::Unregister(this);
@@ -168,7 +172,11 @@
 {
   mMonitor.AssertCurrentThreadOwns();
   if (!mTimeStretcher) {
+#ifdef MOZ_SYSTEM_SOUNDTOUCH
+    mTimeStretcher = new soundtouch::SoundTouch();
+#else
     mTimeStretcher = soundtouch::createSoundTouchObj();
+#endif
     mTimeStretcher->setSampleRate(mAudioClock.GetInputRate());
     mTimeStretcher->setChannels(mOutChannels);
     mTimeStretcher->setPitch(1.0);
--- icecat-60.2.0/dom/media/AudioStream.h
+++ icecat-60.2.0/dom/media/AudioStream.h
@@ -15,7 +15,11 @@
 #include "mozilla/TimeStamp.h"
 #include "mozilla/UniquePtr.h"
 #include "CubebUtils.h"
+#ifdef MOZ_SYSTEM_SOUNDTOUCH
+#include "soundtouch/SoundTouch.h"
+#else
 #include "soundtouch/SoundTouchFactory.h"
+#endif
 
 #if defined(XP_WIN)
 #include "mozilla/audio/AudioNotificationReceiver.h"
@@ -297,7 +301,11 @@
   uint32_t mChannels;
   uint32_t mOutChannels;
   AudioClock mAudioClock;
+#ifdef MOZ_SYSTEM_SOUNDTOUCH
+  nsAutoPtr<soundtouch::SoundTouch> mTimeStretcher;
+#else
   soundtouch::SoundTouch* mTimeStretcher;
+#endif
 
   // Output file for dumping audio
   FILE* mDumpFile;
--- icecat-60.2.0/dom/media/moz.build
+++ icecat-60.2.0/dom/media/moz.build
@@ -327,6 +327,21 @@
 
 DEFINES['MOZILLA_INTERNAL_API'] = True
 
+if CONFIG['MOZ_SYSTEM_OGG']:
+    CXXFLAGS += CONFIG['MOZ_OGG_CFLAGS']
+
+if CONFIG['MOZ_SYSTEM_THEORA']:
+    CXXFLAGS += CONFIG['MOZ_THEORA_CFLAGS']
+
+if CONFIG['MOZ_SYSTEM_VORBIS']:
+    CXXFLAGS += CONFIG['MOZ_VORBIS_CFLAGS']
+
+if CONFIG['MOZ_SYSTEM_TREMOR']:
+    CXXFLAGS += CONFIG['MOZ_TREMOR_CFLAGS']
+
+if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
+    CXXFLAGS += CONFIG['MOZ_SOUNDTOUCH_CFLAGS']
+
 if CONFIG['MOZ_ANDROID_HLS_SUPPORT']:
     DEFINES['MOZ_ANDROID_HLS_SUPPORT'] = True
 
--- icecat-60.2.0/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
+++ icecat-60.2.0/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
@@ -15,9 +15,13 @@
 #include <windows.h>
 #endif
 
+#ifdef MOZ_SYSTEM_SOUNDTOUCH
+#include "nsXPCOMPrivate.h" // for XUL_DLL
+#else
 // We use a known symbol located in lgpllibs to determine its location.
 // soundtouch happens to be always included in lgpllibs
 #include "soundtouch/SoundTouch.h"
+#endif
 
 namespace mozilla {
 
@@ -64,6 +68,12 @@
 
   sLinkStatus = LinkStatus_FAILED;
 
+#ifdef MOZ_SYSTEM_SOUNDTOUCH
+  // We retrieve the path of the XUL library as this is where mozavcodec and
+  // mozavutil libs are located.
+  char* path =
+    PR_GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Init);
+#else
   // We retrieve the path of the lgpllibs library as this is where mozavcodec
   // and mozavutil libs are located.
   PathString lgpllibsname = GetLibraryName(nullptr, "lgpllibs");
@@ -73,6 +83,7 @@
   PathString path =
     GetLibraryFilePathname(lgpllibsname.get(),
                            (PRFuncPtr)&soundtouch::SoundTouch::getVersionId);
+#endif
   if (path.IsEmpty()) {
     return false;
   }
--- icecat-60.2.0/old-configure.in
+++ icecat-60.2.0/old-configure.in
@@ -2451,6 +2451,111 @@
 fi
 fi # COMPILE_ENVIRONMENT
 
+dnl ========================================================
+dnl Check for libogg
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-ogg,
+[  --with-system-ogg       Use system libogg (located with pkgconfig)],
+MOZ_SYSTEM_OGG=1,
+MOZ_SYSTEM_OGG=)
+
+if test -n "$MOZ_SYSTEM_OGG"; then
+    PKG_CHECK_MODULES(MOZ_OGG, ogg >= 1.3.3)
+
+    _SAVE_LIBS=$LIBS
+    LIBS="$LIBS $MOZ_OGG_LIBS"
+    AC_CHECK_FUNC(ogg_set_mem_functions, [],
+      [AC_DEFINE(MOZ_OGG_NO_MEM_REPORTING)])
+    LIBS=$_SAVE_LIBS
+fi
+
+AC_SUBST(MOZ_SYSTEM_OGG)
+
+dnl ========================================================
+dnl Check for libvorbis
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-vorbis,
+[  --with-system-vorbis    Use system libvorbis (located with pkgconfig)],
+MOZ_SYSTEM_VORBIS=1,
+MOZ_SYSTEM_VORBIS=)
+
+if test -n "$MOZ_SYSTEM_VORBIS"; then
+    PKG_CHECK_MODULES(MOZ_VORBIS, vorbis vorbisenc >= 1.3.6)
+fi
+
+AC_SUBST(MOZ_SYSTEM_VORBIS)
+
+dnl ========================================================
+dnl Check for integer-only libvorbis aka tremor
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-tremor,
+[  --with-system-tremor    Use system libtremor (located with pkgconfig)],
+MOZ_SYSTEM_TREMOR=1,
+MOZ_SYSTEM_TREMOR=)
+
+if test -n "$MOZ_SYSTEM_TREMOR"; then
+    PKG_CHECK_MODULES(MOZ_TREMOR, vorbisidec >= 1.2.1)
+fi
+
+AC_SUBST(MOZ_SYSTEM_TREMOR)
+
+dnl ========================================================
+dnl Check for libtheora
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-theora,
+[  --with-system-theora    Use system libtheora (located with pkgconfig)],
+MOZ_SYSTEM_THEORA=1,
+MOZ_SYSTEM_THEORA=)
+
+if test -n "$MOZ_SYSTEM_THEORA"; then
+    PKG_CHECK_MODULES(MOZ_THEORA, theora >= 1.2)
+fi
+
+AC_SUBST(MOZ_SYSTEM_THEORA)
+
+dnl ========================================================
+dnl Check for libSoundTouch
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-soundtouch,
+[  --with-system-soundtouch Use system libSoundTouch (located with pkgconfig)],
+MOZ_SYSTEM_SOUNDTOUCH=1,
+MOZ_SYSTEM_SOUNDTOUCH=)
+
+if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then
+    PKG_CHECK_MODULES(MOZ_SOUNDTOUCH, soundtouch >= 1.9.0)
+
+    AC_LANG_SAVE
+    AC_LANG_CPLUSPLUS
+    _SAVE_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $MOZ_SOUNDTOUCH_CFLAGS"
+    AC_CACHE_CHECK(for soundtouch sample type,
+                   ac_cv_soundtouch_sample_type,
+                   [AC_TRY_COMPILE([#include <SoundTouch.h>
+                                    #ifndef SOUNDTOUCH_INTEGER_SAMPLES
+                                    #error soundtouch expects float samples
+                                    #endif],
+                                   [],
+                                   [ac_cv_soundtouch_sample_type=short],
+                                   [ac_cv_soundtouch_sample_type=float])])
+    CXXFLAGS=$_SAVE_CXXFLAGS
+    AC_LANG_RESTORE
+
+    if test \( -n "$MOZ_SAMPLE_TYPE_S16" -a "$ac_cv_soundtouch_sample_type" != short \) \
+         -o \( -n "$MOZ_SAMPLE_TYPE_FLOAT32" -a "$ac_cv_soundtouch_sample_type" != float \) ; then
+        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.])
+    fi
+fi
+
+if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then
+    AC_DEFINE(MOZ_SYSTEM_SOUNDTOUCH)
+fi
+AC_SUBST(MOZ_SYSTEM_SOUNDTOUCH)
+
 dnl system libvpx Support
 dnl ========================================================
 MOZ_ARG_WITH_BOOL(system-libvpx,
--- icecat-60.2.0/toolkit/library/moz.build
+++ icecat-60.2.0/toolkit/library/moz.build
@@ -244,6 +244,21 @@
 if CONFIG['MOZ_SYSTEM_HUNSPELL']:
     OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS']
 
+if CONFIG['MOZ_SYSTEM_OGG']:
+    OS_LIBS += CONFIG['MOZ_OGG_LIBS']
+
+if CONFIG['MOZ_SYSTEM_THEORA']:
+    OS_LIBS += CONFIG['MOZ_THEORA_LIBS']
+
+if CONFIG['MOZ_SYSTEM_VORBIS']:
+    OS_LIBS += CONFIG['MOZ_VORBIS_LIBS']
+
+if CONFIG['MOZ_SYSTEM_TREMOR']:
+    OS_LIBS += CONFIG['MOZ_TREMOR_LIBS']
+
+if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
+    OS_LIBS += CONFIG['MOZ_SOUNDTOUCH_LIBS']
+
 if CONFIG['MOZ_SYSTEM_LIBEVENT']:
     OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS']
 
--- icecat-60.2.0/xpcom/build/XPCOMInit.cpp
+++ icecat-60.2.0/xpcom/build/XPCOMInit.cpp
@@ -138,7 +138,9 @@
 
 #include "mozilla/ipc/GeckoChildProcessHost.h"
 
+#ifndef MOZ_OGG_NO_MEM_REPORTING
 #include "ogg/ogg.h"
+#endif
 #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
 #if defined(HAVE_STDINT_H)
 // mozilla-config.h defines HAVE_STDINT_H, and then it's defined *again* in
@@ -639,11 +641,13 @@
   // this oddness.
   mozilla::SetICUMemoryFunctions();
 
+#ifndef MOZ_OGG_NO_MEM_REPORTING
   // Do the same for libogg.
   ogg_set_mem_functions(OggReporter::CountingMalloc,
                         OggReporter::CountingCalloc,
                         OggReporter::CountingRealloc,
                         OggReporter::CountingFree);
+#endif
 
 #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
   // And for VPX.