Bug 221608 - Split RemoteRealtimeMediaSource in two audio-specific and video-specific classes
Summary: Split RemoteRealtimeMediaSource in two audio-specific and video-specific classes
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-09 06:59 PST by youenn fablet
Modified: 2021-02-11 03:09 PST (History)
8 users (show)

See Also:


Attachments
Patch (71.11 KB, patch)
2021-02-09 07:02 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (70.96 KB, patch)
2021-02-09 08:48 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-09 06:59:39 PST
Split RemoteRealtimeMediaSource in two audio-specific and video-specific classes
Comment 1 youenn fablet 2021-02-09 07:02:53 PST
Created attachment 419711 [details]
Patch
Comment 2 youenn fablet 2021-02-09 08:48:24 PST
Created attachment 419725 [details]
Patch
Comment 3 Eric Carlson 2021-02-10 08:53:12 PST
Comment on attachment 419725 [details]
Patch

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

> Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp:131
> +void RemoteRealtimeAudioSource::whenReady(CompletionHandler<void(String)>&& callback)
> +{
> +    if (m_isReady)
> +        return callback(WTFMove(m_errorMessage));
> +    m_callback = WTFMove(callback);
> +}
> +
> +void RemoteRealtimeAudioSource::didFail(String&& errorMessage)
> +{
> +    m_isReady = true;
> +    m_errorMessage = WTFMove(errorMessage);
> +    if (m_callback)
> +        m_callback(m_errorMessage);
> +}
> +
> +void RemoteRealtimeAudioSource::setAsReady()
> +{
> +    m_isReady = true;
> +    if (m_callback)
> +        m_callback({ });
> +}
> +
> +void RemoteRealtimeAudioSource::setCapabilities(RealtimeMediaSourceCapabilities&& capabilities)
> +{
> +    m_capabilities = WTFMove(capabilities);
> +}
> +
> +void RemoteRealtimeAudioSource::setSettings(RealtimeMediaSourceSettings&& settings)
> +{
> +    auto changed = m_settings.difference(settings);
> +    m_settings = WTFMove(settings);
> +    notifySettingsDidChangeObservers(changed);
> +}
> +

These methods are identical in the Audio and Video classes, can they be moved into a base class?

> Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp:182
> +IPC::Connection* RemoteRealtimeAudioSource::connection()
> +{
> +    ASSERT(isMainThread());
> +#if ENABLE(GPU_PROCESS)
> +    if (m_shouldCaptureInGPUProcess)
> +        return &WebProcess::singleton().ensureGPUProcessConnection().connection();
> +#endif
> +    return WebProcess::singleton().parentProcessConnection();
> +}
> +
> +void RemoteRealtimeAudioSource::startProducingData()
> +{
> +    connection()->send(Messages::UserMediaCaptureManagerProxy::StartProducingData { m_identifier }, 0);
> +}
> +
> +void RemoteRealtimeAudioSource::stopProducingData()
> +{
> +    connection()->send(Messages::UserMediaCaptureManagerProxy::StopProducingData { m_identifier }, 0);
> +}
> +
> +const WebCore::RealtimeMediaSourceCapabilities& RemoteRealtimeAudioSource::capabilities()
> +{
> +    return m_capabilities;
> +}
> +
> +void RemoteRealtimeAudioSource::applyConstraints(const MediaConstraints& constraints, ApplyConstraintsHandler&& completionHandler)
> +{
> +    m_pendingApplyConstraintsCallbacks.append(WTFMove(completionHandler));
> +    // FIXME: Use sendAsyncWithReply.
> +    connection()->send(Messages::UserMediaCaptureManagerProxy::ApplyConstraints { m_identifier, constraints }, 0);
> +}
> +
> +void RemoteRealtimeAudioSource::applyConstraintsSucceeded(RealtimeMediaSourceSettings&& settings)
> +{
> +    setSettings(WTFMove(settings));
> +
> +    auto callback = m_pendingApplyConstraintsCallbacks.takeFirst();
> +    callback({ });
> +}
> +
> +void RemoteRealtimeAudioSource::applyConstraintsFailed(String&& failedConstraint, String&& errorMessage)
> +{
> +    auto callback = m_pendingApplyConstraintsCallbacks.takeFirst();
> +    callback(ApplyConstraintsError { WTFMove(failedConstraint), WTFMove(errorMessage) });
> +}

Ditto

> Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp:215
> +void RemoteRealtimeAudioSource::captureStopped()
> +{
> +    stop();
> +    hasEnded();
> +}
> +
> +void RemoteRealtimeAudioSource::captureFailed()
> +{
> +    RealtimeMediaSource::captureFailed();
> +    hasEnded();
> +}
> +
> +#if ENABLE(GPU_PROCESS)
> +void RemoteRealtimeAudioSource::gpuProcessConnectionDidClose(GPUProcessConnection&)
> +{
> +    ASSERT(m_shouldCaptureInGPUProcess);
> +    if (isEnded())
> +        return;
> +
> +    m_manager.remoteCaptureSampleManager().didUpdateSourceConnection(*this);
> +    createRemoteMediaSource();
> +    // FIXME: We should update the track according current settings.
> +    if (isProducingData())
> +        startProducingData();
> +}

Ditto.

> Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp:118
> +    if (auto source = m_audioSources.get(id))
>          source->captureStopped();
> +    else if (auto source = m_videoSources.get(id))
> +        source->captureStopped();

This pattern is used in enough places this it would be good to have a method that returned the source given an identifier.
Comment 4 youenn fablet 2021-02-11 03:02:49 PST
I will look at sharing more code in a follow-up patch since the plan is for RemoteRealtimeVideoSource to become a RealtimeVideoCaptureSource.
Comment 5 EWS 2021-02-11 03:08:27 PST
Committed r272719: <https://commits.webkit.org/r272719>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 419725 [details].
Comment 6 Radar WebKit Bug Importer 2021-02-11 03:09:25 PST
<rdar://problem/74227645>