Changeset 263623 in webkit


Ignore:
Timestamp:
Jun 27, 2020 9:20:26 AM (4 years ago)
Author:
youenn@apple.com
Message:

Log capture device information in case of getUserMedia failing to select a device
https://bugs.webkit.org/show_bug.cgi?id=213643

Reviewed by Eric Carlson.

Log constraints and device in case of a failing getUserMedia call.
No obserable change, logging addition.

  • platform/mediastream/mac/CoreAudioCaptureDevice.cpp:

(WebCore::getDeviceInfo):
(WebCore::CoreAudioCaptureDevice::deviceClock):

  • platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp:

(WebCore::isValidCaptureDevice):

  • platform/mediastream/MediaConstraints.cpp:

(WebCore::MediaConstraint::log const):
(WebCore::BooleanConstraint::logAsBoolean const):
(WebCore::DoubleConstraint::logAsDouble const):
(WebCore::IntConstraint::logAsInt const):

  • platform/mediastream/MediaConstraints.h:
  • platform/mediastream/RealtimeMediaSource.cpp:

(WebCore::RealtimeMediaSource::supportsSizeAndFrameRate):
(WebCore::RealtimeMediaSource::selectSettings):

  • platform/mediastream/RealtimeMediaSourceCenter.cpp:

(WebCore::RealtimeMediaSourceCenter::validateRequestConstraints):

  • platform/mediastream/RealtimeVideoCaptureSource.cpp:

(WebCore::RealtimeVideoCaptureSource::bestSupportedSizeAndFrameRate):

  • platform/mediastream/VideoPreset.h:

