Bug 186933

Summary: [WPE][GTK] Implement WebAudioSourceProviderGStreamer to allow bridging MediaStream and the WebAudio APIs
Product: WebKit Reporter: Thibault Saunier <tsaunier>
Component: WebRTCAssignee: Thibault Saunier <tsaunier>
Status: RESOLVED FIXED    
Severity: Normal CC: alex, commit-queue, pnormand, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=218335
Bug Depends on:    
Bug Blocks: 187064    
Attachments:
Description Flags
Patch
none
Patch none

Description Thibault Saunier 2018-06-22 10:56:19 PDT
This is also required for many WebRTC LayoutTests.
Comment 1 Thibault Saunier 2018-12-06 07:34:52 PST
Created attachment 356726 [details]
Patch
Comment 2 Philippe Normand 2018-12-06 08:28:03 PST
Comment on attachment 356726 [details]
Patch

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

> Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:138
> +    if (m_pipeline)
> +        gst_element_set_state(m_pipeline.get(), GST_STATE_NULL);

Needs ifdef guards

> Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:241
> +    if (m_pipeline)
> +        gst_element_set_state(m_pipeline.get(), GST_STATE_PLAYING);

Ditto

> Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCapturer.cpp:45
>      GstElement* source = GStreamerCapturer::createSource();

No need for this variable anymore

> Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp:40
> +static const double Tau = 2 * M_PI;
> +static const double BipBopDuration = 0.07;
> +static const double BipBopVolume = 0.5;
> +static const double BipFrequency = 1500;
> +static const double BopFrequency = 500;
> +static const double HumFrequency = 150;
> +static const double HumVolume = 0.1;

I think we usually name static constants like s_fooBar :)

> Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp:119
> +            addHum(BipBopVolume, BopFrequency, rate, 0, static_cast<float*>(m_bipBopBuffer.data() + bopStart), bipBopSampleCount);

shouldn't the 0 here be bopStart?
Comment 3 Thibault Saunier 2018-12-06 09:36:14 PST
Created attachment 356735 [details]
Patch
Comment 4 Thibault Saunier 2018-12-06 09:52:24 PST
(In reply to Philippe Normand from comment #2)
> Comment on attachment 356726 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=356726&action=review
> 
> > Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:138
> > +    if (m_pipeline)
> > +        gst_element_set_state(m_pipeline.get(), GST_STATE_NULL);
> 
> Needs ifdef guards
> 
> > Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:241
> > +    if (m_pipeline)
> > +        gst_element_set_state(m_pipeline.get(), GST_STATE_PLAYING);
> 
> Ditto

I am just gonna remove the ifdefing of the varible, it won't be used in some cases
but to me it is better than ifdefing all around.

> > Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCapturer.cpp:45
> >      GstElement* source = GStreamerCapturer::createSource();
> 
> No need for this variable anymore

The whole override is not needed anymore, removed :-)
 
> > Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp:40
> > +static const double Tau = 2 * M_PI;
> > +static const double BipBopDuration = 0.07;
> > +static const double BipBopVolume = 0.5;
> > +static const double BipFrequency = 1500;
> > +static const double BopFrequency = 500;
> > +static const double HumFrequency = 150;
> > +static const double HumVolume = 0.1;
> 
> I think we usually name static constants like s_fooBar :)

Done.

> > Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp:119
> > +            addHum(BipBopVolume, BopFrequency, rate, 0, static_cast<float*>(m_bipBopBuffer.data() + bopStart), bipBopSampleCount);
> 
> shouldn't the 0 here be bopStart?

Nop, we already offset the data.
Comment 5 Philippe Normand 2018-12-07 01:37:26 PST
So the start param of addHum() is basically useless then?
Comment 6 Thibault Saunier 2018-12-07 02:10:15 PST
(In reply to Philippe Normand from comment #5)
> So the start param of addHum() is basically useless then?

....

> Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp:85
> +                    addHum(s_HumVolume, s_HumFrequency, sampleRate(), m_samplesRendered, (float*)map.data(), bipBopCount);

It is used here.
Comment 7 Philippe Normand 2018-12-07 02:14:05 PST
Comment on attachment 356735 [details]
Patch

OK then!
Comment 8 WebKit Commit Bot 2018-12-07 02:49:04 PST
Comment on attachment 356735 [details]
Patch

Clearing flags on attachment: 356735

Committed r238951: <https://trac.webkit.org/changeset/238951>
Comment 9 WebKit Commit Bot 2018-12-07 02:49:05 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2018-12-07 02:50:41 PST
<rdar://problem/46550463>