RESOLVED FIXED 187627
Support connecting a MediaStreamAudioDestinationNode to RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=187627
Summary Support connecting a MediaStreamAudioDestinationNode to RTCPeerConnection
youenn fablet
Reported 2018-07-12 16:34:16 PDT
We basically need to implement MediaStreamAudioSource
Attachments
Patch (19.09 KB, patch)
2018-07-12 16:41 PDT, youenn fablet
no flags
Patch (22.52 KB, patch)
2018-07-12 17:09 PDT, youenn fablet
no flags
Patch (22.62 KB, patch)
2018-07-12 17:47 PDT, youenn fablet
no flags
Patch (22.33 KB, patch)
2018-07-13 12:18 PDT, youenn fablet
no flags
Patch for landing (30.02 KB, patch)
2018-07-13 16:20 PDT, youenn fablet
no flags
youenn fablet
Comment 1 2018-07-12 16:41:19 PDT
youenn fablet
Comment 2 2018-07-12 16:41:43 PDT
youenn fablet
Comment 3 2018-07-12 17:09:02 PDT
youenn fablet
Comment 4 2018-07-12 17:47:30 PDT
Eric Carlson
Comment 5 2018-07-12 18:43:18 PDT
Comment on attachment 344906 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=344906&action=review > Source/WebCore/Modules/webaudio/MediaStreamAudioSourceCocoa.cpp:58 > + if (bus.numberOfChannels() != 1 && bus.numberOfChannels() != 2) > + return; It is probably worth adding a release error log here. > Source/WebCore/Modules/webaudio/MediaStreamAudioSourceCocoa.cpp:93 > + auto* buffer = audioBufferList.buffer(0); > + buffer->mDataByteSize = numberOfFrames * sizeof(float); > + buffer->mNumberChannels = 1; > + if (!muted()) > + memcpy(buffer->mData, bus.channel(0)->data(), buffer->mDataByteSize); > + else > + memset(buffer->mData, 0, buffer->mDataByteSize); > + } else { > + auto* buffer = audioBufferList.buffer(0); > + buffer->mDataByteSize = numberOfFrames * sizeof(float); > + buffer->mNumberChannels = 1; > + if (!muted()) > + memcpy(buffer->mData, bus.channel(0)->data(), buffer->mDataByteSize); > + else > + memset(buffer->mData, 0, buffer->mDataByteSize); > + > + buffer = audioBufferList.buffer(1); > + buffer->mDataByteSize = numberOfFrames * sizeof(float); > + buffer->mNumberChannels = 1; > + if (!muted()) > + memcpy(buffer->mData, bus.channel(1)->data(), buffer->mDataByteSize); > + else > + memset(buffer->mData, 0, buffer->mDataByteSize); > + A helper function would simplify this, something like: static void setupBuffer(WebAudioBufferList audioBufferList, int channel, size_t numberOfFrames) { auto* buffer = audioBufferList.buffer(channel); buffer->mDataByteSize = numberOfFrames * sizeof(float); buffer->mNumberChannels = 1; if (!muted()) memcpy(buffer->mData, bus.channel(channel)->data(), buffer->mDataByteSize); else memset(buffer->mData, 0, buffer->mDataByteSize); }
youenn fablet
Comment 6 2018-07-13 12:18:17 PDT
Jer Noble
Comment 7 2018-07-13 15:57:16 PDT
Comment on attachment 344965 [details] Patch r=me, with nits. View in context: https://bugs.webkit.org/attachment.cgi?id=344965&action=review > Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp:48 > +static inline Ref<MediaStream> createMediaStream(ScriptExecutionContext& context, Ref<RealtimeMediaSource>&& source) > +{ > + auto mediaStreamPrivate = MediaStreamPrivate::create(Vector<Ref<RealtimeMediaSource>>::from(WTFMove(source)), { }); > + return MediaStream::create(context, WTFMove(mediaStreamPrivate)); > +} > + This seems really awkward. Why isn't this a static create() method on MediaStream, taking a context and source? > Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h:-58 > - void setAudioFormat(size_t numberOfChannels, float sampleRate); > - void consumeAudio(AudioBus*, size_t numberOfFrames); > - > - void addAudioConsumer(AudioDestinationConsumer*); > - bool removeAudioConsumer(AudioDestinationConsumer*); > - const Vector<RefPtr<AudioDestinationConsumer>>& audioConsumers() const { return m_audioConsumers; } It looks like this was the only use of AudioDestinationConsumer, so you might as well just remove AudioDestinationConsumer.h entirely.
youenn fablet
Comment 8 2018-07-13 16:20:16 PDT
Created attachment 345000 [details] Patch for landing
youenn fablet
Comment 9 2018-07-13 16:21:22 PDT
Thanks for the review. > A helper function would simplify this, something like: > > static void setupBuffer(WebAudioBufferList audioBufferList, int channel, > size_t numberOfFrames) Added a helper routine. > > +static inline Ref<MediaStream> createMediaStream(ScriptExecutionContext& context, Ref<RealtimeMediaSource>&& source) > > +{ > > + auto mediaStreamPrivate = MediaStreamPrivate::create(Vector<Ref<RealtimeMediaSource>>::from(WTFMove(source)), { }); > > + return MediaStream::create(context, WTFMove(mediaStreamPrivate)); > > +} > > + > > This seems really awkward. Why isn't this a static create() method on > MediaStream, taking a context and source? OK, added a create to MediaStreamPrivate. > > Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h:-58 > > - void setAudioFormat(size_t numberOfChannels, float sampleRate); > > - void consumeAudio(AudioBus*, size_t numberOfFrames); > > - > > - void addAudioConsumer(AudioDestinationConsumer*); > > - bool removeAudioConsumer(AudioDestinationConsumer*); > > - const Vector<RefPtr<AudioDestinationConsumer>>& audioConsumers() const { return m_audioConsumers; } > > It looks like this was the only use of AudioDestinationConsumer, so you > might as well just remove AudioDestinationConsumer.h entirely. OK
WebKit Commit Bot
Comment 10 2018-07-13 17:04:38 PDT
Comment on attachment 345000 [details] Patch for landing Clearing flags on attachment: 345000 Committed r233829: <https://trac.webkit.org/changeset/233829>
WebKit Commit Bot
Comment 11 2018-07-13 17:04:39 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.