Shaka Packager Library¶
Documentation for the top level Shaka packager library. See Internal API for documentation on internal APIs.
-
class
shaka::
Packager
¶ Public Functions
-
Status
Initialize
(const PackagingParams &packaging_params, const std::vector<StreamDescriptor> &stream_descriptors)¶ Initialize packaging pipeline.
- Return
- OK on success, an appropriate error code on failure.
- Parameters
packaging_params
: contains the packaging parameters.stream_descriptors
: a list of stream descriptors.
-
Status
Run
()¶ Run the pipeline to completion (or failed / been cancelled). Note that it blocks until completion.
- Return
- OK on success, an appropriate error code on failure.
-
void
Cancel
()¶ Cancel packaging. Note that it has to be called from another thread.
Public Static Functions
-
std::string
GetLibraryVersion
()¶ - Return
- The version of the library.
-
std::string
DefaultStreamLabelFunction
(int max_sd_pixels, int max_hd_pixels, int max_uhd1_pixels, const EncryptionParams::EncryptedStreamAttributes &stream_attributes)¶ Default stream label function implementation.
- Return
- the stream label associated with
stream_info
. Can be “AUDIO”, “SD”, “HD”, “UHD1” or “UHD2”. - Parameters
max_sd_pixels
: The threshold to determine whether a video track should be considered as SD. If the max pixels per frame is no higher than max_sd_pixels, i.e. [0, max_sd_pixels], it is SD.max_hd_pixels
: The threshold to determine whether a video track should be considered as HD. If the max pixels per frame is higher than max_sd_pixels, but no higher than max_hd_pixels, i.e. (max_sd_pixels, max_hd_pixels], it is HD.max_uhd1_pixels
: The threshold to determine whether a video track should be considered as UHD1. If the max pixels per frame is higher than max_hd_pixels, but no higher than max_uhd1_pixels, i.e. (max_hd_pixels, max_uhd1_pixels], it is UHD1. Otherwise it is UHD2.stream_info
: Encrypted stream info.
-
Status
Sample code:
shaka::Packager packager;
// Setup packaging parameters.
shaka::PackagingParams packaging_params;
// Use default parameters here.
// Setup stream descriptors.
std::vector<shaka::StreamDescriptor> stream_descriptors;
shaka::StreamDescriptor stream_descriptor;
stream_descriptor.input = "input.mp4";
stream_descriptor.stream_selector = "video";
stream_descriptor.output = "output_video.mp4";
stream_descriptors.push_back(stream_descriptor);
shaka::StreamDescriptor stream_descriptor;
stream_descriptor.input = "input.mp4";
stream_descriptor.stream_selector = "audio";
stream_descriptor.output = "output_audio.mp4";
stream_descriptors.push_back(stream_descriptor);
shaka::Status status = packager.Initialize(packaging_params,
stream_descriptors);
if (!status.ok()) { ... }
status = packager.Run();
if (!status.ok()) { ... }