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);
49 current_key_id_ = encryption_config.key_id;
51 return InitializeMuxer();
52 case StreamDataType::kSegmentInfo: {
53 auto& segment_info = stream_data->segment_info;
54 if (muxer_listener_ && segment_info->is_encrypted) {
56 segment_info->key_rotation_encryption_config.get();
58 if (encryption_config && encryption_config->key_id != current_key_id_) {
59 muxer_listener_->OnEncryptionInfoReady(
60 !kInitialEncryptionInfo, encryption_config->protection_scheme,
61 encryption_config->key_id, encryption_config->constant_iv,
62 encryption_config->key_system_info);
63 current_key_id_ = encryption_config->key_id;
65 if (!encryption_started_) {
66 encryption_started_ =
true;
67 muxer_listener_->OnEncryptionStart();
70 return FinalizeSegment(stream_data->stream_index,
71 std::move(segment_info));
73 case StreamDataType::kMediaSample:
74 return AddSample(stream_data->stream_index,
75 std::move(stream_data->media_sample));
77 VLOG(3) <<
"Stream data type "
78 <<
static_cast<int>(stream_data->stream_data_type) <<
" ignored.";