Skip to content

Commit f157dfc

Browse files
committed
arrange optional features
use the config script to choose which source files to add instead of having #ifs on the whole source file
1 parent 6300b64 commit f157dfc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+326
-508
lines changed

Diff for: config

+71-42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
ngx_addon_name=ngx_http_vod_module
22
ngx_module_incs=
33
ngx_module_libs=
4+
VOD_SRCS=
5+
VOD_DEPS=
46

57
# version
68
#
@@ -36,6 +38,34 @@ fi
3638

3739
# openssl evp
3840
#
41+
VOD_FEATURE_SRCS=" \
42+
$ngx_addon_dir/vod/dash/edash_packager.c \
43+
$ngx_addon_dir/vod/hls/aes_cbc_encrypt.c \
44+
$ngx_addon_dir/vod/hls/eac3_encrypt_filter.c \
45+
$ngx_addon_dir/vod/hls/frame_encrypt_filter.c \
46+
$ngx_addon_dir/vod/hls/sample_aes_avc_filter.c \
47+
$ngx_addon_dir/vod/mp4/mp4_aes_ctr.c \
48+
$ngx_addon_dir/vod/mp4/mp4_cbcs_encrypt.c \
49+
$ngx_addon_dir/vod/mp4/mp4_cenc_decrypt.c \
50+
$ngx_addon_dir/vod/mp4/mp4_cenc_encrypt.c \
51+
$ngx_addon_dir/vod/mp4/mp4_cenc_passthrough.c \
52+
$ngx_addon_dir/vod/mss/mss_playready.c \
53+
"
54+
55+
VOD_FEATURE_DEPS=" \
56+
$ngx_addon_dir/vod/dash/edash_packager.h \
57+
$ngx_addon_dir/vod/hls/aes_cbc_encrypt.h \
58+
$ngx_addon_dir/vod/hls/eac3_encrypt_filter.h \
59+
$ngx_addon_dir/vod/hls/frame_encrypt_filter.h \
60+
$ngx_addon_dir/vod/hls/sample_aes_avc_filter.h \
61+
$ngx_addon_dir/vod/mp4/mp4_aes_ctr.h \
62+
$ngx_addon_dir/vod/mp4/mp4_cbcs_encrypt.h \
63+
$ngx_addon_dir/vod/mp4/mp4_cenc_decrypt.h \
64+
$ngx_addon_dir/vod/mp4/mp4_cenc_encrypt.h \
65+
$ngx_addon_dir/vod/mp4/mp4_cenc_passthrough.h \
66+
$ngx_addon_dir/vod/mss/mss_playready.h \
67+
"
68+
3969
if [ $OPENSSL = NONE ]; then
4070
LIB_CRYPTO=${LIB_CRYPTO:--lcrypto}
4171
LIB_PTHREAD=${LIB_PTHREAD:--lpthread}
@@ -51,8 +81,12 @@ if [ $OPENSSL = NONE ]; then
5181

5282
if [ $ngx_found = yes ]; then
5383
ngx_module_libs="$ngx_module_libs $ngx_feature_libs"
84+
VOD_SRCS="$VOD_SRCS $VOD_FEATURE_SRCS"
85+
VOD_DEPS="$VOD_DEPS $VOD_FEATURE_DEPS"
5486
fi
5587
else
88+
VOD_SRCS="$VOD_SRCS $VOD_FEATURE_SRCS"
89+
VOD_DEPS="$VOD_DEPS $VOD_FEATURE_DEPS"
5690
cat << END >> $NGX_AUTO_CONFIG_H
5791

5892
#ifndef NGX_HAVE_OPENSSL_EVP
@@ -111,6 +145,30 @@ ngx_feature_test="avcodec_send_packet(NULL, NULL)"
111145

