| FFmpegKit Linux API 6.0

Loading...
Searching...
No Matches
FFmpegKit.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Taner Sener
3 *
4 * This file is part of FFmpegKit.
5 *
6 * FFmpegKit is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpegKit is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "ArchDetect.h"
21#include "FFmpegKit.h"
22#include "FFmpegKitConfig.h"
23#include "Packages.h"
24
25 extern "C" {
26 void cancel_operation(long id);
27}
28
29 extern void* ffmpegKitInitialize();
30
31 const void* _ffmpegKitInitializeri{ffmpegKitInitialize()};
32
33std::shared_ptr<ffmpegkit::FFmpegSession> ffmpegkit::FFmpegKit::executeWithArguments(const std::list<std::string>& arguments) {
34 auto session = ffmpegkit::FFmpegSession::create(arguments);
35 ffmpegkit::FFmpegKitConfig::ffmpegExecute(session);
36 return session;
37}
38
39std::shared_ptr<ffmpegkit::FFmpegSession> ffmpegkit::FFmpegKit::executeWithArgumentsAsync(const std::list<std::string>& arguments, FFmpegSessionCompleteCallback completeCallback) {
40 auto session = ffmpegkit::FFmpegSession::create(arguments, completeCallback);
41 ffmpegkit::FFmpegKitConfig::asyncFFmpegExecute(session);
42 return session;
43}
44
45std::shared_ptr<ffmpegkit::FFmpegSession> ffmpegkit::FFmpegKit::executeWithArgumentsAsync(const std::list<std::string>& arguments, FFmpegSessionCompleteCallback completeCallback, ffmpegkit::LogCallback logCallback, ffmpegkit::StatisticsCallback statisticsCallback) {
46 auto session = ffmpegkit::FFmpegSession::create(arguments, completeCallback, logCallback, statisticsCallback);
47 ffmpegkit::FFmpegKitConfig::asyncFFmpegExecute(session);
48 return session;
49}
50
51std::shared_ptr<ffmpegkit::FFmpegSession> ffmpegkit::FFmpegKit::execute(const std::string command) {
52 auto session = ffmpegkit::FFmpegSession::create(FFmpegKitConfig::parseArguments(command.c_str()));
53 ffmpegkit::FFmpegKitConfig::ffmpegExecute(session);
54 return session;
55}
56
57std::shared_ptr<ffmpegkit::FFmpegSession> ffmpegkit::FFmpegKit::executeAsync(const std::string command, FFmpegSessionCompleteCallback completeCallback) {
58 auto session = ffmpegkit::FFmpegSession::create(FFmpegKitConfig::parseArguments(command.c_str()), completeCallback);
59 ffmpegkit::FFmpegKitConfig::asyncFFmpegExecute(session);
60 return session;
61}
62
63std::shared_ptr<ffmpegkit::FFmpegSession> ffmpegkit::FFmpegKit::executeAsync(const std::string command, FFmpegSessionCompleteCallback completeCallback, ffmpegkit::LogCallback logCallback, ffmpegkit::StatisticsCallback statisticsCallback) {
64 auto session = ffmpegkit::FFmpegSession::create(FFmpegKitConfig::parseArguments(command.c_str()), completeCallback, logCallback, statisticsCallback);
65 ffmpegkit::FFmpegKitConfig::asyncFFmpegExecute(session);
66 return session;
67}
68
69 void ffmpegkit::FFmpegKit::cancel() {
70
71 /*
72 * ZERO (0) IS A SPECIAL SESSION ID
73 * WHEN IT IS PASSED TO THIS METHOD, A SIGINT IS GENERATED WHICH CANCELS ALL ONGOING SESSIONS
74 */
75 cancel_operation(0);
76}
77
78 void ffmpegkit::FFmpegKit::cancel(const long sessionId) {
79 cancel_operation(sessionId);
80}
81
82std::shared_ptr<std::list<std::shared_ptr<ffmpegkit::FFmpegSession>>> ffmpegkit::FFmpegKit::listSessions() {
83 return ffmpegkit::FFmpegKitConfig::getFFmpegSessions();
84}
ArchDetect.h
cancel_operation
void cancel_operation(long id)
Definition fftools_ffmpeg.c:4367
_ffmpegKitInitializeri
const void * _ffmpegKitInitializeri
Definition FFmpegKit.cpp:31
ffmpegKitInitialize
void * ffmpegKitInitialize()
Definition FFmpegKitConfig.cpp:771
FFmpegKit.h
logCallback
static ffmpegkit::LogCallback logCallback
Definition FFmpegKitConfig.cpp:69
statisticsCallback
static ffmpegkit::StatisticsCallback statisticsCallback
Definition FFmpegKitConfig.cpp:72
FFmpegKitConfig.h
Packages.h
ffmpegkit::FFmpegKitConfig::parseArguments
static std::list< std::string > parseArguments(const std::string &command)
Definition FFmpegKitConfig.cpp:1366
ffmpegkit::FFmpegKitConfig::asyncFFmpegExecute
static void asyncFFmpegExecute(const std::shared_ptr< ffmpegkit::FFmpegSession > ffmpegSession)
Definition FFmpegKitConfig.cpp:1060
ffmpegkit::FFmpegKitConfig::getFFmpegSessions
static std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::FFmpegSession > > > getFFmpegSessions()
Definition FFmpegKitConfig.cpp:1272
ffmpegkit::FFmpegKitConfig::ffmpegExecute
static void ffmpegExecute(const std::shared_ptr< ffmpegkit::FFmpegSession > ffmpegSession)
Definition FFmpegKitConfig.cpp:1012
ffmpegkit::FFmpegKit::listSessions
static std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::FFmpegSession > > > listSessions()
Definition FFmpegKit.cpp:82
ffmpegkit::FFmpegKit::executeWithArgumentsAsync
static std::shared_ptr< ffmpegkit::FFmpegSession > executeWithArgumentsAsync(const std::list< std::string > &arguments, FFmpegSessionCompleteCallback completeCallback)
Definition FFmpegKit.cpp:39
ffmpegkit::FFmpegKit::executeWithArguments
static std::shared_ptr< ffmpegkit::FFmpegSession > executeWithArguments(const std::list< std::string > &arguments)
Definition FFmpegKit.cpp:33
ffmpegkit::FFmpegKit::executeAsync
static std::shared_ptr< ffmpegkit::FFmpegSession > executeAsync(const std::string command, FFmpegSessionCompleteCallback completeCallback)
Definition FFmpegKit.cpp:57
ffmpegkit::FFmpegKit::cancel
static void cancel()
Definition FFmpegKit.cpp:69
ffmpegkit::FFmpegKit::execute
static std::shared_ptr< ffmpegkit::FFmpegSession > execute(const std::string command)
Definition FFmpegKit.cpp:51
ffmpegkit::FFmpegSession::create
static std::shared_ptr< ffmpegkit::FFmpegSession > create(const std::list< std::string > &arguments)
Definition FFmpegSession.cpp:27
ffmpegkit::StatisticsCallback
std::function< void(const std::shared_ptr< ffmpegkit::Statistics > statistics)> StatisticsCallback
Definition StatisticsCallback.h:35
ffmpegkit::LogCallback
std::function< void(const std::shared_ptr< ffmpegkit::Log > log)> LogCallback
Definition LogCallback.h:35
ffmpegkit::FFmpegSessionCompleteCallback
std::function< void(const std::shared_ptr< ffmpegkit::FFmpegSession > session)> FFmpegSessionCompleteCallback
Definition FFmpegSessionCompleteCallback.h:52