зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1432793 - Force screensharing simulcast to one layer and stop generating layers once an odd width and height are found; r=bwc
This limits screensharing simulcast to a single layer. When window sharing, our source video can have arbitrary dimensions. If one of those dimensions ends up being odd, the aspect ratio of the smaller layer will not match the aspect ratio of the odd sized layer, causing a runtime assertion failure and crash. It is not sufficient to prevent the creation of odd sized layers in CreateEncoderStreams because the user can resize the window while it is being shared, which will cause a fatal assertion prior to the streams being recreated. When switching back from window sharing to camera, a call to CreateEncoderStreams will occur with resolutions matching the dimensions of the window that was just shared. To prevent a crash, this also adds a check which prevents the creation of layers with odd resolutions. Looking at cricket::GetSimulcastConfig for the version of webrtc.org in tree, the number of simulcast layers is limited to one, or two if a field experiment is enabled. That code also limits resolutions at which screensharing is allowed as well as the number of layers that can be created for each resolution, and ensures that each layer is exactly half the size of the layer above. Adding these new constraints to CreateEncoderStreams makes us more consistent with what the webrtc.org code would do when creating streams, which should help to avoid more assertion failures in the future. Long term, I believe we should just switch to using cricket::GetSimulcastConfig. MozReview-Commit-ID: 8gjdY5GPPjl --HG-- extra : rebase_source : b13b7acdac7f1e0b6016417b83bbe97dc2417a92
This commit is contained in:
Родитель
19f62f31a4
Коммит
3eee879885
|
@ -581,7 +581,20 @@ std::vector<webrtc::VideoStream>
|
|||
WebrtcVideoConduit::VideoStreamFactory::CreateEncoderStreams(int width, int height,
|
||||
const webrtc::VideoEncoderConfig& config)
|
||||
{
|
||||
auto streamCount = config.number_of_streams;
|
||||
size_t streamCount = config.number_of_streams;
|
||||
|
||||
// Disallow odd width and height, they will cause aspect ratio checks to
|
||||
// fail in the webrtc.org code. We can hit transient states after window
|
||||
// sharing ends where odd resolutions are requested for the camera.
|
||||
streamCount = std::min(streamCount, static_cast<size_t>(
|
||||
1 + std::min(CountTrailingZeroes32(width),
|
||||
CountTrailingZeroes32(height))));
|
||||
|
||||
// We only allow one layer when screensharing
|
||||
if (mConduit->mCodecMode == webrtc::VideoCodecMode::kScreensharing) {
|
||||
streamCount = 1;
|
||||
}
|
||||
|
||||
std::vector<webrtc::VideoStream> streams;
|
||||
streams.reserve(streamCount);
|
||||
MOZ_ASSERT(mConduit);
|
||||
|
|
Загрузка…
Ссылка в новой задаче