| 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 |
|
| 9 |
#include <cstdint> |
| 10 |
#include <memory> |
| 11 |
#include <span> |
| 12 |
#include <string> |
| 13 |
#include <vector> |
| 14 |
|
| 15 |
namespace openmsx { |
| 16 |
|
| 17 |
class AviWriter; |
| 18 |
class FrameSource; |
| 19 |
class Interpreter; |
| 20 |
class MSXMixer; |
| 21 |
class PostProcessor; |
| 22 |
class Reactor; |
| 23 |
class TclObject; |
| 24 |
class Wav16Writer; |
| 25 |
|
| 26 |
class AviRecorder |
| 27 |
{ |
| 28 |
public: |
| 29 |
static constexpr std::string_view VIDEO_DIR = "videos"; |
| 30 |
static constexpr std::string_view AUDIO_DIR = "soundlogs"; |
| 31 |
static constexpr std::string_view VIDEO_EXTENSION = ".avi"; |
| 32 |
static constexpr std::string_view AUDIO_EXTENSION = ".wav"; |
| 33 |
|
| 34 |
public: |
| 35 |
explicit AviRecorder(Reactor& reactor); |
| 36 |
~AviRecorder(); |
| 37 |
|
| 38 |
void addWave(std::span<const StereoFloat> data); |
| 39 |
void addImage(const FrameSource* frame, EmuTime time); |
| 40 |
void stop(); |
| 41 |
[[nodiscard]] unsigned getFrameHeight() const; |
| 42 |
[[nodiscard]] bool isRecording() const; |
| 43 |
|
| 44 |
private: |
| 45 |
void start(bool recordAudio, bool recordVideo, bool recordMono, |
| 46 |
bool recordStereo, const std::string& filename); |
| 47 |
void status(std::span<const TclObject> tokens, TclObject& result) const; |
| 48 |
|
| 49 |
void processStart (Interpreter& interp, std::span<const TclObject> tokens, TclObject& result); |
| 50 |
void processStop (std::span<const TclObject> tokens); |
| 51 |
void processToggle(Interpreter& interp, std::span<const TclObject> tokens, TclObject& result); |
| 52 |
|
| 53 |
private: |
| 54 |
Reactor& reactor; |
| 55 |
|
| 56 |
struct Cmd final : Command { |
| 57 |
explicit Cmd(CommandController& commandController); |
| 58 |
void execute(std::span<const TclObject> tokens, TclObject& result) override; |
| 59 |
[[nodiscard]] std::string help(std::span<const TclObject> tokens) const override; |
| 60 |
void tabCompletion(std::vector<std::string>& tokens) const override; |
| 61 |
} recordCommand; |
| 62 |
|
| 63 |
std::vector<int16_t> audioBuf; |
| 64 |
std::unique_ptr<AviWriter> aviWriter; |
| 65 |
std::unique_ptr<Wav16Writer> wavWriter; |
| 66 |
std::vector<PostProcessor*> postProcessors; |
| 67 |
MSXMixer* mixer = nullptr; |
| 68 |
EmuDuration duration = EmuDuration::infinity(); |
| 69 |
EmuTime prevTime = EmuTime::infinity(); |
| 70 |
unsigned sampleRate; |
| 71 |
unsigned frameWidth; |
| 72 |
unsigned frameHeight = 0; |
| 73 |
bool warnedFps; |
| 74 |
bool warnedSampleRate; |
| 75 |
bool warnedStereo; |
| 76 |
bool stereo; |
| 77 |
}; |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
#endif |