MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ open()

bool MayaFlux::IO::VideoFileWriter::open ( const std::string &  filepath,
uint32_t  width,
uint32_t  height,
double  frame_rate,
AVPixelFormat  src_pixel_format,
AVCodecID  explicit_codec = AV_CODEC_ID_NONE 
)

Definition at line 212 of file VideoFileWriter.cpp.

218{
219 if (m_open.load(std::memory_order_acquire)) {
220 set_error("open() called while already open");
221 return false;
222 }
223
224 m_width = width;
225 m_height = height;
226 m_src_fmt = src_pixel_format;
227 m_close_promise = std::promise<bool> {};
228 m_closing.store(false, std::memory_order_release);
229
230 m_worker = std::thread(&VideoFileWriter::worker_loop, this,
231 filepath, width, height, frame_rate, src_pixel_format, explicit_codec);
232
233 constexpr int k_spin_ms = 500;
234 constexpr int k_sleep_us = 500;
235 for (int i = 0; i < (k_spin_ms * 1000 / k_sleep_us); ++i) {
236 if (m_open.load(std::memory_order_acquire))
237 return true;
238 std::this_thread::sleep_for(std::chrono::microseconds(k_sleep_us));
239 }
240
241 if (m_worker.joinable())
242 m_worker.join();
243 return false;
244}
uint32_t width
Definition Decoder.cpp:59
void worker_loop(const std::string &filepath, uint32_t width, uint32_t height, double frame_rate, AVPixelFormat src_fmt, AVCodecID codec_id)
void set_error(std::string msg)
std::promise< bool > m_close_promise

References m_close_promise, m_closing, m_height, m_open, m_src_fmt, m_width, m_worker, set_error(), width, and worker_loop().

Referenced by record().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: