@sbhjt-gr/react-native-webrtc 137.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.clang-format +11 -0
- package/.eslintignore +6 -0
- package/.nvmrc +1 -0
- package/ISSUE_TEMPLATE.md +40 -0
- package/LICENSE +22 -0
- package/README.md +82 -0
- package/android/build.gradle +36 -0
- package/android/consumer-rules.pro +3 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +113 -0
- package/android/src/main/java/com/oney/WebRTCModule/CameraCaptureController.java +338 -0
- package/android/src/main/java/com/oney/WebRTCModule/CameraEventsHandler.java +49 -0
- package/android/src/main/java/com/oney/WebRTCModule/DataChannelWrapper.java +99 -0
- package/android/src/main/java/com/oney/WebRTCModule/DataPacketCryptorManager.java +63 -0
- package/android/src/main/java/com/oney/WebRTCModule/DisplayUtils.java +16 -0
- package/android/src/main/java/com/oney/WebRTCModule/EglUtils.java +66 -0
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +539 -0
- package/android/src/main/java/com/oney/WebRTCModule/LibraryLoader.java +21 -0
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionNotification.java +70 -0
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionService.java +82 -0
- package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +588 -0
- package/android/src/main/java/com/oney/WebRTCModule/RTCCryptoManager.java +493 -0
- package/android/src/main/java/com/oney/WebRTCModule/RTCVideoViewManager.java +98 -0
- package/android/src/main/java/com/oney/WebRTCModule/ReactBridgeUtil.java +36 -0
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +94 -0
- package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +342 -0
- package/android/src/main/java/com/oney/WebRTCModule/StringUtils.java +101 -0
- package/android/src/main/java/com/oney/WebRTCModule/ThreadUtils.java +41 -0
- package/android/src/main/java/com/oney/WebRTCModule/TrackCapturerEventsEmitter.java +34 -0
- package/android/src/main/java/com/oney/WebRTCModule/VideoTrackAdapter.java +137 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +1593 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModuleOptions.java +33 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModulePackage.java +21 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +583 -0
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/ProcessorProvider.java +38 -0
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +59 -0
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoFrameProcessor.java +19 -0
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoFrameProcessorFactoryInterface.java +12 -0
- package/android/src/main/java/com/oney/WebRTCModule/webrtcutils/H264AndSoftwareVideoDecoderFactory.java +73 -0
- package/android/src/main/java/com/oney/WebRTCModule/webrtcutils/H264AndSoftwareVideoEncoderFactory.java +73 -0
- package/android/src/main/java/com/oney/WebRTCModule/webrtcutils/SoftwareVideoDecoderFactoryProxy.java +36 -0
- package/android/src/main/java/com/oney/WebRTCModule/webrtcutils/SoftwareVideoEncoderFactoryProxy.java +36 -0
- package/android/src/main/java/org/webrtc/Camera1Helper.java +54 -0
- package/android/src/main/java/org/webrtc/Camera2Helper.java +52 -0
- package/android/src/main/res/values/strings.xml +5 -0
- package/android/src/main/res/values/styles.xml +8 -0
- package/apple/.placeholder +0 -0
- package/ios/RCTWebRTC/CaptureController.h +18 -0
- package/ios/RCTWebRTC/CaptureController.m +29 -0
- package/ios/RCTWebRTC/CapturerEventsDelegate.h +12 -0
- package/ios/RCTWebRTC/DataChannelWrapper.h +27 -0
- package/ios/RCTWebRTC/DataChannelWrapper.m +42 -0
- package/ios/RCTWebRTC/I420Converter.h +22 -0
- package/ios/RCTWebRTC/I420Converter.m +164 -0
- package/ios/RCTWebRTC/PIPController.h +24 -0
- package/ios/RCTWebRTC/PIPController.m +234 -0
- package/ios/RCTWebRTC/RCTConvert+WebRTC.h +16 -0
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +206 -0
- package/ios/RCTWebRTC/RTCMediaStreamTrack+React.h +10 -0
- package/ios/RCTWebRTC/RTCMediaStreamTrack+React.m +16 -0
- package/ios/RCTWebRTC/RTCVideoViewManager.h +29 -0
- package/ios/RCTWebRTC/RTCVideoViewManager.m +411 -0
- package/ios/RCTWebRTC/SampleBufferVideoCallView.h +12 -0
- package/ios/RCTWebRTC/SampleBufferVideoCallView.m +178 -0
- package/ios/RCTWebRTC/ScreenCaptureController.h +20 -0
- package/ios/RCTWebRTC/ScreenCaptureController.m +83 -0
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.h +7 -0
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +60 -0
- package/ios/RCTWebRTC/ScreenCapturer.h +19 -0
- package/ios/RCTWebRTC/ScreenCapturer.m +264 -0
- package/ios/RCTWebRTC/SerializeUtils.h +28 -0
- package/ios/RCTWebRTC/SerializeUtils.m +314 -0
- package/ios/RCTWebRTC/SocketConnection.h +13 -0
- package/ios/RCTWebRTC/SocketConnection.m +137 -0
- package/ios/RCTWebRTC/TrackCapturerEventsEmitter.h +14 -0
- package/ios/RCTWebRTC/TrackCapturerEventsEmitter.m +37 -0
- package/ios/RCTWebRTC/VideoCaptureController.h +21 -0
- package/ios/RCTWebRTC/VideoCaptureController.m +328 -0
- package/ios/RCTWebRTC/WebRTCModule+Permissions.m +75 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCAudioSession.m +20 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.h +14 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.m +165 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCFrameCryptor.m +611 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.h +14 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +545 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.h +24 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +1004 -0
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +267 -0
- package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.h +12 -0
- package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.m +166 -0
- package/ios/RCTWebRTC/WebRTCModule.h +45 -0
- package/ios/RCTWebRTC/WebRTCModule.m +149 -0
- package/ios/RCTWebRTC/WebRTCModuleOptions.h +24 -0
- package/ios/RCTWebRTC/WebRTCModuleOptions.m +31 -0
- package/ios/RCTWebRTC/videoEffects/ProcessorProvider.h +9 -0
- package/ios/RCTWebRTC/videoEffects/ProcessorProvider.m +23 -0
- package/ios/RCTWebRTC/videoEffects/VideoEffectProcessor.h +13 -0
- package/ios/RCTWebRTC/videoEffects/VideoEffectProcessor.m +23 -0
- package/ios/RCTWebRTC/videoEffects/VideoFrameProcessor.h +8 -0
- package/ios/RCTWebRTC.xcodeproj/project.pbxproj +404 -0
- package/ios/RCTWebRTC.xcworkspace/contents.xcworkspacedata +10 -0
- package/lib/commonjs/Constraints.js +2 -0
- package/lib/commonjs/Constraints.js.map +1 -0
- package/lib/commonjs/EventEmitter.js +69 -0
- package/lib/commonjs/EventEmitter.js.map +1 -0
- package/lib/commonjs/Logger.js +47 -0
- package/lib/commonjs/Logger.js.map +1 -0
- package/lib/commonjs/MediaDevices.js +54 -0
- package/lib/commonjs/MediaDevices.js.map +1 -0
- package/lib/commonjs/MediaStream.js +137 -0
- package/lib/commonjs/MediaStream.js.map +1 -0
- package/lib/commonjs/MediaStreamError.js +19 -0
- package/lib/commonjs/MediaStreamError.js.map +1 -0
- package/lib/commonjs/MediaStreamErrorEvent.js +17 -0
- package/lib/commonjs/MediaStreamErrorEvent.js.map +1 -0
- package/lib/commonjs/MediaStreamTrack.js +239 -0
- package/lib/commonjs/MediaStreamTrack.js.map +1 -0
- package/lib/commonjs/MediaStreamTrackEvent.js +26 -0
- package/lib/commonjs/MediaStreamTrackEvent.js.map +1 -0
- package/lib/commonjs/MessageEvent.js +27 -0
- package/lib/commonjs/MessageEvent.js.map +1 -0
- package/lib/commonjs/Permissions.js +116 -0
- package/lib/commonjs/Permissions.js.map +1 -0
- package/lib/commonjs/RTCAudioSession.js +33 -0
- package/lib/commonjs/RTCAudioSession.js.map +1 -0
- package/lib/commonjs/RTCDataChannel.js +165 -0
- package/lib/commonjs/RTCDataChannel.js.map +1 -0
- package/lib/commonjs/RTCDataChannelEvent.js +26 -0
- package/lib/commonjs/RTCDataChannelEvent.js.map +1 -0
- package/lib/commonjs/RTCDataPacketCryptor.js +76 -0
- package/lib/commonjs/RTCDataPacketCryptor.js.map +1 -0
- package/lib/commonjs/RTCDataPacketCryptorFactory.js +27 -0
- package/lib/commonjs/RTCDataPacketCryptorFactory.js.map +1 -0
- package/lib/commonjs/RTCErrorEvent.js +23 -0
- package/lib/commonjs/RTCErrorEvent.js.map +1 -0
- package/lib/commonjs/RTCFrameCryptor.js +138 -0
- package/lib/commonjs/RTCFrameCryptor.js.map +1 -0
- package/lib/commonjs/RTCFrameCryptorFactory.js +81 -0
- package/lib/commonjs/RTCFrameCryptorFactory.js.map +1 -0
- package/lib/commonjs/RTCIceCandidate.js +34 -0
- package/lib/commonjs/RTCIceCandidate.js.map +1 -0
- package/lib/commonjs/RTCIceCandidateEvent.js +28 -0
- package/lib/commonjs/RTCIceCandidateEvent.js.map +1 -0
- package/lib/commonjs/RTCKeyProvider.js +111 -0
- package/lib/commonjs/RTCKeyProvider.js.map +1 -0
- package/lib/commonjs/RTCPIPView.js +38 -0
- package/lib/commonjs/RTCPIPView.js.map +1 -0
- package/lib/commonjs/RTCPeerConnection.js +694 -0
- package/lib/commonjs/RTCPeerConnection.js.map +1 -0
- package/lib/commonjs/RTCRtcpParameters.js +24 -0
- package/lib/commonjs/RTCRtcpParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpCapabilities.js +22 -0
- package/lib/commonjs/RTCRtpCapabilities.js.map +1 -0
- package/lib/commonjs/RTCRtpCodecCapability.js +19 -0
- package/lib/commonjs/RTCRtpCodecCapability.js.map +1 -0
- package/lib/commonjs/RTCRtpCodecParameters.js +38 -0
- package/lib/commonjs/RTCRtpCodecParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpEncodingParameters.js +78 -0
- package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpHeaderExtension.js +27 -0
- package/lib/commonjs/RTCRtpHeaderExtension.js.map +1 -0
- package/lib/commonjs/RTCRtpParameters.js +35 -0
- package/lib/commonjs/RTCRtpParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpReceiveParameters.js +15 -0
- package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpReceiver.js +53 -0
- package/lib/commonjs/RTCRtpReceiver.js.map +1 -0
- package/lib/commonjs/RTCRtpSendParameters.js +49 -0
- package/lib/commonjs/RTCRtpSendParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpSender.js +67 -0
- package/lib/commonjs/RTCRtpSender.js.map +1 -0
- package/lib/commonjs/RTCRtpTransceiver.js +81 -0
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -0
- package/lib/commonjs/RTCSessionDescription.js +33 -0
- package/lib/commonjs/RTCSessionDescription.js.map +1 -0
- package/lib/commonjs/RTCTrackEvent.js +38 -0
- package/lib/commonjs/RTCTrackEvent.js.map +1 -0
- package/lib/commonjs/RTCUtil.js +186 -0
- package/lib/commonjs/RTCUtil.js.map +1 -0
- package/lib/commonjs/RTCView.js +16 -0
- package/lib/commonjs/RTCView.js.map +1 -0
- package/lib/commonjs/ScreenCapturePickerView.js +10 -0
- package/lib/commonjs/ScreenCapturePickerView.js.map +1 -0
- package/lib/commonjs/getDisplayMedia.js +33 -0
- package/lib/commonjs/getDisplayMedia.js.map +1 -0
- package/lib/commonjs/getUserMedia.js +101 -0
- package/lib/commonjs/getUserMedia.js.map +1 -0
- package/lib/commonjs/index.js +224 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/Constraints.js +2 -0
- package/lib/module/Constraints.js.map +1 -0
- package/lib/module/EventEmitter.js +58 -0
- package/lib/module/EventEmitter.js.map +1 -0
- package/lib/module/Logger.js +39 -0
- package/lib/module/Logger.js.map +1 -0
- package/lib/module/MediaDevices.js +46 -0
- package/lib/module/MediaDevices.js.map +1 -0
- package/lib/module/MediaStream.js +129 -0
- package/lib/module/MediaStream.js.map +1 -0
- package/lib/module/MediaStreamError.js +12 -0
- package/lib/module/MediaStreamError.js.map +1 -0
- package/lib/module/MediaStreamErrorEvent.js +10 -0
- package/lib/module/MediaStreamErrorEvent.js.map +1 -0
- package/lib/module/MediaStreamTrack.js +231 -0
- package/lib/module/MediaStreamTrack.js.map +1 -0
- package/lib/module/MediaStreamTrackEvent.js +19 -0
- package/lib/module/MediaStreamTrackEvent.js.map +1 -0
- package/lib/module/MessageEvent.js +20 -0
- package/lib/module/MessageEvent.js.map +1 -0
- package/lib/module/Permissions.js +109 -0
- package/lib/module/Permissions.js.map +1 -0
- package/lib/module/RTCAudioSession.js +26 -0
- package/lib/module/RTCAudioSession.js.map +1 -0
- package/lib/module/RTCDataChannel.js +155 -0
- package/lib/module/RTCDataChannel.js.map +1 -0
- package/lib/module/RTCDataChannelEvent.js +19 -0
- package/lib/module/RTCDataChannelEvent.js.map +1 -0
- package/lib/module/RTCDataPacketCryptor.js +66 -0
- package/lib/module/RTCDataPacketCryptor.js.map +1 -0
- package/lib/module/RTCDataPacketCryptorFactory.js +19 -0
- package/lib/module/RTCDataPacketCryptorFactory.js.map +1 -0
- package/lib/module/RTCErrorEvent.js +16 -0
- package/lib/module/RTCErrorEvent.js.map +1 -0
- package/lib/module/RTCFrameCryptor.js +128 -0
- package/lib/module/RTCFrameCryptor.js.map +1 -0
- package/lib/module/RTCFrameCryptorFactory.js +70 -0
- package/lib/module/RTCFrameCryptorFactory.js.map +1 -0
- package/lib/module/RTCIceCandidate.js +27 -0
- package/lib/module/RTCIceCandidate.js.map +1 -0
- package/lib/module/RTCIceCandidateEvent.js +21 -0
- package/lib/module/RTCIceCandidateEvent.js.map +1 -0
- package/lib/module/RTCKeyProvider.js +101 -0
- package/lib/module/RTCKeyProvider.js.map +1 -0
- package/lib/module/RTCPIPView.js +26 -0
- package/lib/module/RTCPIPView.js.map +1 -0
- package/lib/module/RTCPeerConnection.js +684 -0
- package/lib/module/RTCPeerConnection.js.map +1 -0
- package/lib/module/RTCRtcpParameters.js +17 -0
- package/lib/module/RTCRtcpParameters.js.map +1 -0
- package/lib/module/RTCRtpCapabilities.js +15 -0
- package/lib/module/RTCRtpCapabilities.js.map +1 -0
- package/lib/module/RTCRtpCodecCapability.js +12 -0
- package/lib/module/RTCRtpCodecCapability.js.map +1 -0
- package/lib/module/RTCRtpCodecParameters.js +31 -0
- package/lib/module/RTCRtpCodecParameters.js.map +1 -0
- package/lib/module/RTCRtpEncodingParameters.js +71 -0
- package/lib/module/RTCRtpEncodingParameters.js.map +1 -0
- package/lib/module/RTCRtpHeaderExtension.js +20 -0
- package/lib/module/RTCRtpHeaderExtension.js.map +1 -0
- package/lib/module/RTCRtpParameters.js +27 -0
- package/lib/module/RTCRtpParameters.js.map +1 -0
- package/lib/module/RTCRtpReceiveParameters.js +7 -0
- package/lib/module/RTCRtpReceiveParameters.js.map +1 -0
- package/lib/module/RTCRtpReceiver.js +45 -0
- package/lib/module/RTCRtpReceiver.js.map +1 -0
- package/lib/module/RTCRtpSendParameters.js +41 -0
- package/lib/module/RTCRtpSendParameters.js.map +1 -0
- package/lib/module/RTCRtpSender.js +59 -0
- package/lib/module/RTCRtpSender.js.map +1 -0
- package/lib/module/RTCRtpTransceiver.js +74 -0
- package/lib/module/RTCRtpTransceiver.js.map +1 -0
- package/lib/module/RTCSessionDescription.js +26 -0
- package/lib/module/RTCSessionDescription.js.map +1 -0
- package/lib/module/RTCTrackEvent.js +31 -0
- package/lib/module/RTCTrackEvent.js.map +1 -0
- package/lib/module/RTCUtil.js +176 -0
- package/lib/module/RTCUtil.js.map +1 -0
- package/lib/module/RTCView.js +11 -0
- package/lib/module/RTCView.js.map +1 -0
- package/lib/module/ScreenCapturePickerView.js +3 -0
- package/lib/module/ScreenCapturePickerView.js.map +1 -0
- package/lib/module/getDisplayMedia.js +26 -0
- package/lib/module/getDisplayMedia.js.map +1 -0
- package/lib/module/getUserMedia.js +92 -0
- package/lib/module/getUserMedia.js.map +1 -0
- package/lib/module/index.js +60 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/Constraints.d.ts +19 -0
- package/lib/typescript/EventEmitter.d.ts +7 -0
- package/lib/typescript/Logger.d.ts +13 -0
- package/lib/typescript/MediaDevices.d.ts +30 -0
- package/lib/typescript/MediaStream.d.ts +48 -0
- package/lib/typescript/MediaStreamError.d.ts +6 -0
- package/lib/typescript/MediaStreamErrorEvent.d.ts +6 -0
- package/lib/typescript/MediaStreamTrack.d.ts +103 -0
- package/lib/typescript/MediaStreamTrackEvent.d.ts +19 -0
- package/lib/typescript/MessageEvent.d.ts +21 -0
- package/lib/typescript/Permissions.d.ts +55 -0
- package/lib/typescript/RTCAudioSession.d.ts +10 -0
- package/lib/typescript/RTCDataChannel.d.ts +43 -0
- package/lib/typescript/RTCDataChannelEvent.d.ts +19 -0
- package/lib/typescript/RTCDataPacketCryptor.d.ts +12 -0
- package/lib/typescript/RTCDataPacketCryptorFactory.d.ts +6 -0
- package/lib/typescript/RTCErrorEvent.d.ts +12 -0
- package/lib/typescript/RTCFrameCryptor.d.ts +47 -0
- package/lib/typescript/RTCFrameCryptorFactory.d.ts +21 -0
- package/lib/typescript/RTCIceCandidate.d.ts +17 -0
- package/lib/typescript/RTCIceCandidateEvent.d.ts +20 -0
- package/lib/typescript/RTCKeyProvider.d.ts +21 -0
- package/lib/typescript/RTCPIPView.d.ts +15 -0
- package/lib/typescript/RTCPeerConnection.d.ts +117 -0
- package/lib/typescript/RTCRtcpParameters.d.ts +10 -0
- package/lib/typescript/RTCRtpCapabilities.d.ts +9 -0
- package/lib/typescript/RTCRtpCodecCapability.d.ts +7 -0
- package/lib/typescript/RTCRtpCodecParameters.d.ts +16 -0
- package/lib/typescript/RTCRtpEncodingParameters.d.ts +23 -0
- package/lib/typescript/RTCRtpHeaderExtension.d.ts +12 -0
- package/lib/typescript/RTCRtpParameters.d.ts +19 -0
- package/lib/typescript/RTCRtpReceiveParameters.d.ts +4 -0
- package/lib/typescript/RTCRtpReceiver.d.ts +21 -0
- package/lib/typescript/RTCRtpSendParameters.d.ts +20 -0
- package/lib/typescript/RTCRtpSender.d.ts +22 -0
- package/lib/typescript/RTCRtpTransceiver.d.ts +31 -0
- package/lib/typescript/RTCSessionDescription.d.ts +12 -0
- package/lib/typescript/RTCTrackEvent.d.ts +29 -0
- package/lib/typescript/RTCUtil.d.ts +37 -0
- package/lib/typescript/RTCView.d.ts +117 -0
- package/lib/typescript/ScreenCapturePickerView.d.ts +2 -0
- package/lib/typescript/getDisplayMedia.d.ts +2 -0
- package/lib/typescript/getUserMedia.d.ts +7 -0
- package/lib/typescript/index.d.ts +22 -0
- package/livekit-react-native-webrtc.podspec +29 -0
- package/macos/RCTWebRTC.xcodeproj/project.pbxproj +324 -0
- package/macos/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/macos/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/metro.config.js +7 -0
- package/metro.config.macos.js +14 -0
- package/package.json +65 -0
- package/react-native.config.js +11 -0
- package/src/.eslintrc.cjs +67 -0
- package/src/Constraints.ts +21 -0
- package/src/EventEmitter.ts +83 -0
- package/src/Logger.ts +49 -0
- package/src/MediaDevices.ts +53 -0
- package/src/MediaStream.ts +161 -0
- package/src/MediaStreamError.ts +12 -0
- package/src/MediaStreamErrorEvent.ts +11 -0
- package/src/MediaStreamTrack.ts +331 -0
- package/src/MediaStreamTrackEvent.ts +25 -0
- package/src/MessageEvent.ts +26 -0
- package/src/Permissions.ts +133 -0
- package/src/RTCAudioSession.ts +25 -0
- package/src/RTCDataChannel.ts +190 -0
- package/src/RTCDataChannelEvent.ts +28 -0
- package/src/RTCDataPacketCryptor.ts +90 -0
- package/src/RTCDataPacketCryptorFactory.ts +25 -0
- package/src/RTCErrorEvent.ts +21 -0
- package/src/RTCFrameCryptor.ts +163 -0
- package/src/RTCFrameCryptorFactory.ts +102 -0
- package/src/RTCIceCandidate.ts +29 -0
- package/src/RTCIceCandidateEvent.ts +26 -0
- package/src/RTCKeyProvider.ts +117 -0
- package/src/RTCPIPView.tsx +47 -0
- package/src/RTCPeerConnection.ts +832 -0
- package/src/RTCRtcpParameters.ts +23 -0
- package/src/RTCRtpCapabilities.ts +16 -0
- package/src/RTCRtpCodecCapability.ts +13 -0
- package/src/RTCRtpCodecParameters.ts +44 -0
- package/src/RTCRtpEncodingParameters.ts +90 -0
- package/src/RTCRtpHeaderExtension.ts +27 -0
- package/src/RTCRtpParameters.ts +37 -0
- package/src/RTCRtpReceiveParameters.ts +7 -0
- package/src/RTCRtpReceiver.ts +60 -0
- package/src/RTCRtpSendParameters.ts +63 -0
- package/src/RTCRtpSender.ts +78 -0
- package/src/RTCRtpTransceiver.ts +107 -0
- package/src/RTCSessionDescription.ts +30 -0
- package/src/RTCTrackEvent.ts +42 -0
- package/src/RTCUtil.ts +211 -0
- package/src/RTCView.ts +122 -0
- package/src/ScreenCapturePickerView.ts +4 -0
- package/src/getDisplayMedia.ts +30 -0
- package/src/getUserMedia.ts +111 -0
- package/src/index.ts +101 -0
- package/tools/format.sh +6 -0
- package/tools/release.sh +45 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import android.app.Notification;
|
|
4
|
+
import android.app.Service;
|
|
5
|
+
import android.content.ComponentName;
|
|
6
|
+
import android.content.Context;
|
|
7
|
+
import android.content.Intent;
|
|
8
|
+
import android.content.pm.ServiceInfo;
|
|
9
|
+
import android.os.Build;
|
|
10
|
+
import android.os.IBinder;
|
|
11
|
+
import android.util.Log;
|
|
12
|
+
|
|
13
|
+
import java.util.Random;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This class implements an Android {@link Service}, a foreground one specifically, and it's
|
|
17
|
+
* responsible for presenting an ongoing notification when a conference is in progress.
|
|
18
|
+
* The service will help keep the app running while in the background.
|
|
19
|
+
*
|
|
20
|
+
* See: https://developer.android.com/guide/components/services
|
|
21
|
+
*/
|
|
22
|
+
public class MediaProjectionService extends Service {
|
|
23
|
+
private static final String TAG = MediaProjectionService.class.getSimpleName();
|
|
24
|
+
|
|
25
|
+
static final int NOTIFICATION_ID = new Random().nextInt(99999) + 10000;
|
|
26
|
+
|
|
27
|
+
public static void launch(Context context) {
|
|
28
|
+
if (!WebRTCModuleOptions.getInstance().enableMediaProjectionService) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
MediaProjectionNotification.createNotificationChannel(context);
|
|
33
|
+
Intent intent = new Intent(context, MediaProjectionService.class);
|
|
34
|
+
ComponentName componentName;
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
38
|
+
componentName = context.startForegroundService(intent);
|
|
39
|
+
} else {
|
|
40
|
+
componentName = context.startService(intent);
|
|
41
|
+
}
|
|
42
|
+
} catch (RuntimeException e) {
|
|
43
|
+
// Avoid crashing due to ForegroundServiceStartNotAllowedException (API level 31).
|
|
44
|
+
// See: https://developer.android.com/guide/components/foreground-services#background-start-restrictions
|
|
45
|
+
Log.w(TAG, "Media projection service not started", e);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (componentName == null) {
|
|
50
|
+
Log.w(TAG, "Media projection service not started");
|
|
51
|
+
} else {
|
|
52
|
+
Log.i(TAG, "Media projection service started");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public static void abort(Context context) {
|
|
57
|
+
if (!WebRTCModuleOptions.getInstance().enableMediaProjectionService) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Intent intent = new Intent(context, MediaProjectionService.class);
|
|
62
|
+
context.stopService(intent);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Override
|
|
66
|
+
public IBinder onBind(Intent intent) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@Override
|
|
71
|
+
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
72
|
+
Notification notification = MediaProjectionNotification.buildMediaProjectionNotification(this);
|
|
73
|
+
|
|
74
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
75
|
+
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION);
|
|
76
|
+
} else {
|
|
77
|
+
startForeground(NOTIFICATION_ID, notification);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return START_NOT_STICKY;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import android.util.Base64;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import androidx.annotation.Nullable;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.bridge.Arguments;
|
|
9
|
+
import com.facebook.react.bridge.Promise;
|
|
10
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
11
|
+
import com.facebook.react.bridge.WritableArray;
|
|
12
|
+
import com.facebook.react.bridge.WritableMap;
|
|
13
|
+
|
|
14
|
+
import org.webrtc.AudioTrack;
|
|
15
|
+
import org.webrtc.DataChannel;
|
|
16
|
+
import org.webrtc.IceCandidate;
|
|
17
|
+
import org.webrtc.MediaStream;
|
|
18
|
+
import org.webrtc.MediaStreamTrack;
|
|
19
|
+
import org.webrtc.PeerConnection;
|
|
20
|
+
import org.webrtc.RTCStatsReport;
|
|
21
|
+
import org.webrtc.RtpReceiver;
|
|
22
|
+
import org.webrtc.RtpSender;
|
|
23
|
+
import org.webrtc.RtpTransceiver;
|
|
24
|
+
import org.webrtc.SessionDescription;
|
|
25
|
+
import org.webrtc.VideoTrack;
|
|
26
|
+
|
|
27
|
+
import java.nio.ByteBuffer;
|
|
28
|
+
import java.nio.charset.StandardCharsets;
|
|
29
|
+
import java.util.HashMap;
|
|
30
|
+
import java.util.Map;
|
|
31
|
+
import java.util.Objects;
|
|
32
|
+
import java.util.UUID;
|
|
33
|
+
|
|
34
|
+
class PeerConnectionObserver implements PeerConnection.Observer {
|
|
35
|
+
private final static String TAG = WebRTCModule.TAG;
|
|
36
|
+
|
|
37
|
+
private final Map<String, DataChannelWrapper> dataChannels;
|
|
38
|
+
private final int id;
|
|
39
|
+
private int transceiverNextId = 0;
|
|
40
|
+
|
|
41
|
+
private PeerConnection peerConnection;
|
|
42
|
+
final Map<String, String> remoteStreamIds; // Stream ID -> React tag
|
|
43
|
+
final Map<String, MediaStream> remoteStreams; // React tag -> MediaStream
|
|
44
|
+
final Map<String, MediaStreamTrack> remoteTracks;
|
|
45
|
+
private final VideoTrackAdapter videoTrackAdapters;
|
|
46
|
+
private final WebRTCModule webRTCModule;
|
|
47
|
+
|
|
48
|
+
PeerConnectionObserver(WebRTCModule webRTCModule, int id) {
|
|
49
|
+
this.webRTCModule = webRTCModule;
|
|
50
|
+
this.id = id;
|
|
51
|
+
this.dataChannels = new HashMap<>();
|
|
52
|
+
this.remoteStreamIds = new HashMap<>();
|
|
53
|
+
this.remoteStreams = new HashMap<>();
|
|
54
|
+
this.remoteTracks = new HashMap<>();
|
|
55
|
+
this.videoTrackAdapters = new VideoTrackAdapter(webRTCModule, id);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
PeerConnection getPeerConnection() {
|
|
59
|
+
return peerConnection;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void setPeerConnection(PeerConnection peerConnection) {
|
|
63
|
+
this.peerConnection = peerConnection;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void close() {
|
|
67
|
+
Log.d(TAG, "PeerConnection.close() for " + id);
|
|
68
|
+
|
|
69
|
+
peerConnection.close();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void dispose() {
|
|
73
|
+
Log.d(TAG, "PeerConnection.dispose() for " + id);
|
|
74
|
+
|
|
75
|
+
// Remove video track adapters
|
|
76
|
+
for (MediaStreamTrack track : this.remoteTracks.values()) {
|
|
77
|
+
if (track instanceof VideoTrack) {
|
|
78
|
+
videoTrackAdapters.removeAdapter((VideoTrack) track);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Remove DataChannel observers
|
|
83
|
+
for (DataChannelWrapper dcw : dataChannels.values()) {
|
|
84
|
+
DataChannel dataChannel = dcw.getDataChannel();
|
|
85
|
+
dataChannel.unregisterObserver();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// At this point there should be no local MediaStreams in the associated
|
|
89
|
+
// PeerConnection. Call dispose() to free all remaining resources held
|
|
90
|
+
// by the PeerConnection instance (RtpReceivers, RtpSenders, etc.)
|
|
91
|
+
peerConnection.dispose();
|
|
92
|
+
|
|
93
|
+
remoteStreamIds.clear();
|
|
94
|
+
remoteStreams.clear();
|
|
95
|
+
remoteTracks.clear();
|
|
96
|
+
dataChannels.clear();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public synchronized int getNextTransceiverId() {
|
|
100
|
+
return transceiverNextId++;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
RtpTransceiver addTransceiver(MediaStreamTrack.MediaType mediaType, RtpTransceiver.RtpTransceiverInit init) {
|
|
104
|
+
if (peerConnection == null) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return peerConnection.addTransceiver(mediaType, init);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
RtpTransceiver addTransceiver(MediaStreamTrack track, RtpTransceiver.RtpTransceiverInit init) {
|
|
112
|
+
if (peerConnection == null) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return peerConnection.addTransceiver(track, init);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
RtpReceiver getReceiver(String id) {
|
|
120
|
+
if (this.peerConnection == null) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
for (RtpReceiver receiver : this.peerConnection.getReceivers()) {
|
|
125
|
+
if (receiver.id().equals(id)) {
|
|
126
|
+
return receiver;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
RtpSender getSender(String id) {
|
|
134
|
+
if (this.peerConnection == null) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
for (RtpSender sender : this.peerConnection.getSenders()) {
|
|
139
|
+
if (sender.id().equals(id)) {
|
|
140
|
+
return sender;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
RtpTransceiver getTransceiver(String id) {
|
|
148
|
+
if (this.peerConnection == null) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
for (RtpTransceiver transceiver : this.peerConnection.getTransceivers()) {
|
|
153
|
+
if (transceiver.getSender().id().equals(id)) {
|
|
154
|
+
return transceiver;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
WritableMap createDataChannel(String label, ReadableMap config) {
|
|
161
|
+
DataChannel.Init init = new DataChannel.Init();
|
|
162
|
+
if (config != null) {
|
|
163
|
+
if (config.hasKey("id")) {
|
|
164
|
+
init.id = config.getInt("id");
|
|
165
|
+
}
|
|
166
|
+
if (config.hasKey("ordered")) {
|
|
167
|
+
init.ordered = config.getBoolean("ordered");
|
|
168
|
+
}
|
|
169
|
+
if (config.hasKey("maxRetransmitTime")) {
|
|
170
|
+
init.maxRetransmitTimeMs = config.getInt("maxRetransmitTime");
|
|
171
|
+
}
|
|
172
|
+
if (config.hasKey("maxRetransmits")) {
|
|
173
|
+
init.maxRetransmits = config.getInt("maxRetransmits");
|
|
174
|
+
}
|
|
175
|
+
if (config.hasKey("protocol")) {
|
|
176
|
+
init.protocol = config.getString("protocol");
|
|
177
|
+
}
|
|
178
|
+
if (config.hasKey("negotiated")) {
|
|
179
|
+
init.negotiated = config.getBoolean("negotiated");
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
DataChannel dataChannel = peerConnection.createDataChannel(label, init);
|
|
183
|
+
if (dataChannel == null) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
final String reactTag = UUID.randomUUID().toString();
|
|
187
|
+
DataChannelWrapper dcw = new DataChannelWrapper(webRTCModule, id, reactTag, dataChannel);
|
|
188
|
+
dataChannels.put(reactTag, dcw);
|
|
189
|
+
dataChannel.registerObserver(dcw);
|
|
190
|
+
|
|
191
|
+
WritableMap info = Arguments.createMap();
|
|
192
|
+
info.putInt("peerConnectionId", id);
|
|
193
|
+
info.putString("reactTag", reactTag);
|
|
194
|
+
info.putString("label", dataChannel.label());
|
|
195
|
+
info.putInt("id", dataChannel.id());
|
|
196
|
+
info.putBoolean("ordered", init.ordered);
|
|
197
|
+
info.putInt("maxPacketLifeTime", init.maxRetransmitTimeMs);
|
|
198
|
+
info.putInt("maxRetransmits", init.maxRetransmits);
|
|
199
|
+
info.putString("protocol", init.protocol);
|
|
200
|
+
info.putBoolean("negotiated", init.negotiated);
|
|
201
|
+
info.putString("readyState", dcw.dataChannelStateString(dataChannel.state()));
|
|
202
|
+
return info;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
void dataChannelClose(String reactTag) {
|
|
206
|
+
DataChannelWrapper dcw = dataChannels.get(reactTag);
|
|
207
|
+
if (dcw == null) {
|
|
208
|
+
Log.d(TAG, "dataChannelClose() dataChannel is null");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
DataChannel dataChannel = dcw.getDataChannel();
|
|
213
|
+
dataChannel.close();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
void dataChannelDispose(String reactTag) {
|
|
217
|
+
DataChannelWrapper dcw = dataChannels.get(reactTag);
|
|
218
|
+
if (dcw == null) {
|
|
219
|
+
Log.d(TAG, "dataChannelDispose() dataChannel is null");
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
DataChannel dataChannel = dcw.getDataChannel();
|
|
224
|
+
dataChannel.unregisterObserver();
|
|
225
|
+
dataChannels.remove(reactTag);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
void dataChannelSend(String reactTag, String data, String type) {
|
|
229
|
+
DataChannelWrapper dcw = dataChannels.get(reactTag);
|
|
230
|
+
if (dcw == null) {
|
|
231
|
+
Log.d(TAG, "dataChannelSend() dataChannel is null");
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
byte[] byteArray;
|
|
236
|
+
if (type.equals("text")) {
|
|
237
|
+
byteArray = data.getBytes(StandardCharsets.UTF_8);
|
|
238
|
+
} else if (type.equals("binary")) {
|
|
239
|
+
byteArray = Base64.decode(data, Base64.NO_WRAP);
|
|
240
|
+
} else {
|
|
241
|
+
Log.e(TAG, "Unsupported data type: " + type);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
ByteBuffer byteBuffer = ByteBuffer.wrap(byteArray);
|
|
245
|
+
DataChannel.Buffer buffer = new DataChannel.Buffer(byteBuffer, type.equals("binary"));
|
|
246
|
+
dcw.getDataChannel().send(buffer);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
void getStats(Promise promise) {
|
|
250
|
+
peerConnection.getStats(rtcStatsReport -> promise.resolve(StringUtils.statsToJSON(rtcStatsReport)));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
public void receiverGetStats(String receiverId, Promise promise) {
|
|
254
|
+
RtpReceiver targetReceiver = null;
|
|
255
|
+
for (RtpReceiver r : peerConnection.getReceivers()) {
|
|
256
|
+
if (r.id().equals(receiverId)) {
|
|
257
|
+
targetReceiver = r;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (targetReceiver == null) {
|
|
263
|
+
Log.w(TAG, "receiverGetStats(): Receiver ID " + receiverId + " not found");
|
|
264
|
+
promise.resolve(StringUtils.statsToJSON(new RTCStatsReport(0, new HashMap<>())));
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
peerConnection.getStats(
|
|
269
|
+
targetReceiver, rtcStatsReport -> promise.resolve(StringUtils.statsToJSON(rtcStatsReport)));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
public void senderGetStats(String senderId, Promise promise) {
|
|
273
|
+
RtpSender targetSender = null;
|
|
274
|
+
for (RtpSender s : peerConnection.getSenders()) {
|
|
275
|
+
if (s.id().equals(senderId)) {
|
|
276
|
+
targetSender = s;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (targetSender == null) {
|
|
282
|
+
Log.w(TAG, "senderGetStats(): Sender ID " + senderId + " not found");
|
|
283
|
+
promise.resolve(StringUtils.statsToJSON(new RTCStatsReport(0, new HashMap<>())));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
peerConnection.getStats(
|
|
288
|
+
targetSender, rtcStatsReport -> promise.resolve(StringUtils.statsToJSON(rtcStatsReport)));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
@Override
|
|
292
|
+
public void onIceCandidate(final IceCandidate candidate) {
|
|
293
|
+
Log.d(TAG, "onIceCandidate");
|
|
294
|
+
|
|
295
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
296
|
+
WritableMap params = Arguments.createMap();
|
|
297
|
+
params.putInt("pcId", id);
|
|
298
|
+
|
|
299
|
+
WritableMap candidateParams = Arguments.createMap();
|
|
300
|
+
candidateParams.putInt("sdpMLineIndex", candidate.sdpMLineIndex);
|
|
301
|
+
candidateParams.putString("sdpMid", candidate.sdpMid);
|
|
302
|
+
candidateParams.putString("candidate", candidate.sdp);
|
|
303
|
+
|
|
304
|
+
params.putMap("candidate", candidateParams);
|
|
305
|
+
|
|
306
|
+
SessionDescription newSdp = peerConnection.getLocalDescription();
|
|
307
|
+
WritableMap newSdpMap = Arguments.createMap();
|
|
308
|
+
|
|
309
|
+
// Can happen when doing a rollback.
|
|
310
|
+
if (newSdp != null) {
|
|
311
|
+
newSdpMap.putString("type", newSdp.type.canonicalForm());
|
|
312
|
+
newSdpMap.putString("sdp", newSdp.description);
|
|
313
|
+
}
|
|
314
|
+
params.putMap("sdp", newSdpMap);
|
|
315
|
+
|
|
316
|
+
webRTCModule.sendEvent("peerConnectionGotICECandidate", params);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
@Override
|
|
321
|
+
public void onIceCandidatesRemoved(final IceCandidate[] candidates) {}
|
|
322
|
+
|
|
323
|
+
@Override
|
|
324
|
+
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
|
|
325
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
326
|
+
WritableMap params = Arguments.createMap();
|
|
327
|
+
params.putInt("pcId", id);
|
|
328
|
+
params.putString("iceConnectionState", iceConnectionStateString(iceConnectionState));
|
|
329
|
+
webRTCModule.sendEvent("peerConnectionIceConnectionChanged", params);
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
@Override
|
|
334
|
+
public void onConnectionChange(PeerConnection.PeerConnectionState peerConnectionState) {
|
|
335
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
336
|
+
WritableMap params = Arguments.createMap();
|
|
337
|
+
params.putInt("pcId", id);
|
|
338
|
+
params.putString("connectionState", peerConnectionStateString(peerConnectionState));
|
|
339
|
+
|
|
340
|
+
webRTCModule.sendEvent("peerConnectionStateChanged", params);
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
@Override
|
|
345
|
+
public void onIceConnectionReceivingChange(boolean receiving) {}
|
|
346
|
+
|
|
347
|
+
@Override
|
|
348
|
+
public void onIceGatheringChange(PeerConnection.IceGatheringState iceGatheringState) {
|
|
349
|
+
Log.d(TAG, "onIceGatheringChange" + iceGatheringState.name());
|
|
350
|
+
|
|
351
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
352
|
+
WritableMap params = Arguments.createMap();
|
|
353
|
+
params.putInt("pcId", id);
|
|
354
|
+
params.putString("iceGatheringState", iceGatheringStateString(iceGatheringState));
|
|
355
|
+
|
|
356
|
+
if (iceGatheringState == PeerConnection.IceGatheringState.COMPLETE) {
|
|
357
|
+
SessionDescription newSdp = peerConnection.getLocalDescription();
|
|
358
|
+
WritableMap newSdpMap = Arguments.createMap();
|
|
359
|
+
|
|
360
|
+
// Can happen when doing a rollback.
|
|
361
|
+
if (newSdp != null) {
|
|
362
|
+
newSdpMap.putString("type", newSdp.type.canonicalForm());
|
|
363
|
+
newSdpMap.putString("sdp", newSdp.description);
|
|
364
|
+
}
|
|
365
|
+
params.putMap("sdp", newSdpMap);
|
|
366
|
+
}
|
|
367
|
+
webRTCModule.sendEvent("peerConnectionIceGatheringChanged", params);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
@Override
|
|
372
|
+
public void onDataChannel(DataChannel dataChannel) {
|
|
373
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
374
|
+
final String reactTag = UUID.randomUUID().toString();
|
|
375
|
+
DataChannelWrapper dcw = new DataChannelWrapper(webRTCModule, id, reactTag, dataChannel);
|
|
376
|
+
dataChannels.put(reactTag, dcw);
|
|
377
|
+
dataChannel.registerObserver(dcw);
|
|
378
|
+
|
|
379
|
+
WritableMap info = Arguments.createMap();
|
|
380
|
+
info.putInt("peerConnectionId", id);
|
|
381
|
+
info.putString("reactTag", reactTag);
|
|
382
|
+
info.putString("label", dataChannel.label());
|
|
383
|
+
info.putInt("id", dataChannel.id());
|
|
384
|
+
|
|
385
|
+
// TODO: These values are not gettable from a DataChannel instance.
|
|
386
|
+
info.putBoolean("ordered", true);
|
|
387
|
+
info.putInt("maxPacketLifeTime", -1);
|
|
388
|
+
info.putInt("maxRetransmits", -1);
|
|
389
|
+
info.putString("protocol", "");
|
|
390
|
+
|
|
391
|
+
info.putBoolean("negotiated", false);
|
|
392
|
+
info.putString("readyState", dcw.dataChannelStateString(dataChannel.state()));
|
|
393
|
+
|
|
394
|
+
WritableMap params = Arguments.createMap();
|
|
395
|
+
params.putInt("pcId", id);
|
|
396
|
+
params.putMap("dataChannel", info);
|
|
397
|
+
|
|
398
|
+
webRTCModule.sendEvent("peerConnectionDidOpenDataChannel", params);
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
@Override
|
|
403
|
+
public void onRenegotiationNeeded() {
|
|
404
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
405
|
+
WritableMap params = Arguments.createMap();
|
|
406
|
+
params.putInt("pcId", id);
|
|
407
|
+
webRTCModule.sendEvent("peerConnectionOnRenegotiationNeeded", params);
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
@Override
|
|
412
|
+
public void onSignalingChange(PeerConnection.SignalingState signalingState) {
|
|
413
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
414
|
+
WritableMap params = Arguments.createMap();
|
|
415
|
+
params.putInt("pcId", id);
|
|
416
|
+
params.putString("signalingState", signalingStateString(signalingState));
|
|
417
|
+
webRTCModule.sendEvent("peerConnectionSignalingStateChanged", params);
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Triggered when a new track is signaled by the remote peer, as a result of
|
|
423
|
+
* setRemoteDescription.
|
|
424
|
+
*/
|
|
425
|
+
@Override
|
|
426
|
+
public void onAddTrack(final RtpReceiver receiver, final MediaStream[] mediaStreams) {
|
|
427
|
+
Log.d(TAG, "onAddTrack");
|
|
428
|
+
|
|
429
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
430
|
+
RtpTransceiver transceiver = null;
|
|
431
|
+
for (RtpTransceiver t : this.peerConnection.getTransceivers()) {
|
|
432
|
+
if (Objects.equals(t.getReceiver().id(), receiver.id())) {
|
|
433
|
+
transceiver = t;
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (transceiver == null) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
final MediaStreamTrack track = receiver.track();
|
|
443
|
+
|
|
444
|
+
// We need to fire this event for an existing track sometimes, like
|
|
445
|
+
// when the transceiver direction (on the sending side) switches from
|
|
446
|
+
// sendrecv to recvonly and then back.
|
|
447
|
+
final boolean existingTrack = remoteTracks.containsKey(track.id());
|
|
448
|
+
|
|
449
|
+
if (!existingTrack) {
|
|
450
|
+
if (track.kind().equals(MediaStreamTrack.VIDEO_TRACK_KIND)) {
|
|
451
|
+
videoTrackAdapters.addAdapter((VideoTrack) track);
|
|
452
|
+
} else if (track.kind().equals(MediaStreamTrack.AUDIO_TRACK_KIND)) {
|
|
453
|
+
((AudioTrack) track).setVolume(WebRTCModuleOptions.getInstance().defaultTrackVolume);
|
|
454
|
+
}
|
|
455
|
+
remoteTracks.put(track.id(), track);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
WritableMap params = Arguments.createMap();
|
|
459
|
+
WritableArray streams = Arguments.createArray();
|
|
460
|
+
|
|
461
|
+
for (MediaStream stream : mediaStreams) {
|
|
462
|
+
// Getting the streamReactTag
|
|
463
|
+
String streamReactTag = remoteStreamIds.get(stream.getId());
|
|
464
|
+
|
|
465
|
+
if (streamReactTag == null) {
|
|
466
|
+
streamReactTag = UUID.randomUUID().toString();
|
|
467
|
+
remoteStreamIds.put(stream.getId(), streamReactTag);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// Make sure the stored stream is updated in case we get a new reference.
|
|
471
|
+
remoteStreams.put(streamReactTag, stream);
|
|
472
|
+
|
|
473
|
+
streams.pushMap(SerializeUtils.serializeStream(id, streamReactTag, stream));
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
params.putArray("streams", streams);
|
|
477
|
+
params.putMap("receiver", SerializeUtils.serializeReceiver(id, receiver));
|
|
478
|
+
params.putInt("transceiverOrder", getNextTransceiverId());
|
|
479
|
+
params.putMap("transceiver", SerializeUtils.serializeTransceiver(id, transceiver));
|
|
480
|
+
params.putInt("pcId", this.id);
|
|
481
|
+
|
|
482
|
+
webRTCModule.sendEvent("peerConnectionOnTrack", params);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Triggered when the signaling from SetRemoteDescription indicates that a transceiver
|
|
488
|
+
* will be receiving media from a remote endpoint. This is only called if UNIFIED_PLAN
|
|
489
|
+
* semantics are specified. The transceiver will be disposed automatically.
|
|
490
|
+
*/
|
|
491
|
+
@Override
|
|
492
|
+
public void onTrack(final RtpTransceiver transceiver) {}
|
|
493
|
+
|
|
494
|
+
/*
|
|
495
|
+
* Triggered when a previously added remote track is removed by the remote
|
|
496
|
+
* peer, as a result of setRemoteDescription.
|
|
497
|
+
*/
|
|
498
|
+
@Override
|
|
499
|
+
public void onRemoveTrack(RtpReceiver receiver) {
|
|
500
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
501
|
+
WritableMap params = Arguments.createMap();
|
|
502
|
+
params.putInt("pcId", this.id);
|
|
503
|
+
params.putString("receiverId", receiver.id());
|
|
504
|
+
|
|
505
|
+
webRTCModule.sendEvent("peerConnectionOnRemoveTrack", params);
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
// This is only added to compile. Plan B is not supported anymore.
|
|
510
|
+
@Override
|
|
511
|
+
public void onRemoveStream(MediaStream stream) {}
|
|
512
|
+
|
|
513
|
+
// This is only added to compile. Plan B is not supported anymore.
|
|
514
|
+
@Override
|
|
515
|
+
public void onAddStream(MediaStream stream) {}
|
|
516
|
+
|
|
517
|
+
@Nullable
|
|
518
|
+
private String peerConnectionStateString(PeerConnection.PeerConnectionState peerConnectionState) {
|
|
519
|
+
switch (peerConnectionState) {
|
|
520
|
+
case NEW:
|
|
521
|
+
return "new";
|
|
522
|
+
case CONNECTING:
|
|
523
|
+
return "connecting";
|
|
524
|
+
case CONNECTED:
|
|
525
|
+
return "connected";
|
|
526
|
+
case DISCONNECTED:
|
|
527
|
+
return "disconnected";
|
|
528
|
+
case FAILED:
|
|
529
|
+
return "failed";
|
|
530
|
+
case CLOSED:
|
|
531
|
+
return "closed";
|
|
532
|
+
}
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
@Nullable
|
|
537
|
+
private String iceConnectionStateString(PeerConnection.IceConnectionState iceConnectionState) {
|
|
538
|
+
switch (iceConnectionState) {
|
|
539
|
+
case NEW:
|
|
540
|
+
return "new";
|
|
541
|
+
case CHECKING:
|
|
542
|
+
return "checking";
|
|
543
|
+
case CONNECTED:
|
|
544
|
+
return "connected";
|
|
545
|
+
case COMPLETED:
|
|
546
|
+
return "completed";
|
|
547
|
+
case FAILED:
|
|
548
|
+
return "failed";
|
|
549
|
+
case DISCONNECTED:
|
|
550
|
+
return "disconnected";
|
|
551
|
+
case CLOSED:
|
|
552
|
+
return "closed";
|
|
553
|
+
}
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
@Nullable
|
|
558
|
+
private String iceGatheringStateString(PeerConnection.IceGatheringState iceGatheringState) {
|
|
559
|
+
switch (iceGatheringState) {
|
|
560
|
+
case NEW:
|
|
561
|
+
return "new";
|
|
562
|
+
case GATHERING:
|
|
563
|
+
return "gathering";
|
|
564
|
+
case COMPLETE:
|
|
565
|
+
return "complete";
|
|
566
|
+
}
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
@Nullable
|
|
571
|
+
private String signalingStateString(PeerConnection.SignalingState signalingState) {
|
|
572
|
+
switch (signalingState) {
|
|
573
|
+
case STABLE:
|
|
574
|
+
return "stable";
|
|
575
|
+
case HAVE_LOCAL_OFFER:
|
|
576
|
+
return "have-local-offer";
|
|
577
|
+
case HAVE_LOCAL_PRANSWER:
|
|
578
|
+
return "have-local-pranswer";
|
|
579
|
+
case HAVE_REMOTE_OFFER:
|
|
580
|
+
return "have-remote-offer";
|
|
581
|
+
case HAVE_REMOTE_PRANSWER:
|
|
582
|
+
return "have-remote-pranswer";
|
|
583
|
+
case CLOSED:
|
|
584
|
+
return "closed";
|
|
585
|
+
}
|
|
586
|
+
return null;
|
|
587
|
+
}
|
|
588
|
+
}
|