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.

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.

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.

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.

struct shaka::Mp4OutputParams

MP4 (ISO-BMFF) output related parameters.

Public Members

bool use_decoding_timestamp_in_timeline = false

Set the flag use_decoding_timestamp_in_timeline, which if set to true, use decoding timestamp instead of presentation timestamp in media timeline, which is needed to workaround a Chromium bug that decoding timestamp is used in buffered range, https://crbug.com/398130.

Public Static Attributes

constexpr int kNoSidxBoxInSegment = -1

Set the number of subsegments in each SIDX box. If 0, a single SIDX box is used per segment. If -1, no SIDX box is used. Otherwise, the Muxer will pack N subsegments in the root SIDX of the segment, with segment_duration/N/subsegment_duration fragments per subsegment. This flag is ingored for DASH MPD with on-demand profile.

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 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 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 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.

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 instead and omit SegmentTimeline completely. Ignored if $Time$ is used in segment template, since $Time$ requires accurate Segment Timeline.

Public Static Attributes

constexpr double kSuggestedPresentationDelayNotSet = 0

Set MPD 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.

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:

kVod
kEvent
kLive
enum shaka::KeyProvider

Encryption / decryption key providers.

Values:

kNone = 0
kWidevine = 1
kPlayReady = 2
kRawKey = 3
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:

kNone
kAes
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. Two different modes of playready key acquisition is supported: (1) Fetch from a key server. key_server_url and program_identifier are required. The presence of other parameters may be necessary depends on server configuration. (2) Provide the raw key directly. Both key_id and key are required. We are planning to merge this mode with RawKeyParams.

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.

Warning

doxygenstruct: Cannot find class “shaka::RawKeyEncryptionParams” in doxygen xml output for project “shaka” from directory: ../../out/doxygen/xml

Warning

doxygenstruct: Cannot find class “shaka::RawKeyEncryptionParams::KeyPair” in doxygen xml output for project “shaka” from directory: ../../out/doxygen/xml

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.

bool generate_common_pssh = false

When it is true, generate a v1 PSSH box for the common system ID. See: https://goo.gl/s8RIhr. The flag is default to be true if enable_raw_key_encryption is set and no other pssh flags are specified.

bool generate_playready_pssh = false

When it is true, include a PlayReady PSSH box. A playready PSSH is always generated regardless of the value of generate_playready_pssh for enable_playready_encryption.

bool generate_widevine_pssh = false

When it is true, include a widevine PSSH box. A widevine PSSH is always generated regardless of the value of generate_widevine_pssh for enable_widevine_encryption.

double clear_lead_in_seconds = 0

Clear lead duration in seconds.

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

constexpr uint32_t kProtectionSchemeCenc = 0x63656E63

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

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.

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.

Warning

doxygenstruct: Cannot find class “shaka::RawKeyDecryptionParams” in doxygen xml output for project “shaka” from directory: ../../out/doxygen/xml

Warning

doxygenstruct: Cannot find class “shaka::RawKeyDecryptionParams::KeyPair” in doxygen xml output for project “shaka” from directory: ../../out/doxygen/xml

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

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:

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