openMSX
AviRecorder.hh
Go to the documentation of this file.
1#ifndef AVIRECORDER_HH
2#define AVIRECORDER_HH
3
4#include "Command.hh"
5#include "EmuDuration.hh"
6#include "EmuTime.hh"
7#include "Mixer.hh"
8#include <cstdint>
9#include <memory>
10#include <span>
11#include <vector>
12
13namespace openmsx {
14
15class AviWriter;
16class Filename;
17class FrameSource;
18class Interpreter;
19class MSXMixer;
20class PostProcessor;
21class Reactor;
22class TclObject;
23class Wav16Writer;
24
26{
27public:
28 static constexpr std::string_view VIDEO_DIR = "videos";
29 static constexpr std::string_view AUDIO_DIR = "soundlogs";
30 static constexpr std::string_view VIDEO_EXTENSION = ".avi";
31 static constexpr std::string_view AUDIO_EXTENSION = ".wav";
32
33public:
34 explicit AviRecorder(Reactor& reactor);
36
37 void addWave(std::span<const StereoFloat> data);
38 void addImage(FrameSource* frame, EmuTime::param time);
39 void stop();
40 [[nodiscard]] unsigned getFrameHeight() const;
41 [[nodiscard]] bool isRecording() const;
42
43private:
44 void start(bool recordAudio, bool recordVideo, bool recordMono,
45 bool recordStereo, const Filename& filename);
46 void status(std::span<const TclObject> tokens, TclObject& result) const;
47
48 void processStart (Interpreter& interp, std::span<const TclObject> tokens, TclObject& result);
49 void processStop (std::span<const TclObject> tokens);
50 void processToggle(Interpreter& interp, std::span<const TclObject> tokens, TclObject& result);
51
52private:
53 Reactor& reactor;
54
55 struct Cmd final : Command {
56 explicit Cmd(CommandController& commandController);
57 void execute(std::span<const TclObject> tokens, TclObject& result) override;
58 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
59 void tabCompletion(std::vector<std::string>& tokens) const override;
60 } recordCommand;
61
62 std::vector<int16_t> audioBuf;
63 std::unique_ptr<AviWriter> aviWriter; // can be nullptr
64 std::unique_ptr<Wav16Writer> wavWriter; // can be nullptr
65 std::vector<PostProcessor*> postProcessors;
66 MSXMixer* mixer = nullptr;
68 EmuTime prevTime = EmuTime::infinity();
69 unsigned sampleRate;
70 unsigned frameWidth;
71 unsigned frameHeight = 0;
72 bool warnedFps;
73 bool warnedSampleRate;
74 bool warnedStereo;
75 bool stereo;
76};
77
78} // namespace openmsx
79
80#endif
void addImage(FrameSource *frame, EmuTime::param time)
void addWave(std::span< const StereoFloat > data)
static constexpr std::string_view AUDIO_DIR
unsigned getFrameHeight() const
bool isRecording() const
static constexpr std::string_view VIDEO_DIR
static constexpr std::string_view AUDIO_EXTENSION
static constexpr std::string_view VIDEO_EXTENSION
static constexpr EmuDuration infinity()
This class represents a filename.
Definition Filename.hh:20
Interface for getting lines from a video frame.
Contains the main loop of openMSX.
Definition Reactor.hh:72
This file implemented 3 utility functions:
Definition Autofire.cc:11