diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AbstractSession.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AbstractSession.java index fcb8c62..0464bda 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AbstractSession.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/AbstractSession.java @@ -115,7 +115,7 @@ public abstract class AbstractSession implements Session { * @param logCallback session specific log callback * @param logRedirectionStrategy session specific log redirection strategy */ - public AbstractSession(final String[] arguments, + protected AbstractSession(final String[] arguments, final LogCallback logCallback, final LogRedirectionStrategy logRedirectionStrategy) { this.sessionId = sessionIdGenerator.getAndIncrement(); diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFmpegKit.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFmpegKit.java index d0b6dee..1df5ef0 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFmpegKit.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFmpegKit.java @@ -55,7 +55,7 @@ public class FFmpegKit { * @return FFmpeg session created for this execution */ public static FFmpegSession executeWithArguments(final String[] arguments) { - final FFmpegSession session = new FFmpegSession(arguments); + final FFmpegSession session = FFmpegSession.create(arguments); FFmpegKitConfig.ffmpegExecute(session); @@ -75,7 +75,7 @@ public class FFmpegKit { */ public static FFmpegSession executeWithArgumentsAsync(final String[] arguments, final FFmpegSessionCompleteCallback completeCallback) { - final FFmpegSession session = new FFmpegSession(arguments, completeCallback); + final FFmpegSession session = FFmpegSession.create(arguments, completeCallback); FFmpegKitConfig.asyncFFmpegExecute(session); @@ -99,7 +99,7 @@ public class FFmpegKit { final FFmpegSessionCompleteCallback completeCallback, final LogCallback logCallback, final StatisticsCallback statisticsCallback) { - final FFmpegSession session = new FFmpegSession(arguments, completeCallback, logCallback, statisticsCallback); + final FFmpegSession session = FFmpegSession.create(arguments, completeCallback, logCallback, statisticsCallback); FFmpegKitConfig.asyncFFmpegExecute(session); @@ -121,7 +121,7 @@ public class FFmpegKit { public static FFmpegSession executeWithArgumentsAsync(final String[] arguments, final FFmpegSessionCompleteCallback completeCallback, final ExecutorService executorService) { - final FFmpegSession session = new FFmpegSession(arguments, completeCallback); + final FFmpegSession session = FFmpegSession.create(arguments, completeCallback); FFmpegKitConfig.asyncFFmpegExecute(session, executorService); @@ -148,7 +148,7 @@ public class FFmpegKit { final LogCallback logCallback, final StatisticsCallback statisticsCallback, final ExecutorService executorService) { - final FFmpegSession session = new FFmpegSession(arguments, completeCallback, logCallback, statisticsCallback); + final FFmpegSession session = FFmpegSession.create(arguments, completeCallback, logCallback, statisticsCallback); FFmpegKitConfig.asyncFFmpegExecute(session, executorService); @@ -224,7 +224,7 @@ public class FFmpegKit { public static FFmpegSession executeAsync(final String command, final FFmpegSessionCompleteCallback completeCallback, final ExecutorService executorService) { - final FFmpegSession session = new FFmpegSession(FFmpegKitConfig.parseArguments(command), completeCallback); + final FFmpegSession session = FFmpegSession.create(FFmpegKitConfig.parseArguments(command), completeCallback); FFmpegKitConfig.asyncFFmpegExecute(session, executorService); @@ -252,7 +252,7 @@ public class FFmpegKit { final LogCallback logCallback, final StatisticsCallback statisticsCallback, final ExecutorService executorService) { - final FFmpegSession session = new FFmpegSession(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback, statisticsCallback); + final FFmpegSession session = FFmpegSession.create(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback, statisticsCallback); FFmpegKitConfig.asyncFFmpegExecute(session, executorService); diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFmpegSession.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFmpegSession.java index ca7d105..a33f5ef 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFmpegSession.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFmpegSession.java @@ -52,8 +52,8 @@ public class FFmpegSession extends AbstractSession implements Session { * * @param arguments command arguments */ - public FFmpegSession(final String[] arguments) { - this(arguments, null); + public static FFmpegSession create(final String[] arguments) { + return new FFmpegSession(arguments, null, null, null, FFmpegKitConfig.getLogRedirectionStrategy()); } /** @@ -62,8 +62,8 @@ public class FFmpegSession extends AbstractSession implements Session { * @param arguments command arguments * @param completeCallback session specific complete callback */ - public FFmpegSession(final String[] arguments, final FFmpegSessionCompleteCallback completeCallback) { - this(arguments, completeCallback, null, null); + public static FFmpegSession create(final String[] arguments, final FFmpegSessionCompleteCallback completeCallback) { + return new FFmpegSession(arguments, completeCallback, null, null, FFmpegKitConfig.getLogRedirectionStrategy()); } /** @@ -74,11 +74,11 @@ public class FFmpegSession extends AbstractSession implements Session { * @param logCallback session specific log callback * @param statisticsCallback session specific statistics callback */ - public FFmpegSession(final String[] arguments, - final FFmpegSessionCompleteCallback completeCallback, - final LogCallback logCallback, - final StatisticsCallback statisticsCallback) { - this(arguments, completeCallback, logCallback, statisticsCallback, FFmpegKitConfig.getLogRedirectionStrategy()); + public static FFmpegSession create(final String[] arguments, + final FFmpegSessionCompleteCallback completeCallback, + final LogCallback logCallback, + final StatisticsCallback statisticsCallback) { + return new FFmpegSession(arguments, completeCallback, logCallback, statisticsCallback, FFmpegKitConfig.getLogRedirectionStrategy()); } /** @@ -90,11 +90,28 @@ public class FFmpegSession extends AbstractSession implements Session { * @param statisticsCallback session specific statistics callback * @param logRedirectionStrategy session specific log redirection strategy */ - public FFmpegSession(final String[] arguments, - final FFmpegSessionCompleteCallback completeCallback, - final LogCallback logCallback, - final StatisticsCallback statisticsCallback, - final LogRedirectionStrategy logRedirectionStrategy) { + public static FFmpegSession create(final String[] arguments, + final FFmpegSessionCompleteCallback completeCallback, + final LogCallback logCallback, + final StatisticsCallback statisticsCallback, + final LogRedirectionStrategy logRedirectionStrategy) { + return new FFmpegSession(arguments, completeCallback, logCallback, statisticsCallback, logRedirectionStrategy); + } + + /** + * Builds a new FFmpeg session. + * + * @param arguments command arguments + * @param completeCallback session specific complete callback + * @param logCallback session specific log callback + * @param statisticsCallback session specific statistics callback + * @param logRedirectionStrategy session specific log redirection strategy + */ + private FFmpegSession(final String[] arguments, + final FFmpegSessionCompleteCallback completeCallback, + final LogCallback logCallback, + final StatisticsCallback statisticsCallback, + final LogRedirectionStrategy logRedirectionStrategy) { super(arguments, logCallback, logRedirectionStrategy); this.completeCallback = completeCallback; diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFprobeKit.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFprobeKit.java index d64c0d5..1713bbf 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFprobeKit.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFprobeKit.java @@ -69,7 +69,7 @@ public class FFprobeKit { * @return FFprobe session created for this execution */ public static FFprobeSession executeWithArguments(final String[] arguments) { - final FFprobeSession session = new FFprobeSession(arguments); + final FFprobeSession session = FFprobeSession.create(arguments); FFmpegKitConfig.ffprobeExecute(session); @@ -89,7 +89,7 @@ public class FFprobeKit { */ public static FFprobeSession executeWithArgumentsAsync(final String[] arguments, final FFprobeSessionCompleteCallback completeCallback) { - final FFprobeSession session = new FFprobeSession(arguments, completeCallback); + final FFprobeSession session = FFprobeSession.create(arguments, completeCallback); FFmpegKitConfig.asyncFFprobeExecute(session); @@ -111,7 +111,7 @@ public class FFprobeKit { public static FFprobeSession executeWithArgumentsAsync(final String[] arguments, final FFprobeSessionCompleteCallback completeCallback, final LogCallback logCallback) { - final FFprobeSession session = new FFprobeSession(arguments, completeCallback, logCallback); + final FFprobeSession session = FFprobeSession.create(arguments, completeCallback, logCallback); FFmpegKitConfig.asyncFFprobeExecute(session); @@ -133,7 +133,7 @@ public class FFprobeKit { public static FFprobeSession executeWithArgumentsAsync(final String[] arguments, final FFprobeSessionCompleteCallback completeCallback, final ExecutorService executorService) { - final FFprobeSession session = new FFprobeSession(arguments, completeCallback); + final FFprobeSession session = FFprobeSession.create(arguments, completeCallback); FFmpegKitConfig.asyncFFprobeExecute(session, executorService); @@ -157,7 +157,7 @@ public class FFprobeKit { final FFprobeSessionCompleteCallback completeCallback, final LogCallback logCallback, final ExecutorService executorService) { - final FFprobeSession session = new FFprobeSession(arguments, completeCallback, logCallback); + final FFprobeSession session = FFprobeSession.create(arguments, completeCallback, logCallback); FFmpegKitConfig.asyncFFprobeExecute(session, executorService); @@ -231,7 +231,7 @@ public class FFprobeKit { public static FFprobeSession executeAsync(final String command, final FFprobeSessionCompleteCallback completeCallback, final ExecutorService executorService) { - final FFprobeSession session = new FFprobeSession(FFmpegKitConfig.parseArguments(command), completeCallback); + final FFprobeSession session = FFprobeSession.create(FFmpegKitConfig.parseArguments(command), completeCallback); FFmpegKitConfig.asyncFFprobeExecute(session, executorService); @@ -257,7 +257,7 @@ public class FFprobeKit { final FFprobeSessionCompleteCallback completeCallback, final LogCallback logCallback, final ExecutorService executorService) { - final FFprobeSession session = new FFprobeSession(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback); + final FFprobeSession session = FFprobeSession.create(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback); FFmpegKitConfig.asyncFFprobeExecute(session, executorService); @@ -271,7 +271,7 @@ public class FFprobeKit { * @return media information session created for this execution */ public static MediaInformationSession getMediaInformation(final String path) { - final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path)); + final MediaInformationSession session = MediaInformationSession.create(defaultGetMediaInformationCommandArguments(path)); FFmpegKitConfig.getMediaInformationExecute(session, AbstractSession.DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT); @@ -287,7 +287,7 @@ public class FFprobeKit { */ public static MediaInformationSession getMediaInformation(final String path, final int waitTimeout) { - final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path)); + final MediaInformationSession session = MediaInformationSession.create(defaultGetMediaInformationCommandArguments(path)); FFmpegKitConfig.getMediaInformationExecute(session, waitTimeout); @@ -308,7 +308,7 @@ public class FFprobeKit { */ public static MediaInformationSession getMediaInformationAsync(final String path, final MediaInformationSessionCompleteCallback completeCallback) { - final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), completeCallback); + final MediaInformationSession session = MediaInformationSession.create(defaultGetMediaInformationCommandArguments(path), completeCallback); FFmpegKitConfig.asyncGetMediaInformationExecute(session, AbstractSession.DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT); @@ -333,7 +333,7 @@ public class FFprobeKit { final MediaInformationSessionCompleteCallback completeCallback, final LogCallback logCallback, final int waitTimeout) { - final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), completeCallback, logCallback); + final MediaInformationSession session = MediaInformationSession.create(defaultGetMediaInformationCommandArguments(path), completeCallback, logCallback); FFmpegKitConfig.asyncGetMediaInformationExecute(session, waitTimeout); @@ -356,7 +356,7 @@ public class FFprobeKit { public static MediaInformationSession getMediaInformationAsync(final String path, final MediaInformationSessionCompleteCallback completeCallback, final ExecutorService executorService) { - final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), completeCallback); + final MediaInformationSession session = MediaInformationSession.create(defaultGetMediaInformationCommandArguments(path), completeCallback); FFmpegKitConfig.asyncGetMediaInformationExecute(session, executorService, AbstractSession.DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT); @@ -383,7 +383,7 @@ public class FFprobeKit { final LogCallback logCallback, final ExecutorService executorService, final int waitTimeout) { - final MediaInformationSession session = new MediaInformationSession(defaultGetMediaInformationCommandArguments(path), completeCallback, logCallback); + final MediaInformationSession session = MediaInformationSession.create(defaultGetMediaInformationCommandArguments(path), completeCallback, logCallback); FFmpegKitConfig.asyncGetMediaInformationExecute(session, executorService, waitTimeout); @@ -397,7 +397,7 @@ public class FFprobeKit { * @return media information session created for this execution */ public static MediaInformationSession getMediaInformationFromCommand(final String command) { - final MediaInformationSession session = new MediaInformationSession(FFmpegKitConfig.parseArguments(command)); + final MediaInformationSession session = MediaInformationSession.create(FFmpegKitConfig.parseArguments(command)); FFmpegKitConfig.getMediaInformationExecute(session, AbstractSession.DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT); @@ -447,7 +447,7 @@ public class FFprobeKit { final MediaInformationSessionCompleteCallback completeCallback, final LogCallback logCallback, final int waitTimeout) { - final MediaInformationSession session = new MediaInformationSession(arguments, completeCallback, logCallback); + final MediaInformationSession session = MediaInformationSession.create(arguments, completeCallback, logCallback); FFmpegKitConfig.asyncGetMediaInformationExecute(session, waitTimeout); diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFprobeSession.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFprobeSession.java index 2d97220..dc2add9 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFprobeSession.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/FFprobeSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021 Taner Sener + * Copyright (c) 2020-2022 Taner Sener * * This file is part of FFmpegKit. * @@ -34,8 +34,8 @@ public class FFprobeSession extends AbstractSession implements Session { * * @param arguments command arguments */ - public FFprobeSession(final String[] arguments) { - this(arguments, null); + public static FFprobeSession create(final String[] arguments) { + return new FFprobeSession(arguments, null, null, FFmpegKitConfig.getLogRedirectionStrategy()); } /** @@ -44,8 +44,8 @@ public class FFprobeSession extends AbstractSession implements Session { * @param arguments command arguments * @param completeCallback session specific complete callback */ - public FFprobeSession(final String[] arguments, final FFprobeSessionCompleteCallback completeCallback) { - this(arguments, completeCallback, null); + public static FFprobeSession create(final String[] arguments, final FFprobeSessionCompleteCallback completeCallback) { + return new FFprobeSession(arguments, completeCallback, null, FFmpegKitConfig.getLogRedirectionStrategy()); } /** @@ -55,10 +55,10 @@ public class FFprobeSession extends AbstractSession implements Session { * @param completeCallback session specific complete callback * @param logCallback session specific log callback */ - public FFprobeSession(final String[] arguments, - final FFprobeSessionCompleteCallback completeCallback, - final LogCallback logCallback) { - this(arguments, completeCallback, logCallback, FFmpegKitConfig.getLogRedirectionStrategy()); + public static FFprobeSession create(final String[] arguments, + final FFprobeSessionCompleteCallback completeCallback, + final LogCallback logCallback) { + return new FFprobeSession(arguments, completeCallback, logCallback, FFmpegKitConfig.getLogRedirectionStrategy()); } /** @@ -69,10 +69,25 @@ public class FFprobeSession extends AbstractSession implements Session { * @param logCallback session specific log callback * @param logRedirectionStrategy session specific log redirection strategy */ - public FFprobeSession(final String[] arguments, - final FFprobeSessionCompleteCallback completeCallback, - final LogCallback logCallback, - final LogRedirectionStrategy logRedirectionStrategy) { + public static FFprobeSession create(final String[] arguments, + final FFprobeSessionCompleteCallback completeCallback, + final LogCallback logCallback, + final LogRedirectionStrategy logRedirectionStrategy) { + return new FFprobeSession(arguments, completeCallback, logCallback, logRedirectionStrategy); + } + + /** + * Builds a new FFprobe session. + * + * @param arguments command arguments + * @param completeCallback session specific complete callback + * @param logCallback session specific log callback + * @param logRedirectionStrategy session specific log redirection strategy + */ + private FFprobeSession(final String[] arguments, + final FFprobeSessionCompleteCallback completeCallback, + final LogCallback logCallback, + final LogRedirectionStrategy logRedirectionStrategy) { super(arguments, logCallback, logRedirectionStrategy); this.completeCallback = completeCallback; diff --git a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/MediaInformationSession.java b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/MediaInformationSession.java index 97ed2d2..545662e 100644 --- a/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/MediaInformationSession.java +++ b/android/ffmpeg-kit-android-lib/src/main/java/com/arthenica/ffmpegkit/MediaInformationSession.java @@ -40,8 +40,8 @@ public class MediaInformationSession extends AbstractSession implements Session * * @param arguments command arguments */ - public MediaInformationSession(final String[] arguments) { - this(arguments, null); + public static MediaInformationSession create(final String[] arguments) { + return new MediaInformationSession(arguments, null, null); } /** @@ -50,8 +50,8 @@ public class MediaInformationSession extends AbstractSession implements Session * @param arguments command arguments * @param completeCallback session specific complete callback */ - public MediaInformationSession(final String[] arguments, final MediaInformationSessionCompleteCallback completeCallback) { - this(arguments, completeCallback, null); + public static MediaInformationSession create(final String[] arguments, final MediaInformationSessionCompleteCallback completeCallback) { + return new MediaInformationSession(arguments, completeCallback, null); } /** @@ -61,7 +61,18 @@ public class MediaInformationSession extends AbstractSession implements Session * @param completeCallback session specific complete callback * @param logCallback session specific log callback */ - public MediaInformationSession(final String[] arguments, final MediaInformationSessionCompleteCallback completeCallback, final LogCallback logCallback) { + public static MediaInformationSession create(final String[] arguments, final MediaInformationSessionCompleteCallback completeCallback, final LogCallback logCallback) { + return new MediaInformationSession(arguments, completeCallback, logCallback); + } + + /** + * Creates a new media information session. + * + * @param arguments command arguments + * @param completeCallback session specific complete callback + * @param logCallback session specific log callback + */ + private MediaInformationSession(final String[] arguments, final MediaInformationSessionCompleteCallback completeCallback, final LogCallback logCallback) { super(arguments, logCallback, LogRedirectionStrategy.NEVER_PRINT_LOGS); this.completeCallback = completeCallback; diff --git a/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFmpegKitConfigTest.java b/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFmpegKitConfigTest.java index 0934ec0..38a77c2 100644 --- a/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFmpegKitConfigTest.java +++ b/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFmpegKitConfigTest.java @@ -175,14 +175,14 @@ public class FFmpegKitConfigTest { FFmpegKitConfig.setSessionHistorySize(newSize); for (int i = 1; i <= (newSize + 5); i++) { - new FFmpegSession(TEST_ARGUMENTS); + FFmpegSession.create(TEST_ARGUMENTS); Assert.assertTrue(FFmpegKitConfig.getSessions().size() <= newSize); } newSize = 3; FFmpegKitConfig.setSessionHistorySize(newSize); for (int i = 1; i <= (newSize + 5); i++) { - new FFmpegSession(TEST_ARGUMENTS); + FFmpegSession.create(TEST_ARGUMENTS); Assert.assertTrue(FFmpegKitConfig.getSessions().size() <= newSize); } } diff --git a/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFmpegSessionTest.java b/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFmpegSessionTest.java index e84e34d..ba855c9 100644 --- a/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFmpegSessionTest.java +++ b/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFmpegSessionTest.java @@ -30,7 +30,7 @@ public class FFmpegSessionTest { @Test public void constructorTest() { - FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS); + FFmpegSession ffmpegSession = FFmpegSession.create(TEST_ARGUMENTS); // 1. getCompleteCallback Assert.assertNull(ffmpegSession.getCompleteCallback()); @@ -100,7 +100,7 @@ public class FFmpegSessionTest { } }; - FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS, completeCallback); + FFmpegSession ffmpegSession = FFmpegSession.create(TEST_ARGUMENTS, completeCallback); // 1. getCompleteCallback Assert.assertEquals(ffmpegSession.getCompleteCallback(), completeCallback); @@ -184,7 +184,7 @@ public class FFmpegSessionTest { } }; - FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS, completeCallback, logCallback, statisticsCallback); + FFmpegSession ffmpegSession = FFmpegSession.create(TEST_ARGUMENTS, completeCallback, logCallback, statisticsCallback); // 1. getCompleteCallback Assert.assertEquals(ffmpegSession.getCompleteCallback(), completeCallback); @@ -247,9 +247,9 @@ public class FFmpegSessionTest { @Test public void getSessionIdTest() { - FFmpegSession ffmpegSession1 = new FFmpegSession(TEST_ARGUMENTS); - FFmpegSession ffmpegSession2 = new FFmpegSession(TEST_ARGUMENTS); - FFmpegSession ffmpegSession3 = new FFmpegSession(TEST_ARGUMENTS); + FFmpegSession ffmpegSession1 = FFmpegSession.create(TEST_ARGUMENTS); + FFmpegSession ffmpegSession2 = FFmpegSession.create(TEST_ARGUMENTS); + FFmpegSession ffmpegSession3 = FFmpegSession.create(TEST_ARGUMENTS); Assert.assertTrue(ffmpegSession3.getSessionId() > ffmpegSession2.getSessionId()); Assert.assertTrue(ffmpegSession3.getSessionId() > ffmpegSession1.getSessionId()); @@ -262,7 +262,7 @@ public class FFmpegSessionTest { @Test public void getLogs() { - final FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS); + final FFmpegSession ffmpegSession = FFmpegSession.create(TEST_ARGUMENTS); String logMessage1 = "i am log one"; String logMessage2 = "i am log two"; @@ -279,7 +279,7 @@ public class FFmpegSessionTest { @Test public void getLogsAsStringTest() { - final FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS); + final FFmpegSession ffmpegSession = FFmpegSession.create(TEST_ARGUMENTS); String logMessage1 = "i am log one"; String logMessage2 = "i am log two"; @@ -296,18 +296,18 @@ public class FFmpegSessionTest { public void getLogRedirectionStrategy() { FFmpegKitConfig.setLogRedirectionStrategy(LogRedirectionStrategy.NEVER_PRINT_LOGS); - final FFmpegSession ffmpegSession1 = new FFmpegSession(TEST_ARGUMENTS); + final FFmpegSession ffmpegSession1 = FFmpegSession.create(TEST_ARGUMENTS); Assert.assertEquals(FFmpegKitConfig.getLogRedirectionStrategy(), ffmpegSession1.getLogRedirectionStrategy()); FFmpegKitConfig.setLogRedirectionStrategy(LogRedirectionStrategy.PRINT_LOGS_WHEN_SESSION_CALLBACK_NOT_DEFINED); - final FFmpegSession ffmpegSession2 = new FFmpegSession(TEST_ARGUMENTS); + final FFmpegSession ffmpegSession2 = FFmpegSession.create(TEST_ARGUMENTS); Assert.assertEquals(FFmpegKitConfig.getLogRedirectionStrategy(), ffmpegSession2.getLogRedirectionStrategy()); } @Test public void startRunningTest() { - FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS); + FFmpegSession ffmpegSession = FFmpegSession.create(TEST_ARGUMENTS); ffmpegSession.startRunning(); @@ -318,7 +318,7 @@ public class FFmpegSessionTest { @Test public void completeTest() { - FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS); + FFmpegSession ffmpegSession = FFmpegSession.create(TEST_ARGUMENTS); ffmpegSession.startRunning(); ffmpegSession.complete(new ReturnCode(100)); @@ -331,7 +331,7 @@ public class FFmpegSessionTest { @Test public void failTest() { - FFmpegSession ffmpegSession = new FFmpegSession(TEST_ARGUMENTS); + FFmpegSession ffmpegSession = FFmpegSession.create(TEST_ARGUMENTS); ffmpegSession.startRunning(); ffmpegSession.fail(new Exception("")); diff --git a/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFprobeSessionTest.java b/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFprobeSessionTest.java index 7374e6c..ee2b412 100644 --- a/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFprobeSessionTest.java +++ b/android/ffmpeg-kit-android-lib/src/test/java/com/arthenica/ffmpegkit/FFprobeSessionTest.java @@ -30,7 +30,7 @@ public class FFprobeSessionTest { @Test public void constructorTest() { - FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS); + FFprobeSession ffprobeSession = FFprobeSession.create(TEST_ARGUMENTS); // 1. getCompleteCallback Assert.assertNull(ffprobeSession.getCompleteCallback()); @@ -97,7 +97,7 @@ public class FFprobeSessionTest { } }; - FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS, completeCallback); + FFprobeSession ffprobeSession = FFprobeSession.create(TEST_ARGUMENTS, completeCallback); // 1. getCompleteCallback Assert.assertEquals(ffprobeSession.getCompleteCallback(), completeCallback); @@ -171,7 +171,7 @@ public class FFprobeSessionTest { } }; - FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS, completeCallback, logCallback); + FFprobeSession ffprobeSession = FFprobeSession.create(TEST_ARGUMENTS, completeCallback, logCallback); // 1. getCompleteCallback Assert.assertEquals(ffprobeSession.getCompleteCallback(), completeCallback); @@ -231,9 +231,9 @@ public class FFprobeSessionTest { @Test public void getSessionIdTest() { - FFprobeSession ffprobeSession1 = new FFprobeSession(TEST_ARGUMENTS); - FFprobeSession ffprobeSession2 = new FFprobeSession(TEST_ARGUMENTS); - FFprobeSession ffprobeSession3 = new FFprobeSession(TEST_ARGUMENTS); + FFprobeSession ffprobeSession1 = FFprobeSession.create(TEST_ARGUMENTS); + FFprobeSession ffprobeSession2 = FFprobeSession.create(TEST_ARGUMENTS); + FFprobeSession ffprobeSession3 = FFprobeSession.create(TEST_ARGUMENTS); Assert.assertTrue(ffprobeSession3.getSessionId() > ffprobeSession2.getSessionId()); Assert.assertTrue(ffprobeSession3.getSessionId() > ffprobeSession1.getSessionId()); @@ -246,7 +246,7 @@ public class FFprobeSessionTest { @Test public void getLogs() { - final FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS); + final FFprobeSession ffprobeSession = FFprobeSession.create(TEST_ARGUMENTS); String logMessage1 = "i am log one"; String logMessage2 = "i am log two"; @@ -263,7 +263,7 @@ public class FFprobeSessionTest { @Test public void getLogsAsStringTest() { - final FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS); + final FFprobeSession ffprobeSession = FFprobeSession.create(TEST_ARGUMENTS); String logMessage1 = "i am log one"; String logMessage2 = "i am log two"; @@ -280,18 +280,18 @@ public class FFprobeSessionTest { public void getLogRedirectionStrategy() { FFmpegKitConfig.setLogRedirectionStrategy(LogRedirectionStrategy.NEVER_PRINT_LOGS); - final FFprobeSession ffprobeSession1 = new FFprobeSession(TEST_ARGUMENTS); + final FFprobeSession ffprobeSession1 = FFprobeSession.create(TEST_ARGUMENTS); Assert.assertEquals(FFmpegKitConfig.getLogRedirectionStrategy(), ffprobeSession1.getLogRedirectionStrategy()); FFmpegKitConfig.setLogRedirectionStrategy(LogRedirectionStrategy.PRINT_LOGS_WHEN_SESSION_CALLBACK_NOT_DEFINED); - final FFprobeSession ffprobeSession2 = new FFprobeSession(TEST_ARGUMENTS); + final FFprobeSession ffprobeSession2 = FFprobeSession.create(TEST_ARGUMENTS); Assert.assertEquals(FFmpegKitConfig.getLogRedirectionStrategy(), ffprobeSession2.getLogRedirectionStrategy()); } @Test public void startRunningTest() { - FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS); + FFprobeSession ffprobeSession = FFprobeSession.create(TEST_ARGUMENTS); ffprobeSession.startRunning(); @@ -302,7 +302,7 @@ public class FFprobeSessionTest { @Test public void completeTest() { - FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS); + FFprobeSession ffprobeSession = FFprobeSession.create(TEST_ARGUMENTS); ffprobeSession.startRunning(); ffprobeSession.complete(new ReturnCode(100)); @@ -315,7 +315,7 @@ public class FFprobeSessionTest { @Test public void failTest() { - FFprobeSession ffprobeSession = new FFprobeSession(TEST_ARGUMENTS); + FFprobeSession ffprobeSession = FFprobeSession.create(TEST_ARGUMENTS); ffprobeSession.startRunning(); ffprobeSession.fail(new Exception("")); diff --git a/apple/Makefile.in b/apple/Makefile.in index f2c68c0..633d73f 100644 --- a/apple/Makefile.in +++ b/apple/Makefile.in @@ -229,6 +229,7 @@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FFMPEG_FRAMEWORKS = @FFMPEG_FRAMEWORKS@ FGREP = @FGREP@ +FILECMD = @FILECMD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ diff --git a/apple/src/FFmpegKit.m b/apple/src/FFmpegKit.m index 9e82404..721f055 100644 --- a/apple/src/FFmpegKit.m +++ b/apple/src/FFmpegKit.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021 Taner Sener + * Copyright (c) 2018-2022 Taner Sener * * This file is part of FFmpegKit. * @@ -35,61 +35,61 @@ } + (FFmpegSession*)executeWithArguments:(NSArray*)arguments { - FFmpegSession* session = [[FFmpegSession alloc] init:arguments]; + FFmpegSession* session = [FFmpegSession create:arguments]; [FFmpegKitConfig ffmpegExecute:session]; return session; } + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback { - FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:completeCallback]; + FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncFFmpegExecute:session]; return session; } + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback { - FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; + FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; [FFmpegKitConfig asyncFFmpegExecute:session]; return session; } + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue { - FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:completeCallback]; + FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; return session; } + (FFmpegSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback onDispatchQueue:(dispatch_queue_t)queue { - FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; + FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; return session; } + (FFmpegSession*)execute:(NSString*)command { - FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command]]; + FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command]]; [FFmpegKitConfig ffmpegExecute:session]; return session; } + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback { - FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback]; + FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncFFmpegExecute:session]; return session; } + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback { - FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; + FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; [FFmpegKitConfig asyncFFmpegExecute:session]; return session; } + (FFmpegSession*)executeAsync:(NSString*)command withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue { - FFmpegSession* session = [[FFmpegSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback]; + FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; return session; } + (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] withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; + FFmpegSession* session = [FFmpegSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback]; [FFmpegKitConfig asyncFFmpegExecute:session onDispatchQueue:queue]; return session; } diff --git a/apple/src/FFmpegSession.h b/apple/src/FFmpegSession.h index fac4ff5..f877d34 100644 --- a/apple/src/FFmpegSession.h +++ b/apple/src/FFmpegSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Taner Sener + * Copyright (c) 2021-2022 Taner Sener * * This file is part of FFmpegKit. * @@ -35,7 +35,7 @@ * * @param arguments command arguments */ -- (instancetype)init:(NSArray*)arguments; ++ (instancetype)create:(NSArray*)arguments; /** * Builds a new FFmpeg session. @@ -43,7 +43,7 @@ * @param arguments command arguments * @param completeCallback session specific complete callback */ -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback; /** * Builds a new FFmpeg session. @@ -53,7 +53,7 @@ * @param logCallback session specific log callback * @param statisticsCallback session specific statistics callback */ -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback; /** * Builds a new FFmpeg session. @@ -64,7 +64,7 @@ * @param statisticsCallback session specific statistics callback * @param logRedirectionStrategy session specific log redirection strategy */ -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; /** * Returns the session specific statistics callback. diff --git a/apple/src/FFmpegSession.m b/apple/src/FFmpegSession.m index 6fdcd68..df0751b 100644 --- a/apple/src/FFmpegSession.m +++ b/apple/src/FFmpegSession.m @@ -33,46 +33,20 @@ // EMPTY INITIALIZE } -- (instancetype)init:(NSArray*)arguments { - - self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; - - if (self) { - _statisticsCallback = nil; - _completeCallback = nil; - _statistics = [[NSMutableArray alloc] init]; - _statisticsLock = [[NSRecursiveLock alloc] init]; - } - - return self; ++ (instancetype)create:(NSArray*)arguments { + return [[self alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; } -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback { - - self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; - - if (self) { - _statisticsCallback = nil; - _completeCallback = completeCallback; - _statistics = [[NSMutableArray alloc] init]; - _statisticsLock = [[NSRecursiveLock alloc] init]; - } - - return self; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback { + return [[self alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; } -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback { ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback { + return [[self alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; +} - self = [super init:arguments withLogCallback:logCallback withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; - - if (self) { - _statisticsCallback = statisticsCallback; - _completeCallback = completeCallback; - _statistics = [[NSMutableArray alloc] init]; - _statisticsLock = [[NSRecursiveLock alloc] init]; - } - - return self; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { + return [[self alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withStatisticsCallback:statisticsCallback withLogRedirectionStrategy:logRedirectionStrategy]; } - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFmpegSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withStatisticsCallback:(StatisticsCallback)statisticsCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { diff --git a/apple/src/FFprobeKit.m b/apple/src/FFprobeKit.m index 59cdeab..d7aeeec 100644 --- a/apple/src/FFprobeKit.m +++ b/apple/src/FFprobeKit.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021 Taner Sener + * Copyright (c) 2020-2022 Taner Sener * * This file is part of FFmpegKit. * @@ -33,121 +33,121 @@ } + (FFprobeSession*)executeWithArguments:(NSArray*)arguments { - FFprobeSession* session = [[FFprobeSession alloc] init:arguments]; + FFprobeSession* session = [FFprobeSession create:arguments]; [FFmpegKitConfig ffprobeExecute:session]; return session; } + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback { - FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:completeCallback]; + FFprobeSession* session = [FFprobeSession create:arguments withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncFFprobeExecute:session]; return session; } + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback { - FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback]; + FFprobeSession* session = [FFprobeSession create:arguments withCompleteCallback:completeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncFFprobeExecute:session]; return session; } + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue { - FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:completeCallback]; + FFprobeSession* session = [FFprobeSession create:arguments withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; return session; } + (FFprobeSession*)executeWithArgumentsAsync:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue { - FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback]; + FFprobeSession* session = [FFprobeSession create:arguments withCompleteCallback:completeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; return session; } + (FFprobeSession*)execute:(NSString*)command { - FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command]]; + FFprobeSession* session = [FFprobeSession create:[FFmpegKitConfig parseArguments:command]]; [FFmpegKitConfig ffprobeExecute:session]; return session; } + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback { - FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback]; + FFprobeSession* session = [FFprobeSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncFFprobeExecute:session]; return session; } + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback { - FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback]; + FFprobeSession* session = [FFprobeSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncFFprobeExecute:session]; return session; } + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue { - FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback]; + FFprobeSession* session = [FFprobeSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; return session; } + (FFprobeSession*)executeAsync:(NSString*)command withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue { - FFprobeSession* session = [[FFprobeSession alloc] init:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback]; + FFprobeSession* session = [FFprobeSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncFFprobeExecute:session onDispatchQueue:queue]; return session; } + (MediaInformationSession*)getMediaInformation:(NSString*)path { NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path]; - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments]; + MediaInformationSession* session = [MediaInformationSession create:arguments]; [FFmpegKitConfig getMediaInformationExecute:session withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit]; return session; } + (MediaInformationSession*)getMediaInformation:(NSString*)path withTimeout:(int)waitTimeout { NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path]; - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments]; + MediaInformationSession* session = [MediaInformationSession create:arguments]; [FFmpegKitConfig getMediaInformationExecute:session withTimeout:waitTimeout]; return session; } + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback { NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path]; - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:completeCallback]; + MediaInformationSession* session = [MediaInformationSession create:arguments withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit]; return session; } + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withTimeout:(int)waitTimeout { NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path]; - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback]; + MediaInformationSession* session = [MediaInformationSession create:arguments withCompleteCallback:completeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session withTimeout:waitTimeout]; return session; } + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback onDispatchQueue:(dispatch_queue_t)queue { NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path]; - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:completeCallback]; + MediaInformationSession* session = [MediaInformationSession create:arguments withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit]; return session; } + (MediaInformationSession*)getMediaInformationAsync:(NSString*)path withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { NSArray* arguments = [FFprobeKit defaultGetMediaInformationCommandArguments:path]; - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:completeCallback]; + MediaInformationSession* session = [MediaInformationSession create:arguments withCompleteCallback:completeCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout]; return session; } + (MediaInformationSession*)getMediaInformationFromCommand:(NSString*)command { - MediaInformationSession* session = [[MediaInformationSession alloc] init:[FFmpegKitConfig parseArguments:command]]; + MediaInformationSession* session = [MediaInformationSession create:[FFmpegKitConfig parseArguments:command]]; [FFmpegKitConfig getMediaInformationExecute:session withTimeout:AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit]; return session; } + (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] withCompleteCallback:completeCallback withLogCallback:logCallback]; + MediaInformationSession* session = [MediaInformationSession create:[FFmpegKitConfig parseArguments:command] withCompleteCallback:completeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout]; return session; } + (MediaInformationSession*)getMediaInformationFromCommandArgumentsAsync:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback onDispatchQueue:(dispatch_queue_t)queue withTimeout:(int)waitTimeout { - MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback]; + MediaInformationSession* session = [MediaInformationSession create:arguments withCompleteCallback:completeCallback withLogCallback:logCallback]; [FFmpegKitConfig asyncGetMediaInformationExecute:session onDispatchQueue:queue withTimeout:waitTimeout]; return session; } diff --git a/apple/src/FFprobeSession.h b/apple/src/FFprobeSession.h index 40f62df..f09dbe6 100644 --- a/apple/src/FFprobeSession.h +++ b/apple/src/FFprobeSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Taner Sener + * Copyright (c) 2021-2022 Taner Sener * * This file is part of FFmpegKit. * @@ -34,7 +34,7 @@ * * @param arguments command arguments */ -- (instancetype)init:(NSArray*)arguments; ++ (instancetype)create:(NSArray*)arguments; /** * Builds a new FFprobe session. @@ -42,7 +42,7 @@ * @param arguments command arguments * @param completeCallback session specific complete callback */ -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback; /** * Builds a new FFprobe session. @@ -51,7 +51,7 @@ * @param completeCallback session specific complete callback * @param logCallback session specific log callback */ -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback; /** * Builds a new FFprobe session. @@ -61,7 +61,7 @@ * @param logCallback session specific log callback * @param logRedirectionStrategy session specific log redirection strategy */ -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy; /** * Returns the session specific complete callback. diff --git a/apple/src/FFprobeSession.m b/apple/src/FFprobeSession.m index 8036d91..40fac64 100644 --- a/apple/src/FFprobeSession.m +++ b/apple/src/FFprobeSession.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Taner Sener + * Copyright (c) 2021-2022 Taner Sener * * This file is part of FFmpegKit. * @@ -29,37 +29,20 @@ // EMPTY INITIALIZE } -- (instancetype)init:(NSArray*)arguments { - - self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; - - if (self) { - _completeCallback = nil; - } - - return self; ++ (instancetype)create:(NSArray*)arguments { + return [[self alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; } -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback { - - self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; - - if (self) { - _completeCallback = completeCallback; - } - - return self; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback { + return [[self alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:nil withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; } -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback { ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback { + return [[self alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; +} - self = [super init:arguments withLogCallback:logCallback withLogRedirectionStrategy:[FFmpegKitConfig getLogRedirectionStrategy]]; - - if (self) { - _completeCallback = completeCallback; - } - - return self; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { + return [[self alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback withLogRedirectionStrategy:logRedirectionStrategy]; } - (instancetype)init:(NSArray*)arguments withCompleteCallback:(FFprobeSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback withLogRedirectionStrategy:(LogRedirectionStrategy)logRedirectionStrategy { diff --git a/apple/src/Makefile.in b/apple/src/Makefile.in index 1020462..e4d7421 100644 --- a/apple/src/Makefile.in +++ b/apple/src/Makefile.in @@ -303,6 +303,7 @@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FFMPEG_FRAMEWORKS = @FFMPEG_FRAMEWORKS@ FGREP = @FGREP@ +FILECMD = @FILECMD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ diff --git a/apple/src/MediaInformationSession.h b/apple/src/MediaInformationSession.h index e529edb..5df4ace 100644 --- a/apple/src/MediaInformationSession.h +++ b/apple/src/MediaInformationSession.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Taner Sener + * Copyright (c) 2021-2022 Taner Sener * * This file is part of FFmpegKit. * @@ -36,7 +36,7 @@ * * @param arguments command arguments */ -- (instancetype)init:(NSArray*)arguments; ++ (instancetype)create:(NSArray*)arguments; /** * Creates a new media information session. @@ -44,7 +44,7 @@ * @param arguments command arguments * @param completeCallback session specific complete callback */ -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback; /** * Creates a new media information session. @@ -53,7 +53,7 @@ * @param completeCallback session specific complete callback * @param logCallback session specific log callback */ -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback; /** * Returns the media information extracted in this session. diff --git a/apple/src/MediaInformationSession.m b/apple/src/MediaInformationSession.m index 76214b0..5ab5398 100644 --- a/apple/src/MediaInformationSession.m +++ b/apple/src/MediaInformationSession.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Taner Sener + * Copyright (c) 2021-2022 Taner Sener * * This file is part of FFmpegKit. * @@ -30,26 +30,16 @@ // EMPTY INITIALIZE } -- (instancetype)init:(NSArray*)arguments { - - self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; - - if (self) { - _completeCallback = nil; - } - - return self; ++ (instancetype)create:(NSArray*)arguments { + return [[self alloc] init:arguments withCompleteCallback:nil withLogCallback:nil]; } -- (instancetype)init:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback { ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback { + return [[self alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:nil]; +} - self = [super init:arguments withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; - - if (self) { - _completeCallback = completeCallback; - } - - return self; ++ (instancetype)create:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback { + return [[self alloc] init:arguments withCompleteCallback:completeCallback withLogCallback:logCallback]; } - (instancetype)init:(NSArray*)arguments withCompleteCallback:(MediaInformationSessionCompleteCallback)completeCallback withLogCallback:(LogCallback)logCallback {