# FFmpegKit Linux API: ffmpegkit::AbstractSession Class Reference

Loading...
Searching...
No Matches
ffmpegkit::AbstractSession Class Reference

`#include <AbstractSession.h>`

## Public Member Functions

| AbstractSession (const std::list< std::string > &arguments, const ffmpegkit::LogCallback logCallback, const LogRedirectionStrategy logRedirectionStrategy)
void | waitForAsynchronousMessagesInTransmit (const int timeout) const
ffmpegkit::LogCallback | getLogCallback () const override
long | getSessionId () const override
std::chrono::time_point< std::chrono::system_clock > | getCreateTime () const override
std::chrono::time_point< std::chrono::system_clock > | getStartTime () const override
std::chrono::time_point< std::chrono::system_clock > | getEndTime () const override
long | getDuration () const override
std::shared_ptr< std::list< std::string > > | getArguments () const override
std::string | getCommand () const override
std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::Log > > > | getAllLogsWithTimeout (const int waitTimeout) const override
std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::Log > > > | getAllLogs () const override
std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::Log > > > | getLogs () const override
std::string | getAllLogsAsStringWithTimeout (const int waitTimeout) const override
std::string | getAllLogsAsString () const override
std::string | getLogsAsString () const override
std::string | getOutput () const override
ffmpegkit::SessionState | getState () const override
std::shared_ptr< ffmpegkit::ReturnCode > | getReturnCode () const override
std::string | getFailStackTrace () const override
ffmpegkit::LogRedirectionStrategy | getLogRedirectionStrategy () const override
bool | thereAreAsynchronousMessagesInTransmit () const override
void | addLog (const std::shared_ptr< ffmpegkit::Log > log) override
void | startRunning () override
void | complete (const std::shared_ptr< ffmpegkit::ReturnCode > returnCode) override
void | fail (const char *error) override
virtual bool | isFFmpeg () const override
virtual bool | isFFprobe () const override
virtual bool | isMediaInformation () const override
void | cancel () override
virtual ffmpegkit::LogCallback | getLogCallback () const =0
virtual long | getSessionId () const =0
virtual std::chrono::time_point< std::chrono::system_clock > | getCreateTime () const =0
virtual std::chrono::time_point< std::chrono::system_clock > | getStartTime () const =0
virtual std::chrono::time_point< std::chrono::system_clock > | getEndTime () const =0
virtual long | getDuration () const =0
virtual std::shared_ptr< std::list< std::string > > | getArguments () const =0
virtual std::string | getCommand () const =0
virtual std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::Log > > > | getAllLogsWithTimeout (const int waitTimeout) const =0
virtual std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::Log > > > | getAllLogs () const =0
virtual std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::Log > > > | getLogs () const =0
virtual std::string | getAllLogsAsStringWithTimeout (const int waitTimeout) const =0
virtual std::string | getAllLogsAsString () const =0
virtual std::string | getLogsAsString () const =0
virtual std::string | getOutput () const =0
virtual ffmpegkit::SessionState | getState () const =0
virtual std::shared_ptr< ffmpegkit::ReturnCode > | getReturnCode () const =0
virtual std::string | getFailStackTrace () const =0
virtual LogRedirectionStrategy | getLogRedirectionStrategy () const =0
virtual bool | thereAreAsynchronousMessagesInTransmit () const =0
virtual void | addLog (const std::shared_ptr< ffmpegkit::Log > log)=0
virtual void | startRunning ()=0
virtual void | complete (const std::shared_ptr< ffmpegkit::ReturnCode > returnCode)=0
virtual void | fail (const char *error)=0
virtual bool | isFFmpeg () const =0
virtual bool | isFFprobe () const =0
virtual bool | isMediaInformation () const =0
virtual void | cancel ()=0

## Static Public Attributes

static constexpr int | DefaultTimeoutForAsynchronousMessagesInTransmit = 5000

## Private Attributes

const long | _sessionId
ffmpegkit::LogCallback | _logCallback
std::chrono::time_point< std::chrono::system_clock > | _createTime
std::chrono::time_point< std::chrono::system_clock > | _startTime
std::chrono::time_point< std::chrono::system_clock > | _endTime
std::shared_ptr< std::list< std::string > > | _arguments
std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::Log > > > | _logs
SessionState | _state
std::shared_ptr< ffmpegkit::ReturnCode > | _returnCode
std::string | _failStackTrace
LogRedirectionStrategy | _logRedirectionStrategy