112146
if [ $ngx_found = yes ]; then
113147
ngx_module_libs="$ngx_module_libs $LIB_AV_CODEC $LIB_AV_UTIL -lm"
148+
VOD_FEATURE_SRCS=" \
149+
$ngx_addon_dir/ngx_http_vod_thumb.c \
150+
$ngx_addon_dir/ngx_http_vod_volume_map.c \
151+
$ngx_addon_dir/vod/filters/audio_decoder.c \
152+
$ngx_addon_dir/vod/filters/audio_encoder.c \
153+
$ngx_addon_dir/vod/filters/volume_map.c \
154+
$ngx_addon_dir/vod/thumb/thumb_grabber.c \
155+
"
156+
157+
VOD_FEATURE_DEPS=" \
158+
$ngx_addon_dir/ngx_http_vod_thumb.h \
159+
$ngx_addon_dir/ngx_http_vod_thumb_commands.h \
160+
$ngx_addon_dir/ngx_http_vod_thumb_conf.h \
161+
$ngx_addon_dir/ngx_http_vod_volume_map.h \
162+
$ngx_addon_dir/ngx_http_vod_volume_map_commands.h \
163+
$ngx_addon_dir/ngx_http_vod_volume_map_conf.h \
164+
$ngx_addon_dir/vod/filters/audio_decoder.h \
165+
$ngx_addon_dir/vod/filters/audio_encoder.h \
166+
$ngx_addon_dir/vod/filters/volume_map.h \
167+
$ngx_addon_dir/vod/thumb/thumb_grabber.h \
168+
"
169+
170+
VOD_SRCS="$VOD_SRCS $VOD_FEATURE_SRCS"
171+
VOD_DEPS="$VOD_DEPS $VOD_FEATURE_DEPS"
114172
fi
115173

116174
# libswscale
@@ -125,7 +183,7 @@ ngx_feature_test="sws_scale(NULL, NULL, NULL, 0, 0, NULL, NULL)"
125183
. auto/feature
126184

127185
if [ $ngx_found = yes ]; then
128-
ngx_module_libs="$ngx_module_libs -lswscale"
186+
ngx_module_libs="$ngx_module_libs -lswscale"
129187
fi
130188

131189
# libavfilter
@@ -162,9 +220,18 @@ ngx_feature_test="xmlReadMemory(NULL, 0, NULL, NULL, 0);"
162220
if [ $ngx_found = yes ]; then
163221
ngx_module_incs="$ngx_module_incs $ngx_feature_path"
164222
ngx_module_libs="$ngx_module_libs $ngx_feature_libs"
223+
VOD_FEATURE_SRCS=" \
224+
$ngx_addon_dir/vod/subtitle/dfxp_format.c \
225+
"
226+
VOD_FEATURE_DEPS=" \
227+
$ngx_addon_dir/vod/subtitle/dfxp_format.h \
228+
"
229+
VOD_SRCS="$VOD_SRCS $VOD_FEATURE_SRCS"
230+
VOD_DEPS="$VOD_DEPS $VOD_FEATURE_DEPS"
165231
fi
166232

