Shaka Packager SDK
packager.h
1 // Copyright 2017 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef PACKAGER_PACKAGER_H_
8 #define PACKAGER_PACKAGER_H_
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include "packager/file/public/buffer_callback_params.h"
15 #include "packager/hls/public/hls_params.h"
16 #include "packager/media/public/ad_cue_generator_params.h"
17 #include "packager/media/public/chunking_params.h"
18 #include "packager/media/public/crypto_params.h"
19 #include "packager/media/public/mp4_output_params.h"
20 #include "packager/mpd/public/mpd_params.h"
21 #include "packager/status.h"
22 
23 namespace shaka {
24 
26 struct TestParams {
28  bool dump_stream_info = false;
31  bool inject_fake_clock = false;
35 };
36 
40  std::string temp_dir;
49 
52 
55  bool output_media_info = false;
58  bool single_threaded = false;
63 
66  DecryptionParams decryption_params;
67 
70 
71  // Parameters for testing. Do not use in production.
72  TestParams test_params;
73 };
74 
78  std::string input;
79 
82  std::string stream_selector;
83 
86  std::string output;
88  std::string segment_template;
89 
92  std::string output_format;
95  bool skip_encryption = false;
100  std::string drm_label;
104  uint32_t trick_play_factor = 0;
108  uint32_t bandwidth = 0;
111  std::string language;
115  int32_t cc_index = -1;
116 
120  std::string hls_name;
123  std::string hls_group_id;
126  std::string hls_playlist_name;
132  std::vector<std::string> hls_characteristics;
133 
135  std::vector<std::string> dash_accessiblities;
137  std::vector<std::string> dash_roles;
138 
140  bool dash_only = false;
142  bool hls_only = false;
143 };
144 
145 class SHAKA_EXPORT Packager {
146  public:
147  Packager();
148  ~Packager();
149 
154  Status Initialize(
155  const PackagingParams& packaging_params,
156  const std::vector<StreamDescriptor>& stream_descriptors);
157 
161  Status Run();
162 
164  void Cancel();
165 
167  static std::string GetLibraryVersion();
168 
188  static std::string DefaultStreamLabelFunction(
189  int max_sd_pixels,
190  int max_hd_pixels,
191  int max_uhd1_pixels,
192  const EncryptionParams::EncryptedStreamAttributes& stream_attributes);
193 
194  private:
195  Packager(const Packager&) = delete;
196  Packager& operator=(const Packager&) = delete;
197 
198  struct PackagerInternal;
199  std::unique_ptr<PackagerInternal> internal_;
200 };
201 
202 } // namespace shaka
203 
204 #endif // PACKAGER_PACKAGER_H_
shaka::StreamDescriptor::segment_template
std::string segment_template
Specifies segment template. Can be empty.
Definition: packager.h:88
shaka::StreamDescriptor::input
std::string input
Input/source media file path or network stream URL. Required.
Definition: packager.h:78
shaka::StreamDescriptor::hls_only
bool hls_only
Set to true to indicate that the stream is for hls only.
Definition: packager.h:142
shaka::Mp4OutputParams
MP4 (ISO-BMFF) output related parameters.
Definition: mp4_output_params.h:13
shaka::StreamDescriptor::hls_group_id
std::string hls_group_id
Definition: packager.h:123
shaka::HlsParams
HLS related parameters.
Definition: hls_params.h:23
shaka::StreamDescriptor::hls_playlist_name
std::string hls_playlist_name
Definition: packager.h:126
shaka::EncryptionParams::EncryptedStreamAttributes
Encrypted stream information that is used to determine stream label.
Definition: crypto_params.h:187
shaka::StreamDescriptor::output_format
std::string output_format
Definition: packager.h:92
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::PackagingParams::encryption_params
EncryptionParams encryption_params
Encryption and Decryption Parameters.
Definition: packager.h:65
shaka::StreamDescriptor::hls_name
std::string hls_name
Definition: packager.h:120
shaka::StreamDescriptor::language
std::string language
Definition: packager.h:111
shaka::StreamDescriptor::drm_label
std::string drm_label
Definition: packager.h:100
shaka::PackagingParams::hls_params
HlsParams hls_params
HLS related parameters.
Definition: packager.h:62
shaka::StreamDescriptor
Defines a single input/output stream.
Definition: packager.h:76
shaka::PackagingParams::output_media_info
bool output_media_info
Definition: packager.h:55
shaka::BufferCallbackParams
Buffer callback params.
Definition: buffer_callback_params.h:15
shaka::Status
Definition: status.h:110
shaka::StreamDescriptor::hls_characteristics
std::vector< std::string > hls_characteristics
Definition: packager.h:132
shaka::TestParams::inject_fake_clock
bool inject_fake_clock
Definition: packager.h:31
shaka::TestParams
Parameters used for testing.
Definition: packager.h:26
shaka::PackagingParams::buffer_callback_params
BufferCallbackParams buffer_callback_params
Buffer callback params.
Definition: packager.h:69
shaka::StreamDescriptor::cc_index
int32_t cc_index
Definition: packager.h:115
shaka::PackagingParams::ad_cue_generator_params
AdCueGeneratorParams ad_cue_generator_params
Out of band cuepoint parameters.
Definition: packager.h:51
shaka::TestParams::injected_library_version
std::string injected_library_version
Definition: packager.h:34
shaka::ChunkingParams
Chunking (segmentation) related parameters.
Definition: chunking_params.h:13
shaka::StreamDescriptor::bandwidth
uint32_t bandwidth
Definition: packager.h:108
shaka::DecryptionParams
Decryption parameters.
Definition: crypto_params.h:228
shaka::EncryptionParams
Encryption parameters.
Definition: crypto_params.h:146
shaka::MpdParams
DASH MPD related parameters.
Definition: mpd_params.h:16
shaka::PackagingParams::mpd_params
MpdParams mpd_params
DASH MPD related parameters.
Definition: packager.h:60
shaka::StreamDescriptor::stream_selector
std::string stream_selector
Definition: packager.h:82
shaka::TestParams::dump_stream_info
bool dump_stream_info
Whether to dump input stream info.
Definition: packager.h:28
shaka::StreamDescriptor::trick_play_factor
uint32_t trick_play_factor
Definition: packager.h:104
shaka::StreamDescriptor::hls_iframe_playlist_name
std::string hls_iframe_playlist_name
Definition: packager.h:129
shaka::PackagingParams::temp_dir
std::string temp_dir
Specify temporary directory for intermediate temporary files.
Definition: packager.h:40
shaka::StreamDescriptor::skip_encryption
bool skip_encryption
Definition: packager.h:95
shaka::StreamDescriptor::dash_accessiblities
std::vector< std::string > dash_accessiblities
Optional for DASH output. It defines Accessibility elements of the stream.
Definition: packager.h:135
shaka::PackagingParams::chunking_params
ChunkingParams chunking_params
Chunking (segmentation) related parameters.
Definition: packager.h:48
shaka::PackagingParams
Packaging parameters.
Definition: packager.h:38
shaka::PackagingParams::single_threaded
bool single_threaded
Definition: packager.h:58
shaka::PackagingParams::mp4_output_params
Mp4OutputParams mp4_output_params
MP4 (ISO-BMFF) output related parameters.
Definition: packager.h:42
shaka::PackagingParams::transport_stream_timestamp_offset_ms
uint32_t transport_stream_timestamp_offset_ms
Definition: packager.h:46
shaka::StreamDescriptor::dash_only
bool dash_only
Set to true to indicate that the stream is for dash only.
Definition: packager.h:140
shaka::StreamDescriptor::output
std::string output
Definition: packager.h:86
shaka::Packager
Definition: packager.h:145
shaka::AdCueGeneratorParams
Cuepoint generator related parameters.
Definition: ad_cue_generator_params.h:23
shaka::StreamDescriptor::dash_roles
std::vector< std::string > dash_roles
Optional for DASH output. It defines Role elements of the stream.
Definition: packager.h:137