## Detailed Description

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

Definition at line 31 of file AbstractSession.h.

## Constructor & Destructor Documentation

## AbstractSession()

ffmpegkit::AbstractSession::AbstractSession | ( | const std::list< std::string > & | arguments,
|  | const ffmpegkit::LogCallback | logCallback,
|  | const LogRedirectionStrategy | logRedirectionStrategy
| ) |  |

Creates a new abstract session.

Parameters

  arguments | command arguments
  logCallback | session specific log callback
  logRedirectionStrategy | session specific log redirection strategy

Definition at line 36 of file AbstractSession.cpp.

## Member Function Documentation

## addLog()

void ffmpegkit::AbstractSession::addLog | ( | const std::shared_ptr< ffmpegkit::Log > | log | ) |

overridevirtual

Adds a new log entry for this session.

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

Parameters

  log | log entry

Implements ffmpegkit::Session.

Definition at line 162 of file AbstractSession.cpp.

## cancel()

void ffmpegkit::AbstractSession::cancel | ( |  | ) |

overridevirtual

Cancels running the session.

Implements ffmpegkit::Session.

Definition at line 198 of file AbstractSession.cpp.

## complete()

void ffmpegkit::AbstractSession::complete | ( | const std::shared_ptr< ffmpegkit::ReturnCode > | returnCode | ) |

overridevirtual

Completes running the session with the provided return code.

Parameters

  returnCode | return code of the execution

Implements ffmpegkit::Session.

Definition at line 171 of file AbstractSession.cpp.

## fail()

void ffmpegkit::AbstractSession::fail | ( | const char * | error | ) |

overridevirtual

Ends running the session with a failure.

Parameters

  error | error received

Implements ffmpegkit::Session.

Definition at line 177 of file AbstractSession.cpp.

## getAllLogs()

std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::Log > > > ffmpegkit::AbstractSession::getAllLogs | ( |  | ) | const

overridevirtual

Returns all log entries generated for this session. If there are asynchronous messages that are not delivered yet, this method waits for them.

Returns
  list of log entries generated for this session

Implements ffmpegkit::Session.

Definition at line 106 of file AbstractSession.cpp.

## getAllLogsAsString()

std::string ffmpegkit::AbstractSession::getAllLogsAsString | ( |  | ) | const

overridevirtual

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

Returns
  all log entries generated for this session as a concatenated string

Implements ffmpegkit::Session.

Definition at line 124 of file AbstractSession.cpp.

## getAllLogsAsStringWithTimeout()

std::string ffmpegkit::AbstractSession::getAllLogsAsStringWithTimeout | ( | const int | waitTimeout | ) | const

overridevirtual

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

Parameters

  waitTimeout | wait timeout for asynchronous messages in milliseconds

Returns
  all log entries generated for this session as a concatenated string

Implements ffmpegkit::Session.

Definition at line 114 of file AbstractSession.cpp.

## getAllLogsWithTimeout()

std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::Log > > > ffmpegkit::AbstractSession::getAllLogsWithTimeout | ( | const int | waitTimeout | ) | const

overridevirtual

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

Parameters

  waitTimeout | wait timeout for asynchronous messages in milliseconds

Returns
  list of log entries generated for this session

Implements ffmpegkit::Session.

Definition at line 97 of file AbstractSession.cpp.

## getArguments()

std::shared_ptr< std::list< std::string > > ffmpegkit::AbstractSession::getArguments | ( |  | ) | const

overridevirtual

Returns command arguments as a list.

Returns
  command arguments as a list

Implements ffmpegkit::Session.

Definition at line 89 of file AbstractSession.cpp.

## getCommand()

std::string ffmpegkit::AbstractSession::getCommand | ( |  | ) | const

overridevirtual

Returns command arguments as a concatenated string.

Returns
  command arguments as a concatenated string

Implements ffmpegkit::Session.

Definition at line 93 of file AbstractSession.cpp.

## getCreateTime()

std::chrono::time_point< std::chrono::system_clock > ffmpegkit::AbstractSession::getCreateTime | ( |  | ) | const

overridevirtual

Returns session create time.

Returns
  session create time

Implements ffmpegkit::Session.

