replace execute callback with session specific complete callbacks, fixes #197

This commit is contained in:
Taner Sener 2021-12-23 23:10:13 +00:00
parent 6d1493d08d
commit 38d88e0c12
38 changed files with 1277 additions and 774 deletions

View File

@ -28,8 +28,8 @@ import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
/** /**
* Abstract session implementation which includes common features shared by <code>FFmpeg</code> * Abstract session implementation which includes common features shared by <code>FFmpeg</code>,
* and <code>FFprobe</code> sessions. * <code>FFprobe</code> and <code>MediaInformation</code> sessions.
*/ */
public abstract class AbstractSession implements Session { public abstract class AbstractSession implements Session {
@ -49,12 +49,7 @@ public abstract class AbstractSession implements Session {
protected final long sessionId; protected final long sessionId;
/** /**
* Session specific execute callback function. * Session specific log callback.
*/
protected final ExecuteCallback executeCallback;
/**
* Session specific log callback function.
*/ */
protected final LogCallback logCallback; protected final LogCallback logCallback;
@ -117,16 +112,13 @@ public abstract class AbstractSession implements Session {
* Creates a new abstract session. * Creates a new abstract session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback function * @param logCallback session specific log callback
* @param logCallback session specific log callback function
* @param logRedirectionStrategy session specific log redirection strategy * @param logRedirectionStrategy session specific log redirection strategy
*/ */
public AbstractSession(final String[] arguments, public AbstractSession(final String[] arguments,
final ExecuteCallback executeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final LogRedirectionStrategy logRedirectionStrategy) { final LogRedirectionStrategy logRedirectionStrategy) {
this.sessionId = sessionIdGenerator.getAndIncrement(); this.sessionId = sessionIdGenerator.getAndIncrement();
this.executeCallback = executeCallback;
this.logCallback = logCallback; this.logCallback = logCallback;
this.createTime = new Date(); this.createTime = new Date();
this.startTime = null; this.startTime = null;
@ -143,11 +135,6 @@ public abstract class AbstractSession implements Session {
FFmpegKitConfig.addSession(this); FFmpegKitConfig.addSession(this);
} }
@Override
public ExecuteCallback getExecuteCallback() {
return executeCallback;
}
@Override @Override
public LogCallback getLogCallback() { public LogCallback getLogCallback() {
return logCallback; return logCallback;

View File

@ -26,33 +26,33 @@ import com.arthenica.smartexception.java.Exceptions;
*/ */
public class AsyncFFmpegExecuteTask implements Runnable { public class AsyncFFmpegExecuteTask implements Runnable {
private final FFmpegSession ffmpegSession; private final FFmpegSession ffmpegSession;
private final ExecuteCallback executeCallback; private final FFmpegSessionCompleteCallback completeCallback;
public AsyncFFmpegExecuteTask(final FFmpegSession ffmpegSession) { public AsyncFFmpegExecuteTask(final FFmpegSession ffmpegSession) {
this.ffmpegSession = ffmpegSession; this.ffmpegSession = ffmpegSession;
this.executeCallback = ffmpegSession.getExecuteCallback(); this.completeCallback = ffmpegSession.getCompleteCallback();
} }
@Override @Override
public void run() { public void run() {
FFmpegKitConfig.ffmpegExecute(ffmpegSession); FFmpegKitConfig.ffmpegExecute(ffmpegSession);
if (executeCallback != null) { if (completeCallback != null) {
try { try {
// NOTIFY SESSION CALLBACK DEFINED // NOTIFY SESSION CALLBACK DEFINED
executeCallback.apply(ffmpegSession); completeCallback.apply(ffmpegSession);
} catch (final Exception e) { } catch (final Exception e) {
android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session complete callback.%s", Exceptions.getStackTraceString(e)));
} }
} }
final ExecuteCallback globalExecuteCallbackFunction = FFmpegKitConfig.getExecuteCallback(); final FFmpegSessionCompleteCallback globalFFmpegSessionCompleteCallback = FFmpegKitConfig.getFFmpegSessionCompleteCallback();
if (globalExecuteCallbackFunction != null) { if (globalFFmpegSessionCompleteCallback != null) {
try { try {
// NOTIFY GLOBAL CALLBACK DEFINED // NOTIFY GLOBAL CALLBACK DEFINED
globalExecuteCallbackFunction.apply(ffmpegSession); globalFFmpegSessionCompleteCallback.apply(ffmpegSession);
} catch (final Exception e) { } catch (final Exception e) {
android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global complete callback.%s", Exceptions.getStackTraceString(e)));
} }
} }
} }

View File

@ -26,33 +26,33 @@ import com.arthenica.smartexception.java.Exceptions;
*/ */
public class AsyncFFprobeExecuteTask implements Runnable { public class AsyncFFprobeExecuteTask implements Runnable {
private final FFprobeSession ffprobeSession; private final FFprobeSession ffprobeSession;
private final ExecuteCallback executeCallback; private final FFprobeSessionCompleteCallback completeCallback;
public AsyncFFprobeExecuteTask(final FFprobeSession ffprobeSession) { public AsyncFFprobeExecuteTask(final FFprobeSession ffprobeSession) {
this.ffprobeSession = ffprobeSession; this.ffprobeSession = ffprobeSession;
this.executeCallback = ffprobeSession.getExecuteCallback(); this.completeCallback = ffprobeSession.getCompleteCallback();
} }
@Override @Override
public void run() { public void run() {
FFmpegKitConfig.ffprobeExecute(ffprobeSession); FFmpegKitConfig.ffprobeExecute(ffprobeSession);
if (executeCallback != null) { if (completeCallback != null) {
try { try {
// NOTIFY SESSION CALLBACK DEFINED // NOTIFY SESSION CALLBACK DEFINED
executeCallback.apply(ffprobeSession); completeCallback.apply(ffprobeSession);
} catch (final Exception e) { } catch (final Exception e) {
android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session complete callback.%s", Exceptions.getStackTraceString(e)));
} }
} }
final ExecuteCallback globalExecuteCallbackFunction = FFmpegKitConfig.getExecuteCallback(); final FFprobeSessionCompleteCallback globalFFprobeSessionCompleteCallback = FFmpegKitConfig.getFFprobeSessionCompleteCallback();
if (globalExecuteCallbackFunction != null) { if (globalFFprobeSessionCompleteCallback != null) {
try { try {
// NOTIFY GLOBAL CALLBACK DEFINED // NOTIFY GLOBAL CALLBACK DEFINED
globalExecuteCallbackFunction.apply(ffprobeSession); globalFFprobeSessionCompleteCallback.apply(ffprobeSession);
} catch (final Exception e) { } catch (final Exception e) {
android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global complete callback.%s", Exceptions.getStackTraceString(e)));
} }
} }
} }

View File

@ -26,7 +26,7 @@ import com.arthenica.smartexception.java.Exceptions;
*/ */
public class AsyncGetMediaInformationTask implements Runnable { public class AsyncGetMediaInformationTask implements Runnable {
private final MediaInformationSession mediaInformationSession; private final MediaInformationSession mediaInformationSession;
private final ExecuteCallback executeCallback; private final MediaInformationSessionCompleteCallback completeCallback;
private final Integer waitTimeout; private final Integer waitTimeout;
public AsyncGetMediaInformationTask(final MediaInformationSession mediaInformationSession) { public AsyncGetMediaInformationTask(final MediaInformationSession mediaInformationSession) {
@ -35,7 +35,7 @@ public class AsyncGetMediaInformationTask implements Runnable {
public AsyncGetMediaInformationTask(final MediaInformationSession mediaInformationSession, final Integer waitTimeout) { public AsyncGetMediaInformationTask(final MediaInformationSession mediaInformationSession, final Integer waitTimeout) {
this.mediaInformationSession = mediaInformationSession; this.mediaInformationSession = mediaInformationSession;
this.executeCallback = mediaInformationSession.getExecuteCallback(); this.completeCallback = mediaInformationSession.getCompleteCallback();
this.waitTimeout = waitTimeout; this.waitTimeout = waitTimeout;
} }
@ -43,22 +43,22 @@ public class AsyncGetMediaInformationTask implements Runnable {
public void run() { public void run() {
FFmpegKitConfig.getMediaInformationExecute(mediaInformationSession, waitTimeout); FFmpegKitConfig.getMediaInformationExecute(mediaInformationSession, waitTimeout);
if (executeCallback != null) { if (completeCallback != null) {
try { try {
// NOTIFY SESSION CALLBACK DEFINED // NOTIFY SESSION CALLBACK DEFINED
executeCallback.apply(mediaInformationSession); completeCallback.apply(mediaInformationSession);
} catch (final Exception e) { } catch (final Exception e) {
android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session complete callback.%s", Exceptions.getStackTraceString(e)));
} }
} }
final ExecuteCallback globalExecuteCallbackFunction = FFmpegKitConfig.getExecuteCallback(); final MediaInformationSessionCompleteCallback globalMediaInformationSessionCompleteCallback = FFmpegKitConfig.getMediaInformationSessionCompleteCallback();
if (globalExecuteCallbackFunction != null) { if (globalMediaInformationSessionCompleteCallback != null) {
try { try {
// NOTIFY GLOBAL CALLBACK DEFINEDs // NOTIFY GLOBAL CALLBACK DEFINEDs
globalExecuteCallbackFunction.apply(mediaInformationSession); globalMediaInformationSessionCompleteCallback.apply(mediaInformationSession);
} catch (final Exception e) { } catch (final Exception e) {
android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global ExecuteCallback block.%s", Exceptions.getStackTraceString(e))); android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global complete callback.%s", Exceptions.getStackTraceString(e)));
} }
} }
} }

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2018-2021 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.ffmpegkit;
/**
* <p>Callback function invoked when an asynchronous session ends running.
* <p>Session has either {@link SessionState#COMPLETED} or {@link SessionState#FAILED} state when
* the callback is invoked.
* <p>If it has {@link SessionState#COMPLETED} state, <code>ReturnCode</code> should be checked to
* see the execution result.
* <p>If <code>getState</code> returns {@link SessionState#FAILED} then
* <code>getFailStackTrace</code> should be used to get the failure reason.
* <pre>
* switch (session.getState()) {
* case COMPLETED: {
* ReturnCode returnCode = session.getReturnCode();
* } break;
* case FAILED: {
* String failStackTrace = session.getFailStackTrace();
* } break;
* }
* </pre>
*/
@FunctionalInterface
public interface ExecuteCallback {
/**
* <p>Called when an asynchronous session ends running.
*
* @param session session
*/
void apply(final Session session);
}

View File

@ -23,16 +23,16 @@ import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
/** /**
* <p>Main class to run <code>FFmpeg</code> commands. Supports executing commands both synchronously and * <p>Main class to run <code>FFmpeg</code> commands. Supports executing commands both
* asynchronously. * synchronously and asynchronously.
* <pre> * <pre>
* FFmpegSession session = FFmpegKit.execute("-i file1.mp4 -c:v libxvid file1.avi"); * FFmpegSession session = FFmpegKit.execute("-i file1.mp4 -c:v libxvid file1.avi");
* *
* FFmpegSession asyncSession = FFmpegKit.executeAsync("-i file1.mp4 -c:v libxvid file1.avi", executeCallback); * FFmpegSession asyncSession = FFmpegKit.executeAsync("-i file1.mp4 -c:v libxvid file1.avi", completeCallback);
* </pre> * </pre>
* <p>Provides overloaded <code>execute</code> methods to define session specific callbacks. * <p>Provides overloaded <code>execute</code> methods to define session specific callbacks.
* <pre> * <pre>
* FFmpegSession asyncSession = FFmpegKit.executeAsync("-i file1.mp4 -c:v libxvid file1.avi", executeCallback, logCallback, statisticsCallback); * FFmpegSession asyncSession = FFmpegKit.executeAsync("-i file1.mp4 -c:v libxvid file1.avi", completeCallback, logCallback, statisticsCallback);
* </pre> * </pre>
*/ */
public class FFmpegKit { public class FFmpegKit {
@ -65,16 +65,17 @@ public class FFmpegKit {
/** /**
* <p>Starts an asynchronous FFmpeg execution with arguments provided. * <p>Starts an asynchronous FFmpeg execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFmpegSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param arguments FFmpeg command options/arguments as string array * @param arguments FFmpeg command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
public static FFmpegSession executeWithArgumentsAsync(final String[] arguments, public static FFmpegSession executeWithArgumentsAsync(final String[] arguments,
final ExecuteCallback executeCallback) { final FFmpegSessionCompleteCallback completeCallback) {
final FFmpegSession session = new FFmpegSession(arguments, executeCallback); final FFmpegSession session = new FFmpegSession(arguments, completeCallback);
FFmpegKitConfig.asyncFFmpegExecute(session); FFmpegKitConfig.asyncFFmpegExecute(session);
@ -84,20 +85,21 @@ public class FFmpegKit {
/** /**
* <p>Starts an asynchronous FFmpeg execution with arguments provided. * <p>Starts an asynchronous FFmpeg execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFmpegSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param arguments FFmpeg command options/arguments as string array * @param arguments FFmpeg command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param statisticsCallback callback that will receive statistics * @param statisticsCallback callback that will receive statistics
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
public static FFmpegSession executeWithArgumentsAsync(final String[] arguments, public static FFmpegSession executeWithArgumentsAsync(final String[] arguments,
final ExecuteCallback executeCallback, final FFmpegSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final StatisticsCallback statisticsCallback) { final StatisticsCallback statisticsCallback) {
final FFmpegSession session = new FFmpegSession(arguments, executeCallback, logCallback, statisticsCallback); final FFmpegSession session = new FFmpegSession(arguments, completeCallback, logCallback, statisticsCallback);
FFmpegKitConfig.asyncFFmpegExecute(session); FFmpegKitConfig.asyncFFmpegExecute(session);
@ -107,18 +109,19 @@ public class FFmpegKit {
/** /**
* <p>Starts an asynchronous FFmpeg execution with arguments provided. * <p>Starts an asynchronous FFmpeg execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFmpegSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param arguments FFmpeg command options/arguments as string array * @param arguments FFmpeg command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
public static FFmpegSession executeWithArgumentsAsync(final String[] arguments, public static FFmpegSession executeWithArgumentsAsync(final String[] arguments,
final ExecuteCallback executeCallback, final FFmpegSessionCompleteCallback completeCallback,
final ExecutorService executorService) { final ExecutorService executorService) {
final FFmpegSession session = new FFmpegSession(arguments, executeCallback); final FFmpegSession session = new FFmpegSession(arguments, completeCallback);
FFmpegKitConfig.asyncFFmpegExecute(session, executorService); FFmpegKitConfig.asyncFFmpegExecute(session, executorService);
@ -128,22 +131,24 @@ public class FFmpegKit {
/** /**
* <p>Starts an asynchronous FFmpeg execution with arguments provided. * <p>Starts an asynchronous FFmpeg execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFmpegSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param arguments FFmpeg command options/arguments as string array * @param arguments FFmpeg command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param statisticsCallback callback that will receive statistics * @param statisticsCallback callback that will receive statistics
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous
* operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
public static FFmpegSession executeWithArgumentsAsync(final String[] arguments, public static FFmpegSession executeWithArgumentsAsync(final String[] arguments,
final ExecuteCallback executeCallback, final FFmpegSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final StatisticsCallback statisticsCallback, final StatisticsCallback statisticsCallback,
final ExecutorService executorService) { final ExecutorService executorService) {
final FFmpegSession session = new FFmpegSession(arguments, executeCallback, logCallback, statisticsCallback); final FFmpegSession session = new FFmpegSession(arguments, completeCallback, logCallback, statisticsCallback);
FFmpegKitConfig.asyncFFmpegExecute(session, executorService); FFmpegKitConfig.asyncFFmpegExecute(session, executorService);
@ -163,57 +168,63 @@ public class FFmpegKit {
} }
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to
* into arguments. You can use single or double quote characters to specify arguments inside your command. * split the command into arguments. You can use single or double quote characters to specify
* arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFmpegSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param command FFmpeg command * @param command FFmpeg command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
public static FFmpegSession executeAsync(final String command, public static FFmpegSession executeAsync(final String command,
final ExecuteCallback executeCallback) { final FFmpegSessionCompleteCallback completeCallback) {
return executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), executeCallback); return executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), completeCallback);
} }
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to
* into arguments. You can use single or double quote characters to specify arguments inside your command. * split the command into arguments. You can use single or double quote characters to specify
* arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFmpegSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param command FFmpeg command * @param command FFmpeg command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param statisticsCallback callback that will receive statistics * @param statisticsCallback callback that will receive statistics
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
public static FFmpegSession executeAsync(final String command, public static FFmpegSession executeAsync(final String command,
final ExecuteCallback executeCallback, final FFmpegSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final StatisticsCallback statisticsCallback) { final StatisticsCallback statisticsCallback) {
return executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback, statisticsCallback); return executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback, statisticsCallback);
} }
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to
* into arguments. You can use single or double quote characters to specify arguments inside your command. * split the command into arguments. You can use single or double quote characters to specify
* arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFmpegSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param command FFmpeg command * @param command FFmpeg command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
public static FFmpegSession executeAsync(final String command, public static FFmpegSession executeAsync(final String command,
final ExecuteCallback executeCallback, final FFmpegSessionCompleteCallback completeCallback,
final ExecutorService executorService) { final ExecutorService executorService) {
final FFmpegSession session = new FFmpegSession(FFmpegKitConfig.parseArguments(command), executeCallback); final FFmpegSession session = new FFmpegSession(FFmpegKitConfig.parseArguments(command), completeCallback);
FFmpegKitConfig.asyncFFmpegExecute(session, executorService); FFmpegKitConfig.asyncFFmpegExecute(session, executorService);
@ -221,25 +232,27 @@ public class FFmpegKit {
} }
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to
* into arguments. You can use single or double quote characters to specify arguments inside your command. * split the command into arguments. You can use single or double quote characters to specify
* arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFmpegSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param command FFmpeg command * @param command FFmpeg command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param statisticsCallback callback that will receive statistics * @param statisticsCallback callback that will receive statistics
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
public static FFmpegSession executeAsync(final String command, public static FFmpegSession executeAsync(final String command,
final ExecuteCallback executeCallback, final FFmpegSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final StatisticsCallback statisticsCallback, final StatisticsCallback statisticsCallback,
final ExecutorService executorService) { final ExecutorService executorService) {
final FFmpegSession session = new FFmpegSession(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback, statisticsCallback); final FFmpegSession session = new FFmpegSession(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback, statisticsCallback);
FFmpegKitConfig.asyncFFmpegExecute(session, executorService); FFmpegKitConfig.asyncFFmpegExecute(session, executorService);
@ -249,7 +262,7 @@ public class FFmpegKit {
/** /**
* <p>Cancels all running sessions. * <p>Cancels all running sessions.
* *
* <p>This function does not wait for termination to complete and returns immediately. * <p>This method does not wait for termination to complete and returns immediately.
*/ */
public static void cancel() { public static void cancel() {
@ -264,7 +277,7 @@ public class FFmpegKit {
/** /**
* <p>Cancels the session specified with <code>sessionId</code>. * <p>Cancels the session specified with <code>sessionId</code>.
* *
* <p>This function does not wait for termination to complete and returns immediately. * <p>This method does not wait for termination to complete and returns immediately.
* *
* @param sessionId id of the session that will be cancelled * @param sessionId id of the session that will be cancelled
*/ */

View File

@ -120,9 +120,11 @@ public class FFmpegKitConfig {
private static ExecutorService asyncExecutorService; private static ExecutorService asyncExecutorService;
/* Global callbacks */ /* Global callbacks */
private static LogCallback globalLogCallbackFunction; private static LogCallback globalLogCallback;
private static StatisticsCallback globalStatisticsCallbackFunction; private static StatisticsCallback globalStatisticsCallback;
private static ExecuteCallback globalExecuteCallbackFunction; private static FFmpegSessionCompleteCallback globalFFmpegSessionCompleteCallback;
private static FFprobeSessionCompleteCallback globalFFprobeSessionCompleteCallback;
private static MediaInformationSessionCompleteCallback globalMediaInformationSessionCompleteCallback;
private static final SparseArray<SAFProtocolUrl> safIdMap; private static final SparseArray<SAFProtocolUrl> safIdMap;
private static final SparseArray<SAFProtocolUrl> safFileDescriptorMap; private static final SparseArray<SAFProtocolUrl> safFileDescriptorMap;
private static LogRedirectionStrategy globalLogRedirectionStrategy; private static LogRedirectionStrategy globalLogRedirectionStrategy;
@ -163,9 +165,11 @@ public class FFmpegKitConfig {
sessionHistoryList = new LinkedList<>(); sessionHistoryList = new LinkedList<>();
sessionHistoryLock = new Object(); sessionHistoryLock = new Object();
globalLogCallbackFunction = null; globalLogCallback = null;
globalStatisticsCallbackFunction = null; globalStatisticsCallback = null;
globalExecuteCallbackFunction = null; globalFFmpegSessionCompleteCallback = null;
globalFFprobeSessionCompleteCallback = null;
globalMediaInformationSessionCompleteCallback = null;
safIdMap = new SparseArray<>(); safIdMap = new SparseArray<>();
safFileDescriptorMap = new SparseArray<>(); safFileDescriptorMap = new SparseArray<>();
@ -239,12 +243,12 @@ public class FFmpegKitConfig {
// NOTIFY SESSION CALLBACK DEFINED // NOTIFY SESSION CALLBACK DEFINED
session.getLogCallback().apply(log); session.getLogCallback().apply(log);
} catch (final Exception e) { } catch (final Exception e) {
android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session LogCallback block.%s", Exceptions.getStackTraceString(e))); android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session log callback.%s", Exceptions.getStackTraceString(e)));
} }
} }
} }
final LogCallback globalLogCallbackFunction = FFmpegKitConfig.globalLogCallbackFunction; final LogCallback globalLogCallbackFunction = FFmpegKitConfig.globalLogCallback;
if (globalLogCallbackFunction != null) { if (globalLogCallbackFunction != null) {
globalCallbackDefined = true; globalCallbackDefined = true;
@ -252,7 +256,7 @@ public class FFmpegKitConfig {
// NOTIFY GLOBAL CALLBACK DEFINED // NOTIFY GLOBAL CALLBACK DEFINED
globalLogCallbackFunction.apply(log); globalLogCallbackFunction.apply(log);
} catch (final Exception e) { } catch (final Exception e) {
android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global LogCallback block.%s", Exceptions.getStackTraceString(e))); android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global log callback.%s", Exceptions.getStackTraceString(e)));
} }
} }
@ -345,18 +349,18 @@ public class FFmpegKitConfig {
// NOTIFY SESSION CALLBACK IF DEFINED // NOTIFY SESSION CALLBACK IF DEFINED
ffmpegSession.getStatisticsCallback().apply(statistics); ffmpegSession.getStatisticsCallback().apply(statistics);
} catch (final Exception e) { } catch (final Exception e) {
android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session StatisticsCallback block.%s", Exceptions.getStackTraceString(e))); android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside session statistics callback.%s", Exceptions.getStackTraceString(e)));
} }
} }
} }
final StatisticsCallback globalStatisticsCallbackFunction = FFmpegKitConfig.globalStatisticsCallbackFunction; final StatisticsCallback globalStatisticsCallbackFunction = FFmpegKitConfig.globalStatisticsCallback;
if (globalStatisticsCallbackFunction != null) { if (globalStatisticsCallbackFunction != null) {
try { try {
// NOTIFY GLOBAL CALLBACK IF DEFINED // NOTIFY GLOBAL CALLBACK IF DEFINED
globalStatisticsCallbackFunction.apply(statistics); globalStatisticsCallbackFunction.apply(statistics);
} catch (final Exception e) { } catch (final Exception e) {
android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global StatisticsCallback block.%s", Exceptions.getStackTraceString(e))); android.util.Log.e(FFmpegKitConfig.TAG, String.format("Exception thrown inside global statistics callback.%s", Exceptions.getStackTraceString(e)));
} }
} }
} }
@ -704,8 +708,9 @@ public class FFmpegKitConfig {
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given session. * <p>Starts an asynchronous FFmpeg execution for the given session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFmpegSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param ffmpegSession FFmpeg session which includes command options/arguments * @param ffmpegSession FFmpeg session which includes command options/arguments
*/ */
@ -718,8 +723,9 @@ public class FFmpegKitConfig {
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given session. * <p>Starts an asynchronous FFmpeg execution for the given session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFmpegSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param ffmpegSession FFmpeg session which includes command options/arguments * @param ffmpegSession FFmpeg session which includes command options/arguments
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
@ -733,8 +739,9 @@ public class FFmpegKitConfig {
/** /**
* <p>Starts an asynchronous FFprobe execution for the given session. * <p>Starts an asynchronous FFprobe execution for the given session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFprobeSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param ffprobeSession FFprobe session which includes command options/arguments * @param ffprobeSession FFprobe session which includes command options/arguments
*/ */
@ -747,8 +754,9 @@ public class FFmpegKitConfig {
/** /**
* <p>Starts an asynchronous FFprobe execution for the given session. * <p>Starts an asynchronous FFprobe execution for the given session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFprobeSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param ffprobeSession FFprobe session which includes command options/arguments * @param ffprobeSession FFprobe session which includes command options/arguments
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
@ -762,10 +770,12 @@ public class FFmpegKitConfig {
/** /**
* <p>Starts an asynchronous FFprobe execution for the given media information session. * <p>Starts an asynchronous FFprobe execution for the given media information session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use a {@link MediaInformationSessionCompleteCallback} if you want to be notified
* about the result.
* *
* @param mediaInformationSession media information session which includes command options/arguments * @param mediaInformationSession media information session which includes command
* options/arguments
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
*/ */
public static void asyncGetMediaInformationExecute(final MediaInformationSession mediaInformationSession, final int waitTimeout) { public static void asyncGetMediaInformationExecute(final MediaInformationSession mediaInformationSession, final int waitTimeout) {
@ -777,11 +787,14 @@ public class FFmpegKitConfig {
/** /**
* <p>Starts an asynchronous FFprobe execution for the given media information session. * <p>Starts an asynchronous FFprobe execution for the given media information session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use a {@link MediaInformationSessionCompleteCallback} if you want to be notified
* about the result.
* *
* @param mediaInformationSession media information session which includes command options/arguments * @param mediaInformationSession media information session which includes command
* @param executorService executor service that will be used to run this asynchronous operation * options/arguments
* @param executorService executor service that will be used to run this asynchronous
* operation
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
*/ */
public static void asyncGetMediaInformationExecute(final MediaInformationSession mediaInformationSession, final ExecutorService executorService, final int waitTimeout) { public static void asyncGetMediaInformationExecute(final MediaInformationSession mediaInformationSession, final ExecutorService executorService, final int waitTimeout) {
@ -822,42 +835,82 @@ public class FFmpegKitConfig {
} }
/** /**
* <p>Sets a global callback function to redirect FFmpeg/FFprobe logs. * <p>Sets a global callback to redirect FFmpeg/FFprobe logs.
* *
* @param logCallback log callback function or null to disable a previously defined * @param logCallback log callback or null to disable a previously defined callback
* callback
*/ */
public static void enableLogCallback(final LogCallback logCallback) { public static void enableLogCallback(final LogCallback logCallback) {
globalLogCallbackFunction = logCallback; globalLogCallback = logCallback;
} }
/** /**
* <p>Sets a global callback function to redirect FFmpeg statistics. * <p>Sets a global callback to redirect FFmpeg statistics.
* *
* @param statisticsCallback statistics callback function or null to disable a previously * @param statisticsCallback statistics callback or null to disable a previously
* defined callback * defined callback
*/ */
public static void enableStatisticsCallback(final StatisticsCallback statisticsCallback) { public static void enableStatisticsCallback(final StatisticsCallback statisticsCallback) {
globalStatisticsCallbackFunction = statisticsCallback; globalStatisticsCallback = statisticsCallback;
} }
/** /**
* <p>Sets a global callback function to receive execution results. * <p>Sets a global FFmpegSessionCompleteCallback to receive execution results for FFmpeg
* sessions.
* *
* @param executeCallback execute callback function or null to disable a previously * @param ffmpegSessionCompleteCallback complete callback or null to disable a
* defined callback * previously defined callback
*/ */
public static void enableExecuteCallback(final ExecuteCallback executeCallback) { public static void enableFFmpegSessionCompleteCallback(final FFmpegSessionCompleteCallback ffmpegSessionCompleteCallback) {
globalExecuteCallbackFunction = executeCallback; globalFFmpegSessionCompleteCallback = ffmpegSessionCompleteCallback;
} }
/** /**
* <p>Returns the global execute callback function. * <p>Returns the global FFmpegSessionCompleteCallback set.
* *
* @return global execute callback function * @return global FFmpegSessionCompleteCallback or null if it is not set
*/ */
static ExecuteCallback getExecuteCallback() { public static FFmpegSessionCompleteCallback getFFmpegSessionCompleteCallback() {
return globalExecuteCallbackFunction; return globalFFmpegSessionCompleteCallback;
}
/**
* <p>Sets a global FFprobeSessionCompleteCallback to receive execution results for FFprobe
* sessions.
*
* @param ffprobeSessionCompleteCallback complete callback or null to disable a
* previously defined callback
*/
public static void enableFFprobeSessionCompleteCallback(final FFprobeSessionCompleteCallback ffprobeSessionCompleteCallback) {
globalFFprobeSessionCompleteCallback = ffprobeSessionCompleteCallback;
}
/**
* <p>Returns the global FFprobeSessionCompleteCallback set.
*
* @return global FFprobeSessionCompleteCallback or null if it is not set
*/
public static FFprobeSessionCompleteCallback getFFprobeSessionCompleteCallback() {
return globalFFprobeSessionCompleteCallback;
}
/**
* <p>Sets a global MediaInformationSessionCompleteCallback to receive execution results for
* MediaInformation sessions.
*
* @param mediaInformationSessionCompleteCallback complete callback or null to disable
* a previously defined callback
*/
public static void enableMediaInformationSessionCompleteCallback(final MediaInformationSessionCompleteCallback mediaInformationSessionCompleteCallback) {
globalMediaInformationSessionCompleteCallback = mediaInformationSessionCompleteCallback;
}
/**
* <p>Returns the global MediaInformationSessionCompleteCallback set.
*
* @return global MediaInformationSessionCompleteCallback or null if it is not set
*/
public static MediaInformationSessionCompleteCallback getMediaInformationSessionCompleteCallback() {
return globalMediaInformationSessionCompleteCallback;
} }
/** /**
@ -1135,7 +1188,7 @@ public class FFmpegKitConfig {
* *
* @return all FFmpeg sessions in the session history * @return all FFmpeg sessions in the session history
*/ */
static List<FFmpegSession> getFFmpegSessions() { public static List<FFmpegSession> getFFmpegSessions() {
final LinkedList<FFmpegSession> list = new LinkedList<>(); final LinkedList<FFmpegSession> list = new LinkedList<>();
synchronized (sessionHistoryLock) { synchronized (sessionHistoryLock) {
@ -1154,7 +1207,7 @@ public class FFmpegKitConfig {
* *
* @return all FFprobe sessions in the session history * @return all FFprobe sessions in the session history
*/ */
static List<FFprobeSession> getFFprobeSessions() { public static List<FFprobeSession> getFFprobeSessions() {
final LinkedList<FFprobeSession> list = new LinkedList<>(); final LinkedList<FFprobeSession> list = new LinkedList<>();
synchronized (sessionHistoryLock) { synchronized (sessionHistoryLock) {
@ -1168,6 +1221,25 @@ public class FFmpegKitConfig {
return list; return list;
} }
/**
* <p>Returns all MediaInformation sessions in the session history.
*
* @return all MediaInformation sessions in the session history
*/
public static List<MediaInformationSession> getMediaInformationSessions() {
final LinkedList<MediaInformationSession> list = new LinkedList<>();
synchronized (sessionHistoryLock) {
for (Session session : sessionHistoryList) {
if (session.isMediaInformation()) {
list.add((MediaInformationSession) session);
}
}
}
return list;
}
/** /**
* <p>Returns sessions that have the given state. * <p>Returns sessions that have the given state.
* *
@ -1357,7 +1429,7 @@ public class FFmpegKitConfig {
native static int nativeFFprobeExecute(final long sessionId, final String[] arguments); native static int nativeFFprobeExecute(final long sessionId, final String[] arguments);
/** /**
* <p>Cancels an ongoing FFmpeg operation natively. This function does not wait for termination * <p>Cancels an ongoing FFmpeg operation natively. This method does not wait for termination
* to complete and returns immediately. * to complete and returns immediately.
* *
* @param sessionId id of the session * @param sessionId id of the session

View File

@ -28,10 +28,15 @@ import java.util.List;
public class FFmpegSession extends AbstractSession implements Session { public class FFmpegSession extends AbstractSession implements Session {
/** /**
* Session specific statistics callback function. * Session specific statistics callback.
*/ */
private final StatisticsCallback statisticsCallback; private final StatisticsCallback statisticsCallback;
/**
* Session specific complete callback.
*/
private final FFmpegSessionCompleteCallback completeCallback;
/** /**
* Statistics entries received for this session. * Statistics entries received for this session.
*/ */
@ -54,44 +59,45 @@ public class FFmpegSession extends AbstractSession implements Session {
/** /**
* Builds a new FFmpeg session. * Builds a new FFmpeg session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback function * @param completeCallback session specific complete callback
*/ */
public FFmpegSession(final String[] arguments, final ExecuteCallback executeCallback) { public FFmpegSession(final String[] arguments, final FFmpegSessionCompleteCallback completeCallback) {
this(arguments, executeCallback, null, null); this(arguments, completeCallback, null, null);
} }
/** /**
* Builds a new FFmpeg session. * Builds a new FFmpeg session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback function * @param completeCallback session specific complete callback
* @param logCallback session specific log callback function * @param logCallback session specific log callback
* @param statisticsCallback session specific statistics callback function * @param statisticsCallback session specific statistics callback
*/ */
public FFmpegSession(final String[] arguments, public FFmpegSession(final String[] arguments,
final ExecuteCallback executeCallback, final FFmpegSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final StatisticsCallback statisticsCallback) { final StatisticsCallback statisticsCallback) {
this(arguments, executeCallback, logCallback, statisticsCallback, FFmpegKitConfig.getLogRedirectionStrategy()); this(arguments, completeCallback, logCallback, statisticsCallback, FFmpegKitConfig.getLogRedirectionStrategy());
} }
/** /**
* Builds a new FFmpeg session. * Builds a new FFmpeg session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback function * @param completeCallback session specific complete callback
* @param logCallback session specific log callback function * @param logCallback session specific log callback
* @param statisticsCallback session specific statistics callback function * @param statisticsCallback session specific statistics callback
* @param logRedirectionStrategy session specific log redirection strategy * @param logRedirectionStrategy session specific log redirection strategy
*/ */
public FFmpegSession(final String[] arguments, public FFmpegSession(final String[] arguments,
final ExecuteCallback executeCallback, final FFmpegSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final StatisticsCallback statisticsCallback, final StatisticsCallback statisticsCallback,
final LogRedirectionStrategy logRedirectionStrategy) { final LogRedirectionStrategy logRedirectionStrategy) {
super(arguments, executeCallback, logCallback, logRedirectionStrategy); super(arguments, logCallback, logRedirectionStrategy);
this.completeCallback = completeCallback;
this.statisticsCallback = statisticsCallback; this.statisticsCallback = statisticsCallback;
this.statistics = new LinkedList<>(); this.statistics = new LinkedList<>();
@ -99,14 +105,23 @@ public class FFmpegSession extends AbstractSession implements Session {
} }
/** /**
* Returns the session specific statistics callback function. * Returns the session specific statistics callback.
* *
* @return session specific statistics callback function * @return session specific statistics callback
*/ */
public StatisticsCallback getStatisticsCallback() { public StatisticsCallback getStatisticsCallback() {
return statisticsCallback; return statisticsCallback;
} }
/**
* Returns the session specific complete callback.
*
* @return session specific complete callback
*/
public FFmpegSessionCompleteCallback getCompleteCallback() {
return completeCallback;
}
/** /**
* Returns all statistics entries generated for this session. If there are asynchronous * Returns all statistics entries generated for this session. If there are asynchronous
* messages that are not delivered yet, this method waits for them until the given timeout. * messages that are not delivered yet, this method waits for them until the given timeout.
@ -165,10 +180,8 @@ public class FFmpegSession extends AbstractSession implements Session {
} }
/** /**
* Adds a new statistics entry for this session. * Adds a new statistics entry for this session. It is invoked internally by
* * <code>FFmpegKit</code> library methods. Must not be used by user applications.
* It is invoked internally by <code>FFmpegKit</code> library methods. Must not be used by user
* applications.
* *
* @param statistics statistics entry * @param statistics statistics entry
*/ */
@ -188,6 +201,11 @@ public class FFmpegSession extends AbstractSession implements Session {
return false; return false;
} }
@Override
public boolean isMediaInformation() {
return false;
}
@Override @Override
public String toString() { public String toString() {
final StringBuilder stringBuilder = new StringBuilder(); final StringBuilder stringBuilder = new StringBuilder();

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2018-2021 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.ffmpegkit;
/**
* <p>Callback function that is invoked when an asynchronous <code>FFmpeg</code> session has ended.
*/
@FunctionalInterface
public interface FFmpegSessionCompleteCallback {
/**
* <p>Called when an FFmpeg session has ended.
*
* @param session FFmpeg session
*/
void apply(final FFmpegSession session);
}

View File

@ -23,16 +23,16 @@ import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
/** /**
* <p>Main class to run <code>FFprobe</code> commands. Supports executing commands both synchronously and * <p>Main class to run <code>FFprobe</code> commands. Supports executing commands both
* asynchronously. * synchronously and asynchronously.
* <pre> * <pre>
* FFprobeSession session = FFprobeKit.execute("-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4"); * FFprobeSession session = FFprobeKit.execute("-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4");
* *
* FFprobeSession asyncSession = FFprobeKit.executeAsync("-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4", executeCallback); * FFprobeSession asyncSession = FFprobeKit.executeAsync("-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4", completeCallback);
* </pre> * </pre>
* <p>Provides overloaded <code>execute</code> methods to define session specific callbacks. * <p>Provides overloaded <code>execute</code> methods to define session specific callbacks.
* <pre> * <pre>
* FFprobeSession session = FFprobeKit.executeAsync("-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4", executeCallback, logCallback); * FFprobeSession session = FFprobeKit.executeAsync("-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4", completeCallback, logCallback);
* </pre> * </pre>
* <p>It can extract media information for a file or a url, using {@link #getMediaInformation(String)} method. * <p>It can extract media information for a file or a url, using {@link #getMediaInformation(String)} method.
* <pre> * <pre>
@ -79,16 +79,17 @@ public class FFprobeKit {
/** /**
* <p>Starts an asynchronous FFprobe execution with arguments provided. * <p>Starts an asynchronous FFprobe execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFprobeSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param arguments FFprobe command options/arguments as string array * @param arguments FFprobe command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
public static FFprobeSession executeWithArgumentsAsync(final String[] arguments, public static FFprobeSession executeWithArgumentsAsync(final String[] arguments,
final ExecuteCallback executeCallback) { final FFprobeSessionCompleteCallback completeCallback) {
final FFprobeSession session = new FFprobeSession(arguments, executeCallback); final FFprobeSession session = new FFprobeSession(arguments, completeCallback);
FFmpegKitConfig.asyncFFprobeExecute(session); FFmpegKitConfig.asyncFFprobeExecute(session);
@ -98,18 +99,19 @@ public class FFprobeKit {
/** /**
* <p>Starts an asynchronous FFprobe execution with arguments provided. * <p>Starts an asynchronous FFprobe execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFprobeSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param arguments FFprobe command options/arguments as string array * @param arguments FFprobe command options/arguments as string array
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
public static FFprobeSession executeWithArgumentsAsync(final String[] arguments, public static FFprobeSession executeWithArgumentsAsync(final String[] arguments,
final ExecuteCallback executeCallback, final FFprobeSessionCompleteCallback completeCallback,
final LogCallback logCallback) { final LogCallback logCallback) {
final FFprobeSession session = new FFprobeSession(arguments, executeCallback, logCallback); final FFprobeSession session = new FFprobeSession(arguments, completeCallback, logCallback);
FFmpegKitConfig.asyncFFprobeExecute(session); FFmpegKitConfig.asyncFFprobeExecute(session);
@ -119,18 +121,19 @@ public class FFprobeKit {
/** /**
* <p>Starts an asynchronous FFprobe execution with arguments provided. * <p>Starts an asynchronous FFprobe execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFprobeSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param arguments FFprobe command options/arguments as string array * @param arguments FFprobe command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
public static FFprobeSession executeWithArgumentsAsync(final String[] arguments, public static FFprobeSession executeWithArgumentsAsync(final String[] arguments,
final ExecuteCallback executeCallback, final FFprobeSessionCompleteCallback completeCallback,
final ExecutorService executorService) { final ExecutorService executorService) {
final FFprobeSession session = new FFprobeSession(arguments, executeCallback); final FFprobeSession session = new FFprobeSession(arguments, completeCallback);
FFmpegKitConfig.asyncFFprobeExecute(session, executorService); FFmpegKitConfig.asyncFFprobeExecute(session, executorService);
@ -140,20 +143,21 @@ public class FFprobeKit {
/** /**
* <p>Starts an asynchronous FFprobe execution with arguments provided. * <p>Starts an asynchronous FFprobe execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFprobeSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param arguments FFprobe command options/arguments as string array * @param arguments FFprobe command options/arguments as string array
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
public static FFprobeSession executeWithArgumentsAsync(final String[] arguments, public static FFprobeSession executeWithArgumentsAsync(final String[] arguments,
final ExecuteCallback executeCallback, final FFprobeSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final ExecutorService executorService) { final ExecutorService executorService) {
final FFprobeSession session = new FFprobeSession(arguments, executeCallback, logCallback); final FFprobeSession session = new FFprobeSession(arguments, completeCallback, logCallback);
FFmpegKitConfig.asyncFFprobeExecute(session, executorService); FFmpegKitConfig.asyncFFprobeExecute(session, executorService);
@ -173,55 +177,61 @@ public class FFprobeKit {
} }
/** /**
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFprobe execution for the given command. Space character is used
* into arguments. You can use single or double quote characters to specify arguments inside your command. * to split the command into arguments. You can use single or double quote characters to
* specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFprobeSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param command FFprobe command * @param command FFprobe command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
public static FFprobeSession executeAsync(final String command, public static FFprobeSession executeAsync(final String command,
final ExecuteCallback executeCallback) { final FFprobeSessionCompleteCallback completeCallback) {
return executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), executeCallback); return executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), completeCallback);
} }
/** /**
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFprobe execution for the given command. Space character is used
* into arguments. You can use single or double quote characters to specify arguments inside your command. * to split the command into arguments. You can use single or double quote characters to
* specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFprobeSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param command FFprobe command * @param command FFprobe command
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
public static FFprobeSession executeAsync(final String command, public static FFprobeSession executeAsync(final String command,
final ExecuteCallback executeCallback, final FFprobeSessionCompleteCallback completeCallback,
final LogCallback logCallback) { final LogCallback logCallback) {
return executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback); return executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback);
} }
/** /**
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFprobe execution for the given command. Space character is used
* into arguments. You can use single or double quote characters to specify arguments inside your command. * to split the command into arguments. You can use single or double quote characters to
* specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFprobeSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param command FFprobe command * @param command FFprobe command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
public static FFprobeSession executeAsync(final String command, public static FFprobeSession executeAsync(final String command,
final ExecuteCallback executeCallback, final FFprobeSessionCompleteCallback completeCallback,
final ExecutorService executorService) { final ExecutorService executorService) {
final FFprobeSession session = new FFprobeSession(FFmpegKitConfig.parseArguments(command), executeCallback); final FFprobeSession session = new FFprobeSession(FFmpegKitConfig.parseArguments(command), completeCallback);
FFmpegKitConfig.asyncFFprobeExecute(session, executorService); FFmpegKitConfig.asyncFFprobeExecute(session, executorService);
@ -229,23 +239,25 @@ public class FFprobeKit {
} }
/** /**
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFprobe execution for the given command. Space character is used
* into arguments. You can use single or double quote characters to specify arguments inside your command. * to split the command into arguments. You can use single or double quote characters to
* specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use an {@link FFprobeSessionCompleteCallback} if you want to be notified about the
* result.
* *
* @param command FFprobe command * @param command FFprobe command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
public static FFprobeSession executeAsync(final String command, public static FFprobeSession executeAsync(final String command,
final ExecuteCallback executeCallback, final FFprobeSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final ExecutorService executorService) { final ExecutorService executorService) {
final FFprobeSession session = new FFprobeSession(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback); final FFprobeSession session = new FFprobeSession(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback);
FFmpegKitConfig.asyncFFprobeExecute(session, executorService); FFmpegKitConfig.asyncFFprobeExecute(session, executorService);
@ -283,18 +295,20 @@ public class FFprobeKit {
} }
/** /**
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. * <p>Starts an asynchronous FFprobe execution to extract the media information for the
* specified file.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use a {@link MediaInformationSessionCompleteCallback} if you want to be notified
* about the result.
* *
* @param path path or uri of a media file * @param path path or uri of a media file
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @return media information session created for this execution * @return media information session created for this execution
*/ */
public static MediaInformationSession getMediaInformationAsync(final String path, public static MediaInformationSession getMediaInformationAsync(final String path,
final ExecuteCallback executeCallback) { final MediaInformationSessionCompleteCallback completeCallback) {
final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), executeCallback); final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), completeCallback);
FFmpegKitConfig.asyncGetMediaInformationExecute(session, AbstractSession.DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT); FFmpegKitConfig.asyncGetMediaInformationExecute(session, AbstractSession.DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT);
@ -302,22 +316,24 @@ public class FFprobeKit {
} }
/** /**
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. * <p>Starts an asynchronous FFprobe execution to extract the media information for the
* specified file.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use a {@link MediaInformationSessionCompleteCallback} if you want to be notified
* about the result.
* *
* @param path path or uri of a media file * @param path path or uri of a media file
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
public static MediaInformationSession getMediaInformationAsync(final String path, public static MediaInformationSession getMediaInformationAsync(final String path,
final ExecuteCallback executeCallback, final MediaInformationSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final int waitTimeout) { final int waitTimeout) {
final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), executeCallback, logCallback); final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), completeCallback, logCallback);
FFmpegKitConfig.asyncGetMediaInformationExecute(session, waitTimeout); FFmpegKitConfig.asyncGetMediaInformationExecute(session, waitTimeout);
@ -325,20 +341,22 @@ public class FFprobeKit {
} }
/** /**
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. * <p>Starts an asynchronous FFprobe execution to extract the media information for the
* specified file.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use a {@link MediaInformationSessionCompleteCallback} if you want to be notified
* about the result.
* *
* @param path path or uri of a media file * @param path path or uri of a media file
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
* @return media information session created for this execution * @return media information session created for this execution
*/ */
public static MediaInformationSession getMediaInformationAsync(final String path, public static MediaInformationSession getMediaInformationAsync(final String path,
final ExecuteCallback executeCallback, final MediaInformationSessionCompleteCallback completeCallback,
final ExecutorService executorService) { final ExecutorService executorService) {
final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), executeCallback); final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), completeCallback);
FFmpegKitConfig.asyncGetMediaInformationExecute(session, executorService, AbstractSession.DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT); FFmpegKitConfig.asyncGetMediaInformationExecute(session, executorService, AbstractSession.DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT);
@ -346,24 +364,26 @@ public class FFprobeKit {
} }
/** /**
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. * <p>Starts an asynchronous FFprobe execution to extract the media information for the
* specified file.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use a {@link MediaInformationSessionCompleteCallback} if you want to be notified
* about the result.
* *
* @param path path or uri of a media file * @param path path or uri of a media file
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param executorService executor service that will be used to run this asynchronous operation * @param executorService executor service that will be used to run this asynchronous operation
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
public static MediaInformationSession getMediaInformationAsync(final String path, public static MediaInformationSession getMediaInformationAsync(final String path,
final ExecuteCallback executeCallback, final MediaInformationSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final ExecutorService executorService, final ExecutorService executorService,
final int waitTimeout) { final int waitTimeout) {
final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), executeCallback, logCallback); final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), completeCallback, logCallback);
FFmpegKitConfig.asyncGetMediaInformationExecute(session, executorService, waitTimeout); FFmpegKitConfig.asyncGetMediaInformationExecute(session, executorService, waitTimeout);
@ -385,44 +405,49 @@ public class FFprobeKit {
} }
/** /**
* <p>Starts an asynchronous FFprobe execution to extract media information using a command. The command passed to * <p>Starts an asynchronous FFprobe execution to extract media information using a command.
* this method must generate the output in JSON format in order to successfully extract media information from it. * The command passed to this method must generate the output in JSON format in order to
* successfully extract media information from it.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use a {@link MediaInformationSessionCompleteCallback} if you want to be notified
* about the result.
* *
* @param command FFprobe command that prints media information for a file in JSON format * @param command FFprobe command that prints media information for a file in JSON
* @param executeCallback callback that will be notified when execution is completed * format
* @param logCallback callback that will receive logs * @param completeCallback callback that will be notified when execution has completed
* @param waitTimeout max time to wait until media information is transmitted * @param logCallback callback that will receive logs
* @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
public static MediaInformationSession getMediaInformationFromCommandAsync(final String command, public static MediaInformationSession getMediaInformationFromCommandAsync(final String command,
final ExecuteCallback executeCallback, final MediaInformationSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final int waitTimeout) { final int waitTimeout) {
return getMediaInformationFromCommandArgumentsAsync(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback, waitTimeout); return getMediaInformationFromCommandArgumentsAsync(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback, waitTimeout);
} }
/** /**
* <p>Starts an asynchronous FFprobe execution to extract media information using command arguments. The command * <p>Starts an asynchronous FFprobe execution to extract media information using command
* passed to this method must generate the output in JSON format in order to successfully extract media information * arguments. The command passed to this method must generate the output in JSON format in
* from it. * order to successfully extract media information from it.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* {@link ExecuteCallback} if you want to be notified about the result. * You must use a {@link MediaInformationSessionCompleteCallback} if you want to be notified
* about the result.
* *
* @param arguments FFprobe command arguments that print media information for a file in JSON format * @param arguments FFprobe command arguments that print media information for a file in
* @param executeCallback callback that will be notified when execution is completed * JSON format
* @param logCallback callback that will receive logs * @param completeCallback callback that will be notified when execution has completed
* @param waitTimeout max time to wait until media information is transmitted * @param logCallback callback that will receive logs
* @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
private static MediaInformationSession getMediaInformationFromCommandArgumentsAsync(final String[] arguments, private static MediaInformationSession getMediaInformationFromCommandArgumentsAsync(final String[] arguments,
final ExecuteCallback executeCallback, final MediaInformationSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final int waitTimeout) { final int waitTimeout) {
final MediaInformationSession session = new MediaInformationSession(arguments, executeCallback, logCallback); final MediaInformationSession session = new MediaInformationSession(arguments, completeCallback, logCallback);
FFmpegKitConfig.asyncGetMediaInformationExecute(session, waitTimeout); FFmpegKitConfig.asyncGetMediaInformationExecute(session, waitTimeout);
@ -434,8 +459,17 @@ public class FFprobeKit {
* *
* @return all FFprobe sessions in the session history * @return all FFprobe sessions in the session history
*/ */
public static List<FFprobeSession> listSessions() { public static List<FFprobeSession> listFFprobeSessions() {
return FFmpegKitConfig.getFFprobeSessions(); return FFmpegKitConfig.getFFprobeSessions();
} }
/**
* <p>Lists all MediaInformation sessions in the session history.
*
* @return all MediaInformation sessions in the session history
*/
public static List<MediaInformationSession> listMediaInformationSessions() {
return FFmpegKitConfig.getMediaInformationSessions();
}
} }

View File

@ -24,6 +24,11 @@ package com.arthenica.ffmpegkit;
*/ */
public class FFprobeSession extends AbstractSession implements Session { public class FFprobeSession extends AbstractSession implements Session {
/**
* Session specific complete callback.
*/
private final FFprobeSessionCompleteCallback completeCallback;
/** /**
* Builds a new FFprobe session. * Builds a new FFprobe session.
* *
@ -36,39 +41,50 @@ public class FFprobeSession extends AbstractSession implements Session {
/** /**
* Builds a new FFprobe session. * Builds a new FFprobe session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback function * @param completeCallback session specific complete callback
*/ */
public FFprobeSession(final String[] arguments, final ExecuteCallback executeCallback) { public FFprobeSession(final String[] arguments, final FFprobeSessionCompleteCallback completeCallback) {
this(arguments, executeCallback, null); this(arguments, completeCallback, null);
} }
/** /**
* Builds a new FFprobe session. * Builds a new FFprobe session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback function * @param completeCallback session specific complete callback
* @param logCallback session specific log callback function * @param logCallback session specific log callback
*/ */
public FFprobeSession(final String[] arguments, public FFprobeSession(final String[] arguments,
final ExecuteCallback executeCallback, final FFprobeSessionCompleteCallback completeCallback,
final LogCallback logCallback) { final LogCallback logCallback) {
this(arguments, executeCallback, logCallback, FFmpegKitConfig.getLogRedirectionStrategy()); this(arguments, completeCallback, logCallback, FFmpegKitConfig.getLogRedirectionStrategy());
} }
/** /**
* Builds a new FFprobe session. * Builds a new FFprobe session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback function * @param completeCallback session specific complete callback
* @param logCallback session specific log callback function * @param logCallback session specific log callback
* @param logRedirectionStrategy session specific log redirection strategy * @param logRedirectionStrategy session specific log redirection strategy
*/ */
public FFprobeSession(final String[] arguments, public FFprobeSession(final String[] arguments,
final ExecuteCallback executeCallback, final FFprobeSessionCompleteCallback completeCallback,
final LogCallback logCallback, final LogCallback logCallback,
final LogRedirectionStrategy logRedirectionStrategy) { final LogRedirectionStrategy logRedirectionStrategy) {
super(arguments, executeCallback, logCallback, logRedirectionStrategy); super(arguments, logCallback, logRedirectionStrategy);
this.completeCallback = completeCallback;
}
/**
* Returns the session specific complete callback.
*
* @return session specific complete callback
*/
public FFprobeSessionCompleteCallback getCompleteCallback() {
return completeCallback;
} }
@Override @Override
@ -81,6 +97,11 @@ public class FFprobeSession extends AbstractSession implements Session {
return true; return true;
} }
@Override
public boolean isMediaInformation() {
return false;
}
@Override @Override
public String toString() { public String toString() {
final StringBuilder stringBuilder = new StringBuilder(); final StringBuilder stringBuilder = new StringBuilder();

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2018-2021 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.ffmpegkit;
/**
* <p>Callback function that is invoked when an asynchronous <code>FFprobe</code> session has ended.
*/
@FunctionalInterface
public interface FFprobeSessionCompleteCallback {
/**
* <p>Called when an FFprobe session has ended.
*
* @param session FFprobe session
*/
void apply(final FFprobeSession session);
}

View File

@ -23,13 +23,18 @@ package com.arthenica.ffmpegkit;
* <p>A custom FFprobe session, which produces a <code>MediaInformation</code> object using the * <p>A custom FFprobe session, which produces a <code>MediaInformation</code> object using the
* FFprobe output. * FFprobe output.
*/ */
public class MediaInformationSession extends FFprobeSession implements Session { public class MediaInformationSession extends AbstractSession implements Session {
/** /**
* Media information extracted in the session. * Media information extracted in the session.
*/ */
private MediaInformation mediaInformation; private MediaInformation mediaInformation;
/**
* Session specific complete callback.
*/
private final MediaInformationSessionCompleteCallback completeCallback;
/** /**
* Creates a new media information session. * Creates a new media information session.
* *
@ -42,22 +47,24 @@ public class MediaInformationSession extends FFprobeSession implements Session {
/** /**
* Creates a new media information session. * Creates a new media information session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback function * @param completeCallback session specific complete callback
*/ */
public MediaInformationSession(final String[] arguments, final ExecuteCallback executeCallback) { public MediaInformationSession(final String[] arguments, final MediaInformationSessionCompleteCallback completeCallback) {
this(arguments, executeCallback, null); this(arguments, completeCallback, null);
} }
/** /**
* Creates a new media information session. * Creates a new media information session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback function * @param completeCallback session specific complete callback
* @param logCallback session specific log callback function * @param logCallback session specific log callback
*/ */
public MediaInformationSession(final String[] arguments, final ExecuteCallback executeCallback, final LogCallback logCallback) { public MediaInformationSession(final String[] arguments, final MediaInformationSessionCompleteCallback completeCallback, final LogCallback logCallback) {
super(arguments, executeCallback, logCallback, LogRedirectionStrategy.NEVER_PRINT_LOGS); super(arguments, logCallback, LogRedirectionStrategy.NEVER_PRINT_LOGS);
this.completeCallback = completeCallback;
} }
/** /**
@ -79,6 +86,30 @@ public class MediaInformationSession extends FFprobeSession implements Session {
this.mediaInformation = mediaInformation; this.mediaInformation = mediaInformation;
} }
/**
* Returns the session specific complete callback.
*
* @return session specific complete callback
*/
public MediaInformationSessionCompleteCallback getCompleteCallback() {
return completeCallback;
}
@Override
public boolean isFFmpeg() {
return false;
}
@Override
public boolean isFFprobe() {
return false;
}
@Override
public boolean isMediaInformation() {
return true;
}
@Override @Override
public String toString() { public String toString() {
final StringBuilder stringBuilder = new StringBuilder(); final StringBuilder stringBuilder = new StringBuilder();

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2018-2021 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.ffmpegkit;
/**
* <p>Callback function that is invoked when an asynchronous <code>MediaInformation</code> session
* has ended.
*/
@FunctionalInterface
public interface MediaInformationSessionCompleteCallback {
/**
* <p>Called when a media information session has ended.
*
* @param session media information session
*/
void apply(final MediaInformationSession session);
}

View File

@ -29,16 +29,9 @@ import java.util.concurrent.Future;
public interface Session { public interface Session {
/** /**
* Returns the session specific execute callback function. * Returns the session specific log callback.
* *
* @return session specific execute callback function * @return session specific log callback
*/
ExecuteCallback getExecuteCallback();
/**
* Returns the session specific log callback function.
*
* @return session specific log callback function
*/ */
LogCallback getLogCallback(); LogCallback getLogCallback();
@ -198,7 +191,7 @@ public interface Session {
/** /**
* Adds a new log entry for this session. * Adds a new log entry for this session.
* * <p>
* It is invoked internally by <code>FFmpegKit</code> library methods. Must not be used by user * It is invoked internally by <code>FFmpegKit</code> library methods. Must not be used by user
* applications. * applications.
* *
@ -227,6 +220,13 @@ public interface Session {
*/ */
boolean isFFprobe(); boolean isFFprobe();
/**
* Returns whether it is a <code>MediaInformation</code> session or not.
*
* @return true if it is a <code>MediaInformation</code> session, false otherwise
*/
boolean isMediaInformation();
/** /**
* Cancels running the session. * Cancels running the session.
*/ */

View File

@ -32,8 +32,8 @@ public class FFmpegSessionTest {
public void constructorTest() { public void constructorTest() {
FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS); FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS);
// 1. getExecuteCallback // 1. getCompleteCallback
Assert.assertNull(ffmpegSession.getExecuteCallback()); Assert.assertNull(ffmpegSession.getCompleteCallback());
// 2. getLogCallback // 2. getLogCallback
Assert.assertNull(ffmpegSession.getLogCallback()); Assert.assertNull(ffmpegSession.getLogCallback());
@ -93,17 +93,17 @@ public class FFmpegSessionTest {
@Test @Test
public void constructorTest2() { public void constructorTest2() {
ExecuteCallback executeCallback = new ExecuteCallback() { FFmpegSessionCompleteCallback completeCallback = new FFmpegSessionCompleteCallback() {
@Override @Override
public void apply(Session session) { public void apply(FFmpegSession session) {
} }
}; };
FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS, executeCallback); FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS, completeCallback);
// 1. getExecuteCallback // 1. getCompleteCallback
Assert.assertEquals(ffmpegSession.getExecuteCallback(), executeCallback); Assert.assertEquals(ffmpegSession.getCompleteCallback(), completeCallback);
// 2. getLogCallback // 2. getLogCallback
Assert.assertNull(ffmpegSession.getLogCallback()); Assert.assertNull(ffmpegSession.getLogCallback());
@ -163,10 +163,10 @@ public class FFmpegSessionTest {
@Test @Test
public void constructorTest3() { public void constructorTest3() {
ExecuteCallback executeCallback = new ExecuteCallback() { FFmpegSessionCompleteCallback completeCallback = new FFmpegSessionCompleteCallback() {
@Override @Override
public void apply(Session session) { public void apply(FFmpegSession session) {
} }
}; };
@ -184,10 +184,10 @@ public class FFmpegSessionTest {
} }
}; };
FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS, executeCallback, logCallback, statisticsCallback); FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS, completeCallback, logCallback, statisticsCallback);
// 1. getExecuteCallback // 1. getCompleteCallback
Assert.assertEquals(ffmpegSession.getExecuteCallback(), executeCallback); Assert.assertEquals(ffmpegSession.getCompleteCallback(), completeCallback);
// 2. getLogCallback // 2. getLogCallback
Assert.assertEquals(ffmpegSession.getLogCallback(), logCallback); Assert.assertEquals(ffmpegSession.getLogCallback(), logCallback);

View File

@ -32,8 +32,8 @@ public class FFprobeSessionTest {
public void constructorTest() { public void constructorTest() {
FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS); FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS);
// 1. getExecuteCallback // 1. getCompleteCallback
Assert.assertNull(ffprobeSession.getExecuteCallback()); Assert.assertNull(ffprobeSession.getCompleteCallback());
// 2. getLogCallback // 2. getLogCallback
Assert.assertNull(ffprobeSession.getLogCallback()); Assert.assertNull(ffprobeSession.getLogCallback());
@ -90,17 +90,17 @@ public class FFprobeSessionTest {
@Test @Test
public void constructorTest2() { public void constructorTest2() {
ExecuteCallback executeCallback = new ExecuteCallback() { FFprobeSessionCompleteCallback completeCallback = new FFprobeSessionCompleteCallback() {
@Override @Override
public void apply(Session session) { public void apply(FFprobeSession session) {
} }
}; };
FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS, executeCallback); FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS, completeCallback);
// 1. getExecuteCallback // 1. getCompleteCallback
Assert.assertEquals(ffprobeSession.getExecuteCallback(), executeCallback); Assert.assertEquals(ffprobeSession.getCompleteCallback(), completeCallback);
// 2. getLogCallback // 2. getLogCallback
Assert.assertNull(ffprobeSession.getLogCallback()); Assert.assertNull(ffprobeSession.getLogCallback());
@ -157,10 +157,10 @@ public class FFprobeSessionTest {
@Test @Test
public void constructorTest3() { public void constructorTest3() {
ExecuteCallback executeCallback = new ExecuteCallback() { FFprobeSessionCompleteCallback completeCallback = new FFprobeSessionCompleteCallback() {
@Override @Override
public void apply(Session session) { public void apply(FFprobeSession session) {
} }
}; };
@ -171,10 +171,10 @@ public class FFprobeSessionTest {
} }
}; };
FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS, executeCallback, logCallback); FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS, completeCallback, logCallback);
// 1. getExecuteCallback // 1. getCompleteCallback
Assert.assertEquals(ffprobeSession.getExecuteCallback(), executeCallback); Assert.assertEquals(ffprobeSession.getCompleteCallback(), completeCallback);
// 2. getLogCallback // 2. getLogCallback
Assert.assertEquals(ffprobeSession.getLogCallback(), logCallback); Assert.assertEquals(ffprobeSession.getLogCallback(), logCallback);

View File

@ -29,8 +29,8 @@
extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit; extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
/** /**
* Abstract session implementation which includes common features shared by <code>FFmpeg</code> * Abstract session implementation which includes common features shared by <code>FFmpeg</code>,
* and <code>FFprobe</code> sessions. * <code>FFprobe</code> and <code>MediaInformation</code> sessions.
*/ */
@interface AbstractSession : NSObject<Session> @interface AbstractSession : NSObject<Session>
@ -38,11 +38,10 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
* Creates a new abstract session. * Creates a new abstract session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback
* @param logCallback session specific log callback * @param logCallback session specific log callback
* @param logRedirectionStrategy session specific log redirection strategy * @param logRedirectionStrategy session specific log redirection strategy
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; - (instancetype)init:(NSArray*)arguments withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy;
/** /**
* Waits for all asynchronous messages to be transmitted until the given timeout. * Waits for all asynchronous messages to be transmitted until the given timeout.

View File

@ -19,7 +19,6 @@
#import "AbstractSession.h" #import "AbstractSession.h"
#import "AtomicLong.h" #import "AtomicLong.h"
#import "ExecuteCallback.h"
#import "FFmpegKit.h" #import "FFmpegKit.h"
#import "FFmpegKitConfig.h" #import "FFmpegKitConfig.h"
#import "LogCallback.h" #import "LogCallback.h"
@ -33,7 +32,6 @@ extern void addSessionToSessionHistory(id<Session> session);
@implementation AbstractSession { @implementation AbstractSession {
long _sessionId; long _sessionId;
ExecuteCallback _executeCallback;
LogCallback _logCallback; LogCallback _logCallback;
NSDate* _createTime; NSDate* _createTime;
NSDate* _startTime; NSDate* _startTime;
@ -51,11 +49,10 @@ extern void addSessionToSessionHistory(id<Session> session);
sessionIdGenerator = [[AtomicLong alloc] initWithValue:1]; sessionIdGenerator = [[AtomicLong alloc] initWithValue:1];
} }
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { - (instancetype)init:(NSArray*)arguments withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy {
self = [super init]; self = [super init];
if (self) { if (self) {
_sessionId = [sessionIdGenerator getAndIncrement]; _sessionId = [sessionIdGenerator getAndIncrement];
_executeCallback = executeCallback;
_logCallback = logCallback; _logCallback = logCallback;
_createTime = [NSDate date]; _createTime = [NSDate date];
_startTime = nil; _startTime = nil;
@ -74,10 +71,6 @@ extern void addSessionToSessionHistory(id<Session> session);
return self; return self;
} }
- (ExecuteCallback)getExecuteCallback {
return _executeCallback;
}
- (LogCallback)getLogCallback { - (LogCallback)getLogCallback {
return _logCallback; return _logCallback;
} }
@ -230,6 +223,11 @@ extern void addSessionToSessionHistory(id<Session> session);
return false; return false;
} }
- (BOOL)isMediaInformation {
// IMPLEMENTED IN SUBCLASSES
return false;
}
- (void)cancel { - (void)cancel {
if (_state == SessionStateRunning) { if (_state == SessionStateRunning) {
[FFmpegKit cancel:_sessionId]; [FFmpegKit cancel:_sessionId];

View File

@ -23,7 +23,6 @@
#import <string.h> #import <string.h>
#import <stdlib.h> #import <stdlib.h>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "ExecuteCallback.h"
#import "LogCallback.h" #import "LogCallback.h"
#import "FFmpegSession.h" #import "FFmpegSession.h"
#import "StatisticsCallback.h" #import "StatisticsCallback.h"
@ -34,11 +33,11 @@
* <pre> * <pre>
* FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v libxvid file1.avi"]; * FFmpegSession *session = [FFmpegKit execute:@"-i file1.mp4 -c:v libxvid file1.avi"];
* *
* FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withExecuteCallback:executeCallback]; * FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withCompleteCallback:completeCallback];
* </pre> * </pre>
* <p>Provides overloaded <code>execute</code> methods to define session specific callbacks. * <p>Provides overloaded <code>execute</code> methods to define session specific callbacks.
* <pre> * <pre>
* FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; * FFmpegSession *asyncSession = [FFmpegKit executeAsync:@"-i file1.mp4 -c:v libxvid file1.avi" withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
* </pre> * </pre>
*/ */
@interface FFmpegKit : NSObject @interface FFmpegKit : NSObject
@ -54,56 +53,56 @@
/** /**
* <p>Starts an asynchronous FFmpeg execution with arguments provided. * <p>Starts an asynchronous FFmpeg execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFmpegSessionCompleteCallback if you want to be notified about the result.
* *
* @param arguments FFmpeg command options/arguments as string array * @param arguments FFmpeg command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback;
/** /**
* <p>Starts an asynchronous FFmpeg execution with arguments provided. * <p>Starts an asynchronous FFmpeg execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFmpegSessionCompleteCallback if you want to be notified about the result.
* *
* @param arguments FFmpeg command options/arguments as string array * @param arguments FFmpeg command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param statisticsCallback callback that will receive statistics * @param statisticsCallback callback that will receive statistics
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback;
/** /**
* <p>Starts an asynchronous FFmpeg execution with arguments provided. * <p>Starts an asynchronous FFmpeg execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFmpegSessionCompleteCallback if you want to be notified about the result.
* *
* @param arguments FFmpeg command options/arguments as string array * @param arguments FFmpeg command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Starts an asynchronous FFmpeg execution with arguments provided. * <p>Starts an asynchronous FFmpeg execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFmpegSessionCompleteCallback if you want to be notified about the result.
* *
* @param arguments FFmpeg command options/arguments as string array * @param arguments FFmpeg command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param statisticsCallback callback that will receive statistics * @param statisticsCallback callback that will receive statistics
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue; + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Synchronously executes FFmpeg command provided. Space character is used to split command * <p>Synchronously executes FFmpeg command provided. Space character is used to split command
@ -120,70 +119,70 @@
* into arguments. You can use single or double quote characters to specify arguments inside your command. * into arguments. You can use single or double quote characters to specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * FFmpegSessionCompleteCallback if you want to be notified about the result.
* *
* @param command FFmpeg command * @param command FFmpeg command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback; + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback;
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command
* into arguments. You can use single or double quote characters to specify arguments inside your command. * into arguments. You can use single or double quote characters to specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * FFmpegSessionCompleteCallback if you want to be notified about the result.
* *
* @param command FFmpeg command * @param command FFmpeg command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param statisticsCallback callback that will receive statistics * @param statisticsCallback callback that will receive statistics
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback;
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command
* into arguments. You can use single or double quote characters to specify arguments inside your command. * into arguments. You can use single or double quote characters to specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * FFmpegSessionCompleteCallback if you want to be notified about the result.
* *
* @param command FFmpeg command * @param command FFmpeg command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFmpeg execution for the given command. Space character is used to split the command
* into arguments. You can use single or double quote characters to specify arguments inside your command. * into arguments. You can use single or double quote characters to specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * FFmpegSessionCompleteCallback if you want to be notified about the result.
* *
* @param command FFmpeg command * @param command FFmpeg command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param statisticsCallback callback that will receive statistics * @param statisticsCallback callback that will receive statistics
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFmpeg session created for this execution * @return FFmpeg session created for this execution
*/ */
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue; + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Cancels all running sessions. * <p>Cancels all running sessions.
* *
* <p>This function does not wait for termination to complete and returns immediately. * <p>This method does not wait for termination to complete and returns immediately.
*/ */
+ (void)cancel; + (void)cancel;
/** /**
* <p>Cancels the session specified with <code>sessionId</code>. * <p>Cancels the session specified with <code>sessionId</code>.
* *
* <p>This function does not wait for termination to complete and returns immediately. * <p>This method does not wait for termination to complete and returns immediately.
* *
* @param sessionId id of the session that will be cancelled * @param sessionId id of the session that will be cancelled
*/ */

View File

@ -40,26 +40,26 @@
return session; return session;
} }
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback { + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback]; FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session]; [FFmpegKitConfig asyncFFmpegExecute:session];
return session; return session;
} }
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback { + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session]; [FFmpegKitConfig asyncFFmpegExecute:session];
return session; return session;
} }
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue { + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback]; FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session; return session;
} }
+ (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue { + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session; return session;
} }
@ -70,26 +70,26 @@
return session; return session;
} }
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback { + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback {
FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback]; FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session]; [FFmpegKitConfig asyncFFmpegExecute:session];
return session; return session;
} }
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback { + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session]; [FFmpegKitConfig asyncFFmpegExecute:session];
return session; return session;
} }
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue { + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback]; FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session; return session;
} }
+ (FFmpegSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue { + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue {
FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback];
[FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue];
return session; return session;
} }

View File

@ -24,7 +24,6 @@
#import <pthread.h> #import <pthread.h>
#import <unistd.h> #import <unistd.h>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "ExecuteCallback.h"
#import "FFmpegSession.h" #import "FFmpegSession.h"
#import "FFprobeSession.h" #import "FFprobeSession.h"
#import "LogCallback.h" #import "LogCallback.h"
@ -191,8 +190,8 @@ typedef NS_ENUM(NSUInteger, Signal) {
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given session. * <p>Starts an asynchronous FFmpeg execution for the given session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFmpegSessionCompleteCallback if you want to be notified about the result.
* *
* @param ffmpegSession FFmpeg session which includes command options/arguments * @param ffmpegSession FFmpeg session which includes command options/arguments
*/ */
@ -201,8 +200,8 @@ typedef NS_ENUM(NSUInteger, Signal) {
/** /**
* <p>Starts an asynchronous FFmpeg execution for the given session. * <p>Starts an asynchronous FFmpeg execution for the given session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFmpegSessionCompleteCallback if you want to be notified about the result.
* *
* @param ffmpegSession FFmpeg session which includes command options/arguments * @param ffmpegSession FFmpeg session which includes command options/arguments
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
@ -212,8 +211,8 @@ typedef NS_ENUM(NSUInteger, Signal) {
/** /**
* <p>Starts an asynchronous FFprobe execution for the given session. * <p>Starts an asynchronous FFprobe execution for the given session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFprobeSessionCompleteCallback if you want to be notified about the result.
* *
* @param ffprobeSession FFprobe session which includes command options/arguments * @param ffprobeSession FFprobe session which includes command options/arguments
*/ */
@ -222,8 +221,8 @@ typedef NS_ENUM(NSUInteger, Signal) {
/** /**
* <p>Starts an asynchronous FFprobe execution for the given session. * <p>Starts an asynchronous FFprobe execution for the given session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFprobeSessionCompleteCallback if you want to be notified about the result.
* *
* @param ffprobeSession FFprobe session which includes command options/arguments * @param ffprobeSession FFprobe session which includes command options/arguments
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
@ -233,8 +232,8 @@ typedef NS_ENUM(NSUInteger, Signal) {
/** /**
* <p>Starts an asynchronous FFprobe execution for the given media information session. * <p>Starts an asynchronous FFprobe execution for the given media information session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an MediaInformationSessionCompleteCallback if you want to be notified about the result.
* *
* @param mediaInformationSession media information session which includes command options/arguments * @param mediaInformationSession media information session which includes command options/arguments
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
@ -244,8 +243,8 @@ typedef NS_ENUM(NSUInteger, Signal) {
/** /**
* <p>Starts an asynchronous FFprobe execution for the given media information session. * <p>Starts an asynchronous FFprobe execution for the given media information session.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an MediaInformationSessionCompleteCallback if you want to be notified about the result.
* *
* @param mediaInformationSession media information session which includes command options/arguments * @param mediaInformationSession media information session which includes command options/arguments
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
@ -268,18 +267,47 @@ typedef NS_ENUM(NSUInteger, Signal) {
+ (void)enableStatisticsCallback:(StatisticsCallback)statisticsCallback; + (void)enableStatisticsCallback:(StatisticsCallback)statisticsCallback;
/** /**
* <p>Sets a global execute callback to receive execution results. * <p>Sets a global FFmpegSessionCompleteCallback to receive execution results for FFmpeg sessions.
* *
* @param executeCallback execute callback or nil to disable a previously execute callback * @param ffmpegSessionCompleteCallback complete callback or nil to disable a previously defined callback
*/ */
+ (void)enableExecuteCallback:(ExecuteCallback)executeCallback; + (void)enableFFmpegSessionCompleteCallback:(FFmpegSessionCompleteCallback)ffmpegSessionCompleteCallback;
/** /**
* <p>Returns the global execute callback. * <p>Returns the global FFmpegSessionCompleteCallback set.
* *
* @return global execute callback * @return global FFmpegSessionCompleteCallback or nil if it is not set
*/ */
+ (ExecuteCallback)getExecuteCallback; + (FFmpegSessionCompleteCallback)getFFmpegSessionCompleteCallback;
/**
* <p>Sets a global FFprobeSessionCompleteCallback to receive execution results for FFprobe sessions.
*
* @param ffprobeSessionCompleteCallback complete callback or nil to disable a previously defined callback
*/
+ (void)enableFFprobeSessionCompleteCallback:(FFprobeSessionCompleteCallback)ffprobeSessionCompleteCallback;
/**
* <p>Returns the global FFprobeSessionCompleteCallback set.
*
* @return global FFprobeSessionCompleteCallback or nil if it is not set
*/
+ (FFprobeSessionCompleteCallback)getFFprobeSessionCompleteCallback;
/**
* <p>Sets a global MediaInformationSessionCompleteCallback to receive execution results for MediaInformation sessions.
*
* @param mediaInformationSessionCompleteCallback complete callback or nil to disable a previously defined
* callback
*/
+ (void)enableMediaInformationSessionCompleteCallback:(MediaInformationSessionCompleteCallback)mediaInformationSessionCompleteCallback;
/**
* <p>Returns the global MediaInformationSessionCompleteCallback set.
*
* @return global MediaInformationSessionCompleteCallback or nil if it is not set
*/
+ (MediaInformationSessionCompleteCallback)getMediaInformationSessionCompleteCallback;
/** /**
* Returns the current log level. * Returns the current log level.
@ -367,6 +395,13 @@ typedef NS_ENUM(NSUInteger, Signal) {
*/ */
+ (NSArray*)getFFprobeSessions; + (NSArray*)getFFprobeSessions;
/**
* <p>Returns all MediaInformation sessions in the session history.
*
* @return all MediaInformation sessions in the session history
*/
+ (NSArray*)getMediaInformationSessions;
/** /**
* <p>Returns sessions that have the given state. * <p>Returns sessions that have the given state.
* *

View File

@ -67,8 +67,10 @@ static LogCallback logCallback;
/** Holds callback defined to redirect statistics */ /** Holds callback defined to redirect statistics */
static StatisticsCallback statisticsCallback; static StatisticsCallback statisticsCallback;
/** Holds callback defined to redirect asynchronous execution results */ /** Holds complete callbacks defined to redirect asynchronous execution results */
static ExecuteCallback executeCallback; static FFmpegSessionCompleteCallback ffmpegSessionCompleteCallback;
static FFprobeSessionCompleteCallback ffprobeSessionCompleteCallback;
static MediaInformationSessionCompleteCallback mediaInformationSessionCompleteCallback;
static LogRedirectionStrategy globalLogRedirectionStrategy; static LogRedirectionStrategy globalLogRedirectionStrategy;
@ -507,7 +509,7 @@ void process_log(long sessionId, int levelValue, AVBPrint* logMessage) {
sessionLogCallback(log); sessionLogCallback(log);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside session LogCallback block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside session log callback. %@", [exception callStackSymbols]);
} }
} }
} }
@ -521,7 +523,7 @@ void process_log(long sessionId, int levelValue, AVBPrint* logMessage) {
globalLogCallback(log); globalLogCallback(log);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside global LogCallback block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside global log callback. %@", [exception callStackSymbols]);
} }
} }
@ -580,7 +582,7 @@ void process_statistics(long sessionId, int videoFrameNumber, float videoFps, fl
sessionStatisticsCallback(statistics); sessionStatisticsCallback(statistics);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside session StatisticsCallback block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside session statistics callback. %@", [exception callStackSymbols]);
} }
} }
} }
@ -591,7 +593,7 @@ void process_statistics(long sessionId, int videoFrameNumber, float videoFps, fl
globalStatisticsCallback(statistics); globalStatisticsCallback(statistics);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside global StatisticsCallback block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside global statistics callback. %@", [exception callStackSymbols]);
} }
} }
} }
@ -751,7 +753,9 @@ int executeFFprobe(long sessionId, NSArray* arguments) {
logCallback = nil; logCallback = nil;
statisticsCallback = nil; statisticsCallback = nil;
executeCallback = nil; ffmpegSessionCompleteCallback = nil;
ffprobeSessionCompleteCallback = nil;
mediaInformationSessionCompleteCallback = nil;
globalLogRedirectionStrategy = LogRedirectionStrategyPrintLogsWhenNoCallbacksDefined; globalLogRedirectionStrategy = LogRedirectionStrategyPrintLogsWhenNoCallbacksDefined;
@ -1008,25 +1012,25 @@ int executeFFprobe(long sessionId, NSArray* arguments) {
dispatch_async(queue, ^{ dispatch_async(queue, ^{
[FFmpegKitConfig ffmpegExecute:ffmpegSession]; [FFmpegKitConfig ffmpegExecute:ffmpegSession];
ExecuteCallback sessionExecuteCallback = [ffmpegSession getExecuteCallback]; FFmpegSessionCompleteCallback completeCallback = [ffmpegSession getCompleteCallback];
if (sessionExecuteCallback != nil) { if (completeCallback != nil) {
@try { @try {
// NOTIFY SESSION CALLBACK DEFINED // NOTIFY SESSION CALLBACK DEFINED
sessionExecuteCallback(ffmpegSession); completeCallback(ffmpegSession);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside session complete callback. %@", [exception callStackSymbols]);
} }
} }
ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; FFmpegSessionCompleteCallback globalFFmpegSessionCompleteCallback = [FFmpegKitConfig getFFmpegSessionCompleteCallback];
if (globalExecuteCallback != nil) { if (globalFFmpegSessionCompleteCallback != nil) {
@try { @try {
// NOTIFY SESSION CALLBACK DEFINED // NOTIFY SESSION CALLBACK DEFINED
globalExecuteCallback(ffmpegSession); globalFFmpegSessionCompleteCallback(ffmpegSession);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside global complete callback. %@", [exception callStackSymbols]);
} }
} }
}); });
@ -1040,25 +1044,25 @@ int executeFFprobe(long sessionId, NSArray* arguments) {
dispatch_async(queue, ^{ dispatch_async(queue, ^{
[FFmpegKitConfig ffprobeExecute:ffprobeSession]; [FFmpegKitConfig ffprobeExecute:ffprobeSession];
ExecuteCallback sessionExecuteCallback = [ffprobeSession getExecuteCallback]; FFprobeSessionCompleteCallback completeCallback = [ffprobeSession getCompleteCallback];
if (sessionExecuteCallback != nil) { if (completeCallback != nil) {
@try { @try {
// NOTIFY SESSION CALLBACK DEFINED // NOTIFY SESSION CALLBACK DEFINED
sessionExecuteCallback(ffprobeSession); completeCallback(ffprobeSession);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside session complete callback. %@", [exception callStackSymbols]);
} }
} }
ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; FFprobeSessionCompleteCallback globalFFprobeSessionCompleteCallback = [FFmpegKitConfig getFFprobeSessionCompleteCallback];
if (globalExecuteCallback != nil) { if (globalFFprobeSessionCompleteCallback != nil) {
@try { @try {
// NOTIFY SESSION CALLBACK DEFINED // NOTIFY SESSION CALLBACK DEFINED
globalExecuteCallback(ffprobeSession); globalFFprobeSessionCompleteCallback(ffprobeSession);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside global complete callback. %@", [exception callStackSymbols]);
} }
} }
}); });
@ -1072,25 +1076,25 @@ int executeFFprobe(long sessionId, NSArray* arguments) {
dispatch_async(queue, ^{ dispatch_async(queue, ^{
[FFmpegKitConfig getMediaInformationExecute:mediaInformationSession withTimeout:waitTimeout]; [FFmpegKitConfig getMediaInformationExecute:mediaInformationSession withTimeout:waitTimeout];
ExecuteCallback sessionExecuteCallback = [mediaInformationSession getExecuteCallback]; MediaInformationSessionCompleteCallback completeCallback = [mediaInformationSession getCompleteCallback];
if (sessionExecuteCallback != nil) { if (completeCallback != nil) {
@try { @try {
// NOTIFY SESSION CALLBACK DEFINED // NOTIFY SESSION CALLBACK DEFINED
sessionExecuteCallback(mediaInformationSession); completeCallback(mediaInformationSession);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside session complete callback. %@", [exception callStackSymbols]);
} }
} }
ExecuteCallback globalExecuteCallback = [FFmpegKitConfig getExecuteCallback]; MediaInformationSessionCompleteCallback globalMediaInformationSessionCompleteCallback = [FFmpegKitConfig getMediaInformationSessionCompleteCallback];
if (globalExecuteCallback != nil) { if (globalMediaInformationSessionCompleteCallback != nil) {
@try { @try {
// NOTIFY SESSION CALLBACK DEFINED // NOTIFY SESSION CALLBACK DEFINED
globalExecuteCallback(mediaInformationSession); globalMediaInformationSessionCompleteCallback(mediaInformationSession);
} }
@catch(NSException* exception) { @catch(NSException* exception) {
NSLog(@"Exception thrown inside session ExecuteCallback block. %@", [exception callStackSymbols]); NSLog(@"Exception thrown inside global complete callback. %@", [exception callStackSymbols]);
} }
} }
}); });
@ -1104,12 +1108,28 @@ int executeFFprobe(long sessionId, NSArray* arguments) {
statisticsCallback = callback; statisticsCallback = callback;
} }
+ (void)enableExecuteCallback:(ExecuteCallback)callback { + (void)enableFFmpegSessionCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback {
executeCallback = callback; ffmpegSessionCompleteCallback = completeCallback;
} }
+ (ExecuteCallback)getExecuteCallback { + (FFmpegSessionCompleteCallback)getFFmpegSessionCompleteCallback {
return executeCallback; return ffmpegSessionCompleteCallback;
}
+ (void)enableFFprobeSessionCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback {
ffprobeSessionCompleteCallback = completeCallback;
}
+ (FFprobeSessionCompleteCallback)getFFprobeSessionCompleteCallback {
return ffprobeSessionCompleteCallback;
}
+ (void)enableMediaInformationSessionCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback {
mediaInformationSessionCompleteCallback = completeCallback;
}
+ (MediaInformationSessionCompleteCallback)getMediaInformationSessionCompleteCallback {
return mediaInformationSessionCompleteCallback;
} }
+ (int)getLogLevel { + (int)getLogLevel {
@ -1243,6 +1263,23 @@ int executeFFprobe(long sessionId, NSArray* arguments) {
return ffprobeSessions; return ffprobeSessions;
} }
+ (NSArray*)getMediaInformationSessions {
NSMutableArray* mediaInformationSessions = [[NSMutableArray alloc] init];
[sessionHistoryLock lock];
for(int i = 0; i < [sessionHistoryList count]; i++) {
id<Session> session = [sessionHistoryList objectAtIndex:i];
if ([session isMediaInformation]) {
[mediaInformationSessions addObject:session];
}
}
[sessionHistoryLock unlock];
return mediaInformationSessions;
}
+ (NSArray*)getSessionsByState:(SessionState)state { + (NSArray*)getSessionsByState:(SessionState)state {
NSMutableArray* sessions = [[NSMutableArray alloc] init]; NSMutableArray* sessions = [[NSMutableArray alloc] init];

View File

@ -23,6 +23,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "AbstractSession.h" #import "AbstractSession.h"
#import "StatisticsCallback.h" #import "StatisticsCallback.h"
#import "FFmpegSessionCompleteCallback.h"
/** /**
* <p>An FFmpeg session. * <p>An FFmpeg session.
@ -39,31 +40,31 @@
/** /**
* Builds a new FFmpeg session. * Builds a new FFmpeg session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback * @param completeCallback session specific complete callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback;
/** /**
* Builds a new FFmpeg session. * Builds a new FFmpeg session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback * @param completeCallback session specific complete callback
* @param logCallback session specific log callback * @param logCallback session specific log callback
* @param statisticsCallback session specific statistics callback * @param statisticsCallback session specific statistics callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback;
/** /**
* Builds a new FFmpeg session. * Builds a new FFmpeg session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback * @param completeCallback session specific complete callback
* @param logCallback session specific log callback * @param logCallback session specific log callback
* @param statisticsCallback session specific statistics callback * @param statisticsCallback session specific statistics callback
* @param logRedirectionStrategy session specific log redirection strategy * @param logRedirectionStrategy session specific log redirection strategy
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy;
/** /**
* Returns the session specific statistics callback. * Returns the session specific statistics callback.
@ -72,6 +73,13 @@
*/ */
- (StatisticsCallback)getStatisticsCallback; - (StatisticsCallback)getStatisticsCallback;
/**
* Returns the session specific complete callback.
*
* @return session specific complete callback
*/
- (FFmpegSessionCompleteCallback)getCompleteCallback;
/** /**
* Returns all statistics entries generated for this session. If there are asynchronous * Returns all statistics entries generated for this session. If there are asynchronous
* messages that are not delivered yet, this method waits for them until the given timeout. * messages that are not delivered yet, this method waits for them until the given timeout.
@ -108,10 +116,8 @@
- (Statistics*)getLastReceivedStatistics; - (Statistics*)getLastReceivedStatistics;
/** /**
* Adds a new statistics entry for this session. * Adds a new statistics entry for this session. It is invoked internally by <code>FFmpegKit</code> library methods.
* * Must not be used by user applications.
* It is invoked internally by <code>FFmpegKit</code> library methods. Must not be used by user
* applications.
* *
* @param statistics statistics entry * @param statistics statistics entry
*/ */

View File

@ -17,7 +17,6 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
#import "ExecuteCallback.h"
#import "FFmpegSession.h" #import "FFmpegSession.h"
#import "FFmpegKitConfig.h" #import "FFmpegKitConfig.h"
#import "LogCallback.h" #import "LogCallback.h"
@ -25,6 +24,7 @@
@implementation FFmpegSession { @implementation FFmpegSession {
StatisticsCallback _statisticsCallback; StatisticsCallback _statisticsCallback;
FFmpegSessionCompleteCallback _completeCallback;
NSMutableArray* _statistics; NSMutableArray* _statistics;
NSRecursiveLock* _statisticsLock; NSRecursiveLock* _statisticsLock;
} }
@ -35,10 +35,11 @@
- (instancetype)init:(NSArray*)arguments { - (instancetype)init:(NSArray*)arguments {
self = [super init:arguments withExecuteCallback:nil withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]];
if (self) { if (self) {
_statisticsCallback = nil; _statisticsCallback = nil;
_completeCallback = nil;
_statistics = [[NSMutableArray alloc] init]; _statistics = [[NSMutableArray alloc] init];
_statisticsLock = [[NSRecursiveLock alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init];
} }
@ -46,12 +47,13 @@
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback { - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback {
self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]];
if (self) { if (self) {
_statisticsCallback = nil; _statisticsCallback = nil;
_completeCallback = completeCallback;
_statistics = [[NSMutableArray alloc] init]; _statistics = [[NSMutableArray alloc] init];
_statisticsLock = [[NSRecursiveLock alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init];
} }
@ -59,12 +61,13 @@
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback { - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback {
self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; self = [super init:arguments withLogCallback:logCallback withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]];
if (self) { if (self) {
_statisticsCallback = statisticsCallback; _statisticsCallback = statisticsCallback;
_completeCallback = completeCallback;
_statistics = [[NSMutableArray alloc] init]; _statistics = [[NSMutableArray alloc] init];
_statisticsLock = [[NSRecursiveLock alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init];
} }
@ -72,12 +75,13 @@
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy {
self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withLogRedirectionStrategy:logRedirectionStrategy]; self = [super init:arguments withLogCallback:logCallback withLogRedirectionStrategy:logRedirectionStrategy];
if (self) { if (self) {
_statisticsCallback = statisticsCallback; _statisticsCallback = statisticsCallback;
_completeCallback = completeCallback;
_statistics = [[NSMutableArray alloc] init]; _statistics = [[NSMutableArray alloc] init];
_statisticsLock = [[NSRecursiveLock alloc] init]; _statisticsLock = [[NSRecursiveLock alloc] init];
} }
@ -89,6 +93,10 @@
return _statisticsCallback; return _statisticsCallback;
} }
- (FFmpegSessionCompleteCallback)getCompleteCallback {
return _completeCallback;
}
- (NSArray*)getAllStatisticsWithTimeout:(int)waitTimeout { - (NSArray*)getAllStatisticsWithTimeout:(int)waitTimeout {
[self waitForAsynchronousMessagesInTransmit:waitTimeout]; [self waitForAsynchronousMessagesInTransmit:waitTimeout];
@ -137,5 +145,9 @@
return false; return false;
} }
- (BOOL)isMediaInformation {
return false;
}
@end @end

View File

@ -17,13 +17,13 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FFMPEG_KIT_EXECUTE_CALLBACK_H #ifndef FFMPEG_KIT_FFMPEG_SESSION_COMPLETE_CALLBACK_H
#define FFMPEG_KIT_EXECUTE_CALLBACK_H #define FFMPEG_KIT_FFMPEG_SESSION_COMPLETE_CALLBACK_H
@protocol Session; @class FFmpegSession;
/** /**
* <p>Callback invoked when an asynchronous session ends running. * <p>Callback function that is invoked when an asynchronous <code>FFmpeg</code> session has ended.
* <p>Session has either SessionStateCompleted or SessionStateFailed state when * <p>Session has either SessionStateCompleted or SessionStateFailed state when
* the callback is invoked. * the callback is invoked.
* <p>If it has SessionStateCompleted state, <code>ReturnCode</code> should be checked to * <p>If it has SessionStateCompleted state, <code>ReturnCode</code> should be checked to
@ -43,8 +43,8 @@
* *
* @param session session of the completed execution * @param session session of the completed execution
*/ */
typedef void (^ExecuteCallback)(id<Session> session); typedef void (^FFmpegSessionCompleteCallback)(FFmpegSession* session);
#import "Session.h" #import "FFmpegSession.h"
#endif // FFMPEG_KIT_EXECUTE_CALLBACK_H #endif // FFMPEG_KIT_FFMPEG_SESSION_COMPLETE_CALLBACK_H

View File

@ -32,11 +32,11 @@
* <pre> * <pre>
* FFprobeSession *session = [FFprobeKit execute:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4"]; * FFprobeSession *session = [FFprobeKit execute:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4"];
* *
* FFprobeSession *asyncSession = [FFprobeKit executeAsync:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4" withExecuteCallback:executeCallback]; * FFprobeSession *asyncSession = [FFprobeKit executeAsync:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4" withCompleteCallback:completeCallback];
* </pre> * </pre>
* <p>Provides overloaded <code>execute</code> methods to define session specific callbacks. * <p>Provides overloaded <code>execute</code> methods to define session specific callbacks.
* <pre> * <pre>
* FFprobeSession *session = [FFprobeKit executeAsync:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4" withExecuteCallback:executeCallback withLogCallback:logCallback]; * FFprobeSession *session = [FFprobeKit executeAsync:@"-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4" withCompleteCallback:completeCallback withLogCallback:logCallback];
* </pre> * </pre>
* <p>It can extract media information for a file or a url, using getMediaInformation method. * <p>It can extract media information for a file or a url, using getMediaInformation method.
* <pre> * <pre>
@ -56,54 +56,54 @@
/** /**
* <p>Starts an asynchronous FFprobe execution with arguments provided. * <p>Starts an asynchronous FFprobe execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFprobeSessionCompleteCallback if you want to be notified about the result.
* *
* @param arguments FFprobe command options/arguments as string array * @param arguments FFprobe command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback;
/** /**
* <p>Starts an asynchronous FFprobe execution with arguments provided. * <p>Starts an asynchronous FFprobe execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFprobeSessionCompleteCallback if you want to be notified about the result.
* *
* @param arguments FFprobe command options/arguments as string array * @param arguments FFprobe command options/arguments as string array
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback; + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback;
/** /**
* <p>Starts an asynchronous FFprobe execution with arguments provided. * <p>Starts an asynchronous FFprobe execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFprobeSessionCompleteCallback if you want to be notified about the result.
* *
* @param arguments FFprobe command options/arguments as string array * @param arguments FFprobe command options/arguments as string array
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Starts an asynchronous FFprobe execution with arguments provided. * <p>Starts an asynchronous FFprobe execution with arguments provided.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete.
* ExecuteCallback if you want to be notified about the result. * You must use an FFprobeSessionCompleteCallback if you want to be notified about the result.
* *
* @param arguments FFprobe command options/arguments as string array * @param arguments FFprobe command options/arguments as string array
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue; + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Synchronously executes FFprobe command provided. Space character is used to split command * <p>Synchronously executes FFprobe command provided. Space character is used to split command
@ -120,56 +120,56 @@
* into arguments. You can use single or double quote characters to specify arguments inside your command. * into arguments. You can use single or double quote characters to specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * FFprobeSessionCompleteCallback if you want to be notified about the result.
* *
* @param command FFprobe command * @param command FFprobe command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback; + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback;
/** /**
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command
* into arguments. You can use single or double quote characters to specify arguments inside your command. * into arguments. You can use single or double quote characters to specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * FFprobeSessionCompleteCallback if you want to be notified about the result.
* *
* @param command FFprobe command * @param command FFprobe command
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback; + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback;
/** /**
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command
* into arguments. You can use single or double quote characters to specify arguments inside your command. * into arguments. You can use single or double quote characters to specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * FFprobeSessionCompleteCallback if you want to be notified about the result.
* *
* @param command FFprobe command * @param command FFprobe command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command * <p>Starts an asynchronous FFprobe execution for the given command. Space character is used to split the command
* into arguments. You can use single or double quote characters to specify arguments inside your command. * into arguments. You can use single or double quote characters to specify arguments inside your command.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * FFprobeSessionCompleteCallback if you want to be notified about the result.
* *
* @param command FFprobe command * @param command FFprobe command
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return FFprobe session created for this execution * @return FFprobe session created for this execution
*/ */
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue; + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Extracts media information for the file specified with path. * <p>Extracts media information for the file specified with path.
@ -192,55 +192,55 @@
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. * <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * MediaInformationSessionCompleteCallback if you want to be notified about the result.
* *
* @param path path or uri of a media file * @param path path or uri of a media file
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @return media information session created for this execution * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback; + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback;
/** /**
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. * <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * MediaInformationSessionCompleteCallback if you want to be notified about the result.
* *
* @param path path or uri of a media file * @param path path or uri of a media file
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withTimeout:(int)waitTimeout; + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withTimeout:(int)waitTimeout;
/** /**
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. * <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * MediaInformationSessionCompleteCallback if you want to be notified about the result.
* *
* @param path path or uri of a media file * @param path path or uri of a media file
* @param executeCallback callback that will be called when the execution is completed * @param completeCallback callback that will be called when the execution has completed
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @return media information session created for this execution * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue; + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue;
/** /**
* <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file. * <p>Starts an asynchronous FFprobe execution to extract the media information for the specified file.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * MediaInformationSessionCompleteCallback if you want to be notified about the result.
* *
* @param path path or uri of a media file * @param path path or uri of a media file
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout;
/** /**
* <p>Extracts media information using the command provided asynchronously. * <p>Extracts media information using the command provided asynchronously.
@ -255,16 +255,16 @@
* this method must generate the output in JSON format in order to successfully extract media information from it. * this method must generate the output in JSON format in order to successfully extract media information from it.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * MediaInformationSessionCompleteCallback if you want to be notified about the result.
* *
* @param command FFprobe command that prints media information for a file in JSON format * @param command FFprobe command that prints media information for a file in JSON format
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; + (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSString*)command withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout;
/** /**
* <p>Starts an asynchronous FFprobe execution to extract media information using command arguments. The command * <p>Starts an asynchronous FFprobe execution to extract media information using command arguments. The command
@ -272,23 +272,30 @@
* from it. * from it.
* *
* <p>Note that this method returns immediately and does not wait the execution to complete. You must use an * <p>Note that this method returns immediately and does not wait the execution to complete. You must use an
* ExecuteCallback if you want to be notified about the result. * MediaInformationSessionCompleteCallback if you want to be notified about the result.
* *
* @param command FFprobe command that prints media information for a file in JSON format * @param command FFprobe command that prints media information for a file in JSON format
* @param executeCallback callback that will be notified when execution is completed * @param completeCallback callback that will be notified when execution has completed
* @param logCallback callback that will receive logs * @param logCallback callback that will receive logs
* @param queue dispatch queue that will be used to run this asynchronous operation * @param queue dispatch queue that will be used to run this asynchronous operation
* @param waitTimeout max time to wait until media information is transmitted * @param waitTimeout max time to wait until media information is transmitted
* @return media information session created for this execution * @return media information session created for this execution
*/ */
+ (MediaInformationSession*)getMediaInformationFromCommandArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout; + (MediaInformationSession*)getMediaInformationFromCommandArgumentsAsync:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout;
/** /**
* <p>Lists all FFprobe sessions in the session history. * <p>Lists all FFprobe sessions in the session history.
* *
* @return all FFprobe sessions in the session history * @return all FFprobe sessions in the session history
*/ */
+ (NSArray*)listSessions; + (NSArray*)listFFprobeSessions;
/**
* <p>Lists all MediaInformation sessions in the session history.
*
* @return all MediaInformation sessions in the session history
*/
+ (NSArray*)listMediaInformationSessions;
@end @end

View File

@ -38,26 +38,26 @@
return session; return session;
} }
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback { + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback]; FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFprobeExecute:session]; [FFmpegKitConfig asyncFFprobeExecute:session];
return session; return session;
} }
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback { + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback]; FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncFFprobeExecute:session]; [FFmpegKitConfig asyncFFprobeExecute:session];
return session; return session;
} }
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue { + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback]; FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue];
return session; return session;
} }
+ (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue { + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback]; FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue];
return session; return session;
} }
@ -68,26 +68,26 @@
return session; return session;
} }
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback { + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback {
FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback]; FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFprobeExecute:session]; [FFmpegKitConfig asyncFFprobeExecute:session];
return session; return session;
} }
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback { + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback {
FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback]; FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncFFprobeExecute:session]; [FFmpegKitConfig asyncFFprobeExecute:session];
return session; return session;
} }
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue { + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue {
FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback]; FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue];
return session; return session;
} }
+ (FFprobeSession*)executeAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue { + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue {
FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback]; FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue];
return session; return session;
} }
@ -106,30 +106,30 @@
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback { + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback {
NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path]; NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path];
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback]; MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncGetMediaInformationExecute:session withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit]; [FFmpegKitConfig asyncGetMediaInformationExecute:session withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit];
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withTimeout:(int)waitTimeout { + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withTimeout:(int)waitTimeout {
NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path]; NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path];
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback]; MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncGetMediaInformationExecute:session withTimeout:waitTimeout]; [FFmpegKitConfig asyncGetMediaInformationExecute:session withTimeout:waitTimeout];
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback onDispatchQueue:(dispatch_queue_t)queue { + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue {
NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path]; NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path];
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback]; MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit];
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout {
NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path]; NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path];
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback]; MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:completeCallback];
[FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout];
return session; return session;
} }
@ -140,20 +140,24 @@
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSString*)command withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { + (MediaInformationSession*)getMediaInformationFromCommandAsync:(NSString*)command withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout {
MediaInformationSession* session = [[MediaInformationSession alloc] init:[FFmpegKitConfig parseArguments:command] withExecuteCallback:executeCallback withLogCallback:logCallback]; MediaInformationSession* session = [[MediaInformationSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout];
return session; return session;
} }
+ (MediaInformationSession*)getMediaInformationFromCommandArgumentsAsync:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { + (MediaInformationSession*)getMediaInformationFromCommandArgumentsAsync:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout {
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback]; MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback];
[FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout];
return session; return session;
} }
+ (NSArray*)listSessions { + (NSArray*)listFFprobeSessions {
return [FFmpegKitConfig getFFprobeSessions]; return [FFmpegKitConfig getFFprobeSessions];
} }
+ (NSArray*)listMediaInformationSessions {
return [FFmpegKitConfig getMediaInformationSessions];
}
@end @end

