[GTK][WPE] Start implementing MediaStream API
https://bugs.webkit.org/show_bug.cgi?id=185787

Source/WebCore:

Patch by Thibault Saunier  <tsaunier@igalia.com> and Alejandro G. Castro <alex@igalia.com> on 2018-06-07
Reviewed by Philippe Normand.

We are adding all the required classes to make the
MediaStream API work, that means our own RealtimeMediaSourceCenterLibWebRTC
for the platform, the GStreamerCaptureDeviceManager, the audio/video capturers
and their respective audio/video sources as well as a dedicated GStreamer Source
that adds support for using MediaStream stream inside playbin3.
We are using the GstDeviceMonitor to list devices on the devices.

Enable mediastream tests.

* platform/GStreamer.cmake: Added the new files to the compilation.
* platform/audio/AudioStreamDescription.h: Added new GStreamer type.
* platform/audio/PlatformAudioData.h: Added new GStreamer type for
the GStreamerAudioData class.
* platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::simpleBusMessageCallback): This function and the next
one help us to connect a monitoring callback to a pipeline for
debugging.
(WebCore::connectSimpleBusMessageCallback): Ditto.
* platform/graphics/gstreamer/GStreamerCommon.h: Ditto
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::load): Make use of the loadFull() method.
(WebCore::MediaPlayerPrivateGStreamer::loadFull): Very similar to load()
but allows specifying what pipeline type to use (null to let the function determine
which one should be used). This is required as we force to always use playbin3 for the
mediastream source as it relies on the GstStream API.
(WebCore::MediaPlayerPrivateGStreamer::playbackPosition const): Style fix.
(WebCore::MediaPlayerPrivateGStreamer::naturalSize const): Added, use MediaStream specific information if available.
(WebCore::MediaPlayerPrivateGStreamer::updateTracks): Some style fixes.
(WebCore::MediaPlayerPrivateGStreamer::handleMessage): Enhance dotfiles names.
(WebCore::MediaPlayerPrivateGStreamer::processTableOfContentsEntry): Minor formatting fix.
(WebCore::MediaPlayerPrivateGStreamer::sourceSetup): Set MediaStream on WebKitMediaStreamSource when setting it up.
(WebCore::MediaPlayerPrivateGStreamer::supportsType): Advertise that we support MediaStream if support is built.
(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Make sure playbin3 is forced when loading a MediaStream.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: Add a reference to the MediaStream object and declare loadFull and naturalSize override.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::registerWebKitGStreamerElements): Register the new MediaStreamSrc element.
* platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp:
(WebCore::VideoTrackPrivateGStreamer::VideoTrackPrivateGStreamer): Make sure that MediaStream MAIN tracks are selected by default. We have no way to do it in MediaStreamSrc now as the GstStreamCollection is recreated by parsebin.
* platform/mediastream/RealtimeMediaSource.h: Make CaptureFailed a virtual method as in our mocks we require need to make
* platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::RealtimeMediaSourceCenter::singleton): Remove the code
used for compilation for the platform when we do not have a
RealtimeMediaSourceCenterLibWebRTC. Now we return the proper class
for the platform.
* platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp:
Added class representing the RealtimeMediaSource for the Audio
with GStreamer.
* platform/mediastream/gstreamer/GStreamerAudioCaptureSource.h:
Ditto.
* platform/mediastream/gstreamer/GStreamerAudioCapturer.cpp: Added
this class that represents the GStreamer pipeline that captures
audio from the system devices, it inherits from GStreamerCapturer.
* platform/mediastream/gstreamer/GStreamerAudioCapturer.h: Dito.
* platform/mediastream/gstreamer/GStreamerAudioData.h: Added this
class implementing PlatformAudioData for the GStreamer platform,
used to pass the samples information.
* platform/mediastream/gstreamer/GStreamerAudioStreamDescription.h:
Added this class implementing AudioStreamDescription to export the
information about the audio stream to libwebrtc.
* platform/mediastream/gstreamer/GStreamerCaptureDevice.h: Added
this base class for the audio and video capturing devices, it
implements general WebKit CaptureDevice class.
* platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.cpp:
Added this class that implements the system monitor to get the
list of available devices in the system. It uses GstDeviceMonitor
to handle the operation. It uses two singleton device managers one
for audio and another one for video, as required by the
RealtimeMediaSourceCenter design.
* platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.h: Ditto.
* platform/mediastream/gstreamer/GStreamerCapturer.cpp: Added this
base class representing how GStreamer captures the media from the
input devices in the system. Two classes inherit from this one to
capture audio and video. It setups the GStreamer pipeline and adds
functions to control it.
* platform/mediastream/gstreamer/GStreamerCapturer.h: Ditto.
* platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp: Added.
Implements a subclass of GstBin as a source element that will contain several
GstAppSrc, basically one per MediaStreamTrackPrivate of the MediaStreamPrivate
passed in parameter. It adds Observers on the MediaStreamTracks and
pushes the data to the sources as required. The element implements the GstURIHandler
interface so it can be used in playbin. The MediaPlayerPrivateGStreamer is responsible
for passing the MediaStreamPrivate object to the source when required.
(WebCore::webkitMediaStreamSrcPadProbeCb): Event probe that fixes stream_start events (setting the ID etc)
and finally add src pads to the pipeline.
* platform/mediastream/gstreamer/GStreamerMediaStreamSource.h: Ditto.
* platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp:
Added this RealtimeMediaSource representing the source of the
video data for the GStreamer platform. It handles the settings and
capabilities of the source and creates the capturer used to
control the operation of the stream.
* platform/mediastream/gstreamer/GStreamerVideoCaptureSource.h: Ditto.
* platform/mediastream/gstreamer/GStreamerVideoCapturer.cpp: Added
this class that inherits from the GStreamerCapturer and controls
the GStreamer pipelines of the video streams of the system.
* platform/mediastream/gstreamer/GStreamerVideoCapturer.h: Ditto.
* platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp: Added. Implementation of a Mock capturer for audio stream.
Subclasses GStreamerAudioCapturer and wraps a MockRealtimeAudioSource so that the behaviour is the same a MockRealtimeAudioSource
but still the GStreamer implementation code paths are tested.
* platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h: Ditto.
* platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp: Added. Implementation of a Mock capturer for video stream.
Subclasses GStreamerVideoCapturer and wraps a MockRealtimeVideoSource so that the behaviour is the same a MockRealtimeVideoSource
but still the GStreamer implementation code paths are tested.
* platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h: Ditto.
* platform/mediastream/gstreamer/RealtimeMediaSourceCenterLibWebRTC.cpp:
Added this class that implements the key RealtimeMediaSourceCenter
functions to configure the base class for the platform, using the
other GStreamer classes.
* platform/mock/MockRealtimeAudioSource.cpp: Do not build ::create if GStreamer implementation is built
* platform/mock/MockRealtimeVideoSource.cpp: Do not build ::create if GStreamer implementation is built

