@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,493 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import android.util.Base64;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import androidx.annotation.NonNull;
|
|
7
|
+
import androidx.annotation.Nullable;
|
|
8
|
+
|
|
9
|
+
import com.facebook.react.bridge.Arguments;
|
|
10
|
+
import com.facebook.react.bridge.Promise;
|
|
11
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
12
|
+
import com.facebook.react.bridge.WritableMap;
|
|
13
|
+
|
|
14
|
+
import org.webrtc.DataPacketCryptor;
|
|
15
|
+
import org.webrtc.FrameCryptor;
|
|
16
|
+
import org.webrtc.FrameCryptorAlgorithm;
|
|
17
|
+
import org.webrtc.FrameCryptorFactory;
|
|
18
|
+
import org.webrtc.FrameCryptorKeyProvider;
|
|
19
|
+
import org.webrtc.RtpReceiver;
|
|
20
|
+
import org.webrtc.RtpSender;
|
|
21
|
+
|
|
22
|
+
import java.nio.charset.StandardCharsets;
|
|
23
|
+
import java.util.HashMap;
|
|
24
|
+
import java.util.Map;
|
|
25
|
+
import java.util.Objects;
|
|
26
|
+
import java.util.UUID;
|
|
27
|
+
|
|
28
|
+
public class RTCCryptoManager {
|
|
29
|
+
private static final String TAG = "RTCFrameCryptor";
|
|
30
|
+
private final Map<String, FrameCryptor> frameCryptos = new HashMap<>();
|
|
31
|
+
private final Map<String, FrameCryptorStateObserver> frameCryptoObservers = new HashMap<>();
|
|
32
|
+
private final Map<String, FrameCryptorKeyProvider> keyProviders = new HashMap<>();
|
|
33
|
+
private final Map<String, DataPacketCryptorManager> dataPacketCryptors = new HashMap<>();
|
|
34
|
+
private final WebRTCModule webRTCModule;
|
|
35
|
+
|
|
36
|
+
public RTCCryptoManager(WebRTCModule webRTCModule) {
|
|
37
|
+
this.webRTCModule = webRTCModule;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private void sendEvent(String eventName, WritableMap params) {
|
|
41
|
+
webRTCModule.sendEvent(eventName, params);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class FrameCryptorStateObserver implements FrameCryptor.Observer {
|
|
45
|
+
public FrameCryptorStateObserver(String frameCryptorId) {
|
|
46
|
+
this.frameCryptorId = frameCryptorId;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private final String frameCryptorId;
|
|
50
|
+
|
|
51
|
+
private String frameCryptorErrorStateToString(FrameCryptor.FrameCryptionState state) {
|
|
52
|
+
switch (state) {
|
|
53
|
+
case NEW:
|
|
54
|
+
return "new";
|
|
55
|
+
case OK:
|
|
56
|
+
return "ok";
|
|
57
|
+
case DECRYPTIONFAILED:
|
|
58
|
+
return "decryptionFailed";
|
|
59
|
+
case ENCRYPTIONFAILED:
|
|
60
|
+
return "encryptionFailed";
|
|
61
|
+
case INTERNALERROR:
|
|
62
|
+
return "internalError";
|
|
63
|
+
case KEYRATCHETED:
|
|
64
|
+
return "keyRatcheted";
|
|
65
|
+
case MISSINGKEY:
|
|
66
|
+
return "missingKey";
|
|
67
|
+
default:
|
|
68
|
+
throw new IllegalArgumentException("Unknown FrameCryptorErrorState: " + state);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@Override
|
|
73
|
+
public void onFrameCryptionStateChanged(String participantId, FrameCryptor.FrameCryptionState state) {
|
|
74
|
+
WritableMap event = Arguments.createMap();
|
|
75
|
+
event.putString("event", "frameCryptionStateChanged");
|
|
76
|
+
event.putString("participantId", participantId);
|
|
77
|
+
event.putString("state", frameCryptorErrorStateToString(state));
|
|
78
|
+
event.putString("frameCryptorId", frameCryptorId);
|
|
79
|
+
sendEvent("frameCryptionStateChanged", event);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//
|
|
83
|
+
|
|
84
|
+
private FrameCryptorAlgorithm frameCryptorAlgorithmFromInt(int algorithm) {
|
|
85
|
+
switch (algorithm) {
|
|
86
|
+
case 0:
|
|
87
|
+
return FrameCryptorAlgorithm.AES_GCM;
|
|
88
|
+
// case 1:
|
|
89
|
+
// return FrameCryptorAlgorithm.AES_CBC;
|
|
90
|
+
default:
|
|
91
|
+
return FrameCryptorAlgorithm.AES_GCM;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public String frameCryptorFactoryCreateFrameCryptor(ReadableMap params) {
|
|
96
|
+
String keyProviderId = params.getString("keyProviderId");
|
|
97
|
+
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
|
|
98
|
+
if (keyProvider == null) {
|
|
99
|
+
Log.w(TAG, "frameCryptorFactoryCreateFrameCryptorFailed: keyProvider not found");
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
int peerConnectionId = params.getInt("peerConnectionId");
|
|
103
|
+
PeerConnectionObserver pco = webRTCModule.getPeerConnectionObserver(peerConnectionId);
|
|
104
|
+
if (pco == null) {
|
|
105
|
+
Log.w(TAG, "frameCryptorFactoryCreateFrameCryptorFailed: peerConnection not found");
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
String participantId = params.getString("participantId");
|
|
109
|
+
String type = params.getString("type");
|
|
110
|
+
int algorithm = params.getInt("algorithm");
|
|
111
|
+
String rtpSenderId = params.getString("rtpSenderId");
|
|
112
|
+
String rtpReceiverId = params.getString("rtpReceiverId");
|
|
113
|
+
|
|
114
|
+
if (type == null || !(type.equals("sender") || type.equals("receiver"))) {
|
|
115
|
+
Log.w(TAG, "frameCryptorFactoryCreateFrameCryptorFailed: type must be sender or receiver");
|
|
116
|
+
return null;
|
|
117
|
+
} else if (type.equals("sender")) {
|
|
118
|
+
RtpSender rtpSender = pco.getSender(rtpSenderId);
|
|
119
|
+
|
|
120
|
+
FrameCryptor frameCryptor = FrameCryptorFactory.createFrameCryptorForRtpSender(webRTCModule.mFactory,
|
|
121
|
+
rtpSender,
|
|
122
|
+
participantId,
|
|
123
|
+
frameCryptorAlgorithmFromInt(algorithm),
|
|
124
|
+
keyProvider);
|
|
125
|
+
String frameCryptorId = UUID.randomUUID().toString();
|
|
126
|
+
frameCryptos.put(frameCryptorId, frameCryptor);
|
|
127
|
+
FrameCryptorStateObserver observer = new FrameCryptorStateObserver(frameCryptorId);
|
|
128
|
+
frameCryptor.setObserver(observer);
|
|
129
|
+
frameCryptoObservers.put(frameCryptorId, observer);
|
|
130
|
+
|
|
131
|
+
return frameCryptorId;
|
|
132
|
+
} else {
|
|
133
|
+
RtpReceiver rtpReceiver = pco.getReceiver(rtpReceiverId);
|
|
134
|
+
|
|
135
|
+
FrameCryptor frameCryptor = FrameCryptorFactory.createFrameCryptorForRtpReceiver(webRTCModule.mFactory,
|
|
136
|
+
rtpReceiver,
|
|
137
|
+
participantId,
|
|
138
|
+
frameCryptorAlgorithmFromInt(algorithm),
|
|
139
|
+
keyProvider);
|
|
140
|
+
String frameCryptorId = UUID.randomUUID().toString();
|
|
141
|
+
frameCryptos.put(frameCryptorId, frameCryptor);
|
|
142
|
+
FrameCryptorStateObserver observer = new FrameCryptorStateObserver(frameCryptorId);
|
|
143
|
+
frameCryptor.setObserver(observer);
|
|
144
|
+
frameCryptoObservers.put(frameCryptorId, observer);
|
|
145
|
+
|
|
146
|
+
return frameCryptorId;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
public void frameCryptorSetKeyIndex(ReadableMap params, @NonNull Promise result) {
|
|
151
|
+
String frameCryptorId = params.getString("frameCryptorId");
|
|
152
|
+
FrameCryptor frameCryptor = frameCryptos.get(frameCryptorId);
|
|
153
|
+
if (frameCryptor == null) {
|
|
154
|
+
result.reject("frameCryptorSetKeyIndexFailed", "frameCryptor not found", (Throwable) null);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
int keyIndex = params.getInt("keyIndex");
|
|
158
|
+
frameCryptor.setKeyIndex(keyIndex);
|
|
159
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
160
|
+
paramsResult.putBoolean("result", true);
|
|
161
|
+
result.resolve(paramsResult);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public void frameCryptorGetKeyIndex(ReadableMap params, @NonNull Promise result) {
|
|
165
|
+
String frameCryptorId = params.getString("frameCryptorId");
|
|
166
|
+
FrameCryptor frameCryptor = frameCryptos.get(frameCryptorId);
|
|
167
|
+
if (frameCryptor == null) {
|
|
168
|
+
result.reject("frameCryptorGetKeyIndexFailed", "frameCryptor not found", (Throwable) null);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
int keyIndex = frameCryptor.getKeyIndex();
|
|
172
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
173
|
+
paramsResult.putInt("keyIndex", keyIndex);
|
|
174
|
+
result.resolve(paramsResult);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public void frameCryptorSetEnabled(ReadableMap params, @NonNull Promise result) {
|
|
178
|
+
String frameCryptorId = params.getString("frameCryptorId");
|
|
179
|
+
FrameCryptor frameCryptor = frameCryptos.get(frameCryptorId);
|
|
180
|
+
if (frameCryptor == null) {
|
|
181
|
+
result.reject("frameCryptorSetEnabledFailed", "frameCryptor not found", (Throwable) null);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
boolean enabled = params.getBoolean("enabled");
|
|
185
|
+
frameCryptor.setEnabled(enabled);
|
|
186
|
+
|
|
187
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
188
|
+
paramsResult.putBoolean("result", enabled);
|
|
189
|
+
result.resolve(paramsResult);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
public void frameCryptorGetEnabled(ReadableMap params, @NonNull Promise result) {
|
|
193
|
+
String frameCryptorId = params.getString("frameCryptorId");
|
|
194
|
+
FrameCryptor frameCryptor = frameCryptos.get(frameCryptorId);
|
|
195
|
+
if (frameCryptor == null) {
|
|
196
|
+
result.reject("frameCryptorGetEnabledFailed", "frameCryptor not found", (Throwable) null);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
boolean enabled = frameCryptor.isEnabled();
|
|
200
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
201
|
+
paramsResult.putBoolean("enabled", enabled);
|
|
202
|
+
result.resolve(paramsResult);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public void frameCryptorDispose(ReadableMap params, @NonNull Promise result) {
|
|
206
|
+
String frameCryptorId = params.getString("frameCryptorId");
|
|
207
|
+
FrameCryptor frameCryptor = frameCryptos.get(frameCryptorId);
|
|
208
|
+
if (frameCryptor == null) {
|
|
209
|
+
result.reject("frameCryptorDisposeFailed", "frameCryptor not found", (Throwable) null);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
frameCryptor.dispose();
|
|
213
|
+
frameCryptos.remove(frameCryptorId);
|
|
214
|
+
frameCryptoObservers.remove(frameCryptorId);
|
|
215
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
216
|
+
paramsResult.putString("result", "success");
|
|
217
|
+
result.resolve(paramsResult);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@Nullable
|
|
221
|
+
public String frameCryptorFactoryCreateKeyProvider(ReadableMap keyProviderOptions) {
|
|
222
|
+
String keyProviderId = UUID.randomUUID().toString();
|
|
223
|
+
|
|
224
|
+
if (keyProviderOptions == null) {
|
|
225
|
+
Log.w(TAG, "frameCryptorFactoryCreateKeyProvider: keyProviderOptions is null!");
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
boolean sharedKey = keyProviderOptions.getBoolean("sharedKey");
|
|
229
|
+
int ratchetWindowSize = keyProviderOptions.getInt("ratchetWindowSize");
|
|
230
|
+
int failureTolerance = keyProviderOptions.getInt("failureTolerance");
|
|
231
|
+
|
|
232
|
+
byte[] ratchetSalt = getBytesFromMap(keyProviderOptions, "ratchetSalt", "ratchetSaltIsBase64");
|
|
233
|
+
|
|
234
|
+
byte[] uncryptedMagicBytes = new byte[0];
|
|
235
|
+
if (keyProviderOptions.hasKey("uncryptedMagicBytes")) {
|
|
236
|
+
uncryptedMagicBytes = Base64.decode(keyProviderOptions.getString("uncryptedMagicBytes"), Base64.DEFAULT);
|
|
237
|
+
}
|
|
238
|
+
int keyRingSize = (int) keyProviderOptions.getInt("keyRingSize");
|
|
239
|
+
boolean discardFrameWhenCryptorNotReady =
|
|
240
|
+
(boolean) keyProviderOptions.getBoolean("discardFrameWhenCryptorNotReady");
|
|
241
|
+
FrameCryptorKeyProvider keyProvider = FrameCryptorFactory.createFrameCryptorKeyProvider(sharedKey,
|
|
242
|
+
ratchetSalt,
|
|
243
|
+
ratchetWindowSize,
|
|
244
|
+
uncryptedMagicBytes,
|
|
245
|
+
failureTolerance,
|
|
246
|
+
keyRingSize,
|
|
247
|
+
discardFrameWhenCryptorNotReady);
|
|
248
|
+
keyProviders.put(keyProviderId, keyProvider);
|
|
249
|
+
return keyProviderId;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
public void keyProviderSetSharedKey(ReadableMap params, @NonNull Promise result) {
|
|
253
|
+
String keyProviderId = params.getString("keyProviderId");
|
|
254
|
+
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
|
|
255
|
+
if (keyProvider == null) {
|
|
256
|
+
result.reject("keyProviderSetKeySharedFailed", "keyProvider not found", (Throwable) null);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
int keyIndex = params.getInt("keyIndex");
|
|
260
|
+
byte[] key = getBytesFromMap(params, "key", "keyIsBase64");
|
|
261
|
+
keyProvider.setSharedKey(keyIndex, key);
|
|
262
|
+
|
|
263
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
264
|
+
paramsResult.putBoolean("result", true);
|
|
265
|
+
result.resolve(paramsResult);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
public void keyProviderRatchetSharedKey(ReadableMap params, @NonNull Promise result) {
|
|
269
|
+
String keyProviderId = params.getString("keyProviderId");
|
|
270
|
+
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
|
|
271
|
+
if (keyProvider == null) {
|
|
272
|
+
result.reject("keyProviderRatchetSharedKeyFailed", "keyProvider not found", (Throwable) null);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
int keyIndex = params.getInt("keyIndex");
|
|
276
|
+
|
|
277
|
+
byte[] newKey = keyProvider.ratchetSharedKey(keyIndex);
|
|
278
|
+
|
|
279
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
280
|
+
paramsResult.putString("result", Base64.encodeToString(newKey, Base64.NO_WRAP));
|
|
281
|
+
result.resolve(paramsResult);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
public void keyProviderExportSharedKey(ReadableMap params, @NonNull Promise result) {
|
|
285
|
+
String keyProviderId = params.getString("keyProviderId");
|
|
286
|
+
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
|
|
287
|
+
if (keyProvider == null) {
|
|
288
|
+
result.reject("keyProviderExportSharedKeyFailed", "keyProvider not found", (Throwable) null);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
int keyIndex = params.getInt("keyIndex");
|
|
292
|
+
|
|
293
|
+
byte[] key = keyProvider.exportSharedKey(keyIndex);
|
|
294
|
+
|
|
295
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
296
|
+
paramsResult.putString("result", Base64.encodeToString(key, Base64.NO_WRAP));
|
|
297
|
+
result.resolve(paramsResult);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
public void keyProviderSetKey(ReadableMap params, @NonNull Promise result) {
|
|
301
|
+
String keyProviderId = params.getString("keyProviderId");
|
|
302
|
+
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
|
|
303
|
+
if (keyProvider == null) {
|
|
304
|
+
result.reject("keyProviderSetKeyFailed", "keyProvider not found", (Throwable) null);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
int keyIndex = params.getInt("keyIndex");
|
|
308
|
+
String participantId = params.getString("participantId");
|
|
309
|
+
byte[] key = getBytesFromMap(params, "key", "keyIsBase64");
|
|
310
|
+
keyProvider.setKey(participantId, keyIndex, key);
|
|
311
|
+
|
|
312
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
313
|
+
paramsResult.putBoolean("result", true);
|
|
314
|
+
result.resolve(paramsResult);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
public void keyProviderRatchetKey(ReadableMap params, @NonNull Promise result) {
|
|
318
|
+
String keyProviderId = params.getString("keyProviderId");
|
|
319
|
+
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
|
|
320
|
+
if (keyProvider == null) {
|
|
321
|
+
result.reject("keyProviderSetKeysFailed", "keyProvider not found", (Throwable) null);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
String participantId = params.getString("participantId");
|
|
325
|
+
int keyIndex = params.getInt("keyIndex");
|
|
326
|
+
|
|
327
|
+
byte[] newKey = keyProvider.ratchetKey(participantId, keyIndex);
|
|
328
|
+
|
|
329
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
330
|
+
paramsResult.putString("result", Base64.encodeToString(newKey, Base64.NO_WRAP));
|
|
331
|
+
result.resolve(paramsResult);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
public void keyProviderExportKey(ReadableMap params, @NonNull Promise result) {
|
|
335
|
+
String keyProviderId = params.getString("keyProviderId");
|
|
336
|
+
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
|
|
337
|
+
if (keyProvider == null) {
|
|
338
|
+
result.reject("keyProviderExportKeyFailed", "keyProvider not found", (Throwable) null);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
String participantId = params.getString("participantId");
|
|
342
|
+
int keyIndex = params.getInt("keyIndex");
|
|
343
|
+
|
|
344
|
+
byte[] key = keyProvider.exportKey(participantId, keyIndex);
|
|
345
|
+
|
|
346
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
347
|
+
paramsResult.putString("result", Base64.encodeToString(key, Base64.NO_WRAP));
|
|
348
|
+
result.resolve(paramsResult);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
public void keyProviderSetSifTrailer(ReadableMap params, @NonNull Promise result) {
|
|
352
|
+
String keyProviderId = params.getString("keyProviderId");
|
|
353
|
+
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
|
|
354
|
+
if (keyProvider == null) {
|
|
355
|
+
result.reject("keyProviderSetSifTrailerFailed", "keyProvider not found", (Throwable) null);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
byte[] sifTrailer = Base64.decode(params.getString("sifTrailer"), Base64.NO_WRAP);
|
|
359
|
+
keyProvider.setSifTrailer(sifTrailer);
|
|
360
|
+
|
|
361
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
362
|
+
paramsResult.putBoolean("result", true);
|
|
363
|
+
result.resolve(paramsResult);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
public void keyProviderDispose(ReadableMap params, @NonNull Promise result) {
|
|
367
|
+
String keyProviderId = params.getString("keyProviderId");
|
|
368
|
+
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
|
|
369
|
+
if (keyProvider == null) {
|
|
370
|
+
result.reject("keyProviderDisposeFailed", "keyProvider not found", (Throwable) null);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
keyProvider.dispose();
|
|
374
|
+
keyProviders.remove(keyProviderId);
|
|
375
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
376
|
+
paramsResult.putString("result", "success");
|
|
377
|
+
result.resolve(paramsResult);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
public void dataPacketCryptorFactoryCreateDataPacketCryptor(ReadableMap params, @NonNull Promise result) {
|
|
381
|
+
int algorithm = params.getInt("algorithm");
|
|
382
|
+
String keyProviderId = params.getString("keyProviderId");
|
|
383
|
+
|
|
384
|
+
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
|
|
385
|
+
if (keyProvider == null) {
|
|
386
|
+
result.reject(
|
|
387
|
+
"dataPacketCryptorFactoryCreateDataPacketCryptorFailed", "keyProvider not found", (Throwable) null);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
DataPacketCryptorManager cryptor =
|
|
392
|
+
new DataPacketCryptorManager(frameCryptorAlgorithmFromInt(algorithm), keyProvider);
|
|
393
|
+
|
|
394
|
+
String dataPacketCryptorId = UUID.randomUUID().toString();
|
|
395
|
+
dataPacketCryptors.put(dataPacketCryptorId, cryptor);
|
|
396
|
+
|
|
397
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
398
|
+
paramsResult.putString("dataPacketCryptorId", dataPacketCryptorId);
|
|
399
|
+
result.resolve(paramsResult);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
public void dataPacketCryptorEncrypt(ReadableMap params, @NonNull Promise result) {
|
|
403
|
+
String dataPacketCryptorId = params.getString("dataPacketCryptorId");
|
|
404
|
+
String participantId = params.getString("participantId");
|
|
405
|
+
int keyIndex = params.getInt("keyIndex");
|
|
406
|
+
byte[] data = getBytesFromMap(params, "data", null);
|
|
407
|
+
|
|
408
|
+
DataPacketCryptorManager cryptor = dataPacketCryptors.get(dataPacketCryptorId);
|
|
409
|
+
|
|
410
|
+
if (cryptor == null) {
|
|
411
|
+
result.reject("dataPacketCryptorEncryptFailed", "data packet cryptor not found", (Throwable) null);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
DataPacketCryptor.EncryptedPacket packet = cryptor.encrypt(participantId, keyIndex, data);
|
|
416
|
+
|
|
417
|
+
if (packet == null) {
|
|
418
|
+
result.reject("dataPacketCryptorEncryptFailed", "null packet", (Throwable) null);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
423
|
+
paramsResult.putString("payload", Base64.encodeToString(packet.payload, Base64.NO_WRAP));
|
|
424
|
+
paramsResult.putString("iv", Base64.encodeToString(packet.iv, Base64.NO_WRAP));
|
|
425
|
+
paramsResult.putInt("keyIndex", packet.keyIndex);
|
|
426
|
+
result.resolve(paramsResult);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
public void dataPacketCryptorDecrypt(ReadableMap params, @NonNull Promise result) {
|
|
430
|
+
String dataPacketCryptorId = params.getString("dataPacketCryptorId");
|
|
431
|
+
String participantId = params.getString("participantId");
|
|
432
|
+
int keyIndex = params.getInt("keyIndex");
|
|
433
|
+
byte[] payload = getBytesFromMap(params, "payload", null);
|
|
434
|
+
byte[] iv = getBytesFromMap(params, "iv", null);
|
|
435
|
+
|
|
436
|
+
DataPacketCryptorManager cryptor = dataPacketCryptors.get(dataPacketCryptorId);
|
|
437
|
+
|
|
438
|
+
if (cryptor == null) {
|
|
439
|
+
result.reject("dataPacketCryptorDecryptFailed", "data packet cryptor not found", (Throwable) null);
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
DataPacketCryptor.EncryptedPacket packet = new DataPacketCryptor.EncryptedPacket(payload, iv, keyIndex);
|
|
444
|
+
|
|
445
|
+
byte[] decryptedData = cryptor.decrypt(participantId, packet);
|
|
446
|
+
|
|
447
|
+
if (decryptedData == null) {
|
|
448
|
+
result.reject("dataPacketCryptorDecryptFailed", "null decrypted data", (Throwable) null);
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
453
|
+
paramsResult.putString("data", Base64.encodeToString(decryptedData, Base64.NO_WRAP));
|
|
454
|
+
result.resolve(paramsResult);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
public void dataPacketCryptorDispose(ReadableMap params, @NonNull Promise result) {
|
|
458
|
+
String dataPacketCryptorId = params.getString("dataPacketCryptorId");
|
|
459
|
+
|
|
460
|
+
DataPacketCryptorManager cryptor = dataPacketCryptors.get(dataPacketCryptorId);
|
|
461
|
+
|
|
462
|
+
if (cryptor == null) {
|
|
463
|
+
result.reject("dataPacketCryptorDisposeFailed", "data packet cryptor not found", (Throwable) null);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
cryptor.dispose();
|
|
468
|
+
dataPacketCryptors.remove(dataPacketCryptorId);
|
|
469
|
+
WritableMap paramsResult = Arguments.createMap();
|
|
470
|
+
paramsResult.putString("result", "success");
|
|
471
|
+
|
|
472
|
+
result.resolve(paramsResult);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
private byte[] getBytesFromMap(ReadableMap map, String key, @Nullable String isBase64Key) {
|
|
476
|
+
boolean isBase64;
|
|
477
|
+
|
|
478
|
+
if (isBase64Key != null) {
|
|
479
|
+
isBase64 = map.getBoolean(isBase64Key);
|
|
480
|
+
} else {
|
|
481
|
+
isBase64 = true;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
byte[] bytes;
|
|
485
|
+
|
|
486
|
+
if (isBase64) {
|
|
487
|
+
bytes = Base64.decode(map.getString(key), Base64.DEFAULT);
|
|
488
|
+
} else {
|
|
489
|
+
bytes = Objects.requireNonNull(map.getString(key)).getBytes(StandardCharsets.UTF_8);
|
|
490
|
+
}
|
|
491
|
+
return bytes;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
4
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
6
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
7
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
8
|
+
|
|
9
|
+
import java.util.HashMap;
|
|
10
|
+
import java.util.Map;
|
|
11
|
+
|
|
12
|
+
public class RTCVideoViewManager extends SimpleViewManager<WebRTCView> {
|
|
13
|
+
private static final String REACT_CLASS = "RTCVideoView";
|
|
14
|
+
|
|
15
|
+
@Override
|
|
16
|
+
public String getName() {
|
|
17
|
+
return REACT_CLASS;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Override
|
|
21
|
+
public WebRTCView createViewInstance(ThemedReactContext context) {
|
|
22
|
+
return new WebRTCView(context);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Sets the indicator which determines whether a specific {@link WebRTCView}
|
|
27
|
+
* is to mirror the video specified by {@code streamURL} during its rendering.
|
|
28
|
+
* For more details, refer to the documentation of the {@code mirror} property
|
|
29
|
+
* of the JavaScript counterpart of {@code WebRTCView} i.e. {@code RTCView}.
|
|
30
|
+
*
|
|
31
|
+
* @param view The {@code WebRTCView} on which the specified {@code mirror} is
|
|
32
|
+
* to be set.
|
|
33
|
+
* @param mirror If the specified {@code WebRTCView} is to mirror the video
|
|
34
|
+
* specified by its associated {@code streamURL} during its rendering,
|
|
35
|
+
* {@code true}; otherwise, {@code false}.
|
|
36
|
+
*/
|
|
37
|
+
@ReactProp(name = "mirror")
|
|
38
|
+
public void setMirror(WebRTCView view, boolean mirror) {
|
|
39
|
+
view.setMirror(mirror);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* In the fashion of
|
|
44
|
+
* https://www.w3.org/TR/html5/embedded-content-0.html#dom-video-videowidth
|
|
45
|
+
* and https://www.w3.org/TR/html5/rendering.html#video-object-fit, resembles
|
|
46
|
+
* the CSS style {@code object-fit}.
|
|
47
|
+
*
|
|
48
|
+
* @param view The {@code WebRTCView} on which the specified {@code objectFit}
|
|
49
|
+
* is to be set.
|
|
50
|
+
* @param objectFit For details, refer to the documentation of the
|
|
51
|
+
* {@code objectFit} property of the JavaScript counterpart of
|
|
52
|
+
* {@code WebRTCView} i.e. {@code RTCView}.
|
|
53
|
+
*/
|
|
54
|
+
@ReactProp(name = "objectFit")
|
|
55
|
+
public void setObjectFit(WebRTCView view, String objectFit) {
|
|
56
|
+
view.setObjectFit(objectFit);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@ReactProp(name = "streamURL")
|
|
60
|
+
public void setStreamURL(WebRTCView view, String streamURL) {
|
|
61
|
+
view.setStreamURL(streamURL);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Sets the z-order of a specific {@link WebRTCView} in the stacking space of
|
|
66
|
+
* all {@code WebRTCView}s. For more details, refer to the documentation of
|
|
67
|
+
* the {@code zOrder} property of the JavaScript counterpart of
|
|
68
|
+
* {@code WebRTCView} i.e. {@code RTCView}.
|
|
69
|
+
*
|
|
70
|
+
* @param view The {@code WebRTCView} on which the specified {@code zOrder} is
|
|
71
|
+
* to be set.
|
|
72
|
+
* @param zOrder The z-order to set on the specified {@code WebRTCView}.
|
|
73
|
+
*/
|
|
74
|
+
@ReactProp(name = "zOrder")
|
|
75
|
+
public void setZOrder(WebRTCView view, int zOrder) {
|
|
76
|
+
view.setZOrder(zOrder);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Sets the callback for when video dimensions change.
|
|
81
|
+
*
|
|
82
|
+
* @param view The {@code WebRTCView} on which the callback is to be set.
|
|
83
|
+
* @param onDimensionsChange The callback to be called when video dimensions change.
|
|
84
|
+
*/
|
|
85
|
+
@ReactProp(name = "onDimensionsChange")
|
|
86
|
+
public void setOnDimensionsChange(WebRTCView view, boolean onDimensionsChange) {
|
|
87
|
+
view.setOnDimensionsChange(onDimensionsChange);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Override
|
|
91
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
92
|
+
Map<String, Object> eventTypeConstants = new HashMap<>();
|
|
93
|
+
Map<String, String> dimensionsChangeEvent = new HashMap<>();
|
|
94
|
+
dimensionsChangeEvent.put("registrationName", "onDimensionsChange");
|
|
95
|
+
eventTypeConstants.put("onDimensionsChange", dimensionsChangeEvent);
|
|
96
|
+
return eventTypeConstants;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
4
|
+
import com.facebook.react.bridge.ReadableType;
|
|
5
|
+
|
|
6
|
+
public class ReactBridgeUtil {
|
|
7
|
+
/**
|
|
8
|
+
* Reads a value from given <tt>ReadableMap</tt> and returns it as
|
|
9
|
+
* a <tt>String</tt>. Note that integer value is converted to double, before
|
|
10
|
+
* it gets converted to a string.
|
|
11
|
+
* @param map the <tt>ReadableMap</tt> from which the value will be obtained
|
|
12
|
+
* @param key the map's key under which the value has been mapped.
|
|
13
|
+
* @return a <tt>String</tt> representation of the value if exists or
|
|
14
|
+
* <tt>null</tt> if there is no value mapped for given <tt>key</tt>.
|
|
15
|
+
*/
|
|
16
|
+
public static String getMapStrValue(ReadableMap map, String key) {
|
|
17
|
+
if (!map.hasKey(key)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
ReadableType type = map.getType(key);
|
|
21
|
+
switch (type) {
|
|
22
|
+
case Boolean:
|
|
23
|
+
return String.valueOf(map.getBoolean(key));
|
|
24
|
+
case Number:
|
|
25
|
+
// Don't know how to distinguish between Int and Double from
|
|
26
|
+
// ReadableType.Number. 'getInt' will fail on double value,
|
|
27
|
+
// while 'getDouble' works for both.
|
|
28
|
+
// return String.valueOf(map.getInt(key));
|
|
29
|
+
return String.valueOf(map.getDouble(key));
|
|
30
|
+
case String:
|
|
31
|
+
return map.getString(key);
|
|
32
|
+
default:
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|