Bug 1450954 - Add back code to undo screenshare constraints hack. r?jib
MozReview-Commit-ID: 9rDRj7U8vQi
--- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
@@ -305,17 +305,32 @@ MediaEngineRemoteVideoSource::Start(cons
LOG(("StartCapture failed"));
MutexAutoLock lock(mMutex);
mState = kStopped;
return NS_ERROR_FAILURE;
}
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;
}));
return NS_OK;
}
@@ -489,16 +504,17 @@ MediaEngineRemoteVideoSource::DeliverFra
int32_t req_max_width;
int32_t req_max_height;
int32_t req_ideal_width;
int32_t req_ideal_height;
{
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;
req_ideal_height = (mCapability.height >> 16) & 0xffff;
}
if (aProps.rotation() == 90 || aProps.rotation() == 270) {
// This frame is rotated, so what was negotiated as width is now height,
@@ -821,16 +837,17 @@ MediaEngineRemoteVideoSource::ChooseCapa
case MediaSourceEnum::Screen:
case MediaSourceEnum::Window:
case MediaSourceEnum::Application: {
FlattenedConstraints c(aConstraints);
// The actual resolution to constrain around is not easy to find ahead of
// 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 =
(c.mHeight.mIdeal.valueOr(0) & 0xffff) << 16 | (c.mHeight.mMax & 0xffff);
aCapability.maxFPS =
c.mFrameRate.Clamp(c.mFrameRate.mIdeal.valueOr(aPrefs.mFPS));
return true;
}