File: fdkaac.patch

package info (click to toggle)
gnome-remote-desktop 49.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,240 kB
  • sloc: ansic: 46,124; xml: 234; python: 168; sh: 99; makefile: 22
file content (274 lines) | stat: -rw-r--r-- 8,434 bytes parent folder | download | duplicates (2)
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
From: =?utf-8?q?Jeremy_B=C3=ADcha?= <jeremy.bicha@canonical.com>
Date: Wed, 13 Mar 2024 16:06:41 -0400
Subject: Revert "rdp-dsp: Stop making fdk-aac optional"

This reverts commit b70ae574d0b8e8b4804d460bae77232a24397841.

Forwarded: not-needed

Upstream knows that we still need this patch, perhaps hoping that
the additional pressure will help get fdk-aac into Debian
but that is up to the ftpmasters, not the gnome-remote-desktop packagers
---
 config.h.meson                   |  3 +++
 meson.build                      | 14 +++++++++++++-
 meson_options.txt                |  5 +++++
 src/grd-rdp-dsp.c                | 25 ++++++++++++++++++++++++-
 src/grd-rdp-dvc-audio-playback.c |  4 ++++
 src/meson.build                  |  7 ++++++-
 6 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/config.h.meson b/config.h.meson
index cafba4e..8e86a0d 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -9,6 +9,9 @@
 /* Defined if LIBSYSTEMD is supported */
 #mesondefine HAVE_LIBSYSTEMD
 
+/* Defined if FDK AAC is available */
+#mesondefine HAVE_FDK_AAC
+
 /* Defined if RDP backend enabled */
 #mesondefine HAVE_RDP
 
diff --git a/meson.build b/meson.build
index ce7fb73..7bfa094 100644
--- a/meson.build
+++ b/meson.build
@@ -37,6 +37,7 @@ tss2_rc_dep = dependency('tss2-rc')
 tss2_tctildr_dep = dependency('tss2-tctildr')
 xkbcommon_dep = dependency('xkbcommon', version: xkbcommon_req)
 
+have_fdk_aac = get_option('fdk_aac')
 have_rdp = get_option('rdp')
 have_vnc = get_option('vnc')
 
@@ -44,13 +45,16 @@ if not have_rdp and not have_vnc
   error('Must enable at least one backend')
 endif
 
+if have_fdk_aac and not have_rdp
+  error('Support for audio output redirection using FDK AAC requires the RDP backend')
+endif
+
 if have_rdp
   add_global_arguments('-D_GNU_SOURCE', language : 'c')
 
   dl_dep = cc.find_library('dl', required: true)
 
   cuda_dep = dependency('ffnvcodec', version: cuda_req)
-  fdk_aac_dep = dependency('fdk-aac')
   freerdp_dep = dependency('freerdp3', version: freerdp_req)
   freerdp_client_dep = dependency('freerdp-client3', version: freerdp_req)
   freerdp_server_dep = dependency('freerdp-server3', version: freerdp_req)
@@ -62,6 +66,9 @@ if have_rdp
   polkit_dep = dependency('polkit-gobject-1', version: polkit_req)
   vulkan_dep = dependency('vulkan', version: vulkan_req)
   winpr_dep = dependency('winpr3', version: freerdp_req)
+  if have_fdk_aac
+    fdk_aac_dep = dependency('fdk-aac')
+  endif
 
   glslc = find_program('glslc', required: true)
   spirv_opt = find_program('spirv-opt', required: true)
@@ -106,6 +113,7 @@ cdata.set_quoted('VERSION', meson.project_version())
 cdata.set('HAVE_LIBSYSTEMD', libsystemd_dep.found())
 cdata.set('HAVE_RDP', have_rdp)
 cdata.set('HAVE_VNC', have_vnc)
+cdata.set('HAVE_FDK_AAC', have_fdk_aac)
 
 cdata.set_quoted('GRD_DATA_DIR', grd_datadir)
 cdata.set_quoted('GRD_LIBEXEC_DIR', libexecdir)
