# Get (optional) usp overrides and establish defaults
IncludeOptional usp-overrides.de[f]
<IfDefine !UspModulesDir>
  Define UspModulesDir "/usr/lib64/httpd/modules"
</IfDefine>

# Load required modules, if needed
<IfModule !headers_module>
  LoadModule headers_module "/usr/lib64/httpd/modules/mod_headers.so"
</IfModule>
<IfModule !proxy_module>
  LoadModule proxy_module "/usr/lib64/httpd/modules/mod_proxy.so"
</IfModule>
<IfModule !proxy_http_module>
  LoadModule proxy_http_module "/usr/lib64/httpd/modules/mod_proxy_http.so"
</IfModule>
<IfModule !socache_shmcb_module>
  LoadModule socache_shmcb_module "/usr/lib64/httpd/modules/mod_socache_shmcb.so"
</IfModule>
<IfModule !ssl_module>
  LoadModule ssl_module "/usr/lib64/httpd/modules/mod_ssl.so"
</IfModule>
<IfModule !unified_s3_auth_module>
  LoadModule unified_s3_auth_module "${UspModulesDir}/mod_unified_s3_auth.so"
</IfModule>
<IfModule !smooth_streaming_module>
  LoadModule smooth_streaming_module "${UspModulesDir}/mod_smooth_streaming.so"
</IfModule>

#
# If you have virtual hosts then you really want to remove this global
# configuration and configure on a per-virtual-host basis.

# Enable the module.
#AddHandler smooth-streaming.extensions .ism .isml

# Enable just in time packaging for VOD (.ism), Live (.isml), mp4 and f4m.
#<LocationMatch "\.(mp4|f4m|smil|[is]sml?)/">
#  UspHandleIsm on
#  UspHandleF4f on
#</LocationMatch>

# Enable to serve .mp4 and .hd files through Unified Origin. This may be useful
# for playout of statically stored dref-ed MP4 files and/or playout of pseudo
# streaming (mod_smooth_streaming).
#<LocationMatch "\.(mp4|hd)$">
#  SetHandler smooth-streaming.extensions
#</LocationMatch>

# Enable using subrequests for I/O backend requests by default.
#
# Note that this feature requires mod_proxy and mod_proxy_http. For optimal
# performance, create Proxy sections for each remote storage server. See:
# https://docs.unified-streaming.com/documentation/vod/storage_proxy.html
<Location "/">
  UspEnableSubreq on
</Location>

# Enable proxying (for subrequests) to SSL hosts by default.
SSLProxyEngine on

# Instead of the default proxy worker, you can create additional ones and
# tune them for your own storage backend.
#<Proxy "https://my-bucket.s3-region.amazonaws.com/">
#  ProxySet connectiontimeout=5 timeout=30 ttl=300 keepalive=on retry=0
#  RequestHeader set MyHeader "%D %t"
#</Proxy>

# Use UspOutputFilter for manifest editing.
#
# This sets the base path for finding yaml configuration files with
# --python_pipeline_path to /etc/manifest-edit/conf, which is the suggested
# location for maintaining your own copies of the read-only configuration files
# installed under /usr/share/manifest-edit.
#
# Use the query parameter 'python_pipeline_config' to specify the yaml
# configuration. Do not add the .yaml extension, and only specify the relative
# path, for example:
#
# .../manifest.ism/.mpd?python_pipeline_config=mpd/adaptation_sets_order
#
# To match a specific path to a manifest, such as an .mpd, adjust the following
# example:
#
#<LocationMatch "^/path/you/want/to/manifest/edit/.*\.mpd$">
#  <If "%{QUERY_STRING} =~ /(^|&)python_pipeline_config=/">
#    UspOutputFilter "/usr/bin/manifest_edit -v 1 -o stdout: --python_pipeline_path=/etc/manifest-edit/conf --query_string=%{QUERY_STRING} stdin:"
#  </If>
#</LocationMatch>
#
# Alternatively, you can use UspOutputFilter with a specific yaml configuration
# file, and forgo using query parameters, in which case all manifests will be
# filtered accordingly. For example:
#
#<LocationMatch "^/some/other/path/.*\.mpd$">
#  UspOutputFilter "/usr/bin/manifest_edit -v 1 -o stdout: --python_pipeline_config=/etc/manifest-edit/conf/my_specific_configuration.yaml stdin:"
#</LocationMatch>

# The default setting is to invoke the UspOutputFilter for any URL ending in
# .mpd or .m3u8, with a query parameter 'python_pipeline_config'.
<LocationMatch ".*\.(mpd|m3u8)$">
  <If "%{QUERY_STRING} =~ /(^|&)python_pipeline_config=/">
    UspOutputFilter "/usr/bin/manifest_edit -v 1 -o stdout: --python_pipeline_path=/etc/manifest-edit/conf --query_string=%{QUERY_STRING} stdin:"
  </If>
</LocationMatch>

# The following also matches .mpd or .m3u8 manifests when URL rewriting is
# active, e.g. for IsmProxyPass.
<LocationMatch ".*\.ism[l]?$">
  <If "%{QUERY_STRING} =~ /(^|&)python_pipeline_config=/ && %{QUERY_STRING} =~ /(^|&)file=.*\.(mpd|m3u8)($|&)/">
    UspOutputFilter "/usr/bin/manifest_edit -v 1 -o stdout: --python_pipeline_path=/etc/manifest-edit/conf --query_string=%{QUERY_STRING} stdin:"
  </If>
</LocationMatch>
