Shaka Packager Library (Continued)

struct shaka::PackagingParams

Packaging parameters.

Public Members

std::string temp_dir

Specify temporary directory for intermediate temporary files.

Mp4OutputParams mp4_output_params

MP4 (ISO-BMFF) output related parameters.

uint32_t transport_stream_timestamp_offset_ms = 0

The offset to be applied to transport stream (e.g. MPEG2-TS, HLS packed audio) timestamps to compensate for possible negative timestamps in the input.

ChunkingParams chunking_params

Chunking (segmentation) related parameters.

AdCueGeneratorParams ad_cue_generator_params

Out of band cuepoint parameters.

bool output_media_info = false

Create a human readable format of MediaInfo. The output file name will be the name specified by output flag, suffixed with .media_info.

bool single_threaded = false

Only use a single thread to generate output. This is useful in tests to avoid non-deterministic outputs.

MpdParams mpd_params

DASH MPD related parameters.

HlsParams hls_params

HLS related parameters.

EncryptionParams encryption_params

Encryption and Decryption Parameters.

BufferCallbackParams buffer_callback_params

Buffer callback params.

struct shaka::StreamDescriptor

Defines a single input/output stream.

Public Members

std::string input

Input/source media file path or network stream URL. Required.

std::string stream_selector

Stream selector, can be audio, video, text or a zero based stream index. Required.

std::string output

Specifies output file path or init segment path (if segment template is specified). Can be empty for self initialization media segments.

std::string segment_template

Specifies segment template. Can be empty.

std::string output_format

Optional value which specifies output container format, e.g. “mp4”. If not specified, will detect from output / segment template name.

bool skip_encryption = false

If set to true, the stream will not be encrypted. This is useful, e.g. to encrypt only video streams.

std::string drm_label

Specifies a custom DRM stream label, which can be a DRM label defined by the DRM system. Typically values include AUDIO, SD, HD, UHD1, UHD2. If not provided, the DRM stream label is derived from stream type (video, audio), resolutions etc.

uint32_t trick_play_factor = 0

If set to a non-zero value, will generate a trick play / trick mode stream with frames sampled from the key frames in the original stream. trick_play_factor defines the sampling rate.

uint32_t bandwidth = 0

Optional user-specified content bit rate for the stream, in bits/sec. If specified, this value is propagated to the $Bandwidth$ template parameter for segment names. If not specified, its value may be estimated.

std::string language

Optional value which contains a user-specified language tag. If specified, this value overrides any language metadata in the input stream.

int32_t cc_index = -1

Optional value for the index of the sub-stream to use. For some text formats, there are multiple “channels” in a single stream. This allows selecting only one channel.

std::string hls_name

Required for audio when outputting HLS. It defines the name of the output stream, which is not necessarily the same as output. This is used as the NAME attribute for EXT-X-MEDIA.

std::string hls_group_id

Required for audio when outputting HLS. It defines the group ID for the output stream. This is used as the GROUP-ID attribute for EXT-X-MEDIA.

std::string hls_playlist_name

Required for HLS output. It defines the name of the playlist for the stream. Usually ends with .m3u8.

std::string hls_iframe_playlist_name

Optional for HLS output. It defines the name of the I-Frames only playlist for the stream. For Video only. Usually ends with .m3u8.

std::vector<std::string> hls_characteristics

Optional for HLS output. It defines the CHARACTERISTICS attribute of the stream.

std::vector<std::string> dash_accessiblities

Optional for DASH output. It defines Accessibility elements of the stream.

std::vector<std::string> dash_roles

Optional for DASH output. It defines Role elements of the stream.

bool dash_only = false

Set to true to indicate that the stream is for dash only.

bool hls_only = false

Set to true to indicate that the stream is for hls only.

struct shaka::Mp4OutputParams

MP4 (ISO-BMFF) output related parameters.

Public Members

bool include_pssh_in_stream = true

Include pssh in the encrypted stream. CMAF and DASH-IF recommends carrying license acquisition information in the manifest and not duplicate the information in the stream. (This is not a hard requirement so we are still CMAF compatible even if pssh is included in the stream.)

