candlewick 0.1.0
A renderer
Loading...
Searching...
No Matches
VideoRecorder.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef CANDLEWICK_WITH_FFMPEG_SUPPORT
4#error "Including this file requires candlewick to be built with FFmpeg support"
5#endif
6#include "../core/Core.h"
7#include "../core/Tags.h"
8
9#include <SDL3/SDL_gpu.h>
10#include <SDL3/SDL_stdinc.h>
11#include <memory>
12
13namespace candlewick {
14namespace media {
15
16 struct VideoRecorderImpl;
17
19
21 std::unique_ptr<VideoRecorderImpl> _impl;
22 Uint32 _width;
23 Uint32 _height;
24
25 public:
26 struct Settings {
27 int fps = 30;
28 // default: 2.5 Mb/s
29 int bitRate = 2'500'000u;
30 int outputWidth = 0;
31 int outputHeight = 0;
33
37 VideoRecorder &operator=(VideoRecorder &&) noexcept;
38
44 void open(Uint32 width, Uint32 height, std::string_view filename);
45
47 bool isRecording() const { return _impl != nullptr; }
48
59 VideoRecorder(Uint32 width, Uint32 height, std::string_view filename,
61
62 VideoRecorder(Uint32 width, Uint32 height, std::string_view filename);
63
64 Uint32 frameCounter() const;
65
66 void close() noexcept;
67
69
71 const Device &device,
73 SDL_GPUTexture *texture,
74 SDL_GPUTextureFormat format);
75 };
76
77} // namespace media
78} // namespace candlewick
Definition CommandBuffer.h:17
Transfer buffer for the texture downloader.
Definition WriteTextureToImage.h:19
VideoRecorder(NoInitT)
Constructor which will not open the file or stream.
void open(Uint32 width, Uint32 height, std::string_view filename)
Open the recording stream.
struct candlewick::media::VideoRecorder::Settings settings
bool isRecording() const
Returns whether the recording stream is open.
Definition VideoRecorder.h:47
VideoRecorder(Uint32 width, Uint32 height, std::string_view filename)
VideoRecorder(Uint32 width, Uint32 height, std::string_view filename, Settings settings)
Constructor for the video recorder.
VideoRecorder(VideoRecorder &&) noexcept
void writeTextureToVideoFrame(CommandBuffer &command_buffer, const Device &device, TransferBufferPool &pool, SDL_GPUTexture *texture, SDL_GPUTextureFormat format)
Definition VideoRecorder.h:14
Definition Camera.h:8
RAII wrapper for SDL_GPUDevice.
Definition Device.h:17
Tag type for non-initializing constructors (for e.g. RAII classes)
Definition Tags.h:6
Definition VideoRecorder.h:26
int fps
Definition VideoRecorder.h:27
int outputHeight
Definition VideoRecorder.h:31
int outputWidth
Definition VideoRecorder.h:30
int bitRate
Definition VideoRecorder.h:29