diff --git a/react-native/README.md b/react-native/README.md index 66f2281..6d4c8ce 100644 --- a/react-native/README.md +++ b/react-native/README.md @@ -8,11 +8,11 @@ - `arm-v7a`, `arm-v7a-neon`, `arm64-v8a`, `x86` and `x86_64` architectures on Android - `Android API Level 16` or later - `armv7`, `armv7s`, `arm64`, `arm64-simulator`, `i386`, `x86_64`, `x86_64-mac-catalyst` and `arm64-mac-catalyst` architectures on iOS - - `iOS SDK 9.3` or later + - `iOS SDK 10` or later - Can process Storage Access Framework (SAF) Uris on Android - - 24 external libraries + - 25 external libraries - `dav1d`, `fontconfig`, `freetype`, `fribidi`, `gmp`, `gnutls`, `kvazaar`, `lame`, `libass`, `libiconv`, `libilbc`, `libtheora`, `libvorbis`, `libvpx`, `libwebp`, `libxml2`, `opencore-amr`, `opus`, `shine`, `snappy`, `soxr`, `speex`, `twolame`, `vo-amrwbenc` + `dav1d`, `fontconfig`, `freetype`, `fribidi`, `gmp`, `gnutls`, `kvazaar`, `lame`, `libass`, `libiconv`, `libilbc`, `libtheora`, `libvorbis`, `libvpx`, `libwebp`, `libxml2`, `opencore-amr`, `opus`, `shine`, `snappy`, `soxr`, `speex`, `twolame`, `vo-amrwbenc`, `zimg` - 4 external libraries with GPL license @@ -73,7 +73,7 @@ The following table shows all package names and their respective API levels, iOS 12.1 min-lts 16 -9.3 +10 min-gpl @@ -82,7 +82,7 @@ The following table shows all package names and their respective API levels, iOS 12.1 min-gpl-lts 16 -9.3 +10 https @@ -91,7 +91,7 @@ The following table shows all package names and their respective API levels, iOS 12.1 https-lts 16 -9.3 +10 https-gpl @@ -100,7 +100,7 @@ The following table shows all package names and their respective API levels, iOS 12.1 https-gpl-lts 16 -9.3 +10 audio @@ -109,7 +109,7 @@ The following table shows all package names and their respective API levels, iOS 12.1 audio-lts 16 -9.3 +10 video @@ -118,7 +118,7 @@ The following table shows all package names and their respective API levels, iOS 12.1 video-lts 16 -9.3 +10 full @@ -127,7 +127,7 @@ The following table shows all package names and their respective API levels, iOS 12.1 full-lts 16 -9.3 +10 full-gpl @@ -136,7 +136,7 @@ The following table shows all package names and their respective API levels, iOS 12.1 full-gpl-lts 16 -9.3 +10 @@ -323,7 +323,7 @@ compare to each other. }); ``` -8. Get previous `FFmpeg` and `FFprobe` sessions from the session history. +8. Get previous `FFmpeg`, `FFprobe` and `MediaInformation` sessions from the session history. ```js FFmpegKit.listSessions().then(sessionList => { @@ -332,7 +332,13 @@ compare to each other. }); }); - FFprobeKit.listSessions().then(sessionList => { + FFprobeKit.listFFprobeSessions().then(sessionList => { + sessionList.forEach(async session => { + const sessionId = session.getSessionId(); + }); + }); + + FFprobeKit.listMediaInformationSessions().then(sessionList => { sessionList.forEach(async session => { const sessionId = session.getSessionId(); }); @@ -340,10 +346,18 @@ compare to each other. ``` 9. Enable global callbacks. - - Execute Callback, called when an async execution is ended + - Session type specific Complete Callbacks, called when an async session has been completed ```js - FFmpegKitConfig.enableExecuteCallback(session => { + FFmpegKitConfig.enableFFmpegSessionCompleteCallback(session => { + const sessionId = session.getSessionId(); + }); + + FFmpegKitConfig.enableFFprobeSessionCompleteCallback(session => { + const sessionId = session.getSessionId(); + }); + + FFmpegKitConfig.enableMediaInformationSessionCompleteCallback(session => { const sessionId = session.getSessionId(); }); ``` diff --git a/react-native/android/build.gradle b/react-native/android/build.gradle index e51ec38..e509ee4 100644 --- a/react-native/android/build.gradle +++ b/react-native/android/build.gradle @@ -31,8 +31,8 @@ android { defaultConfig { minSdkVersion safeExtGet('ffmpegKitPackage', 'https').contains("-lts") ? 16 : 24 targetSdkVersion 30 - versionCode 450 - versionName "4.5.0" + versionCode 451 + versionName "4.5.1" } buildTypes { diff --git a/react-native/android/gradle.properties b/react-native/android/gradle.properties index 48aa8f1..389aa70 100644 --- a/react-native/android/gradle.properties +++ b/react-native/android/gradle.properties @@ -1,3 +1,3 @@ android.useAndroidX=true -ffmpegKit.android.main.version=4.5 -ffmpegKit.android.lts.version=4.5 +ffmpegKit.android.main.version=4.5.1-1 +ffmpegKit.android.lts.version=4.5.1-1 diff --git a/react-native/android/src/main/java/com/arthenica/ffmpegkit/reactnative/FFmpegKitReactNativeModule.java b/react-native/android/src/main/java/com/arthenica/ffmpegkit/reactnative/FFmpegKitReactNativeModule.java index 6f12fdd..17f3ee4 100644 --- a/react-native/android/src/main/java/com/arthenica/ffmpegkit/reactnative/FFmpegKitReactNativeModule.java +++ b/react-native/android/src/main/java/com/arthenica/ffmpegkit/reactnative/FFmpegKitReactNativeModule.java @@ -894,22 +894,18 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple } @ReactMethod - public void getSafParameter(final Boolean writable, final String uriString, final Promise promise) { + public void getSafParameter(final String uriString, final String openMode, final Promise promise) { final ReactApplicationContext reactContext = getReactApplicationContext(); final Uri uri = Uri.parse(uriString); if (uri == null) { - Log.w(LIBRARY_NAME, String.format("Cannot getSafParameter using parameters writable: %s, uriString: %s. Uri string cannot be parsed.", writable, uriString)); + Log.w(LIBRARY_NAME, String.format("Cannot getSafParameter using parameters uriString: %s, openMode: %s. Uri string cannot be parsed.", uriString, openMode)); promise.reject("GET_SAF_PARAMETER_FAILED", "Uri string cannot be parsed."); } else { final String safParameter; - if (writable) { - safParameter = FFmpegKitConfig.getSafParameterForWrite(reactContext, uri); - } else { - safParameter = FFmpegKitConfig.getSafParameterForRead(reactContext, uri); - } + safParameter = FFmpegKitConfig.getSafParameter(reactContext, uri, openMode); - Log.d(LIBRARY_NAME, String.format("getSafParameter using parameters writable: %s, uriString: %s completed with saf parameter: %s.", writable, uriString, safParameter)); + Log.d(LIBRARY_NAME, String.format("getSafParameter using parameters uriString: %s, openMode: %s completed with saf parameter: %s.", uriString, openMode, safParameter)); promise.resolve(safParameter); } @@ -994,19 +990,17 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple sessionMap.putDouble(KEY_SESSION_START_TIME, toLong(session.getStartTime())); sessionMap.putString(KEY_SESSION_COMMAND, session.getCommand()); - if (session.isFFprobe()) { - if (session.isMediaInformation()) { - final MediaInformationSession mediaInformationSession = (MediaInformationSession) session; - final MediaInformation mediaInformation = mediaInformationSession.getMediaInformation(); - if (mediaInformation != null) { - sessionMap.putMap(KEY_SESSION_MEDIA_INFORMATION, toMap(mediaInformation)); - } - sessionMap.putDouble(KEY_SESSION_TYPE, SESSION_TYPE_MEDIA_INFORMATION); - } else { - sessionMap.putDouble(KEY_SESSION_TYPE, SESSION_TYPE_FFPROBE); - } - } else { + if (session.isFFmpeg()) { sessionMap.putDouble(KEY_SESSION_TYPE, SESSION_TYPE_FFMPEG); + } else if (session.isFFprobe()) { + sessionMap.putDouble(KEY_SESSION_TYPE, SESSION_TYPE_FFPROBE); + } else if (session.isMediaInformation()) { + final MediaInformationSession mediaInformationSession = (MediaInformationSession) session; + final MediaInformation mediaInformation = mediaInformationSession.getMediaInformation(); + if (mediaInformation != null) { + sessionMap.putMap(KEY_SESSION_MEDIA_INFORMATION, toMap(mediaInformation)); + } + sessionMap.putDouble(KEY_SESSION_TYPE, SESSION_TYPE_MEDIA_INFORMATION); } return sessionMap; diff --git a/react-native/ffmpeg-kit-react-native.podspec b/react-native/ffmpeg-kit-react-native.podspec index e56aada..9df9380 100644 --- a/react-native/ffmpeg-kit-react-native.podspec +++ b/react-native/ffmpeg-kit-react-native.podspec @@ -23,113 +23,113 @@ Pod::Spec.new do |s| s.subspec 'min' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-min', "4.5" + ss.dependency 'ffmpeg-kit-ios-min', "4.5.1" ss.ios.deployment_target = '12.1' end s.subspec 'min-lts' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-min', "4.5.LTS" - ss.ios.deployment_target = '9.3' + ss.dependency 'ffmpeg-kit-ios-min', "4.5.1.LTS" + ss.ios.deployment_target = '10' end s.subspec 'min-gpl' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-min-gpl', "4.5" + ss.dependency 'ffmpeg-kit-ios-min-gpl', "4.5.1" ss.ios.deployment_target = '12.1' end s.subspec 'min-gpl-lts' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-min-gpl', "4.5.LTS" - ss.ios.deployment_target = '9.3' + ss.dependency 'ffmpeg-kit-ios-min-gpl', "4.5.1.LTS" + ss.ios.deployment_target = '10' end s.subspec 'https' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-https', "4.5" + ss.dependency 'ffmpeg-kit-ios-https', "4.5.1" ss.ios.deployment_target = '12.1' end s.subspec 'https-lts' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-https', "4.5.LTS" - ss.ios.deployment_target = '9.3' + ss.dependency 'ffmpeg-kit-ios-https', "4.5.1.LTS" + ss.ios.deployment_target = '10' end s.subspec 'https-gpl' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-https-gpl', "4.5" + ss.dependency 'ffmpeg-kit-ios-https-gpl', "4.5.1" ss.ios.deployment_target = '12.1' end s.subspec 'https-gpl-lts' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-https-gpl', "4.5.LTS" - ss.ios.deployment_target = '9.3' + ss.dependency 'ffmpeg-kit-ios-https-gpl', "4.5.1.LTS" + ss.ios.deployment_target = '10' end s.subspec 'audio' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-audio', "4.5" + ss.dependency 'ffmpeg-kit-ios-audio', "4.5.1" ss.ios.deployment_target = '12.1' end s.subspec 'audio-lts' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-audio', "4.5.LTS" - ss.ios.deployment_target = '9.3' + ss.dependency 'ffmpeg-kit-ios-audio', "4.5.1.LTS" + ss.ios.deployment_target = '10' end s.subspec 'video' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-video', "4.5" + ss.dependency 'ffmpeg-kit-ios-video', "4.5.1" ss.ios.deployment_target = '12.1' end s.subspec 'video-lts' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-video', "4.5.LTS" - ss.ios.deployment_target = '9.3' + ss.dependency 'ffmpeg-kit-ios-video', "4.5.1.LTS" + ss.ios.deployment_target = '10' end s.subspec 'full' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-full', "4.5" + ss.dependency 'ffmpeg-kit-ios-full', "4.5.1" ss.ios.deployment_target = '12.1' end s.subspec 'full-lts' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-full', "4.5.LTS" - ss.ios.deployment_target = '9.3' + ss.dependency 'ffmpeg-kit-ios-full', "4.5.1.LTS" + ss.ios.deployment_target = '10' end s.subspec 'full-gpl' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-full-gpl', "4.5" + ss.dependency 'ffmpeg-kit-ios-full-gpl', "4.5.1" ss.ios.deployment_target = '12.1' end s.subspec 'full-gpl-lts' do |ss| ss.source_files = '**/FFmpegKitReactNativeModule.m', '**/FFmpegKitReactNativeModule.h' - ss.dependency 'ffmpeg-kit-ios-full-gpl', "4.5.LTS" - ss.ios.deployment_target = '9.3' + ss.dependency 'ffmpeg-kit-ios-full-gpl', "4.5.1.LTS" + ss.ios.deployment_target = '10' end end diff --git a/react-native/ios/FFmpegKitReactNativeModule.m b/react-native/ios/FFmpegKitReactNativeModule.m index 839175c..d566474 100644 --- a/react-native/ios/FFmpegKitReactNativeModule.m +++ b/react-native/ios/FFmpegKitReactNativeModule.m @@ -637,7 +637,7 @@ RCT_EXPORT_METHOD(selectDocument:(BOOL)writable title:(NSString*)title type:(NSS reject(@"Not Supported", @"Not supported on iOS platform.", nil); } -RCT_EXPORT_METHOD(getSafParameter:(BOOL)writable uri:(NSString*)uriString resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { +RCT_EXPORT_METHOD(getSafParameter:(NSString*)uriString mode:(NSString*)openMode resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { reject(@"Not Supported", @"Not supported on iOS platform.", nil); } diff --git a/react-native/package.json b/react-native/package.json index 0d46320..e5fc263 100644 --- a/react-native/package.json +++ b/react-native/package.json @@ -1,6 +1,6 @@ { "name": "ffmpeg-kit-react-native", - "version": "4.5.0", + "version": "4.5.1", "description": "FFmpeg Kit for React Native", "main": "src/index", "types": "src/index.d.ts", diff --git a/react-native/src/index.d.ts b/react-native/src/index.d.ts index d856480..839fc62 100644 --- a/react-native/src/index.d.ts +++ b/react-native/src/index.d.ts @@ -150,6 +150,12 @@ declare module 'ffmpeg-kit-react-native' { static setLogLevel(level: Level): Promise; + static getSafParameterForRead(uriString: String): Promise; + + static getSafParameterForWrite(uriString: String): Promise; + + static getSafParameter(uriString: String, openMode: String): Promise; + static getSessionHistorySize(): Promise; static setSessionHistorySize(sessionHistorySize: number): Promise; @@ -200,10 +206,6 @@ declare module 'ffmpeg-kit-react-native' { static selectDocumentForWrite(title?: string, type?: string, extraTypes?: string[]): Promise; - static getSafParameterForRead(uriString): Promise; - - static getSafParameterForWrite(uriString): Promise; - } export class FFmpegSession extends AbstractSession implements Session { diff --git a/react-native/src/index.js b/react-native/src/index.js index 958221f..298cd72 100644 --- a/react-native/src/index.js +++ b/react-native/src/index.js @@ -1156,6 +1156,54 @@ export class FFmpegKitConfig { return FFmpegKitReactNativeModule.setLogLevel(level); } + /** + *

Converts the given Structured Access Framework Uri into an input url that can be used in FFmpeg + * and FFprobe commands. + * + *

Note that this method is Android only. It will fail if called on other platforms. It also requires + * API Level ≥ 19. On older API levels it returns an empty url. + * + * @param uriString SAF uri ("content:…") + * @return input url that can be passed to FFmpegKit or FFprobeKit + */ + static async getSafParameterForRead(uriString) { + await FFmpegKitConfig.init(); + + return FFmpegKitReactNativeModule.getSafParameter(uriString, "r"); + } + + /** + *

Converts the given Structured Access Framework Uri into an output url that can be used in FFmpeg + * and FFprobe commands. + * + *

Note that this method is Android only. It will fail if called on other platforms. It also requires + * API Level ≥ 19. On older API levels it returns an empty url. + * + * @param uriString SAF uri ("content:…") + * @return output url that can be passed to FFmpegKit or FFprobeKit + */ + static async getSafParameterForWrite(uriString) { + await FFmpegKitConfig.init(); + + return FFmpegKitReactNativeModule.getSafParameter(uriString, "w"); + } + + /** + *

Converts the given Structured Access Framework Uri into an saf protocol url opened with the given open mode. + * + *

Note that this method is Android only. It will fail if called on other platforms. It also requires + * API Level ≥ 19. On older API levels it returns an empty url. + * + * @param uriString SAF uri ("content:…") + * @param openMode file mode to use as defined in Android Structured Access Framework documentation + * @return saf protocol url that can be passed to FFmpegKit or FFprobeKit + */ + static async getSafParameter(uriString, openMode) { + await FFmpegKitConfig.init(); + + return FFmpegKitReactNativeModule.getSafParameter(uriString, openMode); + } + /** * Returns the session history size. * @@ -1522,38 +1570,6 @@ export class FFmpegKitConfig { return FFmpegKitReactNativeModule.selectDocument(true, title, type, extraTypes); } - /** - *

Converts the given Structured Access Framework Uri into an input url that can be used in FFmpeg - * and FFprobe commands. - * - *

Note that this method is Android only. It will fail if called on other platforms. It also requires - * API Level ≥ 19. On older API levels it returns an empty url. - * - * @param uriString SAF uri ("content:…") - * @return input url that can be passed to FFmpegKit or FFprobeKit - */ - static async getSafParameterForRead(uriString) { - await FFmpegKitConfig.init(); - - return FFmpegKitReactNativeModule.getSafParameter(false, uriString); - } - - /** - *

Converts the given Structured Access Framework Uri into an output url that can be used in FFmpeg - * and FFprobe commands. - * - *

Note that this method is Android only. It will fail if called on other platforms. It also requires - * API Level ≥ 19. On older API levels it returns an empty url. - * - * @param uriString SAF uri ("content:…") - * @return output url that can be passed to FFmpegKit or FFprobeKit - */ - static async getSafParameterForWrite(uriString) { - await FFmpegKitConfig.init(); - - return FFmpegKitReactNativeModule.getSafParameter(true, uriString); - } - } class FFmpegKitFactory {