bool generate_sidx_in_media_segments = true

Indicates whether a ‘sidx’ box should be generated in the media segments. Note that it is required by spec if segment_template contains $Times$ specifier.

struct shaka::ChunkingParams

Chunking (segmentation) related parameters.

Public Members

double segment_duration_in_seconds = 0

Segment duration in seconds.

double subsegment_duration_in_seconds = 0

Subsegment duration in seconds. Should not be larger than the segment duration.

bool segment_sap_aligned = true

Force segments to begin with stream access points. Actual segment duration may not be exactly what is specified by segment_duration.

bool subsegment_sap_aligned = true

Force subsegments to begin with stream access points. Actual subsegment duration may not be exactly what is specified by subsegment_duration. Setting to subsegment_sap_aligned to true but segment_sap_aligned to false is not allowed.

struct shaka::MpdParams

DASH MPD related parameters.

Public Members

std::string mpd_output

MPD output file path.

std::vector<std::string> base_urls

BaseURLs for the MPD. The values will be added as <BaseURL> element(s) under the <MPD> element.

double min_buffer_time = 2.0

Set MPD@minBufferTime attribute, which specifies, in seconds, a common duration used in the definition of the MPD representation data rate. A client can be assured of having enough data for continous playout providing playout begins at min_buffer_time after the first bit is received.

double minimum_update_period = 0

Set MPD@minimumUpdatePeriod attribute, which indicates to the player how often to refresh the MPD in seconds. For dynamic MPD only.

double time_shift_buffer_depth = 0

Set MPD@timeShiftBufferDepth attribute, which is the guaranteed duration of the time shifting buffer for ‘dynamic’ media presentations, in seconds.

size_t preserved_segments_outside_live_window = 0

Segments outside the live window (defined by ‘time_shift_buffer_depth’ above) are automatically removed except for the most recent X segments defined by this parameter. This is needed to accommodate latencies in various stages of content serving pipeline, so that the segments stay accessible as they may still be accessed by the player. The segments are not removed if the value is zero.

std::string default_language

The tracks tagged with this language will have <Role … value=”main” /> in the manifest. This allows the player to choose the correct default language for the content. This applies to both audio and text tracks. The default language for text tracks can be overriden by ‘default_text_language’.

std::string default_text_language

Same as above, but this overrides the default language for text tracks, i.e. subtitles or close-captions.

bool generate_static_live_mpd = false

Generate static MPD for live profile. Note that this flag has no effect for on-demand profile, in which case static MPD is always used.

bool generate_dash_if_iop_compliant_mpd = true

Try to generate DASH-IF IOP compliant MPD.

bool allow_approximate_segment_timeline = false

For live profile only. If enabled, segments with close duration (i.e. with difference less than one sample) are considered to have the same duration. This enables MPD generator to generate less SegmentTimeline entries. If all segments are of the same duration except the last one, we will do further optimization to use SegmentTemplate@duration instead and omit SegmentTimeline completely. Ignored if $Time$ is used in segment template, since $Time$ requires accurate Segment Timeline.

double target_segment_duration = 0

This is the target segment duration requested by the user. The actual segment duration may be different to the target segment duration. This parameter is included here to calculate the approximate SegmentTimeline if it is enabled. It will be populated from segment duration specified in ChunkingParams if not specified.

bool allow_codec_switching = false

If enabled, allow switching between different codecs, if they have the same language, media type (audio, video etc) and container type.

bool include_mspr_pro = true

If enabled, PlayReady Object <mspr:pro> will be inserted into <ContentProtection …> element alongside with <cenc:pssh> when using PlayReady protection system.

bool use_segment_list = false

Uses SegmentList instead of SegmentBase. Use this if the content is huge and the total number of (sub)segment references is greater than what the sidx atom allows (65535).

Public Static Attributes

static constexpr double kSuggestedPresentationDelayNotSet = 0

Set MPD@suggestedPresentationDelay attribute. For ‘dynamic’ media presentations, it specifies a delay, in seconds, to be added to the media presentation time. The attribute is not set if the value is 0; the client is expected to choose a suitable value in this case.

struct UtcTiming

UTCTimings. For dynamic MPD only.

