diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncFFmpegExecuteTask.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncFFmpegExecuteTask.java index f1f0cce..56c4d30 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncFFmpegExecuteTask.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncFFmpegExecuteTask.java @@ -19,6 +19,8 @@ package com.arthenica.ffmpegkit; +import com.arthenica.smartexception.java.Exceptions; + /** *

Executes an FFmpeg session asynchronously. */ @@ -35,13 +37,23 @@ public class AsyncFFmpegExecuteTask implements Runnable { public void run() { FFmpegKitConfig.ffmpegExecute(ffmpegSession); - final ExecuteCallback globalExecuteCallbackFunction = FFmpegKitConfig.getExecuteCallback(); - if (globalExecuteCallbackFunction != null) { - globalExecuteCallbackFunction.apply(ffmpegSession); + if (executeCallback != null) { + try { + // NOTIFY SESSION CALLBACK DEFINED + executeCallback.apply(ffmpegSession); + } catch (final Exception e) { + android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); + } } - if (executeCallback != null) { - executeCallback.apply(ffmpegSession); + final ExecuteCallback globalExecuteCallbackFunction = FFmpegKitConfig.getExecuteCallback(); + if (globalExecuteCallbackFunction != null) { + try { + // NOTIFY GLOBAL CALLBACK DEFINED + globalExecuteCallbackFunction.apply(ffmpegSession); + } catch (final Exception e) { + android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); + } } } } diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncFFprobeExecuteTask.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncFFprobeExecuteTask.java index dafb86d..74182c9 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncFFprobeExecuteTask.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncFFprobeExecuteTask.java @@ -19,6 +19,8 @@ package com.arthenica.ffmpegkit; +import com.arthenica.smartexception.java.Exceptions; + /** *

Executes an FFprobe session asynchronously. */ @@ -35,13 +37,23 @@ public class AsyncFFprobeExecuteTask implements Runnable { public void run() { FFmpegKitConfig.ffprobeExecute(ffprobeSession); - final ExecuteCallback globalExecuteCallbackFunction = FFmpegKitConfig.getExecuteCallback(); - if (globalExecuteCallbackFunction != null) { - globalExecuteCallbackFunction.apply(ffprobeSession); + if (executeCallback != null) { + try { + // NOTIFY SESSION CALLBACK DEFINED + executeCallback.apply(ffprobeSession); + } catch (final Exception e) { + android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); + } } - if (executeCallback != null) { - executeCallback.apply(ffprobeSession); + final ExecuteCallback globalExecuteCallbackFunction = FFmpegKitConfig.getExecuteCallback(); + if (globalExecuteCallbackFunction != null) { + try { + // NOTIFY GLOBAL CALLBACK DEFINED + globalExecuteCallbackFunction.apply(ffprobeSession); + } catch (final Exception e) { + android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); + } } } diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncGetMediaInformationTask.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncGetMediaInformationTask.java index fe3368f..c59d81d 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncGetMediaInformationTask.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AsyncGetMediaInformationTask.java @@ -19,6 +19,8 @@ package com.arthenica.ffmpegkit; +import com.arthenica.smartexception.java.Exceptions; + /** *

Executes a MediaInformation session asynchronously. */ @@ -41,13 +43,23 @@ public class AsyncGetMediaInformationTask implements Runnable { public void run() { FFmpegKitConfig.getMediaInformationExecute(mediaInformationSession, waitTimeout); - final ExecuteCallback globalExecuteCallbackFunction = FFmpegKitConfig.getExecuteCallback(); - if (globalExecuteCallbackFunction != null) { - globalExecuteCallbackFunction.apply(mediaInformationSession); + if (executeCallback != null) { + try { + // NOTIFY SESSION CALLBACK DEFINED + executeCallback.apply(mediaInformationSession); + } catch (final Exception e) { + android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); + } } - if (executeCallback != null) { - executeCallback.apply(mediaInformationSession); + final ExecuteCallback globalExecuteCallbackFunction = FFmpegKitConfig.getExecuteCallback(); + if (globalExecuteCallbackFunction != null) { + try { + // NOTIFY GLOBAL CALLBACK DEFINEDs + globalExecuteCallbackFunction.apply(mediaInformationSession); + } catch (final Exception e) { + android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); + } } } diff --git a/apple/src/FFmpegKitConfig.m b/apple/src/FFmpegKitConfig.m index 4d12649..8896186 100644 --- a/apple/src/FFmpegKitConfig.m +++ b/apple/src/FFmpegKitConfig.m @@ -990,7 +990,7 @@ int executeFFprobe(long sessionId, NSArray* arguments) { int returnCodeValue = executeFFprobe([mediaInformationSession getSessionId], [mediaInformationSession getArguments]); ReturnCode* returnCode = [[ReturnCode alloc] init:returnCodeValue]; [mediaInformationSession complete:returnCode]; - if ([returnCode isSuccess]) { + if ([returnCode isValueSuccess]) { MediaInformation* mediaInformation = [MediaInformationJsonParser from:[mediaInformationSession getAllLogsAsStringWithTimeout:waitTimeout]]; [mediaInformationSession setMediaInformation:mediaInformation]; } @@ -1007,14 +1007,27 @@ int executeFFprobe(long sessionId, NSArray* arguments) { + (void)asyncFFmpegExecute:(FFmpegSession*)ffmpegSession onDispatchQueue:(dispatch_queue_t)queue { dispatch_async(queue, ^{ [FFmpegKitConfig ffmpegExecute:ffmpegSession]; - ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; - if (globalExecuteCallback != nil) { - globalExecuteCallback(ffmpegSession); - } - + ExecuteCallback sessionExecuteCallback = [ffmpegSession getExecuteCallback]; if (sessionExecuteCallback != nil) { - sessionExecuteCallback(ffmpegSession); + @try { + // NOTIFY SESSION CALLBACK DEFINED + sessionExecuteCallback(ffmpegSession); + } + @catch(NSException* exception) { + NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); + } + } + + ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; + if (globalExecuteCallback != nil) { + @try { + // NOTIFY SESSION CALLBACK DEFINED + globalExecuteCallback(ffmpegSession); + } + @catch(NSException* exception) { + NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); + } } }); } @@ -1026,14 +1039,27 @@ int executeFFprobe(long sessionId, NSArray* arguments) { + (void)asyncFFprobeExecute:(FFprobeSession*)ffprobeSession onDispatchQueue:(dispatch_queue_t)queue { dispatch_async(queue, ^{ [FFmpegKitConfig ffprobeExecute:ffprobeSession]; - ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; - if (globalExecuteCallback != nil) { - globalExecuteCallback(ffprobeSession); - } - + ExecuteCallback sessionExecuteCallback = [ffprobeSession getExecuteCallback]; if (sessionExecuteCallback != nil) { - sessionExecuteCallback(ffprobeSession); + @try { + // NOTIFY SESSION CALLBACK DEFINED + sessionExecuteCallback(ffprobeSession); + } + @catch(NSException* exception) { + NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); + } + } + + ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; + if (globalExecuteCallback != nil) { + @try { + // NOTIFY SESSION CALLBACK DEFINED + globalExecuteCallback(ffprobeSession); + } + @catch(NSException* exception) { + NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); + } } }); } @@ -1045,14 +1071,27 @@ int executeFFprobe(long sessionId, NSArray* arguments) { + (void)asyncGetMediaInformationExecute:(MediaInformationSession*)mediaInformationSession onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { dispatch_async(queue, ^{ [FFmpegKitConfig getMediaInformationExecute:mediaInformationSession withTimeout:waitTimeout]; - ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; - if (globalExecuteCallback != nil) { - globalExecuteCallback(mediaInformationSession); - } - + ExecuteCallback sessionExecuteCallback = [mediaInformationSession getExecuteCallback]; if (sessionExecuteCallback != nil) { - sessionExecuteCallback(mediaInformationSession); + @try { + // NOTIFY SESSION CALLBACK DEFINED + sessionExecuteCallback(mediaInformationSession); + } + @catch(NSException* exception) { + NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); + } + } + + ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; + if (globalExecuteCallback != nil) { + @try { + // NOTIFY SESSION CALLBACK DEFINED + globalExecuteCallback(mediaInformationSession); + } + @catch(NSException* exception) { + NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); + } } }); }