167-
VOD_DEPS="$ngx_addon_dir/ngx_async_open_file_cache.h \
233+
VOD_DEPS="$VOD_DEPS \
234+
$ngx_addon_dir/ngx_async_open_file_cache.h \
168235
$ngx_addon_dir/ngx_buffer_cache.h \
169236
$ngx_addon_dir/ngx_buffer_cache_internal.h \
170237
$ngx_addon_dir/ngx_child_http_request.h \
@@ -186,13 +253,7 @@ VOD_DEPS="$ngx_addon_dir/ngx_async_open_file_cache.h \
186253
$ngx_addon_dir/ngx_http_vod_request_parse.h \
187254
$ngx_addon_dir/ngx_http_vod_status.h \
188255
$ngx_addon_dir/ngx_http_vod_submodule.h \
189-
$ngx_addon_dir/ngx_http_vod_thumb.h \
190-
$ngx_addon_dir/ngx_http_vod_thumb_commands.h \
191-
$ngx_addon_dir/ngx_http_vod_thumb_conf.h \
192256
$ngx_addon_dir/ngx_http_vod_utils.h \
193-
$ngx_addon_dir/ngx_http_vod_volume_map.h \
194-
$ngx_addon_dir/ngx_http_vod_volume_map_commands.h \
195-
$ngx_addon_dir/ngx_http_vod_volume_map_conf.h \
196257
$ngx_addon_dir/ngx_perf_counters.h \
197258
$ngx_addon_dir/ngx_perf_counters_x.h \
198259
$ngx_addon_dir/vod/aes_defs.h \
@@ -204,30 +265,23 @@ VOD_DEPS="$ngx_addon_dir/ngx_async_open_file_cache.h \
204265
$ngx_addon_dir/vod/codec_config.h \
205266
$ngx_addon_dir/vod/common.h \
206267
$ngx_addon_dir/vod/dash/dash_packager.h \
207-
$ngx_addon_dir/vod/dash/edash_packager.h \
208268
$ngx_addon_dir/vod/dynamic_buffer.h \
209-
$ngx_addon_dir/vod/filters/audio_decoder.h \
210-
$ngx_addon_dir/vod/filters/audio_encoder.h \
211269
$ngx_addon_dir/vod/filters/audio_filter.h \
212270
$ngx_addon_dir/vod/filters/concat_clip.h \
213271
$ngx_addon_dir/vod/filters/dynamic_clip.h \
214272
$ngx_addon_dir/vod/filters/filter.h \
215273
$ngx_addon_dir/vod/filters/gain_filter.h \
216274
$ngx_addon_dir/vod/filters/mix_filter.h \
217275
$ngx_addon_dir/vod/filters/rate_filter.h \
218-
$ngx_addon_dir/vod/filters/volume_map.h \
219276
$ngx_addon_dir/vod/hds/hds_amf0_encoder.h \
220277
$ngx_addon_dir/vod/hds/hds_amf0_fields_x.h \
221278
$ngx_addon_dir/vod/hds/hds_encryption.h \
222279
$ngx_addon_dir/vod/hds/hds_fragment.h \
223280
$ngx_addon_dir/vod/hds/hds_manifest.h \
224281
$ngx_addon_dir/vod/hevc_parser.h \
225282
$ngx_addon_dir/vod/hls/adts_encoder_filter.h \
226-
$ngx_addon_dir/vod/hls/aes_cbc_encrypt.h \
227283
$ngx_addon_dir/vod/hls/bit_fields.h \
228284
$ngx_addon_dir/vod/hls/buffer_filter.h \
229-
$ngx_addon_dir/vod/hls/eac3_encrypt_filter.h \
230-
$ngx_addon_dir/vod/hls/frame_encrypt_filter.h \
231285
$ngx_addon_dir/vod/hls/frame_joiner_filter.h \
232286
$ngx_addon_dir/vod/hls/hls_encryption.h \
233287
$ngx_addon_dir/vod/hls/hls_muxer.h \
@@ -236,7 +290,6 @@ VOD_DEPS="$ngx_addon_dir/ngx_async_open_file_cache.h \
236290
$ngx_addon_dir/vod/hls/media_filter.h \
237291
$ngx_addon_dir/vod/hls/mp4_to_annexb_filter.h \
238292
$ngx_addon_dir/vod/hls/mpegts_encoder_filter.h \
239-
$ngx_addon_dir/vod/hls/sample_aes_avc_filter.h \
240293
$ngx_addon_dir/vod/input/silence_generator.h \
241294
$ngx_addon_dir/vod/input/frames_source.h \
242295
$ngx_addon_dir/vod/input/frames_source_cache.h \
@@ -255,11 +308,6 @@ VOD_DEPS="$ngx_addon_dir/ngx_async_open_file_cache.h \
255308
$ngx_addon_dir/vod/mkv/mkv_builder.h \
256309
$ngx_addon_dir/vod/mkv/mkv_defs.h \
257310
$ngx_addon_dir/vod/mkv/mkv_format.h \
258-
$ngx_addon_dir/vod/mp4/mp4_aes_ctr.h \
259-
$ngx_addon_dir/vod/mp4/mp4_cbcs_encrypt.h \
260-
$ngx_addon_dir/vod/mp4/mp4_cenc_decrypt.h \
261-
$ngx_addon_dir/vod/mp4/mp4_cenc_encrypt.h \
262-
$ngx_addon_dir/vod/mp4/mp4_cenc_passthrough.h \
263311
$ngx_addon_dir/vod/mp4/mp4_clipper.h \
264312
$ngx_addon_dir/vod/mp4/mp4_defs.h \
265313
$ngx_addon_dir/vod/mp4/mp4_format.h \
@@ -270,8 +318,6 @@ VOD_DEPS="$ngx_addon_dir/ngx_async_open_file_cache.h \
270318
$ngx_addon_dir/vod/mp4/mp4_parser_base.h \
271319
$ngx_addon_dir/vod/mp4/mp4_write_stream.h \
272320
$ngx_addon_dir/vod/mss/mss_packager.h \
273-
$ngx_addon_dir/vod/mss/mss_playready.h \
274-
$ngx_addon_dir/vod/thumb/thumb_grabber.h \
275321
$ngx_addon_dir/vod/subtitle/cap_format.h \
276322
$ngx_addon_dir/vod/subtitle/dfxp_format.h \
277323
$ngx_addon_dir/vod/subtitle/subtitle_format.h \
@@ -288,7 +334,8 @@ VOD_DEPS="$ngx_addon_dir/ngx_async_open_file_cache.h \
288334
$ngx_addon_dir/vod/write_stream.h \
289335
"
290336

