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

Unified Diff: media/mp4/mp4_stream_parser.cc

Issue 10886022: Fix encrypted AAC in BMFF by adding subsample info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use constant in ConvertEsdsToADTS Created 8 years, 4 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
« no previous file with comments | « 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 b025b7ad527ba384e8798974808a10548058620d..b8f633131505f6c3eb458853238b4e554726bb75 100644
--- a/media/mp4/mp4_stream_parser.cc
+++ b/media/mp4/mp4_stream_parser.cc
@@ -309,6 +309,25 @@ bool MP4StreamParser::PrepareAVCBuffer(
return true;
}
+bool MP4StreamParser::PrepareAACBuffer(
+ const AAC& aac_config, std::vector<uint8>* frame_buf,
+ std::vector<SubsampleEntry>* subsamples) const {
+ // Append an ADTS header to every audio sample.
+ RCHECK(aac_config.ConvertEsdsToADTS(frame_buf));
+
+ // As above, adjust subsample information to account for the headers. AAC is
+ // not required to use subsample encryption, so we may need to add an entry.
+ if (subsamples->empty()) {
+ SubsampleEntry entry;
+ entry.clear_bytes = AAC::kADTSHeaderSize;
+ entry.cypher_bytes = frame_buf->size() - AAC::kADTSHeaderSize;
+ subsamples->push_back(entry);
+ } else {
+ (*subsamples)[0].clear_bytes += AAC::kADTSHeaderSize;
+ }
+ return true;
+}
+
bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers,
BufferQueue* video_buffers,
bool* err) {
@@ -366,39 +385,40 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers,
if (buf_size < runs_->sample_size()) return false;
scoped_ptr<DecryptConfig> decrypt_config;
- if (runs_->is_encrypted())
+ std::vector<SubsampleEntry> subsamples;
+ if (runs_->is_encrypted()) {
decrypt_config = runs_->GetDecryptConfig();
+ subsamples = decrypt_config->subsamples();
+ }
std::vector<uint8> frame_buf(buf, buf + runs_->sample_size());
if (video) {
- std::vector<SubsampleEntry> subsamples;
- if (decrypt_config.get())
- subsamples = decrypt_config->subsamples();
if (!PrepareAVCBuffer(runs_->video_description().avcc,
&frame_buf, &subsamples)) {
DLOG(ERROR) << "Failed to prepare AVC sample for decode";
*err = true;
return false;
}
- if (!subsamples.empty()) {
- decrypt_config.reset(new DecryptConfig(
- decrypt_config->key_id(),
- decrypt_config->iv(),
- decrypt_config->checksum(),
- decrypt_config->data_offset(),
- subsamples));
- }
}
if (audio) {
- const AAC& aac = runs_->audio_description().esds.aac;
- if (!aac.ConvertEsdsToADTS(&frame_buf)) {
- DLOG(ERROR) << "Failed to convert ESDS to ADTS";
+ if (!PrepareAACBuffer(runs_->audio_description().esds.aac,
+ &frame_buf, &subsamples)) {
+ DLOG(ERROR) << "Failed to prepare AAC sample for decode";
*err = true;
return false;
}
}
+ if (decrypt_config.get() != NULL && !subsamples.empty()) {
+ decrypt_config.reset(new DecryptConfig(
+ decrypt_config->key_id(),
+ decrypt_config->iv(),
+ decrypt_config->checksum(),
+ decrypt_config->data_offset(),
+ subsamples));
+ }
+
scoped_refptr<StreamParserBuffer> stream_buf =
StreamParserBuffer::CopyFrom(&frame_buf[0], frame_buf.size(),
runs_->is_keyframe());
« no previous file with comments | « media/mp4/mp4_stream_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698