Merge remote-tracking branch 'github/master' into HEAD

This commit is contained in:
Widevine Buildbot 2017-08-29 20:46:52 +00:00
commit f20ad03caf
4 changed files with 144 additions and 32 deletions

View File

@ -0,0 +1,76 @@
// Copyright 2017 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "packager/media/event/combined_muxer_listener.h"
namespace shaka {
namespace media {
CombinedMuxerListener::CombinedMuxerListener(
std::list<std::unique_ptr<MuxerListener>>* muxer_listeners) {
DCHECK(muxer_listeners);
muxer_listeners_.swap(*muxer_listeners);
}
CombinedMuxerListener::~CombinedMuxerListener() {}
void CombinedMuxerListener::OnEncryptionInfoReady(
bool is_initial_encryption_info,
FourCC protection_scheme,
const std::vector<uint8_t>& key_id,
const std::vector<uint8_t>& iv,
const std::vector<ProtectionSystemSpecificInfo>& key_system_info) {
for (auto& listener: muxer_listeners_) {
listener->OnEncryptionInfoReady(is_initial_encryption_info,
protection_scheme,
key_id,
iv,
key_system_info);
}
}
void CombinedMuxerListener::OnEncryptionStart() {
for (auto& listener: muxer_listeners_) {
listener->OnEncryptionStart();
}
}
void CombinedMuxerListener::OnMediaStart(
const MuxerOptions& muxer_options,
const StreamInfo& stream_info,
uint32_t time_scale,
ContainerType container_type) {
for (auto& listener: muxer_listeners_) {
listener->OnMediaStart(
muxer_options, stream_info, time_scale, container_type);
}
}
void CombinedMuxerListener::OnSampleDurationReady(
uint32_t sample_duration) {
for (auto& listener: muxer_listeners_) {
listener->OnSampleDurationReady(sample_duration);
}
}
void CombinedMuxerListener::OnMediaEnd(const MediaRanges& media_ranges,
float duration_seconds) {
for (auto& listener: muxer_listeners_) {
listener->OnMediaEnd(media_ranges, duration_seconds);
}
}
void CombinedMuxerListener::OnNewSegment(const std::string& file_name,
uint64_t start_time,
uint64_t duration,
uint64_t segment_file_size) {
for (auto& listener: muxer_listeners_) {
listener->OnNewSegment(file_name, start_time, duration, segment_file_size);
}
}
} // namespace media
} // namespace shaka

View File

@ -0,0 +1,52 @@
// Copyright 2017 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MEDIA_EVENT_COMBINED_MUXER_LISTENER_H_
#define PACKAGER_MEDIA_EVENT_COMBINED_MUXER_LISTENER_H_
#include <list>
#include <memory>
#include "packager/media/event/muxer_listener.h"
namespace shaka {
namespace media {
class CombinedMuxerListener : public MuxerListener {
public:
explicit CombinedMuxerListener(
std::list<std::unique_ptr<MuxerListener>>* muxer_listeners);
~CombinedMuxerListener() override;
void OnEncryptionInfoReady(bool is_initial_encryption_info,
FourCC protection_scheme,
const std::vector<uint8_t>& key_id,
const std::vector<uint8_t>& iv,
const std::vector<ProtectionSystemSpecificInfo>&
key_system_info) override;
void OnEncryptionStart() override;
void OnMediaStart(const MuxerOptions& muxer_options,
const StreamInfo& stream_info,
uint32_t time_scale,
ContainerType container_type) override;
void OnSampleDurationReady(uint32_t sample_duration) override;
void OnMediaEnd(const MediaRanges& media_ranges,
float duration_seconds) override;
void OnNewSegment(const std::string& file_name,
uint64_t start_time,
uint64_t duration,
uint64_t segment_file_size) override;
private:
std::list<std::unique_ptr<MuxerListener>> muxer_listeners_;
DISALLOW_COPY_AND_ASSIGN(CombinedMuxerListener);
};
} // namespace media
} // namespace shaka
#endif // PACKAGER_MEDIA_EVENT_COMBINED_MUXER_LISTENER_H_

View File

