From bdb96010698e09f462aefa767f2c38e3e9df957d Mon Sep 17 00:00:00 2001 From: Taner Sener Date: Tue, 16 Feb 2021 16:33:28 +0000 Subject: [PATCH] add helper methods to ReturnCode --- .../src/main/java/com/arthenica/ffmpegkit/ReturnCode.java | 8 ++++++++ apple/src/ReturnCode.h | 4 ++++ apple/src/ReturnCode.m | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/ReturnCode.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/ReturnCode.java index cdd1094..a91ff9e 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/ReturnCode.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/ReturnCode.java @@ -31,6 +31,14 @@ public class ReturnCode { this.value = value; } + public static boolean isSuccess(final ReturnCode returnCode) { + return (returnCode != null && returnCode.getValue() == SUCCESS); + } + + public static boolean isCancel(final ReturnCode returnCode) { + return (returnCode != null && returnCode.getValue() == CANCEL); + } + public int getValue() { return value; } diff --git a/apple/src/ReturnCode.h b/apple/src/ReturnCode.h index 76fba7c..3d47ee4 100644 --- a/apple/src/ReturnCode.h +++ b/apple/src/ReturnCode.h @@ -31,6 +31,10 @@ typedef NS_ENUM(NSUInteger, ReturnCodeEnum) { - (instancetype)init:(int)value; ++ (BOOL)isSuccess:(ReturnCode*)value; + ++ (BOOL)isCancel:(ReturnCode*)value; + - (int)getValue; - (BOOL)isSuccess; diff --git a/apple/src/ReturnCode.m b/apple/src/ReturnCode.m index 3253007..3f65732 100644 --- a/apple/src/ReturnCode.m +++ b/apple/src/ReturnCode.m @@ -32,6 +32,14 @@ return self; } ++ (BOOL)isSuccess:(ReturnCode*)value { + return (value != nil) && ([value getValue] == ReturnCodeSuccess); +} + ++ (BOOL)isCancel:(ReturnCode*)value { + return (value != nil) && ([value getValue] == ReturnCodeCancel); +} + - (int)getValue { return _value; }