(WebCore::VideoPreset::log const):

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r263622 r263623  
     12020-06-27  Youenn Fablet  <youenn@apple.com>
     2
     3        Log capture device information in case of getUserMedia failing to select a device
     4        https://bugs.webkit.org/show_bug.cgi?id=213643
     5
     6        Reviewed by Eric Carlson.
     7
     8        Log constraints and device in case of a failing getUserMedia call.
     9        No obserable change, logging addition.
     10
     11        * platform/mediastream/mac/CoreAudioCaptureDevice.cpp:
     12        (WebCore::getDeviceInfo):
     13        (WebCore::CoreAudioCaptureDevice::deviceClock):
     14        * platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp:
     15        (WebCore::isValidCaptureDevice):
     16        * platform/mediastream/MediaConstraints.cpp:
     17        (WebCore::MediaConstraint::log const):
     18        (WebCore::BooleanConstraint::logAsBoolean const):
     19        (WebCore::DoubleConstraint::logAsDouble const):
     20        (WebCore::IntConstraint::logAsInt const):
     21        * platform/mediastream/MediaConstraints.h:
     22        * platform/mediastream/RealtimeMediaSource.cpp:
     23        (WebCore::RealtimeMediaSource::supportsSizeAndFrameRate):
     24        (WebCore::RealtimeMediaSource::selectSettings):
     25        * platform/mediastream/RealtimeMediaSourceCenter.cpp:
     26        (WebCore::RealtimeMediaSourceCenter::validateRequestConstraints):
     27        * platform/mediastream/RealtimeVideoCaptureSource.cpp:
     28        (WebCore::RealtimeVideoCaptureSource::bestSupportedSizeAndFrameRate):
     29        * platform/mediastream/VideoPreset.h:
     30        (WebCore::VideoPreset::log const):
     31
    1322020-06-27  Youenn Fablet  <youenn@apple.com>
    233
  • trunk/Source/WebCore/platform/mediastream/MediaConstraints.cpp

    r241489 r263623  
    405405    addDefaultVideoConstraints(mandatoryConstraints, needsFrameRateConstraints, needsSizeConstraints, needsFacingModeConstraints);
    406406}
    407    
     407
     408void MediaConstraint::log() const
     409{
     410    switch (dataType()) {
     411    case DataType::Boolean:
     412        downcast<const BooleanConstraint>(*this).logAsBoolean();
     413        break;
     414    case DataType::Double:
     415        downcast<const DoubleConstraint>(*this).logAsDouble();
     416        break;
     417    case DataType::Integer:
     418        downcast<const IntConstraint>(*this).logAsInt();
     419        break;
     420    case DataType::None:
     421    case DataType::String:
     422        WTFLogAlways("MediaConstraint %d of type %d", constraintType(), dataType());
     423    }
     424}
     425
     426void BooleanConstraint::logAsBoolean() const
     427{
     428    WTFLogAlways("BooleanConstraint %d, exact %d, ideal %d", constraintType(), m_exact ? *m_exact : -1, m_ideal ? *m_ideal : -1);
     429}
     430
     431void DoubleConstraint::logAsDouble() const
     432{
     433    WTFLogAlways("DoubleConstraint %d, min %f, max %f, exact %f, ideal %f", constraintType(), m_min ? *m_min : -1, m_max ? *m_max : -1, m_exact ? *m_exact : -1, m_ideal ? *m_ideal : -1);
     434}
     435
     436void IntConstraint::logAsInt() const
     437{
     438    WTFLogAlways("IntConstraint %d, min %d, max %d, exact %d, ideal %d", constraintType(), m_min ? *m_min : -1, m_max ? *m_max : -1, m_exact ? *m_exact : -1, m_ideal ? *m_ideal : -1);
     439}
     440
     441
    408442}
    409443
  • trunk/Source/WebCore/platform/mediastream/MediaConstraints.h

    r262994 r263623  
    7676    }
    7777
     78    void log() const;
     79
    7880protected:
    7981    MediaConstraint(const String& name, MediaConstraintType constraintType, DataType dataType)
     
    416418        NumericConstraint::innerMerge(downcast<const IntConstraint>(other));
    417419    }
     420
     421    void logAsInt() const;
    418422};
    419423
     
    432436        NumericConstraint::innerMerge(downcast<DoubleConstraint>(other));
    433437    }
     438
     439    void logAsDouble() const;
    434440};
    435441
     
    527533        return true;
    528534    }
     535
     536    void logAsBoolean() const;
    529537
    530538private:
  • trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp

    r262905 r263623  
    312312        double constraintDistance = fitnessDistance(*widthConstraint);
    313313        if (std::isinf(constraintDistance)) {
     314            auto range = capabilities.width();
     315            WTFLogAlways("RealtimeMediaSource::supportsSizeAndFrameRate failed width constraint, capabilities are [%d, %d]", range.rangeMin().asInt, range.rangeMax().asInt);
    314316            badConstraint = widthConstraint->name();
    315317            return false;
     
    327329        double constraintDistance = fitnessDistance(*heightConstraint);
    328330        if (std::isinf(constraintDistance)) {
     331            auto range = capabilities.height();
     332            WTFLogAlways("RealtimeMediaSource::supportsSizeAndFrameRate failed height constraint, capabilities are [%d, %d]", range.rangeMin().asInt, range.rangeMax().asInt);
    329333            badConstraint = heightConstraint->name();
    330334            return false;
     
    342346        double constraintDistance = fitnessDistance(*frameRateConstraint);
    343347        if (std::isinf(constraintDistance)) {
     348            auto range = capabilities.frameRate();
     349            WTFLogAlways("RealtimeMediaSource::supportsSizeAndFrameRate failed frame rate constraint, capabilities are [%d, %d]", range.rangeMin().asInt, range.rangeMax().asInt);
    344350            badConstraint = frameRateConstraint->name();
    345351            return false;
     
    662668        return false;
    663669
    664     constraints.mandatoryConstraints.filter([&](const MediaConstraint& constraint) {
     670    constraints.mandatoryConstraints.filter([&](auto& constraint) {
    665671        if (!supportsConstraint(constraint))
    666672            return false;
     
    673679        double constraintDistance = fitnessDistance(constraint);
    674680        if (std::isinf(constraintDistance)) {
     681            WTFLogAlways("RealtimeMediaSource::selectSettings failed constraint %d", constraint.constraintType());
    675682            failedConstraint = constraint.name();
    676683            return true;
  • trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp

    r261373 r263623  
    247247        getUserMediaDevices(request, String { deviceIdentifierHashSalt }, audioDeviceInfo, videoDeviceInfo, firstInvalidConstraint);
    248248
    249     if ((request.audioConstraints.isValid && audioDeviceInfo.isEmpty()) || (request.videoConstraints.isValid && videoDeviceInfo.isEmpty())) {
     249    if (request.audioConstraints.isValid && audioDeviceInfo.isEmpty()) {
     250        WTFLogAlways("Audio capture was requested but no device was found amongst %zu devices", audioCaptureFactory().audioCaptureDeviceManager().captureDevices().size());
     251        request.audioConstraints.mandatoryConstraints.forEach([](auto& constraint) { constraint.log(); });
     252
     253        invalidHandler(firstInvalidConstraint);
     254        return;
     255    }
     256
     257    if (request.videoConstraints.isValid && videoDeviceInfo.isEmpty()) {
     258        WTFLogAlways("Video capture was requested but no device was found amongst %zu devices", videoCaptureFactory().videoCaptureDeviceManager().captureDevices().size());
     259        request.videoConstraints.mandatoryConstraints.forEach([](auto& constraint) { constraint.log(); });
     260
    250261        invalidHandler(firstInvalidConstraint);
    251262        return;
  • trunk/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.cpp

    r260364 r263623  
    330330    }
    331331
    332     if (!exactSizePreset && !aspectRatioPreset && !resizePreset)
     332    if (!exactSizePreset && !aspectRatioPreset && !resizePreset) {
     333        WTFLogAlways("RealtimeVideoCaptureSource::bestSupportedSizeAndFrameRate failed supporting constraints %d %d %f", requestedWidth ? *requestedWidth : -1, requestedHeight ? *requestedHeight : -1, requestedFrameRate ? *requestedFrameRate : -1);
     334        for (const auto& preset : presets())
     335            preset->log();
     336
    333337        return { };
     338    }
    334339
    335340    result.requestedFrameRate = requestedFrameRate.value();
  • trunk/Source/WebCore/platform/mediastream/VideoPreset.h

    r244704 r263623  
    115115    VideoPresetType type;
    116116
     117    void log()const;
     118
    117119protected:
    118120    VideoPreset(IntSize size, Vector<FrameRateRange>&& frameRateRanges, VideoPresetType type)
     
    124126};
    125127
     128inline void VideoPreset::log() const
     129{
     130    WTFLogAlways("VideoPreset of size (%d,%d) and type %d", size.width(), size.height(), type);
     131    for (auto range : frameRateRanges)
     132        WTFLogAlways("VideoPreset frame rate range [%f, %f]", range.minimum, range.maximum);
     133}
     134
    126135} // namespace WebCore
    127136
  • trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDevice.cpp

    r239427 r263623  
    4646    auto err = AudioObjectGetPropertyData(static_cast<UInt32>(deviceID), &address, 0, nullptr, &dataSize, &uniqueID);
    4747    if (err) {
    48         LOG(Media, "CoreAudioCaptureDevice::getDeviceInfo failed to get device unique id with error %d (%.4s)", (int)err, (char*)&err);
     48        RELEASE_LOG_ERROR(WebRTC, "CoreAudioCaptureDevice::getDeviceInfo failed to get device unique id with error %d (%.4s)", (int)err, (char*)&err);
    4949        return false;
    5050    }
     
    5757    err = AudioObjectGetPropertyData(static_cast<UInt32>(deviceID), &address, 0, nullptr, &dataSize, &localizedName);
    5858    if (err) {
    59         LOG(Media, "CoreAudioCaptureDevice::getDeviceInfo failed to get device name with error %d (%.4s)", (int)err, (char*)&err);
     59        RELEASE_LOG_ERROR(WebRTC, "CoreAudioCaptureDevice::getDeviceInfo failed to get device name with error %d (%.4s)", (int)err, (char*)&err);
    6060        return false;
    6161    }
     
    9090    auto err = CMAudioDeviceClockCreate(kCFAllocatorDefault, persistentId().createCFString().get(), &clock);
    9191    if (err) {
    92         LOG(Media, "CoreAudioCaptureDevice::CMAudioDeviceClockCreate(%p) CMAudioDeviceClockCreate failed with error %d (%.4s)", this, (int)err, (char*)&err);
     92        RELEASE_LOG_ERROR(WebRTC, "CoreAudioCaptureDevice::CMAudioDeviceClockCreate(%p) CMAudioDeviceClockCreate failed with error %d (%.4s)", this, (int)err, (char*)&err);
    9393        return nullptr;
    9494    }
  • trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp

    r258478 r263623  
    8585    // Ignore output devices that have input only for echo cancellation.
    8686    AudioObjectPropertyAddress address = { kAudioDevicePropertyTapEnabled, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
    87     if (AudioObjectHasProperty(device.deviceID(), &address))
    88         return false;
     87    if (AudioObjectHasProperty(device.deviceID(), &address)) {
     88        RELEASE_LOG(WebRTC, "Ignoring output device that have input only for echo cancellation");
     89        return false;
     90    }
    8991
    9092    // Ignore non-aggregable devices.
     
    9799    if (name)
    98100        CFRelease(name);
    99     if (isNonAggregable)
    100         return false;
     101    if (isNonAggregable) {
     102        RELEASE_LOG(WebRTC, "Ignoring output device that is non aggregable");
     103        return false;
     104    }
    101105
    102106    // Ignore unnamed devices and aggregate devices created by VPIO.
    103     return !device.label().isEmpty() && !device.label().startsWith("VPAUAggregateAudioDevice");
     107    if (device.label().isEmpty()) {
     108        RELEASE_LOG(WebRTC, "Ignoring output device that is unnamed");
     109        return false;
     110    }
     111
     112    if (device.label().startsWith("VPAUAggregateAudioDevice")) {
     113        RELEASE_LOG(WebRTC, "Ignoring output VPAUAggregateAudioDevice device");
     114        return false;
     115    }
     116
     117    return true;
    104118}
    105119
Note: See TracChangeset for help on using the changeset viewer.