DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
muxer.cc
1 // Copyright 2014 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 #include "packager/media/base/muxer.h"
8 
9 #include <algorithm>
10 
11 #include "packager/media/base/fourccs.h"
12 #include "packager/media/base/media_sample.h"
13 
14 namespace shaka {
15 namespace media {
16 
17 Muxer::Muxer(const MuxerOptions& options)
18  : options_(options),
19  encryption_key_source_(NULL),
20  max_sd_pixels_(0),
21  max_hd_pixels_(0),
22  max_uhd1_pixels_(0),
23  clear_lead_in_seconds_(0),
24  crypto_period_duration_in_seconds_(0),
25  protection_scheme_(FOURCC_NULL),
26  cancelled_(false),
27  clock_(NULL) {}
28 
29 Muxer::~Muxer() {}
30 
31 void Muxer::SetKeySource(KeySource* encryption_key_source,
32  uint32_t max_sd_pixels,
33  uint32_t max_hd_pixels,
34  uint32_t max_uhd1_pixels,
35  double clear_lead_in_seconds,
36  double crypto_period_duration_in_seconds,
37  FourCC protection_scheme) {
38  DCHECK(encryption_key_source);
39  encryption_key_source_ = encryption_key_source;
40  max_sd_pixels_ = max_sd_pixels;
41  max_hd_pixels_ = max_hd_pixels;
42  max_uhd1_pixels_ = max_uhd1_pixels;
43  clear_lead_in_seconds_ = clear_lead_in_seconds;
44  crypto_period_duration_in_seconds_ = crypto_period_duration_in_seconds;
45  protection_scheme_ = protection_scheme;
46 }
47 
48 void Muxer::Cancel() {
49  cancelled_ = true;
50 }
51 
52 void Muxer::SetMuxerListener(std::unique_ptr<MuxerListener> muxer_listener) {
53  muxer_listener_ = std::move(muxer_listener);
54 }
55 
57  std::unique_ptr<ProgressListener> progress_listener) {
58  progress_listener_ = std::move(progress_listener);
59 }
60 
61 Status Muxer::Process(std::unique_ptr<StreamData> stream_data) {
62  Status status;
63  switch (stream_data->stream_data_type) {
64  case StreamDataType::kStreamInfo:
65  streams_.push_back(std::move(stream_data->stream_info));
66  return InitializeMuxer();
67  case StreamDataType::kMediaSample:
68  return DoAddSample(stream_data->media_sample);
69  default:
70  VLOG(3) << "Stream data type "
71  << static_cast<int>(stream_data->stream_data_type) << " ignored.";
72  break;
73  }
74  // No dispatch for muxer.
75  return Status::OK;
76 }
77 
78 } // namespace media
79 } // namespace shaka
void SetProgressListener(std::unique_ptr< ProgressListener > progress_listener)
Definition: muxer.cc:56
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:30
void SetKeySource(KeySource *encryption_key_source, uint32_t max_sd_pixels, uint32_t max_hd_pixels, uint32_t max_uhd1_pixels, double clear_lead_in_seconds, double crypto_period_duration_in_seconds, FourCC protection_scheme)
Definition: muxer.cc:31
Status Process(std::unique_ptr< StreamData > stream_data) override
Definition: muxer.cc:61
void SetMuxerListener(std::unique_ptr< MuxerListener > muxer_listener)
Definition: muxer.cc:52