Source/WebCore/ChangeLog

 12020-01-07 youenn fablet <youenn@apple.com>
 2
 3 Implement MediaRecorder backend in GPUProcess
 4 https://bugs.webkit.org/show_bug.cgi?id=205802
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Add a page provider to create MediaRecorderPrivate implementations.
 9 This is used by WebKit layer to implement this in GPUProcess.
 10
 11 Update MediaRecorderPrivate by adding an error callback that is used to surface errors as MediaRecorder error events.
 12
 13 Covered by existing tests as MediaRecorder implementation in WebKitTestRunner will use GPUProcess.
 14
 15 * Headers.cmake:
 16 * Modules/mediarecorder/MediaRecorder.cpp:
 17 (WebCore::MediaRecorder::create):
 18 (WebCore::MediaRecorder::createMediaRecorderPrivate):
 19 * Modules/mediarecorder/MediaRecorder.h:
 20 * Modules/mediarecorder/MediaRecorderProvider.cpp: Added.
 21 (WebCore::MediaRecorderProvider::createMediaRecorderPrivate):
 22 * Modules/mediarecorder/MediaRecorderProvider.h: Added.
 23 * Sources.txt:
 24 * WebCore.xcodeproj/project.pbxproj:
 25 * loader/EmptyClients.cpp:
 26 (WebCore::pageConfigurationWithEmptyClients):
 27 * page/Page.cpp:
 28 (WebCore::Page::Page):
 29 * page/Page.h:
 30 (WebCore::Page::mediaRecorderProvider):
 31 * page/PageConfiguration.cpp:
 32 (WebCore::PageConfiguration::PageConfiguration):
 33 * page/PageConfiguration.h:
 34 * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
 35 * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
 36 (WebCore::MediaRecorderPrivateWriter::create):
 37 * platform/mediastream/MediaStreamPrivate.h:
 38 * platform/mediastream/MediaStreamTrackPrivate.h:
 39 * testing/Internals.cpp:
 40 (WebCore::Internals::resetToConsistentState):
 41 (WebCore::Internals::setUseGPUProcessForWebRTC):
 42
1432020-01-07 Carlos Garcia Campos <cgarcia@igalia.com>
244
345 [GTK][WPE] Add API to set purpose and hints of active editable element to input methods

Source/WebKit/ChangeLog

 12020-01-07 youenn fablet <youenn@apple.com>
 2
 3 Implement MediaRecorder backend in GPUProcess
 4 https://bugs.webkit.org/show_bug.cgi?id=205802
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Add support for sending audio/video tracks to record from WebProcess to GPUProcess.
 9 Add a MediaRecorderPrivate implementation that supports sending one audio track and/or one video track to GPUProcess
 10 and stopping/fetching data from the remote recorder in GPUProcess.
 11
 12 In GPUProcess, implement the remote recorder using the existing WebCore recorder writer.
 13
 14 * CMakeLists.txt:
 15 * DerivedSources-input.xcfilelist:
 16 * DerivedSources-output.xcfilelist:
 17 * DerivedSources.make:
 18 * GPUProcess/GPUConnectionToWebProcess.cpp:
 19 (WebKit::GPUConnectionToWebProcess::userMediaCaptureManagerProxy):
 20 (WebKit::GPUConnectionToWebProcess::mediaRecorders):
 21 (WebKit::GPUConnectionToWebProcess::didReceiveMessage):
 22 * GPUProcess/GPUConnectionToWebProcess.h:
 23 * GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in:
 24 * GPUProcess/webrtc/RemoteMediaRecorder.cpp: Added.
 25 (WebKit::RemoteMediaRecorder::create):
 26 (WebKit::RemoteMediaRecorder::RemoteMediaRecorder):
 27 (WebKit::RemoteMediaRecorder::~RemoteMediaRecorder):
 28 (WebKit::RemoteMediaRecorder::storage):
 29 (WebKit::RemoteMediaRecorder::audioSamplesStorageChanged):
 30 (WebKit::RemoteMediaRecorder::audioSamplesAvailable):
 31 (WebKit::RemoteMediaRecorder::videoSampleAvailable):
 32 (WebKit::RemoteMediaRecorder::fetchData):
 33 (WebKit::RemoteMediaRecorder::stopRecording):
 34 * GPUProcess/webrtc/RemoteMediaRecorder.h: Added.
 35 * GPUProcess/webrtc/RemoteMediaRecorder.messages.in: Added.
 36 * GPUProcess/webrtc/RemoteMediaRecorders.cpp: Added.
 37 (WebKit::RemoteMediaRecorders::RemoteMediaRecorders):
 38 (WebKit::RemoteMediaRecorders::~RemoteMediaRecorders):
 39 (WebKit::RemoteMediaRecorders::didReceiveRemoteMediaRecorderMessage):
 40 (WebKit::RemoteMediaRecorders::createRecorder):
 41 (WebKit::RemoteMediaRecorders::releaseRecorder):
 42 * GPUProcess/webrtc/RemoteMediaRecorders.h: Added.
 43 (WebKit::RemoteMediaRecorders::didReceiveMessageFromWebProcess):
 44 * GPUProcess/webrtc/RemoteMediaRecorders.messages.in: Added.
 45 * Scripts/webkit/messages.py:
 46 * Sources.txt:
 47 * SourcesCocoa.txt:
 48 * WebKit.xcodeproj/project.pbxproj:
 49 * WebProcess/GPU/media/MediaRecorderProvider.cpp: Added.
 50 (WebCore::MediaRecorderProvider::createMediaRecorderPrivate):
 51 * WebProcess/GPU/media/MediaRecorderProvider.h: Added.
 52 * WebProcess/GPU/webrtc/MediaRecorderIdentifier.h: Added.
 53 * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: Added.
 54 (WebKit::MediaRecorderPrivate::MediaRecorderPrivate):
 55 (WebKit::MediaRecorderPrivate::~MediaRecorderPrivate):
 56 (WebKit::MediaRecorderPrivate::sampleBufferUpdated):
 57 (WebKit::MediaRecorderPrivate::audioSamplesAvailable):
 58 (WebKit::MediaRecorderPrivate::storageChanged):
 59 (WebKit::MediaRecorderPrivate::fetchData):
 60 (WebKit::MediaRecorderPrivate::stopRecording):
 61 * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: Added.
 62 * WebProcess/GPU/webrtc/MediaRecorderProvider.cpp: Added.
 63 (WebKit::MediaRecorderProvider::createMediaRecorderPrivate):
 64 * WebProcess/GPU/webrtc/MediaRecorderProvider.h: Added.
 65 * WebProcess/WebPage/WebPage.cpp:
 66 (WebKit::m_overriddenMediaType):
 67
1682020-01-07 Carlos Garcia Campos <cgarcia@igalia.com>
269
370 [GTK][WPE] Add API to retrieve and delete surrounding text for input methods

Source/WebKitLegacy/mac/ChangeLog

 12020-01-07 youenn fablet <youenn@apple.com>
 2
 3 Implement MediaRecorder backend in GPUProcess
 4 https://bugs.webkit.org/show_bug.cgi?id=205802
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * WebView/WebView.mm:
 9 (-[WebView _commonInitializationWithFrameName:groupName:]):
 10 (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
 11
1122020-01-07 Carlos Garcia Campos <cgarcia@igalia.com>
213
314 [GTK][WPE] Add API to set purpose and hints of active editable element to input methods

Source/WebKitLegacy/win/ChangeLog

 12020-01-07 youenn fablet <youenn@apple.com>
 2
 3 Implement MediaRecorder backend in GPUProcess
 4 https://bugs.webkit.org/show_bug.cgi?id=205802
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * WebView.cpp:
 9 (WebView::initWithFrame):
 10
1112020-01-07 Carlos Garcia Campos <cgarcia@igalia.com>
212
313 [GTK][WPE] Add API to set purpose and hints of active editable element to input methods

Source/WebCore/Headers.cmake

@@set(WebCore_PRIVATE_FRAMEWORK_HEADERS
8080 Modules/indexeddb/shared/IDBResultData.h
8181 Modules/indexeddb/shared/IDBTransactionInfo.h
8282
 83 Modules/mediarecorder/MediaRecorderProvider.h
 84
8385 Modules/mediasession/MediaSessionEvents.h
8486 Modules/mediasession/MediaSessionMetadata.h
8587 Modules/mediasession/WebMediaSessionManager.h

@@set(WebCore_PRIVATE_FRAMEWORK_HEADERS
11551157 platform/graphics/transforms/TransformOperations.h
11561158 platform/graphics/transforms/TransformationMatrix.h
11571159
 1160 platform/mediarecorder/MediaRecorderPrivate.h
 1161
11581162 platform/mediastream/CaptureDevice.h
11591163 platform/mediastream/CaptureDeviceManager.h
11601164 platform/mediastream/MediaConstraints.h

Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp

3434#include "EventNames.h"
3535#include "MediaRecorderErrorEvent.h"
3636#include "MediaRecorderPrivate.h"
 37#include "MediaRecorderProvider.h"
 38#include "Page.h"
3739#include "SharedBuffer.h"
3840#include "WindowEventLoop.h"
3941#include <wtf/IsoMallocInlines.h>

@@creatorFunction MediaRecorder::m_customCreator = nullptr;
5052
5153ExceptionOr<Ref<MediaRecorder>> MediaRecorder::create(Document& document, Ref<MediaStream>&& stream, Options&& options)
5254{
53  auto privateInstance = MediaRecorder::getPrivateImpl(stream->privateStream());
 55 auto privateInstance = MediaRecorder::createMediaRecorderPrivate(document, stream->privateStream());
5456 if (!privateInstance)
5557 return Exception { NotSupportedError, "The MediaRecorder is unsupported on this platform"_s };
5658 auto recorder = adoptRef(*new MediaRecorder(document, WTFMove(stream), WTFMove(privateInstance), WTFMove(options)));
5759 recorder->suspendIfNeeded();
 60 recorder->m_private->setErrorCallback([recorder = recorder.copyRef()](auto&& exception) mutable {
 61 recorder->dispatchError(WTFMove(*exception));
 62 });
5863 return recorder;
5964}
6065

@@void MediaRecorder::setCustomPrivateRecorderCreator(creatorFunction creator)
6368 m_customCreator = creator;
6469}
6570
66 std::unique_ptr<MediaRecorderPrivate> MediaRecorder::getPrivateImpl(const MediaStreamPrivate& stream)
 71std::unique_ptr<MediaRecorderPrivate> MediaRecorder::createMediaRecorderPrivate(Document& document, const MediaStreamPrivate& stream)
6772{
6873 if (m_customCreator)
6974 return m_customCreator();
7075
71 #if PLATFORM(COCOA)
72  return MediaRecorderPrivateAVFImpl::create(stream);
73 #else
74  UNUSED_PARAM(stream);
75  return nullptr;
76 #endif
 76 auto* page = document.page();
 77 if (!page)
 78 return nullptr;
 79
 80 return page->mediaRecorderProvider().createMediaRecorderPrivate(stream);
7781}
7882
7983MediaRecorder::MediaRecorder(Document& document, Ref<MediaStream>&& stream, std::unique_ptr<MediaRecorderPrivate>&& privateImpl, Options&& option)

@@void MediaRecorder::didAddOrRemoveTrack()
182186 if (!m_isActive || state() == RecordingState::Inactive)
183187 return;
184188 stopRecordingInternal();
185  auto event = MediaRecorderErrorEvent::create(eventNames().errorEvent, Exception { UnknownError, "Track cannot be added to or removed from the MediaStream while recording is happening"_s });
186  dispatchEvent(WTFMove(event));
 189 dispatchError(Exception { UnknownError, "Track cannot be added to or removed from the MediaStream while recording is happening"_s });
187190 });
188191}
189192
 193void MediaRecorder::dispatchError(Exception&& exception)
 194{
 195 if (!m_isActive)
 196 return;
 197 dispatchEvent(MediaRecorderErrorEvent::create(eventNames().errorEvent, WTFMove(exception)));
 198}
 199
