Skip to content

Commit a2655b2

Browse files
committed
[GStreamer][webaudio] Rialto with WebKit audio sink
https://bugs.webkit.org/show_bug.cgi?id=278911 Reviewed by Philippe Normand. Rialto supports single instance of webaudio pcm sing so it is not possible to create more than one WebAudio context. Use WebKit audio sink instead, that mixes all webaudio contextes into single stream and pass it to rialto webaudio sink. With webkit 2.38 webaudio src element produce 'non-interleaved' audio format that is not fully supported by some platform sinks (audio output is breaking). WebKit audio sink (mixer pipeline) also doesn't seem to handle that correctly. Mixer pipeline fails to negotiate caps and inter audio sink reqires the latest gst version to work with such stream. Patch by Andrzej Surdej <Andrzej_Surdej@comcast.com>. * Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp: (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer): * Source/WebCore/platform/gstreamer/GStreamerQuirkRialto.cpp: (WebCore::GStreamerQuirkRialto::createWebAudioSink): Canonical link: https://commits.webkit.org/283137@main
1 parent 332c665 commit a2655b2

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,23 @@ AudioDestinationGStreamer::AudioDestinationGStreamer(AudioIOCallback& callback,
156156
GstElement* audioResample = makeGStreamerElement("audioresample", nullptr);
157157
gst_bin_add_many(GST_BIN_CAST(m_pipeline.get()), m_src.get(), audioConvert, audioResample, audioSink.get(), nullptr);
158158

159-
// Link src pads from webkitAudioSrc to audioConvert ! audioResample ! autoaudiosink.
159+
// Link src pads from webkitAudioSrc to audioConvert ! audioResample ! [capsfilter !] webaudiosink.
160160
gst_element_link_pads_full(m_src.get(), "src", audioConvert, "sink", GST_PAD_LINK_CHECK_NOTHING);
161161
gst_element_link_pads_full(audioConvert, "src", audioResample, "sink", GST_PAD_LINK_CHECK_NOTHING);
162-
gst_element_link_pads_full(audioResample, "src", audioSink.get(), "sink", GST_PAD_LINK_CHECK_NOTHING);
162+
163+
if (!webkitGstCheckVersion(1, 20, 4)) {
164+
// Force audio conversion to 'interleaved' format (by audioconvert element).
165+
// 1) Some platform sinks don't support non-interleaved audio without special caps (rialtowebaudiosink).
166+
// 2) Interaudio sink/src doesn't fully support non-interleaved audio (webkit audio sink)
167+
// 3) audiomixer doesn't support non-interleaved audio in output pipeline (webkit audio sink)
168+
GstElement* capsFilter = makeGStreamerElement("capsfilter", nullptr);
169+
GRefPtr<GstCaps> caps = adoptGRef(gst_caps_new_simple("audio/x-raw", "layout", G_TYPE_STRING, "interleaved", nullptr));
170+
g_object_set(capsFilter, "caps", caps.get(), nullptr);
171+
gst_bin_add(GST_BIN_CAST(m_pipeline.get()), capsFilter);
172+
gst_element_link_pads_full(audioResample, "src", capsFilter, "sink", GST_PAD_LINK_CHECK_NOTHING);
173+
gst_element_link_pads_full(capsFilter, "src", audioSink.get(), "sink", GST_PAD_LINK_CHECK_NOTHING);
174+
} else
175+
gst_element_link_pads_full(audioResample, "src", audioSink.get(), "sink", GST_PAD_LINK_CHECK_NOTHING);
163176
}
164177

165178
AudioDestinationGStreamer::~AudioDestinationGStreamer()

Source/WebCore/platform/gstreamer/GStreamerQuirkRialto.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#if USE(GSTREAMER)
3030

3131
#include "GStreamerCommon.h"
32+
#include "WebKitAudioSinkGStreamer.h"
3233
#include <wtf/OptionSet.h>
3334

3435
namespace WebCore {
@@ -87,6 +88,9 @@ GstElement* GStreamerQuirkRialto::createAudioSink()
8788

8889
GstElement* GStreamerQuirkRialto::createWebAudioSink()
8990
{
91+
if (GstElement* sink = webkitAudioSinkNew())
92+
return sink;
93+
9094
auto sink = makeGStreamerElement("rialtowebaudiosink", nullptr);
9195
RELEASE_ASSERT_WITH_MESSAGE(sink, "rialtowebaudiosink should be available in the system but it is not");
9296
return sink;

0 commit comments

Comments
 (0)