forked from chebizarro/ffmpeg-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSession.h
More file actions
260 lines (225 loc) · 9.68 KB
/
Copy pathSession.h
File metadata and controls
260 lines (225 loc) · 9.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*
* Copyright (c) 2022 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General License for more details.
*
* You should have received a copy of the GNU Lesser General License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FFMPEG_KIT_SESSION_H
#define FFMPEG_KIT_SESSION_H
#include "Log.h"
#include "LogCallback.h"
#include "LogRedirectionStrategy.h"
#include "ReturnCode.h"
#include "SessionState.h"
#include <string>
#include <chrono>
#include <list>
namespace ffmpegkit {
/**
* <p>Common interface for all <code>FFmpegKit</code> sessions.
*/
class Session {
public:
/**
* Returns the session specific log callback.
*
* @return session specific log callback
*/
virtual ffmpegkit::LogCallback getLogCallback() const = 0;
/**
* Returns the session identifier.
*
* @return session identifier
*/
virtual long getSessionId() const = 0;
/**
* Returns session create time.
*
* @return session create time
*/
virtual std::chrono::time_point<std::chrono::system_clock> getCreateTime() const = 0;
/**
* Returns session start time.
*
* @return session start time
*/
virtual std::chrono::time_point<std::chrono::system_clock> getStartTime() const = 0;
/**
* Returns session end time.
*
* @return session end time
*/
virtual std::chrono::time_point<std::chrono::system_clock> getEndTime() const = 0;
/**
* Returns the time taken to execute this session.
*
* @return time taken to execute this session in milliseconds or zero (0) if the session is
* not over yet
*/
virtual long getDuration() const = 0;
/**
* Returns command arguments as a list.
*
* @return command arguments as a list
*/
virtual std::shared_ptr<std::list<std::string>> getArguments() const = 0;
/**
* Returns command arguments as a concatenated string.
*
* @return command arguments as a concatenated string
*/
virtual std::string getCommand() const = 0;
/**
* 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.
*
* @param waitTimeout wait timeout for asynchronous messages in milliseconds
* @return list of log entries generated for this session
*/
virtual std::shared_ptr<std::list<std::shared_ptr<ffmpegkit::Log>>> getAllLogsWithTimeout(const int waitTimeout) const = 0;
/**
* Returns all log entries generated for this session. If there are asynchronous
* messages that are not delivered yet, this method waits for them.
*
* @return list of log entries generated for this session
*/
virtual std::shared_ptr<std::list<std::shared_ptr<ffmpegkit::Log>>> getAllLogs() const = 0;
/**
* 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.
*
* @return list of log entries received for this session
*/
virtual std::shared_ptr<std::list<std::shared_ptr<ffmpegkit::Log>>> getLogs() const = 0;
/**
* 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.
*
* @param waitTimeout wait timeout for asynchronous messages in milliseconds
* @return all log entries generated for this session as a concatenated string
*/
virtual std::string getAllLogsAsStringWithTimeout(const int waitTimeout) const = 0;
/**
* 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.
*
* @return all log entries generated for this session as a concatenated string
*/
virtual std::string getAllLogsAsString() const = 0;
/**
* 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.
*
* @return list of log entries received for this session
*/
virtual std::string getLogsAsString() const = 0;
/**
* Returns the log output generated while running the session.
*
* @return log output generated
*/
virtual std::string getOutput() const = 0;
/**
* Returns the state of the session.
*
* @return state of the session
*/
virtual ffmpegkit::SessionState getState() const = 0;
/**
* 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.
*
* @return the return code for this session if the session has completed, nullptr if session is
* not started, still running or failed
*/
virtual std::shared_ptr<ffmpegkit::ReturnCode> getReturnCode() const = 0;
/**
* Returns the stack trace of the exception received while executing this session.
* <p>
* 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.
*
* @return stack trace of the exception received while executing this session, an empty string if session
* is not started, still running or completed
*/
virtual std::string getFailStackTrace() const = 0;
/**
* Returns session specific log redirection strategy.
*
* @return session specific log redirection strategy
*/
virtual LogRedirectionStrategy getLogRedirectionStrategy() const = 0;
/**
* Returns whether there are still asynchronous messages being transmitted for this
* session or not.
*
* @return true if there are still asynchronous messages being transmitted, false
* otherwise
*/
virtual bool thereAreAsynchronousMessagesInTransmit() const = 0;
/**
* Adds a new log entry for this session.
*
* It is invoked internally by <code>FFmpegKit</code> library methods. Must not be used by user
* applications.
*
* @param log log entry
*/
virtual void addLog(const std::shared_ptr<ffmpegkit::Log> log) = 0;
/**
* Starts running the session.
*/
virtual void startRunning() = 0;
/**
* Completes running the session with the provided return code.
*
* @param returnCode return code of the execution
*/
virtual void complete(const std::shared_ptr<ffmpegkit::ReturnCode> returnCode) = 0;
/**
* Ends running the session with a failure.
*
* @param error error received
*/
virtual void fail(const char* error) = 0;
/**
* Returns whether it is an <code>FFmpeg</code> session or not.
*
* @return true if it is an <code>FFmpeg</code> session, false otherwise
*/
virtual bool isFFmpeg() const = 0;
/**
* Returns whether it is an <code>FFprobe</code> session or not.
*
* @return true if it is an <code>FFprobe</code> session, false otherwise
*/
virtual bool isFFprobe() const = 0;
/**
* Returns whether it is a <code>MediaInformation</code> session or not.
*
* @return true if it is a <code>MediaInformation</code> session, false otherwise
*/
virtual bool isMediaInformation() const = 0;
/**
* Cancels running the session.
*/
virtual void cancel() = 0;
};
}
#endif // FFMPEG_KIT_SESSION_H