From 0861452932b4bd5d8c76f7fba84b337b2c76937e Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Mon, 9 Oct 2017 15:34:20 -0700 Subject: [PATCH] [Test] Rotate key_ids in PSSH as well for key rotation Note that fixed key / raw key rotation should not be used in production. Change-Id: I87fca41ebd00f3cadbf157ff129b8e6a9ca04e7c --- ...-640x360-a-live-cenc-rotation-golden-2.m4s | Bin 16850 -> 16850 bytes ...-640x360-a-live-cenc-rotation-golden-3.m4s | Bin 10472 -> 10472 bytes ...-640x360-v-live-cenc-rotation-golden-2.m4s | Bin 122544 -> 122544 bytes ...-640x360-v-live-cenc-rotation-golden-3.m4s | Bin 80271 -> 80271 bytes packager/media/base/fixed_key_source.cc | 18 +++++++++++++++--- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packager/app/test/testdata/bear-640x360-a-live-cenc-rotation-golden-2.m4s b/packager/app/test/testdata/bear-640x360-a-live-cenc-rotation-golden-2.m4s index 460c2cda5922ec2dcad4aeff05b917c7888f3a9f..b48c322560e05ea4b0dc41dc4a2beff9117c868d 100644 GIT binary patch delta 31 jcmccA%y_Apaf2_jfRV9@shPQjrGX)sWw<$(xzr8-nk)## delta 31 icmccA%y_Apaf2_jfT5AGiK&^ng{1+6wK^ diff --git a/packager/app/test/testdata/bear-640x360-v-live-cenc-rotation-golden-3.m4s b/packager/app/test/testdata/bear-640x360-v-live-cenc-rotation-golden-3.m4s index 4a91b498a4623f678f193a4852bd864b54ef614d..c6ff59c643ae756ac4b187e9ffdb5ff090cabe30 100644 GIT binary patch delta 35 ocmeDG%+mjvWy3~h0b>(WGjj_|14APa%h0I#AoKQv%#7zu0o!2key.begin() + (crypto_period_index % key->key.size()), key->key.end()); - for (size_t i = 0; i < key->key_system_info.size(); i++) { - std::vector pssh_data = key->key_system_info[i].pssh_data(); + for (auto& key_system : key->key_system_info) { + std::vector pssh_data = key_system.pssh_data(); if (!pssh_data.empty()) { std::rotate(pssh_data.begin(), pssh_data.begin() + (crypto_period_index % pssh_data.size()), pssh_data.end()); - key->key_system_info[i].set_pssh_data(pssh_data); + key_system.set_pssh_data(pssh_data); + } + + // Rotate the key_ids in pssh as well if exists. + // Save a local copy of the key ids before clearing the key ids in + // |key_system|. The key ids will be updated and added back later. + std::vector> key_ids_copy = key_system.key_ids(); + key_system.clear_key_ids(); + for (std::vector& key_id : key_ids_copy) { + std::rotate(key_id.begin(), + key_id.begin() + (crypto_period_index % key_id.size()), + key_id.end()); + key_system.add_key_id(key_id); } }