implement getSafParameter api method

This commit is contained in:
Taner Sener 2021-12-31 20:56:11 +00:00
parent ad744d396b
commit 1a998927f4
10 changed files with 122 additions and 101 deletions

View File

@ -1,3 +1,9 @@
## 4.5.1
- Bugfix release
## 4.5.1-LTS
- Bugfix LTS release
## 4.5.0
- Initial release

View File

@ -10,15 +10,15 @@
- `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
- `arm64` and `x86_64` architectures on macOS
- `macOS SDK 10.11+` or later
- `macOS SDK 10.12+` 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`
, `speex`, `twolame`, `vo-amrwbenc`, `zimg`
- 4 external libraries with GPL license
@ -32,7 +32,7 @@ Add `ffmpeg_kit_flutter` as a dependency in your `pubspec.yaml file`.
```yaml
dependencies:
ffmpeg_kit_flutter: ^4.5.0
ffmpeg_kit_flutter: ^4.5.1
```
#### 2.1 Packages
@ -55,7 +55,7 @@ using the following dependency format.
```yaml
dependencies:
ffmpeg_kit_flutter_<package name>: ^4.5.0
ffmpeg_kit_flutter_<package name>: ^4.5.1
```
Note that hyphens in the package name must be replaced with underscores. Additionally, do not forget to use the package
@ -67,7 +67,7 @@ In order to install the `LTS` variant, append `-LTS` to the version you have for
```yaml
dependencies:
ffmpeg_kit_flutter: 4.5.0-LTS
ffmpeg_kit_flutter: 4.5.1-LTS
```
#### 2.4 LTS Releases
@ -99,7 +99,7 @@ The following table shows the Android API level and iOS deployment target requir
<td align="center">24</td>
<td align="center">12.1</td>
<td align="center">16</td>
<td align="center">9.3</td>
<td align="center">10</td>
</tr>
</tbody>
</table>
@ -237,7 +237,7 @@ The following table shows the Android API level and iOS deployment target requir
});
```
8. Get previous `FFmpeg` and `FFprobe` sessions from the session history.
8. Get previous `FFmpeg`, `FFprobe` and `MediaInformation` sessions from the session history.
```dart
FFmpegKit.listSessions().then((sessionList) {
@ -246,7 +246,13 @@ The following table shows the Android API level and iOS deployment target requir
});
});
FFprobeKit.listSessions().then((sessionList) {
FFprobeKit.listFFprobeSessions().then((sessionList) {
sessionList.forEach((session) {
final sessionId = session.getSessionId();
});
});
FFprobeKit.listMediaInformationSessions().then((sessionList) {
sessionList.forEach((session) {
final sessionId = session.getSessionId();
});
@ -255,10 +261,18 @@ The following table shows the Android API level and iOS deployment target requir
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
```dart
FFmpegKitConfig.enableExecuteCallback((session) {
FFmpegKitConfig.enableFFmpegSessionCompleteCallback((session) {
final sessionId = session.getSessionId();
});
FFmpegKitConfig.enableFFprobeSessionCompleteCallback((session) {
final sessionId = session.getSessionId();
});
FFmpegKitConfig.enableMediaInformationSessionCompleteCallback((session) {
final sessionId = session.getSessionId();
});
```

View File

@ -17,8 +17,8 @@ android {
defaultConfig {
minSdkVersion 24
targetSdkVersion 30
versionCode 450
versionName "4.5.0"
versionCode 451
versionName "4.5.1"
}
buildTypes {
@ -43,6 +43,6 @@ repositories {
dependencies {
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'com.arthenica:ffmpeg-kit-https:4.5'
implementation 'com.arthenica:ffmpeg-kit-https:4.5.1'
}

View File

@ -600,10 +600,11 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
break;
case "getSafParameter":
final String uri = call.argument("uri");
if (writable != null && uri != null) {
getSafParameter(writable, uri, result);
final String openMode = call.argument("openMode");
if (uri != null && openMode != null) {
getSafParameter(uri, openMode, result);
} else if (uri != null) {
resultHandler.errorAsync(result, "INVALID_WRITABLE", "Invalid writable value.");
resultHandler.errorAsync(result, "INVALID_OPEN_MODE", "Invalid openMode value.");
} else {
resultHandler.errorAsync(result, "INVALID_URI", "Invalid uri value.");
}
@ -1238,32 +1239,27 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
}
}
protected void getSafParameter(@NonNull final Boolean writable, @NonNull final String uriString, @NonNull final Result result) {
protected void getSafParameter(@NonNull final String uriString, @NonNull final String openMode, @NonNull final Result result) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
android.util.Log.i(LIBRARY_NAME, String.format(Locale.getDefault(), "getSafParameter is not supported on API Level %d", Build.VERSION.SDK_INT));
resultHandler.errorAsync(result, "SELECT_FAILED", String.format(Locale.getDefault(), "getSafParameter is not supported on API Level %d", Build.VERSION.SDK_INT));
resultHandler.errorAsync(result, "GET_SAF_PARAMETER_FAILED", String.format(Locale.getDefault(), "getSafParameter is not supported on API Level %d", Build.VERSION.SDK_INT));
return;
}
if (context != null) {
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));
resultHandler.errorAsync(result, "GET_SAF_PARAMETER_FAILED", "Uri string cannot be parsed.");
} else {
final String safParameter;
if (writable) {
safParameter = FFmpegKitConfig.getSafParameterForWrite(context, uri);
} else {
safParameter = FFmpegKitConfig.getSafParameterForRead(context, uri);
}
final String safParameter = FFmpegKitConfig.getSafParameter(context, 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));
resultHandler.successAsync(result, safParameter);
}
} else {
Log.w(LIBRARY_NAME, String.format("Cannot getSafParameter using parameters writable: %s, uriString: %s. Context is null.", writable, uriString));
Log.w(LIBRARY_NAME, String.format("Cannot getSafParameter using parameters uriString: %s, openMode: %s. Context is null.", uriString, openMode));
resultHandler.errorAsync(result, "INVALID_CONTEXT", "Context is null.");
}
}

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ffmpeg_kit_flutter'
s.version = '4.5.0'
s.version = '4.5.1'
s.summary = 'FFmpeg Kit for Flutter'
s.description = 'A Flutter plugin for running FFmpeg and FFprobe commands.'
s.homepage = 'https://github.com/tanersener/ffmpeg-kit'
@ -23,113 +23,113 @@ Pod::Spec.new do |s|
s.subspec 'min' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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 = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.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

View File

@ -773,7 +773,7 @@ class FFmpegKitConfig {
static Future<String?> getSafParameterForRead(String uriString) async {
try {
await init();
return _platform.ffmpegKitConfigGetSafParameterForRead(uriString);
return _platform.ffmpegKitConfigGetSafParameter(uriString, "r");
} on PlatformException catch (e, stack) {
print("Plugin getSafParameterForRead error: ${e.message}");
return Future.error("getSafParameterForRead failed.", stack);
@ -789,10 +789,27 @@ class FFmpegKitConfig {
static Future<String?> getSafParameterForWrite(String uriString) async {
try {
await init();
return _platform.ffmpegKitConfigGetSafParameterForWrite(uriString);
return _platform.ffmpegKitConfigGetSafParameter(uriString, "w");
} on PlatformException catch (e, stack) {
print("Plugin getSafParameterForWrite error: ${e.message}");
return Future.error("getSafParameterForWrite failed.", stack);
}
}
/// 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 &ge; 19. On older API levels it
/// returns an empty url.
static Future<String?> getSafParameter(
String uriString, String openMode) async {
try {
await init();
return _platform.ffmpegKitConfigGetSafParameter(uriString, openMode);
} on PlatformException catch (e, stack) {
print("Plugin getSafParameter error: ${e.message}");
return Future.error("getSafParameter failed.", stack);
}
}
}

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ffmpeg_kit_flutter'
s.version = '4.5.0'
s.version = '4.5.1'
s.summary = 'FFmpeg Kit for Flutter'
s.description = 'A Flutter plugin for running FFmpeg and FFprobe commands.'
s.homepage = 'https://github.com/tanersener/ffmpeg-kit'
@ -23,113 +23,113 @@ Pod::Spec.new do |s|
s.subspec 'min' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-min', "4.5"
ss.dependency 'ffmpeg-kit-macos-min', "4.5.1"
ss.osx.deployment_target = '10.15'
end
s.subspec 'min-lts' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-min', "4.5.LTS"
ss.osx.deployment_target = '10.11'
ss.dependency 'ffmpeg-kit-macos-min', "4.5.1.LTS"
ss.osx.deployment_target = '10.12'
end
s.subspec 'min-gpl' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-min-gpl', "4.5"
ss.dependency 'ffmpeg-kit-macos-min-gpl', "4.5.1"
ss.osx.deployment_target = '10.15'
end
s.subspec 'min-gpl-lts' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-min-gpl', "4.5.LTS"
ss.osx.deployment_target = '10.11'
ss.dependency 'ffmpeg-kit-macos-min-gpl', "4.5.1.LTS"
ss.osx.deployment_target = '10.12'
end
s.subspec 'https' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-https', "4.5"
ss.dependency 'ffmpeg-kit-macos-https', "4.5.1"
ss.osx.deployment_target = '10.15'
end
s.subspec 'https-lts' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-https', "4.5.LTS"
ss.osx.deployment_target = '10.11'
ss.dependency 'ffmpeg-kit-macos-https', "4.5.1.LTS"
ss.osx.deployment_target = '10.12'
end
s.subspec 'https-gpl' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-https-gpl', "4.5"
ss.dependency 'ffmpeg-kit-macos-https-gpl', "4.5.1"
ss.osx.deployment_target = '10.15'
end
s.subspec 'https-gpl-lts' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-https-gpl', "4.5.LTS"
ss.osx.deployment_target = '10.11'
ss.dependency 'ffmpeg-kit-macos-https-gpl', "4.5.1.LTS"
ss.osx.deployment_target = '10.12'
end
s.subspec 'audio' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-audio', "4.5"
ss.dependency 'ffmpeg-kit-macos-audio', "4.5.1"
ss.osx.deployment_target = '10.15'
end
s.subspec 'audio-lts' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-audio', "4.5.LTS"
ss.osx.deployment_target = '10.11'
ss.dependency 'ffmpeg-kit-macos-audio', "4.5.1.LTS"
ss.osx.deployment_target = '10.12'
end
s.subspec 'video' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-video', "4.5"
ss.dependency 'ffmpeg-kit-macos-video', "4.5.1"
ss.osx.deployment_target = '10.15'
end
s.subspec 'video-lts' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-video', "4.5.LTS"
ss.osx.deployment_target = '10.11'
ss.dependency 'ffmpeg-kit-macos-video', "4.5.1.LTS"
ss.osx.deployment_target = '10.12'
end
s.subspec 'full' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-full', "4.5"
ss.dependency 'ffmpeg-kit-macos-full', "4.5.1"
ss.osx.deployment_target = '10.15'
end
s.subspec 'full-lts' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-full', "4.5.LTS"
ss.osx.deployment_target = '10.11'
ss.dependency 'ffmpeg-kit-macos-full', "4.5.1.LTS"
ss.osx.deployment_target = '10.12'
end
s.subspec 'full-gpl' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-full-gpl', "4.5"
ss.dependency 'ffmpeg-kit-macos-full-gpl', "4.5.1"
ss.osx.deployment_target = '10.15'
end
s.subspec 'full-gpl-lts' do |ss|
ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-full-gpl', "4.5.LTS"
ss.osx.deployment_target = '10.11'
ss.dependency 'ffmpeg-kit-macos-full-gpl', "4.5.1.LTS"
ss.osx.deployment_target = '10.12'
end
end

View File

@ -3,7 +3,7 @@ description: FFmpeg Kit for Flutter. Supports Android, iOS and macOS platforms.
repository: https://github.com/tanersener/ffmpeg-kit
issue_tracker: https://github.com/tanersener/ffmpeg-kit/issues
homepage: https://github.com/tanersener/ffmpeg-kit
version: 4.5.0
version: 4.5.1
environment:
sdk: ">=2.12.0 <3.0.0"
@ -21,7 +21,7 @@ flutter:
pluginClass: FFmpegKitFlutterPlugin
dependencies:
ffmpeg_kit_flutter_platform_interface: ^0.1.0
ffmpeg_kit_flutter_platform_interface: ^0.1.1
flutter:
sdk: flutter

View File

@ -330,16 +330,10 @@ abstract class FFmpegKitPlatform extends PlatformInterface {
'ffmpegKitConfigSelectDocumentForWrite() has not been implemented!');
}
Future<String?> ffmpegKitConfigGetSafParameterForRead(
String uriString) async {
Future<String?> ffmpegKitConfigGetSafParameter(
String uriString, String openMode) async {
throw UnimplementedError(
'ffmpegKitConfigGetSafParameterForRead() has not been implemented!');
}
Future<String?> ffmpegKitConfigGetSafParameterForWrite(
String uriString) async {
throw UnimplementedError(
'ffmpegKitConfigGetSafParameterForWrite() has not been implemented!');
'ffmpegKitConfigGetSafParameter() has not been implemented!');
}
// FFmpegKitFlutterInitializer

View File

@ -302,16 +302,10 @@ class MethodChannelFFmpegKit extends FFmpegKitPlatform {
});
@override
Future<String?> ffmpegKitConfigGetSafParameterForRead(
String uriString) async =>
Future<String?> ffmpegKitConfigGetSafParameter(
String uriString, String openMode) async =>
_channel.invokeMethod<String>(
'getSafParameter', {'writable': false, 'uri': uriString});
@override
Future<String?> ffmpegKitConfigGetSafParameterForWrite(
String uriString) async =>
_channel.invokeMethod<String>(
'getSafParameter', {'writable': true, 'uri': uriString});
'getSafParameter', {'uri': uriString, 'openMode': openMode});
// FFmpegKitFlutterInitializer