react-native-compressor 1.6.4 → 1.7.1
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/LICENSE +1 -1
- package/README.md +41 -27
- package/android/build.gradle +95 -42
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +0 -1
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/reactnativecompressor/CompressorModule.java +107 -43
- package/android/src/main/java/com/reactnativecompressor/CompressorPackage.java +47 -19
- package/android/src/main/java/com/reactnativecompressor/Image/ImageCompressor.java +28 -16
- package/android/src/main/java/com/reactnativecompressor/Image/utils/ImageCompressorOptions.java +5 -1
- package/android/src/main/java/com/reactnativecompressor/Utils/MediaCache.java +65 -0
- package/android/src/main/java/com/reactnativecompressor/Utils/Utils.java +162 -3
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressorHelper.java +7 -4
- package/android/src/main/java/com/reactnativecompressor/Video/VideoModule.java +11 -22
- package/android/src/newarch/CompressorSpec.java +9 -0
- package/android/src/newarch/VideoCompressorSpec.java +9 -0
- package/android/src/oldarch/CompressorSpec.java +34 -0
- package/android/src/oldarch/VideoCompressorSpec.java +26 -0
- package/ios/Compressor-Bridging-Header.h +1 -0
- package/ios/Compressor.h +9 -1
- package/ios/Compressor.mm +427 -0
- package/ios/Compressor.xcodeproj/project.pbxproj +6 -36
- package/ios/Image/ImageCompressor.h +12 -7
- package/ios/Image/ImageCompressor.m +164 -67
- package/ios/Image/ImageCompressorOptions.h +1 -0
- package/ios/Image/ImageCompressorOptions.m +5 -1
- package/ios/Utils/Downloader.h +16 -0
- package/ios/Utils/Downloader.m +150 -0
- package/ios/Utils/MediaCache.h +11 -0
- package/ios/Utils/MediaCache.m +51 -0
- package/ios/Video/VideoCompressor.swift +14 -5
- package/lib/commonjs/Audio/index.js +13 -14
- package/lib/commonjs/Audio/index.js.map +1 -1
- package/lib/commonjs/Image/index.js +26 -7
- package/lib/commonjs/Image/index.js.map +1 -1
- package/lib/commonjs/Main.js +29 -0
- package/lib/commonjs/Main.js.map +1 -0
- package/lib/commonjs/Spec/NativeCompressor.js +10 -0
- package/lib/commonjs/Spec/NativeCompressor.js.map +1 -0
- package/lib/commonjs/Spec/NativeVideoCompressor.js +10 -0
- package/lib/commonjs/Spec/NativeVideoCompressor.js.map +1 -0
- package/lib/commonjs/Video/index.js +17 -25
- package/lib/commonjs/Video/index.js.map +1 -1
- package/lib/commonjs/expo-plugin/compressor.js +1 -4
- package/lib/commonjs/expo-plugin/compressor.js.map +1 -1
- package/lib/commonjs/index.js +21 -28
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/index.js +32 -51
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/Audio/index.js +13 -11
- package/lib/module/Audio/index.js.map +1 -1
- package/lib/module/Image/index.js +27 -6
- package/lib/module/Image/index.js.map +1 -1
- package/lib/module/Main.js +22 -0
- package/lib/module/Main.js.map +1 -0
- package/lib/module/Spec/NativeCompressor.js +3 -0
- package/lib/module/Spec/NativeCompressor.js.map +1 -0
- package/lib/module/Spec/NativeVideoCompressor.js +3 -0
- package/lib/module/Spec/NativeVideoCompressor.js.map +1 -0
- package/lib/module/Video/index.js +18 -19
- package/lib/module/Video/index.js.map +1 -1
- package/lib/module/expo-plugin/compressor.js +1 -3
- package/lib/module/expo-plugin/compressor.js.map +1 -1
- package/lib/module/index.js +8 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/index.js +26 -34
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/Audio/index.d.ts +2 -1
- package/lib/typescript/Audio/index.d.ts.map +1 -0
- package/lib/typescript/Image/index.d.ts +11 -6
- package/lib/typescript/Image/index.d.ts.map +1 -0
- package/lib/typescript/Main.d.ts +4 -0
- package/lib/typescript/Main.d.ts.map +1 -0
- package/lib/typescript/Spec/NativeCompressor.d.ts +14 -0
- package/lib/typescript/Spec/NativeCompressor.d.ts.map +1 -0
- package/lib/typescript/Spec/NativeVideoCompressor.d.ts +13 -0
- package/lib/typescript/Spec/NativeVideoCompressor.d.ts.map +1 -0
- package/lib/typescript/Video/index.d.ts +5 -3
- package/lib/typescript/Video/index.d.ts.map +1 -0
- package/lib/typescript/expo-plugin/compressor.d.ts +2 -3
- package/lib/typescript/expo-plugin/compressor.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -3
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +6 -4
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/package.json +62 -38
- package/react-native-compressor.podspec +24 -1
- package/src/Audio/index.tsx +6 -4
- package/src/Image/index.tsx +38 -5
- package/src/Main.tsx +41 -0
- package/src/Spec/NativeCompressor.ts +15 -0
- package/src/Spec/NativeVideoCompressor.ts +14 -0
- package/src/Video/index.tsx +28 -11
- package/src/expo-plugin/compressor.ts +2 -1
- package/src/index.tsx +7 -2
- package/src/utils/index.tsx +11 -5
- package/android/.gradle/6.9/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.9/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/caches/build_file_checksums.ser +0 -0
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -20
- package/android/.idea/jarRepositories.xml +0 -45
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_0_2_aar.xml +0 -24
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_0_0.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_autofill_autofill_1_1_0_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_collection_collection_1_0_0.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_0_0_aar.xml +0 -24
- package/android/.idea/libraries/Gradle__androidx_core_core_1_1_0_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +0 -24
- package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_0_0_aar.xml +0 -24
- package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_0_0.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +0 -24
- package/android/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml +0 -24
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_0_1_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__com_facebook_fbjni_fbjni_java_only_0_2_2.xml +0 -13
- package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_2_5_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_2_5_0_aar.xml +0 -18
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_2_5_0_aar.xml +0 -18
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_2_5_0_aar.xml +0 -18
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_2_5_0_aar.xml +0 -18
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_native_2_5_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_2_5_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_ashmem_2_5_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_java_2_5_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_native_2_5_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagefilters_2_5_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagetranscoder_2_5_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_ui_common_2_5_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_infer_annotation_infer_annotation_0_18_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_66_1_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__com_facebook_soloader_annotation_0_10_1.xml +0 -13
- package/android/.idea/libraries/Gradle__com_facebook_soloader_nativeloader_0_10_1.xml +0 -13
- package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_10_1_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_yoga_proguard_annotations_1_19_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml +0 -13
- package/android/.idea/libraries/Gradle__com_googlecode_mp4parser_isoparser_1_0_6.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_9_1.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_4_9_1.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okio_okio_2_9_0.xml +0 -13
- package/android/.idea/libraries/Gradle__io_github_lizhangqu_coreprogress_1_0_2_aar.xml +0 -18
- package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +0 -13
- package/android/.idea/libraries/Gradle__org_aspectj_aspectjrt_1_8_2.xml +0 -13
- package/android/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml +0 -13
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_annotations_jvm_1_3_72.xml +0 -13
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_4_10.xml +0 -13
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_4_10.xml +0 -13
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_4_10.xml +0 -13
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_4_10.xml +0 -13
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_4_0.xml +0 -13
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm_1_4_0.xml +0 -13
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/modules/android.iml +0 -138
- package/android/.idea/modules.xml +0 -8
- package/android/.idea/vcs.xml +0 -6
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -183
- package/android/gradlew.bat +0 -100
- package/android/local.properties +0 -8
- package/ios/Compressor.m +0 -351
- package/ios/Compressor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Compressor.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Compressor.xcodeproj/xcshareddata/xcschemes/Compressor.xcscheme +0 -67
- package/ios/Compressor.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist +0 -22
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
#import "Compressor.h"
|
|
2
|
+
|
|
3
|
+
//Image
|
|
4
|
+
#import "Image/ImageCompressor.h"
|
|
5
|
+
#import "Image/ImageCompressorOptions.h"
|
|
6
|
+
#import <React/RCTEventEmitter.h>
|
|
7
|
+
#import <AVFoundation/AVFoundation.h>
|
|
8
|
+
#import "MediaCache.h"
|
|
9
|
+
|
|
10
|
+
#define AlAsset_Library_Scheme @"assets-library"
|
|
11
|
+
@implementation Compressor
|
|
12
|
+
|
|
13
|
+
AVAssetWriter *assetWriter=nil;
|
|
14
|
+
static NSArray *metadatas;
|
|
15
|
+
|
|
16
|
+
- (NSArray *)metadatas
|
|
17
|
+
{
|
|
18
|
+
if (!metadatas) {
|
|
19
|
+
metadatas = @[
|
|
20
|
+
@"albumName",
|
|
21
|
+
@"artist",
|
|
22
|
+
@"comment",
|
|
23
|
+
@"copyrights",
|
|
24
|
+
@"creationDate",
|
|
25
|
+
@"date",
|
|
26
|
+
@"encodedby",
|
|
27
|
+
@"genre",
|
|
28
|
+
@"language",
|
|
29
|
+
@"location",
|
|
30
|
+
@"lastModifiedDate",
|
|
31
|
+
@"performer",
|
|
32
|
+
@"publisher",
|
|
33
|
+
@"title"
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
return metadatas;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (instancetype)init {
|
|
40
|
+
self = [super init];
|
|
41
|
+
[ImageCompressor initCompressorInstance:self];
|
|
42
|
+
return self;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
RCT_EXPORT_MODULE()
|
|
46
|
+
|
|
47
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
48
|
+
return NO;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
//Image
|
|
53
|
+
RCT_EXPORT_METHOD(
|
|
54
|
+
image_compress: (NSString*) imagePath
|
|
55
|
+
optionsDict: (NSDictionary*) optionsDict
|
|
56
|
+
resolver: (RCTPromiseResolveBlock) resolve
|
|
57
|
+
rejecter: (RCTPromiseRejectBlock) reject) {
|
|
58
|
+
[self image_compress:imagePath optionMap:optionsDict resolve:resolve reject:reject];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//Audio
|
|
62
|
+
RCT_EXPORT_METHOD(
|
|
63
|
+
compress_audio: (NSString*) filePath
|
|
64
|
+
optionsDict: (NSDictionary*) optionsDict
|
|
65
|
+
resolver: (RCTPromiseResolveBlock) resolve
|
|
66
|
+
rejecter: (RCTPromiseRejectBlock) reject) {
|
|
67
|
+
[self compress_audio:filePath optionMap:optionsDict resolve:resolve reject:reject];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//general
|
|
71
|
+
RCT_EXPORT_METHOD(
|
|
72
|
+
generateFilePath: (NSString*) extension
|
|
73
|
+
resolver: (RCTPromiseResolveBlock) resolve
|
|
74
|
+
rejecter: (RCTPromiseRejectBlock) reject) {
|
|
75
|
+
[self generateFilePath:extension resolve:resolve reject:reject];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
RCT_EXPORT_METHOD(
|
|
79
|
+
getRealPath: (NSString*) path
|
|
80
|
+
type: (NSString*) type
|
|
81
|
+
resolver: (RCTPromiseResolveBlock) resolve
|
|
82
|
+
rejecter: (RCTPromiseRejectBlock) reject) {
|
|
83
|
+
[self getRealPath:path type:type resolve:resolve reject:reject];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//general
|
|
87
|
+
RCT_EXPORT_METHOD(
|
|
88
|
+
getFileSize: (NSString*) filePath
|
|
89
|
+
resolver: (RCTPromiseResolveBlock) resolve
|
|
90
|
+
rejecter: (RCTPromiseRejectBlock) reject) {
|
|
91
|
+
[self getFileSize:filePath resolve:resolve reject:reject];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
RCT_EXPORT_METHOD(
|
|
96
|
+
getVideoMetaData: (NSString*) filePath
|
|
97
|
+
resolver: (RCTPromiseResolveBlock) resolve
|
|
98
|
+
rejecter: (RCTPromiseRejectBlock) reject) {
|
|
99
|
+
[self getVideoMetaData:filePath resolve:resolve reject:reject];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
- (NSArray<NSString *>*)supportedEvents {
|
|
103
|
+
return @[@"downloadProgress"];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
- (NSString *)getAudioQualityConstant:(NSString *)quality
|
|
107
|
+
{
|
|
108
|
+
NSMutableArray *audioQualityArray = [[NSMutableArray alloc]initWithObjects:@"low", @"medium", @"high", nil];
|
|
109
|
+
int index = [audioQualityArray indexOfObject:quality];
|
|
110
|
+
switch (index) {
|
|
111
|
+
case 0:
|
|
112
|
+
return AVAssetExportPresetLowQuality;
|
|
113
|
+
break;
|
|
114
|
+
case 1:
|
|
115
|
+
return AVAssetExportPresetMediumQuality;
|
|
116
|
+
break;
|
|
117
|
+
case 2:
|
|
118
|
+
return AVAssetExportPresetHighestQuality;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
return AVAssetExportPresetMediumQuality;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
- (void)audo_compress_helper:(AVURLAsset *)avAsset qualityConstant:(NSString *)qualityConstant complete:(void (^)(NSString *mp3Path, BOOL finished))completeCallback {
|
|
125
|
+
NSString *path;
|
|
126
|
+
if ([avAsset.URL.scheme isEqualToString:AlAsset_Library_Scheme]) {
|
|
127
|
+
path = avAsset.URL.query;
|
|
128
|
+
if (path.length == 0) {
|
|
129
|
+
completeCallback(nil, NO);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
}else {
|
|
134
|
+
path = avAsset.URL.path;
|
|
135
|
+
if (!path || ![[NSFileManager defaultManager] fileExistsAtPath:path]) {
|
|
136
|
+
completeCallback(nil, NO);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
NSString *mp3Path = [ImageCompressor generateCacheFilePath:@"m4a"];;
|
|
142
|
+
|
|
143
|
+
if ([[NSFileManager defaultManager] fileExistsAtPath:mp3Path]) {
|
|
144
|
+
if (completeCallback)
|
|
145
|
+
completeCallback(mp3Path, YES);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
NSURL *mp3Url;
|
|
150
|
+
NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:avAsset];
|
|
151
|
+
|
|
152
|
+
if ([compatiblePresets containsObject:qualityConstant]) {
|
|
153
|
+
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]
|
|
154
|
+
initWithAsset:avAsset
|
|
155
|
+
presetName:AVAssetExportPresetAppleM4A];
|
|
156
|
+
|
|
157
|
+
mp3Url = [NSURL fileURLWithPath:mp3Path];
|
|
158
|
+
exportSession.outputURL = mp3Url;
|
|
159
|
+
exportSession.shouldOptimizeForNetworkUse = YES;
|
|
160
|
+
exportSession.outputFileType = AVFileTypeAppleM4A;
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
[exportSession exportAsynchronouslyWithCompletionHandler:^{
|
|
164
|
+
BOOL finished = NO;
|
|
165
|
+
switch ([exportSession status]) {
|
|
166
|
+
case AVAssetExportSessionStatusFailed:
|
|
167
|
+
NSLog(@"AVAssetExportSessionStatusFailed, error:%@.", exportSession.error);
|
|
168
|
+
break;
|
|
169
|
+
|
|
170
|
+
case AVAssetExportSessionStatusCancelled:
|
|
171
|
+
NSLog(@"AVAssetExportSessionStatusCancelled.");
|
|
172
|
+
break;
|
|
173
|
+
|
|
174
|
+
case AVAssetExportSessionStatusCompleted:
|
|
175
|
+
NSLog(@"AVAssetExportSessionStatusCompleted.");
|
|
176
|
+
finished = YES;
|
|
177
|
+
break;
|
|
178
|
+
|
|
179
|
+
case AVAssetExportSessionStatusUnknown:
|
|
180
|
+
NSLog(@"AVAssetExportSessionStatusUnknown");
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case AVAssetExportSessionStatusWaiting:
|
|
184
|
+
NSLog(@"AVAssetExportSessionStatusWaiting");
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
case AVAssetExportSessionStatusExporting:
|
|
188
|
+
NSLog(@"AVAssetExportSessionStatusExporting");
|
|
189
|
+
break;
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (completeCallback)
|
|
194
|
+
completeCallback(mp3Path, finished);
|
|
195
|
+
}];
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
- (void)compress_audio:(NSString *)fileUrl optionMap:(NSDictionary *)optionMap resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
201
|
+
@try {
|
|
202
|
+
if([fileUrl containsString:@"file://"])
|
|
203
|
+
{
|
|
204
|
+
fileUrl=[fileUrl stringByReplacingOccurrencesOfString:@"file://"
|
|
205
|
+
withString:@""];
|
|
206
|
+
}
|
|
207
|
+
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
208
|
+
BOOL isDir;
|
|
209
|
+
if (![fileManager fileExistsAtPath:fileUrl isDirectory:&isDir] || isDir){
|
|
210
|
+
NSError *err = [NSError errorWithDomain:@"file not found" code:-15 userInfo:nil];
|
|
211
|
+
reject([NSString stringWithFormat: @"%lu", (long)err.code], err.localizedDescription, err);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
NSDictionary *assetOptions = @{AVURLAssetPreferPreciseDurationAndTimingKey: @YES};
|
|
216
|
+
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:fileUrl] options:assetOptions];
|
|
217
|
+
NSString *quality=[optionMap objectForKey:@"quality"];
|
|
218
|
+
NSString *qualityConstant=[self getAudioQualityConstant:quality];
|
|
219
|
+
[self audo_compress_helper:asset qualityConstant:qualityConstant complete:^(NSString *mp3Path, BOOL finished) {
|
|
220
|
+
if(finished)
|
|
221
|
+
{
|
|
222
|
+
resolve([NSString stringWithFormat: @"file:/%@", mp3Path]);
|
|
223
|
+
}
|
|
224
|
+
else
|
|
225
|
+
{
|
|
226
|
+
reject(@"Error", @"Something went wrong", nil);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
}];
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
@catch (NSException *exception) {
|
|
233
|
+
reject(exception.name, exception.reason, nil);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
- (void)generateFilePath:(NSString *)extension resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
238
|
+
@try {
|
|
239
|
+
NSString *outputUri =[ImageCompressor generateCacheFilePath:extension];
|
|
240
|
+
resolve(outputUri);
|
|
241
|
+
}
|
|
242
|
+
@catch (NSException *exception) {
|
|
243
|
+
reject(exception.name, exception.reason, nil);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
- (void)getRealPath:(NSString *)path type:(NSString *)type resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
248
|
+
@try {
|
|
249
|
+
if([type isEqualToString:@"video"])
|
|
250
|
+
{
|
|
251
|
+
[ImageCompressor getAbsoluteVideoPath:path uuid:@"" completionHandler:^(NSString* absoluteImagePath){
|
|
252
|
+
resolve(absoluteImagePath);
|
|
253
|
+
}];
|
|
254
|
+
}
|
|
255
|
+
else
|
|
256
|
+
{
|
|
257
|
+
[ImageCompressor getAbsoluteImagePath:path uuid:@"test" completionHandler:^(NSString* absoluteImagePath){
|
|
258
|
+
resolve(absoluteImagePath);
|
|
259
|
+
}];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
@catch (NSException *exception) {
|
|
263
|
+
reject(exception.name, exception.reason, nil);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
- (void)getVideoMetaData:(NSString *)filePath resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
268
|
+
@try {
|
|
269
|
+
[ImageCompressor getAbsoluteVideoPath:filePath uuid:@"" completionHandler:^(NSString *absoluteImagePath) {
|
|
270
|
+
if([absoluteImagePath containsString:@"file://"])
|
|
271
|
+
{
|
|
272
|
+
absoluteImagePath=[absoluteImagePath stringByReplacingOccurrencesOfString:@"file://"
|
|
273
|
+
withString:@""];
|
|
274
|
+
}
|
|
275
|
+
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
276
|
+
|
|
277
|
+
BOOL isDir;
|
|
278
|
+
if (![fileManager fileExistsAtPath:absoluteImagePath isDirectory:&isDir] || isDir){
|
|
279
|
+
NSError *err = [NSError errorWithDomain:@"file not found" code:-15 userInfo:nil];
|
|
280
|
+
reject([NSString stringWithFormat: @"%lu", (long)err.code], err.localizedDescription, err);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
NSDictionary *attrs = [fileManager attributesOfItemAtPath: absoluteImagePath error: NULL];
|
|
284
|
+
UInt32 fileSize = [attrs fileSize];
|
|
285
|
+
NSString *fileSizeString = [@(fileSize) stringValue];
|
|
286
|
+
|
|
287
|
+
NSMutableDictionary *result = [NSMutableDictionary new];
|
|
288
|
+
NSDictionary *assetOptions = @{AVURLAssetPreferPreciseDurationAndTimingKey: @YES};
|
|
289
|
+
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:absoluteImagePath] options:assetOptions];\
|
|
290
|
+
AVAssetTrack *avAsset = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
|
|
291
|
+
CGSize size = [avAsset naturalSize];
|
|
292
|
+
NSString *extension = [[absoluteImagePath lastPathComponent] pathExtension];
|
|
293
|
+
CMTime time = [asset duration];
|
|
294
|
+
int seconds = ceil(time.value/time.timescale);
|
|
295
|
+
[result setObject:[NSString stringWithFormat: @"%.2f", size.width] forKey:@"width"];
|
|
296
|
+
[result setObject:[NSString stringWithFormat: @"%.2f", size.height] forKey:@"height"];
|
|
297
|
+
[result setObject:extension forKey:@"extension"];
|
|
298
|
+
[result setObject:fileSizeString forKey:@"size"];
|
|
299
|
+
[result setObject:[@(seconds) stringValue] forKey:@"duration"];
|
|
300
|
+
NSArray *keys = [NSArray arrayWithObjects:@"commonMetadata", nil];
|
|
301
|
+
[asset loadValuesAsynchronouslyForKeys:keys completionHandler:^{
|
|
302
|
+
// string keys
|
|
303
|
+
for (NSString *key in [self metadatas]) {
|
|
304
|
+
NSArray *items = [AVMetadataItem metadataItemsFromArray:asset.commonMetadata
|
|
305
|
+
withKey:key
|
|
306
|
+
keySpace:AVMetadataKeySpaceCommon];
|
|
307
|
+
for (AVMetadataItem *item in items) {
|
|
308
|
+
[result setObject:item.value forKey:key];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
resolve(result);
|
|
312
|
+
}];
|
|
313
|
+
}];
|
|
314
|
+
}
|
|
315
|
+
@catch (NSException *exception) {
|
|
316
|
+
reject(exception.name, exception.reason, nil);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
- (void)image_compress:(NSString *)imagePath optionMap:(NSDictionary *)optionMap resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
321
|
+
@try {
|
|
322
|
+
ImageCompressorOptions *options = [ImageCompressorOptions fromDictionary:optionMap];
|
|
323
|
+
[ImageCompressor getAbsoluteImagePath:imagePath uuid:options.uuid completionHandler:^(NSString* absoluteImagePath){
|
|
324
|
+
if(options.autoCompress)
|
|
325
|
+
{
|
|
326
|
+
NSString *result = [ImageCompressor autoCompressHandler:absoluteImagePath options:options];
|
|
327
|
+
resolve(result);
|
|
328
|
+
}
|
|
329
|
+
else
|
|
330
|
+
{
|
|
331
|
+
NSString *result = [ImageCompressor manualCompressHandler:absoluteImagePath options:options];
|
|
332
|
+
resolve(result);
|
|
333
|
+
}
|
|
334
|
+
[MediaCache removeCompletedImagePath:absoluteImagePath];
|
|
335
|
+
}];
|
|
336
|
+
|
|
337
|
+
}
|
|
338
|
+
@catch (NSException *exception) {
|
|
339
|
+
reject(exception.name, exception.reason, nil);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
- (void)getFileSize:(NSString *)filePath resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
344
|
+
@try {
|
|
345
|
+
if([filePath hasPrefix:@"http://"]||[filePath hasPrefix:@"https://"])
|
|
346
|
+
{
|
|
347
|
+
[ImageCompressor getFileSizeFromURL:filePath completion:^(NSNumber *fileSize, NSError *error) {
|
|
348
|
+
if (error) {
|
|
349
|
+
NSLog(@"Error: %@", error.localizedDescription);
|
|
350
|
+
} else {
|
|
351
|
+
NSLog(@"File size: %@", fileSize);
|
|
352
|
+
resolve(fileSize);
|
|
353
|
+
}
|
|
354
|
+
}];
|
|
355
|
+
|
|
356
|
+
}
|
|
357
|
+
else
|
|
358
|
+
{
|
|
359
|
+
if([filePath containsString:@"file://"])
|
|
360
|
+
{
|
|
361
|
+
filePath=[filePath stringByReplacingOccurrencesOfString:@"file://"
|
|
362
|
+
withString:@""];
|
|
363
|
+
}
|
|
364
|
+
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
365
|
+
BOOL isDir;
|
|
366
|
+
if (![fileManager fileExistsAtPath:filePath isDirectory:&isDir] || isDir){
|
|
367
|
+
NSError *err = [NSError errorWithDomain:@"file not found" code:-15 userInfo:nil];
|
|
368
|
+
reject([NSString stringWithFormat: @"%lu", (long)err.code], err.localizedDescription, err);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
NSDictionary *attrs = [fileManager attributesOfItemAtPath: filePath error: NULL];
|
|
372
|
+
UInt32 fileSize = [attrs fileSize];
|
|
373
|
+
NSString *fileSizeString = [@(fileSize) stringValue];
|
|
374
|
+
resolve(fileSizeString);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
}
|
|
378
|
+
@catch (NSException *exception) {
|
|
379
|
+
reject(exception.name, exception.reason, nil);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Don't compile this code when we build for the old architecture.
|
|
384
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
385
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
386
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
387
|
+
{
|
|
388
|
+
return std::make_shared<facebook::react::NativeCompressorSpecJSI>(params);
|
|
389
|
+
}
|
|
390
|
+
#endif
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
@end
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
@interface RCT_EXTERN_MODULE(VideoCompressor, RCTEventEmitter)
|
|
397
|
+
|
|
398
|
+
RCT_EXTERN_METHOD(compress:(NSString *)fileUrl
|
|
399
|
+
withOptions:(NSDictionary *)options
|
|
400
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
401
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
402
|
+
|
|
403
|
+
RCT_EXTERN_METHOD(upload:(NSString *)fileUrl
|
|
404
|
+
withOptions:(NSDictionary *)options
|
|
405
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
406
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
407
|
+
|
|
408
|
+
RCT_EXTERN_METHOD(activateBackgroundTask: (NSDictionary *)options
|
|
409
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
410
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
411
|
+
|
|
412
|
+
RCT_EXTERN_METHOD(deactivateBackgroundTask: (NSDictionary *)options
|
|
413
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
414
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
415
|
+
|
|
416
|
+
RCT_EXTERN_METHOD(cancelCompression:(NSString *)uuid)
|
|
417
|
+
|
|
418
|
+
// Don't compile this code when we build for the old architecture.
|
|
419
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
420
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
421
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
422
|
+
{
|
|
423
|
+
return std::make_shared<facebook::react::NativeVideoCompressorSpecJSI>(params);
|
|
424
|
+
}
|
|
425
|
+
#endif
|
|
426
|
+
|
|
427
|
+
@end
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
objects = {
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
|
-
|
|
10
|
+
5E555C0D2413F4C50049A1A2 /* Compressor.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* Compressor.mm */; };
|
|
11
11
|
/* End PBXBuildFile section */
|
|
12
12
|
|
|
13
13
|
/* Begin PBXCopyFilesBuildPhase section */
|
|
@@ -24,11 +24,8 @@
|
|
|
24
24
|
|
|
25
25
|
/* Begin PBXFileReference section */
|
|
26
26
|
134814201AA4EA6300B7C361 /* libCompressor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCompressor.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
27
|
-
188657B826612A1C006FF392 /* Compressor-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Compressor-Bridging-Header.h"; sourceTree = "<group>"; };
|
|
28
|
-
188657BA26612A1D006FF392 /* VideoCompressor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoCompressor.swift; sourceTree = "<group>"; };
|
|
29
|
-
18866CD1266E224C006FF392 /* Image */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Image; sourceTree = "<group>"; };
|
|
30
27
|
B3E7B5881CC2AC0600A0062D /* Compressor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Compressor.h; sourceTree = "<group>"; };
|
|
31
|
-
B3E7B5891CC2AC0600A0062D /* Compressor.
|
|
28
|
+
B3E7B5891CC2AC0600A0062D /* Compressor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Compressor.mm; sourceTree = "<group>"; };
|
|
32
29
|
/* End PBXFileReference section */
|
|
33
30
|
|
|
34
31
|
/* Begin PBXFrameworksBuildPhase section */
|
|
@@ -50,30 +47,11 @@
|
|
|
50
47
|
name = Products;
|
|
51
48
|
sourceTree = "<group>";
|
|
52
49
|
};
|
|
53
|
-
188657B5266127EC006FF392 /* Video */ = {
|
|
54
|
-
isa = PBXGroup;
|
|
55
|
-
children = (
|
|
56
|
-
188657BA26612A1D006FF392 /* VideoCompressor.swift */,
|
|
57
|
-
);
|
|
58
|
-
path = Video;
|
|
59
|
-
sourceTree = "<group>";
|
|
60
|
-
};
|
|
61
|
-
188657B7266127FF006FF392 /* Audio */ = {
|
|
62
|
-
isa = PBXGroup;
|
|
63
|
-
children = (
|
|
64
|
-
);
|
|
65
|
-
path = Audio;
|
|
66
|
-
sourceTree = "<group>";
|
|
67
|
-
};
|
|
68
50
|
58B511D21A9E6C8500147676 = {
|
|
69
51
|
isa = PBXGroup;
|
|
70
52
|
children = (
|
|
71
|
-
188657B826612A1C006FF392 /* Compressor-Bridging-Header.h */,
|
|
72
|
-
18866CD1266E224C006FF392 /* Image */,
|
|
73
|
-
188657B7266127FF006FF392 /* Audio */,
|
|
74
|
-
188657B5266127EC006FF392 /* Video */,
|
|
75
53
|
B3E7B5881CC2AC0600A0062D /* Compressor.h */,
|
|
76
|
-
B3E7B5891CC2AC0600A0062D /* Compressor.
|
|
54
|
+
B3E7B5891CC2AC0600A0062D /* Compressor.mm */,
|
|
77
55
|
134814211AA4EA7D00B7C361 /* Products */,
|
|
78
56
|
);
|
|
79
57
|
sourceTree = "<group>";
|
|
@@ -109,7 +87,6 @@
|
|
|
109
87
|
TargetAttributes = {
|
|
110
88
|
58B511DA1A9E6C8500147676 = {
|
|
111
89
|
CreatedOnToolsVersion = 6.1.1;
|
|
112
|
-
LastSwiftMigration = 1240;
|
|
113
90
|
};
|
|
114
91
|
};
|
|
115
92
|
};
|
|
@@ -136,7 +113,7 @@
|
|
|
136
113
|
isa = PBXSourcesBuildPhase;
|
|
137
114
|
buildActionMask = 2147483647;
|
|
138
115
|
files = (
|
|
139
|
-
|
|
116
|
+
B3E7B58A1CC2AC0600A0062D /* Compressor.mm in Sources */,
|
|
140
117
|
);
|
|
141
118
|
runOnlyForDeploymentPostprocessing = 0;
|
|
142
119
|
};
|
|
@@ -171,6 +148,7 @@
|
|
|
171
148
|
COPY_PHASE_STRIP = NO;
|
|
172
149
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
173
150
|
ENABLE_TESTABILITY = YES;
|
|
151
|
+
"EXCLUDED_ARCHS[sdk=*]" = arm64;
|
|
174
152
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
175
153
|
GCC_DYNAMIC_NO_PIC = NO;
|
|
176
154
|
GCC_NO_COMMON_BLOCKS = YES;
|
|
@@ -221,6 +199,7 @@
|
|
|
221
199
|
COPY_PHASE_STRIP = YES;
|
|
222
200
|
ENABLE_NS_ASSERTIONS = NO;
|
|
223
201
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
202
|
+
"EXCLUDED_ARCHS[sdk=*]" = arm64;
|
|
224
203
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
225
204
|
GCC_NO_COMMON_BLOCKS = YES;
|
|
226
205
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
@@ -239,41 +218,32 @@
|
|
|
239
218
|
58B511F01A9E6C8500147676 /* Debug */ = {
|
|
240
219
|
isa = XCBuildConfiguration;
|
|
241
220
|
buildSettings = {
|
|
242
|
-
CLANG_ENABLE_MODULES = YES;
|
|
243
221
|
HEADER_SEARCH_PATHS = (
|
|
244
222
|
"$(inherited)",
|
|
245
223
|
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
246
224
|
"$(SRCROOT)/../../../React/**",
|
|
247
225
|
"$(SRCROOT)/../../react-native/React/**",
|
|
248
226
|
);
|
|
249
|
-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
|
250
227
|
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
251
228
|
OTHER_LDFLAGS = "-ObjC";
|
|
252
229
|
PRODUCT_NAME = Compressor;
|
|
253
230
|
SKIP_INSTALL = YES;
|
|
254
|
-
SWIFT_OBJC_BRIDGING_HEADER = "Video/Compressor-Bridging-Header.h";
|
|
255
|
-
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
|
256
|
-
SWIFT_VERSION = 5.0;
|
|
257
231
|
};
|
|
258
232
|
name = Debug;
|
|
259
233
|
};
|
|
260
234
|
58B511F11A9E6C8500147676 /* Release */ = {
|
|
261
235
|
isa = XCBuildConfiguration;
|
|
262
236
|
buildSettings = {
|
|
263
|
-
CLANG_ENABLE_MODULES = YES;
|
|
264
237
|
HEADER_SEARCH_PATHS = (
|
|
265
238
|
"$(inherited)",
|
|
266
239
|
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
267
240
|
"$(SRCROOT)/../../../React/**",
|
|
268
241
|
"$(SRCROOT)/../../react-native/React/**",
|
|
269
242
|
);
|
|
270
|
-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
|
271
243
|
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
272
244
|
OTHER_LDFLAGS = "-ObjC";
|
|
273
245
|
PRODUCT_NAME = Compressor;
|
|
274
246
|
SKIP_INSTALL = YES;
|
|
275
|
-
SWIFT_OBJC_BRIDGING_HEADER = "Video/Compressor-Bridging-Header.h";
|
|
276
|
-
SWIFT_VERSION = 5.0;
|
|
277
247
|
};
|
|
278
248
|
name = Release;
|
|
279
249
|
};
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
#import <UIKit/UIKit.h>
|
|
2
|
-
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
3
|
+
#import "Compressor.h"
|
|
3
4
|
#import "ImageCompressorOptions.h"
|
|
4
5
|
|
|
5
|
-
@interface ImageCompressor : NSObject
|
|
6
|
+
@interface ImageCompressor : RCTEventEmitter<NSObject>
|
|
6
7
|
+ (UIImage *)decodeImage:(NSString *)base64;
|
|
7
8
|
+ (UIImage *)loadImage:(NSString *)path;
|
|
8
9
|
+ (NSString *)generateCacheFilePath:(NSString *)extension;
|
|
9
10
|
|
|
10
11
|
+ (UIImage *)manualResize:(UIImage *)image maxWidth:(int)maxWidth maxHeight:(int)maxHeight;
|
|
11
|
-
+(NSString *)manualCompressHandler:(NSString *)imagePath options:(ImageCompressorOptions*)options;
|
|
12
|
-
+(NSString *)autoCompressHandler:(NSString *)imagePath options:(ImageCompressorOptions*)options;
|
|
13
|
-
+ (NSString *)manualCompress:(UIImage *)image output:(enum OutputType)output quality:(float)quality outputExtension:(NSString*)outputExtension isBase64:(Boolean)isBase64;
|
|
12
|
+
+ (NSString *)manualCompressHandler:(NSString *)imagePath options:(ImageCompressorOptions *)options;
|
|
13
|
+
+ (NSString *)autoCompressHandler:(NSString *)imagePath options:(ImageCompressorOptions *)options;
|
|
14
|
+
+ (NSString *)manualCompress:(UIImage *)image output:(enum OutputType)output quality:(float)quality outputExtension:(NSString *)outputExtension isBase64:(Boolean)isBase64;
|
|
14
15
|
+ (UIImage *)scaleAndRotateImage:(UIImage *)image;
|
|
15
|
-
+ (void)getAbsoluteImagePath:(NSString *)imagePath completionHandler:(void (^)(NSString *absoluteImagePath))completionHandler;
|
|
16
|
-
+(void)getAbsoluteVideoPath:(NSString *)videoPath completionHandler:(void (^)(NSString *absoluteImagePath))completionHandler;
|
|
16
|
+
+ (void)getAbsoluteImagePath:(NSString *)imagePath uuid:(NSString *)uuid completionHandler:(void (^)(NSString *absoluteImagePath))completionHandler;
|
|
17
|
+
+ (void)getAbsoluteVideoPath:(NSString *)videoPath uuid:(NSString *)uuid completionHandler:(void (^)(NSString *absoluteImagePath))completionHandler;
|
|
18
|
+
+ (void)downloadFileAndSaveToCache:(NSString *)fileUrl;
|
|
19
|
+
+ (void)getFileSizeFromURL:(NSString *)urlString completion:(void (^)(NSNumber *fileSize, NSError *error))completion;
|
|
20
|
+
+ (void)initCompressorInstance:(Compressor*)instance;
|
|
21
|
+
+ (void)initVideoCompressorInstance:(id)object;
|
|
17
22
|
@end
|