From c376bbc538e40541cbac873e58418d0332f3b06b Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Tue, 10 Apr 2018 13:13:41 +0200 Subject: [PATCH] Bug 1450954 - Add back code to undo screenshare constraints hack. r=jib MozReview-Commit-ID: 9rDRj7U8vQi --HG-- extra : source : e2bd588aa90fe44fe38caed6bc7680111394b934 extra : histedit_source : 148034b0adc84941ae9c39716bb3da6d8258e3a4 --- .../webrtc/MediaEngineRemoteVideoSource.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp index 7af006c014ce..33f2080cd9bc 100644 --- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp @@ -310,7 +310,22 @@ MediaEngineRemoteVideoSource::Start(const RefPtr& aHandl NS_DispatchToMainThread(NS_NewRunnableFunction( "MediaEngineRemoteVideoSource::SetLastCapability", - [settings = mSettings, cap = mCapability]() mutable { + [settings = mSettings, source = mMediaSource, cap = mCapability]() mutable { + switch (source) { + case dom::MediaSourceEnum::Screen: + case dom::MediaSourceEnum::Window: + case dom::MediaSourceEnum::Application: + // Undo the hack where ideal and max constraints are crammed together + // in mCapability for consumption by low-level code. We don't actually + // know the real resolution yet, so report min(ideal, max) for now. + // TODO: This can be removed in bug 1453269. + cap.width = std::min(cap.width >> 16, cap.width & 0xffff); + cap.height = std::min(cap.height >> 16, cap.height & 0xffff); + break; + default: + break; + } + settings->mWidth.Value() = cap.width; settings->mHeight.Value() = cap.height; settings->mFrameRate.Value() = cap.maxFPS; @@ -494,6 +509,7 @@ MediaEngineRemoteVideoSource::DeliverFrame(uint8_t* aBuffer, { MutexAutoLock lock(mMutex); MOZ_ASSERT(mState == kStarted); + // TODO: These can be removed in bug 1453269. req_max_width = mCapability.width & 0xffff; req_max_height = mCapability.height & 0xffff; req_ideal_width = (mCapability.width >> 16) & 0xffff; @@ -826,6 +842,7 @@ MediaEngineRemoteVideoSource::ChooseCapability( // time (and may in fact change over time), so as a hack, we push ideal // and max constraints down to desktop_capture_impl.cc and finish the // algorithm there. + // TODO: This can be removed in bug 1453269. aCapability.width = (c.mWidth.mIdeal.valueOr(0) & 0xffff) << 16 | (c.mWidth.mMax & 0xffff); aCapability.height =