View File

@ -22,6 +22,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "AbstractSession.h" #import "AbstractSession.h"
#import "FFprobeSessionCompleteCallback.h"
/** /**
* <p>An FFprobe session. * <p>An FFprobe session.
@ -38,29 +39,36 @@
/** /**
* Builds a new FFprobe session. * Builds a new FFprobe session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback * @param completeCallback session specific complete callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback;
/** /**
* Builds a new FFprobe session. * Builds a new FFprobe session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback * @param completeCallback session specific complete callback
* @param logCallback session specific log callback * @param logCallback session specific log callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback; - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback;
/** /**
* Builds a new FFprobe session. * Builds a new FFprobe session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback * @param completeCallback session specific complete callback
* @param logCallback session specific log callback * @param logCallback session specific log callback
* @param logRedirectionStrategy session specific log redirection strategy * @param logRedirectionStrategy session specific log redirection strategy
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy;
/**
* Returns the session specific complete callback.
*
* @return session specific complete callback
*/
- (FFprobeSessionCompleteCallback)getCompleteCallback;
@end @end

View File

@ -17,45 +17,66 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
#import "ExecuteCallback.h"
#import "FFprobeSession.h" #import "FFprobeSession.h"
#import "FFmpegKitConfig.h" #import "FFmpegKitConfig.h"
#import "LogCallback.h" #import "LogCallback.h"
@implementation FFprobeSession @implementation FFprobeSession {
FFprobeSessionCompleteCallback _completeCallback;
- (instancetype)init:(NSArray*)arguments {
self = [super init:arguments withExecuteCallback:nil withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]];
return self;
} }
+ (void)initialize { + (void)initialize {
// EMPTY INITIALIZE // EMPTY INITIALIZE
} }
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback { - (instancetype)init:(NSArray*)arguments {
self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]];
if (self) {
_completeCallback = nil;
}
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback { - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback {
self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]];
if (self) {
_completeCallback = completeCallback;
}
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback {
self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withLogRedirectionStrategy:logRedirectionStrategy]; self = [super init:arguments withLogCallback:logCallback withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]];
if (self) {
_completeCallback = completeCallback;
}
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy {
self = [super init:arguments withLogCallback:logCallback withLogRedirectionStrategy:logRedirectionStrategy];
if (self) {
_completeCallback = completeCallback;
}
return self;
}
- (FFprobeSessionCompleteCallback)getCompleteCallback {
return _completeCallback;
}
- (BOOL)isFFmpeg { - (BOOL)isFFmpeg {
return false; return false;
} }
@ -64,5 +85,9 @@
return true; return true;
} }
- (BOOL)isMediaInformation {
return false;
}
@end @end

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2020-2021 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FFMPEG_KIT_FFPROBE_SESSION_COMPLETE_CALLBACK_H
#define FFMPEG_KIT_FFPROBE_SESSION_COMPLETE_CALLBACK_H
@class FFprobeSession;
/**
* <p>Callback function that is invoked when an asynchronous <code>FFprobe</code> session has ended.
* <p>Session has either SessionStateCompleted or SessionStateFailed state when
* the callback is invoked.
* <p>If it has SessionStateCompleted state, <code>ReturnCode</code> should be checked to
* see the execution result.
* <p>If <code>getState</code> returns SessionStateFailed then
* <code>getFailStackTrace</code> should be used to get the failure reason.
* <pre>
* switch ([session getState]) {
* case SessionStateCompleted:
* ReturnCode *returnCode = [session getReturnCode];
* break;
* case SessionStateFailed:
* NSString *failStackTrace = [session getFailStackTrace];
* break;
* }
* </pre>
*
* @param session session of the completed execution
*/
typedef void (^FFprobeSessionCompleteCallback)(FFprobeSession* session);
#import "FFprobeSession.h"
#endif // FFMPEG_KIT_FFPROBE_SESSION_COMPLETE_CALLBACK_H

