# FFmpegKit Linux API: FFmpegKitConfig.cpp File Reference

FFmpegKitConfig.cpp File Reference

Go to the source code of this file.

## Data Structures

class | CallbackData

## Macros

#define | SESSION_MAP_SIZE 1000

## Enumerations

enum | CallbackType { LogType , StatisticsType }

## Functions

static std::atomic< long > | pipeIndexGenerator (1)
int | ffmpeg_execute (int argc, char **argv)
int | ffprobe_execute (int argc, char **argv)
void | ffmpegkit_log_callback_function (void *ptr, int level, const char *format, va_list vargs)
void * | ffmpegKitInitialize ()
static bool | fs_exists (const std::string &s, const bool isFile, const bool isDirectory)
static bool | fs_create_dir (const std::string &s)
void | deleteExpiredSessions ()
void | addSessionToSessionHistory (const std::shared_ptr< ffmpegkit::Session > session)
static void | callbackWait (int milliSeconds)
static void | callbackNotify ()
static const char * | avutil_log_get_level_str (int level)
static void | avutil_log_format_line (void *avcl, int level, const char *fmt, va_list vl, AVBPrint part[4], int *print_prefix)
static void | avutil_log_sanitize (char *line)
static void | logCallbackDataAdd (int level, AVBPrint *data)
static void | statisticsCallbackDataAdd (int frameNumber, float fps, float quality, int64_t size, int time, double bitrate, double speed)
static CallbackData * | callbackDataRemove ()
static void | registerSessionId (long sessionId)
static void | removeSession (long sessionId)
void | cancelSession (long sessionId)
int | cancelRequested (long sessionId)
static void | resetMessagesInTransmit (long sessionId)
void | ffmpegkit_statistics_callback_function (int frameNumber, float fps, float quality, int64_t size, int time, double bitrate, double speed)
static void | process_log (long sessionId, int levelValueInt, AVBPrint *logMessage)
void | process_statistics (long sessionId, int videoFrameNumber, float videoFps, float videoQuality, long size, int time, double bitrate, double speed)
void * | callbackThreadFunction (void *pointer)
static int | executeFFmpeg (const long sessionId, const std::shared_ptr< std::list< std::string > > arguments)
int | executeFFprobe (const long sessionId, const std::shared_ptr< std::list< std::string > > arguments)

## Variables

static int | sessionHistorySize
static std::map< long, std::shared_ptr< ffmpegkit::Session > > | sessionHistoryMap
static std::list< std::shared_ptr< ffmpegkit::Session > > | sessionHistoryList
static std::recursive_mutex | sessionMutex
static std::atomic< short > | sessionMap [SESSION_MAP_SIZE]
static std::atomic< int > | sessionInTransitMessageCountMap [SESSION_MAP_SIZE]
static ffmpegkit::LogCallback | logCallback
static ffmpegkit::StatisticsCallback | statisticsCallback
static ffmpegkit::FFmpegSessionCompleteCallback | ffmpegSessionCompleteCallback
static ffmpegkit::FFprobeSessionCompleteCallback | ffprobeSessionCompleteCallback
static ffmpegkit::MediaInformationSessionCompleteCallback | mediaInformationSessionCompleteCallback
static ffmpegkit::LogRedirectionStrategy | globalLogRedirectionStrategy
static int | redirectionEnabled
static std::recursive_mutex | callbackDataMutex
static std::mutex | callbackMutex
static std::condition_variable | callbackMonitor
static std::list< CallbackData * > | callbackDataList
volatile int | handleSIGQUIT = 1
volatile int | handleSIGINT = 1
volatile int | handleSIGTERM = 1
volatile int | handleSIGXCPU = 1
volatile int | handleSIGPIPE = 1
__thread long | globalSessionId = 0
int | configuredLogLevel = ffmpegkit::LevelAVLogInfo
static std::once_flag | ffmpegKitInitializerFlag
static pthread_t | callbackThread
const void * | _ffmpegKitConfigInitializer {ffmpegKitInitialize()}

