Commit 2983dc91 authored by sandersd's avatar sandersd Committed by Commit bot

Pass initDataType instead of contentType to OnNeedKey().

BUG=224786

Review URL: https://codereview.chromium.org/611513005

Cr-Commit-Position: refs/heads/master@{#297523}
parent 0a1686e0
...@@ -1498,11 +1498,11 @@ WebMediaPlayer::MediaKeyException WebMediaPlayerAndroid::generateKeyRequest( ...@@ -1498,11 +1498,11 @@ WebMediaPlayer::MediaKeyException WebMediaPlayerAndroid::generateKeyRequest(
// so we keep it as simple as possible without breaking major use cases. // so we keep it as simple as possible without breaking major use cases.
static std::string GuessInitDataType(const unsigned char* init_data, static std::string GuessInitDataType(const unsigned char* init_data,
unsigned init_data_length) { unsigned init_data_length) {
// Most WebM files use KeyId of 16 bytes. MP4 init data are always >16 bytes. // Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes.
if (init_data_length == 16) if (init_data_length == 16)
return "video/webm"; return "webm";
return "video/mp4"; return "cenc";
} }
// TODO(xhwang): Report an error when there is encrypted stream but EME is // TODO(xhwang): Report an error when there is encrypted stream but EME is
......
...@@ -117,11 +117,11 @@ static void ReportMediaKeyExceptionToUMA(const std::string& method, ...@@ -117,11 +117,11 @@ static void ReportMediaKeyExceptionToUMA(const std::string& method,
// so we keep it as simple as possible without breaking major use cases. // so we keep it as simple as possible without breaking major use cases.
static std::string GuessInitDataType(const unsigned char* init_data, static std::string GuessInitDataType(const unsigned char* init_data,
unsigned init_data_length) { unsigned init_data_length) {
// Most WebM files use KeyId of 16 bytes. MP4 init data are always >16 bytes. // Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes.
if (init_data_length == 16) if (init_data_length == 16)
return "video/webm"; return "webm";
return "video/mp4"; return "cenc";
} }
scoped_ptr<media::EncryptedMediaPlayerSupport> scoped_ptr<media::EncryptedMediaPlayerSupport>
......
...@@ -95,7 +95,7 @@ bool HasHeader(const uint8* data, int data_length, const std::string& header) { ...@@ -95,7 +95,7 @@ bool HasHeader(const uint8* data, int data_length, const std::string& header) {
std::equal(data, data + header.size(), header.begin()); std::equal(data, data + header.size(), header.begin());
} }
bool ProxyDecryptor::GenerateKeyRequest(const std::string& content_type, bool ProxyDecryptor::GenerateKeyRequest(const std::string& init_data_type,
const uint8* init_data, const uint8* init_data,
int init_data_length) { int init_data_length) {
DVLOG(1) << "GenerateKeyRequest()"; DVLOG(1) << "GenerateKeyRequest()";
...@@ -134,17 +134,6 @@ bool ProxyDecryptor::GenerateKeyRequest(const std::string& content_type, ...@@ -134,17 +134,6 @@ bool ProxyDecryptor::GenerateKeyRequest(const std::string& content_type,
? media::MediaKeys::PERSISTENT_SESSION ? media::MediaKeys::PERSISTENT_SESSION
: media::MediaKeys::TEMPORARY_SESSION; : media::MediaKeys::TEMPORARY_SESSION;
// Convert MIME types used in the prefixed implementation.
std::string init_data_type;
if (content_type == "audio/mp4" || content_type == "video/mp4") {
init_data_type = "cenc";
} else if (content_type == "audio/webm" || content_type == "video/webm") {
init_data_type = "webm";
} else {
NOTREACHED();
init_data_type = content_type;
}
media_keys_->CreateSession(init_data_type, init_data, init_data_length, media_keys_->CreateSession(init_data_type, init_data, init_data_length,
session_type, promise.Pass()); session_type, promise.Pass());
return true; return true;
......
...@@ -72,7 +72,7 @@ class ProxyDecryptor { ...@@ -72,7 +72,7 @@ class ProxyDecryptor {
const GURL& security_origin); const GURL& security_origin);
// May only be called after InitializeCDM() succeeds. // May only be called after InitializeCDM() succeeds.
bool GenerateKeyRequest(const std::string& type, bool GenerateKeyRequest(const std::string& init_data_type,
const uint8* init_data, const uint8* init_data,
int init_data_length); int init_data_length);
void AddKey(const uint8* key, int key_length, void AddKey(const uint8* key, int key_length,
......
...@@ -29,6 +29,7 @@ using testing::SaveArg; ...@@ -29,6 +29,7 @@ using testing::SaveArg;
namespace media { namespace media {
const char kSourceId[] = "SourceId"; const char kSourceId[] = "SourceId";
const char kCencInitDataType[] = "cenc";
const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 };
const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\"";
...@@ -36,8 +37,6 @@ const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; ...@@ -36,8 +37,6 @@ const char kWebMVP9[] = "video/webm; codecs=\"vp9\"";
const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\""; const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\"";
const char kOpusAudioOnlyWebM[] = "video/webm; codecs=\"opus\""; const char kOpusAudioOnlyWebM[] = "video/webm; codecs=\"opus\"";
const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\"";
const char kMP4VideoType[] = "video/mp4";
const char kMP4AudioType[] = "audio/mp4";
#if defined(USE_PROPRIETARY_CODECS) #if defined(USE_PROPRIETARY_CODECS)
const char kADTS[] = "audio/aac"; const char kADTS[] = "audio/aac";
const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\"";
...@@ -267,7 +266,7 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase { ...@@ -267,7 +266,7 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
// correct key ID. // correct key ID.
const uint8* key_id = init_data.empty() ? NULL : &init_data[0]; const uint8* key_id = init_data.empty() ? NULL : &init_data[0];
size_t key_id_length = init_data.size(); size_t key_id_length = init_data.size();
if (type == kMP4AudioType || type == kMP4VideoType) { if (type == kCencInitDataType) {
key_id = kKeyId; key_id = kKeyId;
key_id_length = arraysize(kKeyId); key_id_length = arraysize(kKeyId);
} }
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
namespace media { namespace media {
namespace mp4 { namespace mp4 {
// TODO(xhwang): Figure out the init data type appropriately once it's spec'ed. static const char kCencInitDataType[] = "cenc";
static const char kMp4InitDataType[] = "video/mp4";
MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types, MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types,
bool has_sbr) bool has_sbr)
...@@ -354,7 +353,7 @@ void MP4StreamParser::EmitNeedKeyIfNecessary( ...@@ -354,7 +353,7 @@ void MP4StreamParser::EmitNeedKeyIfNecessary(
headers[i].raw_box.size()); headers[i].raw_box.size());
pos += headers[i].raw_box.size(); pos += headers[i].raw_box.size();
} }
need_key_cb_.Run(kMp4InitDataType, init_data); need_key_cb_.Run(kCencInitDataType, init_data);
} }
bool MP4StreamParser::PrepareAVCBuffer( bool MP4StreamParser::PrepareAVCBuffer(
......
...@@ -25,8 +25,7 @@ using base::TimeDelta; ...@@ -25,8 +25,7 @@ using base::TimeDelta;
namespace media { namespace media {
namespace mp4 { namespace mp4 {
// TODO(xhwang): Figure out the init data type appropriately once it's spec'ed. static const char kCencInitDataType[] = "cenc";
static const char kMp4InitDataType[] = "video/mp4";
class MP4StreamParserTest : public testing::Test { class MP4StreamParserTest : public testing::Test {
public: public:
...@@ -122,7 +121,7 @@ class MP4StreamParserTest : public testing::Test { ...@@ -122,7 +121,7 @@ class MP4StreamParserTest : public testing::Test {
void KeyNeededF(const std::string& type, void KeyNeededF(const std::string& type,
const std::vector<uint8>& init_data) { const std::vector<uint8>& init_data) {
DVLOG(1) << "KeyNeededF: " << init_data.size(); DVLOG(1) << "KeyNeededF: " << init_data.size();
EXPECT_EQ(kMp4InitDataType, type); EXPECT_EQ(kCencInitDataType, type);
EXPECT_FALSE(init_data.empty()); EXPECT_FALSE(init_data.empty());
} }
......
...@@ -11,10 +11,7 @@ ...@@ -11,10 +11,7 @@
namespace media { namespace media {
// TODO(xhwang): Figure out the init data type appropriately once it's spec'ed. const char kWebMEncryptInitDataType[] = "webm";
// See https://www.w3.org/Bugs/Public/show_bug.cgi?id=19096 for more
// information.
const char kWebMEncryptInitDataType[] = "video/webm";
// Fills an initialized DecryptConfig, which can be sent to the Decryptor if // Fills an initialized DecryptConfig, which can be sent to the Decryptor if
// the stream has potentially encrypted frames. Also sets |data_offset| which // the stream has potentially encrypted frames. Also sets |data_offset| which
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment