Bug 1336431: P6. Handle change of resolution in RemoteDataDecoder. r?JamesCheng
MozReview-Commit-ID: 8XOHESQiJ3t
--- a/dom/media/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -8,16 +8,17 @@
#include "FennecJNINatives.h"
#include "GLImages.h"
#include "MediaData.h"
#include "MediaInfo.h"
#include "VideoUtils.h"
#include "VPXDecoder.h"
+#include "mozilla/Mutex.h"
#include "nsThreadUtils.h"
#include "nsPromiseFlatString.h"
#include "nsIGfxInfo.h"
#include "prlog.h"
#include "DurationMap.h"
#include <jni.h>
@@ -175,16 +176,18 @@ public:
bool isEOS = !!(flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM);
int64_t durationUs = 0;
if (!mDecoder->mInputDurations.Find(presentationTimeUs, durationUs) && !isEOS) {
return;
}
if (size > 0) {
+ MutexAutoLock lock(mDecoder->mMutex);
+
RefPtr<layers::Image> img = new SurfaceTextureImage(
mDecoder->mSurfaceTexture.get(), mDecoder->mConfig.mDisplay,
gl::OriginPos::BottomLeft);
RefPtr<VideoData> v = VideoData::CreateFromImage(
mDecoder->mConfig, offset, presentationTimeUs, durationUs,
img, !!(flags & MediaCodec::BUFFER_FLAG_SYNC_FRAME),
presentationTimeUs,
@@ -214,16 +217,17 @@ public:
RemoteVideoDecoder(const VideoInfo& aConfig,
MediaFormat::Param aFormat,
layers::ImageContainer* aImageContainer,
const nsString& aDrmStubId, TaskQueue* aTaskQueue)
: RemoteDataDecoder(MediaData::Type::VIDEO_DATA, aConfig.mMimeType,
aFormat, aDrmStubId, aTaskQueue)
, mImageContainer(aImageContainer)
+ , mMutex("RemoteVideoDecoder Mutex")
, mConfig(aConfig)
{
}
RefPtr<InitPromise> Init() override
{
mSurfaceTexture = AndroidSurfaceTexture::Create();
if (!mSurfaceTexture) {
@@ -270,23 +274,30 @@ public:
mInputDurations.Insert(aSample->mDuration, aSample->mTime);
return RemoteDataDecoder::Decode(aSample);
}
bool SupportDecoderRecycling() const override
{
return mIsCodecSupportAdaptivePlayback;
}
+ void ConfigurationChanged(const TrackInfo& aConfig) override
+ {
+ MOZ_ASSERT(aConfig.GetAsVideoInfo());
+ MutexAutoLock lock(mMutex);
+ mConfig = *aConfig.GetAsVideoInfo();
+ }
private:
layers::ImageContainer* mImageContainer;
- const VideoInfo mConfig;
RefPtr<AndroidSurfaceTexture> mSurfaceTexture;
DurationMap mInputDurations;
bool mIsCodecSupportAdaptivePlayback = false;
+ Mutex mMutex; // Protects mConfig
+ VideoInfo mConfig;
};
class RemoteAudioDecoder : public RemoteDataDecoder
{
public:
RemoteAudioDecoder(const AudioInfo& aConfig,
MediaFormat::Param aFormat,
const nsString& aDrmStubId, TaskQueue* aTaskQueue)