Loading...
Searching...
No Matches
LibavEncoder.hpp
1#pragma once
2
3#include <Media/Libav.hpp>
4#if SCORE_HAS_LIBAV
5#include <Gfx/Libav/LibavOutputSettings.hpp>
6
7#include <ossia/detail/pod_vector.hpp>
8
9#include <mutex>
10#include <span>
11extern "C" {
12#include <libavcodec/avcodec.h>
13#include <libavdevice/avdevice.h>
14#include <libavformat/avformat.h>
15#include <libavutil/pixdesc.h>
16#include <libswscale/swscale.h>
17}
18namespace Gfx
19{
20
21struct OutputStream;
23{
24 explicit LibavEncoder(const LibavOutputSettings& set);
26 void enumerate();
27
28 int start();
29 int add_frame(std::span<ossia::float_vector>);
30 int add_frame(const unsigned char* data, AVPixelFormat fmt, int width, int height);
31 // Pre-converted frame: data is already in the target pixel format.
32 // planes/strides/planeCount describe the YUV plane layout.
33 int add_frame_converted(
34 const unsigned char* const planes[], const int strides[], int planeCount,
35 int width, int height);
36 int stop();
37 int stop_impl(); // Must be called with m_muxMutex held
38
39 bool available() const noexcept { return m_formatContext; }
40
42 AVFormatContext* m_formatContext{};
43
44 std::vector<OutputStream> streams;
45 std::mutex m_muxMutex; // Protects av_interleaved_write_frame (not thread-safe)
46
47 int audio_stream_index = -1;
48 int video_stream_index = -1;
49};
50
51}
52#endif
Binds the rendering pipeline to ossia processes.
Definition CameraDevice.cpp:30
Definition LibavEncoder.hpp:23
Definition LibavOutputSettings.hpp:16