Fix SimpleMpdNotifier logic

- SimpleMpdNotifier didn't register the container ID to its map for VOD.
- AddContentProtection() was not implemented.

Change-Id: I5f1412c785ee5ad3d00910755ff283c404dd895c
This commit is contained in:
Rintaro Kuroiwa 2015-07-21 14:52:20 -07:00
parent 6e4460a245
commit 0687b544b1
3 changed files with 22 additions and 12 deletions

View File

@ -58,8 +58,8 @@ class MpdNotifier {
virtual bool NotifySampleDuration(uint32_t container_id,
uint32_t sample_duration) = 0;
/// Notifies MpdBuilder that there is a new segment ready. Used only for live
/// profile.
/// Notifies MpdBuilder that there is a new segment ready. For live, this
/// is usually a new segment, for VOD this is usually a subsegment.
/// @param container_id Container ID obtained from calling
/// NotifyNewContainer().
/// @param start_time is the start time of the new segment, in units of the

View File

@ -66,12 +66,11 @@ bool SimpleMpdNotifier::NotifyNewContainer(const MediaInfo& media_info,
// generate a valid MPD.
AddContentProtectionElements(media_info, representation);
*container_id = representation->id();
DCHECK(!ContainsKey(representation_map_, representation->id()));
representation_map_[representation->id()] = representation;
if (mpd_builder_->type() == MpdBuilder::kStatic)
return WriteMpdToFile(output_path_, mpd_builder_.get());
DCHECK(!ContainsKey(representation_map_, representation->id()));
representation_map_[representation->id()] = representation;
return true;
}
@ -83,8 +82,10 @@ bool SimpleMpdNotifier::NotifySampleDuration(uint32_t container_id,
LOG(ERROR) << "Unexpected container_id: " << container_id;
return false;
}
// This sets the right frameRate for Representation or AdaptationSet, so
// write out the new MPD.
it->second->SetSampleDuration(sample_duration);
return true;
return WriteMpdToFile(output_path_, mpd_builder_.get());
}
bool SimpleMpdNotifier::NotifyNewSegment(uint32_t container_id,
@ -92,12 +93,13 @@ bool SimpleMpdNotifier::NotifyNewSegment(uint32_t container_id,
uint64_t duration,
uint64_t size) {
base::AutoLock auto_lock(lock_);
RepresentationMap::iterator it = representation_map_.find(container_id);
if (it == representation_map_.end()) {
LOG(ERROR) << "Unexpected container_id: " << container_id;
return false;
}
// For live, the timeline and segmentAlignment gets updated. For VOD,
// subsegmentAlignment gets updated. So write out the MPD.
it->second->AddNewSegment(start_time, duration, size);
return WriteMpdToFile(output_path_, mpd_builder_.get());
}
@ -105,8 +107,14 @@ bool SimpleMpdNotifier::NotifyNewSegment(uint32_t container_id,
bool SimpleMpdNotifier::AddContentProtectionElement(
uint32_t container_id,
const ContentProtectionElement& content_protection_element) {
NOTIMPLEMENTED();
base::AutoLock auto_lock(lock_);
RepresentationMap::iterator it = representation_map_.find(container_id);
if (it == representation_map_.end()) {
LOG(ERROR) << "Unexpected container_id: " << container_id;
return false;
}
it->second->AddContentProtectionElement(content_protection_element);
return WriteMpdToFile(output_path_, mpd_builder_.get());
}
} // namespace edash_packager

View File

@ -133,6 +133,7 @@ TEST_F(SimpleMpdNotifierTest, LiveNotifySampleDuration) {
.WillOnce(Return(default_mock_adaptation_set_.get()));
EXPECT_CALL(*default_mock_adaptation_set_, AddRepresentation(_))
.WillOnce(Return(mock_representation.get()));
EXPECT_CALL(*mock_mpd_builder, ToString(_)).WillOnce(Return(true));
uint32_t container_id;
SetMpdBuilder(&notifier, mock_mpd_builder.PassAs<MpdBuilder>());
@ -214,8 +215,7 @@ TEST_F(SimpleMpdNotifierTest, LiveNotifyNewSegment) {
}
// Verify AddContentProtectionElement() works. Profile doesn't matter.
// TODO(rkuroiwa): Not implemented yet, enable once it is implemented.
TEST_F(SimpleMpdNotifierTest, DISABLED_AddContentProtectionElement) {
TEST_F(SimpleMpdNotifierTest, AddContentProtectionElement) {
SimpleMpdNotifier notifier(kOnDemandProfile, empty_mpd_option_,
empty_base_urls_, output_path_);
@ -228,7 +228,9 @@ TEST_F(SimpleMpdNotifierTest, DISABLED_AddContentProtectionElement) {
.WillOnce(Return(default_mock_adaptation_set_.get()));
EXPECT_CALL(*default_mock_adaptation_set_, AddRepresentation(_))
.WillOnce(Return(mock_representation.get()));
EXPECT_CALL(*mock_mpd_builder, ToString(_)).WillOnce(Return(true));
EXPECT_CALL(*mock_mpd_builder, ToString(_))
.Times(2)
.WillRepeatedly(Return(true));
uint32_t container_id;
SetMpdBuilder(&notifier, mock_mpd_builder.PassAs<MpdBuilder>());