@ -13,6 +13,8 @@
'target_name': 'media_event', 'target_name': 'media_event',
'type': '<(component)', 'type': '<(component)',
'sources': [ 'sources': [
'combined_muxer_listener.cc',
'combined_muxer_listener.h',
'hls_notify_muxer_listener.cc', 'hls_notify_muxer_listener.cc',
'hls_notify_muxer_listener.h', 'hls_notify_muxer_listener.h',
'mpd_notify_muxer_listener.cc', 'mpd_notify_muxer_listener.cc',

View File

@ -27,6 +27,7 @@
#include "packager/media/chunking/chunking_handler.h" #include "packager/media/chunking/chunking_handler.h"
#include "packager/media/crypto/encryption_handler.h" #include "packager/media/crypto/encryption_handler.h"
#include "packager/media/demuxer/demuxer.h" #include "packager/media/demuxer/demuxer.h"
#include "packager/media/event/combined_muxer_listener.h"
#include "packager/media/event/hls_notify_muxer_listener.h" #include "packager/media/event/hls_notify_muxer_listener.h"
#include "packager/media/event/mpd_notify_muxer_listener.h" #include "packager/media/event/mpd_notify_muxer_listener.h"
#include "packager/media/event/vod_media_info_dump_muxer_listener.h" #include "packager/media/event/vod_media_info_dump_muxer_listener.h"
@ -153,26 +154,6 @@ bool ValidateParams(const PackagingParams& packaging_params,
return false; return false;
} }
if (packaging_params.output_media_info &&
!packaging_params.mpd_params.mpd_output.empty()) {
LOG(ERROR) << "output_media_info and MPD output do not work together.";
return false;
}
if (packaging_params.output_media_info &&
!packaging_params.hls_params.master_playlist_output.empty()) {
LOG(ERROR) << "output_media_info and HLS output do not work together.";
return false;
}
// Since there isn't a muxer listener that can output both MPD and HLS,
// disallow specifying both MPD and HLS flags.
if (!packaging_params.mpd_params.mpd_output.empty() &&
!packaging_params.hls_params.master_playlist_output.empty()) {
LOG(ERROR) << "output both MPD and HLS are not supported.";
return false;
}
if (stream_descriptors.empty()) { if (stream_descriptors.empty()) {
LOG(ERROR) << "Stream descriptors cannot be empty."; LOG(ERROR) << "Stream descriptors cannot be empty.";
return false; return false;
@ -421,20 +402,17 @@ Status CreateRemuxJobs(const StreamDescriptorList& stream_descriptors,
if (packaging_params.test_params.inject_fake_clock) if (packaging_params.test_params.inject_fake_clock)
muxer->set_clock(fake_clock); muxer->set_clock(fake_clock);
std::unique_ptr<MuxerListener> muxer_listener; std::list<std::unique_ptr<MuxerListener>> muxer_listeners;
DCHECK(!(packaging_params.output_media_info && mpd_notifier)); DCHECK(!(packaging_params.output_media_info && mpd_notifier));
if (packaging_params.output_media_info) { if (packaging_params.output_media_info) {
const std::string output_media_info_file_name = const std::string output_media_info_file_name =
stream_muxer_options.output_file_name + kMediaInfoSuffix; stream_muxer_options.output_file_name + kMediaInfoSuffix;
std::unique_ptr<VodMediaInfoDumpMuxerListener> muxer_listeners.emplace_back(
vod_media_info_dump_muxer_listener(
new VodMediaInfoDumpMuxerListener(output_media_info_file_name)); new VodMediaInfoDumpMuxerListener(output_media_info_file_name));
muxer_listener = std::move(vod_media_info_dump_muxer_listener);
} }
if (mpd_notifier) { if (mpd_notifier) {
std::unique_ptr<MpdNotifyMuxerListener> mpd_notify_muxer_listener( muxer_listeners.emplace_back(new MpdNotifyMuxerListener(mpd_notifier));
new MpdNotifyMuxerListener(mpd_notifier));
muxer_listener = std::move(mpd_notify_muxer_listener);
} }
if (hls_notifier) { if (hls_notifier) {
@ -450,12 +428,16 @@ Status CreateRemuxJobs(const StreamDescriptorList& stream_descriptors,
if (hls_playlist_name.empty()) if (hls_playlist_name.empty())
hls_playlist_name = base::StringPrintf("stream_%d.m3u8", stream_number); hls_playlist_name = base::StringPrintf("stream_%d.m3u8", stream_number);
muxer_listener.reset(new HlsNotifyMuxerListener(hls_playlist_name, name, muxer_listeners.emplace_back(
new HlsNotifyMuxerListener(hls_playlist_name, name,
group_id, hls_notifier)); group_id, hls_notifier));
} }
if (muxer_listener) if (!muxer_listeners.empty()) {
muxer->SetMuxerListener(std::move(muxer_listener)); std::unique_ptr<CombinedMuxerListener> combined_muxer_listener(
new CombinedMuxerListener(&muxer_listeners));
muxer->SetMuxerListener(std::move(combined_muxer_listener));
}
// Create a new trick_play_handler. Note that the stream_decriptors // Create a new trick_play_handler. Note that the stream_decriptors
// are sorted so that for the same input and stream_selector, the main // are sorted so that for the same input and stream_selector, the main