### SmoothStreaming + PlayReady Example (Python) Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Example of how to play an encrypted SmoothStreaming video stream using PlayReady DRM with inputstream.adaptive in a Python script for Kodi add-ons. ```APIDOC ## SmoothStreaming + PlayReady Example (Python) ### Description This example demonstrates how to configure `inputstream.adaptive` to play an encrypted SmoothStreaming video stream using PlayReady DRM within a Kodi add-on using Python. It shows setting the MIME type, content lookup, and DRM properties. ### Method N/A (Configuration via `xbmcgui.ListItem` properties) ### Endpoint N/A ### Parameters #### Properties - **inputstream** (string) - Set to `'inputstream.adaptive'` to enable the adaptive inputstream. - **inputstream.adaptive.drm_legacy** (string) - Optional - Legacy format for configuring DRM. For PlayReady, simply specify the DRM system: `'com.microsoft.playready'`. - **inputstream.adaptive.drm** (string) - JSON string for configuring DRM. For PlayReady, an empty object is often sufficient: `'{"com.microsoft.playready": {}}'`. - **mimeType** (string) - Set to `'application/vnd.ms-sstr+xml'` for SmoothStreaming. - **ContentLookup** (boolean) - Set to `False` to prevent Kodi from performing an HTTP HEAD request to determine the MIME type. ### Request Example ```python import xbmcgui import xbmcplugin listitem = xbmcgui.ListItem(path='https://www.videoservice.com/tearsofsteel_4k.ism/manifest', offscreen=True) # Prevent Kodi core from determining mimetype via HTTP HEAD request listitem.setMimeType('application/vnd.ms-sstr+xml') listitem.setContentLookup(False) listitem.setProperty('inputstream', 'inputstream.adaptive') # Example configuration with drm_legacy property listitem.setProperty('inputstream.adaptive.drm_legacy', 'com.microsoft.playready') # Example configuration with drm property listitem.setProperty('inputstream.adaptive.drm', '{"com.microsoft.playready": {}}') xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=listitem) ``` ### Response N/A (Resolved URL for playback. ``` -------------------------------- ### DASH + Widevine Example (Python) Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Example of how to play an encrypted DASH video stream using Widevine DRM with inputstream.adaptive in a Python script for Kodi add-ons. ```APIDOC ## DASH + Widevine Example (Python) ### Description This example demonstrates how to configure `inputstream.adaptive` to play an encrypted DASH video stream using Widevine DRM within a Kodi add-on using Python. It shows setting the MIME type, content lookup, and DRM properties. ### Method N/A (Configuration via `xbmcgui.ListItem` properties) ### Endpoint N/A ### Parameters #### Properties - **inputstream** (string) - Set to `'inputstream.adaptive'` to enable the adaptive inputstream. - **inputstream.adaptive.drm_legacy** (string) - Optional - Legacy format for configuring DRM. Format: `DRM_SYSTEM|LICENSE_URL|HEADERS`. Example: `'com.widevine.alpha|https://www.licenseserver.com/acquirelicense|User-Agent=Mozilla%2F5.0...` - **inputstream.adaptive.drm** (string) - JSON string for configuring DRM. Example: `{"com.widevine.alpha": {"license": {"server_url": "https://www.licenseserver.com/acquirelicense", "req_headers": "User-Agent=..."}}}` - **mimeType** (string) - Set to `'application/dash+xml'` for DASH streams. - **ContentLookup** (boolean) - Set to `False` to prevent Kodi from performing an HTTP HEAD request to determine the MIME type. ### Request Example ```python import xbmcgui import xbmcplugin import json from urllib.parse import urlencode listitem = xbmcgui.ListItem(path='https://www.videoservice.com/manifest.mpd', offscreen=True) # Prevent Kodi core from determining mimetype via HTTP HEAD request listitem.setMimeType('application/dash+xml') listitem.setContentLookup(False) listitem.setProperty('inputstream', 'inputstream.adaptive') license_headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0', 'Content-Type': 'application/octet-stream' } # Example configuration with drm_legacy property # listitem.setProperty('inputstream.adaptive.drm_legacy', 'com.widevine.alpha|https://www.licenseserver.com/acquirelicense|' + urlencode(license_headers)) # Example configuration with drm property drm_cfg = {"com.widevine.alpha": {"license": {"server_url": "https://www.licenseserver.com/acquirelicense", "req_headers": urlencode(license_headers)} } } listitem.setProperty('inputstream.adaptive.drm', json.dumps(drm_cfg)) xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=listitem) ``` ### Response N/A (Resolved URL for playback. ``` -------------------------------- ### Parse WebM file with basic parser Source: https://github.com/xbmc/inputstream.adaptive/blob/Piers/lib/webm_parser/README.md A minimal example demonstrating how to initialize a WebM parser and feed it data from standard input using the FileReader class. ```cpp #include #include #include int main() { video_webm_parser::Callback callback; video_webm_parser::FileReader reader(std::freopen(nullptr, "rb", stdin)); video_webm_parser::WebmParser parser; parser.Feed(&callback, &reader); } ``` -------------------------------- ### DRM STRM File Examples for inputstream.adaptive Source: https://context7.com/xbmc/inputstream.adaptive/llms.txt These examples show complete STRM file configurations for playing DRM-protected content with inputstream.adaptive. They demonstrate both legacy and modern JSON-based DRM configuration methods, including Widevine. ```strm #KODIPROP:inputstream=inputstream.adaptive #KODIPROP:inputstream.adaptive.drm_legacy=com.widevine.alpha|https://license.server.com/acquire|User-Agent=Mozilla%2F5.0 #KODIPROP:mimetype=application/dash+xml https://www.videoservice.com/manifest.mpd ``` ```strm #KODIPROP:inputstream=inputstream.adaptive #KODIPROP:inputstream.adaptive.drm={"com.widevine.alpha":{"license":{"server_url":"https://license.server.com/acquire"}}} #KODIPROP:mimetype=application/dash+xml https://www.videoservice.com/manifest.mpd ``` -------------------------------- ### DASH + Widevine Example (STRM/M3U8) Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Example of how to play an encrypted DASH video stream using Widevine DRM with inputstream.adaptive when using playlist files like STRM or M3U8. ```APIDOC ## DASH + Widevine Example (STRM/M3U8) ### Description This example shows how to configure `inputstream.adaptive` for encrypted DASH streams using Widevine DRM when the stream is referenced in a playlist file (e.g., STRM or M3U8). Configuration is done using `#KODIPROP` directives within the playlist file. ### Method N/A (Configuration via `#KODIPROP` directives) ### Endpoint N/A ### Parameters #### Properties (via `#KODIPROP`) - **inputstream** (string) - Set to `'inputstream.adaptive'`. - **inputstream.adaptive.drm_legacy** (string) - Legacy format for DRM configuration. Example: `'com.widevine.alpha|https://www.licenseserver.com/acquirelicense|User-Agent=Mozilla%2F5.0...'` - **inputstream.adaptive.drm** (string) - JSON string for DRM configuration. Example: `'{"com.widevine.alpha":{"license": {"server_url": "https://www.licenseserver.com/acquirelicense","req_headers": "User-Agent=..."}}}'` - **mimetype** (string) - Set to `'application/dash+xml'` for DASH streams. ### Request Example ``` #KODIPROP:inputstream=inputstream.adaptive # Example configuration with drm_legacy property #KODIPROP:inputstream.adaptive.drm_legacy=com.widevine.alpha|https://www.licenseserver.com/acquirelicense|User-Agent=Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F106.0.0.0+Safari%2F537.36 # Example configuration with drm property #KODIPROP:inputstream.adaptive.drm={"com.widevine.alpha":{"license": {"server_url": "https://www.licenseserver.com/acquirelicense","req_headers": "User-Agent=Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F106.0.0.0+Safari%2F537.36"}}} #KODIPROP:mimetype=application/dash+xml https://www.videoservice.com/manifest.mpd ``` ### Response N/A (Stream playback initiated by Kodi. ``` -------------------------------- ### Set Add-on Configuration Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Sets miscellaneous add-on configurations using a JSON dictionary, such as cookie handling, SSL verification, and resolution limits. ```python listitem.setProperty('inputstream.adaptive.config', '{"internal_cookies": true, "resolution_limit": "1280x720"}') ``` -------------------------------- ### HLS + AES-128 Example (Python) Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Example of how to play an encrypted HLS video stream using AES-128 encryption with inputstream.adaptive in a Python script for Kodi add-ons. Custom headers or parameters for key requests can be added if needed. ```APIDOC ## HLS + AES-128 Example (Python) ### Description This example demonstrates how to configure `inputstream.adaptive` to play an encrypted HLS video stream using AES-128 encryption within a Kodi add-on using Python. For AES-128, `inputstream.adaptive.drm` or `inputstream.adaptive.drm_legacy` are usually not required unless custom headers or parameters need to be added to the HTTP key request. ### Method N/A (Configuration via `xbmcgui.ListItem` properties) ### Endpoint N/A ### Parameters #### Properties - **inputstream** (string) - Set to `'inputstream.adaptive'` to enable the adaptive inputstream. - **mimeType** (string) - Set to `'application/vnd.apple.mpegurl'` for HLS streams. - **ContentLookup** (boolean) - Set to `False` to prevent Kodi from performing an HTTP HEAD request to determine the MIME type. - **inputstream.adaptive.drm** (string) - JSON string for configuring DRM. Not typically needed for standard AES-128, but can be used to add custom headers or parameters to the HLS HTTP key request. - **inputstream.adaptive.drm_legacy** (string) - Legacy format for configuring DRM. Not typically needed for standard AES-128. ### Request Example ```python import xbmcgui import xbmcplugin listitem = xbmcgui.ListItem(path='https://www.videoservice.com/master_manifest.m3u8', offscreen=True) # Prevent Kodi core from determining mimetype via HTTP HEAD request listitem.setMimeType('application/vnd.apple.mpegurl') listitem.setContentLookup(False) listitem.setProperty('inputstream', 'inputstream.adaptive') # Usually there is no need to set inputstream.adaptive.drm or inputstream.adaptive.drm_legacy # but, if you need to add custom headers or parameters to the HLS HTTP key request's # listitem.setProperty('inputstream.adaptive.drm', '{"custom_param": "value"}') xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=listitem) ``` ### Response N/A (Resolved URL for playback. ``` -------------------------------- ### Python HTTP Server for Inputstream Adaptive Manifest and License Source: https://github.com/xbmc/inputstream.adaptive/wiki/How-to-provide-custom-manifest-and-license This Python code implements a basic HTTP server using `http.server` to handle manifest and license requests for Inputstream Adaptive. It supports both Python 2 and 3. The server listens for GET requests to '/manifest' and POST requests to '/license', sending appropriate responses. It requires the `content-type` header to be set for manifest responses. ```python try: from http.server import BaseHTTPRequestHandler except ImportError: from BaseHTTPServer import BaseHTTPRequestHandler try: from socketserver import TCPServer except ImportError: from SocketServer import TCPServer try: from urllib.parse import unquote except ImportError: from urllib import unquote class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): def do_GET(self): """Handle http get requests, used for manifest""" path = self.path print('HTTP GET Request received to {}'.format(path)) if '/manifest' not in path: self.send_response(404) self.end_headers() return try: manifest_data = b'my manifest data' self.send_response(200) self.send_header('content-type', 'application/dash+xml') self.end_headers() self.wfile.write(manifest_data) except Exception: self.send_response(500) self.end_headers() def do_POST(self): """Handle http post requests, used for license""" path = self.path print('HTTP POST Request received to {}'.format(path)) if '/license' not in path: self.send_response(404) self.end_headers() return try: length = int(self.headers.get('content-length', 0)) isa_data = self.rfile.read(length).decode('utf-8').split('!') challenge = isa_data[0] session_id = isa_data[1] license_data = b'my license data' self.send_response(200) self.end_headers() self.wfile.write(license_data) except Exception: self.send_response(500) self.end_headers() address = '127.0.0.1' port = 6969 server_inst = TCPServer((address, port), SimpleHTTPRequestHandler) server_inst.serve_forever() ``` -------------------------------- ### Build and Installation Options for Googletest/Googlemock Source: https://github.com/xbmc/inputstream.adaptive/blob/Piers/depends/common/googletest/CMakeLists.txt Enables testing and includes CMake modules for dependent options and installation directories. It provides options to control the building of googlemock and the installation of googletest, which is useful for projects embedding googletest. ```cmake enable_testing() include(CMakeDependentOption) include(GNUInstallDirs) #Note that googlemock target already builds googletest option(BUILD_GMOCK "Builds the googlemock subproject" ON) option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON) if(BUILD_GMOCK) add_subdirectory( googlemock ) else() add_subdirectory( googletest ) endif() ``` -------------------------------- ### Customize License Request Data (str, Python Example) Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Provides custom data for the license request, typically Base64 encoded. Allows injecting various challenge and session data using placeholders. This example shows constructing JSON data with injected challenge and session ID. ```python import json import base64 drm_configs = { "...": { "license": { "req_data": base64.b64encode(json.dumps({"movie_id": "123456", "challenge_base64": "{CHA-B64}", "SID": "{SID-B64}"}).encode("utf-8")).decode("utf-8"), "...": "..." } } } ``` -------------------------------- ### Play unencrypted video stream via STRM file Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Demonstrates how to configure a .strm file with KODIPROP headers to instruct Kodi to use inputstream.adaptive for stream playback. ```text #KODIPROP:inputstream=inputstream.adaptive #KODIPROP:inputstream.adaptive.manifest_type=mpd #KODIPROP:mimetype=application/dash+xml https://www.videoservice.com/manifest.mpd ``` -------------------------------- ### Get Kodi Stacktrace Log with GDB on Linux Source: https://github.com/xbmc/inputstream.adaptive/wiki/Dev.-FAQ This guide explains how to obtain a stacktrace log of a Kodi crash on Linux using the GDB debugger. It involves installing GDB, running Kodi under GDB, triggering a crash, and then using GDB commands to generate the stacktrace. ```bash sudo apt-get install gdb gdb /usr/lib/kodi/kodi.bin bt bt > stacktrace.txt ``` -------------------------------- ### Set manifest and stream parameters Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Configures HTTP parameters for downloading manifests or media streams. Used to pass custom query parameters to the server. ```python listitem.setProperty('inputstream.adaptive.stream_params', 'paramname=value¶mname2=value2') ``` -------------------------------- ### Force HTTP GET for License Request (bool) Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Forces the license request to use HTTP GET instead of the default HTTP POST. Supported for Widevine, Playready, and Wiseplay. ```json { "license": { "use_http_get_request": true } } ``` -------------------------------- ### Set manifest update parameters Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Configures parameters for manifest updates in LIVE content. Used to append query strings to update requests. ```python listitem.setProperty('inputstream.adaptive.manifest_update_parameter', '?foo=bar&baz=qux') listitem.setProperty('inputstream.adaptive.manifest_upd_params', '?foo=bar&baz=qux') ``` -------------------------------- ### Set manifest-specific HTTP headers Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Specifies HTTP headers exclusively for manifest download requests. Useful for passing custom cookies or user agents. ```python listitem.setProperty('inputstream.adaptive.manifest_headers', 'headername=encoded_value&User-Agent=the_user_agent&cookie=the_cookies') ``` -------------------------------- ### Playback Control Settings Source: https://context7.com/xbmc/inputstream.adaptive/llms.txt Configures specific playback behaviors including starting live streams from the beginning of the buffer and setting the original audio language for track selection. ```python # Start live stream from beginning of timeshift buffer listitem.setProperty('inputstream.adaptive.play_timeshift_buffer', 'true') # Set original audio language using ISO 639-1 codes listitem.setProperty('inputstream.adaptive.original_audio_language', 'en') ``` -------------------------------- ### Configure ListItem for License URL in ISAdaptive Source: https://github.com/xbmc/inputstream.adaptive/wiki/How-to-provide-custom-manifest-and-license Sets the license URL for ISAdaptive. This URL points to your HTTP proxy server. The request type is POST. It's recommended to include your add-on name in the path for identification. ```python listitem.setProperty('inputstream.adaptive.license_key', lic_url) # Example: lic_url = "http://127.0.0.1:{port}/addon_name/license?id=234324" ``` -------------------------------- ### Customize DASH Manifest for Audio Properties Source: https://context7.com/xbmc/inputstream.adaptive/llms.txt These XML examples show how to modify DASH manifests to define audio track properties. They illustrate setting tracks as original language, default, or for hearing-impaired users, influencing how media players handle audio streams. ```xml audio_en.mp4 audio_en_ad.mp4 ``` -------------------------------- ### Define SPDX License File Structure Source: https://github.com/xbmc/inputstream.adaptive/blob/Piers/LICENSES/README.md This template demonstrates the required format for license files in the LICENSES subdirectory. It includes the SPDX identifier, URL, usage guide, and the full license text to ensure compliance with tool verification standards like ScanCode. ```text Valid-License-Identifier: GPL-2.0-or-later SPDX-URL: https://spdx.org/licenses/GPL-2.0-or-later Usage-Guide: To use the GNU General Public License v2.0 or later put the following SPDX tag/value pair into a comment according to the placement guidelines in the licensing rules documentation: SPDX-License-Identifier: GPL-2.0-or-later License-Text: Full license text ``` -------------------------------- ### Configure Secure Decoder Control in DASH Manifest Source: https://context7.com/xbmc/inputstream.adaptive/llms.txt This XML example illustrates how to enforce secure decoder settings within a DASH manifest using the ContentProtection element. It specifies Widevine robustness levels, ensuring that protected content is only played by secure hardware decoders. ```xml ... video_1080p.mp4 ``` -------------------------------- ### Enable timeshift buffer playback using inputstream.adaptive.play_timeshift_buffer Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Configures the player to start a live stream from the beginning of the available buffer rather than the live edge. This is particularly useful for sports content. ```python listitem.setProperty('inputstream.adaptive.play_timeshift_buffer', 'true') ``` -------------------------------- ### Configure ListItem for Manifest URL in ISAdaptive Source: https://github.com/xbmc/inputstream.adaptive/wiki/How-to-provide-custom-manifest-and-license Sets the manifest URL for ISAdaptive. This URL points to your HTTP proxy server. The request type is GET. It's recommended to include your add-on name in the path for identification. ```python listitem = xbmcgui.ListItem(path=mpd_url) # Example: mpd_url = "http://127.0.0.1:{port}/addon_name/manifest?id=234324" ``` -------------------------------- ### Build InputStream Adaptive on Linux using CMake Source: https://github.com/xbmc/inputstream.adaptive/wiki/How-to-build Configures and builds the InputStream Adaptive binary add-on using CMake. This process assumes the Kodi source and add-on source are cloned into the local directory. ```bash cmake -DADDONS_TO_BUILD=inputstream.adaptive -DADDON_SRC_PREFIX=../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../xbmc/addons -DPACKAGE_ZIP=1 ../../xbmc/cmake/addons ``` -------------------------------- ### Configure Built-in License Wrappers and Unwrappers Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Demonstrates how to configure DRM settings for a service requiring JSON-wrapped Base64 license requests and nested JSON-wrapped Base64 responses. It utilizes the wrapper/unwrapper flags to define the processing pipeline for license data. ```python import json import base64 lic_req_data = json.dumps({"challenge_base64": "{CHA-B64}"}).encode("utf-8") drm_configs = { "com.widevine.alpha": { "license": { "server_url": "https://theserverurl.com", "req_data": base64.b64encode(lic_req_data).decode("utf-8"), "wrapper": "base64", "unwrapper": "base64,json,base64", "unwrapper_params": {"path_data": "licenseresponse/data"} } } } ``` -------------------------------- ### Optional Key Request Parameters Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Configure specific initialization parameters for the Common Data Model (CDM) during key requests. This is particularly useful for PlayReady DRM, allowing you to set custom data for the `PRCustomData` parameter. ```APIDOC ## Optional Key Request Parameters ### Description Allows configuration of specific initialization parameters for the Common Data Model (CDM) that are typically used for key requests. This is closely related to the type of CDM being used. ### Method N/A (Configuration via properties) ### Endpoint N/A (Configuration via properties) ### Parameters #### Properties - **optional_key_req_params** (dict) - Optional - A dictionary containing custom parameters for the key request. - **custom_data** (string) - Required for PlayReady DRM - Allows setting data for the `PRCustomData` CDM parameter to make the key request. ### Request Example ```json { "optional_key_req_params": { "custom_data": "the data" } } ``` ### Response N/A (Configuration via properties) ``` -------------------------------- ### Configure Multiple DRMs with Priority Source: https://context7.com/xbmc/inputstream.adaptive/llms.txt Sets up multiple Digital Rights Management (DRM) systems with a priority order for automatic selection. This allows the system to attempt to use a preferred DRM (e.g., Widevine) first and fall back to another (e.g., PlayReady) if the first is not supported. The 'priority' key determines the order of selection. ```python import xbmcgui import xbmcplugin import json listitem = xbmcgui.ListItem(path='https://www.videoservice.com/manifest.mpd', offscreen=True) listitem.setMimeType('application/dash+xml') listitem.setContentLookup(False) listitem.setProperty('inputstream', 'inputstream.adaptive') drm_config = { "com.widevine.alpha": { "priority": 1, # Higher priority (selected first if supported) "license": { "server_url": "https://license.server.com/widevine" } }, "com.microsoft.playready": { "priority": 2, # Lower priority (fallback) "license": { "server_url": "https://license.server.com/playready" } } } listitem.setProperty('inputstream.adaptive.drm', json.dumps(drm_config)) xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=listitem) ``` -------------------------------- ### Configure Legacy DRM with Base64 License URI Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Sets the 'inputstream.adaptive.drm_legacy' property using a data scheme. This method is useful for simple ClearKey configurations where the license is provided as a base64 encoded JSON string. ```python listitem.setProperty('inputstream.adaptive.drm_legacy', 'org.w3.clearkey|data:application/json;base64,CK_LICENSE_AS_BASE64') ``` -------------------------------- ### Implement Encrypted SmoothStreaming/PlayReady Playback Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Configuring Kodi ListItem for PlayReady-encrypted SmoothStreaming content. Demonstrates setting the appropriate mime-type and applying the DRM property for the PlayReady CDM. ```python listitem = xbmcgui.ListItem(path='https://www.videoservice.com/tearsofsteel_4k.ism/manifest', offscreen=True) listitem.setMimeType('application/vnd.ms-sstr+xml') listitem.setContentLookup(False) listitem.setProperty('inputstream', 'inputstream.adaptive') listitem.setProperty('inputstream.adaptive.drm', '{"com.microsoft.playready": {}}') xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=listitem) ``` -------------------------------- ### Set Original Audio Language Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Sets the Kodi 'original audio language' flag for streams matching the specified ISO 639-1 language code. ```python listitem.setProperty('inputstream.adaptive.original_audio_language', 'it') ``` -------------------------------- ### Automated Android Build Script for InputStream Adaptive Source: https://github.com/xbmc/inputstream.adaptive/wiki/How-to-build A bash script to automate the cross-compilation of InputStream Adaptive for Android. It handles toolchain configuration, bootstrap, and building the add-on within the Kodi dependency structure. ```bash #!/bin/sh HOST_ARCH="aarch64-linux-android" NDK_VER="28.2.13676358" NDK_API=24 ANDROID_SDK_ROOT="${HOME}/android-tools/android-sdk-linux" KODI_SRC_PATH="${HOME}/dev/xbmc" ISA_SRC_PARENT_PATH="${HOME}/dev" BUILD_TYPE="Debug" ADDON_ID="inputstream.adaptive" cd $KODI_SRC_PATH/tools/depends ./bootstrap CONFIGURE_EXTRA_OPTIONS="--with-ndk-api=${NDK_API} --with-sdk-path=${ANDROID_SDK_ROOT} --with-ndk-path=${ANDROID_SDK_ROOT}/ndk/${NDK_VER}" ./configure --host=${HOST_ARCH} --prefix=$KODI_SRC_PATH/xbmc-depends $CONFIGURE_EXTRA_OPTIONS make -j$(getconf _NPROCESSORS_ONLN) cd $KODI_SRC_PATH make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons ADDONS=$ADDON_ID ADDON_SRC_PREFIX=${ISA_SRC_PARENT_PATH} INSTALL_PREFIX=${KODI_SRC_PATH}/addons EXTRA_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" ``` -------------------------------- ### Set Maximum Stream Bandwidth Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Sets the maximum allowed stream bandwidth in bit/s. This value can override user settings if it is lower than the configured maximum. ```python listitem.setProperty('inputstream.adaptive.max_bandwidth', '100000000000') ``` -------------------------------- ### Test Streams with STRM Files Source: https://context7.com/xbmc/inputstream.adaptive/llms.txt Demonstrates how to create STRM playlist files to test adaptive streams without direct add-on development. These files use `#KODIPROP:` prefixes for configuration. ```strm #KODIPROP:inputstream=inputstream.adaptive #KODIPROP:mimetype=application/dash+xml https://www.videoservice.com/manifest.mpd ``` ```strm #KODIPROP:inputstream=inputstream.adaptive #KODIPROP:mimetype=application/vnd.apple.mpegurl https://www.videoservice.com/master.m3u8 ``` -------------------------------- ### Set common HTTP headers for InputStream Adaptive Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Configures global HTTP headers for all requests. Values should be URL encoded to maintain string integrity. ```python listitem.setProperty('inputstream.adaptive.common_headers', 'headername=encoded_value&User-Agent=the_user_agent&cookie=the_cookies') ``` -------------------------------- ### Configure DRM Session and CDM Parameters Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Settings for controlling DRM session behavior and initializing Content Decryption Module (CDM) parameters. Use force_single_session to optimize multi-key requests and optional_key_req_params for custom CDM initialization data. ```json "force_single_session": True "optional_key_req_params": {"custom_data": "the data"} ``` -------------------------------- ### Configure Encrypted Video Playback with 'none' Key System Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM This snippet demonstrates how to configure inputstream.adaptive for encrypted video playback when the key system is 'none'. It involves setting up custom request headers and parameters for the license server. This is typically used for HLS AES-128 encryption. ```python encrypt_cfg = {"none":{"license": {"req_headers": "User-Agent=Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F106.0.0.0+Safari%2F537.36", "req_params": "/example/param"}}} listitem.setProperty('inputstream.adaptive.drm', json.dumps(encrypt_cfg)) ``` -------------------------------- ### Set Live Stream Delay Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Configures a delay from the live edge for live content to prevent segment request errors. The value must be at least 16 seconds. ```python listitem.setProperty('inputstream.adaptive.live_delay', '16') ``` -------------------------------- ### Set inputstream property for different Kodi versions Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Sets the required property to trigger the inputstream.adaptive add-on, with specific keys for Kodi 18 versus Kodi 19 and above. ```python # For Kodi 19.x and above: listitem.setProperty('inputstream', 'inputstream.adaptive') # For Kodi 18.x: listitem.setProperty('inputstreamaddon', 'inputstream.adaptive') ``` -------------------------------- ### Configure Widevine DRM for Kodi Source: https://context7.com/xbmc/inputstream.adaptive/llms.txt Demonstrates how to set up Widevine DRM using both the legacy property format and the advanced JSON configuration. These methods require a license server URL and optional request headers. ```python import xbmcgui import xbmcplugin from urllib.parse import urlencode import json # Legacy method (Kodi 21+) listitem.setProperty('inputstream.adaptive.drm_legacy', 'com.widevine.alpha|https://license.server.com/acquire|' + urlencode(license_headers)) # Advanced method (Kodi 22+) drm_config = { "com.widevine.alpha": { "license": { "server_url": "https://license.server.com/acquire", "req_headers": urlencode(license_headers) } } } listitem.setProperty('inputstream.adaptive.drm', json.dumps(drm_config)) ``` -------------------------------- ### Configure DASH + ClearKey for Encrypted Video Streams Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM This Python code configures inputstream.adaptive to play encrypted DASH video streams using the ClearKey DRM system. It shows how to set the MIME type, disable content lookup, and specify ClearKey configuration, either by providing key IDs and keys, a license server URL, or by relying on a manifest-embedded URL. ```python listitem = xbmcgui.ListItem(path='https://www.videoservice.com/manifest.mpd', offscreen=True) # These two lines are needed to prevent the HTTP HEAD request from Kodi core, used to determine the mimetype listitem.setMimeType('application/dash+xml') listitem.setContentLookup(False) listitem.setProperty('inputstream', 'inputstream.adaptive') # To provide clear keys, use: drm_cfg = {"org.w3.clearkey": {"license": {"keyids": { "KID_1": "KEY_1", "KID_2": "KEY_2" }} } } # To set a license server url, use: drm_cfg = {"org.w3.clearkey": {"license": {"server_url": "https://www.licenseserver.com/AcquireLicense/"} } } # If the manifest embed the license server url, you can leave empty: drm_cfg = {"org.w3.clearkey": {} } listitem.setProperty('inputstream.adaptive.drm', json.dumps(drm_cfg)) xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=listitem) ``` -------------------------------- ### Set manifest type for InputStream Adaptive Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Specifies the manifest type (mpd, hls, ism) for the media stream. Note that this property is deprecated in Kodi v21 and removed in v22 as auto-detection is now preferred. ```python listitem.setProperty('inputstream.adaptive.manifest_type', 'mpd') ``` -------------------------------- ### Implement Custom Manifest Proxy Source: https://context7.com/xbmc/inputstream.adaptive/llms.txt Sets up a local HTTP proxy server to intercept and manipulate manifest requests or handle license acquisition. This is useful for complex DRM workflows or dynamic manifest generation. ```python from http.server import BaseHTTPRequestHandler from socketserver import TCPServer class ProxyHandler(BaseHTTPRequestHandler): def do_GET(self): if '/manifest' not in self.path: return self.send_response(200) self.send_header('content-type', 'application/dash+xml') self.end_headers() self.wfile.write(b'...') server = TCPServer(('127.0.0.1', 0), ProxyHandler) port = server.server_address[1] listitem.setProperty('inputstream', 'inputstream.adaptive') listitem = xbmcgui.ListItem(path=f'http://127.0.0.1:{port}/myaddon/manifest?id=12345') ``` -------------------------------- ### Set Custom Initialization Data (PSSH Box) Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM This allows providing custom initialization data (PSSH box) to initialize CDM sessions, replacing any provided in the manifest. Accepted values are a standard PSSH box or a Widevine PSSH encoded as base64. Placeholders like {KID} and {UUID} can be used for Widevine PSSH. ```json "init_data": "base64 data" ``` -------------------------------- ### Configure manifest behaviors using inputstream.adaptive.manifest_config Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Sets various manifest processing parameters such as timeshift limits, HLS fixes, and DASH synchronization. The input must be a JSON-formatted string passed as a property to the listitem. ```python import json config = { "timeshift_bufferlimit": 14400, "hls_ignore_endlist": True } listitem.setProperty('inputstream.adaptive.manifest_config', json.dumps(config)) ``` -------------------------------- ### Play unencrypted video stream in Python Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration Configures a Kodi ListItem to use inputstream.adaptive for playing a DASH manifest. It sets the required MIME type, disables content lookup, and specifies the manifest type. ```python listitem = xbmcgui.ListItem(path='https://www.videoservice.com/manifest.mpd', offscreen=True) # These two lines are needed to prevent the HTTP HEAD request from Kodi core, used to determine the mimetype listitem.setMimeType('application/dash+xml') listitem.setContentLookup(False) listitem.setProperty('inputstream', 'inputstream.adaptive') listitem.setProperty('inputstream.adaptive.manifest_type', 'mpd') # Deprecated on Kodi 21, removed on Kodi 22 xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=listitem) ``` -------------------------------- ### Set License Request Parameters (str) Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Appends URL parameters to the license request URL. ```json { "license": { "req_params": "/one/two/three-path" } } ``` -------------------------------- ### Configure DRM Legacy with Python (Kodi) Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Sets the 'inputstream.adaptive.drm_legacy' property to configure DRM settings for adaptive streaming. This method is suitable for providers not requiring advanced configurations. It supports Widevine, PlayReady, and ClearKey DRM systems. ```python # Example for Widevine: listitem.setProperty('inputstream.adaptive.drm_legacy', 'com.widevine.alpha|https://license.server.com/licenserequest|User-Agent=Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F106.0.0.0+Safari%2F537.36') # Constructed string example (recommended) license_headers = { 'Content-Type': 'application/octet-stream', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0', } from urllib.parse import urlencode drm_config = { # Keeping items in order 'DRM KeySystem': 'com.widevine.alpha', 'License server url': 'https://license.server.com/licenserequest', 'License headers': urlencode(license_headers) } listitem.setProperty('inputstream.adaptive.drm_legacy', '|'.join(drm_config.values())) # Example for PlayReady: listitem.setProperty('inputstream.adaptive.drm_legacy', 'com.microsoft.playready|https://www.licenseserver.com/AcquireLicense/') # Example for ClearKey: # KeyId's provided by manifest: listitem.setProperty('inputstream.adaptive.drm_legacy', 'org.w3.clearkey') # KeyId's provided by property: listitem.setProperty('inputstream.adaptive.drm_legacy', 'org.w3.clearkey|000102030405060708090a0b0c0d0e0f:00112233445566778899aabbccddeeff') # License URL provided by property: (supported from v21.5.3) listitem.setProperty('inputstream.adaptive.drm_legacy', 'org.w3.clearkey|https://www.licenseserver.com/AcquireLicense/') ``` -------------------------------- ### Define HDCP version in DASH MPD manifest Source: https://github.com/xbmc/inputstream.adaptive/wiki/HDCP-resolution-limit Example of adding the 'hdcp' attribute to the Representation tag in a DASH MPD manifest. The value represents the version as a concatenated number (e.g., '14' for HDCP 1.4). ```xml ... ... ... ``` -------------------------------- ### Handle License Response Data Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM This snippet shows how to define expected license response data, which will be unwrapped by the configuration. It's useful for debugging and verifying data transfer. ```python response_data = "eyJsaWNlbnNlcmVzcG9uc2UiOiB7ImRhdGEiOiAiZEdocGN5QnBjeUJ5WVhjZ1pHRjBZUT09In19Cg==" ``` -------------------------------- ### Implement HLS/AES-128 Playback Source: https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM Configuring Kodi ListItem for HLS streams using AES-128 encryption. Typically requires minimal DRM configuration unless custom headers are needed for key requests. ```python listitem = xbmcgui.ListItem(path='https://www.videoservice.com/master_manifest.m3u8', offscreen=True) listitem.setMimeType('application/vnd.apple.mpegurl') listitem.setContentLookup(False) listitem.setProperty('inputstream', 'inputstream.adaptive') ```