Backed out changeset f3b3547c610a (bug 1144409) for eme test failures CLOSED TREE

This commit is contained in:
Wes Kocher 2015-03-23 16:06:32 -07:00
parent 19c1469c40
commit d93d614326
4 changed files with 30 additions and 39 deletions

View File

@ -3093,10 +3093,7 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
}
#ifdef MOZ_EME
// Dispatch a distinct 'encrypted' event for each initData we have.
for (const auto& initData : aInfo->mCrypto.mInitDatas) {
DispatchEncrypted(initData.mInitData, initData.mType);
}
DispatchEncrypted(aInfo->mCrypto.mInitData, aInfo->mCrypto.mType);
#endif
}

View File

@ -105,39 +105,16 @@ public:
class EncryptionInfo {
public:
struct InitData {
InitData(const nsString& aType, nsTArray<uint8_t>&& aInitData)
: mType(aType)
, mInitData(Move(aInitData))
{
}
EncryptionInfo() : mIsEncrypted(false) {}
// Encryption type to be passed to JS. Usually `cenc'.
nsString mType;
// Encryption type to be passed to JS. Usually `cenc'.
nsString mType;
// Encryption data.
nsTArray<uint8_t> mInitData;
};
typedef nsTArray<InitData> InitDatas;
// Encryption data.
nsTArray<uint8_t> mInitData;
// True if the stream has encryption metadata
bool IsEncrypted() const
{
return !mInitDatas.IsEmpty();
}
void AddInitData(const nsString& aType, nsTArray<uint8_t>&& aInitData)
{
mInitDatas.AppendElement(InitData(aType, Move(aInitData)));
}
void AddInitData(const EncryptionInfo& aInfo)
{
mInitDatas.AppendElements(aInfo.mInitDatas);
}
// One 'InitData' per encrypted buffer.
InitDatas mInitDatas;
bool mIsEncrypted;
};
class MediaInfo {
@ -154,7 +131,7 @@ public:
bool IsEncrypted() const
{
return mCrypto.IsEncrypted();
return mCrypto.mIsEncrypted;
}
bool HasValidMedia() const

View File

@ -368,7 +368,7 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
{
MonitorAutoUnlock unlock(mDemuxerMonitor);
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mIsEncrypted = mCrypto.valid;
mInfo.mCrypto.mIsEncrypted = mIsEncrypted = mCrypto.valid;
}
// Remember that we've initialized the demuxer, so that if we're decoding
@ -400,14 +400,15 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
}
}
if (mCrypto.valid) {
if (mIsEncrypted) {
nsTArray<uint8_t> initData;
ExtractCryptoInitData(initData);
if (initData.Length() == 0) {
return NS_ERROR_FAILURE;
}
mInfo.mCrypto.AddInitData(NS_LITERAL_STRING("cenc"), Move(initData));
mInfo.mCrypto.mInitData = initData;
mInfo.mCrypto.mType = NS_LITERAL_STRING("cenc");
}
// Get the duration, and report it to the decoder if we have it.

View File

@ -1059,6 +1059,22 @@ MediaSourceReader::MaybeNotifyHaveData()
IsSeeking(), haveAudio, haveVideo, ended);
}
static void
CombineEncryptionData(EncryptionInfo& aTo, const EncryptionInfo& aFrom)
{
if (!aFrom.mIsEncrypted) {
return;
}
aTo.mIsEncrypted = true;
if (!aTo.mType.IsEmpty() && !aTo.mType.Equals(aFrom.mType)) {
NS_WARNING("mismatched encryption types");
}
aTo.mType = aFrom.mType;
aTo.mInitData.AppendElements(aFrom.mInitData);
}
nsresult
MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
{
@ -1082,7 +1098,7 @@ MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
const MediaInfo& info = GetAudioReader()->GetMediaInfo();
MOZ_ASSERT(info.HasAudio());
mInfo.mAudio = info.mAudio;
mInfo.mCrypto.AddInitData(info.mCrypto);
CombineEncryptionData(mInfo.mCrypto, info.mCrypto);
MSE_DEBUG("audio reader=%p duration=%lld",
mAudioSourceDecoder.get(),
mAudioSourceDecoder->GetReader()->GetDecoder()->GetMediaDuration());
@ -1095,7 +1111,7 @@ MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
const MediaInfo& info = GetVideoReader()->GetMediaInfo();
MOZ_ASSERT(info.HasVideo());
mInfo.mVideo = info.mVideo;
mInfo.mCrypto.AddInitData(info.mCrypto);
CombineEncryptionData(mInfo.mCrypto, info.mCrypto);
MSE_DEBUG("video reader=%p duration=%lld",
GetVideoReader(),
GetVideoReader()->GetDecoder()->GetMediaDuration());