Tools:

Patch by Thibault Saunier <tsaunier@igalia.com> on 2018-06-07
Reviewed by Philippe Normand.

* Scripts/webkitpy/style/checker.py: Apply special formatting rules for new GObject subclasses.
* gstreamer/jhbuild.modules: Added a patch for the gst-plugins-base.
* gstreamer/patches/gst-plugins-base-0001-parsebin-Post-STREAM_COLLECTION-on-EVENT_STREAM_COLL.patch:
Added this fix to gst-plugings-base to fix the decodebin3. Merged as 89d0e9cc92a86aa0227ee87406737b6d31670aea

LayoutTests:

Patch by Thibault Saunier <tsaunier@igalia.com> on 2018-06-07
Reviewed by Philippe Normand.

* platform/gtk/TestExpectations: Reactivate MediaStream tests and enable all tests
related to the mediaDevice.enumerateDevices and MediaStream (not RTCPeerConnection nor
webaudio).

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@232589 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed
tree: 60b65d0cd9471368690852915b9280eb633862bd
  1. Examples/
  2. JSTests/
  3. LayoutTests/
  4. ManualTests/
  5. PerformanceTests/
  6. Source/
  7. Tools/
  8. WebDriverTests/
  9. WebKit.xcworkspace/
  10. WebKitLibraries/
  11. Websites/
  12. .clang-format
  13. .dir-locals.el
  14. .gitattributes
  15. .gitignore
  16. ChangeLog
  17. ChangeLog-2012-05-22
  18. ChangeLog-2018-01-01
  19. CMakeLists.txt
  20. Makefile
  21. Makefile.shared
  22. ReadMe.md