Definition at line 66 of file AbstractSession.cpp.

## getDuration()

long ffmpegkit::AbstractSession::getDuration | ( |  | ) | const

overridevirtual

Returns the time taken to execute this session.

Returns
  time taken to execute this session in milliseconds or zero (0) if the session is not over yet

Implements ffmpegkit::Session.

Definition at line 78 of file AbstractSession.cpp.

## getEndTime()

std::chrono::time_point< std::chrono::system_clock > ffmpegkit::AbstractSession::getEndTime | ( |  | ) | const

overridevirtual

Returns session end time.

Returns
  session end time

Implements ffmpegkit::Session.

Definition at line 74 of file AbstractSession.cpp.

## getFailStackTrace()

std::string ffmpegkit::AbstractSession::getFailStackTrace | ( |  | ) | const

overridevirtual

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

The stack trace is only set for sessions that end with SessionStateFailed state. For sessions that has SessionStateCompleted state this method returns an empty string.

Returns
  stack trace of the exception received while executing this session, an empty string if session is not started, still running or completed

Implements ffmpegkit::Session.

Definition at line 150 of file AbstractSession.cpp.

## getLogCallback()

ffmpegkit::LogCallback ffmpegkit::AbstractSession::getLogCallback | ( |  | ) | const

overridevirtual

Returns the session specific log callback.

Returns
  session specific log callback

Implements ffmpegkit::Session.

Definition at line 58 of file AbstractSession.cpp.

## getLogRedirectionStrategy()

ffmpegkit::LogRedirectionStrategy ffmpegkit::AbstractSession::getLogRedirectionStrategy | ( |  | ) | const

overridevirtual

Returns session specific log redirection strategy.

Returns
  session specific log redirection strategy

Implements ffmpegkit::Session.

Definition at line 154 of file AbstractSession.cpp.

## getLogs()

std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::Log > > > ffmpegkit::AbstractSession::getLogs | ( |  | ) | const

overridevirtual

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

Returns
  list of log entries received for this session

Implements ffmpegkit::Session.

Definition at line 110 of file AbstractSession.cpp.

## getLogsAsString()

std::string ffmpegkit::AbstractSession::getLogsAsString | ( |  | ) | const

overridevirtual

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

Returns
  list of log entries received for this session

Implements ffmpegkit::Session.

Definition at line 128 of file AbstractSession.cpp.

## getOutput()

std::string ffmpegkit::AbstractSession::getOutput | ( |  | ) | const

overridevirtual

Returns the log output generated while running the session.

Returns
  log output generated

Implements ffmpegkit::Session.

Definition at line 138 of file AbstractSession.cpp.

## getReturnCode()

std::shared_ptr< ffmpegkit::ReturnCode > ffmpegkit::AbstractSession::getReturnCode | ( |  | ) | const

overridevirtual

Returns the return code for this session. Note that return code is only set for sessions that end with SessionStateCompleted state. If a session is not started, still running or failed then this method returns nullptr.

Returns
  the return code for this session if the session has completed, nullptr if session is not started, still running or failed

Implements ffmpegkit::Session.

Definition at line 146 of file AbstractSession.cpp.

## getSessionId()

long ffmpegkit::AbstractSession::getSessionId | ( |  | ) | const

overridevirtual

Returns the session identifier.

Returns
  session identifier

Implements ffmpegkit::Session.

Definition at line 62 of file AbstractSession.cpp.

## getStartTime()

std::chrono::time_point< std::chrono::system_clock > ffmpegkit::AbstractSession::getStartTime | ( |  | ) | const

overridevirtual

Returns session start time.

Returns
  session start time

Implements ffmpegkit::Session.

Definition at line 70 of file AbstractSession.cpp.

## getState()

ffmpegkit::SessionState ffmpegkit::AbstractSession::getState | ( |  | ) | const

overridevirtual

Returns the state of the session.

Returns
  state of the session

Implements ffmpegkit::Session.

Definition at line 142 of file AbstractSession.cpp.

## isFFmpeg()

bool ffmpegkit::AbstractSession::isFFmpeg | ( |  | ) | const

overridevirtual

Returns whether it is an `FFmpeg` session or not.

Returns
  true if it is an `FFmpeg` session, false otherwise

Implements ffmpegkit::Session.

