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

Unified Diff: media/base/test_data_util.cc

Issue 1517473002: Support HLS MPEG2 TS with SAMPLE-AES encryption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@encryption_scheme
Patch Set: rebase Created 4 years 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/base/test_data_util.h ('k') | media/formats/mp2t/descriptors.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/test_data_util.cc
diff --git a/media/base/test_data_util.cc b/media/base/test_data_util.cc
index c56fd425dc444f3ee724fdee7ee40ce14d230857..9fc6332e7c387afef948b3abeed71a8dffa67b66 100644
--- a/media/base/test_data_util.cc
+++ b/media/base/test_data_util.cc
@@ -14,6 +14,17 @@
namespace media {
+namespace {
+
+// Key used to encrypt test files.
+const uint8_t kSecretKey[] = {0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
+ 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c};
+
+// The key ID for all encrypted files.
+const uint8_t kKeyId[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35};
+}
+
const base::FilePath::CharType kTestDataPath[] =
FILE_PATH_LITERAL("media/test/data");
@@ -56,4 +67,33 @@ scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) {
return buffer;
}
+bool LookupTestKeyVector(const std::vector<uint8_t>& key_id,
+ bool allow_rotation,
+ std::vector<uint8_t>* key) {
+ std::vector<uint8_t> starting_key_id(kKeyId, kKeyId + arraysize(kKeyId));
+ size_t rotate_limit = allow_rotation ? starting_key_id.size() : 1;
+ for (size_t pos = 0; pos < rotate_limit; ++pos) {
+ std::rotate(starting_key_id.begin(), starting_key_id.begin() + pos,
+ starting_key_id.end());
+ if (key_id == starting_key_id) {
+ key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey));
+ std::rotate(key->begin(), key->begin() + pos, key->end());
+ return true;
+ }
+ }
+ return false;
+}
+
+bool LookupTestKeyString(const std::string& key_id,
+ bool allow_rotation,
+ std::string* key) {
+ std::vector<uint8_t> key_vector;
+ bool result =
+ LookupTestKeyVector(std::vector<uint8_t>(key_id.begin(), key_id.end()),
+ allow_rotation, &key_vector);
+ if (result)
+ *key = std::string(key_vector.begin(), key_vector.end());
+ return result;
+}
+
} // namespace media
« no previous file with comments | « media/base/test_data_util.h ('k') | media/formats/mp2t/descriptors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698