ReadMe.md

WebKit

WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.

Feature Status

Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.

Trying the Latest

On macOS, download Safari Technology Preview to test the latest version of WebKit. On Linux, download Epiphany Technology Preview. On Windows, you'll have to build it yourself.

Reporting Bugs

  1. Search WebKit Bugzilla to see if there is an existing report for the bug you've encountered.
  2. Create a Bugzilla account to to report bugs (and to comment on them) if you haven't done so already.
  3. File a bug in accordance with our guidelines.

Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.

Getting the Code

On Windows, follow the instructions on our website.

Cloning the Git SVN Repository

Run the following command to clone WebKit's Git SVN repository:

git clone git://git.webkit.org/WebKit.git WebKit

If you want to be able to commit changes to the repository, or just want to check out branches that aren’t contained in WebKit.git, you will need track WebKit's Subversion repository. You can run the following command to configure this and other options of the new Git clone for WebKit development.

Tools/Scripts/webkit-patch setup-git-clone

For information about this, and other aspects of using Git with WebKit, read the wiki page.

Checking out the Subversion Repository

If you don‘t want to use Git, run the following command to check out WebKit’s Subversion repository:

svn checkout https://svn.webkit.org/repository/webkit/trunk WebKit

Building WebKit

Building macOS Port

Install Xcode and its command line tools if you haven't done so already:

  1. Install Xcode Get Xcode from https://developer.apple.com/downloads. To build WebKit for OS X, Xcode 5.1.1 or later is required. To build WebKit for iOS Simulator, Xcode 7 or later is required.
  2. Install the Xcode Command Line Tools In Terminal, run the command: xcode-select --install

Run the following command to build a debug build with debugging symbols and assertions:

Tools/Scripts/build-webkit --debug

For performance testing, and other purposes, use --release instead.

Using Xcode

You can open WebKit.xcworkspace to build and debug WebKit within WebKit.

If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use WebKitBuild directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select “Custom”, “Relative to Workspace”, and enter WebKitBuild for both Products and Intermediates.

Building iOS Port

The first time after you install a new Xcode, you will need to run the following command to enable Xcode to build command line tools for iOS Simulator:

sudo Tools/Scripts/configure-xcode-for-ios-development

Without this step, you will see the error message: “target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.” when building target JSCLLIntOffsetsExtractor of project JavaScriptCore.

Run the following command to build a debug build with debugging symbols and assertions for iOS:

Tools/Scripts/build-webkit --debug --ios-simulator.

Building the GTK+ Port

For production builds:

cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja
ninja
sudo ninja install

For development builds:

Tools/gtk/install-dependencies
Tools/Scripts/update-webkitgtk-libs
Tools/Scripts/build-webkit --gtk --debug

For more information on building WebKitGTK+, see the wiki page.

Building the WPE Port

For production builds:

cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja
ninja
sudo ninja install

For development builds:

Tools/wpe/install-dependencies
Tools/Scripts/update-webkitwpe-libs
Tools/Scripts/build-webkit --wpe --debug

Building Windows Port

For building WebKit on Windows, see the wiki page.

Running WebKit

With Safari and Other macOS Applications

Run the following command to launch Safari with your local build of WebKit:

Tools/Scripts/run-safari --debug

The run-safari script sets the DYLD_FRAMEWORK_PATH environment variable to point to your build products, and then launches /Applications/Safari.app. DYLD_FRAMEWORK_PATH tells the system loader to prefer your build products over the frameworks installed in /System/Library/Frameworks.

To run other applications with your local build of WebKit, run the following command:

Tools/Scripts/run-webkit-app <application-path>

iOS Simulator

Run the following command to launch iOS simulator with your local build of WebKit:

run-safari --debug --ios-simulator

In both cases, if you have built release builds instead, use --release instead of --debug.

Linux Ports

If you have a development build, you can use the run-minibrowser script, e.g.:

run-minibrowser --debug --wpe

Pass one of --gtk, --jsc-only, or --wpe to indicate the port to use.

Contribute

Congratulations! You’re up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read Contributing Code.