shakebug-react-native 1.0.14
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/DeviceInfo/index.js.flow +177 -0
- package/DeviceInfo/index.ts +1034 -0
- package/DeviceInfo/internal/asyncHookWrappers.ts +59 -0
- package/DeviceInfo/internal/devicesWithDynamicIsland.ts +30 -0
- package/DeviceInfo/internal/devicesWithNotch.ts +374 -0
- package/DeviceInfo/internal/nativeInterface.ts +28 -0
- package/DeviceInfo/internal/privateTypes.ts +231 -0
- package/DeviceInfo/internal/supported-platform-info.ts +97 -0
- package/DeviceInfo/internal/types.ts +19 -0
- package/DeviceInfo/web/index.js +223 -0
- package/GetLocals/src/NativeRNLocalize.ts +18 -0
- package/GetLocals/src/constants.ts +269 -0
- package/GetLocals/src/index.ts +56 -0
- package/GetLocals/src/module.ts +51 -0
- package/GetLocals/src/module.web.ts +148 -0
- package/GetLocals/src/types.ts +31 -0
- package/GetLocation/LocationError.ts +20 -0
- package/GetLocation/index.ts +46 -0
- package/GetLocation/utils.ts +89 -0
- package/ImageOrVedioPicker/src/index.ts +28 -0
- package/ImageOrVedioPicker/src/platforms/NativeImagePicker.ts +10 -0
- package/ImageOrVedioPicker/src/platforms/native.ts +61 -0
- package/ImageOrVedioPicker/src/platforms/web.ts +159 -0
- package/ImageOrVedioPicker/src/types.ts +74 -0
- package/NetInfo/src/__tests__/eventListenerCallbacks.spec.ts +332 -0
- package/NetInfo/src/__tests__/fetch.spec.ts +479 -0
- package/NetInfo/src/index.ts +186 -0
- package/NetInfo/src/internal/__mocks__/nativeModule.ts +13 -0
- package/NetInfo/src/internal/defaultConfiguration.ts +17 -0
- package/NetInfo/src/internal/defaultConfiguration.web.ts +17 -0
- package/NetInfo/src/internal/internetReachability.ts +180 -0
- package/NetInfo/src/internal/nativeInterface.ts +43 -0
- package/NetInfo/src/internal/nativeInterface.web.ts +27 -0
- package/NetInfo/src/internal/nativeModule.ts +15 -0
- package/NetInfo/src/internal/nativeModule.web.ts +306 -0
- package/NetInfo/src/internal/privateTypes.ts +41 -0
- package/NetInfo/src/internal/state.ts +137 -0
- package/NetInfo/src/internal/types.ts +128 -0
- package/README.md +246 -0
- package/RecordScreen/src/index.tsx +75 -0
- package/ScreenShot/src/RNViewShot.js +3 -0
- package/ScreenShot/src/RNViewShot.web.js +42 -0
- package/ScreenShot/src/index.js +308 -0
- package/Sensor/src/index.js +14 -0
- package/Sensor/src/rnsensors.js +57 -0
- package/Sensor/src/sensors.js +97 -0
- package/VideoPlayer/PlayVideo.tsx +51 -0
- package/VideoPlayer/index.js +69 -0
- package/android/README.md +14 -0
- package/android/build/generated/source/buildConfig/debug/com/shakebug/BuildConfig.java +10 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +42 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +18 -0
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +6 -0
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +47 -0
- package/android/build/intermediates/compiled_local_resources/debug/out/xml_imagepicker_provider_paths.xml.flat +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +12 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/CustomMediaMetadataRetriever.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ImageMetadata.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ImagePickerProvider.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Metadata.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Options.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/RecordScreenModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/RecordScreenModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Shakebug.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ShakebugPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Utility.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Utils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/VideoMetadata.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$Formats.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$Results.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$ReusableByteArrayOutputStream.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +49 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +82 -0
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +42 -0
- package/android/build/intermediates/navigation_json/debug/navigation.json +1 -0
- package/android/build/intermediates/packaged_res/debug/values/values.xml +25 -0
- package/android/build/intermediates/packaged_res/debug/xml/imagepicker_provider_paths.xml +4 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/BuildConfig.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/CustomMediaMetadataRetriever.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ImageMetadata.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ImagePickerProvider.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Metadata.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Options.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/RecordScreenModule$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/RecordScreenModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Shakebug.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ShakebugPackage.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Utility.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Utils.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/VideoMetadata.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$Formats.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$Results.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$ReusableByteArrayOutputStream.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot.class +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +48 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +97 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +235 -0
- package/android/src/main/AndroidManifest.xml +40 -0
- package/android/src/main/java/com/shakebug/AmazonFireDeviceConnectivityPoller.java +170 -0
- package/android/src/main/java/com/shakebug/BaseUtils.java +33 -0
- package/android/src/main/java/com/shakebug/BroadcastReceiverConnectivityReceiver.java +131 -0
- package/android/src/main/java/com/shakebug/ConnectivityReceiver.java +318 -0
- package/android/src/main/java/com/shakebug/CrashLoggerModule.java +48 -0
- package/android/src/main/java/com/shakebug/DateUtil.java +64 -0
- package/android/src/main/java/com/shakebug/DeviceType.java +18 -0
- package/android/src/main/java/com/shakebug/DeviceUtil.java +46 -0
- package/android/src/main/java/com/shakebug/DrawingView.java +90 -0
- package/android/src/main/java/com/shakebug/DrawingViewManager.java +38 -0
- package/android/src/main/java/com/shakebug/GetLocation.java +147 -0
- package/android/src/main/java/com/shakebug/ImageMetadata.java +42 -0
- package/android/src/main/java/com/shakebug/ImagePickerProvider.java +8 -0
- package/android/src/main/java/com/shakebug/Metadata.java +46 -0
- package/android/src/main/java/com/shakebug/NetInfoModule.java +79 -0
- package/android/src/main/java/com/shakebug/NetInfoUtils.java +50 -0
- package/android/src/main/java/com/shakebug/NetworkCallbackConnectivityReceiver.java +209 -0
- package/android/src/main/java/com/shakebug/Options.java +42 -0
- package/android/src/main/java/com/shakebug/RNDeviceModule.java +1036 -0
- package/android/src/main/java/com/shakebug/RNInstallReferrerClient.java +124 -0
- package/android/src/main/java/com/shakebug/RNLocalizeModule.java +79 -0
- package/android/src/main/java/com/shakebug/RNLocalizeModuleImpl.java +258 -0
- package/android/src/main/java/com/shakebug/ReactNativeGetLocationModule.java +95 -0
- package/android/src/main/java/com/shakebug/RecordScreenModule.java +202 -0
- package/android/src/main/java/com/shakebug/ScreenshotDetectorModule.java +63 -0
- package/android/src/main/java/com/shakebug/SettingsUtil.java +44 -0
- package/android/src/main/java/com/shakebug/Shakebug.java +181 -0
- package/android/src/main/java/com/shakebug/ShakebugPackage.java +75 -0
- package/android/src/main/java/com/shakebug/ShakebugSDKImagePickerModule.java +56 -0
- package/android/src/main/java/com/shakebug/ShakebugSDKImagePickerModuleImpl.java +230 -0
- package/android/src/main/java/com/shakebug/ShakebugSDKScreenShotModule.java +196 -0
- package/android/src/main/java/com/shakebug/SharedPreferencesModule.java +39 -0
- package/android/src/main/java/com/shakebug/UnitConverter.java +48 -0
- package/android/src/main/java/com/shakebug/Utility.java +29 -0
- package/android/src/main/java/com/shakebug/Utils.java +593 -0
- package/android/src/main/java/com/shakebug/VideoMetadata.java +91 -0
- package/android/src/main/java/com/shakebug/VideoPlayerModule.java +199 -0
- package/android/src/main/java/com/shakebug/VideoThumbnailModule.java +215 -0
- package/android/src/main/java/com/shakebug/VideoTrimModule.java +372 -0
- package/android/src/main/java/com/shakebug/ViewShot.java +627 -0
- package/android/src/main/java/com/shakebug/adapters/VideoTrimmerAdapter.java +54 -0
- package/android/src/main/java/com/shakebug/callback/SingleCallback.java +11 -0
- package/android/src/main/java/com/shakebug/interfaces/IVideoTrimmerView.java +5 -0
- package/android/src/main/java/com/shakebug/interfaces/VideoPlayerListner.java +5 -0
- package/android/src/main/java/com/shakebug/interfaces/VideoTrimListener.java +10 -0
- package/android/src/main/java/com/shakebug/resolver/DeviceIdResolver.java +87 -0
- package/android/src/main/java/com/shakebug/resolver/DeviceTypeResolver.java +94 -0
- package/android/src/main/java/com/shakebug/thread/BackgroundExecutor.java +246 -0
- package/android/src/main/java/com/shakebug/thread/UiThreadExecutor.java +120 -0
- package/android/src/main/java/com/shakebug/types/CellularGeneration.java +60 -0
- package/android/src/main/java/com/shakebug/types/ConnectionType.java +26 -0
- package/android/src/main/java/com/shakebug/utils/StorageUtil.java +139 -0
- package/android/src/main/java/com/shakebug/utils/VideoTrimmerUtil.java +89 -0
- package/android/src/main/java/com/shakebug/widgets/RangeSeekBarView.java +534 -0
- package/android/src/main/java/com/shakebug/widgets/SpacesItemDecoration2.java +32 -0
- package/android/src/main/java/com/shakebug/widgets/VideoPlayerView.java +429 -0
- package/android/src/main/java/com/shakebug/widgets/VideoTrimmerView.java +477 -0
- package/android/src/main/java/com/shakebug/widgets/ZVideoView.java +48 -0
- package/android/src/main/res/drawable/custom_progress.xml +16 -0
- package/android/src/main/res/drawable/custom_thumb.xml +4 -0
- package/android/src/main/res/drawable/ic_close_button.xml +10 -0
- package/android/src/main/res/drawable/ic_video_pause_black.png +0 -0
- package/android/src/main/res/drawable/ic_video_play_black.png +0 -0
- package/android/src/main/res/drawable/ic_video_thumb_handle.png +0 -0
- package/android/src/main/res/drawable/icon_seek_bar.png +0 -0
- package/android/src/main/res/layout/video_player_view.xml +121 -0
- package/android/src/main/res/layout/video_thumb_item_layout.xml +16 -0
- package/android/src/main/res/layout/video_trimmer_view.xml +148 -0
- package/android/src/main/res/values/colors.xml +17 -0
- package/android/src/main/res/values/strings.xml +14 -0
- package/android/src/main/res/xml/imagepicker_provider_paths.xml +4 -0
- package/ios/CammeraPermission/RNCameraPermission.h +16 -0
- package/ios/CammeraPermission/RNCameraPermission.m +46 -0
- package/ios/DeviceInfo/DeviceUID.h +14 -0
- package/ios/DeviceInfo/DeviceUID.m +202 -0
- package/ios/DeviceInfo/EnvironmentUtil.h +41 -0
- package/ios/DeviceInfo/EnvironmentUtil.m +56 -0
- package/ios/DeviceInfo/RNDeviceInfo.h +22 -0
- package/ios/DeviceInfo/RNDeviceInfo.m +918 -0
- package/ios/GetLocals/ShakebugSDKRNLocalize.h +21 -0
- package/ios/GetLocals/ShakebugSDKRNLocalize.m +296 -0
- package/ios/GetLocation/SettingsUtil.h +16 -0
- package/ios/GetLocation/SettingsUtil.m +21 -0
- package/ios/GetLocation/ShakebugSDKLocationModule.h +17 -0
- package/ios/GetLocation/ShakebugSDKLocationModule.m +218 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerManager.h +40 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerManager.m +588 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerUtils.h +26 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerUtils.m +194 -0
- package/ios/MicrophonePermissionManager.h +14 -0
- package/ios/MicrophonePermissionManager.m +35 -0
- package/ios/NetInfo/RNCConnectionState.h +42 -0
- package/ios/NetInfo/RNCConnectionState.m +119 -0
- package/ios/NetInfo/RNCConnectionStateWatcher.h +31 -0
- package/ios/NetInfo/RNCConnectionStateWatcher.m +136 -0
- package/ios/NetInfo/RNCNetInfo.h +13 -0
- package/ios/NetInfo/RNCNetInfo.m +269 -0
- package/ios/RecordScreen/ShakebugSDKRecordScreen.h +31 -0
- package/ios/RecordScreen/ShakebugSDKRecordScreen.m +309 -0
- package/ios/ScreenShot/ShakebugSDKRNViewShot.h +6 -0
- package/ios/ScreenShot/ShakebugSDKRNViewShot.m +186 -0
- package/ios/ScreenshotDetector/ScreenShotDetector.h +12 -0
- package/ios/ScreenshotDetector/ScreenShotDetector.m +37 -0
- package/ios/Senors/RNSensorsAccelerometer.h +22 -0
- package/ios/Senors/RNSensorsAccelerometer.m +162 -0
- package/ios/Senors/RNSensorsBarometer.h +22 -0
- package/ios/Senors/RNSensorsBarometer.m +141 -0
- package/ios/Senors/RNSensorsGravity.h +22 -0
- package/ios/Senors/RNSensorsGravity.m +165 -0
- package/ios/Senors/RNSensorsGyroscope.h +22 -0
- package/ios/Senors/RNSensorsGyroscope.m +160 -0
- package/ios/Senors/RNSensorsMagnetometer.h +22 -0
- package/ios/Senors/RNSensorsMagnetometer.m +163 -0
- package/ios/Senors/RNSensorsOrientation.h +22 -0
- package/ios/Senors/RNSensorsOrientation.m +189 -0
- package/ios/Senors/RNSensorsUtils.h +7 -0
- package/ios/Senors/RNSensorsUtils.m +9 -0
- package/ios/Shakebug.h +7 -0
- package/ios/Shakebug.m +16 -0
- package/ios/Shakebug.xcodeproj/project.pbxproj +872 -0
- package/ios/Shakebug.xcodeproj/xcshareddata/xcschemes/Shakebug.xcscheme +66 -0
- package/ios/Shakebug.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/Shakebug.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/SketchCanvas/DrawingView.h +18 -0
- package/ios/SketchCanvas/DrawingView.m +96 -0
- package/ios/SketchCanvas/DrawingViewManager.h +12 -0
- package/ios/SketchCanvas/DrawingViewManager.m +35 -0
- package/ios/Storage/SharedPreferencesModule.h +13 -0
- package/ios/Storage/SharedPreferencesModule.m +35 -0
- package/ios/Thumbnaill/VideoThumbnailManager.h +12 -0
- package/ios/Thumbnaill/VideoThumbnailManager.m +73 -0
- package/ios/TrimVideo/ShakebugSDKVideoTrim.swift +372 -0
- package/ios/TrimVideo/VideoTrim-Bridging-Header.h +10 -0
- package/ios/TrimVideo/VideoTrim.m +23 -0
- package/ios/TrimVideo/VideoTrimmer.swift +810 -0
- package/ios/TrimVideo/VideoTrimmerThumb.swift +119 -0
- package/ios/TrimVideo/VideoTrimmerViewController.swift +301 -0
- package/ios/VideoPlayer/VideoPlayerModule.h +14 -0
- package/ios/VideoPlayer/VideoPlayerModule.m +29 -0
- package/ios/VideoPlayer/VideoPlayerViewController.h +18 -0
- package/ios/VideoPlayer/VideoPlayerViewController.m +29 -0
- package/package.json +45 -0
- package/shakebug-react-native.podspec +50 -0
- package/src/APIs/AddIssue.js +70 -0
- package/src/APIs/EndSession.js +32 -0
- package/src/APIs/Event.js +39 -0
- package/src/APIs/MatchKey.js +40 -0
- package/src/APIs/StartSession.js +84 -0
- package/src/Assets/images/OpenSketch.png +0 -0
- package/src/Assets/images/Push.png +0 -0
- package/src/Assets/images/RemoveTextView.png +0 -0
- package/src/Assets/images/black.png +0 -0
- package/src/Assets/images/blue.png +0 -0
- package/src/Assets/images/borderdBlack.png +0 -0
- package/src/Assets/images/borderdBlue.png +0 -0
- package/src/Assets/images/borderdGreen.png +0 -0
- package/src/Assets/images/borderdRed.png +0 -0
- package/src/Assets/images/borderdYellow.png +0 -0
- package/src/Assets/images/clear.png +0 -0
- package/src/Assets/images/close.png +0 -0
- package/src/Assets/images/green.png +0 -0
- package/src/Assets/images/next.png +0 -0
- package/src/Assets/images/play.png +0 -0
- package/src/Assets/images/red.png +0 -0
- package/src/Assets/images/shake.png +0 -0
- package/src/Assets/images/shakebugLogo.png +0 -0
- package/src/Assets/images/stopButton.png +0 -0
- package/src/Assets/images/text_icon.png +0 -0
- package/src/Assets/images/yellow.png +0 -0
- package/src/Componanats/CustomAlert.js +80 -0
- package/src/Componanats/ErrorHandler.js +80 -0
- package/src/Componanats/GlobalStateContext.js +22 -0
- package/src/Componanats/KeyboardAvoidingWrapper.js +43 -0
- package/src/Componanats/NavigationContext.js +42 -0
- package/src/Componanats/ShakeFunction.js +562 -0
- package/src/Componanats/localization.js +482 -0
- package/src/Screens/AddDetailsScreen.js +462 -0
- package/src/Screens/FirstScreen.js +629 -0
- package/src/Screens/Shakebug.js +487 -0
- package/src/Screens/StrockView.js +20 -0
- package/src/Screens/TrimVideoScreen.js +81 -0
- package/src/Screens/TutorialScreen.js +36 -0
- package/src/index.tsx +117 -0
- package/trimVideo/src/index.tsx +141 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNCNetInfo.m
|
|
3
|
+
// Shakebug
|
|
4
|
+
//
|
|
5
|
+
// Created by ideveloper2 on 06/03/24.
|
|
6
|
+
// Copyright © 2024 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "RNCNetInfo.h"
|
|
10
|
+
#import "RNCConnectionStateWatcher.h"
|
|
11
|
+
|
|
12
|
+
#include <ifaddrs.h>
|
|
13
|
+
#include <arpa/inet.h>
|
|
14
|
+
|
|
15
|
+
#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION
|
|
16
|
+
#import <CoreTelephony/CTCarrier.h>
|
|
17
|
+
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
|
|
18
|
+
#endif
|
|
19
|
+
@import SystemConfiguration.CaptiveNetwork;
|
|
20
|
+
|
|
21
|
+
#import <React/RCTAssert.h>
|
|
22
|
+
#import <React/RCTBridge.h>
|
|
23
|
+
#import <React/RCTEventDispatcher.h>
|
|
24
|
+
|
|
25
|
+
@interface ShakebugSDKRNCNetInfo () <RNCConnectionStateWatcherDelegate>
|
|
26
|
+
|
|
27
|
+
@property (nonatomic, strong) ShakebugSDKRNCConnectionStateWatcher *connectionStateWatcher;
|
|
28
|
+
@property (nonatomic) BOOL isObserving;
|
|
29
|
+
@property (nonatomic) NSDictionary *config;
|
|
30
|
+
|
|
31
|
+
@end
|
|
32
|
+
|
|
33
|
+
@implementation ShakebugSDKRNCNetInfo
|
|
34
|
+
|
|
35
|
+
#pragma mark - Module setup
|
|
36
|
+
|
|
37
|
+
RCT_EXPORT_MODULE()
|
|
38
|
+
|
|
39
|
+
// We need RNCReachabilityCallback's and module methods to be called on the same thread so that we can have
|
|
40
|
+
// guarantees about when we mess with the reachability callbacks.
|
|
41
|
+
- (dispatch_queue_t)methodQueue
|
|
42
|
+
{
|
|
43
|
+
return dispatch_get_main_queue();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
+ (BOOL)requiresMainQueueSetup
|
|
47
|
+
{
|
|
48
|
+
return YES;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#pragma mark - Lifecycle
|
|
52
|
+
|
|
53
|
+
- (NSArray *)supportedEvents
|
|
54
|
+
{
|
|
55
|
+
return @[@"netInfo.networkStatusDidChange"];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void)startObserving
|
|
59
|
+
{
|
|
60
|
+
self.isObserving = YES;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)stopObserving
|
|
64
|
+
{
|
|
65
|
+
self.isObserving = NO;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (instancetype)init
|
|
69
|
+
{
|
|
70
|
+
self = [super init];
|
|
71
|
+
if (self) {
|
|
72
|
+
_connectionStateWatcher = [[ShakebugSDKRNCConnectionStateWatcher alloc] initWithDelegate:self];
|
|
73
|
+
}
|
|
74
|
+
return self;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
- (void)dealloc
|
|
78
|
+
{
|
|
79
|
+
self.connectionStateWatcher = nil;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#pragma mark - RNCConnectionStateWatcherDelegate
|
|
83
|
+
|
|
84
|
+
- (void)connectionStateWatcher:(ShakebugSDKRNCConnectionStateWatcher *)connectionStateWatcher didUpdateState:(ShakebugSDKRNCConnectionState *)state
|
|
85
|
+
{
|
|
86
|
+
if (self.isObserving) {
|
|
87
|
+
NSDictionary *dictionary = [self currentDictionaryFromUpdateState:state withInterface:NULL];
|
|
88
|
+
[self sendEventWithName:@"netInfo.networkStatusDidChange" body:dictionary];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
#pragma mark - Public API
|
|
93
|
+
|
|
94
|
+
RCT_EXPORT_METHOD(getCurrentState:(nullable NSString *)requestedInterface resolve:(RCTPromiseResolveBlock)resolve
|
|
95
|
+
reject:(__unused RCTPromiseRejectBlock)reject)
|
|
96
|
+
{
|
|
97
|
+
ShakebugSDKRNCConnectionState *state = [self.connectionStateWatcher currentState];
|
|
98
|
+
resolve([self currentDictionaryFromUpdateState:state withInterface:requestedInterface]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
RCT_EXPORT_METHOD(configure:(NSDictionary *)config)
|
|
102
|
+
{
|
|
103
|
+
self.config = config;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#pragma mark - Utilities
|
|
107
|
+
|
|
108
|
+
// Converts the state into a dictionary to send over the bridge
|
|
109
|
+
- (NSDictionary *)currentDictionaryFromUpdateState:(ShakebugSDKRNCConnectionState *)state withInterface:(nullable NSString *)requestedInterface
|
|
110
|
+
{
|
|
111
|
+
NSString *selectedInterface = requestedInterface ?: state.type;
|
|
112
|
+
NSMutableDictionary *details = [self detailsFromInterface:selectedInterface withState:state];
|
|
113
|
+
bool connected = [state.type isEqualToString:selectedInterface] && state.connected;
|
|
114
|
+
if (connected) {
|
|
115
|
+
details[@"isConnectionExpensive"] = @(state.expensive);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return @{
|
|
119
|
+
@"type": selectedInterface,
|
|
120
|
+
@"isConnected": @(connected),
|
|
121
|
+
@"details": details ?: NSNull.null
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
- (NSMutableDictionary *)detailsFromInterface:(nonnull NSString *)requestedInterface withState:(ShakebugSDKRNCConnectionState *)state
|
|
126
|
+
{
|
|
127
|
+
NSMutableDictionary *details = [NSMutableDictionary new];
|
|
128
|
+
if ([requestedInterface isEqualToString: RNCConnectionTypeCellular]) {
|
|
129
|
+
details[@"cellularGeneration"] = state.cellularGeneration ?: NSNull.null;
|
|
130
|
+
details[@"carrier"] = [self carrier] ?: NSNull.null;
|
|
131
|
+
} else if ([requestedInterface isEqualToString: RNCConnectionTypeWifi] || [requestedInterface isEqualToString: RNCConnectionTypeEthernet]) {
|
|
132
|
+
details[@"ipAddress"] = [self ipAddress] ?: NSNull.null;
|
|
133
|
+
details[@"subnet"] = [self subnet] ?: NSNull.null;
|
|
134
|
+
#if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION
|
|
135
|
+
/*
|
|
136
|
+
Without one of the conditions needed to use CNCopyCurrentNetworkInfo, it will leak memory.
|
|
137
|
+
Clients should only set the shouldFetchWiFiSSID to true after ensuring requirements are met to get (B)SSID.
|
|
138
|
+
*/
|
|
139
|
+
if (self.config && self.config[@"shouldFetchWiFiSSID"]) {
|
|
140
|
+
details[@"ssid"] = [self ssid] ?: NSNull.null;
|
|
141
|
+
details[@"bssid"] = [self bssid] ?: NSNull.null;
|
|
142
|
+
}
|
|
143
|
+
#endif
|
|
144
|
+
}
|
|
145
|
+
return details;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
- (NSString *)carrier
|
|
149
|
+
{
|
|
150
|
+
#if (TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST || TARGET_OS_VISION)
|
|
151
|
+
return nil;
|
|
152
|
+
#else
|
|
153
|
+
CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
|
|
154
|
+
CTCarrier *carrier = [netinfo subscriberCellularProvider];
|
|
155
|
+
return carrier.carrierName;
|
|
156
|
+
#endif
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
- (NSString *)ipAddress
|
|
160
|
+
{
|
|
161
|
+
NSString *address = @"0.0.0.0";
|
|
162
|
+
struct ifaddrs *interfaces = NULL;
|
|
163
|
+
struct ifaddrs *temp_addr = NULL;
|
|
164
|
+
int success = 0;
|
|
165
|
+
// retrieve the current interfaces - returns 0 on success
|
|
166
|
+
success = getifaddrs(&interfaces);
|
|
167
|
+
if (success == 0) {
|
|
168
|
+
// Loop through linked list of interfaces
|
|
169
|
+
temp_addr = interfaces;
|
|
170
|
+
while (temp_addr != NULL) {
|
|
171
|
+
if (temp_addr->ifa_addr->sa_family == AF_INET) {
|
|
172
|
+
NSString* ifname = [NSString stringWithUTF8String:temp_addr->ifa_name];
|
|
173
|
+
if (
|
|
174
|
+
// Check if interface is en0 which is the wifi connection on the iPhone
|
|
175
|
+
// and the ethernet connection on the Apple TV
|
|
176
|
+
[ifname isEqualToString:@"en0"] ||
|
|
177
|
+
// Check if interface is en1 which is the wifi connection on the Apple TV
|
|
178
|
+
[ifname isEqualToString:@"en1"]
|
|
179
|
+
) {
|
|
180
|
+
// Get NSString from C String
|
|
181
|
+
char str[INET_ADDRSTRLEN];
|
|
182
|
+
inet_ntop(AF_INET, &((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr, str, INET_ADDRSTRLEN);
|
|
183
|
+
address = [NSString stringWithUTF8String:str];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
temp_addr = temp_addr->ifa_next;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Free memory
|
|
191
|
+
freeifaddrs(interfaces);
|
|
192
|
+
return address;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
- (NSString *)subnet
|
|
196
|
+
{
|
|
197
|
+
NSString *subnet = @"0.0.0.0";
|
|
198
|
+
struct ifaddrs *interfaces = NULL;
|
|
199
|
+
struct ifaddrs *temp_addr = NULL;
|
|
200
|
+
int success = 0;
|
|
201
|
+
// retrieve the current interfaces - returns 0 on success
|
|
202
|
+
success = getifaddrs(&interfaces);
|
|
203
|
+
if (success == 0) {
|
|
204
|
+
// Loop through linked list of interfaces
|
|
205
|
+
temp_addr = interfaces;
|
|
206
|
+
while (temp_addr != NULL) {
|
|
207
|
+
if (temp_addr->ifa_addr->sa_family == AF_INET) {
|
|
208
|
+
NSString* ifname = [NSString stringWithUTF8String:temp_addr->ifa_name];
|
|
209
|
+
if (
|
|
210
|
+
// Check if interface is en0 which is the wifi connection on the iPhone
|
|
211
|
+
// and the ethernet connection on the Apple TV
|
|
212
|
+
[ifname isEqualToString:@"en0"] ||
|
|
213
|
+
// Check if interface is en1 which is the wifi connection on the Apple TV
|
|
214
|
+
[ifname isEqualToString:@"en1"]
|
|
215
|
+
) {
|
|
216
|
+
// Get NSString from C String
|
|
217
|
+
char str[INET_ADDRSTRLEN];
|
|
218
|
+
inet_ntop(AF_INET, &((struct sockaddr_in *)temp_addr->ifa_netmask)->sin_addr, str, INET_ADDRSTRLEN);
|
|
219
|
+
subnet = [NSString stringWithUTF8String:str];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
temp_addr = temp_addr->ifa_next;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Free memory
|
|
227
|
+
freeifaddrs(interfaces);
|
|
228
|
+
return subnet;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
#if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST
|
|
232
|
+
- (NSString *)ssid
|
|
233
|
+
{
|
|
234
|
+
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
|
|
235
|
+
NSDictionary *SSIDInfo;
|
|
236
|
+
NSString *SSID = NULL;
|
|
237
|
+
for (NSString *interfaceName in interfaceNames) {
|
|
238
|
+
// CNCopyCurrentNetworkInfo is deprecated for iOS 13+, need to override & use fetchCurrentWithCompletionHandler
|
|
239
|
+
SSIDInfo = CFBridgingRelease(CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
|
|
240
|
+
if (SSIDInfo.count > 0) {
|
|
241
|
+
SSID = SSIDInfo[@"SSID"];
|
|
242
|
+
if ([SSID isEqualToString:@"Wi-Fi"] || [SSID isEqualToString:@"WLAN"]){
|
|
243
|
+
SSID = NULL;
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return SSID;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
- (NSString *)bssid
|
|
252
|
+
{
|
|
253
|
+
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
|
|
254
|
+
NSDictionary *networkDetails;
|
|
255
|
+
NSString *BSSID = NULL;
|
|
256
|
+
for (NSString *interfaceName in interfaceNames) {
|
|
257
|
+
// CNCopyCurrentNetworkInfo is deprecated for iOS 13+, need to override & use fetchCurrentWithCompletionHandler
|
|
258
|
+
networkDetails = CFBridgingRelease(CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
|
|
259
|
+
if (networkDetails.count > 0)
|
|
260
|
+
{
|
|
261
|
+
BSSID = networkDetails[(NSString *) kCNNetworkInfoKeyBSSID];
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return BSSID;
|
|
266
|
+
}
|
|
267
|
+
#endif
|
|
268
|
+
|
|
269
|
+
@end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RecordScreen.h
|
|
3
|
+
// Shakebug
|
|
4
|
+
//
|
|
5
|
+
// Created by ideveloper2 on 28/02/24.
|
|
6
|
+
// Copyright © 2024 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <React/RCTBridgeModule.h>
|
|
10
|
+
#import <ReplayKit/ReplayKit.h>
|
|
11
|
+
#import <AVFoundation/AVFoundation.h>
|
|
12
|
+
|
|
13
|
+
@interface ShakebugSDKRecordScreen : NSObject <RCTBridgeModule>
|
|
14
|
+
|
|
15
|
+
@property (strong, nonatomic) RPScreenRecorder *screenRecorder;
|
|
16
|
+
@property (strong, nonatomic) AVAssetWriterInput *videoInput;
|
|
17
|
+
@property (strong, nonatomic) AVAssetWriterInput *audioInput;
|
|
18
|
+
@property (strong, nonatomic) AVAssetWriterInput *micInput;
|
|
19
|
+
@property (assign, nonatomic) int screenWidth;
|
|
20
|
+
@property (assign, nonatomic) int screenHeight;
|
|
21
|
+
@property (assign, nonatomic) BOOL enableMic;
|
|
22
|
+
@property (assign, nonatomic) int fps;
|
|
23
|
+
@property (assign, nonatomic) int bitrate;
|
|
24
|
+
|
|
25
|
+
@property (nonatomic) AVAssetWriter *writer;
|
|
26
|
+
@property BOOL encounteredFirstBuffer;
|
|
27
|
+
@property CMSampleBufferRef afterAppBackgroundAudioSampleBuffer;
|
|
28
|
+
@property CMSampleBufferRef afterAppBackgroundMicSampleBuffer;
|
|
29
|
+
@property CMSampleBufferRef afterAppBackgroundVideoSampleBuffer;
|
|
30
|
+
|
|
31
|
+
@end
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RecordScreen.m
|
|
3
|
+
// Shakebug
|
|
4
|
+
//
|
|
5
|
+
// Created by ideveloper2 on 28/02/24.
|
|
6
|
+
// Copyright © 2024 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "ShakebugSDKRecordScreen.h"
|
|
10
|
+
#import <React/RCTConvert.h>
|
|
11
|
+
|
|
12
|
+
@implementation ShakebugSDKRecordScreen
|
|
13
|
+
|
|
14
|
+
UIBackgroundTaskIdentifier _ShakebugSDKbackgroundRenderingID;
|
|
15
|
+
|
|
16
|
+
- (NSDictionary *)errorResponse:(NSDictionary *)result;
|
|
17
|
+
{
|
|
18
|
+
NSDictionary *json = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
19
|
+
@"error", @"status",
|
|
20
|
+
result, @"result",nil];
|
|
21
|
+
return json;
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (NSDictionary *) successResponse:(NSDictionary *)result;
|
|
26
|
+
{
|
|
27
|
+
NSDictionary *json = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
28
|
+
@"success", @"status",
|
|
29
|
+
result, @"result",nil];
|
|
30
|
+
return json;
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
- (void) muteAudioInBuffer:(CMSampleBufferRef)sampleBuffer
|
|
35
|
+
{
|
|
36
|
+
|
|
37
|
+
CMItemCount numSamples = CMSampleBufferGetNumSamples(sampleBuffer);
|
|
38
|
+
NSUInteger channelIndex = 0;
|
|
39
|
+
|
|
40
|
+
CMBlockBufferRef audioBlockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer);
|
|
41
|
+
size_t audioBlockBufferOffset = (channelIndex * numSamples * sizeof(SInt16));
|
|
42
|
+
size_t lengthAtOffset = 0;
|
|
43
|
+
size_t totalLength = 0;
|
|
44
|
+
SInt16 *samples = NULL;
|
|
45
|
+
CMBlockBufferGetDataPointer(audioBlockBuffer, audioBlockBufferOffset, &lengthAtOffset, &totalLength, (char **)(&samples));
|
|
46
|
+
|
|
47
|
+
for (NSInteger i=0; i<numSamples; i++) {
|
|
48
|
+
samples[i] = (SInt16)0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// For H264, unless the value is a multiple of 2 or 4, a green border will appear, so a function to adjust it
|
|
53
|
+
- (int) adjustMultipleOf2:(int)value;
|
|
54
|
+
{
|
|
55
|
+
if (value % 2 == 1) {
|
|
56
|
+
return value + 1;
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
RCT_EXPORT_MODULE()
|
|
63
|
+
|
|
64
|
+
RCT_EXPORT_METHOD(setup: (NSDictionary *)config)
|
|
65
|
+
{
|
|
66
|
+
self.screenWidth = [RCTConvert int: config[@"width"]];
|
|
67
|
+
self.screenHeight = [RCTConvert int: config[@"height"]];
|
|
68
|
+
self.enableMic = [RCTConvert BOOL: config[@"mic"]];
|
|
69
|
+
self.bitrate = [RCTConvert int: config[@"bitrate"]];
|
|
70
|
+
self.fps = [RCTConvert int: config[@"fps"]];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
RCT_REMAP_METHOD(startRecording, resolve:(RCTPromiseResolveBlock)resolve rejecte:(RCTPromiseRejectBlock)reject)
|
|
74
|
+
{
|
|
75
|
+
UIApplication *app = [UIApplication sharedApplication];
|
|
76
|
+
_ShakebugSDKbackgroundRenderingID = [app beginBackgroundTaskWithExpirationHandler:^{
|
|
77
|
+
[app endBackgroundTask:_ShakebugSDKbackgroundRenderingID];
|
|
78
|
+
_ShakebugSDKbackgroundRenderingID = UIBackgroundTaskInvalid;
|
|
79
|
+
}];
|
|
80
|
+
|
|
81
|
+
self.screenRecorder = [RPScreenRecorder sharedRecorder];
|
|
82
|
+
if (self.screenRecorder.isRecording) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
self.encounteredFirstBuffer = NO;
|
|
87
|
+
|
|
88
|
+
NSArray *pathDocuments = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
89
|
+
NSString *outputURL = pathDocuments[0];
|
|
90
|
+
|
|
91
|
+
NSString *videoOutPath = [[outputURL stringByAppendingPathComponent:[NSString stringWithFormat:@"%u", arc4random() % 1000]] stringByAppendingPathExtension:@"mp4"];
|
|
92
|
+
|
|
93
|
+
NSError *error;
|
|
94
|
+
self.writer = [AVAssetWriter assetWriterWithURL:[NSURL fileURLWithPath:videoOutPath] fileType:AVFileTypeMPEG4 error:&error];
|
|
95
|
+
if (!self.writer) {
|
|
96
|
+
NSLog(@"writer: %@", error);
|
|
97
|
+
abort();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
AudioChannelLayout acl = { 0 };
|
|
101
|
+
acl.mChannelLayoutTag = kAudioChannelLayoutTag_Mono;
|
|
102
|
+
self.audioInput = [[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeAudio outputSettings:@{ AVFormatIDKey: @(kAudioFormatMPEG4AAC), AVSampleRateKey: @(44100), AVChannelLayoutKey: [NSData dataWithBytes: &acl length: sizeof( acl ) ], AVEncoderBitRateKey: @(64000)}];
|
|
103
|
+
self.micInput = [[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeAudio outputSettings:@{ AVFormatIDKey: @(kAudioFormatMPEG4AAC), AVSampleRateKey: @(44100), AVChannelLayoutKey: [NSData dataWithBytes: &acl length: sizeof( acl ) ], AVEncoderBitRateKey: @(64000)}];
|
|
104
|
+
|
|
105
|
+
self.audioInput.preferredVolume = 0.0;
|
|
106
|
+
self.micInput.preferredVolume = 0.0;
|
|
107
|
+
|
|
108
|
+
NSDictionary *compressionProperties = @{AVVideoProfileLevelKey : AVVideoProfileLevelH264HighAutoLevel,
|
|
109
|
+
AVVideoH264EntropyModeKey : AVVideoH264EntropyModeCABAC,
|
|
110
|
+
AVVideoAverageBitRateKey : @(self.bitrate),
|
|
111
|
+
AVVideoMaxKeyFrameIntervalKey : @(self.fps),
|
|
112
|
+
AVVideoAllowFrameReorderingKey : @NO};
|
|
113
|
+
|
|
114
|
+
NSLog(@"width: %d", [self adjustMultipleOf2:self.screenWidth]);
|
|
115
|
+
NSLog(@"height: %d", [self adjustMultipleOf2:self.screenHeight]);
|
|
116
|
+
if (@available(iOS 11.0, *)) {
|
|
117
|
+
NSDictionary *videoSettings = @{AVVideoCompressionPropertiesKey : compressionProperties,
|
|
118
|
+
AVVideoCodecKey : AVVideoCodecTypeH264,
|
|
119
|
+
AVVideoWidthKey : @([self adjustMultipleOf2:self.screenWidth]),
|
|
120
|
+
AVVideoHeightKey : @([self adjustMultipleOf2:self.screenHeight])};
|
|
121
|
+
|
|
122
|
+
self.videoInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings];
|
|
123
|
+
} else {
|
|
124
|
+
// Fallback on earlier versions
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
[self.writer addInput:self.audioInput];
|
|
128
|
+
[self.writer addInput:self.micInput];
|
|
129
|
+
[self.writer addInput:self.videoInput];
|
|
130
|
+
[self.videoInput setMediaTimeScale:60];
|
|
131
|
+
[self.writer setMovieTimeScale:60];
|
|
132
|
+
[self.videoInput setExpectsMediaDataInRealTime:YES];
|
|
133
|
+
|
|
134
|
+
if (self.enableMic) {
|
|
135
|
+
self.screenRecorder.microphoneEnabled = YES;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
|
|
139
|
+
if (granted) {
|
|
140
|
+
if (@available(iOS 11.0, *)) {
|
|
141
|
+
[self.screenRecorder startCaptureWithHandler:^(CMSampleBufferRef sampleBuffer, RPSampleBufferType bufferType, NSError* error) {
|
|
142
|
+
// Failure to do so will result in a memory error when accessing the sampleBuffer in the main thread.
|
|
143
|
+
CFRetain(sampleBuffer);
|
|
144
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
145
|
+
if (CMSampleBufferDataIsReady(sampleBuffer)) {
|
|
146
|
+
if (self.writer.status == AVAssetWriterStatusUnknown && !self.encounteredFirstBuffer && bufferType == RPSampleBufferTypeVideo) {
|
|
147
|
+
self.encounteredFirstBuffer = YES;
|
|
148
|
+
NSLog(@"First buffer video");
|
|
149
|
+
[self.writer startWriting];
|
|
150
|
+
[self.writer startSessionAtSourceTime:CMSampleBufferGetPresentationTimeStamp(sampleBuffer)];
|
|
151
|
+
} else if (self.writer.status == AVAssetWriterStatusFailed) {
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
|
|
156
|
+
CMSampleBufferRef copiedBuffer;
|
|
157
|
+
CMSampleBufferCreateCopy(kCFAllocatorDefault, sampleBuffer, &copiedBuffer);
|
|
158
|
+
switch (bufferType) {
|
|
159
|
+
case RPSampleBufferTypeVideo:
|
|
160
|
+
self.afterAppBackgroundVideoSampleBuffer = copiedBuffer;
|
|
161
|
+
break;
|
|
162
|
+
case RPSampleBufferTypeAudioApp:
|
|
163
|
+
self.afterAppBackgroundAudioSampleBuffer = copiedBuffer;
|
|
164
|
+
break;
|
|
165
|
+
case RPSampleBufferTypeAudioMic:
|
|
166
|
+
self.afterAppBackgroundMicSampleBuffer = copiedBuffer;
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
} else if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive) {
|
|
172
|
+
if (bufferType == RPSampleBufferTypeVideo && self.afterAppBackgroundVideoSampleBuffer != nil && self.afterAppBackgroundAudioSampleBuffer != nil && self.afterAppBackgroundMicSampleBuffer != nil) {
|
|
173
|
+
CMTime timeWhenAppBackground = CMTimeSubtract(CMSampleBufferGetPresentationTimeStamp(sampleBuffer), CMSampleBufferGetPresentationTimeStamp(self.afterAppBackgroundVideoSampleBuffer));
|
|
174
|
+
// Calc loop count for appendSampleBuffer.
|
|
175
|
+
long bufferCount = floor(CMTimeGetSeconds(timeWhenAppBackground) * (1 / CMTimeGetSeconds(CMSampleBufferGetDuration(self.afterAppBackgroundAudioSampleBuffer))));
|
|
176
|
+
|
|
177
|
+
// Make mute audio.
|
|
178
|
+
[self muteAudioInBuffer:self.afterAppBackgroundAudioSampleBuffer];
|
|
179
|
+
[self muteAudioInBuffer:self.afterAppBackgroundMicSampleBuffer];
|
|
180
|
+
|
|
181
|
+
for (int i = 0; i < bufferCount; i ++) {
|
|
182
|
+
if (self.audioInput.isReadyForMoreMediaData) {
|
|
183
|
+
[self.audioInput appendSampleBuffer:self.afterAppBackgroundAudioSampleBuffer];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for (int i = 0; i < bufferCount; i ++) {
|
|
187
|
+
if (self.enableMic && self.micInput.isReadyForMoreMediaData) {
|
|
188
|
+
[self.micInput appendSampleBuffer:self.afterAppBackgroundMicSampleBuffer];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Clean
|
|
193
|
+
CFRelease(self.afterAppBackgroundAudioSampleBuffer);
|
|
194
|
+
CFRelease(self.afterAppBackgroundMicSampleBuffer);
|
|
195
|
+
CFRelease(self.afterAppBackgroundVideoSampleBuffer);
|
|
196
|
+
self.afterAppBackgroundAudioSampleBuffer = nil;
|
|
197
|
+
self.afterAppBackgroundMicSampleBuffer = nil;
|
|
198
|
+
self.afterAppBackgroundVideoSampleBuffer = nil;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (self.writer.status == AVAssetWriterStatusWriting) {
|
|
203
|
+
switch (bufferType) {
|
|
204
|
+
case RPSampleBufferTypeVideo:
|
|
205
|
+
if (self.videoInput.isReadyForMoreMediaData) {
|
|
206
|
+
[self.videoInput appendSampleBuffer:sampleBuffer];
|
|
207
|
+
}
|
|
208
|
+
break;
|
|
209
|
+
case RPSampleBufferTypeAudioApp:
|
|
210
|
+
if (self.audioInput.isReadyForMoreMediaData) {
|
|
211
|
+
if(self.enableMic){
|
|
212
|
+
[self.audioInput appendSampleBuffer:sampleBuffer];
|
|
213
|
+
} else {
|
|
214
|
+
[self muteAudioInBuffer:sampleBuffer];
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
break;
|
|
218
|
+
case RPSampleBufferTypeAudioMic:
|
|
219
|
+
if (self.micInput.isReadyForMoreMediaData) {
|
|
220
|
+
if(self.enableMic){
|
|
221
|
+
[self.micInput appendSampleBuffer:sampleBuffer];
|
|
222
|
+
} else {
|
|
223
|
+
[self muteAudioInBuffer:sampleBuffer];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
227
|
+
default:
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
CFRelease(sampleBuffer);
|
|
234
|
+
});
|
|
235
|
+
} completionHandler:^(NSError* error) {
|
|
236
|
+
NSLog(@"startCapture: %@", error);
|
|
237
|
+
if (error) {
|
|
238
|
+
resolve(@"permission_error");
|
|
239
|
+
} else {
|
|
240
|
+
resolve(@"started");
|
|
241
|
+
}
|
|
242
|
+
}];
|
|
243
|
+
} else {
|
|
244
|
+
// Fallback on earlier versions
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
NSError* err = nil;
|
|
248
|
+
reject(0, @"Permission denied", err);
|
|
249
|
+
}
|
|
250
|
+
}];
|
|
251
|
+
|
|
252
|
+
if (self.enableMic) {
|
|
253
|
+
self.screenRecorder.microphoneEnabled = YES;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
RCT_REMAP_METHOD(stopRecording, resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
258
|
+
{
|
|
259
|
+
[[UIApplication sharedApplication] endBackgroundTask:_ShakebugSDKbackgroundRenderingID];
|
|
260
|
+
|
|
261
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
262
|
+
if (@available(iOS 11.0, *)) {
|
|
263
|
+
[[RPScreenRecorder sharedRecorder] stopCaptureWithHandler:^(NSError * _Nullable error) {
|
|
264
|
+
if (!error) {
|
|
265
|
+
[self.audioInput markAsFinished];
|
|
266
|
+
[self.micInput markAsFinished];
|
|
267
|
+
[self.videoInput markAsFinished];
|
|
268
|
+
[self.writer finishWritingWithCompletionHandler:^{
|
|
269
|
+
|
|
270
|
+
NSDictionary *result = [NSDictionary dictionaryWithObject:self.writer.outputURL.absoluteString forKey:@"outputURL"];
|
|
271
|
+
resolve([self successResponse:result]);
|
|
272
|
+
|
|
273
|
+
NSLog(@"finishWritingWithCompletionHandler: Recording stopped successfully. Cleaning up... %@", result);
|
|
274
|
+
self.audioInput = nil;
|
|
275
|
+
self.micInput = nil;
|
|
276
|
+
self.videoInput = nil;
|
|
277
|
+
self.writer = nil;
|
|
278
|
+
self.screenRecorder = nil;
|
|
279
|
+
}];
|
|
280
|
+
}
|
|
281
|
+
}];
|
|
282
|
+
} else {
|
|
283
|
+
// Fallback on earlier versions
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
RCT_REMAP_METHOD(clean,
|
|
289
|
+
cleanResolve:(RCTPromiseResolveBlock)resolve
|
|
290
|
+
cleanRejecte:(RCTPromiseRejectBlock)reject)
|
|
291
|
+
{
|
|
292
|
+
|
|
293
|
+
NSArray *pathDocuments = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
294
|
+
NSString *path = pathDocuments[0];
|
|
295
|
+
NSLog(@"startCapture: %@", path);
|
|
296
|
+
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
|
|
297
|
+
resolve(@"cleaned");
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Don't compile this code when we build for the old architecture.
|
|
301
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
302
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
303
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
304
|
+
{
|
|
305
|
+
return std::make_shared<facebook::react::NativeRecordScreenSpecJSI>(params);
|
|
306
|
+
}
|
|
307
|
+
#endif
|
|
308
|
+
|
|
309
|
+
@end
|