Skip to main content
Version: 🚧 Nightly

File video_encoder.h

Location: video\_encoder.h

Classes​

Namespaces​

Includes​

Source​

#ifndef f3d_video_encoder_h
#define f3d_video_encoder_h

#include "exception.h"
#include "export.h"
#include "video_frame.h"
#include "video_packet.h"

#include <functional>
#include <memory>

namespace f3d
{
class F3D_EXPORT video_encoder
{
public:
virtual ~video_encoder() = default;

enum class codec
{
H264,
HEVC,
VP8,
VP9,
AV1,
EXPLICIT
};

struct params
{
codec Codec = codec::H264;
std::string ExplicitCodecName;
int Width = 0;
int Height = 0;
double FrameRate = 30;
double Bitrate = 5.0;
bool LowLatency = false;
};

[[nodiscard]] static std::shared_ptr<video_encoder> create(const params& p);

[[nodiscard]] static std::vector<std::pair<std::string, std::string>> getAvailableEncoders();


[[nodiscard]] virtual int getWidth() const = 0;
[[nodiscard]] virtual int getHeight() const = 0;

virtual video_encoder& listen(
std::function<void(const std::shared_ptr<video_packet>&)> callback) = 0;

virtual bool submit(const std::shared_ptr<video_frame>& frame) = 0;

virtual video_encoder& flush() = 0;

struct codec_exception : public exception
{
explicit codec_exception(const std::string& what = "");
};

struct transport_exception : public exception
{
explicit transport_exception(const std::string& what = "");
};
};
}

#endif