@sbhjt-gr/react-native-webrtc 124.0.0
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/.claude/settings.local.json +9 -0
- package/.eslintignore +6 -0
- package/.nvmrc +1 -0
- package/ISSUE_TEMPLATE.md +40 -0
- package/LICENSE +22 -0
- package/README.md +103 -0
- package/android/build.gradle +37 -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 +1643 -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/palabra/PalabraClient.java +464 -0
- package/android/src/main/java/com/oney/WebRTCModule/palabra/PalabraConfig.java +17 -0
- package/android/src/main/java/com/oney/WebRTCModule/palabra/PalabraListener.java +7 -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/PalabraAudioSink.h +13 -0
- package/ios/RCTWebRTC/PalabraAudioSink.m +18 -0
- package/ios/RCTWebRTC/PalabraClient.h +36 -0
- package/ios/RCTWebRTC/PalabraClient.m +584 -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+Palabra.h +4 -0
- package/ios/RCTWebRTC/WebRTCModule+Palabra.m +83 -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 +533 -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 +51 -0
- package/ios/RCTWebRTC/WebRTCModule.m +151 -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 +51 -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 +203 -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/RTCPIPView.web.js +23 -0
- package/lib/commonjs/RTCPIPView.web.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/RTCView.web.js +62 -0
- package/lib/commonjs/RTCView.web.js.map +1 -0
- package/lib/commonjs/ScreenCapturePickerView.js +10 -0
- package/lib/commonjs/ScreenCapturePickerView.js.map +1 -0
- package/lib/commonjs/ScreenCapturePickerView.web.js +10 -0
- package/lib/commonjs/ScreenCapturePickerView.web.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/commonjs/index.web.js +175 -0
- package/lib/commonjs/index.web.js.map +1 -0
- package/lib/commonjs/webStream.js +35 -0
- package/lib/commonjs/webStream.js.map +1 -0
- package/lib/module/Constraints.js +2 -0
- package/lib/module/Constraints.js.map +1 -0
- package/lib/module/EventEmitter.js +41 -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 +195 -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/RTCPIPView.web.js +11 -0
- package/lib/module/RTCPIPView.web.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/RTCView.web.js +54 -0
- package/lib/module/RTCView.web.js.map +1 -0
- package/lib/module/ScreenCapturePickerView.js +3 -0
- package/lib/module/ScreenCapturePickerView.js.map +1 -0
- package/lib/module/ScreenCapturePickerView.web.js +4 -0
- package/lib/module/ScreenCapturePickerView.web.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/module/index.web.js +114 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/module/webStream.js +27 -0
- package/lib/module/webStream.js.map +1 -0
- package/lib/typescript/Constraints.d.ts +19 -0
- package/lib/typescript/EventEmitter.d.ts +6 -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 +101 -0
- package/lib/typescript/MediaStreamTrackEvent.d.ts +19 -0
- package/lib/typescript/MessageEvent.d.ts +20 -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/RTCPIPView.web.d.ts +13 -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/RTCView.web.d.ts +25 -0
- package/lib/typescript/ScreenCapturePickerView.d.ts +2 -0
- package/lib/typescript/ScreenCapturePickerView.web.d.ts +1 -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/lib/typescript/index.web.d.ts +101 -0
- package/lib/typescript/webStream.d.ts +3 -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 +66 -0
- package/react-native.config.js +11 -0
- package/src/.eslintrc.cjs +67 -0
- package/src/Constraints.ts +21 -0
- package/src/EventEmitter.ts +65 -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 +284 -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/RTCPIPView.web.tsx +18 -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/RTCView.web.tsx +82 -0
- package/src/ScreenCapturePickerView.ts +4 -0
- package/src/ScreenCapturePickerView.web.tsx +3 -0
- package/src/getDisplayMedia.ts +30 -0
- package/src/getUserMedia.ts +111 -0
- package/src/index.ts +107 -0
- package/src/index.web.ts +191 -0
- package/src/webStream.ts +33 -0
- package/tools/format.sh +6 -0
- package/tools/release.sh +45 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.hardware.camera2.CameraManager;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
import android.util.Pair;
|
|
7
|
+
|
|
8
|
+
import androidx.annotation.Nullable;
|
|
9
|
+
import androidx.core.util.Consumer;
|
|
10
|
+
|
|
11
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
12
|
+
import com.facebook.react.bridge.WritableMap;
|
|
13
|
+
|
|
14
|
+
import org.webrtc.Camera1Capturer;
|
|
15
|
+
import org.webrtc.Camera1Helper;
|
|
16
|
+
import org.webrtc.Camera2Capturer;
|
|
17
|
+
import org.webrtc.Camera2Helper;
|
|
18
|
+
import org.webrtc.CameraEnumerator;
|
|
19
|
+
import org.webrtc.CameraVideoCapturer;
|
|
20
|
+
import org.webrtc.Size;
|
|
21
|
+
import org.webrtc.VideoCapturer;
|
|
22
|
+
|
|
23
|
+
import java.util.ArrayList;
|
|
24
|
+
import java.util.List;
|
|
25
|
+
import java.util.Objects;
|
|
26
|
+
|
|
27
|
+
public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
28
|
+
/**
|
|
29
|
+
* The {@link Log} tag with which {@code CameraCaptureController} is to log.
|
|
30
|
+
*/
|
|
31
|
+
private static final String TAG = CameraCaptureController.class.getSimpleName();
|
|
32
|
+
|
|
33
|
+
private boolean isFrontFacing;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Equivalent to the camera index as a String
|
|
37
|
+
*/
|
|
38
|
+
@Nullable
|
|
39
|
+
private String currentDeviceId;
|
|
40
|
+
|
|
41
|
+
private final Context context;
|
|
42
|
+
private final CameraEnumerator cameraEnumerator;
|
|
43
|
+
|
|
44
|
+
private final String constraintDeviceId;
|
|
45
|
+
private final String constraintFacingMode;
|
|
46
|
+
private ReadableMap constraints;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The {@link CameraEventsHandler} used with
|
|
50
|
+
* {@link CameraEnumerator#createCapturer}.
|
|
51
|
+
*/
|
|
52
|
+
private final CameraEventsHandler cameraEventsHandler = new CameraEventsHandler() {
|
|
53
|
+
@Override
|
|
54
|
+
public void onCameraOpening(String cameraName) {
|
|
55
|
+
super.onCameraOpening(cameraName);
|
|
56
|
+
int cameraIndex = findCameraIndex(cameraName);
|
|
57
|
+
updateActualSize(cameraIndex, cameraName, videoCapturer);
|
|
58
|
+
CameraCaptureController.this.currentDeviceId = cameraIndex == -1 ? null : String.valueOf(cameraIndex);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
public CameraCaptureController(Context context, CameraEnumerator cameraEnumerator, ReadableMap constraints) {
|
|
63
|
+
super(constraints.getInt("width"), constraints.getInt("height"), constraints.getInt("frameRate"));
|
|
64
|
+
|
|
65
|
+
this.context = context;
|
|
66
|
+
this.cameraEnumerator = cameraEnumerator;
|
|
67
|
+
this.constraints = constraints;
|
|
68
|
+
|
|
69
|
+
this.constraintDeviceId = ReactBridgeUtil.getMapStrValue(this.constraints, "deviceId");
|
|
70
|
+
this.constraintFacingMode = ReactBridgeUtil.getMapStrValue(this.constraints, "facingMode");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Nullable
|
|
74
|
+
@Override
|
|
75
|
+
public String getDeviceId() {
|
|
76
|
+
return currentDeviceId;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private int findCameraIndex(String cameraName) {
|
|
80
|
+
String[] deviceNames = cameraEnumerator.getDeviceNames();
|
|
81
|
+
for (int i = 0; i < deviceNames.length; i++) {
|
|
82
|
+
if (Objects.equals(deviceNames[i], cameraName)) {
|
|
83
|
+
return i;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return -1;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@Override
|
|
90
|
+
public WritableMap getSettings() {
|
|
91
|
+
WritableMap settings = super.getSettings();
|
|
92
|
+
settings.putString("facingMode", isFrontFacing ? "user" : "environment");
|
|
93
|
+
return settings;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@Override
|
|
97
|
+
public void applyConstraints(ReadableMap constraints, @Nullable Consumer<Exception> onFinishedCallback) {
|
|
98
|
+
ReadableMap oldConstraints = this.constraints;
|
|
99
|
+
int oldTargetWidth = this.targetWidth;
|
|
100
|
+
int oldTargetHeight = this.targetHeight;
|
|
101
|
+
int oldTargetFps = this.targetFps;
|
|
102
|
+
|
|
103
|
+
// Don't save constraints yet, since we may fail to find a fit.
|
|
104
|
+
Runnable saveConstraints = () -> {
|
|
105
|
+
this.constraints = constraints;
|
|
106
|
+
this.targetWidth = constraints.getInt("width");
|
|
107
|
+
this.targetHeight = constraints.getInt("height");
|
|
108
|
+
this.targetFps = constraints.getInt("frameRate");
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
if (videoCapturer == null) {
|
|
112
|
+
// No existing capturer, just let it initialize normally.
|
|
113
|
+
saveConstraints.run();
|
|
114
|
+
if (onFinishedCallback != null) {
|
|
115
|
+
onFinishedCallback.accept(null);
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Find target camera to switch to.
|
|
121
|
+
String[] deviceNames = cameraEnumerator.getDeviceNames();
|
|
122
|
+
|
|
123
|
+
// Use the initial deviceId/facingMode. It is a constraint violation to change these through applyConstraints.
|
|
124
|
+
final String deviceId = constraintDeviceId;
|
|
125
|
+
final String facingMode = constraintFacingMode;
|
|
126
|
+
int cameraIndex = -1;
|
|
127
|
+
String cameraName = null;
|
|
128
|
+
|
|
129
|
+
// If deviceId is specified, then it takes precedence over facingMode.
|
|
130
|
+
if (deviceId != null) {
|
|
131
|
+
try {
|
|
132
|
+
cameraIndex = Integer.parseInt(deviceId);
|
|
133
|
+
cameraName = deviceNames[cameraIndex];
|
|
134
|
+
} catch (Exception e) {
|
|
135
|
+
Log.d(TAG, "failed to find device with id: " + deviceId);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Otherwise, use facingMode (defaulting to front/user facing).
|
|
140
|
+
if (cameraName == null) {
|
|
141
|
+
cameraIndex = -1;
|
|
142
|
+
final boolean isFrontFacing = facingMode == null || facingMode.equals("user");
|
|
143
|
+
for (String name : deviceNames) {
|
|
144
|
+
cameraIndex++;
|
|
145
|
+
if (cameraEnumerator.isFrontFacing(name) == isFrontFacing) {
|
|
146
|
+
cameraName = name;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (cameraName == null) {
|
|
153
|
+
if (onFinishedCallback != null) {
|
|
154
|
+
onFinishedCallback.accept(new Exception("OverconstrainedError: could not find camera with deviceId: "
|
|
155
|
+
+ deviceId + " or facingMode: " + facingMode));
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// For lambda reference
|
|
161
|
+
final int finalCameraIndex = cameraIndex;
|
|
162
|
+
final String finalCameraName = cameraName;
|
|
163
|
+
boolean shouldSwitchCamera = false;
|
|
164
|
+
try {
|
|
165
|
+
int currentCameraIndex = Integer.parseInt(currentDeviceId);
|
|
166
|
+
shouldSwitchCamera = cameraIndex != currentCameraIndex;
|
|
167
|
+
} catch (Exception e) {
|
|
168
|
+
shouldSwitchCamera = true;
|
|
169
|
+
Log.d(TAG, "Forcing camera switch, couldn't parse current device id: " + currentDeviceId);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
CameraVideoCapturer capturer = (CameraVideoCapturer) videoCapturer;
|
|
173
|
+
Runnable changeFormatIfNeededAndFinish = () -> {
|
|
174
|
+
saveConstraints.run();
|
|
175
|
+
if (targetWidth != oldTargetWidth || targetHeight != oldTargetHeight || targetFps != oldTargetFps) {
|
|
176
|
+
updateActualSize(finalCameraIndex, finalCameraName, videoCapturer);
|
|
177
|
+
capturer.changeCaptureFormat(targetWidth, targetHeight, targetFps);
|
|
178
|
+
}
|
|
179
|
+
if (onFinishedCallback != null) {
|
|
180
|
+
onFinishedCallback.accept(null);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
if (shouldSwitchCamera) {
|
|
185
|
+
capturer.switchCamera(new CameraVideoCapturer.CameraSwitchHandler() {
|
|
186
|
+
@Override
|
|
187
|
+
public void onCameraSwitchDone(boolean isFrontCamera) {
|
|
188
|
+
CameraCaptureController.this.isFrontFacing = isFrontCamera;
|
|
189
|
+
changeFormatIfNeededAndFinish.run();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@Override
|
|
193
|
+
public void onCameraSwitchError(String s) {
|
|
194
|
+
Exception e = new Exception("Error switching camera: " + s);
|
|
195
|
+
Log.e(TAG, "OnCameraSwitchError", e);
|
|
196
|
+
if (onFinishedCallback != null) {
|
|
197
|
+
onFinishedCallback.accept(e);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}, cameraName);
|
|
201
|
+
} else {
|
|
202
|
+
// No camera switch needed, just change format if needed.
|
|
203
|
+
changeFormatIfNeededAndFinish.run();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@Override
|
|
208
|
+
protected VideoCapturer createVideoCapturer() {
|
|
209
|
+
CreateCapturerResult result = createVideoCapturer(constraintDeviceId, constraintFacingMode);
|
|
210
|
+
if (result == null) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
updateActualSize(result.cameraIndex, result.cameraName, result.videoCapturer);
|
|
215
|
+
|
|
216
|
+
return result.videoCapturer;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private void updateActualSize(int cameraIndex, String cameraName, VideoCapturer videoCapturer) {
|
|
220
|
+
// Find actual capture format.
|
|
221
|
+
Size actualSize = null;
|
|
222
|
+
if (videoCapturer instanceof Camera1Capturer) {
|
|
223
|
+
actualSize = Camera1Helper.findClosestCaptureFormat(cameraIndex, targetWidth, targetHeight);
|
|
224
|
+
} else if (videoCapturer instanceof Camera2Capturer) {
|
|
225
|
+
CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
|
|
226
|
+
actualSize = Camera2Helper.findClosestCaptureFormat(cameraManager, cameraName, targetWidth, targetHeight);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (actualSize != null) {
|
|
230
|
+
actualWidth = actualSize.width;
|
|
231
|
+
actualHeight = actualSize.height;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Constructs a new {@code VideoCapturer} instance attempting to satisfy
|
|
237
|
+
* specific constraints.
|
|
238
|
+
*
|
|
239
|
+
* @param deviceId the ID of the requested video device. If not
|
|
240
|
+
* {@code null} and a {@code VideoCapturer} can be created for it, then
|
|
241
|
+
* {@code facingMode} is ignored.
|
|
242
|
+
* @param facingMode the facing of the requested video source such as
|
|
243
|
+
* {@code user} and {@code environment}. If {@code null}, "user" is
|
|
244
|
+
* presumed.
|
|
245
|
+
* @return a pair containing the deviceId and {@code VideoCapturer} satisfying the {@code facingMode} or
|
|
246
|
+
* {@code deviceId} constraint, or null.
|
|
247
|
+
*/
|
|
248
|
+
@Nullable
|
|
249
|
+
private CreateCapturerResult createVideoCapturer(String deviceId, String facingMode) {
|
|
250
|
+
String[] deviceNames = cameraEnumerator.getDeviceNames();
|
|
251
|
+
List<String> failedDevices = new ArrayList<>();
|
|
252
|
+
|
|
253
|
+
String cameraName = null;
|
|
254
|
+
int cameraIndex = -1;
|
|
255
|
+
try {
|
|
256
|
+
cameraIndex = Integer.parseInt(deviceId);
|
|
257
|
+
cameraName = deviceNames[cameraIndex];
|
|
258
|
+
} catch (Exception e) {
|
|
259
|
+
Log.d(TAG, "failed to find device with id: " + deviceId);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// If deviceId is specified, then it takes precedence over facingMode.
|
|
263
|
+
if (cameraName != null) {
|
|
264
|
+
VideoCapturer videoCapturer = cameraEnumerator.createCapturer(cameraName, cameraEventsHandler);
|
|
265
|
+
String message = "Create user-specified camera " + cameraName;
|
|
266
|
+
if (videoCapturer != null) {
|
|
267
|
+
Log.d(TAG, message + " succeeded");
|
|
268
|
+
this.isFrontFacing = cameraEnumerator.isFrontFacing(cameraName);
|
|
269
|
+
this.currentDeviceId = String.valueOf(cameraIndex);
|
|
270
|
+
return new CreateCapturerResult(cameraIndex, cameraName, videoCapturer);
|
|
271
|
+
} else {
|
|
272
|
+
// fallback to facingMode
|
|
273
|
+
Log.d(TAG, message + " failed");
|
|
274
|
+
failedDevices.add(cameraName);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Otherwise, use facingMode (defaulting to front/user facing).
|
|
279
|
+
final boolean isFrontFacing = facingMode == null || facingMode.equals("user");
|
|
280
|
+
cameraIndex = -1;
|
|
281
|
+
for (String name : deviceNames) {
|
|
282
|
+
cameraIndex++;
|
|
283
|
+
if (failedDevices.contains(name)) {
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
if (cameraEnumerator.isFrontFacing(name) != isFrontFacing) {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
VideoCapturer videoCapturer = cameraEnumerator.createCapturer(name, cameraEventsHandler);
|
|
290
|
+
String message = "Create camera " + name;
|
|
291
|
+
if (videoCapturer != null) {
|
|
292
|
+
Log.d(TAG, message + " succeeded");
|
|
293
|
+
this.isFrontFacing = cameraEnumerator.isFrontFacing(name);
|
|
294
|
+
this.currentDeviceId = String.valueOf(cameraIndex);
|
|
295
|
+
return new CreateCapturerResult(cameraIndex, name, videoCapturer);
|
|
296
|
+
} else {
|
|
297
|
+
Log.d(TAG, message + " failed");
|
|
298
|
+
failedDevices.add(name);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
cameraIndex = -1;
|
|
303
|
+
// Fallback to any available camera.
|
|
304
|
+
for (String name : deviceNames) {
|
|
305
|
+
cameraIndex++;
|
|
306
|
+
if (!failedDevices.contains(name)) {
|
|
307
|
+
VideoCapturer videoCapturer = cameraEnumerator.createCapturer(name, cameraEventsHandler);
|
|
308
|
+
String message = "Create fallback camera " + name;
|
|
309
|
+
if (videoCapturer != null) {
|
|
310
|
+
Log.d(TAG, message + " succeeded");
|
|
311
|
+
this.isFrontFacing = cameraEnumerator.isFrontFacing(name);
|
|
312
|
+
this.currentDeviceId = String.valueOf(cameraIndex);
|
|
313
|
+
return new CreateCapturerResult(cameraIndex, name, videoCapturer);
|
|
314
|
+
} else {
|
|
315
|
+
Log.d(TAG, message + " failed");
|
|
316
|
+
failedDevices.add(name);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
currentDeviceId = null;
|
|
322
|
+
Log.w(TAG, "Unable to identify a suitable camera.");
|
|
323
|
+
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private static class CreateCapturerResult {
|
|
328
|
+
public final int cameraIndex;
|
|
329
|
+
public final String cameraName;
|
|
330
|
+
public final VideoCapturer videoCapturer;
|
|
331
|
+
|
|
332
|
+
public CreateCapturerResult(int cameraIndex, String cameraName, VideoCapturer videoCapturer) {
|
|
333
|
+
this.cameraIndex = cameraIndex;
|
|
334
|
+
this.cameraName = cameraName;
|
|
335
|
+
this.videoCapturer = videoCapturer;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
5
|
+
import org.webrtc.CameraVideoCapturer;
|
|
6
|
+
|
|
7
|
+
class CameraEventsHandler implements CameraVideoCapturer.CameraEventsHandler {
|
|
8
|
+
/**
|
|
9
|
+
* The {@link Log} tag with which {@code CameraEventsHandler} is to log.
|
|
10
|
+
*/
|
|
11
|
+
private final static String TAG = WebRTCModule.TAG;
|
|
12
|
+
|
|
13
|
+
// Callback invoked when camera closed.
|
|
14
|
+
@Override
|
|
15
|
+
public void onCameraClosed() {
|
|
16
|
+
Log.d(TAG, "CameraEventsHandler.onCameraClosed");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Called when camera is disconnected.
|
|
20
|
+
@Override
|
|
21
|
+
public void onCameraDisconnected() {
|
|
22
|
+
Log.d(TAG, "CameraEventsHandler.onCameraDisconnected");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Camera error handler - invoked when camera can not be opened or any
|
|
26
|
+
// camera exception happens on camera thread.
|
|
27
|
+
@Override
|
|
28
|
+
public void onCameraError(String errorDescription) {
|
|
29
|
+
Log.d(TAG, "CameraEventsHandler.onCameraError: errorDescription=" + errorDescription);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Invoked when camera stops receiving frames
|
|
33
|
+
@Override
|
|
34
|
+
public void onCameraFreezed(String errorDescription) {
|
|
35
|
+
Log.d(TAG, "CameraEventsHandler.onCameraFreezed: errorDescription=" + errorDescription);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Callback invoked when camera is opening.
|
|
39
|
+
@Override
|
|
40
|
+
public void onCameraOpening(String cameraName) {
|
|
41
|
+
Log.d(TAG, "CameraEventsHandler.onCameraOpening: cameraName=" + cameraName);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Callback invoked when first camera frame is available after camera is opened.
|
|
45
|
+
@Override
|
|
46
|
+
public void onFirstFrameAvailable() {
|
|
47
|
+
Log.d(TAG, "CameraEventsHandler.onFirstFrameAvailable");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import android.util.Base64;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.Nullable;
|
|
6
|
+
|
|
7
|
+
import com.facebook.react.bridge.Arguments;
|
|
8
|
+
import com.facebook.react.bridge.WritableMap;
|
|
9
|
+
|
|
10
|
+
import org.webrtc.DataChannel;
|
|
11
|
+
|
|
12
|
+
import java.nio.charset.StandardCharsets;
|
|
13
|
+
|
|
14
|
+
class DataChannelWrapper implements DataChannel.Observer {
|
|
15
|
+
private final String reactTag;
|
|
16
|
+
private final DataChannel mDataChannel;
|
|
17
|
+
private final int peerConnectionId;
|
|
18
|
+
private final WebRTCModule webRTCModule;
|
|
19
|
+
|
|
20
|
+
DataChannelWrapper(WebRTCModule webRTCModule, int peerConnectionId, String reactTag, DataChannel dataChannel) {
|
|
21
|
+
this.webRTCModule = webRTCModule;
|
|
22
|
+
this.peerConnectionId = peerConnectionId;
|
|
23
|
+
this.reactTag = reactTag;
|
|
24
|
+
mDataChannel = dataChannel;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public DataChannel getDataChannel() {
|
|
28
|
+
return mDataChannel;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public String getReactTag() {
|
|
32
|
+
return reactTag;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Nullable
|
|
36
|
+
public String dataChannelStateString(DataChannel.State dataChannelState) {
|
|
37
|
+
switch (dataChannelState) {
|
|
38
|
+
case CONNECTING:
|
|
39
|
+
return "connecting";
|
|
40
|
+
case OPEN:
|
|
41
|
+
return "open";
|
|
42
|
+
case CLOSING:
|
|
43
|
+
return "closing";
|
|
44
|
+
case CLOSED:
|
|
45
|
+
return "closed";
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Override
|
|
51
|
+
public void onBufferedAmountChange(long amount) {
|
|
52
|
+
WritableMap params = Arguments.createMap();
|
|
53
|
+
params.putString("reactTag", reactTag);
|
|
54
|
+
params.putInt("peerConnectionId", peerConnectionId);
|
|
55
|
+
params.putDouble("bufferedAmount", Long.valueOf(amount).doubleValue());
|
|
56
|
+
|
|
57
|
+
webRTCModule.sendEvent("dataChannelDidChangeBufferedAmount", params);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Override
|
|
61
|
+
public void onMessage(DataChannel.Buffer buffer) {
|
|
62
|
+
WritableMap params = Arguments.createMap();
|
|
63
|
+
params.putString("reactTag", reactTag);
|
|
64
|
+
params.putInt("peerConnectionId", peerConnectionId);
|
|
65
|
+
|
|
66
|
+
byte[] bytes;
|
|
67
|
+
if (buffer.data.hasArray()) {
|
|
68
|
+
bytes = buffer.data.array();
|
|
69
|
+
} else {
|
|
70
|
+
bytes = new byte[buffer.data.remaining()];
|
|
71
|
+
buffer.data.get(bytes);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
String type;
|
|
75
|
+
String data;
|
|
76
|
+
if (buffer.binary) {
|
|
77
|
+
type = "binary";
|
|
78
|
+
data = Base64.encodeToString(bytes, Base64.NO_WRAP);
|
|
79
|
+
} else {
|
|
80
|
+
type = "text";
|
|
81
|
+
data = new String(bytes, StandardCharsets.UTF_8);
|
|
82
|
+
}
|
|
83
|
+
params.putString("type", type);
|
|
84
|
+
params.putString("data", data);
|
|
85
|
+
|
|
86
|
+
webRTCModule.sendEvent("dataChannelReceiveMessage", params);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@Override
|
|
90
|
+
public void onStateChange() {
|
|
91
|
+
WritableMap params = Arguments.createMap();
|
|
92
|
+
params.putString("reactTag", reactTag);
|
|
93
|
+
params.putInt("peerConnectionId", peerConnectionId);
|
|
94
|
+
params.putInt("id", mDataChannel.id());
|
|
95
|
+
params.putString("state", dataChannelStateString(mDataChannel.state()));
|
|
96
|
+
|
|
97
|
+
webRTCModule.sendEvent("dataChannelStateChanged", params);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
5
|
+
import org.webrtc.DataPacketCryptor;
|
|
6
|
+
import org.webrtc.DataPacketCryptorFactory;
|
|
7
|
+
import org.webrtc.FrameCryptorAlgorithm;
|
|
8
|
+
import org.webrtc.FrameCryptorKeyProvider;
|
|
9
|
+
|
|
10
|
+
import javax.annotation.Nullable;
|
|
11
|
+
|
|
12
|
+
public class DataPacketCryptorManager {
|
|
13
|
+
private static final String TAG = DataPacketCryptorManager.class.getSimpleName();
|
|
14
|
+
private final DataPacketCryptor dataPacketCryptor;
|
|
15
|
+
private boolean isDisposed = false;
|
|
16
|
+
|
|
17
|
+
public DataPacketCryptorManager(FrameCryptorAlgorithm algorithm, FrameCryptorKeyProvider keyProvider) {
|
|
18
|
+
dataPacketCryptor =
|
|
19
|
+
DataPacketCryptorFactory.createDataPacketCryptor(FrameCryptorAlgorithm.AES_GCM, keyProvider);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Nullable
|
|
23
|
+
public synchronized DataPacketCryptor.EncryptedPacket encrypt(String participantId, int keyIndex, byte[] payload) {
|
|
24
|
+
if (isDisposed) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
DataPacketCryptor.EncryptedPacket packet = dataPacketCryptor.encrypt(participantId, keyIndex, payload);
|
|
29
|
+
|
|
30
|
+
if (packet == null) {
|
|
31
|
+
Log.i(TAG, "Error encrypting packet: null packet");
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (packet.payload == null) {
|
|
36
|
+
Log.i(TAG, "Error encrypting packet: null payload");
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
if (packet.iv == null) {
|
|
40
|
+
Log.i(TAG, "Error encrypting packet: null iv returned");
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return packet;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Nullable
|
|
48
|
+
public synchronized byte[] decrypt(String participantId, DataPacketCryptor.EncryptedPacket packet) {
|
|
49
|
+
if (isDisposed) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return dataPacketCryptor.decrypt(participantId, packet);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public synchronized void dispose() {
|
|
57
|
+
if (isDisposed) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
isDisposed = true;
|
|
61
|
+
dataPacketCryptor.dispose();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.util.DisplayMetrics;
|
|
6
|
+
import android.view.WindowManager;
|
|
7
|
+
|
|
8
|
+
public class DisplayUtils {
|
|
9
|
+
public static DisplayMetrics getDisplayMetrics(Activity activity) {
|
|
10
|
+
DisplayMetrics displayMetrics = new DisplayMetrics();
|
|
11
|
+
WindowManager windowManager =
|
|
12
|
+
(WindowManager) activity.getApplication().getSystemService(Context.WINDOW_SERVICE);
|
|
13
|
+
windowManager.getDefaultDisplay().getRealMetrics(displayMetrics);
|
|
14
|
+
return displayMetrics;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package com.oney.WebRTCModule;
|
|
2
|
+
|
|
3
|
+
import android.os.Build.VERSION;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import org.webrtc.EglBase;
|
|
7
|
+
|
|
8
|
+
public class EglUtils {
|
|
9
|
+
/**
|
|
10
|
+
* The root {@link EglBase} instance shared by the entire application for
|
|
11
|
+
* the sake of reducing the utilization of system resources (such as EGL
|
|
12
|
+
* contexts). It selects between {@link EglBase10} and {@link EglBase14}
|
|
13
|
+
* by performing a runtime check.
|
|
14
|
+
*/
|
|
15
|
+
private static EglBase rootEglBase;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Lazily creates and returns the one and only {@link EglBase} which will
|
|
19
|
+
* serve as the root for all contexts that are needed.
|
|
20
|
+
*/
|
|
21
|
+
public static synchronized EglBase getRootEglBase() {
|
|
22
|
+
if (rootEglBase == null) {
|
|
23
|
+
// XXX EglBase14 will report that isEGL14Supported() but its
|
|
24
|
+
// getEglConfig() will fail with a RuntimeException with message
|
|
25
|
+
// "Unable to find any matching EGL config". Fall back to EglBase10
|
|
26
|
+
// in the described scenario.
|
|
27
|
+
EglBase eglBase = null;
|
|
28
|
+
int[] configAttributes = EglBase.CONFIG_PLAIN;
|
|
29
|
+
RuntimeException cause = null;
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
// WebRTC internally does this check in isEGL14Supported, but it's no longer exposed
|
|
33
|
+
// in the public API
|
|
34
|
+
if (VERSION.SDK_INT >= 18) {
|
|
35
|
+
eglBase = EglBase.createEgl14(configAttributes);
|
|
36
|
+
}
|
|
37
|
+
} catch (RuntimeException ex) {
|
|
38
|
+
// Fall back to EglBase10.
|
|
39
|
+
cause = ex;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (eglBase == null) {
|
|
43
|
+
try {
|
|
44
|
+
eglBase = EglBase.createEgl10(configAttributes);
|
|
45
|
+
} catch (RuntimeException ex) {
|
|
46
|
+
// Neither EglBase14, nor EglBase10 succeeded to initialize.
|
|
47
|
+
cause = ex;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (cause != null) {
|
|
52
|
+
Log.e(EglUtils.class.getName(), "Failed to create EglBase", cause);
|
|
53
|
+
} else {
|
|
54
|
+
rootEglBase = eglBase;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return rootEglBase;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public static EglBase.Context getRootEglBaseContext() {
|
|
62
|
+
EglBase eglBase = getRootEglBase();
|
|
63
|
+
|
|
64
|
+
return eglBase == null ? null : eglBase.getEglBaseContext();
|
|
65
|
+
}
|
|
66
|
+
}
|