190200void MediaRecorder::trackEnded(MediaStreamTrackPrivate&)
191201{
192202 auto position = m_tracks.findMatching([](auto& track) {

Source/WebCore/Modules/mediarecorder/MediaRecorder.h

@@public:
7171
7272 ExceptionOr<void> startRecording(Optional<int>);
7373 ExceptionOr<void> stopRecording();
74 
 74
7575private:
7676 MediaRecorder(Document&, Ref<MediaStream>&&, std::unique_ptr<MediaRecorderPrivate>&&, Options&& = { });
7777
78  static std::unique_ptr<MediaRecorderPrivate> getPrivateImpl(const MediaStreamPrivate&);
 78 static std::unique_ptr<MediaRecorderPrivate> createMediaRecorderPrivate(Document&, const MediaStreamPrivate&);
7979
8080 Document* document() const;
8181

@@private:
9191 const char* activeDOMObjectName() const final;
9292
9393 void stopRecordingInternal();
94 
 94
 95 void dispatchError(Exception&&);
 96
9597 // MediaStream::Observer
9698 void didAddOrRemoveTrack() final;
9799

Source/WebCore/Modules/mediarecorder/MediaRecorderProvider.cpp

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "MediaRecorderProvider.h"
 28
 29#include "MediaRecorderPrivate.h"
 30
 31#if PLATFORM(COCOA)
 32#include "MediaRecorderPrivateAVFImpl.h"
 33#endif
 34
 35namespace WebCore {
 36
 37#if ENABLE(MEDIA_STREAM)
 38std::unique_ptr<MediaRecorderPrivate> MediaRecorderProvider::createMediaRecorderPrivate(const MediaStreamPrivate& stream)
 39{
 40#if PLATFORM(COCOA)
 41 return MediaRecorderPrivateAVFImpl::create(stream);
 42#else
 43 UNUSED_PARAM(stream);
 44 return nullptr;
 45#endif
 46}
 47#endif
 48
 49}

Source/WebCore/Modules/mediarecorder/MediaRecorderProvider.h

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28namespace WebCore {
 29
 30class MediaRecorderPrivate;
 31class MediaStreamPrivate;
 32
 33class WEBCORE_EXPORT MediaRecorderProvider {
 34 WTF_MAKE_FAST_ALLOCATED;
 35public:
 36 MediaRecorderProvider() = default;
 37 virtual ~MediaRecorderProvider() = default;
 38
 39#if ENABLE(MEDIA_STREAM)
 40 virtual std::unique_ptr<MediaRecorderPrivate> createMediaRecorderPrivate(const MediaStreamPrivate&);
 41#endif
 42
 43 void setUseGPUProcess(bool value) { m_useGPUProcess = value; }
 44
 45protected:
 46 bool m_useGPUProcess { false };
 47};
 48
 49}

Source/WebCore/Sources.txt

@@Modules/mediacontrols/MediaControlsHost.cpp
151151
152152Modules/mediarecorder/BlobEvent.cpp
153153Modules/mediarecorder/MediaRecorder.cpp
 154Modules/mediarecorder/MediaRecorderProvider.cpp
154155Modules/mediarecorder/MediaRecorderErrorEvent.cpp
155156
156157Modules/mediasession/HTMLMediaElementMediaSession.cpp

Source/WebCore/WebCore.xcodeproj/project.pbxproj

11011101 417612B01E3A994000C3D81D /* LibWebRTCMediaEndpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 417612AC1E3A993B00C3D81D /* LibWebRTCMediaEndpoint.h */; };
11021102 417612B11E3A994000C3D81D /* LibWebRTCPeerConnectionBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 417612AD1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.cpp */; };
11031103 417612B21E3A994000C3D81D /* LibWebRTCPeerConnectionBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 417612AE1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.h */; };
 1104 4176E89623C3537B003E83FE /* MediaRecorderProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 4176E88F23C348D2003E83FE /* MediaRecorderProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
11041105 417DA6D913734E6E007C57FB /* Internals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 417DA4CF13734326007C57FB /* Internals.cpp */; };
11051106 417DA6DA13734E6E007C57FB /* Internals.h in Headers */ = {isa = PBXBuildFile; fileRef = 417DA4CE13734326007C57FB /* Internals.h */; };
11061107 417DA71D13735DFA007C57FB /* JSInternals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 417DA71B13735DFA007C57FB /* JSInternals.cpp */; };

13741375 4BDEA32C218033EB0052DFCD /* JSWorkletGlobalScopeBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDEA32B218033EB0052DFCD /* JSWorkletGlobalScopeBase.h */; };
13751376 4D3B00AB215D69A70076B983 /* MediaRecorder.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D3B00A9215D69A70076B983 /* MediaRecorder.h */; };
13761377 4D3B00AF215D6A690076B983 /* BlobEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D3B00AD215D6A690076B983 /* BlobEvent.h */; };
1377  4D3B5016217E58B700665DB1 /* MediaRecorderPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D3B5014217E58B700665DB1 /* MediaRecorderPrivate.h */; };
 1378 4D3B5016217E58B700665DB1 /* MediaRecorderPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D3B5014217E58B700665DB1 /* MediaRecorderPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
13781379 4D73F946218BC5FA003A3ED6 /* MediaRecorderPrivateAVFImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D73F944218BC5FA003A3ED6 /* MediaRecorderPrivateAVFImpl.h */; };
1379  4D73F94E218C4A87003A3ED6 /* MediaRecorderPrivateWriterCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D73F94C218C4A87003A3ED6 /* MediaRecorderPrivateWriterCocoa.h */; };
 1380 4D73F94E218C4A87003A3ED6 /* MediaRecorderPrivateWriterCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D73F94C218C4A87003A3ED6 /* MediaRecorderPrivateWriterCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
13801381 4DB7130D216ECB4D0096A4DD /* MediaRecorderErrorEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DB7130C216EC2BD0096A4DD /* MediaRecorderErrorEvent.h */; };
13811382 4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */; settings = {ATTRIBUTES = (Private, ); }; };
13821383 4E19592A0A39DACC00220FE5 /* MediaQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959240A39DACC00220FE5 /* MediaQuery.h */; settings = {ATTRIBUTES = (Private, ); }; };

73997400 417612AE1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCPeerConnectionBackend.h; path = libwebrtc/LibWebRTCPeerConnectionBackend.h; sourceTree = "<group>"; };
74007401 4176900322FCD8F200B1576D /* MediaSourceRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourceRegistry.h; sourceTree = "<group>"; };
74017402 4176900422FCD8F200B1576D /* MediaSourceRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSourceRegistry.cpp; sourceTree = "<group>"; };
 7403 4176E88F23C348D2003E83FE /* MediaRecorderProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaRecorderProvider.h; sourceTree = "<group>"; };
 7404 4176E89123C34B75003E83FE /* MediaRecorderProvider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaRecorderProvider.cpp; sourceTree = "<group>"; };
74027405 4177F51C2382544000C04486 /* BaseAudioSharedUnit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseAudioSharedUnit.cpp; sourceTree = "<group>"; };
74037406 4177F51E2382545E00C04486 /* BaseAudioSharedUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseAudioSharedUnit.h; sourceTree = "<group>"; };
74047407 417DA4CE13734326007C57FB /* Internals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Internals.h; sourceTree = "<group>"; };

1893218935 4DB7130E216EEBAE0096A4DD /* MediaRecorderErrorEvent.cpp */,
1893318936 4DB7130C216EC2BD0096A4DD /* MediaRecorderErrorEvent.h */,
1893418937 4DB7130A216EC2BC0096A4DD /* MediaRecorderErrorEvent.idl */,
 18938 4176E89123C34B75003E83FE /* MediaRecorderProvider.cpp */,
 18939 4176E88F23C348D2003E83FE /* MediaRecorderProvider.h */,
1893518940 );
1893618941 path = mediarecorder;
1893718942 sourceTree = "<group>";

