void MediaDecoder::MetadataLoaded(UniquePtr<MediaInfo> aInfo, UniquePtr<MetadataTags> aTags, MediaDecoderEventVisibility aEventVisibility) { MOZ_ASSERT(NS_IsMainThread()); AbstractThread::AutoEnter context(AbstractMainThread()); MOZ_DIAGNOSTIC_ASSERT(!IsShutdown()); LOG("MetadataLoaded, channels=%u rate=%u hasAudio=%d hasVideo=%d", aInfo->mAudio.mChannels, aInfo->mAudio.mRate, aInfo->HasAudio(), aInfo->HasVideo()); mMediaSeekable = aInfo->mMediaSeekable; mMediaSeekableOnlyInBufferedRanges = aInfo->mMediaSeekableOnlyInBufferedRanges; mInfo = aInfo.release(); GetOwner()->ConstructMediaTracks(mInfo); // Make sure the element and the frame (if any) are told about // our new size. if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) { mFiredMetadataLoaded = true; GetOwner()->MetadataLoaded(mInfo, std::move(aTags)); } // Invalidate() will end up calling GetOwner()->UpdateMediaSize with the last // dimensions retrieved from the video frame container. The video frame // container contains more up to date dimensions than aInfo. // So we call Invalidate() after calling GetOwner()->MetadataLoaded to ensure // the media element has the latest dimensions. Invalidate(); EnsureTelemetryReported(); }