#ifndef Recorder_h_ #define Recorder_h_ #include #include #include #include #include #include #include "SDL.h" #include "SDL_mixer.h" #define GLM_ENABLE_EXPERIMENTAL #include "glm/ext.hpp" #include "json/json.hpp" #include "filesystem.hpp" #include "Node.hpp" #include "Animation.hpp" #include "extension.hpp" struct Stash { std::vector pixel_buffers; std::vector flipped; std::vector audio_buffers; std::vector audio_buffer_lengths; int frame_offset; Stash(int frame_offset = 0) : frame_offset(frame_offset) {} }; struct Recorder : Node { Stash current_stash = Stash(); Stash most_recent_stash; std::list in_game_stashes; std::list video_stashes; fs::path current_video_directory, current_audio_path; Animation animation = Animation(&Recorder::add_frame, this); bool is_recording = false, writing_recording = false, writing_most_recent = false; std::ofstream audio_file; Recorder(Node*); float get_frame_length(); void respond(SDL_Event&); void capture_screen(); void grab_stash(); void write_most_recent_frames(); void start_recording(); void open_audio_file(); void add_frame(); int get_memory_size(); void make_directory(); void write_stash_frames(Stash*); void keep_stash(); void end_recording(); void finish_writing_video(); void write_mp4(); void write_audio(Uint8*, int); void update(); std::string get_class_name() { return "Recorder"; } }; void process_audio(void*, Uint8*, int); #include "Game.hpp" #endif