@@ -201,6 +209,10 @@ output = [
   '        RDP...................... ' + have_rdp.to_string(),
   '        VNC...................... ' + have_vnc.to_string(),
   '',
+  '    Options for the RDP backend:',
+  '',
+  '        Support for audio output redirection using FDK AAC........' + have_fdk_aac.to_string(),
+  '',
   '  Now type \'ninja -C ' + meson.project_build_root() + '\' to build ' + meson.project_name(),
   '',
   '',
diff --git a/meson_options.txt b/meson_options.txt
index c003176..b0b279d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -8,6 +8,11 @@ option('tests',
        value: true,
        description: 'Build the test suite')
 
+option('fdk_aac',
+       type: 'boolean',
+       value: true,
+       description: 'Audio output redirection for the RDP backend')
+
 option('rdp',
        type: 'boolean',
        value: true,
diff --git a/src/grd-rdp-dsp.c b/src/grd-rdp-dsp.c
index f83d5c5..987316e 100644
--- a/src/grd-rdp-dsp.c
+++ b/src/grd-rdp-dsp.c
@@ -21,10 +21,13 @@
 
 #include "grd-rdp-dsp.h"
 
-#include <fdk-aac/aacenc_lib.h>
 #include <gio/gio.h>
 #include <opus/opus.h>
 
+#ifdef HAVE_FDK_AAC
+#include <fdk-aac/aacenc_lib.h>
+#endif /* HAVE_FDK_AAC */
+
 #define G711_QUANT_MASK 0xF
 #define G711_SEG_MASK 0x70
 #define G711_SEG_SHIFT 4
@@ -36,8 +39,10 @@ struct _GrdRdpDsp
   GrdRdpDspCreateFlag create_flags;
   uint32_t n_channels;
 
+#ifdef HAVE_FDK_AAC
   HANDLE_AACENCODER aac_encoder;
   uint32_t aac_frame_length;
+#endif /* HAVE_FDK_AAC */
 
   OpusEncoder *opus_encoder;
   uint32_t opus_frame_length;
@@ -74,7 +79,11 @@ grd_rdp_dsp_get_frames_per_packet (GrdRdpDsp      *rdp_dsp,
     case GRD_RDP_DSP_CODEC_NONE:
       g_assert_not_reached ();
     case GRD_RDP_DSP_CODEC_AAC:
+#ifdef HAVE_FDK_AAC
       return rdp_dsp->aac_frame_length;
+#else
+      g_assert_not_reached ();
+#endif /* HAVE_FDK_AAC */
     case GRD_RDP_DSP_CODEC_ALAW:
       g_assert_not_reached ();
     case GRD_RDP_DSP_CODEC_OPUS:
@@ -84,6 +93,7 @@ grd_rdp_dsp_get_frames_per_packet (GrdRdpDsp      *rdp_dsp,
   g_assert_not_reached ();
 }
 
+#ifdef HAVE_FDK_AAC
 static gboolean
 encode_aac (GrdRdpDsp  *rdp_dsp,
             int16_t    *input_data,
@@ -139,6 +149,7 @@ encode_aac (GrdRdpDsp  *rdp_dsp,
 
   return TRUE;
 }
+#endif /* HAVE_FDK_AAC */
 
 static gboolean
 encode_opus (GrdRdpDsp  *rdp_dsp,
@@ -189,8 +200,13 @@ grd_rdp_dsp_encode (GrdRdpDsp       *rdp_dsp,
       g_assert_not_reached ();
       return FALSE;
     case GRD_RDP_DSP_CODEC_AAC:
+#ifdef HAVE_FDK_AAC
       return encode_aac (rdp_dsp, input_data, input_size, input_elem_size,
                          output_data, output_size);
+#else
+      g_assert_not_reached ();
+      return FALSE;
+#endif /* HAVE_FDK_AAC */
     case GRD_RDP_DSP_CODEC_ALAW:
       g_assert_not_reached ();
       return FALSE;
@@ -278,6 +294,7 @@ grd_rdp_dsp_decode (GrdRdpDsp       *rdp_dsp,
   return FALSE;
 }
 
+#ifdef HAVE_FDK_AAC
 static gboolean
 create_aac_encoder (GrdRdpDsp  *rdp_dsp,
                     uint32_t    n_samples_per_sec,
@@ -397,6 +414,7 @@ create_aac_encoder (GrdRdpDsp  *rdp_dsp,
 
   return TRUE;
 }
+#endif /* HAVE_FDK_AAC */
 
 static gboolean
 create_opus_encoder (GrdRdpDsp  *rdp_dsp,
@@ -441,12 +459,15 @@ create_encoders (GrdRdpDsp                  *rdp_dsp,
 {
   rdp_dsp->n_channels = dsp_descriptor->n_channels;
 
+#ifdef HAVE_FDK_AAC
   if (!create_aac_encoder (rdp_dsp,
                            dsp_descriptor->n_samples_per_sec_aac,
                            dsp_descriptor->n_channels,
                            dsp_descriptor->bitrate_aac,
                            error))
     return FALSE;
+#endif /* HAVE_FDK_AAC */
+
   if (!create_opus_encoder (rdp_dsp,
                             dsp_descriptor->n_samples_per_sec_opus,
                             dsp_descriptor->n_channels,
@@ -480,7 +501,9 @@ grd_rdp_dsp_dispose (GObject *object)
 
   g_clear_pointer (&rdp_dsp->opus_encoder, opus_encoder_destroy);
 
+#ifdef HAVE_FDK_AAC
   aacEncClose (&rdp_dsp->aac_encoder);
+#endif /* HAVE_FDK_AAC */
 
   G_OBJECT_CLASS (grd_rdp_dsp_parent_class)->dispose (object);
 }
diff --git a/src/grd-rdp-dvc-audio-playback.c b/src/grd-rdp-dvc-audio-playback.c
index 369d5c0..2e096f0 100644
--- a/src/grd-rdp-dvc-audio-playback.c
+++ b/src/grd-rdp-dvc-audio-playback.c
@@ -530,7 +530,9 @@ static const AUDIO_FORMAT audio_format_pcm =
 
 static AUDIO_FORMAT server_formats[] =
 {
+#ifdef HAVE_FDK_AAC
   audio_format_aac,
+#endif /* HAVE_FDK_AAC */
   audio_format_opus,
   audio_format_pcm,
 };
@@ -628,9 +630,11 @@ rdpsnd_activated (RdpsndServerContext *rdpsnd_context)
     {
       AUDIO_FORMAT *audio_format = &rdpsnd_context->client_formats[i];
 
+#ifdef HAVE_FDK_AAC
       if (audio_playback->aac_client_format_idx < 0 &&
           are_audio_formats_equal (audio_format, &audio_format_aac))
         audio_playback->aac_client_format_idx = i;
+#endif /* HAVE_FDK_AAC */
       if (audio_playback->opus_client_format_idx < 0 &&
           are_audio_formats_equal (audio_format, &audio_format_opus))
         audio_playback->opus_client_format_idx = i;
diff --git a/src/meson.build b/src/meson.build
index 1b2cb93..53cedb9 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -248,7 +248,6 @@ if have_rdp
   deps += [
     cuda_dep,
     dl_dep,
-    fdk_aac_dep,
     freerdp_dep,
     freerdp_server_dep,
     fuse_dep,
@@ -259,6 +258,12 @@ if have_rdp
     vulkan_dep,
     winpr_dep,
   ]
+
+  if (have_fdk_aac)
+    deps += [
+      fdk_aac_dep,
+    ]
+  endif
 endif
 
 if have_vnc