struct shaka::HlsParams

HLS related parameters.

Public Members

HlsPlaylistType playlist_type = HlsPlaylistType::kVod

HLS playlist type. See HLS specification for details.

std::string master_playlist_output

HLS master playlist output path.

std::string base_url

The base URL for the Media Playlists and media files listed in the playlists. This is the prefix for the files.

double time_shift_buffer_depth = 0

Defines the live window, or the guaranteed duration of the time shifting buffer for ‘live’ playlists.

size_t preserved_segments_outside_live_window = 0

Segments outside the live window (defined by ‘time_shift_buffer_depth’ above) are automatically removed except for the most recent X segments defined by this parameter. This is needed to accommodate latencies in various stages of content serving pipeline, so that the segments stay accessible as they may still be accessed by the player. The segments are not removed if the value is zero.

std::string key_uri

Defines the key uri for “identity” and “com.apple.streamingkeydelivery” key formats. Ignored if the playlist is not encrypted or not using the above key formats.

std::string default_language

The renditions tagged with this language will have ‘DEFAULT’ set to ‘YES’ in ‘EXT-X-MEDIA’ tag. This allows the player to choose the correct default language for the content. This applies to both audio and text tracks. The default language for text tracks can be overriden by ‘default_text_language’.

std::string default_text_language

Same as above, but this overrides the default language for text tracks, i.e. subtitles or close-captions.

double target_segment_duration = 0

This is the target segment duration requested by the user. The actual segment duration may be different to the target segment duration. It will be populated from segment duration specified in ChunkingParams if not specified.

uint32_t media_sequence_number = 0

Custom EXT-X-MEDIA-SEQUENCE value to allow continuous media playback across packager restarts. See #691 for details.

enum shaka::HlsPlaylistType

Defines the EXT-X-PLAYLIST-TYPE in the HLS specification. For HlsPlaylistType of kLive, EXT-X-PLAYLIST-TYPE tag is omitted.

Values:

enumerator kVod
enumerator kEvent
enumerator kLive
enum shaka::KeyProvider

Encryption key providers. These provide keys to decrypt the content if the source content is encrypted, or used to encrypt the content.

Values:

enumerator kNone
enumerator kRawKey
enumerator kWidevine
enumerator kPlayReady
struct shaka::WidevineSigner

Signer credential for Widevine license server.

Public Members

std::string signer_name

Name of the signer / content provider.

SigningKeyType signing_key_type = SigningKeyType::kNone

Specifies the signing key type, which determines whether AES or RSA key are used to authenticate the signer. A type of ‘kNone’ is invalid.

std::vector<uint8_t> key

AES signing key.

std::vector<uint8_t> iv

AES signing IV.

std::string key

RSA signing private key.

enum shaka::WidevineSigner::SigningKeyType

Values:

enumerator kNone
enumerator kAes
enumerator kRsa
struct shaka::WidevineEncryptionParams

Widevine encryption parameters.

Public Members

std::string key_server_url

Widevine license / key server URL.

std::vector<uint8_t> content_id

Content identifier.

std::string policy

The name of a stored policy, which specifies DRM content rights.

WidevineSigner signer

Signer credential for Widevine license / key server.

std::vector<uint8_t> group_id

Group identifier, if present licenses will belong to this group.

bool enable_entitlement_license

Enables entitlement license when set to true.

struct shaka::PlayReadyEncryptionParams

PlayReady encryption parameters. key_server_url and program_identifier are required. The presence of other parameters may be necessary depends on server configuration.

Public Members

std::string key_server_url

PlayReady license / key server URL.

std::string program_identifier

PlayReady program identifier.

std::string ca_file

Absolute path to the Certificate Authority file for the server cert in PEM format.

std::string client_cert_file

Absolute path to client certificate file.

std::string client_cert_private_key_file

Absolute path to the private key file.

std::string client_cert_private_key_password

Password to the private key file.

struct shaka::RawKeyParams

Raw key encryption/decryption parameters, i.e. with key parameters provided.

Public Members

std::vector<uint8_t> iv

An optional initialization vector. If not provided, a random iv will be generated. Note that this parameter should only be used during testing. Not needed for decryption.