View File

@ -37,28 +37,30 @@ include_HEADERS = \
ArchDetect.h \ ArchDetect.h \
AtomicLong.h \ AtomicLong.h \
Chapter.h \ Chapter.h \
ExecuteCallback.h \
FFmpegKit.h \ FFmpegKit.h \
FFmpegKitConfig.h \ FFmpegKitConfig.h \
FFmpegSession.h \ FFmpegSession.h \
FFprobeKit.h \ FFmpegSessionCompleteCallback.h \
FFprobeSession.h \ FFprobeKit.h \
Level.h \ FFprobeSession.h \
Log.h \ FFprobeSessionCompleteCallback.h \
LogCallback.h \ Level.h \
LogRedirectionStrategy.h \ Log.h \
MediaInformation.h \ LogCallback.h \
MediaInformationJsonParser.h \ LogRedirectionStrategy.h \
MediaInformationSession.h \ MediaInformation.h \
Packages.h \ MediaInformationJsonParser.h \
ReturnCode.h \ MediaInformationSession.h \
Session.h \ MediaInformationSessionCompleteCallback.h \
SessionState.h \ Packages.h \
Statistics.h \ ReturnCode.h \
StatisticsCallback.h \ Session.h \
StreamInformation.h \ SessionState.h \
ffmpegkit_exception.h \ Statistics.h \
fftools_cmdutils.h \ StatisticsCallback.h \
StreamInformation.h \
ffmpegkit_exception.h \
fftools_cmdutils.h \
fftools_ffmpeg.h fftools_ffmpeg.h
libffmpegkit_la_CFLAGS = $(CFLAGS) libffmpegkit_la_CFLAGS = $(CFLAGS)

