diff --git a/dom/media/webrtc/MediaEngineCameraVideoSource.cpp b/dom/media/webrtc/MediaEngineCameraVideoSource.cpp index 68b456b9e62a..9cd1acff4e03 100644 --- a/dom/media/webrtc/MediaEngineCameraVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineCameraVideoSource.cpp @@ -162,6 +162,49 @@ MediaEngineCameraVideoSource::LogConstraints( c.mFrameRate.mIdeal.WasPassed()? c.mFrameRate.mIdeal.Value() : 0)); } +void +MediaEngineCameraVideoSource::LogCapability(const char* aHeader, + const webrtc::CaptureCapability &aCapability, uint32_t aDistance) +{ + // RawVideoType and VideoCodecType media/webrtc/trunk/webrtc/common_types.h + static const char* const types[] = { + "I420", + "YV12", + "YUY2", + "UYVY", + "IYUV", + "ARGB", + "RGB24", + "RGB565", + "ARGB4444", + "ARGB1555", + "MJPEG", + "NV12", + "NV21", + "BGRA", + "Unknown type" + }; + + static const char* const codec[] = { + "VP8", + "VP9", + "H264", + "I420", + "RED", + "ULPFEC", + "Generic codec", + "Unknown codec" + }; + + LOG(("%s: %4u x %4u x %2u maxFps, %s, %s. Distance = %lu", + aHeader, aCapability.width, aCapability.height, aCapability.maxFPS, + types[std::min(std::max(uint32_t(0), uint32_t(aCapability.rawType)), + uint32_t(sizeof(types) / sizeof(*types) - 1))], + codec[std::min(std::max(uint32_t(0), uint32_t(aCapability.codecType)), + uint32_t(sizeof(codec) / sizeof(*codec) - 1))], + aDistance)); +} + bool MediaEngineCameraVideoSource::ChooseCapability( const MediaTrackConstraints &aConstraints, @@ -195,6 +238,7 @@ MediaEngineCameraVideoSource::ChooseCapability( webrtc::CaptureCapability cap; GetCapability(candidate.mIndex, cap); candidate.mDistance = GetFitnessDistance(cap, aConstraints, false, aDeviceId); + LogCapability("Capability", cap, candidate.mDistance); if (candidate.mDistance == UINT32_MAX) { candidateSet.RemoveElementAt(i); } else { @@ -234,6 +278,7 @@ MediaEngineCameraVideoSource::ChooseCapability( // Any remaining multiples all have the same distance. A common case of this // occurs when no ideal is specified. Lean toward defaults. + uint32_t sameDistance = candidateSet[0].mDistance; { MediaTrackConstraintSet prefs; prefs.mWidth.SetAsLong() = aPrefs.GetWidth(); @@ -268,9 +313,7 @@ MediaEngineCameraVideoSource::ChooseCapability( GetCapability(candidateSet[0].mIndex, mCapability); } - LOG(("chose cap %dx%d @%dfps codec %d raw %d", - mCapability.width, mCapability.height, mCapability.maxFPS, - mCapability.codecType, mCapability.rawType)); + LogCapability("Chosen capability", mCapability, sameDistance); return true; } diff --git a/dom/media/webrtc/MediaEngineCameraVideoSource.h b/dom/media/webrtc/MediaEngineCameraVideoSource.h index f5ce28d490db..8b822a88ad77 100644 --- a/dom/media/webrtc/MediaEngineCameraVideoSource.h +++ b/dom/media/webrtc/MediaEngineCameraVideoSource.h @@ -84,6 +84,9 @@ protected: static void TrimLessFitCandidates(CapabilitySet& set); static void LogConstraints(const dom::MediaTrackConstraintSet& aConstraints, bool aAdvanced); +static void LogCapability(const char* aHeader, + const webrtc::CaptureCapability &aCapability, + uint32_t aDistance); virtual size_t NumCapabilities(); virtual void GetCapability(size_t aIndex, webrtc::CaptureCapability& aOut); bool ChooseCapability(const dom::MediaTrackConstraints &aConstraints,