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

Unified Diff: media/mp4/cenc.cc

Issue 10651006: Add Common Encryption support to BMFF, including subsample decryption. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Satisfy mac_rel buildbot Created 8 years, 5 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/cenc.h ('k') | media/mp4/mp4_stream_parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mp4/cenc.cc
diff --git a/media/mp4/cenc.cc b/media/mp4/cenc.cc
index 996ebb12c28c50fe3b3c520ff78e0f6ae47854f5..104948dd4fa9066c3ed98a8f58f81215a0aad4e5 100644
--- a/media/mp4/cenc.cc
+++ b/media/mp4/cenc.cc
@@ -4,6 +4,8 @@
#include "media/mp4/cenc.h"
+#include <cstring>
+
#include "media/mp4/box_reader.h"
#include "media/mp4/rcheck.h"
@@ -15,28 +17,35 @@ FrameCENCInfo::~FrameCENCInfo() {}
bool FrameCENCInfo::Parse(int iv_size, BufferReader* reader) {
const int kEntrySize = 6;
-
// Mandated by CENC spec
RCHECK(iv_size == 8 || iv_size == 16);
- iv.resize(iv_size);
+
+ memset(iv, 0, sizeof(iv));
+ for (int i = 0; i < iv_size; i++)
+ RCHECK(reader->Read1(&iv[i]));
+
+ if (!reader->HasBytes(1)) return true;
uint16 subsample_count;
- RCHECK(reader->ReadVec(&iv, iv_size) &&
- reader->Read2(&subsample_count) &&
+ RCHECK(reader->Read2(&subsample_count) &&
reader->HasBytes(subsample_count * kEntrySize));
- subsamples.resize(subsample_count);
+ subsamples.resize(subsample_count);
for (int i = 0; i < subsample_count; i++) {
- RCHECK(reader->Read2(&subsamples[i].clear_size) &&
- reader->Read4(&subsamples[i].encrypted_size));
+ uint16 clear_bytes;
+ uint32 cypher_bytes;
+ RCHECK(reader->Read2(&clear_bytes) &&
+ reader->Read4(&cypher_bytes));
+ subsamples[i].clear_bytes = clear_bytes;
+ subsamples[i].cypher_bytes = cypher_bytes;
}
return true;
}
-size_t FrameCENCInfo::GetTotalSize() const {
+size_t FrameCENCInfo::GetTotalSizeOfSubsamples() const {
size_t size = 0;
for (size_t i = 0; i < subsamples.size(); i++) {
- size += subsamples[i].clear_size + subsamples[i].encrypted_size;
+ size += subsamples[i].clear_bytes + subsamples[i].cypher_bytes;
}
return size;
}
« no previous file with comments | « media/mp4/cenc.h ('k') | media/mp4/mp4_stream_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698