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

Unified Diff: media/mp4/cenc.cc

Issue 10536014: Implement ISO BMFF support in Media Source. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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
Index: media/mp4/cenc.cc
diff --git a/media/mp4/cenc.cc b/media/mp4/cenc.cc
new file mode 100644
index 0000000000000000000000000000000000000000..39450fa870c5feac55f72f9e8db5bac122ccd921
--- /dev/null
+++ b/media/mp4/cenc.cc
@@ -0,0 +1,46 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/mp4/cenc.h"
+
+#include "media/mp4/box_reader.h"
+#include "media/mp4/rcheck.h"
+#include <numeric>
+
+namespace media {
+namespace mp4 {
+
+FrameCENCInfo::FrameCENCInfo() {};
+FrameCENCInfo::~FrameCENCInfo() {};
+
+bool Parse(size_t iv_size, FrameCENCInfo* cenc, BufferReader* r) {
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 r -> reader
strobe_ 2012/06/07 16:33:54 Done.
+ const size_t kEntrySize = sizeof(uint16) + sizeof(uint32);
+
+ // Mandated by CENC spec
+ RCHECK(iv_size == 8 || iv_size == 16);
+ cenc->iv.resize(iv_size);
+
+ uint16 subsample_count;
+ RCHECK(r->Read(&cenc->iv, iv_size) &&
+ r->Read(&subsample_count) &&
+ r->HasBytes(subsample_count * kEntrySize));
+ cenc->subsamples.resize(subsample_count);
+
+ for (size_t i = 0; i < subsample_count; i++) {
+ RCHECK(r->Read(&cenc->subsamples[i].clear_size) &&
+ r->Read(&cenc->subsamples[i].encrypted_size));
+ }
+ return true;
+}
+
+size_t FrameCENCInfo::GetTotalSize() const {
+ size_t sz = 0;
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 sz -> size
strobe_ 2012/06/07 16:33:54 Done.
+ for (size_t i = 0; i < subsamples.size(); i++) {
+ sz += subsamples[i].clear_size + subsamples[i].encrypted_size;
+ }
+ return sz;
+}
+
+} // namespace mp4
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698