call session callbacks first rather than global callbacks on native platforms
This commit is contained in:
parent
fc747666c5
commit
1cb36ea365
@ -19,6 +19,8 @@
|
||||
|
||||
package com.arthenica.ffmpegkit;
|
||||
|
||||
import com.arthenica.smartexception.java.Exceptions;
|
||||
|
||||
/**
|
||||
* <p>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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.arthenica.ffmpegkit;
|
||||
|
||||
import com.arthenica.smartexception.java.Exceptions;
|
||||
|
||||
/**
|
||||
* <p>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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.arthenica.ffmpegkit;
|
||||
|
||||
import com.arthenica.smartexception.java.Exceptions;
|
||||
|
||||
/**
|
||||
* <p>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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user