Reimplemented in ffmpegkit::FFmpegSession, ffmpegkit::FFprobeSession, and ffmpegkit::MediaInformationSession.

Definition at line 183 of file AbstractSession.cpp.

## isFFprobe()

bool ffmpegkit::AbstractSession::isFFprobe | ( |  | ) | const

overridevirtual

Returns whether it is an `FFprobe` session or not.

Returns
  true if it is an `FFprobe` session, false otherwise

Implements ffmpegkit::Session.

Reimplemented in ffmpegkit::FFmpegSession, ffmpegkit::FFprobeSession, and ffmpegkit::MediaInformationSession.

Definition at line 188 of file AbstractSession.cpp.

## isMediaInformation()

bool ffmpegkit::AbstractSession::isMediaInformation | ( |  | ) | const

overridevirtual

Returns whether it is a `MediaInformation` session or not.

Returns
  true if it is a `MediaInformation` session, false otherwise

Implements ffmpegkit::Session.

Reimplemented in ffmpegkit::FFmpegSession, ffmpegkit::FFprobeSession, and ffmpegkit::MediaInformationSession.

Definition at line 193 of file AbstractSession.cpp.

## startRunning()

void ffmpegkit::AbstractSession::startRunning | ( |  | ) |

overridevirtual

Starts running the session.

Implements ffmpegkit::Session.

Definition at line 166 of file AbstractSession.cpp.

## thereAreAsynchronousMessagesInTransmit()

bool ffmpegkit::AbstractSession::thereAreAsynchronousMessagesInTransmit | ( |  | ) | const

overridevirtual

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

Returns
  true if there are still asynchronous messages being transmitted, false otherwise

Implements ffmpegkit::Session.

Definition at line 158 of file AbstractSession.cpp.

## waitForAsynchronousMessagesInTransmit()

void ffmpegkit::AbstractSession::waitForAsynchronousMessagesInTransmit | ( | const int | timeout | ) | const

Waits for all asynchronous messages to be transmitted until the given timeout.

Parameters

  timeout | wait timeout in milliseconds

Definition at line 47 of file AbstractSession.cpp.

## Field Documentation

## _arguments

std::shared_ptr<std::list<std::string> > ffmpegkit::AbstractSession::_arguments

private

Definition at line 277 of file AbstractSession.h.

## _createTime

std::chrono::time_point<std::chrono::system_clock> ffmpegkit::AbstractSession::_createTime

private

Definition at line 274 of file AbstractSession.h.

## _endTime

std::chrono::time_point<std::chrono::system_clock> ffmpegkit::AbstractSession::_endTime

private

Definition at line 276 of file AbstractSession.h.

## _failStackTrace

std::string ffmpegkit::AbstractSession::_failStackTrace

private

Definition at line 281 of file AbstractSession.h.

## _logCallback

ffmpegkit::LogCallback ffmpegkit::AbstractSession::_logCallback

private

Definition at line 273 of file AbstractSession.h.

## _logRedirectionStrategy

LogRedirectionStrategy ffmpegkit::AbstractSession::_logRedirectionStrategy

private

Definition at line 282 of file AbstractSession.h.

## _logs

std::shared_ptr<std::list<std::shared_ptr<ffmpegkit::Log> > > ffmpegkit::AbstractSession::_logs

private

Definition at line 278 of file AbstractSession.h.

## _returnCode

std::shared_ptr<ffmpegkit::ReturnCode> ffmpegkit::AbstractSession::_returnCode

private

Definition at line 280 of file AbstractSession.h.

## _sessionId

const long ffmpegkit::AbstractSession::_sessionId

private

Definition at line 272 of file AbstractSession.h.

## _startTime

std::chrono::time_point<std::chrono::system_clock> ffmpegkit::AbstractSession::_startTime

private

Definition at line 275 of file AbstractSession.h.

## _state

SessionState ffmpegkit::AbstractSession::_state

private

Definition at line 279 of file AbstractSession.h.

## DefaultTimeoutForAsynchronousMessagesInTransmit

constexpr int ffmpegkit::AbstractSession::DefaultTimeoutForAsynchronousMessagesInTransmit = 5000

staticconstexpr

Defines how long default "getAll" methods wait, in milliseconds.

Definition at line 37 of file AbstractSession.h.

The documentation for this class was generated from the following files:

- AbstractSession.h
- AbstractSession.cpp