Skip to content

Commit

Permalink
implement getSafParameter api method
Browse files Browse the repository at this point in the history
  • Loading branch information
tanersener committed Dec 31, 2021
1 parent ad744d3 commit 1a99892
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 101 deletions.
6 changes: 6 additions & 0 deletions flutter/flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 4.5.1
- Bugfix release

## 4.5.1-LTS
- Bugfix LTS release

## 4.5.0
- Initial release

Expand Down
38 changes: 26 additions & 12 deletions flutter/flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
});
Expand All @@ -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();
});
```
Expand Down
6 changes: 3 additions & 3 deletions flutter/flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
defaultConfig {
minSdkVersion 24
targetSdkVersion 30
versionCode 450
versionName "4.5.0"
versionCode 451
versionName "4.5.1"
}

buildTypes {
Expand All @@ -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'
}

Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,11 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
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.");
}
Expand Down Expand Up @@ -1238,32 +1239,27 @@ protected void selectDocument(@NonNull final Boolean writable, @Nullable final S
}
}

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.");
}
}
Expand Down
50 changes: 25 additions & 25 deletions flutter/flutter/ios/ffmpeg_kit_flutter.podspec
Original file line number Diff line number Diff line change
@@ -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:/tanersener/ffmpeg-kit'
Expand All @@ -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
21 changes: 19 additions & 2 deletions flutter/flutter/lib/ffmpeg_kit_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
}
Loading

0 comments on commit 1a99892

Please sign in to comment.