std::vector<uint8_t> pssh

Inject a custom pssh or multiple concatenated psshs. If not provided, a common system pssh will be generated. Not needed for decryption.

std::map<StreamLabel, KeyInfo> key_map

Defines the KeyInfo for the streams. An empty StreamLabel indicates the default KeyInfo, which applies to all the StreamLabels not present in key_map.

struct KeyInfo
struct shaka::EncryptionParams

Encryption parameters.

Public Members

KeyProvider key_provider = KeyProvider::kNone

Specifies the key provider, which determines which key provider is used and which encryption params is valid. ‘kNone’ means not to encrypt the streams.

ProtectionSystem protection_systems

The protection systems to generate, multiple can be OR’d together.

std::string playready_extra_header_data

Extra XML data to add to PlayReady data.

double clear_lead_in_seconds = 0

Clear lead duration in seconds.

uint8_t crypt_byte_block = 1

The count of the encrypted blocks in the protection pattern, where each block is of size 16-bytes. There are three common patterns (crypt_byte_block:skip_byte_block): 1:9 (default), 5:5, 10:0. Applies to video streams with “cbcs” and “cens” protection schemes only; Ignored otherwise.

uint8_t skip_byte_block = 9

The count of the unencrypted blocks in the protection pattern. Applies to video streams with “cbcs” and “cens” protection schemes only; Ignored otherwise.

bool vp9_subsample_encryption = true

Enable/disable subsample encryption for VP9.

std::function<std::string(const EncryptedStreamAttributes &stream_attributes)> stream_label_func

Stream label function assigns a stream label to the stream to be encrypted. Stream label is used to associate KeyPair with streams. Streams with the same stream label always uses the same keyPair; Streams with different stream label could use the same or different KeyPairs. A default stream label function will be generated if not set.

Public Static Attributes

static constexpr uint32_t kProtectionSchemeCenc = 0x63656E63

The protection scheme: “cenc”, “cens”, “cbc1”, “cbcs”.

static constexpr double kNoKeyRotation = 0

Crypto period duration in seconds. A positive value means key rotation is enabled, the key provider must support key rotation in this case.

struct EncryptedStreamAttributes

Encrypted stream information that is used to determine stream label.

union OneOf
struct shaka::WidevineDecryptionParams

Widevine decryption parameters.

Public Members

std::string key_server_url

Widevine license / key server URL.

WidevineSigner signer

Signer credential for Widevine license / key server.

struct shaka::DecryptionParams

Decryption parameters.

Public Members

KeyProvider key_provider = KeyProvider::kNone

Specifies the key provider, which determines which key provider is used and which encryption params is valid. ‘kNone’ means not to decrypt the streams.

class shaka::Status

Public Functions

inline Status()

Creates a “successful” status.

Status(error::Code error_code, const std::string &error_message)

Create a status with the specified code, and error message. If “error_code == error::OK”, error_message is ignored and a Status object identical to Status::OK is constructed.

void Update(Status new_status)

If “ok()”, stores “new_status” into *this. If “!ok()”, preserves the current “error_code()/error_message()”,

Convenient way of keeping track of the first error encountered. Instead of: if (overall_status.ok()) overall_status = new_status Use: overall_status.Update(new_status);

std::string ToString() const

Return

A combination of the error code name and message.

enum shaka::error::Code

Error codes for the packager APIs.

Values:

enumerator OK
enumerator UNKNOWN
enumerator CANCELLED
enumerator INVALID_ARGUMENT
enumerator UNIMPLEMENTED
enumerator FILE_FAILURE
enumerator END_OF_STREAM
enumerator HTTP_FAILURE
enumerator PARSER_FAILURE
enumerator ENCRYPTION_FAILURE
enumerator CHUNKING_ERROR
enumerator MUXER_FAILURE
enumerator FRAGMENT_FINALIZED
enumerator SERVER_ERROR
enumerator INTERNAL_ERROR
enumerator STOPPED
enumerator TIME_OUT
enumerator NOT_FOUND
enumerator ALREADY_EXISTS
enumerator TRICK_PLAY_ERROR