@ -23,6 +23,7 @@ import android.app.Activity;
import android.content.Context ;
import android.content.Intent ;
import android.net.Uri ;
import android.os.Build ;
import android.util.Log ;
import androidx.annotation.NonNull ;
@ -57,12 +58,11 @@ import java.util.Date;
import java.util.HashMap ;
import java.util.Iterator ;
import java.util.List ;
import java.util.Locale ;
import java.util.Map ;
import java.util.Optional ;
import java.util.concurrent.ExecutorService ;
import java.util.concurrent.Executors ;
import java.util.concurrent.atomic.AtomicBoolean ;
import java.util.stream.Collectors ;
import io.flutter.embedding.engine.plugins.FlutterPlugin ;
import io.flutter.embedding.engine.plugins.activity.ActivityAware ;
@ -114,7 +114,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
// EVENTS
public static final String EVENT_LOG_CALLBACK_EVENT = "FFmpegKitLogCallbackEvent" ;
public static final String EVENT_STATISTICS_CALLBACK_EVENT = "FFmpegKitStatisticsCallbackEvent" ;
public static final String EVENT_EXECU TE_CALLBACK_EVENT = "FFmpegKitExecu teCallbackEvent" ;
public static final String EVENT_COMPL ETE_CALLBACK_EVENT = "FFmpegKitComple teCallbackEvent" ;
// REQUEST CODES
public static final int READABLE_REQUEST_CODE = 10000 ;
@ -127,11 +127,11 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
public static final String ARGUMENT_FFPROBE_JSON_OUTPUT = "ffprobeJsonOutput" ;
public static final String ARGUMENT_WRITABLE = "writable" ;
private static final int asyncWriteToPipe ConcurrencyLimit = 10 ;
private static final int asyncConcurrencyLimit = 10 ;
private final AtomicBoolean logsEnabled ;
private final AtomicBoolean statisticsEnabled ;
private final ExecutorService asyncWriteToPipe ExecutorService ;
private final ExecutorService asyncExecutorService ;
private MethodChannel methodChannel ;
private EventChannel eventChannel ;
@ -147,10 +147,10 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
public FFmpegKitFlutterPlugin ( ) {
this . logsEnabled = new AtomicBoolean ( false ) ;
this . statisticsEnabled = new AtomicBoolean ( false ) ;
this . asyncWriteToPipe ExecutorService = Executors . newFixedThreadPool ( asyncWriteToPipe ConcurrencyLimit ) ;
this . asyncExecutorService = Executors . newFixedThreadPool ( asyncConcurrencyLimit ) ;
this . resultHandler = new FFmpegKitFlutterMethodResultHandler ( ) ;
registerGlobalCallbacks ( ) ;
Log . d ( LIBRARY_NAME , String . format ( "FFmpegKitFlutterPlugin created %s." , this ) ) ;
}
@SuppressWarnings ( "deprecation" )
@ -165,7 +165,9 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
}
protected void registerGlobalCallbacks ( ) {
FFmpegKitConfig . enableExecuteCallback ( this : : emitSession ) ;
FFmpegKitConfig . enableFFmpegSessionCompleteCallback ( this : : emitSession ) ;
FFmpegKitConfig . enableFFprobeSessionCompleteCallback ( this : : emitSession ) ;
FFmpegKitConfig . enableMediaInformationSessionCompleteCallback ( this : : emitSession ) ;
FFmpegKitConfig . enableLogCallback ( log - > {
if ( logsEnabled . get ( ) ) {
@ -192,7 +194,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
@Override
public void onAttachedToActivity ( @NonNull ActivityPluginBinding activityPluginBinding ) {
Log . d ( LIBRARY_NAME , String . format ( "FFmpegKitFlutterPlugin attached to activity %s." , activityPluginBinding . getActivity ( ) ) ) ;
Log . d ( LIBRARY_NAME , String . format ( "FFmpegKitFlutterPlugin %s attached to activity %s." , this , activityPluginBinding . getActivity ( ) ) ) ;
init ( flutterPluginBinding . getBinaryMessenger ( ) , flutterPluginBinding . getApplicationContext ( ) , activityPluginBinding . getActivity ( ) , null , activityPluginBinding ) ;
}
@ -215,7 +217,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
@Override
public void onListen ( final Object o , final EventChannel . EventSink eventSink ) {
this . eventSink = eventSink ;
Log . d ( LIBRARY_NAME , String . format ( "FFmpegKitFlutterPlugin started listening to events on %s." , eventSink ) ) ;
Log . d ( LIBRARY_NAME , String . format ( "FFmpegKitFlutterPlugin %s started listening to events on %s." , this , eventSink ) ) ;
}
@Override
@ -249,72 +251,72 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
@Override
public void onMethodCall ( @NonNull MethodCall call , @NonNull Result result ) {
final Optional < Integer > sessionIdOptional = Optional . ofNullable ( call . argument ( ARGUMENT_SESSION_ID ) ) ;
final Integer sessionId = call . argument ( ARGUMENT_SESSION_ID ) ;
final Integer waitTimeout = call . argument ( ARGUMENT_WAIT_TIMEOUT ) ;
final Optional < List < String > > argumentsOptional = Optional . ofNullable ( call . argument ( ARGUMENT_ARGUMENTS ) ) ;
final Optional < String > ffprobeJsonOutputOptional = Optional . ofNullable ( call . argument ( ARGUMENT_FFPROBE_JSON_OUTPUT ) ) ;
final Optional < Boolean > writableOptional = Optional . ofNullable ( call . argument ( ARGUMENT_WRITABLE ) ) ;
final List < String > arguments = call . argument ( ARGUMENT_ARGUMENTS ) ;
final String ffprobeJsonOutput = call . argument ( ARGUMENT_FFPROBE_JSON_OUTPUT ) ;
final Boolean writable = call . argument ( ARGUMENT_WRITABLE ) ;
switch ( call . method ) {
case "abstractSessionGetEndTime" :
if ( sessionIdOptional . isPresent ( ) ) {
abstractSessionGetEndTime ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
abstractSessionGetEndTime ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "abstractSessionGetDuration" :
if ( sessionIdOptional . isPresent ( ) ) {
abstractSessionGetDuration ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
abstractSessionGetDuration ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "abstractSessionGetAllLogs" :
if ( sessionIdOptional . isPresent ( ) ) {
abstractSessionGetAllLogs ( sessionIdOptional . get ( ) , waitTimeout , result ) ;
if ( sessionId ! = null ) {
abstractSessionGetAllLogs ( sessionId , waitTimeout , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "abstractSessionGetLogs" :
if ( sessionIdOptional . isPresent ( ) ) {
abstractSessionGetLogs ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
abstractSessionGetLogs ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "abstractSessionGetAllLogsAsString" :
if ( sessionIdOptional . isPresent ( ) ) {
abstractSessionGetAllLogsAsString ( sessionIdOptional . get ( ) , waitTimeout , result ) ;
if ( sessionId ! = null ) {
abstractSessionGetAllLogsAsString ( sessionId , waitTimeout , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "abstractSessionGetState" :
if ( sessionIdOptional . isPresent ( ) ) {
abstractSessionGetState ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
abstractSessionGetState ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "abstractSessionGetReturnCode" :
if ( sessionIdOptional . isPresent ( ) ) {
abstractSessionGetReturnCode ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
abstractSessionGetReturnCode ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "abstractSessionGetFailStackTrace" :
if ( sessionIdOptional . isPresent ( ) ) {
abstractSessionGetFailStackTrace ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
abstractSessionGetFailStackTrace ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "thereAreAsynchronousMessagesInTransmit" :
if ( sessionIdOptional . isPresent ( ) ) {
abstractSessionThereAreAsynchronousMessagesInTransmit ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
abstractSessionThereAreAsynchronousMessagesInTransmit ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
@ -323,50 +325,57 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
getArch ( result ) ;
break ;
case "ffmpegSession" :
if ( argumentsOptional . isPresent ( ) ) {
ffmpegSession ( argumentsOptional . get ( ) , result ) ;
if ( arguments ! = null ) {
ffmpegSession ( arguments , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_ARGUMENTS" , "Invalid arguments array." ) ;
}
break ;
case "ffmpegSessionGetAllStatistics" :
if ( sessionIdOptional . isPresent ( ) ) {
ffmpegSessionGetAllStatistics ( sessionIdOptional . get ( ) , waitTimeout , result ) ;
if ( sessionId ! = null ) {
ffmpegSessionGetAllStatistics ( sessionId , waitTimeout , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "ffmpegSessionGetStatistics" :
if ( sessionIdOptional . isPresent ( ) ) {
ffmpegSessionGetStatistics ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
ffmpegSessionGetStatistics ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "ffprobeSession" :
if ( argumentsOptional . isPresent ( ) ) {
ffprobeSession ( argumentsOptional . get ( ) , result ) ;
if ( arguments ! = null ) {
ffprobeSession ( arguments , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_ARGUMENTS" , "Invalid arguments array." ) ;
}
break ;
case "mediaInformationSession" :
if ( argumentsOptional . isPresent ( ) ) {
mediaInformationSession ( argumentsOptional . get ( ) , result ) ;
if ( arguments ! = null ) {
mediaInformationSession ( arguments , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_ARGUMENTS" , "Invalid arguments array." ) ;
}
break ;
case "getMediaInformation" :
if ( sessionId ! = null ) {
getMediaInformation ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "mediaInformationJsonParserFrom" :
if ( ffprobeJsonOutputOptional . isPresent ( ) ) {
mediaInformationJsonParserFrom ( ffprobeJsonOutputOptional . get ( ) , result ) ;
if ( ffprobeJsonOutput ! = null ) {
mediaInformationJsonParserFrom ( ffprobeJsonOutput , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_FFPROBE_JSON_OUTPUT" , "Invalid ffprobe json output." ) ;
}
break ;
case "mediaInformationJsonParserFromWithError" :
if ( ffprobeJsonOutputOptional . isPresent ( ) ) {
mediaInformationJsonParserFromWithError ( ffprobeJsonOutputOptional . get ( ) , result ) ;
if ( ffprobeJsonOutput ! = null ) {
mediaInformationJsonParserFromWithError ( ffprobeJsonOutput , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_FFPROBE_JSON_OUTPUT" , "Invalid ffprobe json output." ) ;
}
@ -390,28 +399,28 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
disableStatistics ( result ) ;
break ;
case "setFontconfigConfigurationPath" :
final Optional < String > pathOptional = Optional . ofNullable ( call . argument ( "path" ) ) ;
if ( pathOptional . isPresent ( ) ) {
setFontconfigConfigurationPath ( pathOptional . get ( ) , result ) ;
final String path = call . argument ( "path" ) ;
if ( path ! = null ) {
setFontconfigConfigurationPath ( path , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_PATH" , "Invalid path." ) ;
}
break ;
case "setFontDirectory" : {
final Optional < String > fontDirectoryOptional = Optional . ofNullable ( call . argument ( "fontDirectory" ) ) ;
final String fontDirectory = call . argument ( "fontDirectory" ) ;
final Map < String , String > fontNameMap = call . argument ( "fontNameMap" ) ;
if ( fontDirectoryOptional . isPresent ( ) ) {
setFontDirectory ( fontDirectoryOptional . get ( ) , fontNameMap , result ) ;
if ( fontDirectory ! = null ) {
setFontDirectory ( fontDirectory , fontNameMap , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_FONT_DIRECTORY" , "Invalid font directory." ) ;
}
break ;
}
case "setFontDirectoryList" : {
final Optional < List < String > > fontDirectoryListOptional = Optional . ofNullable ( call . argument ( "fontDirectoryList" ) ) ;
final List < String > fontDirectoryList = call . argument ( "fontDirectoryList" ) ;
final Map < String , String > fontNameMap = call . argument ( "fontNameMap" ) ;
if ( fontDirectoryListOptional . isPresent ( ) ) {
setFontDirectoryList ( fontDirectoryListOptional . get ( ) , fontNameMap , result ) ;
if ( fontDirectoryList ! = null ) {
setFontDirectoryList ( fontDirectoryList , fontNameMap , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_FONT_DIRECTORY_LIST" , "Invalid font directory list." ) ;
}
@ -421,9 +430,9 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
registerNewFFmpegPipe ( result ) ;
break ;
case "closeFFmpegPipe" :
final Optional < String > ffmpegPipePathOptional = Optional . ofNullable ( call . argument ( "ffmpegPipePath" ) ) ;
if ( ffmpegPipePathOptional . isPresent ( ) ) {
closeFFmpegPipe ( ffmpegPipePathOptional . get ( ) , result ) ;
final String ffmpegPipePath = call . argument ( "ffmpegPipePath" ) ;
if ( ffmpegPipePath ! = null ) {
closeFFmpegPipe ( ffmpegPipePath , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_PIPE_PATH" , "Invalid ffmpeg pipe path." ) ;
}
@ -438,42 +447,63 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
getBuildDate ( result ) ;
break ;
case "setEnvironmentVariable" :
final Optional < String > variableNameOptional = Optional . ofNullable ( call . argument ( "variableName" ) ) ;
final Optional < String > variableValueOptional = Optional . ofNullable ( call . argument ( "variableValue" ) ) ;
final String variableName = call . argument ( "variableName" ) ;
final String variableValue = call . argument ( "variableValue" ) ;
if ( variableNameOptional . isPresent ( ) & & variableValueOptional . isPresent ( ) ) {
setEnvironmentVariable ( variableNameOptional . get ( ) , variableValueOptional . get ( ) , result ) ;
} else if ( variableValueOptional . isPresent ( ) ) {
if ( variableName ! = null & & variableValue ! = null ) {
setEnvironmentVariable ( variableName , variableValue , result ) ;
} else if ( variableValue ! = null ) {
resultHandler . errorAsync ( result , "INVALID_NAME" , "Invalid environment variable name." ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_VALUE" , "Invalid environment variable value." ) ;
}
break ;
case "ignoreSignal" :
final Optional < Integer > signalOptional = Optional . ofNullable ( call . argument ( "signal" ) ) ;
if ( signalOptional . isPresent ( ) ) {
ignoreSignal ( signalOptional . get ( ) , result ) ;
final Integer signal = call . argument ( "signal" ) ;
if ( signal ! = null ) {
ignoreSignal ( signal , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SIGNAL" , "Invalid signal value." ) ;
}
break ;
case "ffmpegSessionExecute" :
if ( sessionId ! = null ) {
ffmpegSessionExecute ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "ffprobeSessionExecute" :
if ( sessionId ! = null ) {
ffprobeSessionExecute ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "mediaInformationSessionExecute" :
if ( sessionId ! = null ) {
mediaInformationSessionExecute ( sessionId , waitTimeout , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "asyncFFmpegSessionExecute" :
if ( sessionIdOptional . isPresent ( ) ) {
asyncFFmpegSessionExecute ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
asyncFFmpegSessionExecute ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "asyncFFprobeSessionExecute" :
if ( sessionIdOptional . isPresent ( ) ) {
asyncFFprobeSessionExecute ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
asyncFFprobeSessionExecute ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
break ;
case "asyncMediaInformationSessionExecute" :
if ( sessionIdOptional . isPresent ( ) ) {
asyncMediaInformationSessionExecute ( sessionIdOptional . get ( ) , waitTimeout , result ) ;
if ( sessionId ! = null ) {
asyncMediaInformationSessionExecute ( sessionId , waitTimeout , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
@ -482,9 +512,9 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
getLogLevel ( result ) ;
break ;
case "setLogLevel" :
final Optional < Integer > levelOptional = Optional . ofNullable ( call . argument ( "level" ) ) ;
if ( levelOptional . isPresent ( ) ) {
setLogLevel ( levelOptional . get ( ) , result ) ;
final Integer level = call . argument ( "level" ) ;
if ( level ! = null ) {
setLogLevel ( level , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_LEVEL" , "Invalid level value." ) ;
}
@ -493,16 +523,16 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
getSessionHistorySize ( result ) ;
break ;
case "setSessionHistorySize" :
final Optional < Integer > sessionHistorySizeOptional = Optional . ofNullable ( call . argument ( "sessionHistorySize" ) ) ;
if ( sessionHistorySizeOptional . isPresent ( ) ) {
setSessionHistorySize ( sessionHistorySizeOptional . get ( ) , result ) ;
final Integer sessionHistorySize = call . argument ( "sessionHistorySize" ) ;
if ( sessionHistorySize ! = null ) {
setSessionHistorySize ( sessionHistorySize , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SIZE" , "Invalid session history size value." ) ;
}
break ;
case "getSession" :
if ( sessionIdOptional . isPresent ( ) ) {
getSession ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
getSession ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
@ -520,9 +550,9 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
clearSessions ( result ) ;
break ;
case "getSessionsByState" :
final Optional < Integer > stateOptional = Optional . ofNullable ( call . argument ( "state" ) ) ;
if ( stateOptional . isPresent ( ) ) {
getSessionsByState ( stateOptional . get ( ) , result ) ;
final Integer state = call . argument ( "state" ) ;
if ( state ! = null ) {
getSessionsByState ( state , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION_STATE" , "Invalid session state value." ) ;
}
@ -531,16 +561,16 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
getLogRedirectionStrategy ( result ) ;
break ;
case "setLogRedirectionStrategy" :
final Optional < Integer > strategyOptional = Optional . ofNullable ( call . argument ( "strategy" ) ) ;
if ( strategyOptional . isPresent ( ) ) {
setLogRedirectionStrategy ( strategyOptional . get ( ) , result ) ;
final Integer strategy = call . argument ( "strategy" ) ;
if ( strategy ! = null ) {
setLogRedirectionStrategy ( strategy , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_LOG_REDIRECTION_STRATEGY" , "Invalid log redirection strategy value." ) ;
}
break ;
case "messagesInTransmit" :
if ( sessionIdOptional . isPresent ( ) ) {
messagesInTransmit ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
messagesInTransmit ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
@ -549,11 +579,11 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
getPlatform ( result ) ;
break ;
case "writeToPipe" :
final Optional < String > inputOptional = Optional . ofNullable ( call . argument ( "input" ) ) ;
final Optional < String > pipeOptional = Optional . ofNullable ( call . argument ( "pipe" ) ) ;
if ( inputOptional . isPresent ( ) & & pipeOptional . isPresent ( ) ) {
writeToPipe ( inputOptional . get ( ) , pipeOptional . get ( ) , result ) ;
} else if ( pipeOptional . isPresent ( ) ) {
final String input = call . argument ( "input" ) ;
final String pipe = call . argument ( "pipe" ) ;
if ( input ! = null & & pipe ! = null ) {
writeToPipe ( input , pipe , result ) ;
} else if ( pipe ! = null ) {
resultHandler . errorAsync ( result , "INVALID_INPUT" , "Invalid input value." ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_PIPE" , "Invalid pipe value." ) ;
@ -562,20 +592,26 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
case "selectDocument" :
final String title = call . argument ( "title" ) ;
final String type = call . argument ( "type" ) ;
final Optional < List < String > > extraTypesOptional = Optional . ofNullable ( call . argument ( "extraTypes" ) ) ;
final String [ ] extraTypesArray = extraTypesOptional . map ( strings - > strings . toArray ( new String [ 0 ] ) ) . orElse ( null ) ;
if ( writableOptional . isPresent ( ) ) {
selectDocument ( writableOptional . get ( ) , title , type , extraTypesArray , result ) ;
final List < String > extraTypes = call . argument ( "extraTypes" ) ;
final String [ ] extraTypesArray ;
if ( extraTypes ! = null ) {
extraTypesArray = extraTypes . toArray ( new String [ 0 ] ) ;
} else {
extraTypesArray = null ;
}
if ( writable ! = null ) {
selectDocument ( writable , title , type , extraTypesArray , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_WRITABLE" , "Invalid writable value." ) ;
}
break ;
case "getSafParameter" :
final Optional < String > uriOptional = Optional . ofNullable ( call . argument ( "uri" ) ) ;
if ( writableOptional . isPresent ( ) & & uriOptional . isPresent ( ) ) {
getSafParameter ( writableOptional . get ( ) , uriOptional . get ( ) , result ) ;
} else if ( uriOptional . isPresent ( ) ) {
resultHandler . errorAsync ( result , "INVALID_WRITABLE" , "Invalid writable value." ) ;
final String uri = call . argument ( "uri" ) ;
final String openMode = call . argument ( "openMode" ) ;
if ( uri ! = null & & openMode ! = null ) {
getSafParameter ( uri , openMode , result ) ;
} else if ( uri ! = null ) {
resultHandler . errorAsync ( result , "INVALID_OPEN_MODE" , "Invalid openMode value." ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_URI" , "Invalid uri value." ) ;
}
@ -584,8 +620,8 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
cancel ( result ) ;
break ;
case "cancelSession" :
if ( sessionIdOptional . isPresent ( ) ) {
cancelSession ( sessionIdOptional . get ( ) , result ) ;
if ( sessionId ! = null ) {
cancelSession ( sessionId , result ) ;
} else {
resultHandler . errorAsync ( result , "INVALID_SESSION" , "Invalid session id." ) ;
}
@ -596,6 +632,9 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
case "getFFprobeSessions" :
getFFprobeSessions ( result ) ;
break ;
case "getMediaInformationSessions" :
getMediaInformationSessions ( result ) ;
break ;
case "getPackageName" :
getPackageName ( result ) ;
break ;
@ -610,6 +649,8 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
@SuppressWarnings ( "deprecation" )
protected void init ( final BinaryMessenger messenger , final Context context , final Activity activity , final io . flutter . plugin . common . PluginRegistry . Registrar registrar , final ActivityPluginBinding activityBinding ) {
registerGlobalCallbacks ( ) ;
if ( methodChannel = = null ) {
methodChannel = new MethodChannel ( messenger , METHOD_CHANNEL ) ;
methodChannel . setMethodCallHandler ( this ) ;
@ -635,7 +676,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
activityBinding . addActivityResultListener ( this ) ;
}
Log . d ( LIBRARY_NAME , String . format ( "FFmpegKitFlutterPlugin initialized with context %s and activity %s." , context , activity ) ) ;
Log . d ( LIBRARY_NAME , String . format ( "FFmpegKitFlutterPlugin %s initialised with context %s and activity %s." , this , context , activity ) ) ;
}
protected void uninit ( ) {
@ -648,7 +689,6 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
this . context = null ;
this . activity = null ;
this . flutterPluginBinding = null ;
this . activityPluginBinding = null ;
Log . d ( LIBRARY_NAME , "FFmpegKitFlutterPlugin uninitialized." ) ;
@ -711,7 +751,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
timeout = AbstractSession . DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT ;
}
final List < com . arthenica . ffmpegkit . Log > allLogs = session . getAllLogs ( timeout ) ;
resultHandler . successAsync ( result , allLogs . stream ( ) . map ( FFmpegKitFlutterPlugin : : toMap ) . collect ( Collectors . toList ( ) ) ) ;
resultHandler . successAsync ( result , toLogMapList ( allLogs ) ) ;
}
}
@ -721,7 +761,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
resultHandler . errorAsync ( result , "SESSION_NOT_FOUND" , "Session not found." ) ;
} else {
final List < com . arthenica . ffmpegkit . Log > allLogs = session . getLogs ( ) ;
resultHandler . successAsync ( result , allLogs . stream ( ) . map ( FFmpegKitFlutterPlugin : : toMap ) . collect ( Collectors . toList ( ) ) ) ;
resultHandler . successAsync ( result , toLogMapList ( allLogs ) ) ;
}
}
@ -800,7 +840,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
if ( session = = null ) {
resultHandler . errorAsync ( result , "SESSION_NOT_FOUND" , "Session not found." ) ;
} else {
if ( session instanceof FFmpegSession ) {
if ( session . isFFmpeg ( ) ) {
final int timeout ;
if ( isValidPositiveNumber ( waitTimeout ) ) {
timeout = waitTimeout ;
@ -808,7 +848,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
timeout = AbstractSession . DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT ;
}
final List < Statistics > allStatistics = ( ( FFmpegSession ) session ) . getAllStatistics ( timeout ) ;
resultHandler . successAsync ( result , allStatistics . stream ( ) . map ( FFmpegKitFlutterPlugin : : toMap ) . collect ( Collectors . toList ( ) ) ) ;
resultHandler . successAsync ( result , toStatisticsMapList ( allStatistics ) ) ;
} else {
resultHandler . errorAsync ( result , "NOT_FFMPEG_SESSION" , "A session is found but it does not have the correct type." ) ;
}
@ -820,9 +860,9 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
if ( session = = null ) {
resultHandler . errorAsync ( result , "SESSION_NOT_FOUND" , "Session not found." ) ;
} else {
if ( session instanceof FFmpegSession ) {
if ( session . isFFmpeg ( ) ) {
final List < Statistics > statistics = ( ( FFmpegSession ) session ) . getStatistics ( ) ;
resultHandler . successAsync ( result , statistics . stream ( ) . map ( FFmpegKitFlutterPlugin : : toMap ) . collect ( Collectors . toList ( ) ) ) ;
resultHandler . successAsync ( result , toStatisticsMapList ( statistics ) ) ;
} else {
resultHandler . errorAsync ( result , "NOT_FFMPEG_SESSION" , "A session is found but it does not have the correct type." ) ;
}
@ -843,6 +883,21 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
resultHandler . successAsync ( result , toMap ( session ) ) ;
}
protected void getMediaInformation ( @NonNull final Integer sessionId , @NonNull final Result result ) {
final Session session = FFmpegKitConfig . getSession ( sessionId . longValue ( ) ) ;
if ( session = = null ) {
resultHandler . errorAsync ( result , "SESSION_NOT_FOUND" , "Session not found." ) ;
} else {
if ( session . isMediaInformation ( ) ) {
final MediaInformationSession mediaInformationSession = ( MediaInformationSession ) session ;
final MediaInformation mediaInformation = mediaInformationSession . getMediaInformation ( ) ;
resultHandler . successAsync ( result , toMap ( mediaInformation ) ) ;
} else {
resultHandler . errorAsync ( result , "NOT_MEDIA_INFORMATION_SESSION" , "A session is found but it does not have the correct type." ) ;
}
}
}
// MediaInformationJsonParser
protected void mediaInformationJsonParserFrom ( @NonNull final String ffprobeJsonOutput , @NonNull final Result result ) {
@ -988,12 +1043,60 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
}
}
protected void ffmpegSessionExecute ( @NonNull final Integer sessionId , @NonNull final Result result ) {
final Session session = FFmpegKitConfig . getSession ( sessionId . longValue ( ) ) ;
if ( session = = null ) {
resultHandler . errorAsync ( result , "SESSION_NOT_FOUND" , "Session not found." ) ;
} else {
if ( session . isFFmpeg ( ) ) {
final FFmpegSessionExecuteTask ffmpegSessionExecuteTask = new FFmpegSessionExecuteTask ( ( FFmpegSession ) session , resultHandler , result ) ;
asyncExecutorService . submit ( ffmpegSessionExecuteTask ) ;
} else {
resultHandler . errorAsync ( result , "NOT_FFMPEG_SESSION" , "A session is found but it does not have the correct type." ) ;
}
}
}
protected void ffprobeSessionExecute ( @NonNull final Integer sessionId , @NonNull final Result result ) {
final Session session = FFmpegKitConfig . getSession ( sessionId . longValue ( ) ) ;
if ( session = = null ) {
resultHandler . errorAsync ( result , "SESSION_NOT_FOUND" , "Session not found." ) ;
} else {
if ( session . isFFprobe ( ) ) {
final FFprobeSessionExecuteTask ffprobeSessionExecuteTask = new FFprobeSessionExecuteTask ( ( FFprobeSession ) session , resultHandler , result ) ;
asyncExecutorService . submit ( ffprobeSessionExecuteTask ) ;
} else {
resultHandler . errorAsync ( result , "NOT_FFPROBE_SESSION" , "A session is found but it does not have the correct type." ) ;
}
}
}
protected void mediaInformationSessionExecute ( @NonNull final Integer sessionId , @Nullable final Integer waitTimeout , @NonNull final Result result ) {
final Session session = FFmpegKitConfig . getSession ( sessionId . longValue ( ) ) ;
if ( session = = null ) {
resultHandler . errorAsync ( result , "SESSION_NOT_FOUND" , "Session not found." ) ;
} else {
if ( session . isMediaInformation ( ) ) {
final int timeout ;
if ( isValidPositiveNumber ( waitTimeout ) ) {
timeout = waitTimeout ;
} else {
timeout = AbstractSession . DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT ;
}
final MediaInformationSessionExecuteTask mediaInformationSessionExecuteTask = new MediaInformationSessionExecuteTask ( ( MediaInformationSession ) session , timeout , resultHandler , result ) ;
asyncExecutorService . submit ( mediaInformationSessionExecuteTask ) ;
} else {
resultHandler . errorAsync ( result , "NOT_MEDIA_INFORMATION_SESSION" , "A session is found but it does not have the correct type." ) ;
}
}
}
protected void asyncFFmpegSessionExecute ( @NonNull final Integer sessionId , @NonNull final Result result ) {
final Session session = FFmpegKitConfig . getSession ( sessionId . longValue ( ) ) ;
if ( session = = null ) {
resultHandler . errorAsync ( result , "SESSION_NOT_FOUND" , "Session not found." ) ;
} else {
if ( session instanceof FFmpegSession ) {
if ( session . isFFmpeg ( ) ) {
FFmpegKitConfig . asyncFFmpegExecute ( ( FFmpegSession ) session ) ;
resultHandler . successAsync ( result , null ) ;
} else {
@ -1007,7 +1110,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
if ( session = = null ) {
resultHandler . errorAsync ( result , "SESSION_NOT_FOUND" , "Session not found." ) ;
} else {
if ( session instanceof FFprobeSession ) {
if ( session . isFFprobe ( ) ) {
FFmpegKitConfig . asyncFFprobeExecute ( ( FFprobeSession ) session ) ;
resultHandler . successAsync ( result , null ) ;
} else {
@ -1021,7 +1124,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
if ( session = = null ) {
resultHandler . errorAsync ( result , "SESSION_NOT_FOUND" , "Session not found." ) ;
} else {
if ( session instanceof MediaInformationSession ) {
if ( session . isMediaInformation ( ) ) {
final int timeout ;
if ( isValidPositiveNumber ( waitTimeout ) ) {
timeout = waitTimeout ;
@ -1074,7 +1177,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
}
protected void getSessions ( @NonNull final Result result ) {
resultHandler . successAsync ( result , toSessionArray ( FFmpegKitConfig . getSessions ( ) ) ) ;
resultHandler . successAsync ( result , toSessionMapList ( FFmpegKitConfig . getSessions ( ) ) ) ;
}
protected void clearSessions ( @NonNull final Result result ) {
@ -1083,7 +1186,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
}
protected void getSessionsByState ( @NonNull final Integer sessionState , @NonNull final Result result ) {
resultHandler . successAsync ( result , toSessionArray ( FFmpegKitConfig . getSessionsByState ( toSessionState ( sessionState ) ) ) ) ;
resultHandler . successAsync ( result , toSessionMapList ( FFmpegKitConfig . getSessionsByState ( toSessionState ( sessionState ) ) ) ) ;
}
protected void getLogRedirectionStrategy ( @NonNull final Result result ) {
@ -1104,11 +1207,17 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
}
protected void writeToPipe ( @NonNull final String inputPath , @NonNull final String namedPipePath , @NonNull final Result result ) {
final Async WriteToPipeTask asyncTask = new Async WriteToPipeTask( inputPath , namedPipePath , resultHandler , result ) ;
asyncWriteToPipe ExecutorService . submit ( asyncTask ) ;
final WriteToPipeTask asyncTask = new WriteToPipeTask ( inputPath , namedPipePath , resultHandler , result ) ;
asyncExecutorService . submit ( asyncTask ) ;
}
protected void selectDocument ( @NonNull final Boolean writable , @Nullable final String title , @Nullable final String type , @Nullable final String [ ] extraTypes , @NonNull final Result result ) {
if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . KITKAT ) {
android . util . Log . i ( LIBRARY_NAME , String . format ( Locale . getDefault ( ) , "selectDocument is not supported on API Level %d" , Build . VERSION . SDK_INT ) ) ;
resultHandler . errorAsync ( result , "SELECT_FAILED" , String . format ( Locale . getDefault ( ) , "selectDocument is not supported on API Level %d" , Build . VERSION . SDK_INT ) ) ;
return ;
}
final Intent intent ;
if ( writable ) {
intent = new Intent ( Intent . ACTION_CREATE_DOCUMENT ) ;
@ -1152,26 +1261,27 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
}
}
protected void getSafParameter ( @NonNull final Boolean writable , @NonNull final String uriString , @NonNull final Result result ) {
protected void getSafParameter ( @NonNull final String uriString , @NonNull final String openMode , @NonNull final Result result ) {
if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . KITKAT ) {
android . util . Log . i ( LIBRARY_NAME , String . format ( Locale . getDefault ( ) , "getSafParameter is not supported on API Level %d" , Build . VERSION . SDK_INT ) ) ;
resultHandler . errorAsync ( result , "GET_SAF_PARAMETER_FAILED" , String . format ( Locale . getDefault ( ) , "getSafParameter is not supported on API Level %d" , Build . VERSION . SDK_INT ) ) ;
return ;
}
if ( context ! = null ) {
final Uri uri = Uri . parse ( uriString ) ;
if ( uri = = null ) {
Log . w ( LIBRARY_NAME , String . format ( "Cannot getSafParameter using parameters writable: %s, uriString: %s. Uri string cannot be parsed." , writable , uriString ) ) ;
Log . w ( LIBRARY_NAME , String . format ( "Cannot getSafParameter using parameters uriString: %s, openMode: %s. Uri string cannot be parsed." , uriString , openMode ) ) ;
resultHandler . errorAsync ( result , "GET_SAF_PARAMETER_FAILED" , "Uri string cannot be parsed." ) ;
} else {
final String safParameter ;
if ( writable ) {
safParameter = FFmpegKitConfig . getSafParameterForWrite ( context , uri ) ;
} else {
safParameter = FFmpegKitConfig . getSafParameterForRead ( context , uri ) ;
}
final String safParameter = FFmpegKitConfig . getSafParameter ( context , uri , openMode ) ;
Log . d ( LIBRARY_NAME , String . format ( "getSafParameter using parameters writable: %s, uriString: %s completed with saf parameter: %s." , writable , uriString , safParameter ) ) ;
Log . d ( LIBRARY_NAME , String . format ( "getSafParameter using parameters uriString: %s, openMode: %s completed with saf parameter: %s." , uriString , openMode , safParameter ) ) ;
resultHandler . successAsync ( result , safParameter ) ;
}
} else {
Log . w ( LIBRARY_NAME , String . format ( "Cannot getSafParameter using parameters writable: %s, uriString: %s. Context is null." , writable , uriString ) ) ;
Log . w ( LIBRARY_NAME , String . format ( "Cannot getSafParameter using parameters uriString: %s, openMode: %s. Context is null." , uriString , openMode ) ) ;
resultHandler . errorAsync ( result , "INVALID_CONTEXT" , "Context is null." ) ;
}
}
@ -1189,13 +1299,17 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
}
protected void getFFmpegSessions ( @NonNull final Result result ) {
resultHandler . successAsync ( result , toSessionArray ( FFmpegKit . listSessions ( ) ) ) ;
resultHandler . successAsync ( result , toSessionMapList ( FFmpegKit . listSessions ( ) ) ) ;
}
// FFprobeKit
protected void getFFprobeSessions ( @NonNull final Result result ) {
resultHandler . successAsync ( result , toSessionArray ( FFprobeKit . listSessions ( ) ) ) ;
resultHandler . successAsync ( result , toSessionMapList ( FFprobeKit . listFFprobeSessions ( ) ) ) ;
}
protected void getMediaInformationSessions ( @NonNull final Result result ) {
resultHandler . successAsync ( result , toSessionMapList ( FFprobeKit . listMediaInformationSessions ( ) ) ) ;
}
// Packages
@ -1240,19 +1354,17 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
sessionMap . put ( KEY_SESSION_START_TIME , toLong ( session . getStartTime ( ) ) ) ;
sessionMap . put ( KEY_SESSION_COMMAND , session . getCommand ( ) ) ;
if ( session . isFFprobe ( ) ) {
if ( session instanceof MediaInformationSession ) {
final MediaInformationSession mediaInformationSession = ( MediaInformationSession ) session ;
final MediaInformation mediaInformation = mediaInformationSession . getMediaInformation ( ) ;
if ( mediaInformation ! = null ) {
sessionMap . put ( KEY_SESSION_MEDIA_INFORMATION , toMap ( mediaInformation ) ) ;
}
sessionMap . put ( KEY_SESSION_TYPE , SESSION_TYPE_MEDIA_INFORMATION ) ;
} else {
sessionMap . put ( KEY_SESSION_TYPE , SESSION_TYPE_FFPROBE ) ;
}
} else {
if ( session . isFFmpeg ( ) ) {
sessionMap . put ( KEY_SESSION_TYPE , SESSION_TYPE_FFMPEG ) ;
} else if ( session . isFFprobe ( ) ) {
sessionMap . put ( KEY_SESSION_TYPE , SESSION_TYPE_FFPROBE ) ;
} else if ( session . isMediaInformation ( ) ) {
final MediaInformationSession mediaInformationSession = ( MediaInformationSession ) session ;
final MediaInformation mediaInformation = mediaInformationSession . getMediaInformation ( ) ;
if ( mediaInformation ! = null ) {
sessionMap . put ( KEY_SESSION_MEDIA_INFORMATION , toMap ( mediaInformation ) ) ;
}
sessionMap . put ( KEY_SESSION_TYPE , SESSION_TYPE_MEDIA_INFORMATION ) ;
}
return sessionMap ;
@ -1339,29 +1451,21 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
return statisticsMap ;
}
protected static List < Map < String , Object > > toSessionArray ( final List < ? extends Session > sessions ) {
final List < Map < String , Object > > sessionArray = new ArrayList < > ( ) ;
for ( int i = 0 ; i < sessions . size ( ) ; i + + ) {
sessionArray . add ( toMap ( sessions . get ( i ) ) ) ;
}
return sessionArray ;
}
protected static Map < String , Object > toMap ( final MediaInformation mediaInformation ) {
Map < String , Object > map = new HashMap < > ( ) ;
if ( mediaInformation ! = null ) {
Map < String , Object > map = new HashMap < > ( ) ;
if ( mediaInformation . getAllProperties ( ) ! = null ) {
JSONObject allProperties = mediaInformation . getAllProperties ( ) ;
if ( allProperties ! = null ) {
map = toMap ( allProperties ) ;
}
}
}
return map ;
return map ;
} else {
return null ;
}
}
protected static Map < String , Object > toMap ( final JSONObject jsonObject ) {
@ -1404,6 +1508,36 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
return list ;
}
protected static List < Map < String , Object > > toSessionMapList ( final List < ? extends Session > sessionList ) {
final List < Map < String , Object > > list = new ArrayList < > ( ) ;
for ( int i = 0 ; i < sessionList . size ( ) ; i + + ) {
list . add ( toMap ( sessionList . get ( i ) ) ) ;
}
return list ;
}
protected static List < Map < String , Object > > toLogMapList ( final List < com . arthenica . ffmpegkit . Log > logList ) {
final List < Map < String , Object > > list = new ArrayList < > ( ) ;
for ( int i = 0 ; i < logList . size ( ) ; i + + ) {
list . add ( toMap ( logList . get ( i ) ) ) ;
}
return list ;
}
protected static List < Map < String , Object > > toStatisticsMapList ( final List < com . arthenica . ffmpegkit . Statistics > statisticsList ) {
final List < Map < String , Object > > list = new ArrayList < > ( ) ;
for ( int i = 0 ; i < statisticsList . size ( ) ; i + + ) {
list . add ( toMap ( statisticsList . get ( i ) ) ) ;
}
return list ;
}
protected static boolean isValidPositiveNumber ( final Integer value ) {
return ( value ! = null ) & & ( value > = 0 ) ;
}
@ -1422,7 +1556,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
protected void emitSession ( final Session session ) {
final HashMap < String , Object > sessionMap = new HashMap < > ( ) ;
sessionMap . put ( EVENT_EXECU TE_CALLBACK_EVENT , toMap ( session ) ) ;
sessionMap . put ( EVENT_COMPL ETE_CALLBACK_EVENT , toMap ( session ) ) ;
resultHandler . successAsync ( eventSink , sessionMap ) ;
}