View File

@ -414,28 +414,30 @@ include_HEADERS = \
ArchDetect.h \ ArchDetect.h \
AtomicLong.h \ AtomicLong.h \
Chapter.h \ Chapter.h \
ExecuteCallback.h \
FFmpegKit.h \ FFmpegKit.h \
FFmpegKitConfig.h \ FFmpegKitConfig.h \
FFmpegSession.h \ FFmpegSession.h \
FFprobeKit.h \ FFmpegSessionCompleteCallback.h \
FFprobeSession.h \ FFprobeKit.h \
Level.h \ FFprobeSession.h \
Log.h \ FFprobeSessionCompleteCallback.h \
LogCallback.h \ Level.h \
LogRedirectionStrategy.h \ Log.h \
MediaInformation.h \ LogCallback.h \
MediaInformationJsonParser.h \ LogRedirectionStrategy.h \
MediaInformationSession.h \ MediaInformation.h \
Packages.h \ MediaInformationJsonParser.h \
ReturnCode.h \ MediaInformationSession.h \
Session.h \ MediaInformationSessionCompleteCallback.h \
SessionState.h \ Packages.h \
Statistics.h \ ReturnCode.h \
StatisticsCallback.h \ Session.h \
StreamInformation.h \ SessionState.h \
ffmpegkit_exception.h \ Statistics.h \
fftools_cmdutils.h \ StatisticsCallback.h \
StreamInformation.h \
ffmpegkit_exception.h \
fftools_cmdutils.h \
fftools_ffmpeg.h fftools_ffmpeg.h
libffmpegkit_la_CFLAGS = $(CFLAGS) libffmpegkit_la_CFLAGS = $(CFLAGS)

