Commit de394fa4 authored by zmo's avatar zmo Committed by Commit bot

Revert of Pass initDataType instead of contentType on OnNeedKey(). (patchset...

Revert of Pass initDataType instead of contentType on OnNeedKey(). (patchset #4 id:60001 of https://codereview.chromium.org/611513005/)

Reason for revert:
This broke media/encrypted-media/encrypted-media-needkey.html on Linux (at least)

Original issue's description:
> Pass initDataType instead of contentType to OnNeedKey().
>
> BUG=224786
>
> Committed: https://crrev.com/2983dc91cc0bc7be6014f4bfc5cb19cc6e262a0b
> Cr-Commit-Position: refs/heads/master@{#297523}

TBR=ddorwin@chromium.org,sandersd@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=224786

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

Cr-Commit-Position: refs/heads/master@{#297538}
parent ca73bb0e
......@@ -1498,11 +1498,11 @@ WebMediaPlayer::MediaKeyException WebMediaPlayerAndroid::generateKeyRequest(
// so we keep it as simple as possible without breaking major use cases.
static std::string GuessInitDataType(const unsigned char* init_data,
unsigned init_data_length) {
// Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes.
// Most WebM files use KeyId of 16 bytes. MP4 init data are always >16 bytes.
if (init_data_length == 16)
return "webm";
return "video/webm";
return "cenc";
return "video/mp4";
}
// TODO(xhwang): Report an error when there is encrypted stream but EME is
......
......@@ -117,11 +117,11 @@ static void ReportMediaKeyExceptionToUMA(const std::string& method,
// so we keep it as simple as possible without breaking major use cases.
static std::string GuessInitDataType(const unsigned char* init_data,
unsigned init_data_length) {
// Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes.
// Most WebM files use KeyId of 16 bytes. MP4 init data are always >16 bytes.
if (init_data_length == 16)
return "webm";
return "video/webm";
return "cenc";
return "video/mp4";
}
scoped_ptr<media::EncryptedMediaPlayerSupport>
......
......@@ -95,7 +95,7 @@ bool HasHeader(const uint8* data, int data_length, const std::string& header) {
std::equal(data, data + header.size(), header.begin());
}
bool ProxyDecryptor::GenerateKeyRequest(const std::string& init_data_type,
bool ProxyDecryptor::GenerateKeyRequest(const std::string& content_type,
const uint8* init_data,
int init_data_length) {
DVLOG(1) << "GenerateKeyRequest()";
......@@ -134,6 +134,17 @@ bool ProxyDecryptor::GenerateKeyRequest(const std::string& init_data_type,
? media::MediaKeys::PERSISTENT_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,
session_type, promise.Pass());
return true;
......
......@@ -72,7 +72,7 @@ class ProxyDecryptor {
const GURL& security_origin);
// May only be called after InitializeCDM() succeeds.
bool GenerateKeyRequest(const std::string& init_data_type,
bool GenerateKeyRequest(const std::string& type,
const uint8* init_data,
int init_data_length);
void AddKey(const uint8* key, int key_length,
......
......@@ -29,7 +29,6 @@ using testing::SaveArg;
namespace media {
const char kSourceId[] = "SourceId";
const char kCencInitDataType[] = "cenc";
const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 };
const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\"";
......@@ -37,6 +36,8 @@ const char kWebMVP9[] = "video/webm; codecs=\"vp9\"";
const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\"";
const char kOpusAudioOnlyWebM[] = "video/webm; codecs=\"opus\"";
const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\"";
const char kMP4VideoType[] = "video/mp4";
const char kMP4AudioType[] = "audio/mp4";
#if defined(USE_PROPRIETARY_CODECS)
const char kADTS[] = "audio/aac";
const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\"";
......@@ -266,7 +267,7 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
// correct key ID.
const uint8* key_id = init_data.empty() ? NULL : &init_data[0];
size_t key_id_length = init_data.size();
if (type == kCencInitDataType) {
if (type == kMP4AudioType || type == kMP4VideoType) {
key_id = kKeyId;
key_id_length = arraysize(kKeyId);
}
......
......@@ -22,7 +22,8 @@
namespace media {
namespace mp4 {
static const char kCencInitDataType[] = "cenc";
// TODO(xhwang): Figure out the init data type appropriately once it's spec'ed.
static const char kMp4InitDataType[] = "video/mp4";
MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types,
bool has_sbr)
......@@ -353,7 +354,7 @@ void MP4StreamParser::EmitNeedKeyIfNecessary(
headers[i].raw_box.size());
pos += headers[i].raw_box.size();
}
need_key_cb_.Run(kCencInitDataType, init_data);
need_key_cb_.Run(kMp4InitDataType, init_data);
}
bool MP4StreamParser::PrepareAVCBuffer(
......
......@@ -25,7 +25,8 @@ using base::TimeDelta;
namespace media {
namespace mp4 {
static const char kCencInitDataType[] = "cenc";
// TODO(xhwang): Figure out the init data type appropriately once it's spec'ed.
static const char kMp4InitDataType[] = "video/mp4";
class MP4StreamParserTest : public testing::Test {
public:
......@@ -121,7 +122,7 @@ class MP4StreamParserTest : public testing::Test {
void KeyNeededF(const std::string& type,
const std::vector<uint8>& init_data) {
DVLOG(1) << "KeyNeededF: " << init_data.size();
EXPECT_EQ(kCencInitDataType, type);
EXPECT_EQ(kMp4InitDataType, type);
EXPECT_FALSE(init_data.empty());
}
......
......@@ -11,7 +11,10 @@
namespace media {
const char kWebMEncryptInitDataType[] = "webm";
// TODO(xhwang): Figure out the init data type appropriately once it's spec'ed.
// 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
// 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