3147431479 4D3B5016217E58B700665DB1 /* MediaRecorderPrivate.h in Headers */,
3147531480 4D73F946218BC5FA003A3ED6 /* MediaRecorderPrivateAVFImpl.h in Headers */,
3147631481 4D73F94E218C4A87003A3ED6 /* MediaRecorderPrivateWriterCocoa.h in Headers */,
 31482 4176E89623C3537B003E83FE /* MediaRecorderProvider.h in Headers */,
3147731483 C90843D01B18E47D00B68564 /* MediaRemoteControls.h in Headers */,
3147831484 CD8ACA8F1D23971900ECC59E /* MediaRemoteSoftLink.h in Headers */,
3147931485 CEEFCD7A19DB31F7003876D7 /* MediaResourceLoader.h in Headers */,

Source/WebCore/loader/EmptyClients.cpp

5353#include "IDBConnectionToServer.h"
5454#include "InspectorClient.h"
5555#include "LibWebRTCProvider.h"
 56#include "MediaRecorderPrivate.h"
 57#include "MediaRecorderProvider.h"
5658#include "NetworkStorageSession.h"
5759#include "Page.h"
5860#include "PageConfiguration.h"

@@Ref<StorageNamespace> EmptyStorageNamespaceProvider::createTransientLocalStorage
571573 return adoptRef(*new EmptyStorageNamespace { sessionID });
572574}
573575
574 class EmptyStorageSessionProvider : public StorageSessionProvider {
 576class EmptyStorageSessionProvider final : public StorageSessionProvider {
575577 NetworkStorageSession* storageSession() const final { return nullptr; }
576578};
577579
 580class EmptyMediaRecorderProvider final : public MediaRecorderProvider {
 581public:
 582 EmptyMediaRecorderProvider() = default;
 583private:
 584#if ENABLE(MEDIA_STREAM)
 585 std::unique_ptr<MediaRecorderPrivate> createMediaRecorderPrivate(const MediaStreamPrivate&) final { return nullptr; }
 586#endif
 587};
 588
578589PageConfiguration pageConfigurationWithEmptyClients(PAL::SessionID sessionID)
579590{
580591 PageConfiguration pageConfiguration {

@@PageConfiguration pageConfigurationWithEmptyClients(PAL::SessionID sessionID)
585596 CacheStorageProvider::create(),
586597 adoptRef(*new EmptyBackForwardClient),
587598 CookieJar::create(adoptRef(*new EmptyStorageSessionProvider)),
588  makeUniqueRef<EmptyProgressTrackerClient>()
 599 makeUniqueRef<EmptyProgressTrackerClient>(),
 600 makeUniqueRef<EmptyMediaRecorderProvider>()
589601 };
590602
591603 static NeverDestroyed<EmptyChromeClient> dummyChromeClient;

Source/WebCore/page/Page.cpp

@@Page::Page(PageConfiguration&& pageConfiguration)
246246#if ENABLE(SPEECH_SYNTHESIS)
247247 , m_speechSynthesisClient(WTFMove(pageConfiguration.speechSynthesisClient))
248248#endif
 249 , m_mediaRecorderProvider((WTFMove(pageConfiguration.mediaRecorderProvider)))
249250 , m_libWebRTCProvider(WTFMove(pageConfiguration.libWebRTCProvider))
250251 , m_verticalScrollElasticity(ScrollElasticityAllowed)
251252 , m_horizontalScrollElasticity(ScrollElasticityAllowed)

Source/WebCore/page/Page.h

@@class LibWebRTCProvider;
110110class LowPowerModeNotifier;
111111class MediaCanStartListener;
112112class MediaPlaybackTarget;
 113class MediaRecorderProvider;
113114class PageConfiguration;
114115class PageConsoleClient;
115116class PageDebuggable;

@@public:
584585 DatabaseProvider& databaseProvider() { return m_databaseProvider; }
585586 CacheStorageProvider& cacheStorageProvider() { return m_cacheStorageProvider; }
586587 SocketProvider& socketProvider() { return m_socketProvider; }
 588 MediaRecorderProvider& mediaRecorderProvider() { return m_mediaRecorderProvider; }
587589 CookieJar& cookieJar() { return m_cookieJar.get(); }
588590
589591 StorageNamespaceProvider& storageNamespaceProvider() { return m_storageNamespaceProvider.get(); }

@@private:
795797 std::unique_ptr<SpeechSynthesisClient> m_speechSynthesisClient;
796798#endif
797799
 800 UniqueRef<MediaRecorderProvider> m_mediaRecorderProvider;
798801 UniqueRef<LibWebRTCProvider> m_libWebRTCProvider;
799802 RTCController m_rtcController;
800803

@@private:
920923 Ref<UserContentProvider> m_userContentProvider;
921924 Ref<VisitedLinkStore> m_visitedLinkStore;
922925 RefPtr<WheelEventTestMonitor> m_wheelEventTestMonitor;
923 
924926 HashSet<ActivityStateChangeObserver*> m_activityStateChangeObservers;
925927
926928#if ENABLE(RESOURCE_USAGE)

Source/WebCore/page/PageConfiguration.cpp

3636#include "DragClient.h"
3737#include "EditorClient.h"
3838#include "LibWebRTCProvider.h"
 39#include "MediaRecorderProvider.h"
3940#include "PerformanceLoggingClient.h"
4041#include "PlugInClient.h"
4142#include "PluginInfoProvider.h"

5556
5657namespace WebCore {
5758
58 PageConfiguration::PageConfiguration(PAL::SessionID sessionID, UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider, Ref<BackForwardClient>&& backForwardClient, Ref<CookieJar>&& cookieJar, UniqueRef<ProgressTrackerClient>&& progressTrackerClient)
 59PageConfiguration::PageConfiguration(PAL::SessionID sessionID, UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider, Ref<BackForwardClient>&& backForwardClient, Ref<CookieJar>&& cookieJar, UniqueRef<ProgressTrackerClient>&& progressTrackerClient, UniqueRef<MediaRecorderProvider>&& mediaRecorderProvider)
5960 : sessionID(sessionID)
6061 , editorClient(WTFMove(editorClient))
6162 , socketProvider(WTFMove(socketProvider))

@@PageConfiguration::PageConfiguration(PAL::SessionID sessionID, UniqueRef<EditorC
6465 , backForwardClient(WTFMove(backForwardClient))
6566 , cookieJar(WTFMove(cookieJar))
6667 , cacheStorageProvider(WTFMove(cacheStorageProvider))
 68 , mediaRecorderProvider(WTFMove(mediaRecorderProvider))
6769{
6870}
6971

Source/WebCore/page/PageConfiguration.h

@@class EditorClient;
5252class FrameLoaderClient;
5353class InspectorClient;
5454class LibWebRTCProvider;
 55class MediaRecorderProvider;
5556class PaymentCoordinatorClient;
5657class PerformanceLoggingClient;
5758class PlugInClient;

@@class SpeechSynthesisClient;
6869class PageConfiguration {
6970 WTF_MAKE_NONCOPYABLE(PageConfiguration); WTF_MAKE_FAST_ALLOCATED;
7071public:
71  WEBCORE_EXPORT PageConfiguration(PAL::SessionID, UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&, Ref<BackForwardClient>&&, Ref<CookieJar>&&, UniqueRef<ProgressTrackerClient>&&);
 72 WEBCORE_EXPORT PageConfiguration(PAL::SessionID, UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&, Ref<BackForwardClient>&&, Ref<CookieJar>&&, UniqueRef<ProgressTrackerClient>&&, UniqueRef<MediaRecorderProvider>&&);
7273 WEBCORE_EXPORT ~PageConfiguration();
7374 PageConfiguration(PageConfiguration&&);
7475

@@public:
123124 RefPtr<DeviceOrientationUpdateProvider> deviceOrientationUpdateProvider;
124125#endif
125126 Vector<String> corsDisablingPatterns;
 127 UniqueRef<MediaRecorderProvider> mediaRecorderProvider;
126128};
127129
128130}

Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h

2626
2727#include <wtf/CompletionHandler.h>
2828#include <wtf/Forward.h>
 29#include "Exception.h"
2930
3031#if ENABLE(MEDIA_STREAM)
3132

@@class SharedBuffer;
4344
4445class MediaRecorderPrivate {
4546public:
46  virtual void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample&) = 0;
47  virtual void audioSamplesAvailable(MediaStreamTrackPrivate&, const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) = 0;
 47 virtual ~MediaRecorderPrivate() = default;
 48
 49 virtual void sampleBufferUpdated(const MediaStreamTrackPrivate&, MediaSample&) = 0;
 50 virtual void audioSamplesAvailable(const MediaStreamTrackPrivate&, const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) = 0;
4851
4952 virtual void fetchData(CompletionHandler<void(RefPtr<SharedBuffer>&&, const String& mimeType)>&&) = 0;
50  virtual ~MediaRecorderPrivate() = default;
51  virtual void stopRecording() { }
 53 virtual void stopRecording() { };
 54
 55 using ErrorCallback = Function<void(Optional<Exception>&&)>;
 56 void setErrorCallback(ErrorCallback&& errorCallback) { m_errorCallback = WTFMove(errorCallback); }
 57
 58protected:
 59 ErrorCallback m_errorCallback;
5260};
5361
5462} // namespace WebCore

Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp

@@MediaRecorderPrivateAVFImpl::MediaRecorderPrivateAVFImpl(Ref<MediaRecorderPrivat
8282{
8383}
8484
85 void MediaRecorderPrivateAVFImpl::sampleBufferUpdated(MediaStreamTrackPrivate& track, MediaSample& sampleBuffer)
 85void MediaRecorderPrivateAVFImpl::sampleBufferUpdated(const MediaStreamTrackPrivate& track, MediaSample& sampleBuffer)
8686{
8787 if (track.id() != m_recordedVideoTrackID)
8888 return;
8989 m_writer->appendVideoSampleBuffer(sampleBuffer.platformSample().sample.cmSampleBuffer);
9090}
9191
92 void MediaRecorderPrivateAVFImpl::audioSamplesAvailable(MediaStreamTrackPrivate& track, const WTF::MediaTime& mediaTime, const PlatformAudioData& data, const AudioStreamDescription& description, size_t sampleCount)
 92void MediaRecorderPrivateAVFImpl::audioSamplesAvailable(const MediaStreamTrackPrivate& track, const WTF::MediaTime& mediaTime, const PlatformAudioData& data, const AudioStreamDescription& description, size_t sampleCount)
9393{
9494 if (track.id() != m_recordedAudioTrackID)
9595 return;

Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.h

@@private:
4343
4444 friend std::unique_ptr<MediaRecorderPrivateAVFImpl> std::make_unique<MediaRecorderPrivateAVFImpl>(Ref<MediaRecorderPrivateWriter>&&, String&&, String&&);
4545
46  void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample&) final;
47  void audioSamplesAvailable(MediaStreamTrackPrivate&, const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
 46 void sampleBufferUpdated(const MediaStreamTrackPrivate&, MediaSample&) final;
 47 void audioSamplesAvailable(const MediaStreamTrackPrivate&, const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
4848 void fetchData(CompletionHandler<void(RefPtr<SharedBuffer>&&, const String&)>&&) final;
4949 const String& mimeType();
5050 void stopRecording();

Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp

3333
3434namespace WebCore {
3535
36 void MediaRecorderPrivateMock::sampleBufferUpdated(MediaStreamTrackPrivate& track, MediaSample&)
 36void MediaRecorderPrivateMock::sampleBufferUpdated(const MediaStreamTrackPrivate& track, MediaSample&)
3737{
3838 generateMockString(track);
3939}
4040
41 void MediaRecorderPrivateMock::audioSamplesAvailable(MediaStreamTrackPrivate& track, const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t)
 41void MediaRecorderPrivateMock::audioSamplesAvailable(const MediaStreamTrackPrivate& track, const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t)
4242{
4343 generateMockString(track);
4444}
4545
46 void MediaRecorderPrivateMock::generateMockString(MediaStreamTrackPrivate& track)
 46void MediaRecorderPrivateMock::generateMockString(const MediaStreamTrackPrivate& track)
4747{
4848 auto locker = holdLock(m_bufferLock);
4949 if (track.type() == RealtimeMediaSource::Type::Audio)

Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h

@@class MediaStreamTrackPrivate;
3636
3737class WEBCORE_EXPORT MediaRecorderPrivateMock final : public MediaRecorderPrivate {
3838private:
39  void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample&) final;
40  void audioSamplesAvailable(MediaStreamTrackPrivate&, const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
 39 void sampleBufferUpdated(const MediaStreamTrackPrivate&, MediaSample&) final;
 40 void audioSamplesAvailable(const MediaStreamTrackPrivate&, const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
4141 void fetchData(CompletionHandler<void(RefPtr<SharedBuffer>&&, const String&)>&&) final;
4242 const String& mimeType();
4343
44  void generateMockString(MediaStreamTrackPrivate&);
 44 void generateMockString(const MediaStreamTrackPrivate&);
4545
4646 mutable Lock m_bufferLock;
4747 StringBuilder m_buffer;

Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h

@@class AudioStreamDescription;
4949class MediaStreamTrackPrivate;
5050class PlatformAudioData;
5151
52 class MediaRecorderPrivateWriter : public ThreadSafeRefCounted<MediaRecorderPrivateWriter, WTF::DestructionThread::Main>, public CanMakeWeakPtr<MediaRecorderPrivateWriter> {
 52class WEBCORE_EXPORT MediaRecorderPrivateWriter : public ThreadSafeRefCounted<MediaRecorderPrivateWriter, WTF::DestructionThread::Main>, public CanMakeWeakPtr<MediaRecorderPrivateWriter> {
5353public:
5454 static RefPtr<MediaRecorderPrivateWriter> create(const MediaStreamTrackPrivate* audioTrack, const MediaStreamTrackPrivate* videoTrack);
 55 static RefPtr<MediaRecorderPrivateWriter> create(bool hasAudio, int width, int height);
5556 ~MediaRecorderPrivateWriter();
5657
5758 bool setupWriter();

Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm

@@static NSString *getAVEncoderBitRateKeyWithFallback()
9090}
9191
9292RefPtr<MediaRecorderPrivateWriter> MediaRecorderPrivateWriter::create(const MediaStreamTrackPrivate* audioTrack, const MediaStreamTrackPrivate* videoTrack)
 93{
 94 int width = 0, height = 0;
 95 if (videoTrack) {
 96 auto& settings = videoTrack->settings();
 97 width = settings.width();
 98 height = settings.height();
 99 }
 100 return create(!!audioTrack, width, height);
 101}
 102
 103RefPtr<MediaRecorderPrivateWriter> MediaRecorderPrivateWriter::create(bool hasAudio, int width, int height)
93104{
94105 NSString *directory = FileSystem::createTemporaryDirectory(@"videos");
95106 NSString *filename = [NSString stringWithFormat:@"/%lld.mp4", CMClockGetTime(CMClockGetHostTimeClock()).value];

@@RefPtr<MediaRecorderPrivateWriter> MediaRecorderPrivateWriter::create(const Medi
106117
107118 auto writer = adoptRef(*new MediaRecorderPrivateWriter(WTFMove(avAssetWriter), WTFMove(filePath)));
108119
109  if (audioTrack && !writer->setAudioInput())
 120 if (hasAudio && !writer->setAudioInput())
110121 return nullptr;
111122
112  if (videoTrack) {
113  auto& settings = videoTrack->settings();
114  if (!writer->setVideoInput(settings.width(), settings.height()))
 123 if (width && height) {
 124 if (!writer->setVideoInput(width, height))
115125 return nullptr;
116126 }
117127

Source/WebCore/platform/mediastream/MediaStreamPrivate.h

@@public:
8181
8282 String id() const { return m_id; }
8383
84  MediaStreamTrackPrivateVector tracks() const;
 84 WEBCORE_EXPORT MediaStreamTrackPrivateVector tracks() const;
8585 MediaStreamTrackPrivate* activeVideoTrack() { return m_activeVideoTrack; }
8686
8787 bool active() const { return m_isActive; }

Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h

@@public:
100100 Ref<MediaStreamTrackPrivate> clone();
101101
102102 RealtimeMediaSource& source() { return m_source.get(); }
103  RealtimeMediaSource::Type type() const;
 103 WEBCORE_EXPORT RealtimeMediaSource::Type type() const;
104104
105105 void endTrack();
106106

@@public:
110110 bool hasObserver(Observer&) const;
111111#endif
112112
113  const RealtimeMediaSourceSettings& settings() const;
 113 WEBCORE_EXPORT const RealtimeMediaSourceSettings& settings() const;
114114 const RealtimeMediaSourceCapabilities& capabilities() const;
115115
116116 void applyConstraints(const MediaConstraints&, RealtimeMediaSource::ApplyConstraintsHandler&&);

Source/WebCore/testing/Internals.cpp

122122#include "MediaEngineConfigurationFactory.h"
123123#include "MediaPlayer.h"
124124#include "MediaProducer.h"
 125#include "MediaRecorderProvider.h"
125126#include "MediaResourceLoader.h"
126127#include "MediaStreamTrack.h"
127128#include "MemoryCache.h"

@@void Internals::resetToConsistentState(Page& page)
550551
551552#if ENABLE(MEDIA_STREAM)
552553 RuntimeEnabledFeatures::sharedFeatures().setInterruptAudioOnPageVisibilityChangeEnabled(false);
 554 WebCore::MediaRecorder::setCustomPrivateRecorderCreator(nullptr);
 555 page.mediaRecorderProvider().setUseGPUProcess(true);
553556#endif
554557
555558 HTMLCanvasElement::setMaxPixelMemoryForTesting(0); // This means use the default value.

@@void Internals::setUseGPUProcessForWebRTC(bool useGPUProcess)
15581561 auto* document = contextDocument();
15591562 if (!document || !document->page())
15601563 return;
 1564
15611565 document->page()->libWebRTCProvider().setUseGPUProcess(useGPUProcess);
 1566 document->page()->mediaRecorderProvider().setUseGPUProcess(useGPUProcess);
15621567#endif
15631568}
15641569#endif

Source/WebKit/CMakeLists.txt

@@set(WebKit_INCLUDE_DIRECTORIES
7878 "${WEBKIT_DIR}/WebProcess/Gamepad"
7979 "${WEBKIT_DIR}/WebProcess/Geolocation"
8080 "${WEBKIT_DIR}/WebProcess/GPU"
 81 "${WEBKIT_DIR}/WebProcess/GPU/media"
 82 "${WEBKIT_DIR}/WebProcess/GPU/webrtc"
8183 "${WEBKIT_DIR}/WebProcess/IconDatabase"
8284 "${WEBKIT_DIR}/WebProcess/InjectedBundle"
8385 "${WEBKIT_DIR}/WebProcess/InjectedBundle/API"

Source/WebKit/DerivedSources-input.xcfilelist

@@$(PROJECT_DIR)/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in
1919$(PROJECT_DIR)/GPUProcess/media/RemoteMediaPlayerManagerProxy.messages.in
2020$(PROJECT_DIR)/GPUProcess/media/RemoteMediaResourceManager.messages.in
2121$(PROJECT_DIR)/GPUProcess/webrtc/LibWebRTCCodecsProxy.messages.in
 22$(PROJECT_DIR)/GPUProcess/webrtc/RemoteMediaRecorder.messages.in
 23$(PROJECT_DIR)/GPUProcess/webrtc/RemoteMediaRecorders.messages.in
2224$(PROJECT_DIR)/NetworkProcess/Cookies/WebCookieManager.messages.in
2325$(PROJECT_DIR)/NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.messages.in
2426$(PROJECT_DIR)/NetworkProcess/IndexedDB/WebIDBServer.messages.in

Source/WebKit/DerivedSources-output.xcfilelist

@@$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaPlayerManagerMessagesRep
129129$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaPlayerManagerProxyMessageReceiver.cpp
130130$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaPlayerManagerProxyMessages.h
131131$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaPlayerManagerProxyMessagesReplies.h
 132$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaRecorderMessageReceiver.cpp
 133$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaRecorderMessages.h
 134$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaRecorderMessagesReplies.h
 135$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaRecordersMessageReceiver.cpp
 136$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaRecordersMessages.h
 137$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaRecordersMessagesReplies.h
132138$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaResourceManagerMessageReceiver.cpp
133139$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaResourceManagerMessages.h
134140$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaResourceManagerMessagesReplies.h

Source/WebKit/DerivedSources.make

@@MESSAGE_RECEIVERS = \
143143 RemoteLayerTreeDrawingAreaProxy \
144144 RemoteMediaPlayerManager \
145145 RemoteMediaPlayerManagerProxy \
 146 RemoteMediaRecorder \
 147 RemoteMediaRecorders \
146148 RemoteMediaResourceManager \
147149 RemoteObjectRegistry \
148150 RemoteScrollingCoordinator \

Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp

3939#include "RemoteLayerTreeDrawingAreaProxyMessages.h"
4040#include "RemoteMediaPlayerManagerProxy.h"
4141#include "RemoteMediaPlayerManagerProxyMessages.h"
 42#include "RemoteMediaRecorderMessages.h"
 43#include "RemoteMediaRecorders.h"
 44#include "RemoteMediaRecordersMessages.h"
4245#include "RemoteMediaResourceManager.h"
4346#include "RemoteMediaResourceManagerMessages.h"
4447#include "RemoteScrollingCoordinatorTransaction.h"

@@UserMediaCaptureManagerProxy& GPUConnectionToWebProcess::userMediaCaptureManager
137140
138141 return *m_userMediaCaptureManagerProxy;
139142}
140 #endif
141143
142 #if PLATFORM(COCOA) && USE(LIBWEBRTC)
143144LibWebRTCCodecsProxy& GPUConnectionToWebProcess::libWebRTCCodecsProxy()
144145{
145146 if (!m_libWebRTCCodecsProxy)

@@LibWebRTCCodecsProxy& GPUConnectionToWebProcess::libWebRTCCodecsProxy()
149150}
150151#endif
151152
 153#if PLATFORM(COCOA) && USE(LIBWEBRTC)
 154RemoteMediaRecorders& GPUConnectionToWebProcess::mediaRecorders()
 155{
 156 if (!m_remoteMediaRecorders)
 157 m_remoteMediaRecorders = makeUnique<RemoteMediaRecorders>(*this);
 158
 159 return *m_remoteMediaRecorders;
 160}
 161#endif
 162
152163void GPUConnectionToWebProcess::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
153164{
154165 if (decoder.messageReceiverName() == Messages::RemoteMediaPlayerManagerProxy::messageReceiverName()) {

@@void GPUConnectionToWebProcess::didReceiveMessage(IPC::Connection& connection, I
163174 userMediaCaptureManagerProxy().didReceiveMessageFromGPUProcess(connection, decoder);
164175 return;
165176 }
 177 if (decoder.messageReceiverName() == Messages::RemoteMediaRecorders::messageReceiverName()) {
 178 mediaRecorders().didReceiveMessageFromWebProcess(connection, decoder);
 179 return;
 180 }
 181 if (decoder.messageReceiverName() == Messages::RemoteMediaRecorder::messageReceiverName()) {
 182 mediaRecorders().didReceiveRemoteMediaRecorderMessage(connection, decoder);
 183 return;
 184 }
166185#endif
167186#if PLATFORM(COCOA) && USE(LIBWEBRTC)
168187 if (decoder.messageReceiverName() == Messages::LibWebRTCCodecsProxy::messageReceiverName()) {

Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h

@@namespace WebKit {
4141class GPUProcess;
4242class LibWebRTCCodecsProxy;
4343class RemoteMediaPlayerManagerProxy;
44 class UserMediaCaptureManagerProxy;
 44class RemoteMediaRecorders;
4545class RemoteMediaResourceManager;
 46class UserMediaCaptureManagerProxy;
4647
4748class GPUConnectionToWebProcess
4849 : public RefCounted<GPUConnectionToWebProcess>

@@private:
7172#endif
7273#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
7374 UserMediaCaptureManagerProxy& userMediaCaptureManagerProxy();
 75 RemoteMediaRecorders& mediaRecorders();
7476#endif
7577
7678 // IPC::Connection::Client

@@private:
8991 PAL::SessionID m_sessionID;
9092#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
9193 std::unique_ptr<UserMediaCaptureManagerProxy> m_userMediaCaptureManagerProxy;
 94 std::unique_ptr<RemoteMediaRecorders> m_remoteMediaRecorders;
9295#endif
9396#if PLATFORM(COCOA) && USE(LIBWEBRTC)
9497 std::unique_ptr<LibWebRTCCodecsProxy> m_libWebRTCCodecsProxy;

Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "RemoteMediaRecorder.h"
 28
 29#if PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
 30
 31#include "SharedRingBufferStorage.h"
 32#include <WebCore/CARingBuffer.h>
 33#include <WebCore/ImageTransferSessionVT.h>
 34#include <WebCore/RemoteVideoSample.h>
 35#include <WebCore/WebAudioBufferList.h>
 36#include <wtf/CompletionHandler.h>
 37
 38using namespace WebCore;
 39
 40namespace WebKit {
 41
 42std::unique_ptr<RemoteMediaRecorder> RemoteMediaRecorder::create(GPUConnectionToWebProcess& gpuConnectionToWebProcess, MediaRecorderIdentifier identifier, bool recordAudio, int width, int height)
 43{
 44 auto writer = MediaRecorderPrivateWriter::create(recordAudio, width, height);
 45 if (!writer)
 46 return nullptr;
 47 return std::unique_ptr<RemoteMediaRecorder>(new RemoteMediaRecorder { gpuConnectionToWebProcess, identifier, writer.releaseNonNull(), recordAudio });
 48}
 49
 50RemoteMediaRecorder::RemoteMediaRecorder(GPUConnectionToWebProcess& gpuConnectionToWebProcess, MediaRecorderIdentifier identifier, Ref<MediaRecorderPrivateWriter>&& writer, bool recordAudio)
 51 : m_gpuConnectionToWebProcess(gpuConnectionToWebProcess)
 52 , m_identifier(identifier)
 53 , m_writer(WTFMove(writer))
 54{
 55 if (recordAudio)
 56 m_ringBuffer = makeUnique<CARingBuffer>(makeUniqueRef<SharedRingBufferStorage>(nullptr));
 57}
 58
 59RemoteMediaRecorder::~RemoteMediaRecorder()
 60{
 61}
 62
 63SharedRingBufferStorage& RemoteMediaRecorder::storage()
 64{
 65 return static_cast<SharedRingBufferStorage&>(m_ringBuffer->storage());
 66}
 67
 68void RemoteMediaRecorder::audioSamplesStorageChanged(const SharedMemory::Handle& handle, const WebCore::CAAudioStreamDescription& description, uint64_t numberOfFrames)
 69{
 70 ASSERT(m_ringBuffer);
 71 if (!m_ringBuffer)
 72 return;
 73
 74 m_description = description;
 75
 76 if (handle.isNull()) {
 77 m_ringBuffer->deallocate();
 78 storage().setReadOnly(false);
 79 storage().setStorage(nullptr);
 80 return;
 81 }
 82
 83 auto memory = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
 84 storage().setStorage(WTFMove(memory));
 85 storage().setReadOnly(true);
 86
 87 m_ringBuffer->allocate(description, numberOfFrames);
 88}
 89
 90void RemoteMediaRecorder::audioSamplesAvailable(MediaTime time, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame)
 91{
 92 ASSERT(m_ringBuffer);
 93 if (!m_ringBuffer)
 94 return;
 95
 96 m_ringBuffer->setCurrentFrameBounds(startFrame, endFrame);
 97
 98 WebAudioBufferList audioData(m_description, numberOfFrames);
 99 m_ringBuffer->fetch(audioData.list(), numberOfFrames, time.timeValue());
 100
 101 m_writer->appendAudioSampleBuffer(audioData, m_description, time, numberOfFrames);
 102}
 103
 104void RemoteMediaRecorder::videoSampleAvailable(WebCore::RemoteVideoSample&& remoteSample)
 105{
 106 if (!m_imageTransferSession || m_imageTransferSession->pixelFormat() != remoteSample.videoFormat())
 107 m_imageTransferSession = ImageTransferSessionVT::create(remoteSample.videoFormat());
 108
 109 if (!m_imageTransferSession) {
 110 ASSERT_NOT_REACHED();
 111 return;
 112 }
 113
 114 auto sampleBuffer = m_imageTransferSession->createMediaSample(remoteSample.surface(), remoteSample.time(), remoteSample.size());
 115 if (!sampleBuffer) {
 116 ASSERT_NOT_REACHED();
 117 return;
 118 }
 119
 120 m_writer->appendVideoSampleBuffer(sampleBuffer->platformSample().sample.cmSampleBuffer);
 121}
 122
 123void RemoteMediaRecorder::fetchData(CompletionHandler<void(IPC::DataReference&&, const String& mimeType)>&& completionHandler)
 124{
 125 static NeverDestroyed<const String> mp4MimeType(MAKE_STATIC_STRING_IMPL("video/mp4"));
 126 m_writer->fetchData([&mp4MimeType = mp4MimeType.get(), completionHandler = WTFMove(completionHandler)](auto&& data) mutable {
 127 auto* pointer = reinterpret_cast<const uint8_t*>(data ? data->data() : nullptr);
 128 completionHandler(IPC::DataReference { pointer, data ? data->size() : 0 }, mp4MimeType);
 129 });
 130}
 131
 132void RemoteMediaRecorder::stopRecording()
 133{
 134 m_writer->stopRecording();
 135}
 136
 137}
 138
 139#endif

Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.h

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#if PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
 29
 30#include "MediaRecorderIdentifier.h"
 31#include "MessageReceiver.h"
 32#include "SharedMemory.h"
 33#include <WebCore/CAAudioStreamDescription.h>
 34#include <WebCore/MediaRecorderPrivateWriterCocoa.h>
 35#include <wtf/MediaTime.h>
 36
 37namespace IPC {
 38class Connection;
 39class DataReference;
 40class Decoder;
 41}
 42
 43namespace WebCore {
 44class CARingBuffer;
 45class ImageTransferSessionVT;
 46class RemoteVideoSample;
 47}
 48
 49namespace WebKit {
 50
 51class GPUConnectionToWebProcess;
 52class SharedRingBufferStorage;
 53
 54class RemoteMediaRecorder : private IPC::MessageReceiver {
 55 WTF_MAKE_FAST_ALLOCATED;
 56public:
 57 static std::unique_ptr<RemoteMediaRecorder> create(GPUConnectionToWebProcess&, MediaRecorderIdentifier, bool recordAudio, int width, int height);
 58 ~RemoteMediaRecorder();
 59
 60 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
 61
 62private:
 63 RemoteMediaRecorder(GPUConnectionToWebProcess&, MediaRecorderIdentifier, Ref<WebCore::MediaRecorderPrivateWriter>&&, bool recordAudio);
 64
 65 // IPC::MessageReceiver
 66 void audioSamplesStorageChanged(const SharedMemory::Handle&, const WebCore::CAAudioStreamDescription&, uint64_t numberOfFrames);
 67 void audioSamplesAvailable(MediaTime, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame);
 68 void videoSampleAvailable(WebCore::RemoteVideoSample&&);
 69 void fetchData(CompletionHandler<void(IPC::DataReference&&, const String& mimeType)>&&);
 70 void stopRecording();
 71
 72 SharedRingBufferStorage& storage();
 73
 74 GPUConnectionToWebProcess& m_gpuConnectionToWebProcess;
 75 MediaRecorderIdentifier m_identifier;
 76 Ref<WebCore::MediaRecorderPrivateWriter> m_writer;
 77
 78 WebCore::CAAudioStreamDescription m_description;
 79 std::unique_ptr<WebCore::CARingBuffer> m_ringBuffer;
 80 std::unique_ptr<WebCore::ImageTransferSessionVT> m_imageTransferSession;
 81};
 82
 83}
 84
 85#endif

Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.messages.in

 1# Copyright (C) 2019 Apple Inc. All rights reserved.
 2#
 3# Redistribution and use in source and binary forms, with or without
 4# modification, are permitted provided that the following conditions
 5# are met:
 6# 1. Redistributions of source code must retain the above copyright
 7# notice, this list of conditions and the following disclaimer.
 8# 2. Redistributions in binary form must reproduce the above copyright
 9# notice, this list of conditions and the following disclaimer in the
 10# documentation and/or other materials provided with the distribution.
 11#
 12# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 13# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 14# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 15# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 16# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 17# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 18# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 19# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 20# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 21# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 22# THE POSSIBILITY OF SUCH DAMAGE.
 23
 24#if PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
 25
 26messages -> RemoteMediaRecorder NotRefCounted {
 27 AudioSamplesStorageChanged(WebKit::SharedMemory::Handle storageHandle, WebCore::CAAudioStreamDescription description, uint64_t numberOfFrames)
 28 AudioSamplesAvailable(MediaTime time, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame)
 29 VideoSampleAvailable(WebCore::RemoteVideoSample sample)
 30 FetchData() -> (IPC::DataReference buffer, String mimeType) Async
 31 StopRecording()
 32}
 33
 34#endif

Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorders.cpp

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "RemoteMediaRecorders.h"
 28
 29#if PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
 30
 31#include "DataReference.h"
 32#include "Decoder.h"
 33#include "RemoteMediaRecorder.h"
 34#include <WebCore/ExceptionData.h>
 35
 36namespace WebKit {
 37
 38RemoteMediaRecorders::RemoteMediaRecorders(GPUConnectionToWebProcess& gpuConnectionToWebProcess)
 39 : m_gpuConnectionToWebProcess(gpuConnectionToWebProcess)
 40{
 41}
 42
 43RemoteMediaRecorders::~RemoteMediaRecorders()
 44{
 45}
 46
 47void RemoteMediaRecorders::didReceiveRemoteMediaRecorderMessage(IPC::Connection& connection, IPC::Decoder& decoder)
 48{
 49 if (auto* recorder = m_recorders.get(makeObjectIdentifier<MediaRecorderIdentifierType>(decoder.destinationID())))
 50 recorder->didReceiveMessage(connection, decoder);
 51}
 52
 53void RemoteMediaRecorders::createRecorder(MediaRecorderIdentifier identifier, bool recordAudio, int width, int height, CompletionHandler<void(Optional<ExceptionData>&&)>&& completionHandler)
 54{
 55 ASSERT(!m_recorders.contains(identifier));
 56 auto recorder = RemoteMediaRecorder::create(m_gpuConnectionToWebProcess, identifier, recordAudio, width, height);
 57 if (!recorder)
 58 return completionHandler(ExceptionData { NotSupportedError, "Unable to create a recorder with the provided stream"_s });
 59
 60 m_recorders.add(identifier, WTFMove(recorder));
 61 completionHandler({ });
 62}
 63
 64void RemoteMediaRecorders::releaseRecorder(MediaRecorderIdentifier identifier)
 65{
 66 ASSERT(m_recorders.contains(identifier));
 67 m_recorders.remove(identifier);
 68}
 69
 70}
 71
 72#endif

Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorders.h

 1
 2
 3/*
 4 * Copyright (C) 2020 Apple Inc. All rights reserved.
 5 *
 6 * Redistribution and use in source and binary forms, with or without
 7 * modification, are permitted provided that the following conditions
 8 * are met:
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer in the
 13 * documentation and/or other materials provided with the distribution.
 14 *
 15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 17 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 25 * THE POSSIBILITY OF SUCH DAMAGE.
 26 */
 27
 28#pragma once
 29
 30#if PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
 31
 32#include "MediaRecorderIdentifier.h"
 33#include "MessageReceiver.h"
 34#include <wtf/Forward.h>
 35#include <wtf/HashMap.h>
 36
 37namespace IPC {
 38class Connection;
 39class Decoder;
 40}
 41
 42namespace WebCore {
 43struct ExceptionData;
 44}
 45
 46namespace WebKit {
 47
 48class GPUConnectionToWebProcess;
 49class RemoteMediaRecorder;
 50
 51class RemoteMediaRecorders : private IPC::MessageReceiver {
 52 WTF_MAKE_FAST_ALLOCATED;
 53public:
 54 explicit RemoteMediaRecorders(GPUConnectionToWebProcess&);
 55 ~RemoteMediaRecorders();
 56
 57 void didReceiveRemoteMediaRecorderMessage(IPC::Connection&, IPC::Decoder&);
 58 void didReceiveMessageFromWebProcess(IPC::Connection& connection, IPC::Decoder& decoder) { didReceiveMessage(connection, decoder); }
 59
 60private:
 61 // IPC::MessageReceiver
 62 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
 63 void createRecorder(MediaRecorderIdentifier, bool recordAudio, int width, int height, CompletionHandler<void(Optional<WebCore::ExceptionData>&&)>&&);
 64 void releaseRecorder(MediaRecorderIdentifier);
 65
 66 GPUConnectionToWebProcess& m_gpuConnectionToWebProcess;
 67 HashMap<MediaRecorderIdentifier, std::unique_ptr<RemoteMediaRecorder>> m_recorders;
 68};
 69
 70}
 71
 72#endif

Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorders.messages.in

 1# Copyright (C) 2019 Apple Inc. All rights reserved.
 2#
 3# Redistribution and use in source and binary forms, with or without
 4# modification, are permitted provided that the following conditions
 5# are met:
 6# 1. Redistributions of source code must retain the above copyright
 7# notice, this list of conditions and the following disclaimer.
 8# 2. Redistributions in binary form must reproduce the above copyright
 9# notice, this list of conditions and the following disclaimer in the
 10# documentation and/or other materials provided with the distribution.
 11#
 12# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 13# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 14# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 15# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 16# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 17# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 18# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 19# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 20# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 21# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 22# THE POSSIBILITY OF SUCH DAMAGE.
 23
 24#if PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
 25
 26messages -> RemoteMediaRecorders NotRefCounted {
 27 CreateRecorder(WebKit::MediaRecorderIdentifier id, bool hasAudio, int width, int height) -> (Optional<WebCore::ExceptionData> creationError) Async
 28 ReleaseRecorder(WebKit::MediaRecorderIdentifier id)
 29}
 30
 31#endif

Source/WebKit/Scripts/webkit/messages.py

@@def types_that_cannot_be_forward_declared():
220220 'WebKit::ActivityStateChangeID',
221221 'WebKit::LayerHostingContextID',
222222 'WebKit::MediaPlayerPrivateRemoteIdentifier',
 223 'WebKit::MediaRecorderIdentifier',
223224 'WebKit::RemoteMediaResourceIdentifier',
224225 'WebKit::RTCDecoderIdentifier',
225226 'WebKit::RTCEncoderIdentifier',

Source/WebKit/Sources.txt

2424GPUProcess/GPUProcess.cpp
2525GPUProcess/GPUConnectionToWebProcess.cpp
2626GPUProcess/GPUProcessCreationParameters.cpp
 27GPUProcess/webrtc/RemoteMediaRecorder.cpp
 28GPUProcess/webrtc/RemoteMediaRecorders.cpp
2729GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp
2830GPUProcess/media/RemoteMediaPlayerProxy.cpp
2931GPUProcess/media/RemoteMediaResource.cpp

@@WebProcess/GPU/media/RemoteMediaPlayerManager.cpp
513515WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp @no-unify
514516WebProcess/GPU/media/RemoteMediaResourceProxy.cpp
515517WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp
 518WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp
 519WebProcess/GPU/webrtc/MediaRecorderProvider.cpp
516520
517521WebProcess/Network/NetworkProcessConnection.cpp
518522WebProcess/Network/WebLoaderStrategy.cpp

Source/WebKit/SourcesCocoa.txt

@@GPUProcessProxyMessageReceiver.cpp
635635GPUProcessMessageReceiver.cpp
636636LibWebRTCCodecsProxyMessageReceiver.cpp
637637LibWebRTCCodecsMessageReceiver.cpp
 638RemoteMediaRecorderMessageReceiver.cpp
 639RemoteMediaRecordersMessageReceiver.cpp
638640ServiceWorkerFetchTaskMessageReceiver.cpp
639641TextCheckingControllerProxyMessageReceiver.cpp

Source/WebKit/WebKit.xcodeproj/project.pbxproj

33163316 4172198C23B612E800AE5686 /* RTCDecoderIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCDecoderIdentifier.h; sourceTree = "<group>"; };
33173317 4172198D23B62C7C00AE5686 /* LibWebRTCCodecs.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = LibWebRTCCodecs.messages.in; sourceTree = "<group>"; };
33183318 4176901322FDD41B00B1576D /* NetworkRTCProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkRTCProvider.mm; sourceTree = "<group>"; };
 3319 4176E89223C34D6E003E83FE /* MediaRecorderProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaRecorderProvider.h; sourceTree = "<group>"; };
 3320 4176E89323C34D6F003E83FE /* MediaRecorderProvider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaRecorderProvider.cpp; sourceTree = "<group>"; };
 3321 4176E89423C34E26003E83FE /* MediaRecorderPrivate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaRecorderPrivate.cpp; sourceTree = "<group>"; };
 3322 4176E89523C34E27003E83FE /* MediaRecorderPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaRecorderPrivate.h; sourceTree = "<group>"; };
 3323 4176E89723C361BD003E83FE /* MediaRecorderIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaRecorderIdentifier.h; sourceTree = "<group>"; };
 3324 4176E89823C36677003E83FE /* RemoteMediaRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteMediaRecorder.h; sourceTree = "<group>"; };
 3325 4176E89923C36D8E003E83FE /* RemoteMediaRecorders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteMediaRecorders.h; sourceTree = "<group>"; };
 3326 4176E89A23C36F71003E83FE /* RemoteMediaRecorders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteMediaRecorders.cpp; sourceTree = "<group>"; };
 3327 4176E89B23C37222003E83FE /* RemoteMediaRecorders.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RemoteMediaRecorders.messages.in; sourceTree = "<group>"; };
 3328 4176E89C23C37479003E83FE /* RemoteMediaRecorder.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RemoteMediaRecorder.messages.in; sourceTree = "<group>"; };
 3329 4176E89D23C376D5003E83FE /* RemoteMediaRecorder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteMediaRecorder.cpp; sourceTree = "<group>"; };
33193330 417915AC2256BB7400D6F97E /* WebSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketChannel.cpp; path = Network/WebSocketChannel.cpp; sourceTree = "<group>"; };
33203331 417915AD2256BB7400D6F97E /* WebSocketChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketChannel.h; path = Network/WebSocketChannel.h; sourceTree = "<group>"; };
33213332 417915B02256C0D600D6F97E /* WebSocketChannelManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketChannelManager.h; path = Network/WebSocketChannelManager.h; sourceTree = "<group>"; };

71177128 4172198A23B6128200AE5686 /* LibWebRTCCodecs.cpp */,
71187129 4172198923B6128200AE5686 /* LibWebRTCCodecs.h */,
71197130 4172198D23B62C7C00AE5686 /* LibWebRTCCodecs.messages.in */,
 7131 4176E89723C361BD003E83FE /* MediaRecorderIdentifier.h */,
 7132 4176E89423C34E26003E83FE /* MediaRecorderPrivate.cpp */,
 7133 4176E89523C34E27003E83FE /* MediaRecorderPrivate.h */,
 7134 4176E89323C34D6F003E83FE /* MediaRecorderProvider.cpp */,
 7135 4176E89223C34D6E003E83FE /* MediaRecorderProvider.h */,
71207136 4172198C23B612E800AE5686 /* RTCDecoderIdentifier.h */,
71217137 4158649A23BE092400A0A61E /* RTCEncoderIdentifier.h */,
71227138 );

71297145 41E0A7C623B6397800561060 /* LibWebRTCCodecsProxy.h */,
71307146 41E0A7C723B6397900561060 /* LibWebRTCCodecsProxy.messages.in */,
71317147 41E0A7C823B6397900561060 /* LibWebRTCCodecsProxy.mm */,
 7148 4176E89D23C376D5003E83FE /* RemoteMediaRecorder.cpp */,
 7149 4176E89823C36677003E83FE /* RemoteMediaRecorder.h */,
 7150 4176E89C23C37479003E83FE /* RemoteMediaRecorder.messages.in */,
 7151 4176E89A23C36F71003E83FE /* RemoteMediaRecorders.cpp */,
 7152 4176E89923C36D8E003E83FE /* RemoteMediaRecorders.h */,
 7153 4176E89B23C37222003E83FE /* RemoteMediaRecorders.messages.in */,
71327154 );
71337155 path = webrtc;
71347156 sourceTree = "<group>";

Source/WebKit/WebProcess/GPU/media/MediaRecorderProvider.cpp

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "MediaRecorderProvider.h"
 28
 29#if PLATFORM(COCOA)
 30#include "MediaRecorderPrivateAVFImpl.h"
 31#endif
 32
 33namespace WebCore {
 34
 35std::unique_ptr<MediaRecorderPrivate> MediaRecorderProvider::createMediaRecorderPrivate(MediaStreamPrivate& stream)
 36{
 37#if PLATFORM(COCOA)
 38 return MediaRecorderPrivateAVFImpl::create(stream);
 39#else
 40 UNUSED_PARAM(stream);
 41 return nullptr;
 42#endif
 43}
 44
 45}

Source/WebKit/WebProcess/GPU/media/MediaRecorderProvider.h

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28namespace WebCore {
 29
 30class MediaRecorderPrivate;
 31class MediaStreamPrivate;
 32
 33class WEBCORE_EXPORT MediaRecorderProvider {
 34 WTF_MAKE_FAST_ALLOCATED;
 35public:
 36 static UniqueRef<MediaRecorderProvider> create() { return makeUniqueRef<MediaRecorderProvider>(); }
 37 virtual ~MediaRecorderProvider() = default;
 38
 39 virtual std::unique_ptr<MediaRecorderPrivate> createMediaRecorderPrivate(MediaStreamPrivate&);
 40};
 41
 42}

Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderIdentifier.h

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include <wtf/ObjectIdentifier.h>
 29
 30namespace WebKit {
 31
 32enum MediaRecorderIdentifierType { };
 33using MediaRecorderIdentifier = ObjectIdentifier<MediaRecorderIdentifierType>;
 34
 35} // namespace WebKit

Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "MediaRecorderPrivate.h"
 28
 29#if PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
 30
 31#include "GPUProcessConnection.h"
 32#include "RemoteMediaRecorderMessages.h"
 33#include "RemoteMediaRecordersMessages.h"
 34#include "WebProcess.h"
 35#include <WebCore/CARingBuffer.h>
 36#include <WebCore/MediaStreamPrivate.h>
 37#include <WebCore/MediaStreamTrackPrivate.h>
 38#include <WebCore/RemoteVideoSample.h>
 39#include <WebCore/SharedBuffer.h>
 40#include <WebCore/WebAudioBufferList.h>
 41
 42using namespace WebCore;
 43
 44namespace WebKit {
 45
 46MediaRecorderPrivate::MediaRecorderPrivate(const MediaStreamPrivate& stream)
 47 : m_identifier(MediaRecorderIdentifier::generate())
 48 , m_connection(WebProcess::singleton().ensureGPUProcessConnection().connection())
 49{
 50 // FIXME: we will need to implement support for multiple audio/video tracks
 51 // Currently we only choose the first track as the recorded track.
 52 // FIXME: We would better to throw an exception to JavaScript if writer creation fails.
 53
 54 const MediaStreamTrackPrivate* audioTrack { nullptr };
 55 const MediaStreamTrackPrivate* videoTrack { nullptr };
 56 for (auto& track : stream.tracks()) {
 57 if (!track->enabled() || track->ended())
 58 continue;
 59 switch (track->type()) {
 60 case RealtimeMediaSource::Type::Video: {
 61 auto& settings = track->settings();
 62 if (!videoTrack && settings.supportsWidth() && settings.supportsHeight()) {
 63 videoTrack = track.get();
 64 m_recordedVideoTrackID = videoTrack->id();
 65 }
 66 break;
 67 }
 68 case RealtimeMediaSource::Type::Audio:
 69 if (!audioTrack) {
 70 m_ringBuffer = makeUnique<CARingBuffer>(makeUniqueRef<SharedRingBufferStorage>(this));
 71 audioTrack = track.get();
 72 m_recordedAudioTrackID = audioTrack->id();
 73 }
 74 break;
 75 case RealtimeMediaSource::Type::None:
 76 break;
 77 }
 78 }
 79 m_connection->sendWithAsyncReply(Messages::RemoteMediaRecorders::CreateRecorder { m_identifier, !!audioTrack, videoTrack ? videoTrack->settings().width() : 0, videoTrack ? videoTrack->settings().height() : 0 }, [this, weakThis = makeWeakPtr(this)](auto&& exception) {
 80 if (!weakThis || !exception)
 81 return;
 82 m_errorCallback(Exception { exception->code, WTFMove(exception->message) });
 83 }, 0);
 84}
 85
 86MediaRecorderPrivate::~MediaRecorderPrivate()
 87{
 88 m_connection->send(Messages::RemoteMediaRecorders::ReleaseRecorder { m_identifier }, 0);
 89}
 90
 91void MediaRecorderPrivate::sampleBufferUpdated(const WebCore::MediaStreamTrackPrivate& track, WebCore::MediaSample& sample)
 92{
 93 if (track.id() != m_recordedVideoTrackID)
 94 return;
 95 if (auto remoteSample = RemoteVideoSample::create(sample))
 96 m_connection->send(Messages::RemoteMediaRecorder::VideoSampleAvailable { WTFMove(*remoteSample) }, m_identifier);
 97}
 98
 99void MediaRecorderPrivate::audioSamplesAvailable(const WebCore::MediaStreamTrackPrivate& track, const MediaTime& time, const PlatformAudioData& audioData, const AudioStreamDescription& description, size_t numberOfFrames)
 100{
 101 if (track.id() != m_recordedAudioTrackID)
 102 return;
 103
 104 if (m_description != description) {
 105 ASSERT(description.platformDescription().type == PlatformDescription::CAAudioStreamBasicType);
 106 m_description = *WTF::get<const AudioStreamBasicDescription*>(description.platformDescription().description);
 107
 108 // Allocate a ring buffer large enough to contain 2 seconds of audio.
 109 m_numberOfFrames = m_description.sampleRate() * 2;
 110 m_ringBuffer->allocate(m_description.streamDescription(), m_numberOfFrames);
 111 }
 112
 113 ASSERT(is<WebAudioBufferList>(audioData));
 114 m_ringBuffer->store(downcast<WebAudioBufferList>(audioData).list(), numberOfFrames, time.timeValue());
 115 uint64_t startFrame;
 116 uint64_t endFrame;
 117 m_ringBuffer->getCurrentFrameBounds(startFrame, endFrame);
 118 m_connection->send(Messages::RemoteMediaRecorder::AudioSamplesAvailable { time, numberOfFrames, startFrame, endFrame }, m_identifier);
 119}
 120
 121void MediaRecorderPrivate::storageChanged(SharedMemory* storage)
 122{
 123 SharedMemory::Handle handle;
 124 if (storage)
 125 storage->createHandle(handle, SharedMemory::Protection::ReadOnly);
 126 m_connection->send(Messages::RemoteMediaRecorder::AudioSamplesStorageChanged { handle, m_description, static_cast<uint64_t>(m_numberOfFrames) }, m_identifier);
 127}
 128
 129void MediaRecorderPrivate::fetchData(CompletionHandler<void(RefPtr<WebCore::SharedBuffer>&&, const String& mimeType)>&& completionHandler)
 130{
 131 m_connection->sendWithAsyncReply(Messages::RemoteMediaRecorder::FetchData { }, [completionHandler = WTFMove(completionHandler)](auto&& data, auto&& mimeType) mutable {
 132 RefPtr<SharedBuffer> buffer;
 133 if (!data.size())
 134 buffer = SharedBuffer::create(data.data(), data.size());
 135 completionHandler(WTFMove(buffer), mimeType);
 136 }, m_identifier);
 137}
 138
 139void MediaRecorderPrivate::stopRecording()
 140{
 141 m_connection->send(Messages::RemoteMediaRecorder::StopRecording { }, m_identifier);
 142}
 143
 144}
 145
 146#endif // PLATFORM(COCOA) && ENABLE(GPU_PROCESS)

Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#if PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
 29
 30#include "MediaRecorderIdentifier.h"
 31#include "SharedRingBufferStorage.h"
 32#include <WebCore/MediaRecorderPrivate.h>
 33#include <wtf/MediaTime.h>
 34#include <wtf/WeakPtr.h>
 35
 36namespace IPC {
 37class Connection;
 38}
 39
 40namespace WebCore {
 41class MediaStreamPrivate;
 42}
 43
 44namespace WebKit {
 45
 46class MediaRecorderPrivate final : public WebCore::MediaRecorderPrivate, public SharedRingBufferStorage::Client, public CanMakeWeakPtr<MediaRecorderPrivate> {
 47 WTF_MAKE_FAST_ALLOCATED;
 48public:
 49 explicit MediaRecorderPrivate(const WebCore::MediaStreamPrivate&);
 50 ~MediaRecorderPrivate();
 51
 52private:
 53 // WebCore::MediaRecorderPrivate
 54 void sampleBufferUpdated(const WebCore::MediaStreamTrackPrivate&, WebCore::MediaSample&) final;
 55 void audioSamplesAvailable(const WebCore::MediaStreamTrackPrivate&, const WTF::MediaTime&, const WebCore::PlatformAudioData&, const WebCore::AudioStreamDescription&, size_t) final;
 56 void fetchData(CompletionHandler<void(RefPtr<WebCore::SharedBuffer>&&, const String& mimeType)>&&) final;
 57 void stopRecording() final;
 58
 59 // SharedRingBufferStorage::Client
 60 void storageChanged(SharedMemory*);
 61
 62 MediaRecorderIdentifier m_identifier;
 63
 64 Ref<IPC::Connection> m_connection;
 65 String m_recordedAudioTrackID;
 66 String m_recordedVideoTrackID;
 67
 68 std::unique_ptr<WebCore::CARingBuffer> m_ringBuffer;
 69 WebCore::CAAudioStreamDescription m_description { };
 70 int64_t m_numberOfFrames { 0 };
 71};
 72
 73}
 74
 75#endif // PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
 76

Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderProvider.cpp

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "MediaRecorderProvider.h"
 28
 29#include "MediaRecorderPrivate.h"
 30#include <WebCore/MediaRecorderPrivate.h>
 31
 32using namespace WebCore;
 33
 34namespace WebKit {
 35
 36#if ENABLE(MEDIA_STREAM)
 37std::unique_ptr<WebCore::MediaRecorderPrivate> MediaRecorderProvider::createMediaRecorderPrivate(const MediaStreamPrivate& stream)
 38{
 39#if ENABLE(GPU_PROCESS)
 40 if (!m_useGPUProcess)
 41 return WebCore::MediaRecorderProvider::createMediaRecorderPrivate(stream);
 42
 43 return makeUnique<MediaRecorderPrivate>(stream);
 44#else
 45 return WebCore::MediaRecorderProvider::createMediaRecorderPrivate(stream);
 46#endif // ENABLE(GPU_PROCESS)
 47}
 48#endif // ENABLE(MEDIA_STREAM)
 49
 50}

Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderProvider.h

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include <WebCore/MediaRecorderProvider.h>
 29
 30namespace WebKit {
 31
 32class MediaRecorderProvider final : public WebCore::MediaRecorderProvider {
 33public:
 34 MediaRecorderProvider() = default;
 35
 36private:
 37#if ENABLE(MEDIA_STREAM)
 38 std::unique_ptr<WebCore::MediaRecorderPrivate> createMediaRecorderPrivate(const WebCore::MediaStreamPrivate&) final;
 39#endif
 40};
 41
 42}

Source/WebKit/WebProcess/WebPage/WebPage.cpp

4545#include "LibWebRTCProvider.h"
4646#include "LoadParameters.h"
4747#include "Logging.h"
 48#include "MediaRecorderProvider.h"
4849#include "NetscapePlugin.h"
4950#include "NetworkConnectionToWebProcessMessages.h"
5051#include "NetworkProcessConnection.h"

@@WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
460461 WebProcess::singleton().cacheStorageProvider(),
461462 WebBackForwardListProxy::create(*this),
462463 WebCookieJar::create(),
463  makeUniqueRef<WebProgressTrackerClient>(*this)
 464 makeUniqueRef<WebProgressTrackerClient>(*this),
 465 makeUniqueRef<MediaRecorderProvider>()
464466 );
465467 pageConfiguration.chromeClient = new WebChromeClient(*this);
466468#if ENABLE(CONTEXT_MENUS)

Source/WebKitLegacy/mac/WebView/WebView.mm

180180#import <WebCore/LocalizedStrings.h>
181181#import <WebCore/LogInitialization.h>
182182#import <WebCore/MIMETypeRegistry.h>
 183#import <WebCore/MediaRecorderProvider.h>
183184#import <WebCore/MemoryCache.h>
184185#import <WebCore/MemoryRelease.h>
185186#import <WebCore/NetworkStorageSession.h>

@@static void WebKitInitializeGamepadProviderIfNecessary()
14481449 WebCore::CacheStorageProvider::create(),
14491450 BackForwardList::create(self),
14501451 WebCore::CookieJar::create(storageProvider.copyRef()),
1451  makeUniqueRef<WebProgressTrackerClient>(self)
 1452 makeUniqueRef<WebProgressTrackerClient>(self),
 1453 makeUniqueRef<WebCore::MediaRecorderProvider>()
14521454 );
14531455#if !PLATFORM(IOS_FAMILY)
14541456 pageConfiguration.chromeClient = new WebChromeClient(self);

@@static void WebKitInitializeGamepadProviderIfNecessary()
17171719 WebCore::CacheStorageProvider::create(),
17181720 BackForwardList::create(self),
17191721 WebCore::CookieJar::create(storageProvider.copyRef()),
1720  makeUniqueRef<WebProgressTrackerClient>(self)
 1722 makeUniqueRef<WebProgressTrackerClient>(self),
 1723 makeUniqueRef<WebCore::MediaRecorderProvider>()
17211724 );
17221725 pageConfiguration.chromeClient = new WebChromeClientIOS(self);
17231726#if ENABLE(DRAG_SUPPORT)

Source/WebKitLegacy/win/WebView.cpp

129129#include <WebCore/LogInitialization.h>
130130#include <WebCore/Logging.h>
131131#include <WebCore/MIMETypeRegistry.h>
 132#include <WebCore/MediaRecorderProvider.h>
132133#include <WebCore/MemoryCache.h>
133134#include <WebCore/MemoryRelease.h>
134135#include <WebCore/NetworkStorageSession.h>

@@HRESULT WebView::initWithFrame(RECT frame, _In_ BSTR frameName, _In_ BSTR groupN
31183119 makeUniqueRef<WebEditorClient>(this),
31193120 SocketProvider::create(),
31203121 makeUniqueRef<LibWebRTCProvider>(),
3121  WebCore::CacheStorageProvider::create(),
 3122 CacheStorageProvider::create(),
31223123 BackForwardList::create(),
31233124 CookieJar::create(storageProvider.copyRef()),
3124  makeUniqueRef<WebProgressTrackerClient>()
 3125 makeUniqueRef<WebProgressTrackerClient>(),
 3126 makeUniqueRef<MediaRecorderProvider>()
31253127 );
31263128 configuration.chromeClient = new WebChromeClient(this);
31273129 configuration.contextMenuClient = new WebContextMenuClient(this);