View File

@ -21,14 +21,15 @@
#define FFMPEG_KIT_MEDIA_INFORMATION_SESSION_H #define FFMPEG_KIT_MEDIA_INFORMATION_SESSION_H
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "FFprobeSession.h" #import "AbstractSession.h"
#import "MediaInformation.h" #import "MediaInformation.h"
#import "MediaInformationSessionCompleteCallback.h"
/** /**
* <p>A custom FFprobe session, which produces a <code>MediaInformation</code> object using the * <p>A custom FFprobe session, which produces a <code>MediaInformation</code> object using the
* FFprobe output. * FFprobe output.
*/ */
@interface MediaInformationSession : FFprobeSession @interface MediaInformationSession : AbstractSession
/** /**
* Creates a new media information session. * Creates a new media information session.
@ -40,19 +41,19 @@
/** /**
* Creates a new media information session. * Creates a new media information session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback * @param completeCallback session specific complete callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback; - (instancetype)init:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback;
/** /**
* Creates a new media information session. * Creates a new media information session.
* *
* @param arguments command arguments * @param arguments command arguments
* @param executeCallback session specific execute callback * @param completeCallback session specific complete callback
* @param logCallback session specific log callback * @param logCallback session specific log callback
*/ */
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback; - (instancetype)init:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback;
/** /**
* Returns the media information extracted in this session. * Returns the media information extracted in this session.
@ -69,6 +70,13 @@
*/ */
- (void)setMediaInformation:(MediaInformation*)mediaInformation; - (void)setMediaInformation:(MediaInformation*)mediaInformation;
/**
* Returns the session specific complete callback.
*
* @return session specific complete callback
*/
- (MediaInformationSessionCompleteCallback)getCompleteCallback;
@end @end
#endif // FFMPEG_KIT_MEDIA_INFORMATION_SESSION_H #endif // FFMPEG_KIT_MEDIA_INFORMATION_SESSION_H