## Macro Definition Documentation

## SESSION_MAP_SIZE

#define SESSION_MAP_SIZE 1000

Session control variables

Definition at line 59 of file FFmpegKitConfig.cpp.

## Enumeration Type Documentation

## CallbackType

enum CallbackType

Enumerator
LogType |
StatisticsType |

Definition at line 120 of file FFmpegKitConfig.cpp.

## Function Documentation

## addSessionToSessionHistory()

void addSessionToSessionHistory | ( | const std::shared_ptr< ffmpegkit::Session > | session | ) |

Definition at line 160 of file FFmpegKitConfig.cpp.

## avutil_log_format_line()

static void avutil_log_format_line | ( | void * | avcl,
|  | int | level,
|  | const char * | fmt,
|  | va_list | vl,
|  | AVBPrint | part[4],
|  | int * | print_prefix
| ) |  |

static

Definition at line 312 of file FFmpegKitConfig.cpp.

## avutil_log_get_level_str()

static const char * avutil_log_get_level_str | ( | int | level | ) |

static

Definition at line 287 of file FFmpegKitConfig.cpp.

## avutil_log_sanitize()

static void avutil_log_sanitize | ( | char * | line | ) |

static

Definition at line 344 of file FFmpegKitConfig.cpp.

## callbackDataRemove()

static CallbackData * callbackDataRemove | ( |  | ) |

static

Removes head of callback data list.

Definition at line 390 of file FFmpegKitConfig.cpp.

## callbackNotify()

static void callbackNotify | ( |  | ) |

static

Notifies threads waiting on callback semaphore.

Definition at line 283 of file FFmpegKitConfig.cpp.

## callbackThreadFunction()

void * callbackThreadFunction | ( | void * | pointer | ) |

Forwards asynchronous messages to Callbacks.

Definition at line 638 of file FFmpegKitConfig.cpp.

## callbackWait()

static void callbackWait | ( | int | milliSeconds | ) |

static

Waits on the callback semaphore for the given time.

Parameters

  milliSeconds | wait time in milliseconds

Definition at line 275 of file FFmpegKitConfig.cpp.

## cancelRequested()

int cancelRequested | ( | long | sessionId | ) |

Checks whether a cancel request for the given session id exists in the session map.

Parameters

  sessionId | session id

Returns
  1 if exists, false otherwise

Definition at line 441 of file FFmpegKitConfig.cpp.

## cancelSession()

void cancelSession | ( | long | sessionId | ) |

Adds a cancel session request to the session map.

Parameters

  sessionId | session id

Definition at line 431 of file FFmpegKitConfig.cpp.

## deleteExpiredSessions()

void deleteExpiredSessions | ( |  | ) |

Definition at line 150 of file FFmpegKitConfig.cpp.

## executeFFmpeg()

static int executeFFmpeg | ( | const long | sessionId,
|  | const std::shared_ptr< std::list< std::string > > | arguments
| ) |  |

static

Definition at line 686 of file FFmpegKitConfig.cpp.

## executeFFprobe()

int executeFFprobe | ( | const long | sessionId,
|  | const std::shared_ptr< std::list< std::string > > | arguments
| ) |  |

Definition at line 726 of file FFmpegKitConfig.cpp.

## ffmpeg_execute()

int ffmpeg_execute | ( | int | argc,
|  | char ** | argv
| ) |  |

Forward declaration for function defined in fftools_ffmpeg.c

Definition at line 4775 of file fftools_ffmpeg.c.

## ffmpegkit_log_callback_function()

void ffmpegkit_log_callback_function | ( | void * | ptr,
|  | int | level,
|  | const char * | format,
|  | va_list | vargs
| ) |  |

Callback function for FFmpeg/FFprobe logs.

Parameters

  ptr | pointer to AVClass struct
  level | log level
  format | format string
  vargs | arguments

Definition at line 470 of file FFmpegKitConfig.cpp.

