├── static
├── alive.html
├── favicon.ico
├── robots.txt
├── crossdomain.xml
└── clientaccesspolicy.xml
├── test
├── .gitignore
├── validate_iframes_params.py.template
├── parse_http_time.py
├── g2o_params.py.template
├── stream_compare_params.py.template
├── main_params.py.template
├── setup_test_entries_params.py.template
├── bitset
│ └── build.sh
├── hls_compare_params.py.template
├── ts_utils.py
├── json_parser
│ └── build.sh
├── buffer_cache
│ ├── build.sh
│ └── ngx_cycle.h
├── get_perf_counters_as_csv.php
├── download_stream.py
├── speed_test.py
├── print_mp4_atoms.py
├── g2o_curl.py
├── decrypt_ts_segment.py
├── verify_test_entries.py
├── compare_utils.py
├── generate_many_tracks.py
├── test_open_file_cache.conf
├── mp4_utils.py
├── test_static.py
├── README.md
├── dash_clear_key.php
├── http_utils.py
├── stream_compare.py
└── uri_compare.py
├── vod
├── mkv
│ ├── mkv_format.h
│ ├── mkv_builder.h
│ ├── mkv_defs.c
│ ├── ebml.h
│ └── mkv_defs.h
├── subtitle
│ ├── cap_format.h
│ ├── dfxp_format.h
│ ├── webvtt_format.h
│ ├── webvtt_builder.h
│ ├── ttml_builder.h
│ ├── subtitle_format.h
│ └── webvtt_format_template.h
├── hls
│ ├── frame_joiner_filter.h
│ ├── eac3_encrypt_filter.h
│ ├── frame_encrypt_filter.h
│ ├── adts_encoder_filter.h
│ ├── hls_encryption.h
│ ├── mp4_to_annexb_filter.h
│ ├── sample_aes_avc_filter.h
│ ├── buffer_filter.h
│ ├── aes_cbc_encrypt.h
│ ├── bit_fields.def
│ ├── id3_encoder_filter.h
│ ├── media_filter.h
│ ├── m3u8_builder.h
│ ├── id3_encoder_filter.c
│ ├── mpegts_encoder_filter.h
│ └── hls_muxer.h
├── mp4
│ ├── mp4_format.h
│ ├── mp4_cbcs_encrypt.h
│ ├── mp4_write_stream.h
│ ├── mp4_cenc_decrypt.h
│ ├── mp4_muxer.h
│ ├── mp4_cenc_passthrough.h
│ ├── mp4_init_segment.h
│ ├── mp4_clipper.h
│ ├── mp4_aes_ctr.h
│ ├── mp4_parser.h
│ ├── mp4_fragment.h
│ └── mp4_cenc_encrypt.h
├── buffer_pool.h
├── filters
│ ├── mix_filter.h
│ ├── gain_filter.h
│ ├── concat_clip.h
│ ├── filter.h
│ ├── rate_filter.h
│ ├── volume_map.h
│ ├── audio_filter.h
│ ├── audio_encoder.h
│ ├── audio_decoder.h
│ ├── dynamic_clip.h
│ └── mix_filter.c
├── input
│ ├── frames_source_memory.h
│ ├── silence_generator.h
│ ├── frames_source.h
│ ├── frames_source_cache.h
│ ├── frames_source_memory.c
│ ├── read_cache.h
│ └── frames_source_cache.c
├── hds
│ ├── hds_encryption.h
│ ├── hds_amf0_fields_x.h
│ ├── hds_manifest.h
│ ├── hds_amf0_encoder.h
│ └── hds_fragment.h
├── cli
│ ├── vod_array.h
│ ├── vod_array.c
│ └── vod_cli_main.c
├── dynamic_buffer.h
├── aes_defs.h
├── thumb
│ └── thumb_grabber.h
├── avc_parser.h
├── hevc_parser.h
├── languages_hash_params.h
├── media_set.c
├── parse_utils.h
├── mss
│ ├── mss_playready.h
│ └── mss_packager.h
├── write_stream.h
├── udrm.h
├── write_buffer.h
├── language_code.h
├── dash
│ ├── edash_packager.h
│ └── dash_packager.h
├── write_buffer_queue.h
├── common.c
├── avc_defs.h
├── dynamic_buffer.c
├── media_set_parser.h
├── read_stream.h
├── avc_hevc_parser.h
├── manifest_utils.h
├── bit_read_stream.h
├── buffer_pool.c
├── codec_config.h
├── media_clip.h
└── json_parser.h
├── ngx_http_vod_hds.h
├── ngx_http_vod_hls.h
├── ngx_http_vod_mss.h
├── conf
├── main.conf.template
├── cors.conf
├── base.conf
├── ssl.conf.template
├── vod-remote-nginx.conf.template
├── vod-local-nginx.conf.template
├── kaltura-nginx.conf.template
├── http.conf.template
├── vod-local.conf.template
├── vod-remote.conf.template
└── kaltura.conf.template
├── ngx_http_vod_dash.h
├── ngx_http_vod_status.h
├── ngx_http_vod_volume_map.h
├── ngx_http_vod_thumb_conf.h
├── ngx_http_vod_volume_map_conf.h
├── ngx_http_vod_mss_conf.h
├── ngx_http_vod_thumb.h
├── ngx_http_vod_submodule.c
├── ngx_perf_counters_x.h
├── ngx_http_vod_hds_conf.h
├── ngx_http_vod_dash_conf.h
├── ngx_http_vod_thumb_commands.h
├── ngx_http_vod_volume_map_commands.h
├── ngx_http_vod_module.h
├── ngx_http_vod_mss_commands.h
├── scripts
├── encrypt_url.rb
└── languages_hash_size.py
├── ngx_async_open_file_cache.h
├── tools
├── prefetch_proxy
│ ├── README.md
│ └── prefetcher.lua
└── persist_proxy
│ ├── README.md
│ ├── status.lua
│ └── metrics.lua
├── ngx_http_vod_hls_conf.h
├── ngx_http_vod_utils.h
├── ngx_http_vod_hds_commands.h
├── ngx_child_http_request.h
├── ngx_buffer_cache_internal.h
├── ngx_buffer_cache.h
├── ngx_perf_counters.c
├── ngx_file_reader.h
├── .github
└── workflows
│ └── ci.yml
├── ci_build.sh
└── ngx_http_vod_request_parse.h
/static/alive.html:
--------------------------------------------------------------------------------
1 | Kaltura
--------------------------------------------------------------------------------
/test/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 |
--------------------------------------------------------------------------------
/test/validate_iframes_params.py.template:
--------------------------------------------------------------------------------
1 | STOP_FILE = '/tmp/validate_iframes_stop'
2 |
--------------------------------------------------------------------------------
/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaltura/nginx-vod-module/HEAD/static/favicon.ico
--------------------------------------------------------------------------------
/static/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow: /content/
3 | Disallow: /p/*/serveFlavor/
4 |
5 | User-agent: Googlebot
6 | Disallow: /content/
7 |
--------------------------------------------------------------------------------
/test/parse_http_time.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | import email.utils as eut
3 | import calendar
4 | import sys
5 |
6 | print(calendar.timegm(eut.parsedate(sys.argv[1])))
7 |
--------------------------------------------------------------------------------
/vod/mkv/mkv_format.h:
--------------------------------------------------------------------------------
1 | #ifndef __MKV_FORMAT_H__
2 | #define __MKV_FORMAT_H__
3 |
4 | // includes
5 | #include "../media_format.h"
6 |
7 | // globals
8 | extern media_format_t mkv_format;
9 |
10 | #endif //__MKV_FORMAT_H__
11 |
--------------------------------------------------------------------------------
/vod/subtitle/cap_format.h:
--------------------------------------------------------------------------------
1 | #ifndef __CAP_FORMAT_H__
2 | #define __CAP_FORMAT_H__
3 |
4 | // includes
5 | #include "../media_format.h"
6 |
7 | // globals
8 | extern media_format_t cap_format;
9 |
10 | #endif //__CAP_FORMAT_H__
11 |
--------------------------------------------------------------------------------
/ngx_http_vod_hds.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_HDS_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_HDS_H_INCLUDED_
3 |
4 | // includes
5 | #include "ngx_http_vod_submodule.h"
6 |
7 | // globals
8 | extern const ngx_http_vod_submodule_t hds;
9 |
10 | #endif // _NGX_HTTP_VOD_HDS_H_INCLUDED_
11 |
--------------------------------------------------------------------------------
/ngx_http_vod_hls.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_HLS_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_HLS_H_INCLUDED_
3 |
4 | // includes
5 | #include "ngx_http_vod_submodule.h"
6 |
7 | // globals
8 | extern const ngx_http_vod_submodule_t hls;
9 |
10 | #endif // _NGX_HTTP_VOD_HLS_H_INCLUDED_
11 |
--------------------------------------------------------------------------------
/ngx_http_vod_mss.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_MSS_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_MSS_H_INCLUDED_
3 |
4 | // includes
5 | #include "ngx_http_vod_submodule.h"
6 |
7 | // globals
8 | extern const ngx_http_vod_submodule_t mss;
9 |
10 | #endif // _NGX_HTTP_VOD_MSS_H_INCLUDED_
11 |
--------------------------------------------------------------------------------
/conf/main.conf.template:
--------------------------------------------------------------------------------
1 | user kaltura;
2 | worker_processes auto;
3 |
4 | error_log @LOG_DIR@/kaltura_nginx_errors.log;
5 |
6 | pid @PID_FILE_PATH@;
7 |
8 | events {
9 | worker_connections 1024;
10 | worker_aio_requests 512;
11 | multi_accept on;
12 | use epoll;
13 | }
14 |
--------------------------------------------------------------------------------
/ngx_http_vod_dash.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_DASH_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_DASH_H_INCLUDED_
3 |
4 | // includes
5 | #include "ngx_http_vod_submodule.h"
6 |
7 | // globals
8 | extern const ngx_http_vod_submodule_t dash;
9 |
10 | #endif // _NGX_HTTP_VOD_DASH_H_INCLUDED_
11 |
--------------------------------------------------------------------------------
/ngx_http_vod_status.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_STATUS_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_STATUS_H_INCLUDED_
3 |
4 | // includes
5 | #include
6 |
7 | // functions
8 | ngx_int_t ngx_http_vod_status_handler(ngx_http_request_t *r);
9 |
10 | #endif // _NGX_HTTP_VOD_STATUS_H_INCLUDED_
11 |
--------------------------------------------------------------------------------
/test/g2o_params.py.template:
--------------------------------------------------------------------------------
1 |
2 | G2O_VERSION = '5'
3 | G2O_GHOST_IP = '1.2.3.4'
4 | G2O_CLIENT_IP = '5.6.7.8'
5 | G2O_UNIQUE_ID = 'xxx'
6 | G2O_NONCE = 'token'
7 | G2O_KEY = ''
8 | G2O_DATA_HEADER_NAME = 'X-Akamai-G2O-Auth-Data'
9 | G2O_SIGN_HEADER_NAME = 'X-Akamai-G2O-Auth-Sign'
10 | G2O_WINDOW = 29
11 |
--------------------------------------------------------------------------------
/vod/hls/frame_joiner_filter.h:
--------------------------------------------------------------------------------
1 | #ifndef __FRAME_JOINER_H__
2 | #define __FRAME_JOINER_H__
3 |
4 | // include
5 | #include "media_filter.h"
6 |
7 | // functions
8 | vod_status_t frame_joiner_init(
9 | media_filter_t* filter,
10 | media_filter_context_t* context);
11 |
12 | #endif // __FRAME_JOINER_H__
13 |
--------------------------------------------------------------------------------
/conf/cors.conf:
--------------------------------------------------------------------------------
1 | add_header Access-Control-Allow-Headers "Origin,Range,Accept-Encoding,Referer,Cache-Control";
2 | add_header Access-Control-Expose-Headers "Server,Content-Length,Content-Range,Date";
3 | add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS";
4 | add_header Access-Control-Allow-Origin "*";
5 |
--------------------------------------------------------------------------------
/ngx_http_vod_volume_map.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_VOLUME_MAP_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_VOLUME_MAP_H_INCLUDED_
3 |
4 | // includes
5 | #include "ngx_http_vod_submodule.h"
6 |
7 | // globals
8 | extern const ngx_http_vod_submodule_t volume_map;
9 |
10 | #endif // _NGX_HTTP_VOD_VOLUME_MAP_H_INCLUDED_
11 |
--------------------------------------------------------------------------------
/vod/subtitle/dfxp_format.h:
--------------------------------------------------------------------------------
1 | #ifndef __DFXP_FORMAT_H__
2 | #define __DFXP_FORMAT_H__
3 |
4 | // includes
5 | #include "../media_format.h"
6 |
7 | // globals
8 | extern media_format_t dfxp_format;
9 |
10 | // functions
11 | void dfxp_init_process();
12 | void dfxp_exit_process();
13 |
14 | #endif //__DFXP_FORMAT_H__
15 |
--------------------------------------------------------------------------------
/vod/subtitle/webvtt_format.h:
--------------------------------------------------------------------------------
1 | #ifndef __WEBVTT_FORMAT_H__
2 | #define __WEBVTT_FORMAT_H__
3 |
4 | // includes
5 | #include "../media_format.h"
6 |
7 | // globals
8 | extern media_format_t webvtt_format;
9 |
10 | // functions
11 | void webvtt_init_process(vod_log_t* log);
12 | void webvtt_exit_process();
13 |
14 | #endif //__WEBVTT_FORMAT_H__
15 |
--------------------------------------------------------------------------------
/vod/mp4/mp4_format.h:
--------------------------------------------------------------------------------
1 | #ifndef __MP4_FORMAT_H__
2 | #define __MP4_FORMAT_H__
3 |
4 | // includes
5 | #include "../media_format.h"
6 |
7 | // enums
8 | enum {
9 | MP4_METADATA_PART_FTYP,
10 | MP4_METADATA_PART_MOOV,
11 | MP4_METADATA_PART_COUNT
12 | };
13 |
14 | // globals
15 | extern media_format_t mp4_format;
16 |
17 | #endif //__MP4_FORMAT_H__
18 |
--------------------------------------------------------------------------------
/ngx_http_vod_thumb_conf.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_THUMB_CONF_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_THUMB_CONF_H_INCLUDED_
3 |
4 | // includes
5 | #include
6 |
7 | // typedefs
8 | typedef struct
9 | {
10 | ngx_str_t file_name_prefix;
11 | ngx_flag_t accurate;
12 | } ngx_http_vod_thumb_loc_conf_t;
13 |
14 | #endif // _NGX_HTTP_VOD_THUMB_CONF_H_INCLUDED_
15 |
--------------------------------------------------------------------------------
/vod/hls/eac3_encrypt_filter.h:
--------------------------------------------------------------------------------
1 | #ifndef __EAC3_ENCRYPT_FILTER_H__
2 | #define __EAC3_ENCRYPT_FILTER_H__
3 |
4 | // include
5 | #include "media_filter.h"
6 | #include "hls_encryption.h"
7 |
8 | // functions
9 | vod_status_t eac3_encrypt_filter_init(
10 | media_filter_t* filter,
11 | media_filter_context_t* context);
12 |
13 | #endif // __EAC3_ENCRYPT_FILTER_H__
14 |
--------------------------------------------------------------------------------
/ngx_http_vod_volume_map_conf.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_VOLUME_MAP_CONF_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_VOLUME_MAP_CONF_H_INCLUDED_
3 |
4 | // includes
5 | #include
6 |
7 | // typedefs
8 | typedef struct
9 | {
10 | ngx_str_t file_name_prefix;
11 | uintptr_t interval;
12 | } ngx_http_vod_volume_map_loc_conf_t;
13 |
14 | #endif // _NGX_HTTP_VOD_VOLUME_MAP_CONF_H_INCLUDED_
--------------------------------------------------------------------------------
/vod/buffer_pool.h:
--------------------------------------------------------------------------------
1 | #ifndef __BUFFER_POOL_H__
2 | #define __BUFFER_POOL_H__
3 |
4 | // includes
5 | #include "common.h"
6 |
7 | // functions
8 | buffer_pool_t* buffer_pool_create(vod_pool_t* pool, vod_log_t* log, size_t buffer_size, size_t count);
9 | void* buffer_pool_alloc(request_context_t* reqeust_context, buffer_pool_t* buffer_pool, size_t* buffer_size);
10 |
11 | #endif // __BUFFER_POOL_H__
12 |
--------------------------------------------------------------------------------
/vod/filters/mix_filter.h:
--------------------------------------------------------------------------------
1 | #ifndef __MIX_FILTER_H__
2 | #define __MIX_FILTER_H__
3 |
4 | // includes
5 | #include "../json_parser.h"
6 |
7 | // functions
8 | vod_status_t mix_filter_parse(
9 | void* context,
10 | vod_json_object_t* element,
11 | void** result);
12 |
13 | vod_status_t mix_filter_parser_init(
14 | vod_pool_t* pool,
15 | vod_pool_t* temp_pool);
16 |
17 | #endif // __MIX_FILTER_H__
18 |
--------------------------------------------------------------------------------
/vod/input/frames_source_memory.h:
--------------------------------------------------------------------------------
1 | #ifndef __FRAMES_SOURCE_MEMORY_H__
2 | #define __FRAMES_SOURCE_MEMORY_H__
3 |
4 | // includes
5 | #include "frames_source.h"
6 |
7 | // globals
8 | extern frames_source_t frames_source_memory;
9 |
10 | // functions
11 | vod_status_t frames_source_memory_init(
12 | request_context_t* request_context,
13 | void** result);
14 |
15 | #endif //__FRAMES_SOURCE_MEMORY_H__
16 |
--------------------------------------------------------------------------------
/test/stream_compare_params.py.template:
--------------------------------------------------------------------------------
1 |
2 | STOP_FILE = '/tmp/stream_compare_stop'
3 | URL1_BASE = ['http://localhost:8001']
4 | URL2_BASE = ['http://localhost:8001']
5 |
6 | EXTRA_HEADERS = {}
7 |
8 | LOG_LEVEL = {
9 | "UrlCompareLog": True
10 | }
11 |
12 | CHUNK_LIST_ITEMS_TO_COMPARE = 0 #0 is all
13 |
14 | URL_COMPARE_RETRIES = 3
15 |
16 | URL_COMPARE_RETRIES_SLEEP_INTERVAL = 5
--------------------------------------------------------------------------------
/vod/filters/gain_filter.h:
--------------------------------------------------------------------------------
1 | #ifndef __GAIN_FILTER_H__
2 | #define __GAIN_FILTER_H__
3 |
4 | // includes
5 | #include "../json_parser.h"
6 |
7 | // functions
8 | vod_status_t gain_filter_parse(
9 | void* context,
10 | vod_json_object_t* element,
11 | void** result);
12 |
13 | vod_status_t gain_filter_parser_init(
14 | vod_pool_t* pool,
15 | vod_pool_t* temp_pool);
16 |
17 | #endif // __GAIN_FILTER_H__
18 |
--------------------------------------------------------------------------------
/conf/base.conf:
--------------------------------------------------------------------------------
1 |
2 | # nginx status page
3 | location = /nginx_status {
4 | stub_status on;
5 | access_log off;
6 | }
7 |
8 | # vod status page
9 | location = /vod_status {
10 | vod_status;
11 | access_log off;
12 | }
13 |
14 | # redirect server error pages to the static page /50x.html
15 | error_page 500 502 503 504 /50x.html;
16 |
17 | location = /50x.html {
18 | root html;
19 | }
20 |
--------------------------------------------------------------------------------
/ngx_http_vod_mss_conf.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_MSS_CONF_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_MSS_CONF_H_INCLUDED_
3 |
4 | // includes
5 | #include
6 | #include "vod/mss/mss_packager.h"
7 |
8 | // typedefs
9 | typedef struct
10 | {
11 | ngx_str_t manifest_file_name_prefix;
12 | mss_manifest_config_t manifest_conf;
13 | } ngx_http_vod_mss_loc_conf_t;
14 |
15 | #endif // _NGX_HTTP_VOD_MSS_CONF_H_INCLUDED_
16 |
--------------------------------------------------------------------------------
/static/crossdomain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/vod/input/silence_generator.h:
--------------------------------------------------------------------------------
1 | #ifndef __SILENCE_GENERATOR_H__
2 | #define __SILENCE_GENERATOR_H__
3 |
4 | // includes
5 | #include "../media_clip.h"
6 | #include "../json_parser.h"
7 |
8 | // globals
9 | extern media_generator_t silence_generator;
10 |
11 | // functions
12 | vod_status_t silence_generator_parse(
13 | void* ctx,
14 | vod_json_object_t* element,
15 | void** result);
16 |
17 | #endif // __SILENCE_GENERATOR_H__
18 |
--------------------------------------------------------------------------------
/vod/subtitle/webvtt_builder.h:
--------------------------------------------------------------------------------
1 | #ifndef __WEBVTT_BUILDER_H__
2 | #define __WEBVTT_BUILDER_H__
3 |
4 | // includes
5 | #include "../media_set.h"
6 |
7 | // constants
8 | #define WEBVTT_TIMESCALE (1000)
9 |
10 | // functions
11 | vod_status_t webvtt_builder_build(
12 | request_context_t* request_context,
13 | media_set_t* media_set,
14 | bool_t clip_relative_timestamps,
15 | vod_str_t* result);
16 |
17 | #endif //__WEBVTT_BUILDER_H__
18 |
--------------------------------------------------------------------------------
/vod/mp4/mp4_cbcs_encrypt.h:
--------------------------------------------------------------------------------
1 | #ifndef __MP4_CBCS_ENCRYPT_H__
2 | #define __MP4_CBCS_ENCRYPT_H__
3 |
4 | // includes
5 | #include "../media_set.h"
6 |
7 | // functions
8 | vod_status_t mp4_cbcs_encrypt_get_writers(
9 | request_context_t* request_context,
10 | media_set_t* media_set,
11 | segment_writer_t* segment_writer,
12 | const u_char* key,
13 | const u_char* iv,
14 | segment_writer_t** result);
15 |
16 | #endif //__MP4_CBCS_ENCRYPT_H__
17 |
--------------------------------------------------------------------------------
/vod/hds/hds_encryption.h:
--------------------------------------------------------------------------------
1 | #ifndef __HDS_ENCRYPTION_H__
2 | #define __HDS_ENCRYPTION_H__
3 |
4 | // includes
5 | #include "../common.h"
6 |
7 | // typedefs
8 | typedef enum {
9 | HDS_ENC_NONE,
10 | HDS_ENC_SELECTIVE, // SE = Selective Encryption
11 | } hds_encryption_type_t;
12 |
13 | typedef struct {
14 | hds_encryption_type_t type;
15 | u_char* key;
16 | u_char* iv;
17 | } hds_encryption_params_t;
18 |
19 | #endif // __HDS_ENCRYPTION_H__
20 |
--------------------------------------------------------------------------------
/conf/ssl.conf.template:
--------------------------------------------------------------------------------
1 | # HTTPS server
2 | #
3 | server {
4 | listen @VOD_PACKAGER_SSL_PORT@ ssl;
5 | server_name @VOD_PACKAGER_HOST@;
6 |
7 | ssl_certificate @SSL_CERT@;
8 | ssl_certificate_key @SSL_KEY@;
9 |
10 | ssl_session_cache shared:SSL:1m;
11 | ssl_session_timeout 5m;
12 |
13 | ssl_ciphers HIGH:!aNULL:!MD5;
14 | ssl_prefer_server_ciphers on;
15 |
16 | include @NGINX_CONF_PATH@/server.conf;
17 | }
18 |
--------------------------------------------------------------------------------
/ngx_http_vod_thumb.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_THUMB_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_THUMB_H_INCLUDED_
3 |
4 | // includes
5 | #include "ngx_http_vod_submodule.h"
6 |
7 | // globals
8 | extern const ngx_http_vod_submodule_t thumb;
9 |
10 | // functions
11 | ngx_int_t ngx_http_vod_thumb_get_url(
12 | ngx_http_vod_submodule_context_t* submodule_context,
13 | uint32_t sequences_mask,
14 | ngx_str_t* result);
15 |
16 | #endif // _NGX_HTTP_VOD_THUMB_H_INCLUDED_
17 |
--------------------------------------------------------------------------------
/test/main_params.py.template:
--------------------------------------------------------------------------------
1 | TEST_FLAVOR_URI = '/p/.../sp/.../serveFlavor/entryId/.../v/.../flavorId/...' # a serveFlavor URI of some h264/aac mp4
2 | TEST_FLAVOR_FILE = '/content/.../entry/data/...mp4' # the file path of some h264/aac mp4
3 | TEST_FILES_ROOT = '/web'
4 | TEST_NONEXISTING_FILE = '/content/file/not/found'
5 | TEST_NO_READ_ACCESS_FILE = '/content/shared/no_access' # a file that nginx workers cant read
6 | TEST_FOLDER = '/content/entry' # some folder
7 |
--------------------------------------------------------------------------------
/test/setup_test_entries_params.py.template:
--------------------------------------------------------------------------------
1 | PARTNER_ID = 1234
2 | ADMIN_SECRET = "abcd"
3 | SERVICE_URL = "http://www.kaltura.com"
4 | USER_NAME = "admin"
5 | TEST_FLAVOR_URL = 'http://www.kaltura.com/p/99/sp/9900/serveFlavor/entryId/0_ci8ffv43/v/1/flavorId/0_o2yj6rxx'
6 | TEMP_DOWNLOAD_PATH = '/tmp/temp.mp4'
7 | TEMP_CONVERT_PATH = '/tmp/convert.mp4'
8 | FFMPEG_BIN = '/path/to/ffmpeg'
9 | QTFASTSTART_BIN = 'python -m qtfaststart' # install https://github.com/danielgtaylor/qtfaststart
10 |
--------------------------------------------------------------------------------
/test/bitset/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ -z "$NGX_ROOT" ]; then
4 | echo "NGX_ROOT not set"
5 | exit 1
6 | fi
7 |
8 | if [ -z "$VOD_ROOT" ]; then
9 | echo "VOD_ROOT not set"
10 | exit 1
11 | fi
12 |
13 | if [ -z "$CC" ]; then
14 | CC=cc
15 | fi
16 |
17 | $CC -Wall -g -obitsettest -DNGX_HAVE_LIB_AV_CODEC=0 $VOD_ROOT/vod/common.c $VOD_ROOT/test/bitset/main.c -I $NGX_ROOT/src/core -I $NGX_ROOT/src/event -I $NGX_ROOT/src/event/modules -I $NGX_ROOT/src/os/unix -I $NGX_ROOT/objs -I $VOD_ROOT
18 |
--------------------------------------------------------------------------------
/static/clientaccesspolicy.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/conf/vod-remote-nginx.conf.template:
--------------------------------------------------------------------------------
1 | include @NGINX_CONF_PATH@/main.conf;
2 |
3 | http {
4 | upstream media {
5 | server @MEDIA_HOST@;
6 | keepalive 32;
7 | }
8 |
9 | include @NGINX_CONF_PATH@/http.conf;
10 |
11 | # vod remote settings
12 | vod_mode remote;
13 | vod_upstream_location /media_proxy;
14 |
15 | server {
16 | listen @VOD_PACKAGER_PORT@;
17 | server_name @VOD_PACKAGER_HOST@;
18 | include @NGINX_CONF_PATH@/server.conf;
19 | }
20 |
21 | include @NGINX_CONF_PATH@/ssl.conf;
22 | }
23 |
--------------------------------------------------------------------------------
/vod/cli/vod_array.h:
--------------------------------------------------------------------------------
1 | #ifndef __VOD_ARRAY_H__
2 | #define __VOD_ARRAY_H__
3 |
4 | #define vod_array_init(array, pool, n, size) vod_array_init_impl(array, n, size)
5 |
6 | typedef struct {
7 | void *elts;
8 | unsigned nelts;
9 | size_t size;
10 | unsigned nalloc;
11 | } vod_array_t;
12 |
13 | int vod_array_init_impl(vod_array_t *array, unsigned n, size_t size);
14 | void *vod_array_push(vod_array_t *a);
15 | void vod_array_destroy(vod_array_t *a);
16 |
17 | #endif // __VOD_ARRAY_H__
18 |
--------------------------------------------------------------------------------
/conf/vod-local-nginx.conf.template:
--------------------------------------------------------------------------------
1 | include @NGINX_CONF_PATH@/main.conf;
2 |
3 | http {
4 | include @NGINX_CONF_PATH@/http.conf;
5 |
6 | # file handle caching / aio
7 | open_file_cache max=1000 inactive=5m;
8 | open_file_cache_valid 2m;
9 | open_file_cache_min_uses 1;
10 | open_file_cache_errors on;
11 | aio on;
12 |
13 | server {
14 | listen @VOD_PACKAGER_PORT@;
15 | server_name @VOD_PACKAGER_HOST@;
16 | include @NGINX_CONF_PATH@/server.conf;
17 | }
18 |
19 | include @NGINX_CONF_PATH@/ssl.conf;
20 | }
21 |
--------------------------------------------------------------------------------
/test/hls_compare_params.py.template:
--------------------------------------------------------------------------------
1 | URL1_PREFIX = 'http://localhost:8001/mapped'
2 | URL1_PREFIXES = ['mapped/hls','remote/hls','mapped/hls/enc','remote/hls/enc']
3 | URL1_SUFFIX = '/index.m3u8'
4 | URL2_PREFIX = 'http://some-other-server'
5 | URL2_SUFFIX = '/index.m3u8'
6 | FFPROBE_BIN = '/path/to/ffprobe'
7 | TEST_PARTNER_ID = '12345'
8 |
9 | STOP_FILE = '/tmp/compare_stop'
10 | TEMP_TS_FILE1 = '/tmp/1.ts'
11 | TEMP_TS_FILE2 = '/tmp/2.ts'
12 | TEMP_FFPROBE_FILE1 = '/tmp/1.ts.ffp'
13 | TEMP_FFPROBE_FILE2 = '/tmp/2.ts.ffp'
14 |
--------------------------------------------------------------------------------
/vod/hls/frame_encrypt_filter.h:
--------------------------------------------------------------------------------
1 | #ifndef __FRAME_ENCRYPT_FILTER_H__
2 | #define __FRAME_ENCRYPT_FILTER_H__
3 |
4 | // include
5 | #include "media_filter.h"
6 | #include "hls_encryption.h"
7 |
8 | // functions
9 | vod_status_t frame_encrypt_filter_init(
10 | media_filter_t* filter,
11 | media_filter_context_t* context,
12 | hls_encryption_params_t* encryption_params);
13 |
14 | void frame_encrypt_start_sub_frame(
15 | media_filter_context_t* context,
16 | uint32_t size);
17 |
18 | #endif // __FRAME_ENCRYPT_FILTER_H__
19 |
--------------------------------------------------------------------------------
/ngx_http_vod_submodule.c:
--------------------------------------------------------------------------------
1 | #include "ngx_http_vod_dash.h"
2 | #include "ngx_http_vod_hds.h"
3 | #include "ngx_http_vod_hls.h"
4 | #include "ngx_http_vod_mss.h"
5 |
6 | #if (NGX_HAVE_LIB_AV_CODEC)
7 | #include "ngx_http_vod_thumb.h"
8 | #include "ngx_http_vod_volume_map.h"
9 | #endif // NGX_HAVE_LIB_AV_CODEC
10 |
11 | const ngx_http_vod_submodule_t* submodules[] = {
12 | &dash,
13 | &hds,
14 | &hls,
15 | &mss,
16 | #if (NGX_HAVE_LIB_AV_CODEC)
17 | &thumb,
18 | &volume_map,
19 | #endif // NGX_HAVE_LIB_AV_CODEC
20 | NULL,
21 | };
22 |
--------------------------------------------------------------------------------
/ngx_perf_counters_x.h:
--------------------------------------------------------------------------------
1 | PC(FETCH_CACHE, fetch_cache)
2 | PC(STORE_CACHE, store_cache)
3 | PC(MAP_PATH, map_path)
4 | PC(PARSE_MEDIA_SET, parse_media_set)
5 | PC(GET_DRM_INFO, get_drm_info)
6 | PC(OPEN_FILE, open_file)
7 | PC(ASYNC_OPEN_FILE, async_open_file)
8 | PC(READ_FILE, read_file)
9 | PC(ASYNC_READ_FILE, async_read_file)
10 | PC(MEDIA_PARSE, media_parse)
11 | PC(BUILD_MANIFEST, build_manifest)
12 | PC(INIT_FRAME_PROCESS, init_frame_processing)
13 | PC(PROCESS_FRAMES, process_frames)
14 | PC(TOTAL, total)
15 |
--------------------------------------------------------------------------------
/ngx_http_vod_hds_conf.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_HDS_CONF_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_HDS_CONF_H_INCLUDED_
3 |
4 | // includes
5 | #include
6 | #include "vod/hds/hds_manifest.h"
7 | #include "vod/hds/hds_fragment.h"
8 |
9 | // typedefs
10 | typedef struct
11 | {
12 | ngx_flag_t absolute_manifest_urls;
13 | ngx_str_t manifest_file_name_prefix;
14 | hds_manifest_config_t manifest_config;
15 | hds_fragment_config_t fragment_config;
16 | } ngx_http_vod_hds_loc_conf_t;
17 |
18 | #endif // _NGX_HTTP_VOD_HDS_CONF_H_INCLUDED_
19 |
--------------------------------------------------------------------------------
/vod/filters/concat_clip.h:
--------------------------------------------------------------------------------
1 | #ifndef __CONCAT_CLIP_H__
2 | #define __CONCAT_CLIP_H__
3 |
4 | // includes
5 | #include "../json_parser.h"
6 | #include "../media_clip.h"
7 |
8 | // functions
9 | vod_status_t concat_clip_parse(
10 | void* context,
11 | vod_json_object_t* element,
12 | void** result);
13 |
14 | vod_status_t concat_clip_concat(
15 | request_context_t* request_context,
16 | media_clip_t* clip);
17 |
18 | vod_status_t concat_clip_parser_init(
19 | vod_pool_t* pool,
20 | vod_pool_t* temp_pool);
21 |
22 | #endif // __CONCAT_CLIP_H__
23 |
--------------------------------------------------------------------------------
/test/ts_utils.py:
--------------------------------------------------------------------------------
1 | from Crypto.Cipher import AES
2 |
3 | def decryptTsSegment(fileData, aesKey, aesIv):
4 | cipher = AES.new(aesKey, AES.MODE_CBC, aesIv)
5 | try:
6 | decryptedTS = cipher.decrypt(fileData)
7 | except ValueError:
8 | return None, 'Error: cipher.decrypt failed'
9 | padLength = ord(decryptedTS[-1])
10 | if padLength > 16:
11 | return None, 'Error: invalid pad length %s' % padLength
12 | if decryptedTS[-padLength:] != chr(padLength) * padLength:
13 | return None, 'Error: invalid padding'
14 | return decryptedTS[:-padLength], ''
15 |
--------------------------------------------------------------------------------
/vod/dynamic_buffer.h:
--------------------------------------------------------------------------------
1 | #ifndef __DYNAMIC_BUFFER_H__
2 | #define __DYNAMIC_BUFFER_H__
3 |
4 | // includes
5 | #include "common.h"
6 |
7 | // typedefs
8 | typedef struct {
9 | request_context_t* request_context;
10 | u_char* start;
11 | u_char* pos;
12 | u_char* end;
13 | } vod_dynamic_buf_t;
14 |
15 | // functions
16 | vod_status_t vod_dynamic_buf_init(vod_dynamic_buf_t* buffer, request_context_t* request_context, size_t initial_size);
17 |
18 | vod_status_t vod_dynamic_buf_reserve(vod_dynamic_buf_t* buffer, size_t size);
19 |
20 | #endif // __DYNAMIC_BUFFER_H__
21 |
--------------------------------------------------------------------------------
/vod/hls/adts_encoder_filter.h:
--------------------------------------------------------------------------------
1 | #ifndef __ADTS_ENCODER_FILTER_H__
2 | #define __ADTS_ENCODER_FILTER_H__
3 |
4 | // includes
5 | #include "hls_encryption.h"
6 | #include "bit_fields.h"
7 | #include "media_filter.h"
8 | #include "../media_format.h"
9 | #include "../common.h"
10 |
11 | // functions
12 | vod_status_t adts_encoder_init(
13 | media_filter_t* filter,
14 | media_filter_context_t* context);
15 |
16 | vod_status_t adts_encoder_set_media_info(
17 | media_filter_context_t* context,
18 | media_info_t* media_info);
19 |
20 | #endif // __ADTS_ENCODER_FILTER_H__
21 |
--------------------------------------------------------------------------------
/vod/aes_defs.h:
--------------------------------------------------------------------------------
1 | #ifndef __AES_DEFS_H__
2 | #define __AES_DEFS_H__
3 |
4 | // includes
5 | #include "common.h"
6 |
7 | #if (VOD_HAVE_OPENSSL_EVP)
8 | #include
9 | #endif // VOD_HAVE_OPENSSL_EVP
10 |
11 | // constants
12 | #ifndef AES_BLOCK_SIZE
13 | #define AES_BLOCK_SIZE (16)
14 | #endif // AES_BLOCK_SIZE
15 |
16 | // macros
17 | #define aes_round_down_to_block(n) ((n) & ~0xf)
18 | #define aes_round_up_to_block(n) aes_round_down_to_block((n) + 0x10)
19 | #define aes_round_up_to_block_exact(n) aes_round_down_to_block((n) + 0xf)
20 |
21 | #endif //__AES_DEFS_H__
22 |
--------------------------------------------------------------------------------
/vod/subtitle/ttml_builder.h:
--------------------------------------------------------------------------------
1 | #ifndef __TTML_BUILDER_H__
2 | #define __TTML_BUILDER_H__
3 |
4 | // includes
5 | #include "../media_set.h"
6 |
7 | // constants
8 | #define TTML_TIMESCALE (1000)
9 |
10 | // functions
11 | size_t ttml_builder_get_max_size(media_set_t* media_set);
12 |
13 | u_char* ttml_builder_write(media_set_t* media_set, u_char* p);
14 |
15 | vod_status_t ttml_build_mp4(
16 | request_context_t* request_context,
17 | media_set_t* media_set,
18 | uint32_t segment_index,
19 | uint32_t timescale,
20 | vod_str_t* result);
21 |
22 | #endif //__TTML_BUILDER_H__
23 |
--------------------------------------------------------------------------------
/vod/hls/hls_encryption.h:
--------------------------------------------------------------------------------
1 | #ifndef __HLS_ENCRYPTION_H__
2 | #define __HLS_ENCRYPTION_H__
3 |
4 | // includes
5 | #include "../common.h"
6 | #include "../aes_defs.h"
7 |
8 | // typedefs
9 | typedef enum {
10 | HLS_ENC_NONE,
11 | HLS_ENC_AES_128,
12 | HLS_ENC_SAMPLE_AES,
13 | HLS_ENC_SAMPLE_AES_CENC,
14 | } hls_encryption_type_t;
15 |
16 | typedef struct {
17 | hls_encryption_type_t type;
18 | u_char* key;
19 | u_char* iv;
20 | vod_str_t key_uri;
21 | bool_t return_iv;
22 | u_char iv_buf[AES_BLOCK_SIZE];
23 | } hls_encryption_params_t;
24 |
25 | #endif // __HLS_ENCRYPTION_H__
26 |
--------------------------------------------------------------------------------
/vod/thumb/thumb_grabber.h:
--------------------------------------------------------------------------------
1 | #ifndef __THUMB_GRABBER_H__
2 | #define __THUMB_GRABBER_H__
3 |
4 | // includes
5 | #include "../media_format.h"
6 | #include "../media_set.h"
7 |
8 | // functions
9 | void thumb_grabber_process_init(vod_log_t* log);
10 |
11 | vod_status_t thumb_grabber_init_state(
12 | request_context_t* request_context,
13 | media_track_t* track,
14 | request_params_t* request_params,
15 | bool_t accurate,
16 | write_callback_t write_callback,
17 | void* write_context,
18 | void** result);
19 |
20 | vod_status_t thumb_grabber_process(void* context);
21 |
22 | #endif //__THUMB_GRABBER_H__
23 |
--------------------------------------------------------------------------------
/ngx_http_vod_dash_conf.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_DASH_CONF_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_DASH_CONF_H_INCLUDED_
3 |
4 | // includes
5 | #include
6 | #include "vod/dash/dash_packager.h"
7 |
8 | // typedefs
9 | typedef struct
10 | {
11 | ngx_str_t manifest_file_name_prefix;
12 | ngx_flag_t absolute_manifest_urls;
13 | ngx_flag_t init_mp4_pssh;
14 | dash_manifest_config_t mpd_config;
15 | } ngx_http_vod_dash_loc_conf_t;
16 |
17 | // globals
18 | extern ngx_conf_enum_t dash_manifest_formats[];
19 |
20 | extern ngx_conf_enum_t dash_subtitle_formats[];
21 |
22 | #endif // _NGX_HTTP_VOD_DASH_CONF_H_INCLUDED_
23 |
--------------------------------------------------------------------------------
/test/json_parser/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ -z "$NGX_ROOT" ]; then
4 | echo "NGX_ROOT not set"
5 | exit 1
6 | fi
7 |
8 | if [ -z "$VOD_ROOT" ]; then
9 | echo "VOD_ROOT not set"
10 | exit 1
11 | fi
12 |
13 | if [ -z "$CC" ]; then
14 | CC=cc
15 | fi
16 |
17 | $CC -Wall -g -ojsontest $VOD_ROOT/vod/json_parser.c $VOD_ROOT/vod/parse_utils.c $VOD_ROOT/test/json_parser/main.c $NGX_ROOT/src/core/ngx_string.c $NGX_ROOT/src/core/ngx_hash.c $NGX_ROOT/src/core/ngx_palloc.c $NGX_ROOT/src/os/unix/ngx_alloc.c -I $NGX_ROOT/src/core -I $NGX_ROOT/src/event -I $NGX_ROOT/src/event/modules -I $NGX_ROOT/src/os/unix -I $NGX_ROOT/objs -I $VOD_ROOT
18 |
--------------------------------------------------------------------------------
/vod/hls/mp4_to_annexb_filter.h:
--------------------------------------------------------------------------------
1 | #ifndef __MP4_TO_ANNEXB_FILTER_H__
2 | #define __MP4_TO_ANNEXB_FILTER_H__
3 |
4 | // includes
5 | #include "hls_encryption.h"
6 | #include "media_filter.h"
7 | #include "../media_format.h"
8 |
9 | // functions
10 | vod_status_t mp4_to_annexb_init(
11 | media_filter_t* filter,
12 | media_filter_context_t* context,
13 | hls_encryption_params_t* encryption_params);
14 |
15 | vod_status_t mp4_to_annexb_set_media_info(
16 | media_filter_context_t* context,
17 | media_info_t* media_info);
18 |
19 | bool_t mp4_to_annexb_simulation_supported(
20 | media_info_t* media_info);
21 |
22 | #endif // __MP4_TO_ANNEXB_FILTER_H__
23 |
--------------------------------------------------------------------------------
/vod/input/frames_source.h:
--------------------------------------------------------------------------------
1 | #ifndef __FRAMES_SOURCE_H__
2 | #define __FRAMES_SOURCE_H__
3 |
4 | // includes
5 | #include "read_cache.h"
6 |
7 | // typedefs
8 | struct input_frame_s;
9 |
10 | typedef struct {
11 | void(*set_cache_slot_id)(void* context, int cache_slot_id);
12 | vod_status_t(*start_frame)(void* context, struct input_frame_s* frame, read_cache_hint_t* cache_hint);
13 | vod_status_t(*read)(void* context, u_char** buffer, uint32_t* size, bool_t* frame_done);
14 | void(*disable_buffer_reuse)(void* context);
15 | vod_status_t(*skip_frames)(void* context, uint32_t skip_count);
16 | } frames_source_t;
17 |
18 | #endif // __FRAMES_SOURCE_H__
19 |
--------------------------------------------------------------------------------
/vod/filters/filter.h:
--------------------------------------------------------------------------------
1 | #ifndef __FILTER_H__
2 | #define __FILTER_H__
3 |
4 | // includes
5 | #include "../input/read_cache.h"
6 | #include "../media_set.h"
7 |
8 | // functions
9 | vod_status_t filter_init_filtered_clips(
10 | request_context_t* request_context,
11 | media_set_t* media_set,
12 | bool_t parsed_frames);
13 |
14 | vod_status_t filter_init_state(
15 | request_context_t* request_context,
16 | read_cache_state_t* read_cache_state,
17 | media_set_t* media_set,
18 | uint32_t max_frame_count,
19 | uint32_t output_codec_id,
20 | void** context);
21 |
22 | vod_status_t filter_run_state_machine(void* context);
23 |
24 | #endif // __FILTER_H__
25 |
--------------------------------------------------------------------------------
/vod/hds/hds_amf0_fields_x.h:
--------------------------------------------------------------------------------
1 | AMF0_FIELD(AMF0_COMMON,duration, AMF0_NUMBER)
2 | AMF0_FIELD(AMF0_VIDEO, width, AMF0_NUMBER)
3 | AMF0_FIELD(AMF0_VIDEO, height, AMF0_NUMBER)
4 | AMF0_FIELD(AMF0_VIDEO, videodatarate, AMF0_NUMBER)
5 | AMF0_FIELD(AMF0_VIDEO, framerate, AMF0_NUMBER)
6 | AMF0_FIELD(AMF0_VIDEO, videocodecid, AMF0_NUMBER)
7 | AMF0_FIELD(AMF0_AUDIO, audiodatarate, AMF0_NUMBER)
8 | AMF0_FIELD(AMF0_AUDIO, audiosamplerate, AMF0_NUMBER)
9 | AMF0_FIELD(AMF0_AUDIO, audiosamplesize, AMF0_NUMBER)
10 | AMF0_FIELD(AMF0_AUDIO, stereo, AMF0_BOOLEAN)
11 | AMF0_FIELD(AMF0_AUDIO, audiocodecid, AMF0_NUMBER)
12 | AMF0_FIELD(AMF0_COMMON,filesize, AMF0_NUMBER)
13 |
--------------------------------------------------------------------------------
/vod/avc_parser.h:
--------------------------------------------------------------------------------
1 | #ifndef __AVC_PARSER_H__
2 | #define __AVC_PARSER_H__
3 |
4 | // includes
5 | #include "common.h"
6 |
7 | // functions
8 | vod_status_t avc_parser_parse_extra_data(
9 | void* ctx,
10 | vod_str_t* extra_data,
11 | uint32_t* nal_packet_size_length,
12 | uint32_t* min_packet_size);
13 |
14 | vod_status_t avc_parser_get_slice_header_size(
15 | void* ctx,
16 | const u_char* buffer,
17 | uint32_t size,
18 | uint32_t* result);
19 |
20 | vod_status_t avc_parser_is_slice(
21 | void* ctx,
22 | uint8_t nal_type,
23 | bool_t* is_slice);
24 |
25 | uint8_t avc_parser_get_transfer_characteristics(
26 | void* ctx);
27 |
28 | #endif // __AVC_PARSER_H__
29 |
--------------------------------------------------------------------------------
/vod/hls/sample_aes_avc_filter.h:
--------------------------------------------------------------------------------
1 | #ifndef __SAMPLE_AES_AVC_FILTER_H__
2 | #define __SAMPLE_AES_AVC_FILTER_H__
3 |
4 | // includes
5 | #include "media_filter.h"
6 |
7 | // functions
8 | vod_status_t sample_aes_avc_filter_init(
9 | media_filter_t* filter,
10 | media_filter_context_t* context,
11 | u_char* key,
12 | u_char* iv);
13 |
14 | vod_status_t sample_aes_avc_start_nal_unit(
15 | media_filter_context_t* context,
16 | int unit_type,
17 | uint32_t unit_size);
18 |
19 | vod_status_t sample_aes_avc_filter_write_nal_body(
20 | media_filter_context_t* context,
21 | const u_char* buffer,
22 | uint32_t size);
23 |
24 | #endif //__SAMPLE_AES_AVC_FILTER_H__
25 |
--------------------------------------------------------------------------------
/vod/mp4/mp4_write_stream.h:
--------------------------------------------------------------------------------
1 | #ifndef __MP4_WRITE_STREAM_H__
2 | #define __MP4_WRITE_STREAM_H__
3 |
4 | #include "../write_stream.h"
5 |
6 | // macros
7 | #define write_atom_name(p, c1, c2, c3, c4) \
8 | { *(p)++ = (c1); *(p)++ = (c2); *(p)++ = (c3); *(p)++ = (c4); }
9 |
10 | #define write_atom_header(p, size, c1, c2, c3, c4) \
11 | { \
12 | write_be32(p, size); \
13 | write_atom_name(p, c1, c2, c3, c4); \
14 | }
15 |
16 | #define write_atom_header64(p, size, c1, c2, c3, c4) \
17 | { \
18 | write_be32(p, 1); \
19 | write_atom_name(p, c1, c2, c3, c4); \
20 | write_be64(p, size); \
21 | }
22 |
23 | #endif //__MP4_WRITE_STREAM_H__
24 |
--------------------------------------------------------------------------------
/test/buffer_cache/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ -z "$NGX_ROOT" ]; then
4 | echo "NGX_ROOT not set"
5 | exit 1
6 | fi
7 |
8 | if [ -z "$VOD_ROOT" ]; then
9 | echo "VOD_ROOT not set"
10 | exit 1
11 | fi
12 |
13 | if [ -z "$CC" ]; then
14 | CC=cc
15 | fi
16 |
17 | $CC -Wall $NGX_ROOT/src/core/ngx_palloc.c $NGX_ROOT/src/os/unix/ngx_alloc.c $NGX_ROOT/src/core/ngx_string.c $NGX_ROOT/src/core/ngx_crc32.c $NGX_ROOT/src/core/ngx_rbtree.c $VOD_ROOT/ngx_buffer_cache.c $VOD_ROOT/test/buffer_cache/main.c -o bctest -I $VOD_ROOT/test/buffer_cache -I $NGX_ROOT/src/core -I $NGX_ROOT/src/event -I $NGX_ROOT/src/event/modules -I $NGX_ROOT/src/os/unix -I $NGX_ROOT/objs -I $VOD_ROOT -g
18 |
--------------------------------------------------------------------------------
/vod/hevc_parser.h:
--------------------------------------------------------------------------------
1 | #ifndef __HEVC_PARSER_H__
2 | #define __HEVC_PARSER_H__
3 |
4 | // includes
5 | #include "common.h"
6 |
7 | // functions
8 | vod_status_t hevc_parser_parse_extra_data(
9 | void* ctx,
10 | vod_str_t* extra_data,
11 | uint32_t* nal_packet_size_length,
12 | uint32_t* min_packet_size);
13 |
14 | vod_status_t hevc_parser_get_slice_header_size(
15 | void* ctx,
16 | const u_char* buffer,
17 | uint32_t size,
18 | uint32_t* result);
19 |
20 | vod_status_t hevc_parser_is_slice(
21 | void* ctx,
22 | uint8_t nal_type,
23 | bool_t* is_slice);
24 |
25 | uint8_t hevc_parser_get_transfer_characteristics(
26 | void* ctx);
27 |
28 | #endif // __HEVC_PARSER_H__
29 |
--------------------------------------------------------------------------------
/ngx_http_vod_thumb_commands.h:
--------------------------------------------------------------------------------
1 | #define BASE_OFFSET offsetof(ngx_http_vod_loc_conf_t, thumb)
2 |
3 | { ngx_string("vod_thumb_file_name_prefix"),
4 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
5 | ngx_conf_set_str_slot,
6 | NGX_HTTP_LOC_CONF_OFFSET,
7 | BASE_OFFSET + offsetof(ngx_http_vod_thumb_loc_conf_t, file_name_prefix),
8 | NULL },
9 |
10 | { ngx_string("vod_thumb_accurate_positioning"),
11 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
12 | ngx_conf_set_flag_slot,
13 | NGX_HTTP_LOC_CONF_OFFSET,
14 | BASE_OFFSET + offsetof(ngx_http_vod_thumb_loc_conf_t, accurate),
15 | NULL },
16 |
17 | #undef BASE_OFFSET
18 |
--------------------------------------------------------------------------------
/ngx_http_vod_volume_map_commands.h:
--------------------------------------------------------------------------------
1 | #define BASE_OFFSET offsetof(ngx_http_vod_loc_conf_t, volume_map)
2 |
3 | { ngx_string("vod_volume_map_file_name_prefix"),
4 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
5 | ngx_conf_set_str_slot,
6 | NGX_HTTP_LOC_CONF_OFFSET,
7 | BASE_OFFSET + offsetof(ngx_http_vod_volume_map_loc_conf_t, file_name_prefix),
8 | NULL },
9 |
10 | { ngx_string("vod_volume_map_interval"),
11 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
12 | ngx_conf_set_num_slot,
13 | NGX_HTTP_LOC_CONF_OFFSET,
14 | BASE_OFFSET + offsetof(ngx_http_vod_volume_map_loc_conf_t, interval),
15 | NULL },
16 |
17 | #undef BASE_OFFSET
--------------------------------------------------------------------------------
/vod/hls/buffer_filter.h:
--------------------------------------------------------------------------------
1 | #ifndef __BUFFER_FILTER_H__
2 | #define __BUFFER_FILTER_H__
3 |
4 | // include
5 | #include "media_filter.h"
6 |
7 | // functions
8 | vod_status_t buffer_filter_init(
9 | media_filter_t* filter,
10 | media_filter_context_t* context,
11 | bool_t align_frames,
12 | uint32_t size);
13 |
14 | vod_status_t buffer_filter_force_flush(
15 | media_filter_context_t* context,
16 | bool_t last_stream_frame);
17 |
18 | bool_t buffer_filter_get_dts(
19 | media_filter_context_t* context,
20 | uint64_t* dts);
21 |
22 |
23 | void buffer_filter_simulated_force_flush(
24 | media_filter_context_t* context,
25 | bool_t last_stream_frame);
26 |
27 | #endif // __BUFFER_FILTER_H__
28 |
--------------------------------------------------------------------------------
/vod/languages_hash_params.h:
--------------------------------------------------------------------------------
1 | // generated by languages_hash_size.py
2 |
3 | #define ISO639_3_HASH_TOTAL_SIZE (2547)
4 |
5 | static const language_hash_offsets_t iso639_3_hash_offsets[] = {
6 | { 0, 361 },
7 | { 361, 148 },
8 | { 509, 191 },
9 | { 700, 85 },
10 | { 785, 19 },
11 | { 804, 33 },
12 | { 837, 111 },
13 | { 948, 146 },
14 | { 1094, 65 },
15 | { 1159, 13 },
16 | { 1172, 212 },
17 | { 1384, 109 },
18 | { 1493, 171 },
19 | { 1664, 108 },
20 | { 1772, 45 },
21 | { 1817, 93 },
22 | { 1910, 8 },
23 | { 1918, 35 },
24 | { 1953, 345 },
25 | { 2298, 178 },
26 | { 2476, 18 },
27 | { 2494, 15 },
28 | { 2509, 9 },
29 | { 2518, 15 },
30 | { 2533, 3 },
31 | { 2536, 11 },
32 | };
33 |
--------------------------------------------------------------------------------
/ngx_http_vod_module.h:
--------------------------------------------------------------------------------
1 | #ifndef _NGX_HTTP_VOD_MODULE_H_INCLUDED_
2 | #define _NGX_HTTP_VOD_MODULE_H_INCLUDED_
3 |
4 | // includes
5 | #include
6 | #include
7 |
8 | // globals
9 | extern ngx_module_t ngx_http_vod_module;
10 |
11 | // main
12 | ngx_int_t ngx_http_vod_handler(ngx_http_request_t *r);
13 |
14 | // variables
15 | ngx_int_t ngx_http_vod_preconfiguration(ngx_conf_t *cf);
16 |
17 | // handlers
18 | ngx_int_t ngx_http_vod_local_request_handler(ngx_http_request_t *r);
19 | ngx_int_t ngx_http_vod_mapped_request_handler(ngx_http_request_t *r);
20 | ngx_int_t ngx_http_vod_remote_request_handler(ngx_http_request_t *r);
21 |
22 | #endif // _NGX_HTTP_VOD_MODULE_H_INCLUDED_
23 |
--------------------------------------------------------------------------------
/vod/mp4/mp4_cenc_decrypt.h:
--------------------------------------------------------------------------------
1 | #ifndef __MP4_CENC_DECRYPT_H__
2 | #define __MP4_CENC_DECRYPT_H__
3 |
4 | // includes
5 | #include "mp4_parser.h"
6 |
7 | // globals
8 | extern frames_source_t mp4_cenc_decrypt_frames_source;
9 |
10 | // functions
11 | vod_status_t mp4_cenc_decrypt_init(
12 | request_context_t* request_context,
13 | frames_source_t* frames_source,
14 | void* frames_source_context,
15 | u_char* key,
16 | media_encryption_t* encryption,
17 | void** result);
18 |
19 | u_char* mp4_cenc_decrypt_get_key(void* context);
20 |
21 | void mp4_cenc_decrypt_get_original_source(
22 | void* ctx,
23 | frames_source_t** frames_source,
24 | void** frames_source_context);
25 |
26 | #endif //__MP4_CENC_DECRYPT_H__
27 |
--------------------------------------------------------------------------------
/vod/media_set.c:
--------------------------------------------------------------------------------
1 | #include "media_set.h"
2 |
3 | int64_t
4 | media_set_get_segment_time_millis(media_set_t* media_set)
5 | {
6 | media_track_t* cur_track;
7 |
8 | // try to find a track that has frames, if no track is found, fallback to the first track
9 | for (cur_track = media_set->filtered_tracks; ; cur_track += media_set->total_track_count)
10 | {
11 | if (cur_track >= media_set->filtered_tracks_end)
12 | {
13 | cur_track = media_set->filtered_tracks;
14 | break;
15 | }
16 |
17 | if (cur_track->frame_count > 0)
18 | {
19 | break;
20 | }
21 | }
22 |
23 | return cur_track->original_clip_time +
24 | rescale_time(cur_track->first_frame_time_offset, cur_track->media_info.timescale, 1000);
25 | }
26 |
--------------------------------------------------------------------------------
/ngx_http_vod_mss_commands.h:
--------------------------------------------------------------------------------
1 | #define BASE_OFFSET offsetof(ngx_http_vod_loc_conf_t, mss)
2 |
3 | { ngx_string("vod_mss_manifest_file_name_prefix"),
4 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
5 | ngx_conf_set_str_slot,
6 | NGX_HTTP_LOC_CONF_OFFSET,
7 | BASE_OFFSET + offsetof(ngx_http_vod_mss_loc_conf_t, manifest_file_name_prefix),
8 | NULL },
9 |
10 | { ngx_string("vod_mss_duplicate_bitrate_threshold"),
11 | NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
12 | ngx_conf_set_num_slot,
13 | NGX_HTTP_LOC_CONF_OFFSET,
14 | BASE_OFFSET + offsetof(ngx_http_vod_mss_loc_conf_t, manifest_conf.duplicate_bitrate_threshold),
15 | NULL },
16 |
17 | #undef BASE_OFFSET
18 |
--------------------------------------------------------------------------------
/vod/parse_utils.h:
--------------------------------------------------------------------------------
1 | #ifndef __PARSE_UTILS_H__
2 | #define __PARSE_UTILS_H__
3 |
4 | // includes
5 | #include "common.h"
6 | #include "media_format.h"
7 |
8 | // functions
9 | vod_status_t parse_utils_parse_guid_string(vod_str_t* str, u_char* output);
10 |
11 | vod_status_t parse_utils_parse_fixed_base64_string(vod_str_t* str, u_char* output, size_t output_size);
12 |
13 | vod_status_t parse_utils_parse_variable_base64_string(vod_pool_t* pool, vod_str_t* str, vod_str_t* result);
14 |
15 | u_char* parse_utils_extract_uint32_token(u_char* start_pos, u_char* end_pos, uint32_t* result);
16 |
17 | u_char* parse_utils_extract_track_tokens(u_char* start_pos, u_char* end_pos, track_mask_t* result);
18 |
19 | #endif // __PARSE_UTILS_H__
20 |
--------------------------------------------------------------------------------
/test/get_perf_counters_as_csv.php:
--------------------------------------------------------------------------------
1 | \nthe url is usually 'http://server-name/vod_status'\n");
6 | }
7 |
8 | // get the status xml
9 | $status = file_get_contents($argv[1]);
10 |
11 | // convert the xml to array
12 | $xml = @simplexml_load_string($status);
13 | $json = json_encode($xml);
14 | $array = json_decode($json, true);
15 |
16 | // print the result
17 | $pc = $array["performance_counters"];
18 |
19 | echo "name,sum,count,max,max_time\n";
20 | foreach ($pc as $key => $row)
21 | {
22 | echo $key;
23 | foreach ($row as $cell)
24 | {
25 | echo ",".$cell;
26 | }
27 | echo "\n";
28 | }
29 |
--------------------------------------------------------------------------------
/conf/kaltura-nginx.conf.template:
--------------------------------------------------------------------------------
1 | include @NGINX_CONF_PATH@/main.conf;
2 |
3 | http {
4 | upstream kalapi {
5 | server @WWW_HOST@;
6 | }
7 |
8 | include @NGINX_CONF_PATH@/http.conf;
9 |
10 | # vod mapped settings
11 | vod_mode mapped;
12 | vod_upstream_location /kalapi_proxy;
13 | vod_upstream_extra_args "pathOnly=1";
14 | vod_mapping_cache mapping_cache 64m;
15 |
16 | # file handle caching / aio
17 | open_file_cache max=1000 inactive=5m;
18 | open_file_cache_valid 2m;
19 | open_file_cache_min_uses 1;
20 | open_file_cache_errors on;
21 | aio on;
22 |
23 | server {
24 | listen @VOD_PACKAGER_PORT@;
25 | server_name @VOD_PACKAGER_HOST@;
26 | include @NGINX_CONF_PATH@/server.conf;
27 | }
28 |
29 | include @NGINX_CONF_PATH@/ssl.conf;
30 | }
31 |
--------------------------------------------------------------------------------
/scripts/encrypt_url.rb:
--------------------------------------------------------------------------------
1 | require 'openssl'
2 | require 'base64'
3 |
4 | if ARGV.length != 4
5 | raise "Usage:\n\truby \n"
6 | end
7 |
8 | base_url = ARGV[0]
9 | encrypted_part = ARGV[1]
10 | encryption_key = [ARGV[2]].pack("H*")
11 | encryption_iv = [ARGV[3]].pack("H*")
12 |
13 | hash_size = 8
14 |
15 | signed_url = Digest::MD5.digest(encrypted_part)[0,hash_size] + encrypted_part
16 |
17 | cipher = OpenSSL::Cipher::AES.new('256-CBC')
18 | cipher.encrypt
19 | cipher.key = encryption_key
20 | cipher.iv = encryption_iv
21 |
22 | encrypted_data = cipher.update(signed_url)
23 | encrypted_data << cipher.final
24 |
25 | puts base_url + Base64.strict_encode64(encrypted_data).tr('+/', '-_').gsub(/(\s|=)*$/,'')
26 |
--------------------------------------------------------------------------------
/test/download_stream.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | import manifest_utils
3 | import http_utils
4 | import sys
5 | import os
6 |
7 | if len(sys.argv) < 3:
8 | print('Usage:\n\tpython %s