Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(990)

Unified Diff: media/mp4/mp4_stream_parser.cc

Issue 10837116: Update EME MediaKeyNeededEvent.initData for ISO BMFF to match current spec. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« media/mp4/box_reader.h ('K') | « media/mp4/mp4_stream_parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mp4/mp4_stream_parser.cc
diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc
index 8d9a9a537ac796b8bbdcef4b4164326884e99cc0..fc141b5a8e150f64672ec39c0688a262cd9161f0 100644
--- a/media/mp4/mp4_stream_parser.cc
+++ b/media/mp4/mp4_stream_parser.cc
@@ -198,7 +198,6 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) {
LOG(ERROR) << "Unsupported audio object type.";
return false;
}
- RCHECK(EmitKeyNeeded(entry.sinf.info.track_encryption));
audio_config.Initialize(kCodecAAC, entry.samplesize,
aac.channel_layout(),
@@ -219,7 +218,6 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) {
LOG(ERROR) << "Unsupported video format.";
return false;
}
- RCHECK(EmitKeyNeeded(entry.sinf.info.track_encryption));
// TODO(strobe): Recover correct crop box
gfx::Size coded_size(entry.width, entry.height);
@@ -253,6 +251,8 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) {
if (!init_cb_.is_null())
base::ResetAndReturn(&init_cb_).Run(true, duration);
+
+ RCHECK(EmitNeedKeyIfNecessary(moov_->pssh));
return true;
}
@@ -261,20 +261,32 @@ bool MP4StreamParser::ParseMoof(BoxReader* reader) {
MovieFragment moof;
RCHECK(moof.Parse(reader));
RCHECK(runs_->Init(moof));
+ RCHECK(EmitNeedKeyIfNecessary(moov_->pssh));
new_segment_cb_.Run(runs_->GetMinDecodeTimestamp());
ChangeState(kEmittingSamples);
return true;
}
-bool MP4StreamParser::EmitKeyNeeded(const TrackEncryption& track_encryption) {
- // TODO(strobe): Send the correct value for initData. The format of initData
- // has not yet been defined; see
- // https://www.w3.org/Bugs/Public/show_bug.cgi?id=17673.
- if (!track_encryption.is_encrypted) return true;
- scoped_array<uint8> kid(new uint8[track_encryption.default_kid.size()]);
- memcpy(kid.get(), &track_encryption.default_kid[0],
- track_encryption.default_kid.size());
- return need_key_cb_.Run(kid.Pass(), track_encryption.default_kid.size());
+bool MP4StreamParser::EmitNeedKeyIfNecessary(
+ const std::vector<ProtectionSystemSpecificHeader>& headers) {
+ // TODO(strobe): ensure that the value of init_data (all PSSH headers
+ // concatenated in arbitrary order) matches the EME spec.
+ // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=17673.
+ if (headers.empty())
+ return true;
+
+ size_t total_size = 0;
+ for (size_t i = 0; i < headers.size(); i++)
+ total_size += headers[i].raw_box.size();
+
+ scoped_array<uint8> init_data(new uint8[total_size]);
+ size_t pos = 0;
+ for (size_t i = 0; i < headers.size(); i++) {
+ memcpy(&init_data.get()[pos], &headers[i].raw_box[0],
+ headers[i].raw_box.size());
+ pos += headers[i].raw_box.size();
+ }
+ return need_key_cb_.Run(init_data.Pass(), total_size);
}
bool MP4StreamParser::PrepareAVCBuffer(
« media/mp4/box_reader.h ('K') | « media/mp4/mp4_stream_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698