refactor session create methods

pull/585/head
Taner Sener 3 years ago
parent c43fed6901
commit 235af6a8c3
  1. 6
      react-native/android/src/main/java/com/arthenica/ffmpegkit/reactnative/FFmpegKitReactNativeModule.java
  2. 6
      react-native/ios/FFmpegKitReactNativeModule.m
  3. 14
      react-native/src/index.d.ts
  4. 64
      react-native/src/index.js

@ -344,7 +344,7 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule {
@ReactMethod
public void ffmpegSession(final ReadableArray readableArray, final Promise promise) {
promise.resolve(toMap(new FFmpegSession(toArgumentsArray(readableArray), null, null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS)));
promise.resolve(toMap(FFmpegSession.create(toArgumentsArray(readableArray), null, null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS)));
}
@ReactMethod
@ -395,14 +395,14 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule {
@ReactMethod
public void ffprobeSession(final ReadableArray readableArray, final Promise promise) {
promise.resolve(toMap(new FFprobeSession(toArgumentsArray(readableArray), null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS)));
promise.resolve(toMap(FFprobeSession.create(toArgumentsArray(readableArray), null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS)));
}
// MediaInformationSession
@ReactMethod
public void mediaInformationSession(final ReadableArray readableArray, final Promise promise) {
promise.resolve(toMap(new MediaInformationSession(toArgumentsArray(readableArray), null, null)));
promise.resolve(toMap(MediaInformationSession.create(toArgumentsArray(readableArray), null, null)));
}
// MediaInformationJsonParser

@ -244,7 +244,7 @@ RCT_EXPORT_METHOD(getArch:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRe
// FFmpegSession
RCT_EXPORT_METHOD(ffmpegSession:(NSArray*)arguments resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
resolve([FFmpegKitReactNativeModule toSessionDictionary:session]);
}
@ -285,14 +285,14 @@ RCT_EXPORT_METHOD(ffmpegSessionGetStatistics:(int)sessionId resolver:(RCTPromise
// FFprobeSession
RCT_EXPORT_METHOD(ffprobeSession:(NSArray*)arguments resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
FFprobeSession* session = [FFprobeSession create:arguments withCompleteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
resolve([FFmpegKitReactNativeModule toSessionDictionary:session]);
}
// MediaInformationSession
RCT_EXPORT_METHOD(mediaInformationSession:(NSArray*)arguments resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil];
MediaInformationSession* session = [MediaInformationSession create:arguments withCompleteCallback:nil withLogCallback:nil];
resolve([FFmpegKitReactNativeModule toSessionDictionary:session]);
}

@ -2,8 +2,6 @@ declare module 'ffmpeg-kit-react-native' {
export abstract class AbstractSession implements Session {
protected constructor();
static createFFmpegSession(argumentsArray: Array<string>, logRedirectionStrategy?: LogRedirectionStrategy): Promise<FFmpegSession>;
static createFFmpegSessionFromMap(sessionMap: { [key: string]: any }): FFmpegSession;
@ -212,12 +210,8 @@ declare module 'ffmpeg-kit-react-native' {
export class FFmpegSession extends AbstractSession implements Session {
constructor();
static create(argumentsArray: Array<string>, completeCallback?: FFmpegSessionCompleteCallback, logCallback?: LogCallback, statisticsCallback?: StatisticsCallback, logRedirectionStrategy?: LogRedirectionStrategy): Promise<FFmpegSession>;
static fromMap(sessionMap: { [key: string]: any }): FFmpegSession;
getStatisticsCallback(): StatisticsCallback;
getCompleteCallback(): FFmpegSessionCompleteCallback;
@ -266,12 +260,8 @@ declare module 'ffmpeg-kit-react-native' {
export class FFprobeSession extends AbstractSession implements Session {
constructor();
static create(argumentsArray: Array<string>, completeCallback?: FFprobeSessionCompleteCallback, logCallback?: LogCallback, logRedirectionStrategy?: LogRedirectionStrategy): Promise<FFprobeSession>;
static fromMap(sessionMap: { [key: string]: any }): FFprobeSession;
getCompleteCallback(): FFprobeSessionCompleteCallback;
isFFmpeg(): boolean;
@ -381,12 +371,8 @@ declare module 'ffmpeg-kit-react-native' {
export class MediaInformationSession extends AbstractSession implements Session {
constructor();
static create(argumentsArray: Array<string>, completeCallback?: MediaInformationSessionCompleteCallback, logCallback?: LogCallback): Promise<MediaInformationSession>;
static fromMap(sessionMap: { [key: string]: any }): MediaInformationSession;
getMediaInformation(): MediaInformation;
setMediaInformation(mediaInformation: MediaInformation): void;

@ -296,13 +296,6 @@ export class AbstractSession extends Session {
*/
#logRedirectionStrategy;
/**
* Creates a new abstract session.
*/
constructor() {
super();
}
/**
* Creates a new FFmpeg session.
*
@ -1605,12 +1598,12 @@ class FFmpegKitFactory {
if (sessionMap !== undefined) {
switch (sessionMap.type) {
case 2:
return FFprobeSession.fromMap(sessionMap);
return AbstractSession.createFFprobeSessionFromMap(sessionMap);
case 3:
return MediaInformationSession.fromMap(sessionMap);
return AbstractSession.createMediaInformationSessionFromMap(sessionMap);
case 1:
default:
return FFmpegSession.fromMap(sessionMap);
return AbstractSession.createFFmpegSessionFromMap(sessionMap);
}
} else {
return undefined;
@ -1935,13 +1928,6 @@ class FFmpegKitInitializer {
*/
export class FFmpegSession extends AbstractSession {
/**
* Creates an empty FFmpeg session.
*/
constructor() {
super();
}
/**
* Creates a new FFmpeg session.
*
@ -1963,16 +1949,6 @@ export class FFmpegSession extends AbstractSession {
return session;
}
/**
* Creates a new FFmpeg session from the given map.
*
* @param sessionMap map that includes session fields as map keys
* @returns FFmpeg session created
*/
static fromMap(sessionMap) {
return AbstractSession.createFFmpegSessionFromMap(sessionMap);
}
/**
* Returns the session specific statistics callback.
*
@ -2252,13 +2228,6 @@ export class FFprobeKit {
*/
export class FFprobeSession extends AbstractSession {
/**
* Creates an empty FFprobe session.
*/
constructor() {
super();
}
/**
* Creates a new FFprobe session.
*
@ -2278,16 +2247,6 @@ export class FFprobeSession extends AbstractSession {
return session;
}
/**
* Creates a new FFprobe session from the given map.
*
* @param sessionMap map that includes session fields as map keys
* @returns FFprobe session created
*/
static fromMap(sessionMap) {
return AbstractSession.createFFprobeSessionFromMap(sessionMap);
}
/**
* Returns the session specific complete callback.
*
@ -2722,13 +2681,6 @@ export class MediaInformationJsonParser {
export class MediaInformationSession extends AbstractSession {
#mediaInformation;
/**
* Creates an empty MediaInformationSession.
*/
constructor() {
super();
}
/**
* Creates a new MediaInformationSession session.
*
@ -2747,16 +2699,6 @@ export class MediaInformationSession extends AbstractSession {
return session;
}
/**
* Creates a new MediaInformationSession from the given map.
*
* @param sessionMap map that includes session fields as map keys
* @returns MediaInformationSession created
*/
static fromMap(sessionMap) {
return AbstractSession.createMediaInformationSessionFromMap(sessionMap);
}
/**
* Returns the media information extracted in this session.
*

Loading…
Cancel
Save