## ffmpegkit_statistics_callback_function()

void ffmpegkit_statistics_callback_function | ( | int | frameNumber,
|  | float | fps,
|  | float | quality,
|  | int64_t | size,
|  | int | time,
|  | double | bitrate,
|  | double | speed
| ) |  |

Callback function for FFmpeg statistics.

Parameters

  frameNumber | last processed frame number
  fps | frames processed per second
  quality | quality of the output stream (video only)
  size | size in bytes
  time | processed output duration
  bitrate | output bit rate in kbits/s
  speed | processing speed = processed duration / operation duration

Definition at line 519 of file FFmpegKitConfig.cpp.

## ffmpegKitInitialize()

void * ffmpegKitInitialize | ( |  | ) |

Definition at line 766 of file FFmpegKitConfig.cpp.

## ffprobe_execute()

int ffprobe_execute | ( | int | argc,
|  | char ** | argv
| ) |  |

Forward declaration for function defined in fftools_ffprobe.c

Definition at line 4050 of file fftools_ffprobe.c.

## fs_create_dir()

static bool fs_create_dir | ( | const std::string & | s | ) |

static

Definition at line 140 of file FFmpegKitConfig.cpp.

## fs_exists()

static bool fs_exists | ( | const std::string & | s,
|  | const bool | isFile,
|  | const bool | isDirectory
| ) |  |

static

Definition at line 125 of file FFmpegKitConfig.cpp.

## logCallbackDataAdd()

static void logCallbackDataAdd | ( | int | level,
|  | AVBPrint * | data
| ) |  |

static

Adds log data to the end of callback data list.

Parameters

  level | log level
  data | log data

Definition at line 358 of file FFmpegKitConfig.cpp.

## pipeIndexGenerator()

static std::atomic< long > pipeIndexGenerator | ( | 1 |  | ) |

static

Generates ids for named ffmpeg kit pipes.

## process_log()

static void process_log | ( | long | sessionId,
|  | int | levelValueInt,
|  | AVBPrint * | logMessage
| ) |  |

static

Definition at line 523 of file FFmpegKitConfig.cpp.

## process_statistics()

void process_statistics | ( | long | sessionId,
|  | int | videoFrameNumber,
|  | float | videoFps,
|  | float | videoQuality,
|  | long | size,
|  | int | time,
|  | double | bitrate,
|  | double | speed
| ) |  |

Definition at line 607 of file FFmpegKitConfig.cpp.

## registerSessionId()

static void registerSessionId | ( | long | sessionId | ) |

static

Registers a session id to the session map.

Parameters

  sessionId | session id

Definition at line 409 of file FFmpegKitConfig.cpp.

## removeSession()

static void removeSession | ( | long | sessionId | ) |

static

Removes a session id from the session map.

Parameters

  sessionId | session id

Definition at line 418 of file FFmpegKitConfig.cpp.

## resetMessagesInTransmit()

static void resetMessagesInTransmit | ( | long | sessionId | ) |

static

Resets the number of messages in transmit for this session.

Parameters

  sessionId | session id

Definition at line 458 of file FFmpegKitConfig.cpp.

## statisticsCallbackDataAdd()

static void statisticsCallbackDataAdd | ( | int | frameNumber,
|  | float | fps,
|  | float | quality,
|  | int64_t | size,
|  | int | time,
|  | double | bitrate,
|  | double | speed
| ) |  |

static

Adds statistics data to the end of callback data list.

Definition at line 374 of file FFmpegKitConfig.cpp.

## Variable Documentation

## _ffmpegKitConfigInitializer

const void* _ffmpegKitConfigInitializer {ffmpegKitInitialize()}

Definition at line 118 of file FFmpegKitConfig.cpp.

## callbackDataList

std::list<CallbackData*> callbackDataList

static

Definition at line 82 of file FFmpegKitConfig.cpp.

## callbackDataMutex

std::recursive_mutex callbackDataMutex

static

Definition at line 78 of file FFmpegKitConfig.cpp.

