|
|
|
@ -2,14 +2,16 @@ import {NativeEventEmitter, NativeModules} from 'react-native'; |
|
|
|
|
|
|
|
|
|
const {FFmpegKitReactNativeModule} = NativeModules; |
|
|
|
|
|
|
|
|
|
const executeCallbackMap = new Map() |
|
|
|
|
const ffmpegSessionCompleteCallbackMap = new Map() |
|
|
|
|
const ffprobeSessionCompleteCallbackMap = new Map() |
|
|
|
|
const mediaInformationSessionCompleteCallbackMap = new Map() |
|
|
|
|
const logCallbackMap = new Map() |
|
|
|
|
const statisticsCallbackMap = new Map() |
|
|
|
|
const logRedirectionStrategyMap = new Map() |
|
|
|
|
|
|
|
|
|
const eventLogCallbackEvent = "FFmpegKitLogCallbackEvent"; |
|
|
|
|
const eventStatisticsCallbackEvent = "FFmpegKitStatisticsCallbackEvent"; |
|
|
|
|
const eventExecuteCallbackEvent = "FFmpegKitExecuteCallbackEvent"; |
|
|
|
|
const eventCompleteCallbackEvent = "FFmpegKitCompleteCallbackEvent"; |
|
|
|
|
|
|
|
|
|
export const LogRedirectionStrategy = { |
|
|
|
|
ALWAYS_PRINT_LOGS: 0, |
|
|
|
@ -59,17 +61,9 @@ class FFmpegKitReactNativeEventEmitter extends NativeEventEmitter { |
|
|
|
|
export class Session { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the session specific execute callback function. |
|
|
|
|
* Returns the session specific log callback. |
|
|
|
|
* |
|
|
|
|
* @return session specific execute callback function |
|
|
|
|
*/ |
|
|
|
|
getExecuteCallback() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the session specific log callback function. |
|
|
|
|
* |
|
|
|
|
* @return session specific log callback function |
|
|
|
|
* @return session specific log callback |
|
|
|
|
*/ |
|
|
|
|
getLogCallback() { |
|
|
|
|
} |
|
|
|
@ -245,6 +239,14 @@ export class Session { |
|
|
|
|
isFFprobe() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns whether it is a <code>MediaInformation</code> session or not. |
|
|
|
|
* |
|
|
|
|
* @return true if it is a <code>MediaInformation</code> session, false otherwise |
|
|
|
|
*/ |
|
|
|
|
isMediaInformation() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Cancels running the session. |
|
|
|
|
*/ |
|
|
|
@ -254,8 +256,8 @@ export class Session { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Abstract session implementation which includes common features shared by <code>FFmpeg</code> |
|
|
|
|
* and <code>FFprobe</code> sessions. |
|
|
|
|
* Abstract session implementation which includes common features shared by <code>FFmpeg</code>, |
|
|
|
|
* <code>FFprobe</code> and <code>MediaInformation</code> sessions. |
|
|
|
|
*/ |
|
|
|
|
export class AbstractSession extends Session { |
|
|
|
|
|
|
|
|
@ -445,18 +447,9 @@ export class AbstractSession extends Session { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the session specific execute callback function. |
|
|
|
|
* Returns the session specific log callback. |
|
|
|
|
* |
|
|
|
|
* @return session specific execute callback function |
|
|
|
|
*/ |
|
|
|
|
getExecuteCallback() { |
|
|
|
|
return FFmpegKitFactory.getExecuteCallback(this.getSessionId()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the session specific log callback function. |
|
|
|
|
* |
|
|
|
|
* @return session specific log callback function |
|
|
|
|
* @return session specific log callback |
|
|
|
|
*/ |
|
|
|
|
getLogCallback() { |
|
|
|
|
return FFmpegKitFactory.getLogCallback(this.getSessionId()) |
|
|
|
@ -666,6 +659,15 @@ export class AbstractSession extends Session { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns whether it is a <code>MediaInformation</code> session or not. |
|
|
|
|
* |
|
|
|
|
* @return true if it is a <code>MediaInformation</code> session, false otherwise |
|
|
|
|
*/ |
|
|
|
|
isMediaInformation() { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Cancels running the session. |
|
|
|
|
*/ |
|
|
|
@ -707,26 +709,26 @@ export class FFmpegKit { |
|
|
|
|
* into arguments. You can use single or double quote characters to specify arguments inside your 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 statisticsCallback callback that will receive statistics |
|
|
|
|
* @return FFmpeg session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async execute(command, executeCallback, logCallback, statisticsCallback) { |
|
|
|
|
return FFmpegKit.executeWithArguments(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback, statisticsCallback); |
|
|
|
|
static async execute(command, completeCallback, logCallback, statisticsCallback) { |
|
|
|
|
return FFmpegKit.executeWithArguments(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback, statisticsCallback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Synchronously executes FFmpeg with arguments provided. |
|
|
|
|
* |
|
|
|
|
* @param commandArguments 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 statisticsCallback callback that will receive statistics |
|
|
|
|
* @return FFmpeg session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async executeWithArguments(commandArguments, executeCallback, logCallback, statisticsCallback) { |
|
|
|
|
let session = await FFmpegSession.create(commandArguments, executeCallback, logCallback, statisticsCallback); |
|
|
|
|
static async executeWithArguments(commandArguments, completeCallback, logCallback, statisticsCallback) { |
|
|
|
|
let session = await FFmpegSession.create(commandArguments, completeCallback, logCallback, statisticsCallback); |
|
|
|
|
|
|
|
|
|
await FFmpegKitConfig.ffmpegExecute(session); |
|
|
|
|
|
|
|
|
@ -738,32 +740,32 @@ export class FFmpegKit { |
|
|
|
|
* 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 |
|
|
|
|
* 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 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 statisticsCallback callback that will receive statistics |
|
|
|
|
* @return FFmpeg session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async executeAsync(command, executeCallback, logCallback, statisticsCallback) { |
|
|
|
|
return FFmpegKit.executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback, statisticsCallback); |
|
|
|
|
static async executeAsync(command, completeCallback, logCallback, statisticsCallback) { |
|
|
|
|
return FFmpegKit.executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback, statisticsCallback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <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 |
|
|
|
|
* ExecuteCallback if you want to be notified about the result. |
|
|
|
|
* FFmpegSessionCompleteCallback if you want to be notified about the result. |
|
|
|
|
* |
|
|
|
|
* @param commandArguments 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 statisticsCallback callback that will receive statistics |
|
|
|
|
* @return FFmpeg session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async executeWithArgumentsAsync(commandArguments, executeCallback, logCallback, statisticsCallback) { |
|
|
|
|
let session = await FFmpegSession.create(commandArguments, executeCallback, logCallback, statisticsCallback); |
|
|
|
|
static async executeWithArgumentsAsync(commandArguments, completeCallback, logCallback, statisticsCallback) { |
|
|
|
|
let session = await FFmpegSession.create(commandArguments, completeCallback, logCallback, statisticsCallback); |
|
|
|
|
|
|
|
|
|
await FFmpegKitConfig.asyncFFmpegExecute(session); |
|
|
|
|
|
|
|
|
@ -773,7 +775,7 @@ export class FFmpegKit { |
|
|
|
|
/** |
|
|
|
|
* <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 |
|
|
|
|
*/ |
|
|
|
@ -1019,7 +1021,7 @@ export class FFmpegKitConfig { |
|
|
|
|
* <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 |
|
|
|
|
* ExecuteCallback if you want to be notified about the result. |
|
|
|
|
* FFmpegSessionCompleteCallback if you want to be notified about the result. |
|
|
|
|
* |
|
|
|
|
* @param ffmpegSession FFmpeg session which includes command options/arguments |
|
|
|
|
*/ |
|
|
|
@ -1033,7 +1035,7 @@ export class FFmpegKitConfig { |
|
|
|
|
* <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 |
|
|
|
|
* ExecuteCallback if you want to be notified about the result. |
|
|
|
|
* FFprobeSessionCompleteCallback if you want to be notified about the result. |
|
|
|
|
* |
|
|
|
|
* @param ffprobeSession FFprobe session which includes command options/arguments |
|
|
|
|
*/ |
|
|
|
@ -1047,7 +1049,7 @@ export class FFmpegKitConfig { |
|
|
|
|
* <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 |
|
|
|
|
* ExecuteCallback if you want to be notified about the result. |
|
|
|
|
* MediaInformationSessionCompleteCallback if you want to be notified about the result. |
|
|
|
|
* |
|
|
|
|
* @param mediaInformationSession media information session which includes command options/arguments |
|
|
|
|
* @param waitTimeout max time to wait until media information is transmitted |
|
|
|
@ -1059,9 +1061,9 @@ export 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 undefined to disable a previously defined |
|
|
|
|
* @param logCallback log callback or undefined to disable a previously defined |
|
|
|
|
* callback |
|
|
|
|
*/ |
|
|
|
|
static enableLogCallback(logCallback) { |
|
|
|
@ -1069,9 +1071,9 @@ export class FFmpegKitConfig { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <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 undefined to disable a previously |
|
|
|
|
* @param statisticsCallback statistics callback or undefined to disable a previously |
|
|
|
|
* defined callback |
|
|
|
|
*/ |
|
|
|
|
static enableStatisticsCallback(statisticsCallback) { |
|
|
|
@ -1079,13 +1081,58 @@ export class FFmpegKitConfig { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Sets a global callback function to receive execution results. |
|
|
|
|
* <p>Sets a global FFmpegSessionCompleteCallback to receive execution results for FFmpeg sessions. |
|
|
|
|
* |
|
|
|
|
* @param ffmpegSessionCompleteCallback complete callback or undefined to disable a previously defined callback |
|
|
|
|
*/ |
|
|
|
|
static enableFFmpegSessionCompleteCallback(ffmpegSessionCompleteCallback) { |
|
|
|
|
FFmpegKitFactory.setGlobalFFmpegSessionCompleteCallback(ffmpegSessionCompleteCallback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Returns the global FFmpegSessionCompleteCallback set. |
|
|
|
|
* |
|
|
|
|
* @return global FFmpegSessionCompleteCallback or undefined if it is not set |
|
|
|
|
*/ |
|
|
|
|
static getFFmpegSessionCompleteCallback() { |
|
|
|
|
return FFmpegKitFactory.getGlobalFFmpegSessionCompleteCallback(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Sets a global FFprobeSessionCompleteCallback to receive execution results for FFprobe sessions. |
|
|
|
|
* |
|
|
|
|
* @param ffprobeSessionCompleteCallback complete callback or undefined to disable a previously defined callback |
|
|
|
|
*/ |
|
|
|
|
static enableFFprobeSessionCompleteCallback(ffprobeSessionCompleteCallback) { |
|
|
|
|
FFmpegKitFactory.setGlobalFFprobeSessionCompleteCallback(ffprobeSessionCompleteCallback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Returns the global FFprobeSessionCompleteCallback set. |
|
|
|
|
* |
|
|
|
|
* @param executeCallback execute callback function or undefined to disable a previously |
|
|
|
|
* defined callback |
|
|
|
|
* @return global FFprobeSessionCompleteCallback or undefined if it is not set |
|
|
|
|
*/ |
|
|
|
|
static enableExecuteCallback(executeCallback) { |
|
|
|
|
FFmpegKitFactory.setGlobalExecuteCallback(executeCallback); |
|
|
|
|
static getFFprobeSessionCompleteCallback() { |
|
|
|
|
return FFmpegKitFactory.getGlobalFFprobeSessionCompleteCallback(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Sets a global MediaInformationSessionCompleteCallback to receive execution results for MediaInformation sessions. |
|
|
|
|
* |
|
|
|
|
* @param mediaInformationSessionCompleteCallback complete callback or undefined to disable a previously defined |
|
|
|
|
* callback |
|
|
|
|
*/ |
|
|
|
|
static enableMediaInformationSessionCompleteCallback(mediaInformationSessionCompleteCallback) { |
|
|
|
|
FFmpegKitFactory.setGlobalMediaInformationSessionCompleteCallback(mediaInformationSessionCompleteCallback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Returns the global MediaInformationSessionCompleteCallback set. |
|
|
|
|
* |
|
|
|
|
* @return global MediaInformationSessionCompleteCallback or undefined if it is not set |
|
|
|
|
*/ |
|
|
|
|
static getMediaInformationSessionCompleteCallback() { |
|
|
|
|
return FFmpegKitFactory.getGlobalMediaInformationSessionCompleteCallback(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -1195,6 +1242,42 @@ export class FFmpegKitConfig { |
|
|
|
|
return FFmpegKitReactNativeModule.clearSessions(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Returns all FFmpeg sessions in the session history. |
|
|
|
|
* |
|
|
|
|
* @return all FFmpeg sessions in the session history |
|
|
|
|
*/ |
|
|
|
|
static async getFFmpegSessions() { |
|
|
|
|
await FFmpegKitConfig.init(); |
|
|
|
|
|
|
|
|
|
const sessionArray = await FFmpegKitReactNativeModule.getFFmpegSessions(); |
|
|
|
|
return sessionArray.map(FFmpegKitFactory.mapToSession); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Returns all FFprobe sessions in the session history. |
|
|
|
|
* |
|
|
|
|
* @return all FFprobe sessions in the session history |
|
|
|
|
*/ |
|
|
|
|
static async getFFprobeSessions() { |
|
|
|
|
await FFmpegKitConfig.init(); |
|
|
|
|
|
|
|
|
|
const sessionArray = await FFmpegKitReactNativeModule.getFFprobeSessions(); |
|
|
|
|
return sessionArray.map(FFmpegKitFactory.mapToSession); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Returns all MediaInformation sessions in the session history. |
|
|
|
|
* |
|
|
|
|
* @return all MediaInformation sessions in the session history |
|
|
|
|
*/ |
|
|
|
|
static async getMediaInformationSessions() { |
|
|
|
|
await FFmpegKitConfig.init(); |
|
|
|
|
|
|
|
|
|
const sessionArray = await FFmpegKitReactNativeModule.getMediaInformationSessions(); |
|
|
|
|
return sessionArray.map(FFmpegKitFactory.mapToSession); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Returns sessions that have the given state. |
|
|
|
|
* |
|
|
|
@ -1475,9 +1558,11 @@ export class FFmpegKitConfig { |
|
|
|
|
|
|
|
|
|
class FFmpegKitFactory { |
|
|
|
|
|
|
|
|
|
static #ffmpegSessionCompleteCallback = undefined; |
|
|
|
|
static #ffprobeSessionCompleteCallback = undefined; |
|
|
|
|
static #mediaInformationSessionCompleteCallback = undefined; |
|
|
|
|
static #logCallback = undefined; |
|
|
|
|
static #statisticsCallback = undefined; |
|
|
|
|
static #executeCallback = undefined; |
|
|
|
|
static #activeLogLevel = undefined; |
|
|
|
|
|
|
|
|
|
static mapToStatistics(statisticsMap) { |
|
|
|
@ -1560,22 +1645,58 @@ class FFmpegKitFactory { |
|
|
|
|
this.#statisticsCallback = statisticsCallback; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static getExecuteCallback(sessionId) { |
|
|
|
|
return executeCallbackMap.get(sessionId); |
|
|
|
|
static getFFmpegSessionCompleteCallback(sessionId) { |
|
|
|
|
return ffmpegSessionCompleteCallbackMap.get(sessionId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static setFFmpegSessionCompleteCallback(sessionId, completeCallback) { |
|
|
|
|
if (completeCallback !== undefined) { |
|
|
|
|
ffmpegSessionCompleteCallbackMap.set(sessionId, completeCallback); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static getGlobalFFmpegSessionCompleteCallback() { |
|
|
|
|
return this.#ffmpegSessionCompleteCallback; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static setGlobalFFmpegSessionCompleteCallback(completeCallback) { |
|
|
|
|
this.#ffmpegSessionCompleteCallback = completeCallback; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static getFFprobeSessionCompleteCallback(sessionId) { |
|
|
|
|
return ffprobeSessionCompleteCallbackMap.get(sessionId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static setExecuteCallback(sessionId, executeCallback) { |
|
|
|
|
if (executeCallback !== undefined) { |
|
|
|
|
executeCallbackMap.set(sessionId, executeCallback); |
|
|
|
|
static setFFprobeSessionCompleteCallback(sessionId, completeCallback) { |
|
|
|
|
if (completeCallback !== undefined) { |
|
|
|
|
ffprobeSessionCompleteCallbackMap.set(sessionId, completeCallback); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static getGlobalExecuteCallback() { |
|
|
|
|
return this.#executeCallback; |
|
|
|
|
static getGlobalFFprobeSessionCompleteCallback() { |
|
|
|
|
return this.#ffprobeSessionCompleteCallback; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static setGlobalFFprobeSessionCompleteCallback(completeCallback) { |
|
|
|
|
this.#ffprobeSessionCompleteCallback = completeCallback; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static setGlobalExecuteCallback(executeCallback) { |
|
|
|
|
this.#executeCallback = executeCallback; |
|
|
|
|
static getMediaInformationSessionCompleteCallback(sessionId) { |
|
|
|
|
return mediaInformationSessionCompleteCallbackMap.get(sessionId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static setMediaInformationSessionCompleteCallback(sessionId, completeCallback) { |
|
|
|
|
if (completeCallback !== undefined) { |
|
|
|
|
mediaInformationSessionCompleteCallbackMap.set(sessionId, completeCallback); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static getGlobalMediaInformationSessionCompleteCallback() { |
|
|
|
|
return this.#mediaInformationSessionCompleteCallback; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static setGlobalMediaInformationSessionCompleteCallback(completeCallback) { |
|
|
|
|
this.#mediaInformationSessionCompleteCallback = completeCallback; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static setLogLevel(logLevel) { |
|
|
|
@ -1631,7 +1752,7 @@ class FFmpegKitInitializer { |
|
|
|
|
// NOTIFY SESSION CALLBACK DEFINED
|
|
|
|
|
activeLogCallback(log); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log("Exception thrown inside session LogCallback block.", err.stack); |
|
|
|
|
console.log("Exception thrown inside session log callback.", err.stack); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1643,7 +1764,7 @@ class FFmpegKitInitializer { |
|
|
|
|
// NOTIFY GLOBAL CALLBACK DEFINED
|
|
|
|
|
globalLogCallbackFunction(log); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log("Exception thrown inside global LogCallback block.", err.stack); |
|
|
|
|
console.log("Exception thrown inside global log callback.", err.stack); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1697,7 +1818,7 @@ class FFmpegKitInitializer { |
|
|
|
|
// NOTIFY SESSION CALLBACK DEFINED
|
|
|
|
|
activeStatisticsCallback(statistics); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log("Exception thrown inside session StatisticsCallback block.", err.stack); |
|
|
|
|
console.log("Exception thrown inside session statistics callback.", err.stack); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1707,34 +1828,60 @@ class FFmpegKitInitializer { |
|
|
|
|
// NOTIFY GLOBAL CALLBACK DEFINED
|
|
|
|
|
globalStatisticsCallbackFunction(statistics); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log("Exception thrown inside global StatisticsCallback block.", err.stack); |
|
|
|
|
console.log("Exception thrown inside global statistics callback.", err.stack); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static processExecuteCallbackEvent(event) { |
|
|
|
|
let sessionId = event.sessionId; |
|
|
|
|
|
|
|
|
|
FFmpegKitConfig.getSession(sessionId).then(session => { |
|
|
|
|
if (session.getExecuteCallback() !== undefined) { |
|
|
|
|
try { |
|
|
|
|
// NOTIFY SESSION CALLBACK DEFINED
|
|
|
|
|
session.getExecuteCallback()(session); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log("Exception thrown inside session ExecuteCallback block.", err.stack); |
|
|
|
|
static processCompleteCallbackEvent(event) { |
|
|
|
|
if (event !== undefined) { |
|
|
|
|
let sessionId = event.sessionId; |
|
|
|
|
|
|
|
|
|
FFmpegKitConfig.getSession(sessionId).then(session => { |
|
|
|
|
if (session !== undefined) { |
|
|
|
|
if (session.getCompleteCallback() !== undefined) { |
|
|
|
|
try { |
|
|
|
|
// NOTIFY SESSION CALLBACK DEFINED
|
|
|
|
|
session.getCompleteCallback()(session); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log("Exception thrown inside session complete callback.", err.stack); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (session.isFFmpeg()) { |
|
|
|
|
let globalFFmpegSessionCompleteCallback = FFmpegKitFactory.getGlobalFFmpegSessionCompleteCallback(); |
|
|
|
|
if (globalFFmpegSessionCompleteCallback !== undefined) { |
|
|
|
|
try { |
|
|
|
|
// NOTIFY GLOBAL CALLBACK DEFINED
|
|
|
|
|
globalFFmpegSessionCompleteCallback(session); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log("Exception thrown inside global complete callback.", err.stack); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (session.isFFprobe()) { |
|
|
|
|
let globalFFprobeSessionCompleteCallback = FFmpegKitFactory.getGlobalFFprobeSessionCompleteCallback(); |
|
|
|
|
if (globalFFprobeSessionCompleteCallback !== undefined) { |
|
|
|
|
try { |
|
|
|
|
// NOTIFY GLOBAL CALLBACK DEFINED
|
|
|
|
|
globalFFprobeSessionCompleteCallback(session); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log("Exception thrown inside global complete callback.", err.stack); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (session.isMediaInformation()) { |
|
|
|
|
let globalMediaInformationSessionCompleteCallback = FFmpegKitFactory.getGlobalMediaInformationSessionCompleteCallback(); |
|
|
|
|
if (globalMediaInformationSessionCompleteCallback !== undefined) { |
|
|
|
|
try { |
|
|
|
|
// NOTIFY GLOBAL CALLBACK DEFINED
|
|
|
|
|
globalMediaInformationSessionCompleteCallback(session); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log("Exception thrown inside global complete callback.", err.stack); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let globalExecuteCallbackFunction = FFmpegKitFactory.getGlobalExecuteCallback(); |
|
|
|
|
if (globalExecuteCallbackFunction !== undefined) { |
|
|
|
|
try { |
|
|
|
|
// NOTIFY GLOBAL CALLBACK DEFINED
|
|
|
|
|
globalExecuteCallbackFunction(session); |
|
|
|
|
} catch (err) { |
|
|
|
|
console.log("Exception thrown inside global ExecuteCallback block.", err.stack); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static async initialize() { |
|
|
|
@ -1748,7 +1895,7 @@ class FFmpegKitInitializer { |
|
|
|
|
|
|
|
|
|
this.#eventEmitter.addListener(eventLogCallbackEvent, FFmpegKitInitializer.processLogCallbackEvent); |
|
|
|
|
this.#eventEmitter.addListener(eventStatisticsCallbackEvent, FFmpegKitInitializer.processStatisticsCallbackEvent); |
|
|
|
|
this.#eventEmitter.addListener(eventExecuteCallbackEvent, FFmpegKitInitializer.processExecuteCallbackEvent); |
|
|
|
|
this.#eventEmitter.addListener(eventCompleteCallbackEvent, FFmpegKitInitializer.processCompleteCallbackEvent); |
|
|
|
|
|
|
|
|
|
FFmpegKitFactory.setLogLevel(await FFmpegKitReactNativeModule.getLogLevel()); |
|
|
|
|
const version = FFmpegKitFactory.getVersion(); |
|
|
|
@ -1779,17 +1926,17 @@ export class FFmpegSession extends AbstractSession { |
|
|
|
|
* Creates a new FFmpeg session. |
|
|
|
|
* |
|
|
|
|
* @param argumentsArray FFmpeg command arguments |
|
|
|
|
* @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 statisticsCallback callback that will receive statistics |
|
|
|
|
* @param logRedirectionStrategy defines how logs will be redirected |
|
|
|
|
* @returns FFmpeg session created |
|
|
|
|
*/ |
|
|
|
|
static async create(argumentsArray, executeCallback, logCallback, statisticsCallback, logRedirectionStrategy) { |
|
|
|
|
static async create(argumentsArray, completeCallback, logCallback, statisticsCallback, logRedirectionStrategy) { |
|
|
|
|
const session = await AbstractSession.createFFmpegSession(argumentsArray, logRedirectionStrategy); |
|
|
|
|
const sessionId = session.getSessionId(); |
|
|
|
|
|
|
|
|
|
FFmpegKitFactory.setExecuteCallback(sessionId, executeCallback); |
|
|
|
|
FFmpegKitFactory.setFFmpegSessionCompleteCallback(sessionId, completeCallback); |
|
|
|
|
FFmpegKitFactory.setLogCallback(sessionId, logCallback); |
|
|
|
|
FFmpegKitFactory.setStatisticsCallback(sessionId, statisticsCallback); |
|
|
|
|
|
|
|
|
@ -1807,14 +1954,23 @@ export class FFmpegSession extends AbstractSession { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the session specific statistics callback function. |
|
|
|
|
* Returns the session specific statistics callback. |
|
|
|
|
* |
|
|
|
|
* @return session specific statistics callback function |
|
|
|
|
* @return session specific statistics callback |
|
|
|
|
*/ |
|
|
|
|
getStatisticsCallback() { |
|
|
|
|
return FFmpegKitFactory.getStatisticsCallback(this.getSessionId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the session specific complete callback. |
|
|
|
|
* |
|
|
|
|
* @return session specific complete callback |
|
|
|
|
*/ |
|
|
|
|
getCompleteCallback() { |
|
|
|
|
return FFmpegKitFactory.getFFmpegSessionCompleteCallback(this.getSessionId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 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. |
|
|
|
@ -1867,6 +2023,10 @@ export class FFmpegSession extends AbstractSession { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isMediaInformation() { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -1879,24 +2039,24 @@ export class FFprobeKit { |
|
|
|
|
* into arguments. You can use single or double quote characters to specify arguments inside your 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 |
|
|
|
|
* @return FFprobe session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async execute(command, executeCallback, logCallback) { |
|
|
|
|
return FFprobeKit.executeWithArguments(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback); |
|
|
|
|
static async execute(command, completeCallback, logCallback) { |
|
|
|
|
return FFprobeKit.executeWithArguments(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Synchronously executes FFprobe with arguments provided. |
|
|
|
|
* |
|
|
|
|
* @param commandArguments 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 logCallback callback that will receive logs |
|
|
|
|
* @return FFprobe session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async executeWithArguments(commandArguments, executeCallback, logCallback) { |
|
|
|
|
let session = await FFprobeSession.create(commandArguments, executeCallback, logCallback); |
|
|
|
|
static async executeWithArguments(commandArguments, completeCallback, logCallback) { |
|
|
|
|
let session = await FFprobeSession.create(commandArguments, completeCallback, logCallback); |
|
|
|
|
|
|
|
|
|
await FFmpegKitConfig.ffprobeExecute(session); |
|
|
|
|
|
|
|
|
@ -1908,30 +2068,30 @@ export class FFprobeKit { |
|
|
|
|
* 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 |
|
|
|
|
* 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 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 |
|
|
|
|
* @return FFprobe session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async executeAsync(command, executeCallback, logCallback) { |
|
|
|
|
return FFprobeKit.executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback); |
|
|
|
|
static async executeAsync(command, completeCallback, logCallback) { |
|
|
|
|
return FFprobeKit.executeWithArgumentsAsync(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <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 |
|
|
|
|
* ExecuteCallback if you want to be notified about the result. |
|
|
|
|
* FFprobeSessionCompleteCallback if you want to be notified about the result. |
|
|
|
|
* |
|
|
|
|
* @param commandArguments 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 logCallback callback that will receive logs |
|
|
|
|
* @return FFprobe session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async executeWithArgumentsAsync(commandArguments, executeCallback, logCallback) { |
|
|
|
|
let session = await FFprobeSession.create(commandArguments, executeCallback, logCallback); |
|
|
|
|
static async executeWithArgumentsAsync(commandArguments, completeCallback, logCallback) { |
|
|
|
|
let session = await FFprobeSession.create(commandArguments, completeCallback, logCallback); |
|
|
|
|
|
|
|
|
|
await FFmpegKitConfig.asyncFFprobeExecute(session); |
|
|
|
|
|
|
|
|
@ -1942,14 +2102,14 @@ export class FFprobeKit { |
|
|
|
|
* <p>Extracts media information for the file specified with path. |
|
|
|
|
* |
|
|
|
|
* @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 waitTimeout max time to wait until media information is transmitted |
|
|
|
|
* @return media information session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async getMediaInformation(path, executeCallback, logCallback, waitTimeout) { |
|
|
|
|
static async getMediaInformation(path, completeCallback, logCallback, waitTimeout) { |
|
|
|
|
const commandArguments = ["-v", "error", "-hide_banner", "-print_format", "json", "-show_format", "-show_streams", "-show_chapters", "-i", path]; |
|
|
|
|
return FFprobeKit.getMediaInformationFromCommandArguments(commandArguments, executeCallback, logCallback, waitTimeout); |
|
|
|
|
return FFprobeKit.getMediaInformationFromCommandArguments(commandArguments, completeCallback, logCallback, waitTimeout); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -1957,13 +2117,13 @@ export class FFprobeKit { |
|
|
|
|
* this method must generate the output in JSON format in order to successfully extract media information from it. |
|
|
|
|
* |
|
|
|
|
* @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 waitTimeout max time to wait until media information is transmitted |
|
|
|
|
* @return media information session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async getMediaInformationFromCommand(command, executeCallback, logCallback, waitTimeout) { |
|
|
|
|
return FFprobeKit.getMediaInformationFromCommandArguments(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback, waitTimeout); |
|
|
|
|
static async getMediaInformationFromCommand(command, completeCallback, logCallback, waitTimeout) { |
|
|
|
|
return FFprobeKit.getMediaInformationFromCommandArguments(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback, waitTimeout); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -1972,13 +2132,13 @@ export class FFprobeKit { |
|
|
|
|
* from it. |
|
|
|
|
* |
|
|
|
|
* @param commandArguments FFprobe command arguments 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 waitTimeout max time to wait until media information is transmitted |
|
|
|
|
* @return media information session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async getMediaInformationFromCommandArguments(commandArguments, executeCallback, logCallback, waitTimeout) { |
|
|
|
|
let session = await MediaInformationSession.create(commandArguments, executeCallback, logCallback); |
|
|
|
|
static async getMediaInformationFromCommandArguments(commandArguments, completeCallback, logCallback, waitTimeout) { |
|
|
|
|
let session = await MediaInformationSession.create(commandArguments, completeCallback, logCallback); |
|
|
|
|
|
|
|
|
|
await FFmpegKitConfig.getMediaInformationExecute(session, waitTimeout); |
|
|
|
|
|
|
|
|
@ -1989,17 +2149,17 @@ export class FFprobeKit { |
|
|
|
|
* <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 |
|
|
|
|
* 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 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 waitTimeout max time to wait until media information is transmitted |
|
|
|
|
* @return media information session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async getMediaInformationAsync(path, executeCallback, logCallback, waitTimeout) { |
|
|
|
|
static async getMediaInformationAsync(path, completeCallback, logCallback, waitTimeout) { |
|
|
|
|
const commandArguments = ["-v", "error", "-hide_banner", "-print_format", "json", "-show_format", "-show_streams", "-show_chapters", "-i", path]; |
|
|
|
|
return FFprobeKit.getMediaInformationFromCommandArgumentsAsync(commandArguments, executeCallback, logCallback, waitTimeout); |
|
|
|
|
return FFprobeKit.getMediaInformationFromCommandArgumentsAsync(commandArguments, completeCallback, logCallback, waitTimeout); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -2007,16 +2167,16 @@ export class FFprobeKit { |
|
|
|
|
* 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 |
|
|
|
|
* 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 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 waitTimeout max time to wait until media information is transmitted |
|
|
|
|
* @return media information session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async getMediaInformationFromCommandAsync(command, executeCallback, logCallback, waitTimeout) { |
|
|
|
|
return FFprobeKit.getMediaInformationFromCommandArgumentsAsync(FFmpegKitConfig.parseArguments(command), executeCallback, logCallback, waitTimeout); |
|
|
|
|
static async getMediaInformationFromCommandAsync(command, completeCallback, logCallback, waitTimeout) { |
|
|
|
|
return FFprobeKit.getMediaInformationFromCommandArgumentsAsync(FFmpegKitConfig.parseArguments(command), completeCallback, logCallback, waitTimeout); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -2025,16 +2185,16 @@ export class FFprobeKit { |
|
|
|
|
* from it. |
|
|
|
|
* |
|
|
|
|
* <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 commandArguments FFprobe command arguments 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 waitTimeout max time to wait until media information is transmitted |
|
|
|
|
* @return media information session created for this execution |
|
|
|
|
*/ |
|
|
|
|
static async getMediaInformationFromCommandArgumentsAsync(commandArguments, executeCallback, logCallback, waitTimeout) { |
|
|
|
|
let session = await MediaInformationSession.create(commandArguments, executeCallback, logCallback); |
|
|
|
|
static async getMediaInformationFromCommandArgumentsAsync(commandArguments, completeCallback, logCallback, waitTimeout) { |
|
|
|
|
let session = await MediaInformationSession.create(commandArguments, completeCallback, logCallback); |
|
|
|
|
|
|
|
|
|
await FFmpegKitConfig.asyncGetMediaInformationExecute(session, waitTimeout); |
|
|
|
|
|
|
|
|
@ -2046,13 +2206,25 @@ export class FFprobeKit { |
|
|
|
|
* |
|
|
|
|
* @return all FFprobe sessions in the session history |
|
|
|
|
*/ |
|
|
|
|
static async listSessions() { |
|
|
|
|
static async listFFprobeSessions() { |
|
|
|
|
await FFmpegKitConfig.init(); |
|
|
|
|
|
|
|
|
|
const sessionArray = await FFmpegKitReactNativeModule.getFFprobeSessions(); |
|
|
|
|
return sessionArray.map(FFmpegKitFactory.mapToSession); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p>Lists all MediaInformation sessions in the session history. |
|
|
|
|
* |
|
|
|
|
* @return all MediaInformation sessions in the session history |
|
|
|
|
*/ |
|
|
|
|
static async listMediaInformationSessions() { |
|
|
|
|
await FFmpegKitConfig.init(); |
|
|
|
|
|
|
|
|
|
const sessionArray = await FFmpegKitReactNativeModule.getMediaInformationSessions(); |
|
|
|
|
return sessionArray.map(FFmpegKitFactory.mapToSession); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -2071,16 +2243,16 @@ export class FFprobeSession extends AbstractSession { |
|
|
|
|
* Creates a new FFprobe session. |
|
|
|
|
* |
|
|
|
|
* @param argumentsArray FFprobe command arguments |
|
|
|
|
* @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 logRedirectionStrategy defines how logs will be redirected |
|
|
|
|
* @returns FFprobe session created |
|
|
|
|
*/ |
|
|
|
|
static async create(argumentsArray, executeCallback, logCallback, logRedirectionStrategy) { |
|
|
|
|
static async create(argumentsArray, completeCallback, logCallback, logRedirectionStrategy) { |
|
|
|
|
const session = await AbstractSession.createFFprobeSession(argumentsArray, logRedirectionStrategy); |
|
|
|
|
const sessionId = session.getSessionId(); |
|
|
|
|
|
|
|
|
|
FFmpegKitFactory.setExecuteCallback(sessionId, executeCallback); |
|
|
|
|
FFmpegKitFactory.setFFprobeSessionCompleteCallback(sessionId, completeCallback); |
|
|
|
|
FFmpegKitFactory.setLogCallback(sessionId, logCallback); |
|
|
|
|
|
|
|
|
|
return session; |
|
|
|
@ -2096,6 +2268,15 @@ export class FFprobeSession extends AbstractSession { |
|
|
|
|
return AbstractSession.createFFprobeSessionFromMap(sessionMap); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the session specific complete callback. |
|
|
|
|
* |
|
|
|
|
* @return session specific complete callback |
|
|
|
|
*/ |
|
|
|
|
getCompleteCallback() { |
|
|
|
|
return FFmpegKitFactory.getFFprobeSessionCompleteCallback(this.getSessionId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isFFmpeg() { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -2104,6 +2285,10 @@ export class FFprobeSession extends AbstractSession { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isMediaInformation() { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -2469,7 +2654,7 @@ export class MediaInformationJsonParser { |
|
|
|
|
* <p>A custom FFprobe session, which produces a <code>MediaInformation</code> object using the |
|
|
|
|
* FFprobe output. |
|
|
|
|
*/ |
|
|
|
|
export class MediaInformationSession extends FFprobeSession { |
|
|
|
|
export class MediaInformationSession extends AbstractSession { |
|
|
|
|
#mediaInformation; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -2483,15 +2668,15 @@ export class MediaInformationSession extends FFprobeSession { |
|
|
|
|
* Creates a new MediaInformationSession session. |
|
|
|
|
* |
|
|
|
|
* @param argumentsArray FFprobe command arguments |
|
|
|
|
* @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 |
|
|
|
|
* @returns MediaInformationSession session created |
|
|
|
|
*/ |
|
|
|
|
static async create(argumentsArray, executeCallback, logCallback) { |
|
|
|
|
static async create(argumentsArray, completeCallback, logCallback) { |
|
|
|
|
const session = await AbstractSession.createMediaInformationSession(argumentsArray); |
|
|
|
|
const sessionId = session.getSessionId(); |
|
|
|
|
|
|
|
|
|
FFmpegKitFactory.setExecuteCallback(sessionId, executeCallback); |
|
|
|
|
FFmpegKitFactory.setMediaInformationSessionCompleteCallback(sessionId, completeCallback); |
|
|
|
|
FFmpegKitFactory.setLogCallback(sessionId, logCallback); |
|
|
|
|
|
|
|
|
|
return session; |
|
|
|
@ -2526,6 +2711,27 @@ export class MediaInformationSession extends FFprobeSession { |
|
|
|
|
this.#mediaInformation = mediaInformation; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the session specific complete callback. |
|
|
|
|
* |
|
|
|
|
* @return session specific complete callback |
|
|
|
|
*/ |
|
|
|
|
getCompleteCallback() { |
|
|
|
|
return FFmpegKitFactory.getMediaInformationSessionCompleteCallback(this.getSessionId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isFFmpeg() { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isFFprobe() { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isMediaInformation() { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|