# AbstractSession

Package

## Class AbstractSession

- All Implemented Interfaces:
    `com.arthenica.ffmpegkit.Session`

      public abstract class AbstractSession
       implements Session

  Abstract session implementation which includes common features shared by `FFmpeg`, `FFprobe` and `MediaInformation` sessions.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `public final static int` | `DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT` |
    `protected final long` | `sessionId` |
    `protected final LogCallback` | `logCallback` |
    `protected final Date` | `createTime` |
    `protected Date` | `startTime` |
    `protected Date` | `endTime` |
    `protected final Array<String>` | `arguments` |
    `protected final List<Log>` | `logs` |
    `protected Future<out Object>` | `future` |
    `protected SessionState` | `state` |
    `protected ReturnCode` | `returnCode` |
    `protected String` | `failStackTrace` |
    `protected final LogRedirectionStrategy` | `logRedirectionStrategy` |

  - ### Method Summary

    Modifier and Type | Method | Description
    --- | --- | ---
    `long` | `getSessionId()` | Returns the session identifier.
    `LogCallback` | `getLogCallback()` | Returns the session specific log callback.
    `Date` | `getCreateTime()` | Returns session create time.
    `Date` | `getStartTime()` | Returns session start time.
    `Date` | `getEndTime()` | Returns session end time.
    `Array<String>` | `getArguments()` | Returns command arguments as an array.
    `List<Log>` | `getLogs()` | Returns all log entries delivered for this session.
    `Future<out Object>` | `getFuture()` | Returns the future created for this session, if it is executed asynchronously.
    `void` | `setFuture(Future<out Object> future)` | Sets the future created for this session.
    `SessionState` | `getState()` | Returns the state of the session.
    `ReturnCode` | `getReturnCode()` | Returns the return code for this session.
    `String` | `getFailStackTrace()` | Returns the stack trace of the exception received while executing this session.
    `LogRedirectionStrategy` | `getLogRedirectionStrategy()` | Returns session specific log redirection strategy.
    `long` | `getDuration()` | Returns the time taken to execute this session.
    `String` | `getCommand()` | Returns command arguments as a concatenated string.
    `List<Log>` | `getAllLogs(int waitTimeout)` | Returns all log entries generated for this session.
    `List<Log>` | `getAllLogs()` | Returns all log entries generated for this session.
    `String` | `getAllLogsAsString(int waitTimeout)` | Returns all log entries generated for this session as a concatenated string.
    `String` | `getAllLogsAsString()` | Returns all log entries generated for this session as a concatenated string.
    `String` | `getLogsAsString()` | Returns all log entries delivered for this session as a concatenated string.
    `String` | `getOutput()` | Returns the log output generated while running the session.
    `boolean` | `thereAreAsynchronousMessagesInTransmit()` | Returns whether there are still asynchronous messages being transmitted for thissession or not.
    `void` | `addLog(Log log)` | Adds a new log entry for this session.
    `void` | `cancel()` | Cancels running the session.

    - ### Methods inherited from class com.arthenica.ffmpegkit.Session

      `isFFmpeg, isFFprobe, isMediaInformation`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getSessionId

           long getSessionId()

      Returns the session identifier.

    - #### getLogCallback

           LogCallback getLogCallback()

      Returns the session specific log callback.

    - #### getCreateTime

           Date getCreateTime()

      Returns session create time.

    - #### getStartTime

           Date getStartTime()

      Returns session start time.

    - #### getEndTime

           Date getEndTime()

      Returns session end time.

    - #### getArguments

           Array<String> getArguments()

      Returns command arguments as an array.

    - #### getLogs

           List<Log> getLogs()

      Returns all log entries delivered for this session. Note that if there are asynchronous logmessages that are not delivered yet, this method will not wait for them and will returnimmediately.

    - #### getFuture

           Future<out Object> getFuture()

      Returns the future created for this session, if it is executed asynchronously.

    - #### setFuture

           void setFuture(Future<out Object> future)

      Sets the future created for this session.

      Parameters:
        `future` - future that runs this session asynchronously

    - #### getState

           SessionState getState()

      Returns the state of the session.

    - #### getReturnCode

           ReturnCode getReturnCode()

      Returns the return code for this session. Note that return code is only set for sessionsthat end with COMPLETED state. If a session is not started, still running or failed thenthis method returns null.

    - #### getFailStackTrace

           String getFailStackTrace()

      Returns the stack trace of the exception received while executing this session.

      The stack trace is only set for sessions that end with FAILED state. For sessions that hasCOMPLETED state this method returns null.

    - #### getLogRedirectionStrategy

           LogRedirectionStrategy getLogRedirectionStrategy()

      Returns session specific log redirection strategy.

    - #### getDuration

           long getDuration()

      Returns the time taken to execute this session.

    - #### getCommand

           String getCommand()

      Returns command arguments as a concatenated string.

    - #### getAllLogs

           List<Log> getAllLogs(int waitTimeout)

      Returns all log entries generated for this session. If there are asynchronousmessages that are not delivered yet, this method waits for them until the given timeout.

      Parameters:
        `waitTimeout` - wait timeout for asynchronous messages in milliseconds

    - #### getAllLogs

           List<Log> getAllLogs()

      Returns all log entries generated for this session. If there are asynchronousmessages that are not delivered yet, this method waits for them until DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT expires.

    - #### getAllLogsAsString

           String getAllLogsAsString(int waitTimeout)

      Returns all log entries generated for this session as a concatenated string. If there areasynchronous messages that are not delivered yet, this method waits for them untilthe given timeout.

      Parameters:
        `waitTimeout` - wait timeout for asynchronous messages in milliseconds

    - #### getAllLogsAsString

           String getAllLogsAsString()

      Returns all log entries generated for this session as a concatenated string. If there areasynchronous messages that are not delivered yet, this method waits for them until DEFAULT_TIMEOUT_FOR_ASYNCHRONOUS_MESSAGES_IN_TRANSMIT expires.

    - #### getLogsAsString

           String getLogsAsString()

      Returns all log entries delivered for this session as a concatenated string. Note that ifthere are asynchronous log messages that are not delivered yet, this method will not waitfor them and will return immediately.

    - #### getOutput

           String getOutput()

      Returns the log output generated while running the session.

    - #### thereAreAsynchronousMessagesInTransmit

           boolean thereAreAsynchronousMessagesInTransmit()

      Returns whether there are still asynchronous messages being transmitted for thissession or not.

    - #### addLog

           void addLog(Log log)

      Adds a new log entry for this session.

      It is invoked internally by `FFmpegKit` library methods. Must not be used by userapplications.

      Parameters:
        `log` - log entry

    - #### cancel

           void cancel()

      Cancels running the session.