Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebRTC audio support #1368

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
8a0b09c
Remove old webrtc binding source
Mar 18, 2019
e8267c4
Add new webrtc bindings source from node-webrtc module
Mar 18, 2019
c46321f
Remove binding.cc deinitialization code
Mar 18, 2019
5eaeb01
Remove getusermedia video support
Mar 18, 2019
2f83924
Add missing webrtc Winsock2.h includes
Mar 18, 2019
6fb0829
Flag out Winsock2.h includes to be windows-only
Mar 18, 2019
0762961
Comment out non-functional RTCRtpSender/RTCRtpReceiver getCapabilitie…
Mar 18, 2019
50576e2
Update PeerConnectionFactory constructor usage
Mar 18, 2019
2e783aa
Add new WebRTC audio driver
Mar 18, 2019
caa0538
Bugfix webrtc binary binding
Mar 18, 2019
aac361b
Remove old RTC js bindings
Mar 18, 2019
0fe5a5d
Add node-webrtc RTC js bindings
Mar 18, 2019
458e48f
Add new RTC js binding files
Mar 18, 2019
30a1c5d
Bugfix RTC js binding to native
Mar 18, 2019
9e46162
Add missing RTC js RTCTrackEvent exposure
Mar 18, 2019
485d81c
Update window exposure for new RTC implementation
Mar 18, 2019
0463754
Rename webaudiocontext MediaStreamTrack -> AudioMediaStreamTrack due …
Mar 18, 2019
8ab0f9a
Update windows webrtc build spec
Mar 18, 2019
a1f854b
Add missing peerconnectionfactory.cc video encoder/decoder includes
Mar 18, 2019
cb97a30
Add missing webrtc.h binding
Mar 18, 2019
cfd8e95
Hook in WebRTC getUserMedia version in Window.js
Mar 18, 2019
37a1146
Update LUMIN binding.gyp for new webrtc build
Mar 18, 2019
0ad3dac
Remove binding.gyp dead WebRTC sources
Mar 18, 2019
4603e69
Bugfix magic leap build exokit.cpp
Mar 18, 2019
649d436
Bugfix WebAudioBindingImpl syntax
Mar 18, 2019
2be5a92
Bugfix mic zeroing
Mar 19, 2019
d7ee1d8
Bugfix WebRTC fake audio device buffering
Mar 19, 2019
f01cf67
Bugfix lunix arm64 WebRTC build
Mar 19, 2019
583563f
Bugfix macOS WebRTC build
Mar 19, 2019
1ac2e37
Bugfix linux WebRTC build
Mar 19, 2019
105e1da
Bugfix getusermedia.cc template handling
Mar 19, 2019
338435c
Bump native-webrtc-deps version again
Mar 19, 2019
927c363
Bump native-webrtc-deps version
Mar 20, 2019
a766d71
Add MediaStreamTrack EventTarget method stubs
Mar 21, 2019
6886ac8
Mark DataChannel properties as configurable
Mar 21, 2019
7e4848a
Bump native-webrtc-deps version
Mar 22, 2019
0f51892
WebAudio bindings dead code removal
Mar 22, 2019
ddc68b4
Remove binary WebAudio media streams in favor of the ones from WebRTC…
Mar 22, 2019
9f367b4
Clean up root webrtc bindings
Mar 22, 2019
93bdd02
Bump native-webrtc-deps version
Mar 22, 2019
02eddf4
Remove dead WebAudio MediaStream binary bindings exposure
Mar 22, 2019
2b21394
Update webrtc binding Handle to Local for node 12 support
Mar 23, 2019
919fdb8
Remove dead v8::Handle exposure in webrtc bindings
Mar 23, 2019
a7bfdc6
More webrtc bindings node 12 debugging
Mar 23, 2019
d33fb82
Move webrtc bindings v8.h due to naming conflict
Mar 23, 2019
49bfa92
Small webrtc bindings v8 converters bugfixing
Mar 23, 2019
36b037a
Small webrtc bindings interfaces node 12 cleanup
Mar 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'deps/exokit-bindings/windowsystem/src/*.cc',
'deps/exokit-bindings/glfw/src/*.cc',
'deps/exokit-bindings/webrtc/src/*.cc',
'deps/exokit-bindings/webrtc/src/converters/*.cc',
'deps/exokit-bindings/webrtc/src/webrtc/*.cc',
'deps/oculus/src/*.cpp',
'deps/openvr/src/*.cpp',
'deps/exokit-bindings/leapmotion/src/*.cc',
Expand All @@ -38,6 +40,8 @@
"<!(node -e \"console.log(require.resolve('native-browser-deps').slice(0, -9) + '/lib')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc/third_party/abseil-cpp')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc/third_party/libyuv/include')\")",
"<!(node -e \"console.log(require.resolve('native-oculus-deps').slice(0, -9) + '/Include')\")",
"<!(node -e \"console.log(require.resolve('native-openvr-deps').slice(0, -9) + '/headers')\")",
"<!(node -e \"console.log(require.resolve('leapmotion').slice(0, -9) + '/include')\")",
Expand All @@ -56,6 +60,7 @@
'<(module_root_dir)/deps/exokit-bindings/videocontext/include',
'<(module_root_dir)/deps/exokit-bindings/windowsystem/include',
'<(module_root_dir)/deps/exokit-bindings/glfw/include',
'<(module_root_dir)/deps/exokit-bindings/webrtc',
'<(module_root_dir)/deps/exokit-bindings/webrtc/include',
'<(module_root_dir)/deps/oculus/include',
'<(module_root_dir)/deps/openvr/include',
Expand Down Expand Up @@ -92,11 +97,15 @@
'libcef_dll_wrapper.lib',
'LibOVR.lib',
'webrtc.lib',
'peerconnection.lib',
'create_pc_factory.lib',
'bbr.lib',
'winmm.lib',
'wmcodecdspuuid.lib',
'secur32.lib',
'msdmo.lib',
'dmoguids.lib',
'Iphlpapi.lib',
],
'copies': [
{
Expand Down Expand Up @@ -164,6 +173,8 @@
'<!@(ls -1 deps/exokit-bindings/windowsystem/src/*.cc)',
'<!@(ls -1 deps/exokit-bindings/glfw/src/*.cc)',
'<!@(ls -1 deps/exokit-bindings/webrtc/src/*.cc)',
'<!@(ls -1 deps/exokit-bindings/webrtc/src/converters/*.cc)',
'<!@(ls -1 deps/exokit-bindings/webrtc/src/webrtc/*.cc)',
'<!@(ls -1 deps/openvr/src/*.cpp)',
],
'include_dirs': [
Expand All @@ -178,6 +189,8 @@
"<!(node -e \"console.log(require.resolve('native-browser-deps').slice(0, -9) + '/lib')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc/third_party/abseil-cpp')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc/third_party/libyuv/include')\")",
"<!(node -e \"console.log(require.resolve('native-openvr-deps').slice(0, -9) + '/headers')\")",
'<(module_root_dir)/deps/exokit-bindings',
'<(module_root_dir)/deps/exokit-bindings/utf8',
Expand All @@ -194,7 +207,7 @@
'<(module_root_dir)/deps/exokit-bindings/videocontext/include',
'<(module_root_dir)/deps/exokit-bindings/windowsystem/include',
'<(module_root_dir)/deps/exokit-bindings/glfw/include',
'<(module_root_dir)/deps/exokit-bindings/webrtc/include',
'<(module_root_dir)/deps/exokit-bindings/webrtc',
'<(module_root_dir)/deps/openvr/include',
],
'library_dirs': [
Expand Down Expand Up @@ -303,7 +316,7 @@
'<(module_root_dir)/deps/exokit-bindings/videocontext/include',
'<(module_root_dir)/deps/exokit-bindings/windowsystem/include',
'<(module_root_dir)/deps/exokit-bindings/glfw/include',
'<(module_root_dir)/deps/exokit-bindings/webrtc/include',
'<(module_root_dir)/deps/exokit-bindings/webrtc',
],
'library_dirs': [
"<!(node -e \"console.log(require.resolve('native-graphics-deps').slice(0, -9) + '/lib2/arm64/glew')\")",
Expand Down Expand Up @@ -379,6 +392,8 @@
'<!@(ls -1 deps/exokit-bindings/windowsystem/src/*.cc)',
'<!@(ls -1 deps/exokit-bindings/glfw/src/*.cc)',
'<!@(ls -1 deps/exokit-bindings/webrtc/src/*.cc)',
'<!@(ls -1 deps/exokit-bindings/webrtc/src/converters/*.cc)',
'<!@(ls -1 deps/exokit-bindings/webrtc/src/webrtc/*.cc)',
'<!@(ls -1 deps/openvr/src/*.cpp)',
],
'include_dirs': [
Expand All @@ -393,6 +408,8 @@
"<!(node -e \"console.log(require.resolve('native-browser-deps').slice(0, -9) + '/lib')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc/third_party/abseil-cpp')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc/third_party/libyuv/include')\")",
"<!(node -e \"console.log(require.resolve('native-openvr-deps').slice(0, -9) + '/headers')\")",
'<(module_root_dir)/deps/exokit-bindings',
'<(module_root_dir)/deps/exokit-bindings/utf8',
Expand All @@ -409,7 +426,7 @@
'<(module_root_dir)/deps/exokit-bindings/videocontext/include',
'<(module_root_dir)/deps/exokit-bindings/windowsystem/include',
'<(module_root_dir)/deps/exokit-bindings/glfw/include',
'<(module_root_dir)/deps/exokit-bindings/webrtc/include',
'<(module_root_dir)/deps/exokit-bindings/webrtc',
'<(module_root_dir)/deps/openvr/include',
],
'library_dirs': [
Expand Down Expand Up @@ -498,6 +515,8 @@
'<!@(ls -1 deps/exokit-bindings/windowsystem/src/*.cc)',
'<!@(ls -1 deps/exokit-bindings/egl/src/*.cc)',
'<!@(ls -1 deps/exokit-bindings/webrtc/src/*.cc)',
'<!@(ls -1 deps/exokit-bindings/webrtc/src/converters/*.cc)',
'<!@(ls -1 deps/exokit-bindings/webrtc/src/webrtc/*.cc)',
'<!@(ls -1 deps/exokit-bindings/magicleap/src/*.cc)',
'<!@(ls -1 deps/exokit-bindings/magicleap/deps/sjpeg/src/*.cc)',
],
Expand All @@ -512,6 +531,8 @@
"<!(node -e \"console.log(require.resolve('native-browser-deps').slice(0, -9) + '/lib')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc/third_party/abseil-cpp')\")",
"<!(node -e \"console.log(require.resolve('native-webrtc-deps').slice(0, -9) + '/include/webrtc/third_party/libyuv/include')\")",
'<(module_root_dir)/deps/exokit-bindings',
'<(module_root_dir)/deps/exokit-bindings/utf8',
'<(module_root_dir)/deps/exokit-bindings/node',
Expand All @@ -527,7 +548,7 @@
'<(module_root_dir)/deps/exokit-bindings/videocontext/include',
'<(module_root_dir)/deps/exokit-bindings/windowsystem/include',
'<(module_root_dir)/deps/exokit-bindings/egl/include',
'<(module_root_dir)/deps/exokit-bindings/webrtc/include',
'<(module_root_dir)/deps/exokit-bindings/webrtc',
'<(module_root_dir)/deps/exokit-bindings/magicleap/include',
'<(module_root_dir)/deps/exokit-bindings/magicleap/deps/sjpeg/src',
"<!(echo $MLSDK)/lumin/stl/libc++/include",
Expand Down
2 changes: 1 addition & 1 deletion deps/exokit-bindings/bindings/include/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ Local<Object> makeCanvasPattern();
Local<Object> makeAudio();
Local<Object> makeVideo(Local<Value> imageDataCons);
Local<Object> makeBrowser();
Local<Object> makeRtc();
Local<Object> makeRtc(Local<Object> module);

#endif
10 changes: 3 additions & 7 deletions deps/exokit-bindings/bindings/src/bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ Local<Object> makeAudio() {
exports->Set(JS_STR("AudioProcessingEvent"), audioProcessingEventCons);
Local<Value> scriptProcessorNodeCons = webaudio::ScriptProcessorNode::Initialize(isolate, audioBufferCons, audioProcessingEventCons);
exports->Set(JS_STR("ScriptProcessorNode"), scriptProcessorNodeCons);
Local<Value> mediaStreamTrackCons = webaudio::MediaStreamTrack::Initialize(isolate);
exports->Set(JS_STR("MediaStreamTrack"), mediaStreamTrackCons);
Local<Value> microphoneMediaStreamCons = webaudio::MicrophoneMediaStream::Initialize(isolate, mediaStreamTrackCons);
exports->Set(JS_STR("MicrophoneMediaStream"), microphoneMediaStreamCons);
exports->Set(JS_STR("AudioContext"), webaudio::AudioContext::Initialize(isolate, audioListenerCons, audioSourceNodeCons, audioDestinationNodeCons, gainNodeCons, analyserNodeCons, pannerNodeCons, audioBufferCons, audioBufferSourceNodeCons, audioProcessingEventCons, stereoPannerNodeCons, oscillatorNodeCons, scriptProcessorNodeCons, mediaStreamTrackCons, microphoneMediaStreamCons));
exports->Set(JS_STR("AudioContext"), webaudio::AudioContext::Initialize(isolate, audioListenerCons, audioSourceNodeCons, audioDestinationNodeCons, gainNodeCons, analyserNodeCons, pannerNodeCons, audioBufferCons, audioBufferSourceNodeCons, audioProcessingEventCons, stereoPannerNodeCons, oscillatorNodeCons, scriptProcessorNodeCons));

return scope.Escape(exports);
}
Expand All @@ -136,14 +132,14 @@ Local<Object> makeBrowser() {
}
#endif

Local<Object> makeRtc() {
Local<Object> makeRtc(Local<Object> module) {
Isolate *isolate = Isolate::GetCurrent();

Nan::EscapableHandleScope scope;

Local<Object> exports = Nan::New<Object>();

node_webrtc::init(exports);
node_webrtc::init(exports, module);

return scope.Escape(exports);
}
4 changes: 1 addition & 3 deletions deps/exokit-bindings/webaudiocontext/include/AudioContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include <AudioBuffer.h>
#include <ScriptProcessorNode.h>
#include <AudioListener.h>
#include <MediaStreamTrack.h>
#include <MicrophoneMediaStream.h>
#include <AudioDestinationGenericImpl.h>

using namespace std;
Expand All @@ -32,7 +30,7 @@ lab::AudioContext *getDefaultAudioContext(float sampleRate = lab::DefaultSampleR

class AudioContext : public ObjectWrap {
public:
static Local<Object> Initialize(Isolate *isolate, Local<Value> audioListenerCons, Local<Value> audioSourceNodeCons, Local<Value> audioDestinationNodeCons, Local<Value> gainNodeCons, Local<Value> analyserNodeCons, Local<Value> pannerNodeCons, Local<Value> audioBufferCons, Local<Value> audioBufferSourceNodeCons, Local<Value> audioProcessingEventCons, Local<Value> stereoPannerNodeCons, Local<Value> oscillatorNodeCons, Local<Value> scriptProcessorNodeCons, Local<Value> mediaStreamTrackCons, Local<Value> microphoneMediaStreamCons);
static Local<Object> Initialize(Isolate *isolate, Local<Value> audioListenerCons, Local<Value> audioSourceNodeCons, Local<Value> audioDestinationNodeCons, Local<Value> gainNodeCons, Local<Value> analyserNodeCons, Local<Value> pannerNodeCons, Local<Value> audioBufferCons, Local<Value> audioBufferSourceNodeCons, Local<Value> audioProcessingEventCons, Local<Value> stereoPannerNodeCons, Local<Value> oscillatorNodeCons, Local<Value> scriptProcessorNodeCons);
void Close();
Local<Object> CreateMediaElementSource(Local<Function> audioDestinationNodeConstructor, Local<Object> mediaElement, Local<Object> audioContextObj);
Local<Object> CreateMediaStreamSource(Local<Function> audioSourceNodeConstructor, Local<Object> mediaStream, Local<Object> audioContextObj);
Expand Down
48 changes: 0 additions & 48 deletions deps/exokit-bindings/webaudiocontext/include/MediaStreamTrack.h

This file was deleted.

This file was deleted.

10 changes: 4 additions & 6 deletions deps/exokit-bindings/webaudiocontext/src/AudioContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AudioContext::AudioContext(float sampleRate) {

AudioContext::~AudioContext() {}

Local<Object> AudioContext::Initialize(Isolate *isolate, Local<Value> audioListenerCons, Local<Value> audioSourceNodeCons, Local<Value> audioDestinationNodeCons, Local<Value> gainNodeCons, Local<Value> analyserNodeCons, Local<Value> pannerNodeCons, Local<Value> audioBufferCons, Local<Value> audioBufferSourceNodeCons, Local<Value> audioProcessingEventCons, Local<Value> stereoPannerNodeCons, Local<Value> oscillatorNodeCons, Local<Value> scriptProcessorNodeCons, Local<Value> mediaStreamTrackCons, Local<Value> microphoneMediaStreamCons) {
Local<Object> AudioContext::Initialize(Isolate *isolate, Local<Value> audioListenerCons, Local<Value> audioSourceNodeCons, Local<Value> audioDestinationNodeCons, Local<Value> gainNodeCons, Local<Value> analyserNodeCons, Local<Value> pannerNodeCons, Local<Value> audioBufferCons, Local<Value> audioBufferSourceNodeCons, Local<Value> audioProcessingEventCons, Local<Value> stereoPannerNodeCons, Local<Value> oscillatorNodeCons, Local<Value> scriptProcessorNodeCons) {
#if defined(ANDROID) || defined(LUMIN)
lab::SetGenericFunctions(
adgCreate,
Expand Down Expand Up @@ -83,8 +83,6 @@ Local<Object> AudioContext::Initialize(Isolate *isolate, Local<Value> audioListe
ctorFn->Set(JS_STR("AudioBufferSourceNode"), audioBufferSourceNodeCons);
ctorFn->Set(JS_STR("AudioProcessingEvent"), audioProcessingEventCons);
ctorFn->Set(JS_STR("ScriptProcessorNode"), scriptProcessorNodeCons);
ctorFn->Set(JS_STR("MediaStreamTrack"), mediaStreamTrackCons);
ctorFn->Set(JS_STR("MicrophoneMediaStream"), microphoneMediaStreamCons);

return scope.Escape(ctorFn);
}
Expand Down Expand Up @@ -314,14 +312,14 @@ NAN_METHOD(AudioContext::CreateMediaElementSource) {
NAN_METHOD(AudioContext::CreateMediaStreamSource) {
Nan::HandleScope scope;

if (info[0]->IsObject() && JS_OBJ(JS_OBJ(info[0])->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("MicrophoneMediaStream"))) {
Local<Object> microphoneMediaStream = Local<Object>::Cast(info[0]);
if (info[0]->IsObject() && JS_OBJ(JS_OBJ(info[0])->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("MediaStream"))) {
Local<Object> mediaStream = Local<Object>::Cast(info[0]);

Local<Object> audioContextObj = info.This();
AudioContext *audioContext = ObjectWrap::Unwrap<AudioContext>(audioContextObj);

Local<Function> audioSourceNodeConstructor = Local<Function>::Cast(JS_OBJ(audioContextObj->Get(JS_STR("constructor")))->Get(JS_STR("AudioSourceNode")));
Local<Object> audioNodeObj = audioContext->CreateMediaStreamSource(audioSourceNodeConstructor, microphoneMediaStream, audioContextObj);
Local<Object> audioNodeObj = audioContext->CreateMediaStreamSource(audioSourceNodeConstructor, mediaStream, audioContextObj);

info.GetReturnValue().Set(audioNodeObj);
} else {
Expand Down
18 changes: 1 addition & 17 deletions deps/exokit-bindings/webaudiocontext/src/AudioSourceNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ NAN_METHOD(AudioSourceNode::New) {
} else {
Nan::ThrowError("AudioSourceNode: invalid audio element state");
}
} else if (info[0]->IsObject() && JS_OBJ(JS_OBJ(info[0])->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("MicrophoneMediaStream"))) {
} else if (info[0]->IsObject() && JS_OBJ(JS_OBJ(info[0])->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("MediaStream"))) {
AudioSourceNode *audioSourceNode = new AudioSourceNode();
Local<Object> audioSourceNodeObj = info.This();
audioSourceNode->Wrap(audioSourceNodeObj);
Expand All @@ -66,22 +66,6 @@ NAN_METHOD(AudioSourceNode::New) {
}

info.GetReturnValue().Set(audioSourceNodeObj);

/* Local<Object> microphoneMediaStreamObj = Local<Object>::Cast(info[0]);
MicrophoneMediaStream *microphoneMediaStream = ObjectWrap::Unwrap<MicrophoneMediaStream>(Local<Object>::Cast(microphoneMediaStreamObj));

if (microphoneMediaStream->audioNode) {
AudioSourceNode *audioSourceNode = new AudioSourceNode();
Local<Object> audioSourceNodeObj = info.This();
audioSourceNode->Wrap(audioSourceNodeObj);

audioSourceNode->context.Reset(audioContextObj);
audioSourceNode->audioNode = microphoneMediaStream->audioNode;

info.GetReturnValue().Set(audioSourceNodeObj);
} else {
Nan::ThrowError("AudioSourceNode: media stream is not live");
} */
} else {
Nan::ThrowError("AudioSourceNode: invalid media element");
}
Expand Down
Loading