7 #include "packager/media/base/muxer.h"
11 #include "packager/media/base/media_sample.h"
16 const bool kInitialEncryptionInfo =
true;
19 Muxer::Muxer(
const MuxerOptions& options)
20 : options_(options), cancelled_(false), clock_(NULL) {}
29 muxer_listener_ = std::move(muxer_listener);
33 std::unique_ptr<ProgressListener> progress_listener) {
34 progress_listener_ = std::move(progress_listener);
39 switch (stream_data->stream_data_type) {
40 case StreamDataType::kStreamInfo:
41 streams_.push_back(std::move(stream_data->stream_info));
42 if (muxer_listener_ && streams_.back()->is_encrypted()) {
44 streams_.back()->encryption_config();
45 muxer_listener_->OnEncryptionInfoReady(
46 kInitialEncryptionInfo, encryption_config.protection_scheme,
47 encryption_config.key_id, encryption_config.constant_iv,
48 encryption_config.key_system_info);
50 return InitializeMuxer();
51 case StreamDataType::kSegmentInfo: {
52 auto& segment_info = stream_data->segment_info;
53 if (muxer_listener_) {
55 segment_info->key_rotation_encryption_config.get();
56 if (encryption_config) {
57 muxer_listener_->OnEncryptionInfoReady(
58 !kInitialEncryptionInfo, encryption_config->protection_scheme,
59 encryption_config->key_id, encryption_config->constant_iv,
60 encryption_config->key_system_info);
62 if (segment_info->is_encrypted && !encryption_started_) {
63 encryption_started_ =
true;
64 muxer_listener_->OnEncryptionStart();
67 return FinalizeSegment(stream_data->stream_index,
68 std::move(segment_info));
70 case StreamDataType::kMediaSample:
71 return AddSample(stream_data->stream_index,
72 std::move(stream_data->media_sample));
74 VLOG(3) <<
"Stream data type "
75 <<
static_cast<int>(stream_data->stream_data_type) <<
" ignored.";