291-
VOD_SRCS="$ngx_addon_dir/ngx_async_open_file_cache.c \
337+
VOD_SRCS="$VOD_SRCS \
338+
$ngx_addon_dir/ngx_async_open_file_cache.c \
292339
$ngx_addon_dir/ngx_buffer_cache.c \
293340
$ngx_addon_dir/ngx_child_http_request.c \
294341
$ngx_addon_dir/ngx_file_reader.c \
@@ -301,44 +348,34 @@ VOD_SRCS="$ngx_addon_dir/ngx_async_open_file_cache.c \
301348
$ngx_addon_dir/ngx_http_vod_request_parse.c \
302349
$ngx_addon_dir/ngx_http_vod_status.c \
303350
$ngx_addon_dir/ngx_http_vod_submodule.c \
304-
$ngx_addon_dir/ngx_http_vod_thumb.c \
305351
$ngx_addon_dir/ngx_http_vod_utils.c \
306-
$ngx_addon_dir/ngx_http_vod_volume_map.c \
307352
$ngx_addon_dir/ngx_perf_counters.c \
308353
$ngx_addon_dir/vod/avc_parser.c \
309354
$ngx_addon_dir/vod/avc_hevc_parser.c \
310355
$ngx_addon_dir/vod/buffer_pool.c \
311356
$ngx_addon_dir/vod/codec_config.c \
312357
$ngx_addon_dir/vod/common.c \
313358
$ngx_addon_dir/vod/dash/dash_packager.c \
314-
$ngx_addon_dir/vod/dash/edash_packager.c \
315359
$ngx_addon_dir/vod/dynamic_buffer.c \
316-
$ngx_addon_dir/vod/filters/audio_decoder.c \
317-
$ngx_addon_dir/vod/filters/audio_encoder.c \
318360
$ngx_addon_dir/vod/filters/audio_filter.c \
319361
$ngx_addon_dir/vod/filters/concat_clip.c \
320362
$ngx_addon_dir/vod/filters/dynamic_clip.c \
321363
$ngx_addon_dir/vod/filters/filter.c \
322364
$ngx_addon_dir/vod/filters/gain_filter.c \
323365
$ngx_addon_dir/vod/filters/mix_filter.c \
324366
$ngx_addon_dir/vod/filters/rate_filter.c \
325-
$ngx_addon_dir/vod/filters/volume_map.c \
326367
$ngx_addon_dir/vod/hds/hds_amf0_encoder.c \
327368
$ngx_addon_dir/vod/hds/hds_fragment.c \
328369
$ngx_addon_dir/vod/hds/hds_manifest.c \
329370
$ngx_addon_dir/vod/hevc_parser.c \
330371
$ngx_addon_dir/vod/hls/adts_encoder_filter.c \
331-
$ngx_addon_dir/vod/hls/aes_cbc_encrypt.c \
332372
$ngx_addon_dir/vod/hls/buffer_filter.c \
333-
$ngx_addon_dir/vod/hls/eac3_encrypt_filter.c \
334-
$ngx_addon_dir/vod/hls/frame_encrypt_filter.c \
335373
$ngx_addon_dir/vod/hls/frame_joiner_filter.c \
336374
$ngx_addon_dir/vod/hls/hls_muxer.c \
337375
$ngx_addon_dir/vod/hls/id3_encoder_filter.c \
338376
$ngx_addon_dir/vod/hls/m3u8_builder.c \
339377
$ngx_addon_dir/vod/hls/mp4_to_annexb_filter.c \
340378
$ngx_addon_dir/vod/hls/mpegts_encoder_filter.c \
341-
$ngx_addon_dir/vod/hls/sample_aes_avc_filter.c \
342379
$ngx_addon_dir/vod/input/silence_generator.c \
343380
$ngx_addon_dir/vod/input/frames_source_cache.c \
344381
$ngx_addon_dir/vod/input/frames_source_memory.c \
@@ -352,11 +389,6 @@ VOD_SRCS="$ngx_addon_dir/ngx_async_open_file_cache.c \
352389
$ngx_addon_dir/vod/mkv/mkv_builder.c \
353390
$ngx_addon_dir/vod/mkv/mkv_defs.c \
354391
$ngx_addon_dir/vod/mkv/mkv_format.c \
355-
$ngx_addon_dir/vod/mp4/mp4_aes_ctr.c \
356-
$ngx_addon_dir/vod/mp4/mp4_cbcs_encrypt.c \
357-
$ngx_addon_dir/vod/mp4/mp4_cenc_decrypt.c \
358-
$ngx_addon_dir/vod/mp4/mp4_cenc_encrypt.c \
359-
$ngx_addon_dir/vod/mp4/mp4_cenc_passthrough.c \
360392
$ngx_addon_dir/vod/mp4/mp4_clipper.c \
361393
$ngx_addon_dir/vod/mp4/mp4_format.c \
362394
$ngx_addon_dir/vod/mp4/mp4_fragment.c \
@@ -365,10 +397,7 @@ VOD_SRCS="$ngx_addon_dir/ngx_async_open_file_cache.c \
365397
$ngx_addon_dir/vod/mp4/mp4_parser.c \
366398
$ngx_addon_dir/vod/mp4/mp4_parser_base.c \
367399
$ngx_addon_dir/vod/mss/mss_packager.c \
368-
$ngx_addon_dir/vod/mss/mss_playready.c \
369-
$ngx_addon_dir/vod/thumb/thumb_grabber.c \
370400
$ngx_addon_dir/vod/subtitle/cap_format.c \
371-
$ngx_addon_dir/vod/subtitle/dfxp_format.c \
372401
$ngx_addon_dir/vod/subtitle/subtitle_format.c \
373402
$ngx_addon_dir/vod/subtitle/ttml_builder.c \
374403
$ngx_addon_dir/vod/subtitle/webvtt_builder.c \

