Bug 222166 - Update camera and microphone capture state control WKWebView API
Summary: Update camera and microphone capture state control WKWebView API
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-02-19 06:16 PST by youenn fablet
Modified: 2021-03-04 08:44 PST (History)
13 users (show)

See Also:


Attachments
Patch (50.00 KB, patch)
2021-02-19 06:27 PST, youenn fablet
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (49.71 KB, patch)
2021-02-19 06:33 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (49.73 KB, patch)
2021-02-19 08:23 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Rebasing (50.57 KB, patch)
2021-03-04 05:45 PST, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2021-02-19 06:16:44 PST
Update camera and microphone capture state control WKWebView API
Comment 1 youenn fablet 2021-02-19 06:27:28 PST
Created attachment 420961 [details]
Patch
Comment 2 youenn fablet 2021-02-19 06:33:03 PST
Created attachment 420962 [details]
Patch
Comment 3 youenn fablet 2021-02-19 08:23:57 PST
Created attachment 420971 [details]
Patch
Comment 4 Eric Carlson 2021-02-19 08:38:50 PST
Comment on attachment 420962 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=420962&action=review

> Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp:524
> +static inline bool trackMatchesKind(RealtimeMediaSource::Type type, MediaProducer::MediaCaptureKind kind)

Nit: `trackMatchesKind` is slightly awkward. Maybe `isKindOfTrack`, or `isTypeOfTrack` instead?

> Source/WebCore/page/MediaProducer.h:72
> +    enum class MediaCaptureKind {

Nit: `Kind` doesn't seem right. RealtimeMediaSource's `Type` is analogous, so how about `MediaCaptureType`?

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1741
> +    auto mutedState = _page->mutedStateFlags();

I think `pageMutedState` would make the logic easier to follow.

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1745
> +        mutedState = WebCore::MediaProducer::AudioCaptureIsMuted;

Don't you want to just add the muted flag:  `mutedState |= WebCore::MediaProducer::AudioCaptureIsMuted`?

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1747
> +    _page->setMuted(mutedState, [completionHandler = makeBlockPtr(completionHandler)] {
> +        completionHandler();

If the page microphone capture state is already already muted, why not just call the completion handler immediately and return?

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1766
> +    auto mutedState = _page->mutedStateFlags();
> +    if (state == _WKMediaCaptureStateActive && mutedState & WebCore::MediaProducer::VideoCaptureIsMuted)
> +        mutedState ^= WebCore::MediaProducer::VideoCaptureIsMuted;
> +    else if (state == _WKMediaCaptureStateMuted)
> +        mutedState = WebCore::MediaProducer::VideoCaptureIsMuted;
> +    _page->setMuted(mutedState, [completionHandler = makeBlockPtr(completionHandler)] {
> +        completionHandler();
> +    });

Ditto the comments above.

> Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm:159
> +void PageClientImplCocoa::microphoneCaptureChanged()
> +{
> +    [m_webView didChangeValueForKey:@"_microphoneCaptureState"];
> +}
> +
> +void PageClientImplCocoa::cameraCaptureChanged()

s/*CaptureChanged/*CaptureStateChanged/
Comment 5 Radar WebKit Bug Importer 2021-02-26 06:17:14 PST
<rdar://problem/74788059>
Comment 6 youenn fablet 2021-03-04 04:58:34 PST
Comment on attachment 420971 [details]
Patch

win failure unrelated
Comment 7 EWS 2021-03-04 04:59:22 PST
Tools/Scripts/svn-apply failed to apply attachment 420971 [details] to trunk.
Please resolve the conflicts and upload a new patch.
Comment 8 youenn fablet 2021-03-04 05:45:19 PST
Created attachment 422218 [details]
Rebasing
Comment 9 EWS 2021-03-04 08:44:21 PST
Committed r273891: <https://commits.webkit.org/r273891>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 422218 [details].