diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp index 159f4c6571f2..f67f02473106 100644 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp @@ -581,7 +581,20 @@ std::vector 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( + 1 + std::min(CountTrailingZeroes32(width), + CountTrailingZeroes32(height)))); + + // We only allow one layer when screensharing + if (mConduit->mCodecMode == webrtc::VideoCodecMode::kScreensharing) { + streamCount = 1; + } + std::vector streams; streams.reserve(streamCount); MOZ_ASSERT(mConduit);