Diff for: ngx_file_reader.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ngx_file_reader_update_state_file_info(ngx_file_reader_state_t* state, ngx_open_
5454
#if (NGX_HAVE_OPENAT)
5555
case NGX_EMLINK:
5656
case NGX_ELOOP:
57-
#endif
57+
#endif // NGX_HAVE_OPENAT
5858

5959
level = NGX_LOG_ERR;
6060
rc = NGX_HTTP_FORBIDDEN;
@@ -118,7 +118,7 @@ ngx_file_reader_init(
118118
state->use_aio = clcf->aio;
119119
state->read_callback = read_callback;
120120
state->callback_context = callback_context;
121-
#endif
121+
#endif // NGX_HAVE_FILE_AIO
122122

123123
rc = ngx_file_reader_init_open_file_info(&of, r, clcf, path);
124124
if (rc != NGX_OK)
@@ -189,7 +189,7 @@ ngx_file_reader_init_async(
189189
state->use_aio = clcf->aio;
190190
state->read_callback = read_callback;
191191
state->callback_context = callback_context;
192-
#endif
192+
#endif // NGX_HAVE_FILE_AIO
193193

194194
open_context = *context;
195195

@@ -442,4 +442,4 @@ ngx_async_file_read(ngx_file_reader_state_t* state, ngx_buf_t *buf, size_t size,
442442
return NGX_OK;
443443
}
444444

445-
#endif
445+
#endif // NGX_HAVE_FILE_AIO

Diff for: ngx_file_reader.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#if (NGX_THREADS)
1111
#include "ngx_async_open_file_cache.h"
12-
#endif
12+
#endif // NGX_THREADS
1313

1414
// constants
1515
#define OPEN_FILE_NO_CACHE (0x1)
@@ -29,7 +29,7 @@ typedef struct {
2929
ngx_async_read_callback_t read_callback;
3030
void* callback_context;
3131
ngx_buf_t* buf;
32-
#endif
32+
#endif // NGX_HAVE_FILE_AIO
3333
} ngx_file_reader_state_t;
3434

3535
// functions
@@ -54,7 +54,7 @@ ngx_int_t ngx_file_reader_init_async(
5454
ngx_http_core_loc_conf_t *clcf,
5555
ngx_str_t* path,
5656
uint32_t flags);
57-
#endif
57+
#endif // NGX_THREADS
5858

5959
ngx_int_t ngx_file_reader_dump_file_part(void* context, off_t start, off_t end);
6060

0 commit comments

Comments
 (0)