From 11fd4a8721f305d7c7d142c54aecd5e79e96c969 Mon Sep 17 00:00:00 2001 From: Gian-Carlo Pascutto Date: Mon, 18 Aug 2014 14:06:01 +0200 Subject: [PATCH] Bug 929431 - Improve matching of camera capabilities to WebRTC restraints. r=jesup --- .../media/webrtc/MediaEngineWebRTCVideo.cpp | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/content/media/webrtc/MediaEngineWebRTCVideo.cpp b/content/media/webrtc/MediaEngineWebRTCVideo.cpp index 4e0ca21096e..738b9bb9f51 100644 --- a/content/media/webrtc/MediaEngineWebRTCVideo.cpp +++ b/content/media/webrtc/MediaEngineWebRTCVideo.cpp @@ -309,9 +309,28 @@ MediaEngineWebRTCVideoSource::ChooseCapability( // FIXME: expose expected capture delay? } } + // Same resolution, maybe better format or FPS match + if (mCapability.width == cap.width && mCapability.height == cap.height) { + // FPS too low + if (cap.maxFPS < (uint32_t) aPrefs.mMinFPS) { + continue; + } + // Better match + if (cap.maxFPS < mCapability.maxFPS) { + mCapability = cap; + } else if (cap.maxFPS == mCapability.maxFPS) { + // Resolution and FPS the same, check format + if (cap.rawType == webrtc::RawVideoType::kVideoI420 + || cap.rawType == webrtc::RawVideoType::kVideoYUY2 + || cap.rawType == webrtc::RawVideoType::kVideoYV12) { + mCapability = cap; + } + } + } } - LOG(("chose cap %dx%d @%dfps", - mCapability.width, mCapability.height, mCapability.maxFPS)); + LOG(("chose cap %dx%d @%dfps codec %d raw %d", + mCapability.width, mCapability.height, mCapability.maxFPS, + mCapability.codecType, mCapability.rawType)); #endif }