View File

@ -17,13 +17,13 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
#import "ExecuteCallback.h" #import "MediaInformationSession.h"
#import "LogCallback.h" #import "LogCallback.h"
#import "MediaInformation.h" #import "MediaInformation.h"
#import "MediaInformationSession.h"
@implementation MediaInformationSession { @implementation MediaInformationSession {
MediaInformation* _mediaInformation; MediaInformation* _mediaInformation;
MediaInformationSessionCompleteCallback _completeCallback;
} }
+ (void)initialize { + (void)initialize {
@ -32,21 +32,33 @@
- (instancetype)init:(NSArray*)arguments { - (instancetype)init:(NSArray*)arguments {
self = [super init:arguments withExecuteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
if (self) {
_completeCallback = nil;
}
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback { - (instancetype)init:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback {
self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
if (self) {
_completeCallback = completeCallback;
}
return self; return self;
} }
- (instancetype)init:(NSArray*)arguments withExecuteCallback:(ExecuteCallback)executeCallback withLogCallback:(LogCallback)logCallback { - (instancetype)init:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback {
self = [super init:arguments withExecuteCallback:executeCallback withLogCallback:logCallback withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; self = [super init:arguments withLogCallback:logCallback withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
if (self) {
_completeCallback = completeCallback;
}
return self; return self;
} }
@ -59,5 +71,21 @@
_mediaInformation = mediaInformation; _mediaInformation = mediaInformation;
} }
- (MediaInformationSessionCompleteCallback)getCompleteCallback {
return _completeCallback;
}
- (BOOL)isFFmpeg {
return false;
}
- (BOOL)isFFprobe {
return false;
}
- (BOOL)isMediaInformation {
return true;
}
@end @end

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2020-2021 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FFMPEG_KIT_MEDIA_INFORMATION_SESSION_COMPLETE_CALLBACK_H
#define FFMPEG_KIT_MEDIA_INFORMATION_SESSION_COMPLETE_CALLBACK_H
@class MediaInformationSession;
/**
* <p>Callback function that is invoked when an asynchronous <code>MediaInformation</code> session
* has ended.
* <p>Session has either SessionStateCompleted or SessionStateFailed state when
* the callback is invoked.
* <p>If it has SessionStateCompleted state, <code>ReturnCode</code> should be checked to
* see the execution result.
* <p>If <code>getState</code> returns SessionStateFailed then
* <code>getFailStackTrace</code> should be used to get the failure reason.
* <pre>
* switch ([session getState]) {
* case SessionStateCompleted:
* ReturnCode *returnCode = [session getReturnCode];
* break;
* case SessionStateFailed:
* NSString *failStackTrace = [session getFailStackTrace];
* break;
* }
* </pre>
*
* @param session session of the completed execution
*/
typedef void (^MediaInformationSessionCompleteCallback)(MediaInformationSession* session);
#import "MediaInformationSession.h"
#endif // FFMPEG_KIT_MEDIA_INFORMATION_SESSION_COMPLETE_CALLBACK_H

View File

@ -21,7 +21,6 @@
#define FFMPEG_KIT_SESSION_H #define FFMPEG_KIT_SESSION_H
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "ExecuteCallback.h"
#import "Log.h" #import "Log.h"
#import "LogCallback.h" #import "LogCallback.h"
#import "LogRedirectionStrategy.h" #import "LogRedirectionStrategy.h"
@ -35,13 +34,6 @@
@required @required
/**
* Returns the session specific execute callback.
*
* @return session specific execute callback
*/
- (ExecuteCallback)getExecuteCallback;
/** /**
* Returns the session specific log callback. * Returns the session specific log callback.
* *
@ -171,7 +163,7 @@
* that end with SessionStateCompleted state. If a session is not started, still running or failed then * that end with SessionStateCompleted state. If a session is not started, still running or failed then
* this method returns nil. * this method returns nil.
* *
* @return the return code for this session if the session is completed, nil if session is * @return the return code for this session if the session has completed, nil if session is
* not started, still running or failed * not started, still running or failed
*/ */
- (ReturnCode*)getReturnCode; - (ReturnCode*)getReturnCode;
@ -246,6 +238,13 @@
*/ */
- (BOOL)isFFprobe; - (BOOL)isFFprobe;
/**
* Returns whether it is a <code>MediaInformation</code> session or not.
*
* @return true if it is a <code>MediaInformation</code> session, false otherwise
*/
- (BOOL)isMediaInformation;
/** /**
* Cancels running the session. * Cancels running the session.
*/ */

View File

@ -841,12 +841,13 @@ framework module ffmpegkit {
header "ArchDetect.h" header "ArchDetect.h"
header "AtomicLong.h" header "AtomicLong.h"
header "Chapter.h" header "Chapter.h"
header "ExecuteCallback.h"
header "FFmpegKit.h" header "FFmpegKit.h"
header "FFmpegKitConfig.h" header "FFmpegKitConfig.h"
header "FFmpegSession.h" header "FFmpegSession.h"
header "FFmpegSessionCompleteCallback.h"
header "FFprobeKit.h" header "FFprobeKit.h"
header "FFprobeSession.h" header "FFprobeSession.h"
header "FFprobeSessionCompleteCallback.h"
header "Level.h" header "Level.h"
header "Log.h" header "Log.h"
header "LogCallback.h" header "LogCallback.h"
@ -854,6 +855,7 @@ framework module ffmpegkit {
header "MediaInformation.h" header "MediaInformation.h"
header "MediaInformationJsonParser.h" header "MediaInformationJsonParser.h"
header "MediaInformationSession.h" header "MediaInformationSession.h"
header "MediaInformationSessionCompleteCallback.h"
header "Packages.h" header "Packages.h"
header "ReturnCode.h" header "ReturnCode.h"
header "Session.h" header "Session.h"