Bug 1560092 - Create decoder for encrypted h264 media even if an SPS is not found. r=jya

If an mp4 uses the AVC3 sample format then extra data will be stored in sample
data rather than in metadata. In encrypted streams the metadata is unencrypted
but samples are typically encrypted. If all samples are encrypted and the only
SPS data is in samples then the MediaChangeMonitor will never observe any SPS
data.

This updates the MediaChangeMonitor so that it will not try and inspect h264
content once encryption is detected and relies on the CDM to handle such
content.

Differential Revision: https://phabricator.services.mozilla.com/D37485

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bryce Van Dyk 2019-07-11 16:29:18 +00:00
parent f471fc6507
commit ea20dbf0b2

View File

@ -35,10 +35,20 @@ class H264ChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor {
}
bool CanBeInstantiated() const override {
// Found encrypted content, let the CDM handle it.
if ((mTrackInfo && (*mTrackInfo)->mCrypto.IsEncrypted()) ||
mGotEncryptedContent) {
return true;
}
return H264::HasSPS(mCurrentConfig.mExtraData);
}
MediaResult CheckForChange(MediaRawData* aSample) override {
// Don't look at encrypted content.
if (aSample->mCrypto.IsEncrypted()) {
mGotEncryptedContent = true;
return NS_OK;
}
// To be usable we need to convert the sample to 4 bytes NAL size AVCC.
if (!AnnexB::ConvertSampleToAVCC(aSample)) {
// We need AVCC content to be able to later parse the SPS.
@ -141,6 +151,7 @@ class H264ChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor {
uint32_t mStreamID = 0;
const bool mFullParsing;
bool mGotSPS = false;
bool mGotEncryptedContent = false;
RefPtr<TrackInfoSharedPtr> mTrackInfo;
RefPtr<MediaByteBuffer> mPreviousExtraData;
};