## callbackMonitor

std::condition_variable callbackMonitor

static

Definition at line 80 of file FFmpegKitConfig.cpp.

## callbackMutex

std::mutex callbackMutex

static

Definition at line 79 of file FFmpegKitConfig.cpp.

## callbackThread

pthread_t callbackThread

static

Definition at line 114 of file FFmpegKitConfig.cpp.

## configuredLogLevel

int configuredLogLevel = ffmpegkit::LevelAVLogInfo

Holds the default log level

Definition at line 95 of file FFmpegKitConfig.cpp.

## ffmpegKitInitializerFlag

std::once_flag ffmpegKitInitializerFlag

static

Definition at line 113 of file FFmpegKitConfig.cpp.

## ffmpegSessionCompleteCallback

ffmpegkit::FFmpegSessionCompleteCallback ffmpegSessionCompleteCallback

static

Holds complete callbacks defined to redirect asynchronous execution results

Definition at line 70 of file FFmpegKitConfig.cpp.

## ffprobeSessionCompleteCallback

ffmpegkit::FFprobeSessionCompleteCallback ffprobeSessionCompleteCallback

static

Definition at line 71 of file FFmpegKitConfig.cpp.

## globalLogRedirectionStrategy

ffmpegkit::LogRedirectionStrategy globalLogRedirectionStrategy

static

Definition at line 74 of file FFmpegKitConfig.cpp.

## globalSessionId

__thread long globalSessionId = 0

Holds the id of the current execution

Definition at line 92 of file FFmpegKitConfig.cpp.

## handleSIGINT

volatile int handleSIGINT = 1

Definition at line 86 of file FFmpegKitConfig.cpp.

## handleSIGPIPE

volatile int handleSIGPIPE = 1

Definition at line 89 of file FFmpegKitConfig.cpp.

## handleSIGQUIT

volatile int handleSIGQUIT = 1

Fields that control the handling of SIGNALs

Definition at line 85 of file FFmpegKitConfig.cpp.

## handleSIGTERM

volatile int handleSIGTERM = 1

Definition at line 87 of file FFmpegKitConfig.cpp.

## handleSIGXCPU

volatile int handleSIGXCPU = 1

Definition at line 88 of file FFmpegKitConfig.cpp.

## logCallback

ffmpegkit::LogCallback logCallback

static

Holds callback defined to redirect logs

Definition at line 64 of file FFmpegKitConfig.cpp.

## mediaInformationSessionCompleteCallback

ffmpegkit::MediaInformationSessionCompleteCallback mediaInformationSessionCompleteCallback

static

Definition at line 72 of file FFmpegKitConfig.cpp.

## redirectionEnabled

int redirectionEnabled

static

Redirection control variables

Definition at line 77 of file FFmpegKitConfig.cpp.

## sessionHistoryList

std::list<std::shared_ptr<ffmpegkit::Session> > sessionHistoryList

static

Definition at line 55 of file FFmpegKitConfig.cpp.

## sessionHistoryMap

std::map<long, std::shared_ptr<ffmpegkit::Session> > sessionHistoryMap

static

Definition at line 54 of file FFmpegKitConfig.cpp.

## sessionHistorySize

int sessionHistorySize

static

Definition at line 53 of file FFmpegKitConfig.cpp.

## sessionInTransitMessageCountMap

std::atomic<int> sessionInTransitMessageCountMap[SESSION_MAP_SIZE]

static

Definition at line 61 of file FFmpegKitConfig.cpp.

## sessionMap

std::atomic<short> sessionMap[SESSION_MAP_SIZE]

static

Definition at line 60 of file FFmpegKitConfig.cpp.

## sessionMutex

std::recursive_mutex sessionMutex

static

Definition at line 56 of file FFmpegKitConfig.cpp.

## statisticsCallback

ffmpegkit::StatisticsCallback statisticsCallback

static

Holds callback defined to redirect statistics

Definition at line 67 of file FFmpegKitConfig.cpp.