diff --git a/example/index.tsx b/example/index.tsx index 203603e..a6028aa 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -1,8 +1,8 @@ import { AppRegistry } from 'react-native'; //import App from './src/App'; -//import App from './src/Play'; +import App from './src/Play'; //import App from './src/Peer'; -import App from './src/Conference'; +//import App from './src/Conference'; import { name as appName } from './app.json'; AppRegistry.registerComponent(appName, () => App); diff --git a/example/ios/Podfile b/example/ios/Podfile index 77dd9a9..d7ffe6e 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,7 +1,10 @@ require_relative '../node_modules/react-native/scripts/react_native_pods' + +project 'ReactNativeAntMediaExample.xcodeproj' + require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' -platform :ios, '11.0' +platform :ios, '16.0' install! 'cocoapods', :deterministic_uuids => false target 'ReactNativeAntMediaExample' do diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock new file mode 100644 index 0000000..26f1134 --- /dev/null +++ b/example/ios/Podfile.lock @@ -0,0 +1,566 @@ +PODS: + - boost (1.76.0) + - CocoaAsyncSocket (7.6.5) + - DoubleConversion (1.1.6) + - FBLazyVector (0.68.2) + - FBReactNativeSpec (0.68.2): + - RCT-Folly (= 2021.06.28.00-v2) + - RCTRequired (= 0.68.2) + - RCTTypeSafety (= 0.68.2) + - React-Core (= 0.68.2) + - React-jsi (= 0.68.2) + - ReactCommon/turbomodule/core (= 0.68.2) + - Flipper (0.125.0): + - Flipper-Folly (~> 2.6) + - Flipper-RSocket (~> 1.4) + - Flipper-Boost-iOSX (1.76.0.1.11) + - Flipper-DoubleConversion (3.2.0) + - Flipper-Fmt (7.1.7) + - Flipper-Folly (2.6.10): + - Flipper-Boost-iOSX + - Flipper-DoubleConversion + - Flipper-Fmt (= 7.1.7) + - Flipper-Glog + - libevent (~> 2.1.12) + - OpenSSL-Universal (= 1.1.1100) + - Flipper-Glog (0.5.0.4) + - Flipper-PeerTalk (0.0.4) + - Flipper-RSocket (1.4.3): + - Flipper-Folly (~> 2.6) + - FlipperKit (0.125.0): + - FlipperKit/Core (= 0.125.0) + - FlipperKit/Core (0.125.0): + - Flipper (~> 0.125.0) + - FlipperKit/CppBridge + - FlipperKit/FBCxxFollyDynamicConvert + - FlipperKit/FBDefines + - FlipperKit/FKPortForwarding + - SocketRocket (~> 0.6.0) + - FlipperKit/CppBridge (0.125.0): + - Flipper (~> 0.125.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.125.0): + - Flipper-Folly (~> 2.6) + - FlipperKit/FBDefines (0.125.0) + - FlipperKit/FKPortForwarding (0.125.0): + - CocoaAsyncSocket (~> 7.6) + - Flipper-PeerTalk (~> 0.0.4) + - FlipperKit/FlipperKitHighlightOverlay (0.125.0) + - FlipperKit/FlipperKitLayoutHelpers (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitHighlightOverlay + - FlipperKit/FlipperKitLayoutTextSearchable + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitHighlightOverlay + - FlipperKit/FlipperKitLayoutHelpers + - YogaKit (~> 1.18) + - FlipperKit/FlipperKitLayoutPlugin (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitHighlightOverlay + - FlipperKit/FlipperKitLayoutHelpers + - FlipperKit/FlipperKitLayoutIOSDescriptors + - FlipperKit/FlipperKitLayoutTextSearchable + - YogaKit (~> 1.18) + - FlipperKit/FlipperKitLayoutTextSearchable (0.125.0) + - FlipperKit/FlipperKitNetworkPlugin (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitReactPlugin (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitUserDefaultsPlugin (0.125.0): + - FlipperKit/Core + - FlipperKit/SKIOSNetworkPlugin (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitNetworkPlugin + - fmt (6.2.1) + - glog (0.3.5) + - JitsiWebRTC (111.0.2) + - libevent (2.1.12) + - OpenSSL-Universal (1.1.1100) + - RCT-Folly (2021.06.28.00-v2): + - boost + - DoubleConversion + - fmt (~> 6.2.1) + - glog + - RCT-Folly/Default (= 2021.06.28.00-v2) + - RCT-Folly/Default (2021.06.28.00-v2): + - boost + - DoubleConversion + - fmt (~> 6.2.1) + - glog + - RCTRequired (0.68.2) + - RCTTypeSafety (0.68.2): + - FBLazyVector (= 0.68.2) + - RCT-Folly (= 2021.06.28.00-v2) + - RCTRequired (= 0.68.2) + - React-Core (= 0.68.2) + - React (0.68.2): + - React-Core (= 0.68.2) + - React-Core/DevSupport (= 0.68.2) + - React-Core/RCTWebSocket (= 0.68.2) + - React-RCTActionSheet (= 0.68.2) + - React-RCTAnimation (= 0.68.2) + - React-RCTBlob (= 0.68.2) + - React-RCTImage (= 0.68.2) + - React-RCTLinking (= 0.68.2) + - React-RCTNetwork (= 0.68.2) + - React-RCTSettings (= 0.68.2) + - React-RCTText (= 0.68.2) + - React-RCTVibration (= 0.68.2) + - React-callinvoker (0.68.2) + - React-Codegen (0.68.2): + - FBReactNativeSpec (= 0.68.2) + - RCT-Folly (= 2021.06.28.00-v2) + - RCTRequired (= 0.68.2) + - RCTTypeSafety (= 0.68.2) + - React-Core (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - ReactCommon/turbomodule/core (= 0.68.2) + - React-Core (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default (= 0.68.2) + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/CoreModulesHeaders (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/Default (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/DevSupport (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default (= 0.68.2) + - React-Core/RCTWebSocket (= 0.68.2) + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-jsinspector (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/RCTActionSheetHeaders (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/RCTAnimationHeaders (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/RCTBlobHeaders (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/RCTImageHeaders (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/RCTLinkingHeaders (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/RCTNetworkHeaders (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/RCTSettingsHeaders (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/RCTTextHeaders (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/RCTVibrationHeaders (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-Core/RCTWebSocket (0.68.2): + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-Core/Default (= 0.68.2) + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsiexecutor (= 0.68.2) + - React-perflogger (= 0.68.2) + - Yoga + - React-CoreModules (0.68.2): + - RCT-Folly (= 2021.06.28.00-v2) + - RCTTypeSafety (= 0.68.2) + - React-Codegen (= 0.68.2) + - React-Core/CoreModulesHeaders (= 0.68.2) + - React-jsi (= 0.68.2) + - React-RCTImage (= 0.68.2) + - ReactCommon/turbomodule/core (= 0.68.2) + - React-cxxreact (0.68.2): + - boost (= 1.76.0) + - DoubleConversion + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-callinvoker (= 0.68.2) + - React-jsi (= 0.68.2) + - React-jsinspector (= 0.68.2) + - React-logger (= 0.68.2) + - React-perflogger (= 0.68.2) + - React-runtimeexecutor (= 0.68.2) + - React-jsi (0.68.2): + - boost (= 1.76.0) + - DoubleConversion + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-jsi/Default (= 0.68.2) + - React-jsi/Default (0.68.2): + - boost (= 1.76.0) + - DoubleConversion + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-jsiexecutor (0.68.2): + - DoubleConversion + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-perflogger (= 0.68.2) + - React-jsinspector (0.68.2) + - React-logger (0.68.2): + - glog + - react-native-webrtc (111.0.0): + - JitsiWebRTC (~> 111.0.0) + - React-Core + - React-perflogger (0.68.2) + - React-RCTActionSheet (0.68.2): + - React-Core/RCTActionSheetHeaders (= 0.68.2) + - React-RCTAnimation (0.68.2): + - RCT-Folly (= 2021.06.28.00-v2) + - RCTTypeSafety (= 0.68.2) + - React-Codegen (= 0.68.2) + - React-Core/RCTAnimationHeaders (= 0.68.2) + - React-jsi (= 0.68.2) + - ReactCommon/turbomodule/core (= 0.68.2) + - React-RCTBlob (0.68.2): + - RCT-Folly (= 2021.06.28.00-v2) + - React-Codegen (= 0.68.2) + - React-Core/RCTBlobHeaders (= 0.68.2) + - React-Core/RCTWebSocket (= 0.68.2) + - React-jsi (= 0.68.2) + - React-RCTNetwork (= 0.68.2) + - ReactCommon/turbomodule/core (= 0.68.2) + - React-RCTImage (0.68.2): + - RCT-Folly (= 2021.06.28.00-v2) + - RCTTypeSafety (= 0.68.2) + - React-Codegen (= 0.68.2) + - React-Core/RCTImageHeaders (= 0.68.2) + - React-jsi (= 0.68.2) + - React-RCTNetwork (= 0.68.2) + - ReactCommon/turbomodule/core (= 0.68.2) + - React-RCTLinking (0.68.2): + - React-Codegen (= 0.68.2) + - React-Core/RCTLinkingHeaders (= 0.68.2) + - React-jsi (= 0.68.2) + - ReactCommon/turbomodule/core (= 0.68.2) + - React-RCTNetwork (0.68.2): + - RCT-Folly (= 2021.06.28.00-v2) + - RCTTypeSafety (= 0.68.2) + - React-Codegen (= 0.68.2) + - React-Core/RCTNetworkHeaders (= 0.68.2) + - React-jsi (= 0.68.2) + - ReactCommon/turbomodule/core (= 0.68.2) + - React-RCTSettings (0.68.2): + - RCT-Folly (= 2021.06.28.00-v2) + - RCTTypeSafety (= 0.68.2) + - React-Codegen (= 0.68.2) + - React-Core/RCTSettingsHeaders (= 0.68.2) + - React-jsi (= 0.68.2) + - ReactCommon/turbomodule/core (= 0.68.2) + - React-RCTText (0.68.2): + - React-Core/RCTTextHeaders (= 0.68.2) + - React-RCTVibration (0.68.2): + - RCT-Folly (= 2021.06.28.00-v2) + - React-Codegen (= 0.68.2) + - React-Core/RCTVibrationHeaders (= 0.68.2) + - React-jsi (= 0.68.2) + - ReactCommon/turbomodule/core (= 0.68.2) + - React-runtimeexecutor (0.68.2): + - React-jsi (= 0.68.2) + - ReactCommon/turbomodule/core (0.68.2): + - DoubleConversion + - glog + - RCT-Folly (= 2021.06.28.00-v2) + - React-callinvoker (= 0.68.2) + - React-Core (= 0.68.2) + - React-cxxreact (= 0.68.2) + - React-jsi (= 0.68.2) + - React-logger (= 0.68.2) + - React-perflogger (= 0.68.2) + - ReactNativeIncallManager (4.1.0): + - React-Core + - RNVectorIcons (10.0.3): + - React-Core + - SocketRocket (0.6.1) + - Yoga (1.14.0) + - YogaKit (1.18.1): + - Yoga (~> 1.14) + +DEPENDENCIES: + - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) + - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) + - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) + - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) + - Flipper (= 0.125.0) + - Flipper-Boost-iOSX (= 1.76.0.1.11) + - Flipper-DoubleConversion (= 3.2.0) + - Flipper-Fmt (= 7.1.7) + - Flipper-Folly (= 2.6.10) + - Flipper-Glog (= 0.5.0.4) + - Flipper-PeerTalk (= 0.0.4) + - Flipper-RSocket (= 1.4.3) + - FlipperKit (= 0.125.0) + - FlipperKit/Core (= 0.125.0) + - FlipperKit/CppBridge (= 0.125.0) + - FlipperKit/FBCxxFollyDynamicConvert (= 0.125.0) + - FlipperKit/FBDefines (= 0.125.0) + - FlipperKit/FKPortForwarding (= 0.125.0) + - FlipperKit/FlipperKitHighlightOverlay (= 0.125.0) + - FlipperKit/FlipperKitLayoutPlugin (= 0.125.0) + - FlipperKit/FlipperKitLayoutTextSearchable (= 0.125.0) + - FlipperKit/FlipperKitNetworkPlugin (= 0.125.0) + - FlipperKit/FlipperKitReactPlugin (= 0.125.0) + - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.125.0) + - FlipperKit/SKIOSNetworkPlugin (= 0.125.0) + - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) + - OpenSSL-Universal (= 1.1.1100) + - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) + - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) + - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) + - React (from `../node_modules/react-native/`) + - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) + - React-Codegen (from `build/generated/ios`) + - React-Core (from `../node_modules/react-native/`) + - React-Core/DevSupport (from `../node_modules/react-native/`) + - React-Core/RCTWebSocket (from `../node_modules/react-native/`) + - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) + - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) + - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) + - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) + - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) + - React-logger (from `../node_modules/react-native/ReactCommon/logger`) + - react-native-webrtc (from `../node_modules/react-native-webrtc`) + - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) + - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) + - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) + - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) + - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) + - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) + - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) + - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) + - React-RCTText (from `../node_modules/react-native/Libraries/Text`) + - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) + - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) + - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) + - ReactNativeIncallManager (from `../node_modules/react-native-incall-manager`) + - RNVectorIcons (from `../node_modules/react-native-vector-icons`) + - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) + +SPEC REPOS: + trunk: + - CocoaAsyncSocket + - Flipper + - Flipper-Boost-iOSX + - Flipper-DoubleConversion + - Flipper-Fmt + - Flipper-Folly + - Flipper-Glog + - Flipper-PeerTalk + - Flipper-RSocket + - FlipperKit + - fmt + - JitsiWebRTC + - libevent + - OpenSSL-Universal + - SocketRocket + - YogaKit + +EXTERNAL SOURCES: + boost: + :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" + DoubleConversion: + :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" + FBLazyVector: + :path: "../node_modules/react-native/Libraries/FBLazyVector" + FBReactNativeSpec: + :path: "../node_modules/react-native/React/FBReactNativeSpec" + glog: + :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" + RCT-Folly: + :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" + RCTRequired: + :path: "../node_modules/react-native/Libraries/RCTRequired" + RCTTypeSafety: + :path: "../node_modules/react-native/Libraries/TypeSafety" + React: + :path: "../node_modules/react-native/" + React-callinvoker: + :path: "../node_modules/react-native/ReactCommon/callinvoker" + React-Codegen: + :path: build/generated/ios + React-Core: + :path: "../node_modules/react-native/" + React-CoreModules: + :path: "../node_modules/react-native/React/CoreModules" + React-cxxreact: + :path: "../node_modules/react-native/ReactCommon/cxxreact" + React-jsi: + :path: "../node_modules/react-native/ReactCommon/jsi" + React-jsiexecutor: + :path: "../node_modules/react-native/ReactCommon/jsiexecutor" + React-jsinspector: + :path: "../node_modules/react-native/ReactCommon/jsinspector" + React-logger: + :path: "../node_modules/react-native/ReactCommon/logger" + react-native-webrtc: + :path: "../node_modules/react-native-webrtc" + React-perflogger: + :path: "../node_modules/react-native/ReactCommon/reactperflogger" + React-RCTActionSheet: + :path: "../node_modules/react-native/Libraries/ActionSheetIOS" + React-RCTAnimation: + :path: "../node_modules/react-native/Libraries/NativeAnimation" + React-RCTBlob: + :path: "../node_modules/react-native/Libraries/Blob" + React-RCTImage: + :path: "../node_modules/react-native/Libraries/Image" + React-RCTLinking: + :path: "../node_modules/react-native/Libraries/LinkingIOS" + React-RCTNetwork: + :path: "../node_modules/react-native/Libraries/Network" + React-RCTSettings: + :path: "../node_modules/react-native/Libraries/Settings" + React-RCTText: + :path: "../node_modules/react-native/Libraries/Text" + React-RCTVibration: + :path: "../node_modules/react-native/Libraries/Vibration" + React-runtimeexecutor: + :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" + ReactCommon: + :path: "../node_modules/react-native/ReactCommon" + ReactNativeIncallManager: + :path: "../node_modules/react-native-incall-manager" + RNVectorIcons: + :path: "../node_modules/react-native-vector-icons" + Yoga: + :path: "../node_modules/react-native/ReactCommon/yoga" + +SPEC CHECKSUMS: + boost: a7c83b31436843459a1961bfd74b96033dc77234 + CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 + DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662 + FBLazyVector: a7a655862f6b09625d11c772296b01cd5164b648 + FBReactNativeSpec: 81ce99032d5b586fddd6a38d450f8595f7e04be4 + Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 + Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c + Flipper-DoubleConversion: 3d3d04a078d4f3a1b6c6916587f159dc11f232c4 + Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b + Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 + Flipper-Glog: 87bc98ff48de90cb5b0b5114ed3da79d85ee2dd4 + Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 + Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541 + FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86 + fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 + glog: 476ee3e89abb49e07f822b48323c51c57124b572 + JitsiWebRTC: 80f62908fcf2a1160e0d14b584323fb6e6be630b + libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 + OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c + RCT-Folly: 4d8508a426467c48885f1151029bc15fa5d7b3b8 + RCTRequired: 3e917ea5377751094f38145fdece525aa90545a0 + RCTTypeSafety: c43c072a4bd60feb49a9570b0517892b4305c45e + React: 176dd882de001854ced260fad41bb68a31aa4bd0 + React-callinvoker: c2864d1818d6e64928d2faf774a3800dfc38fe1f + React-Codegen: 98b6f97f0a7abf7d67e4ce435c77c05b7a95cf05 + React-Core: fdaa2916b1c893f39f02cff0476d1fb0cab1e352 + React-CoreModules: fd8705b80699ec36c2cdd635c2ce9d874b9cfdfc + React-cxxreact: 1832d971f7b0cb2c7b943dc0ec962762c90c906e + React-jsi: 72af715135abe8c3f0dcf3b2548b71d048b69a7e + React-jsiexecutor: b7b553412f2ec768fe6c8f27cd6bafdb9d8719e6 + React-jsinspector: c5989c77cb89ae6a69561095a61cce56a44ae8e8 + React-logger: a0833912d93b36b791b7a521672d8ee89107aff1 + react-native-webrtc: a9d4d8ef61adb634e006ffd956c494ad8318d95c + React-perflogger: a18b4f0bd933b8b24ecf9f3c54f9bf65180f3fe6 + React-RCTActionSheet: 547fe42fdb4b6089598d79f8e1d855d7c23e2162 + React-RCTAnimation: bc9440a1c37b06ae9ebbb532d244f607805c6034 + React-RCTBlob: a1295c8e183756d7ef30ba6e8f8144dfe8a19215 + React-RCTImage: a30d1ee09b1334067fbb6f30789aae2d7ac150c9 + React-RCTLinking: ffc6d5b88d1cb9aca13c54c2ec6507fbf07f2ac4 + React-RCTNetwork: f807a2facab6cf5cf36d592e634611de9cf12d81 + React-RCTSettings: 861806819226ed8332e6a8f90df2951a34bb3e7f + React-RCTText: f3fb464cc41a50fc7a1aba4deeb76a9ad8282cb9 + React-RCTVibration: 79040b92bfa9c3c2d2cb4f57e981164ec7ab9374 + React-runtimeexecutor: b960b687d2dfef0d3761fbb187e01812ebab8b23 + ReactCommon: 095366164a276d91ea704ce53cb03825c487a3f2 + ReactNativeIncallManager: 2385505fa5dfdbbc78925e3b8d23b30ce0cde40e + RNVectorIcons: bc7ee28cadf39c77a49232a14738dfce690f66cd + SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 + Yoga: 99652481fcd320aefa4a7ef90095b95acd181952 + YogaKit: f782866e155069a2cca2517aafea43200b01fd5a + +PODFILE CHECKSUM: 68f4a73cf9956345faf1485d93ea9edae0b6253f + +COCOAPODS: 1.15.2 diff --git a/example/ios/ReactNativeAntMediaExample.xcodeproj/project.pbxproj b/example/ios/ReactNativeAntMediaExample.xcodeproj/project.pbxproj index 5e450b6..e340dc5 100644 --- a/example/ios/ReactNativeAntMediaExample.xcodeproj/project.pbxproj +++ b/example/ios/ReactNativeAntMediaExample.xcodeproj/project.pbxproj @@ -200,7 +200,8 @@ 83CBB9F71A601CBA00E9B192 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1210; + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1530; TargetAttributes = { 00E356ED1AD99517003FC87E = { CreatedOnToolsVersion = 6.2; @@ -430,13 +431,14 @@ isa = XCBuildConfiguration; baseConfigurationReference = 5B7EB9410499542E8C5724F5 /* Pods-ReactNativeAntMediaExample-ReactNativeAntMediaExampleTests.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); INFOPLIST_FILE = ReactNativeAntMediaExampleTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -457,10 +459,11 @@ isa = XCBuildConfiguration; baseConfigurationReference = 89C6BE57DB24E9ADA2F236DE /* Pods-ReactNativeAntMediaExample-ReactNativeAntMediaExampleTests.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; COPY_PHASE_STRIP = NO; INFOPLIST_FILE = ReactNativeAntMediaExampleTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -484,8 +487,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = MJU7KX4L7S; ENABLE_BITCODE = NO; INFOPLIST_FILE = ReactNativeAntMediaExample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -510,7 +515,9 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = MJU7KX4L7S; INFOPLIST_FILE = ReactNativeAntMediaExample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -560,6 +567,7 @@ COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; @@ -576,7 +584,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", @@ -631,6 +639,7 @@ COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; @@ -640,7 +649,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", diff --git a/example/ios/ReactNativeAntMediaExample.xcodeproj/xcshareddata/xcschemes/ReactNativeAntMediaExample.xcscheme b/example/ios/ReactNativeAntMediaExample.xcodeproj/xcshareddata/xcschemes/ReactNativeAntMediaExample.xcscheme index a94ea6a..3acbf9f 100644 --- a/example/ios/ReactNativeAntMediaExample.xcodeproj/xcshareddata/xcschemes/ReactNativeAntMediaExample.xcscheme +++ b/example/ios/ReactNativeAntMediaExample.xcodeproj/xcshareddata/xcschemes/ReactNativeAntMediaExample.xcscheme @@ -1,6 +1,6 @@ + + + + + + diff --git a/example/package.json b/example/package.json index cb07910..3c62dee 100644 --- a/example/package.json +++ b/example/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "@react-native-community/cli": "^7.0.4", + "@react-native-community/cli-platform-ios": "^13.6.6", "babel-runtime": "^6.26.0", "react": "17.0.2", "react-native": "0.68.2", diff --git a/example/src/Play.tsx b/example/src/Play.tsx index b75709f..fcd1d5a 100644 --- a/example/src/Play.tsx +++ b/example/src/Play.tsx @@ -5,7 +5,7 @@ import { View, SafeAreaView, TouchableOpacity, - Text, + Text, ActivityIndicator, } from 'react-native'; import {useAntMedia, rtc_view} from '@antmedia/react-native-ant-media'; @@ -17,6 +17,7 @@ export default function App() { const streamNameRef = useRef(defaultStreamName); const [remoteMedia, setRemoteStream] = useState(''); const [isPlaying, setIsPlaying] = useState(false); + const [isReconnecting, setIsReconnecting] = useState(false); const adaptor = useAntMedia({ url: webSocketUrl, @@ -36,17 +37,18 @@ export default function App() { case 'play_started': console.log('play_started'); setIsPlaying(true); + setIsReconnecting(false); break; case 'play_finished': console.log('play_finished'); - - setIsPlaying(false); - setRemoteStream(''); - break; - case "newStreamAvailable": + break; + case "newStreamAvailable": if(data.streamId == streamNameRef.current) setRemoteStream(data.stream.toURL()); - break; + break; + case "reconnection_attempt_for_player": + setIsReconnecting(true); + break; default: console.log(command); break; @@ -80,6 +82,8 @@ export default function App() { return; } adaptor.stop(streamNameRef.current); + setIsPlaying(false); + setRemoteStream(''); }, [adaptor]); return ( @@ -94,11 +98,18 @@ export default function App() { ) : ( <> - {remoteMedia ? ( + {(remoteMedia && isReconnecting) ? ( + <>{ + + + Reconnecting.. + + } + ) : (remoteMedia ? ( <>{rtc_view(remoteMedia, styles.streamPlayer)} ) : ( <> - )} + ))} Stop Playing diff --git a/src/index.tsx b/src/index.tsx index 8fefb2d..a319dc7 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -30,11 +30,15 @@ export interface RemoteStreams { } export interface Adaptor { - publish: (streamId: string, token?: string, subscriberId?:string , subscriberCode?: string, streamName?: string, mainTrack?:string, metaData?:string) => void; - play: (streamId: string, token?: string, room?: string , enableTracks?: MediaStream[],subscriberId?:string , subscriberCode?: string, metaData?:string) => void; + publish: (streamId: string, token?: string, subscriberId?: string, subscriberCode?: string, streamName?: string, mainTrack?: string, metaData?: string) => void; + play: (streamId: string, token?: string, room?: string, enableTracks?: MediaStream[], subscriberId?: string, subscriberCode?: string, metaData?: string) => void; stop: (streamId: string) => void; + stopLocalStream: () => void; + initialiseWebSocket: () => void; + closeWebSocket: () => void; join: (streamId: string) => void; leave: (streamId: string) => void; + requestVideoTrackAssignments: (streamId: string) => void; getRoomInfo: (room: string, streamId?: string) => void; initPeerConnection: ( streamId: string, @@ -46,9 +50,9 @@ export interface Adaptor { muteLocalMic: () => void; unmuteLocalMic: () => void; setLocalMicVolume: (volume: number) => void; - setRemoteAudioVolume: (volume: number, streamId: string, roomName: string|undefined) => void; - muteRemoteAudio: (streamId: string, roomName: string|undefined) => void; - unmuteRemoteAudio: (streamId: string, roomName: string|undefined) => void; + setRemoteAudioVolume: (volume: number, streamId: string, roomName: string | undefined) => void; + muteRemoteAudio: (streamId: string, roomName: string | undefined) => void; + unmuteRemoteAudio: (streamId: string, roomName: string | undefined) => void; turnOffLocalCamera: () => void; turnOnLocalCamera: () => void; turnOffRemoteCamera: () => void; @@ -91,6 +95,10 @@ export function useAntMedia(params: Params) { const adaptorRef: any = useRef(null); + const wsRef: any = useRef(new WebSocket(url)); + + var ws = wsRef.current; + let localStream: any = useRef(null); const remotePeerConnection = useRef({}).current; @@ -107,6 +115,26 @@ export function useAntMedia(params: Params) { var pingTimer: any = -1; + var lastReconnectiontionTrialTime = 0; + + var publishStreamId = ""; + + var publishToken = ""; + var publishSubscriberId = ""; + var publishSubscriberCode = ""; + var publishStreamName = ""; + var publishMainTrack = ""; + var publishMetaData = ""; + + var playToken = ""; + var playRoomId = ""; + var playEnableTracks: MediaStreamTrack[] = []; + var playSubscriberId = ""; + var playSubscriberCode = ""; + var playMetaData = ""; + + var iceRestart = false; + var idMapping = new Array(); const closePeerConnection = useCallback( @@ -126,17 +154,19 @@ export function useAntMedia(params: Params) { if (peerConnection.signalingState !== 'closed') { peerConnection.close(); } - const playStreamIndex = playStreamIds.indexOf(streamId); + } - if (playStreamIndex !== -1) { - playStreamIds.splice(playStreamIndex, 1); - } + const playStreamIndex = playStreamIds.indexOf(streamId); + + if (playStreamIndex !== -1) { + playStreamIds.splice(playStreamIndex, 1); } if (remotePeerConnectionStats[streamId] != null) { clearInterval(remotePeerConnectionStats[streamId].timerId); delete remotePeerConnectionStats[streamId]; } + clearPingTimer(); }, [playStreamIds, remotePeerConnection, remotePeerConnectionStats] ); @@ -160,20 +190,99 @@ export function useAntMedia(params: Params) { const onTrack = useCallback( (event: any, streamId: any) => { - const dataObj = { - stream: event.streams[0], - track: event.track, - streamId: streamId, - trackId: idMapping[streamId] != undefined? idMapping[streamId][event.transceiver.mid]:undefined, - } - if (adaptorRef.current) { - callback.call(adaptorRef.current, 'newStreamAvailable', dataObj); - callback.call(adaptorRef.current, 'newTrackAvailable', dataObj); - } + const dataObj = { + stream: event.streams[0], + track: event.track, + streamId: streamId, + trackId: idMapping[streamId] != undefined ? idMapping[streamId][event.transceiver.mid] : undefined, + } + if (adaptorRef.current) { + callback.call(adaptorRef.current, 'newStreamAvailable', dataObj); + callback.call(adaptorRef.current, 'newTrackAvailable', dataObj); + } }, [callback] ); + const iceConnectionState = useCallback((streamId) => { + try { + if (remotePeerConnection[streamId] != null) { + return remotePeerConnection[streamId].iceConnectionState; + } + return null; + } catch (e) { + return null; + } + }, [remotePeerConnection]); + + const reconnectIfRequired = useCallback((delayMs: number = 3000) => { + //It's important to run the following methods after 3000 ms because the stream may be stopped by the user in the meantime + if (delayMs > 0) { + setTimeout(() => { + tryAgain(); + }, delayMs); + } + else { + tryAgain() + } + }, []); + + const tryAgain = useCallback(() => { + + const now = Date.now(); + //to prevent too many trial from different paths + if (now - lastReconnectiontionTrialTime < 3000) { + return; + } + lastReconnectiontionTrialTime = now; + + //reconnect publish + //if remotePeerConnection has a peer connection for the stream id, it means that it is not stopped on purpose + + if (remotePeerConnection[publishStreamId] != null && + //check connection status to not stop streaming an active stream + iceConnectionState(publishStreamId) != "checking" && + iceConnectionState(publishStreamId) != "connected" && + iceConnectionState(publishStreamId) != "completed") { + // notify that reconnection process started for publish + if (adaptorRef.current) { + callback.call(adaptorRef.current, 'reconnection_attempt_for_publisher', publishStreamId); + } + + stop(publishStreamId); + setTimeout(() => { + //publish about some time later because server may not drop the connection yet + //it may trigger already publishing error + console.log("Trying publish again for stream: " + publishStreamId); + publish(publishStreamId, publishToken, publishSubscriberId, publishSubscriberCode, publishStreamName, publishMainTrack, publishMetaData); + }, 500); + } + + //reconnect play + for (var index in playStreamIds) { + let streamId = playStreamIds[index]; + if (remotePeerConnection[streamId] != null && + //check connection status to not stop streaming an active stream + iceConnectionState(streamId) != "checking" && + iceConnectionState(streamId) != "connected" && + iceConnectionState(streamId) != "completed") { + // notify that reconnection process started for play + if (adaptorRef.current) { + callback.call(adaptorRef.current, 'reconnection_attempt_for_player', publishStreamId); + } + + console.log("It will try to play again for stream: " + streamId + " because it is not stopped on purpose") + stop(streamId); + setTimeout(() => { + //play about some time later because server may not drop the connection yet + //it may trigger already playing error + console.log("Trying play again for stream: " + streamId); + play(streamId, playToken, playRoomId, playEnableTracks, playSubscriberId, playSubscriberCode, playMetaData); + }, 500); + } + } + }, [callback]); + const initDataChannel = useCallback((streamId: string, dataChannel: any) => { dataChannel.onerror = (error: any) => { console.log('Data Channel Error:', error); @@ -225,7 +334,7 @@ export function useAntMedia(params: Params) { // @ts-ignore localStream.current.getTracks().forEach((track) => { remotePeerConnection[streamId].addTrack(track, localStream.current); -// localStream.current.getTracks().forEach((track: MediaStreamTrack) => { remotePeerConnection[streamId].addTrack(track, localStream.current); }); + // localStream.current.getTracks().forEach((track: MediaStreamTrack) => { remotePeerConnection[streamId].addTrack(track, localStream.current); }); }); } @@ -247,6 +356,34 @@ export function useAntMedia(params: Params) { initDataChannel(streamId, event.channel); }; + // @ts-ignore + remotePeerConnection[streamId].onnegotiationneeded = async (event: any) => { + if (debug) console.log('onnegotiationneeded'); + await remotePeerConnection[streamId].setLocalDescription(await remotePeerConnection[streamId].createOffer({ iceRestart: iceRestart })); + ws.send({ desc: remotePeerConnection[streamId].localDescription }); + } + + // @ts-ignore + remotePeerConnection[streamId].oniceconnectionstatechange = (event: RTCPeerConnectionIceEvent) => { + if (debug) console.log('oniceconnectionstatechange', event); + + if (!remotePeerConnection[streamId]) { + return + } + + if (typeof remotePeerConnection[streamId].iceConnectionState === 'undefined') { + reconnectIfRequired(3000); + return + } + + console.warn("ICE connection state changed to " + remotePeerConnection[streamId].iceConnectionState) + var obj = { state: remotePeerConnection[streamId].iceConnectionState, streamId: streamId }; + if (obj.state == "connected") { iceRestart = false; } + if (obj.state == "failed") { iceRestart = true; remotePeerConnection[streamId].restartIce(); } + if (obj.state == "disconnected" || obj.state == "closed") reconnectIfRequired(3000); + if (callback && adaptorRef.current) callback.call(adaptorRef.current, 'ice_connection_state_changed', obj); + }; + if (dataChannelMode === 'publish') { const dataChannelOptions = { ordered: true, @@ -333,13 +470,13 @@ export function useAntMedia(params: Params) { if (debug) console.debug(`addIceCandidate ${streamId}`); if (debug) console.debug('candidate', candidate); await remotePeerConnection[streamId].addIceCandidate(candidate); - } catch (err) {} + } catch (err) { } }, [debug, remotePeerConnection] ); const takeConfiguration = useCallback( - async (streamId: any, configuration: string, typeOfConfiguration: string , idMap?:string) => { + async (streamId: any, configuration: string, typeOfConfiguration: string, idMap?: string) => { const type = typeOfConfiguration; var conf = configuration; conf = conf.replace("a=extmap:13 urn:3gpp:video-orientation\r\n", ""); @@ -444,13 +581,14 @@ export function useAntMedia(params: Params) { ] ); - var ws: any = useRef(new WebSocket(url)).current; - - ws.sendJson = (dt: any) => { - ws.send(JSON.stringify(dt)); - }; + const setWebSocketListeners = useCallback(() => { + if (!ws) return; + ws.sendJson = (dt: any) => { + if (ws && ws.send && ws.readyState === ws.OPEN) { + ws.send(JSON.stringify(dt)); + } + }; - useEffect(() => { ws.onopen = () => { if (debug) console.log('web socket opened !'); callback.call(adaptorRef.current, 'initiated'); @@ -465,11 +603,12 @@ export function useAntMedia(params: Params) { if (debug) console.log('got stream'); localStream.current = stream; + if (adaptorRef.current) callback.call(adaptorRef.current, 'local_stream_updated', stream); if (debug) console.log('in stream', localStream.current); }) .catch((error: any) => { // Log error - if (debug) console.log('got error', error , mediaConstraints); + if (debug) console.log('got error', error, mediaConstraints); }); } else { if (debug) console.log('only data channel'); @@ -492,7 +631,7 @@ export function useAntMedia(params: Params) { takeCandidate(data.streamId, data.label, data.candidate, data.id); break; case 'takeConfiguration': - takeConfiguration(data.streamId, data.sdp, data.type,data.idMapping); + takeConfiguration(data.streamId, data.sdp, data.type, data.idMapping); break; case 'stop': if (debug) console.log(' in stop', data); @@ -539,7 +678,6 @@ export function useAntMedia(params: Params) { break; } }; - ws.onerror = (e: any) => { // an error occurred clearPingTimer(); @@ -550,7 +688,13 @@ export function useAntMedia(params: Params) { // connection closed clearPingTimer(); if (debug) console.log(e.code, e.reason); + if (callback && adaptorRef.current) callback.call(adaptorRef.current, 'websocket_closed', ''); + ws = null; }; + }, [callback, callbackError, closePeerConnection, debug, mediaConstraints, startPublishing, takeCandidate, takeConfiguration, ws]); + + useEffect(() => { + setWebSocketListeners(); }, [ callback, callbackError, @@ -571,9 +715,27 @@ export function useAntMedia(params: Params) { subscriberId?: string, subscriberCode?: string, streamName?: string, - mainTrack?:string, - metaData?:string + mainTrack?: string, + metaData?: string ) => { + publishStreamId = streamId; + publishToken = token ? token : ''; + publishSubscriberId = subscriberId ? subscriberId : ''; + publishSubscriberCode = subscriberCode ? subscriberCode : ''; + publishStreamName = streamName ? streamName : ''; + publishMainTrack = mainTrack ? mainTrack : ''; + publishMetaData = metaData ? metaData : ''; + + if (ws && ws.readyState === ws.CLOSED) { + if (debug) console.log('WebSocket is not connected'); + if (adaptorRef.current) callback.call(adaptorRef.current, 'websocket_not_initialized', ''); + } + + if (localStream.current === null) { + if (debug) console.log('Local stream is not ready'); + return; + } + let data = {} as any; if (onlyDataChannel) { data = { @@ -586,8 +748,6 @@ export function useAntMedia(params: Params) { audio: false, }; } else { - if (!localStream.current) return; - let [video, audio] = [false, false]; // @ts-ignore @@ -616,7 +776,21 @@ export function useAntMedia(params: Params) { //play const play = useCallback( - (streamId: string, token?: string, room?: string , enableTracks?:MediaStreamTrack[],subscriberId?:string, subscriberCode?:string ,metaData?:string ) => { + (streamId: string, token?: string, room?: string, enableTracks?: MediaStreamTrack[], subscriberId?: string, subscriberCode?: string, metaData?: string) => { + if (playStreamIds.includes(streamId)) return; + + playToken = token ? token : ''; + playRoomId = room ? room : ''; + playEnableTracks = enableTracks ? enableTracks : []; + playSubscriberId = subscriberId ? subscriberId : ""; + playSubscriberCode = subscriberCode ? subscriberCode : ""; + playMetaData = metaData ? metaData : ""; + + if (ws && ws.readyState === ws.CLOSED) { + if (debug) console.log('WebSocket is not connected'); + if (adaptorRef.current) callback.call(adaptorRef.current, 'websocket_not_initialized', ''); + } + playStreamIds.push(streamId); const data = { command: 'play', @@ -638,6 +812,38 @@ export function useAntMedia(params: Params) { [playStreamIds, ws] ); + const stopLocalStream = useCallback( + () => { + if (localStream.current) { + // @ts-ignore + localStream.current.getTracks().forEach((track) => { + track.stop(); + }); + localStream.current = null; + } + }, + [localStream] + ); + + const initialiseWebSocket = useCallback(() => { + console.log('initialising websocket') + if (ws && ws.readyState === ws.OPEN) { + if (debug) console.log('WebSocket is already connected'); + return; + } + + wsRef.current = new WebSocket(url); + ws = wsRef.current; + setWebSocketListeners(); + console.log('WebSocket is connected'); + }, [ws]); + + const closeWebSocket = useCallback(() => { + if (ws) { + ws.close(); + } + }, [ws]); + const stop = useCallback( (streamId: any) => { closePeerConnection(streamId); @@ -669,6 +875,18 @@ export function useAntMedia(params: Params) { streamId, }; if (ws) ws.sendJson(data); + closePeerConnection(streamId); + }, + [ws] + ); + + const requestVideoTrackAssignments = useCallback( + (streamId: string) => { + const data = { + command: 'getVideoTrackAssignmentsCommand', + streamId, + }; + if (ws) ws.sendJson(data); }, [ws] ); @@ -700,7 +918,7 @@ export function useAntMedia(params: Params) { } }, [localStream]); - const setRemoteAudioVolume = useCallback((volume: number, streamId: string, roomName: string|undefined) => { + const setRemoteAudioVolume = useCallback((volume: number, streamId: string, roomName: string | undefined) => { console.log("Setting remote mic") // @ts-ignore if (typeof roomName != 'undefined' && remotePeerConnection[roomName]) { @@ -711,7 +929,7 @@ export function useAntMedia(params: Params) { track._setVolume(volume); } }); - } else if(remotePeerConnection[streamId]) { + } else if (remotePeerConnection[streamId]) { remotePeerConnection[streamId]._remoteStreams.forEach((stream) => { let audioTrackID = "ARDAMSa" + streamId; let track = stream.getTrackById(audioTrackID); @@ -722,7 +940,7 @@ export function useAntMedia(params: Params) { } }, [remotePeerConnection]); - const muteRemoteAudio = useCallback((streamId: string, roomName: string|undefined) => { + const muteRemoteAudio = useCallback((streamId: string, roomName: string | undefined) => { console.log("Muting remote mic") // @ts-ignore if (typeof roomName != 'undefined' && remotePeerConnection[roomName]) { @@ -733,7 +951,7 @@ export function useAntMedia(params: Params) { track.enabled = false; } }); - } else if(remotePeerConnection[streamId]) { + } else if (remotePeerConnection[streamId]) { remotePeerConnection[streamId]._remoteStreams.forEach((stream) => { let audioTrackID = "ARDAMSa" + streamId; let track = stream.getTrackById(audioTrackID); @@ -744,7 +962,7 @@ export function useAntMedia(params: Params) { } }, [remotePeerConnection]); - const unmuteRemoteAudio = useCallback((streamId: string, roomName: string|undefined) => { + const unmuteRemoteAudio = useCallback((streamId: string, roomName: string | undefined) => { console.log("Muting remote mic") // @ts-ignore if (typeof roomName != 'undefined' && remotePeerConnection[roomName]) { @@ -755,7 +973,7 @@ export function useAntMedia(params: Params) { track.enabled = true; } }); - } else if(remotePeerConnection[streamId]) { + } else if (remotePeerConnection[streamId]) { remotePeerConnection[streamId]._remoteStreams.forEach((stream) => { let audioTrackID = "ARDAMSa" + streamId; let track = stream.getTrackById(audioTrackID); @@ -778,23 +996,23 @@ export function useAntMedia(params: Params) { [ws] ); const setPingTimer = useCallback(() => { - pingTimer = setInterval(()=>{ - if(ws != null) - ws.sendJson({ - command: 'ping', - }); - },3000); - },[]); + pingTimer = setInterval(() => { + if (ws != null) + ws.sendJson({ + command: 'ping', + }); + }, 3000); + }, []); const clearPingTimer = useCallback(() => { if (pingTimer != -1) { if (debug) { - console.log("Clearing ping message timer"); + console.log("Clearing ping message timer"); } clearInterval(pingTimer); pingTimer = -1; } - },[]); + }, []); //Data Channel const peerMessage = useCallback( @@ -810,15 +1028,15 @@ export function useAntMedia(params: Params) { [ws] ); - const getDevices = useCallback( async () => { + const getDevices = useCallback(async () => { var deviceArray = new Array(); try { const devices = await mediaDevices.enumerateDevices(); // @ts-ignore - devices.map( device => { + devices.map(device => { deviceArray.push(device); - } ); + }); callback.call(adaptorRef.current, 'available_devices', deviceArray); } catch (err: any) { @@ -862,7 +1080,7 @@ export function useAntMedia(params: Params) { } }, []); - const turnOffRemoteCamera = useCallback((streamId: string, roomName: string|undefined) => { + const turnOffRemoteCamera = useCallback((streamId: string, roomName: string | undefined) => { console.log("Turning off remote camera") // @ts-ignore if (typeof roomName != 'undefined' && remotePeerConnection[roomName]) { @@ -873,7 +1091,7 @@ export function useAntMedia(params: Params) { track.enabled = false; } }); - } else if(remotePeerConnection[streamId]) { + } else if (remotePeerConnection[streamId]) { remotePeerConnection[streamId]._remoteStreams.forEach((stream) => { let videoTrackID = "ARDAMSv" + streamId; let track = stream.getTrackById(videoTrackID); @@ -884,7 +1102,7 @@ export function useAntMedia(params: Params) { } }, [remotePeerConnection]); - const turnOnRemoteCamera = useCallback((streamId: string, roomName: string|undefined) => { + const turnOnRemoteCamera = useCallback((streamId: string, roomName: string | undefined) => { console.log("Turning on remote camera") // @ts-ignore if (typeof roomName != 'undefined' && remotePeerConnection[roomName]) { @@ -895,7 +1113,7 @@ export function useAntMedia(params: Params) { track.enabled = true; } }); - } else if(remotePeerConnection[streamId]) { + } else if (remotePeerConnection[streamId]) { remotePeerConnection[streamId]._remoteStreams.forEach((stream) => { let videoTrackID = "ARDAMSv" + streamId; let track = stream.getTrackById(videoTrackID); @@ -921,8 +1139,12 @@ export function useAntMedia(params: Params) { publish, play, stop, + stopLocalStream, + initialiseWebSocket, + closeWebSocket, join, leave, + requestVideoTrackAssignments, getRoomInfo, initPeerConnection, localStream, @@ -945,9 +1167,13 @@ export function useAntMedia(params: Params) { publish, play, stop, + stopLocalStream, + initialiseWebSocket, + closeWebSocket, localStream, join, leave, + requestVideoTrackAssignments, getRoomInfo, initPeerConnection, peerMessage, @@ -970,9 +1196,13 @@ export function useAntMedia(params: Params) { publish, play, stop, + stopLocalStream, + initialiseWebSocket, + closeWebSocket, localStream, join, leave, + requestVideoTrackAssignments, getRoomInfo, initPeerConnection, peerMessage, @@ -997,7 +1227,7 @@ export function rtc_view( customStyles: any = { width: '70%', height: '50%', alignSelf: 'center' }, objectFit: any = 'cover' ) { - if(stream instanceof MediaStreamTrack ){ + if (stream instanceof MediaStreamTrack) { let mediaStream = new MediaStream(undefined); mediaStream.addTrack(stream); stream = mediaStream.toURL();