2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2009-03-28 15:27:48 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2009-03-28 15:27:48 -06:00
|
|
|
|
2020-10-21 08:37:16 -06:00
|
|
|
#include <ctime>
|
|
|
|
#include <memory>
|
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
2013-02-26 18:47:48 -07:00
|
|
|
|
2020-10-21 08:37:16 -06:00
|
|
|
struct FrameDumpContext;
|
|
|
|
class PointerWrap;
|
2023-01-30 23:15:09 -07:00
|
|
|
|
|
|
|
// Holds relevant emulation state during a rendered frame for
|
|
|
|
// when it is later asynchronously written.
|
|
|
|
struct FrameState
|
|
|
|
{
|
|
|
|
u64 ticks = 0;
|
|
|
|
int frame_number = 0;
|
|
|
|
u32 savestate_index = 0;
|
|
|
|
int refresh_rate_num = 0;
|
|
|
|
int refresh_rate_den = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FrameData
|
|
|
|
{
|
|
|
|
const u8* data = nullptr;
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
int stride = 0;
|
|
|
|
FrameState state;
|
|
|
|
};
|
2020-10-21 08:37:16 -06:00
|
|
|
|
2023-01-26 21:03:15 -07:00
|
|
|
class FFMpegFrameDump
|
2009-03-28 15:27:48 -06:00
|
|
|
{
|
2014-06-14 21:29:05 -06:00
|
|
|
public:
|
2023-01-26 21:03:15 -07:00
|
|
|
FFMpegFrameDump();
|
|
|
|
~FFMpegFrameDump();
|
2016-11-04 11:19:35 -06:00
|
|
|
|
2020-11-21 14:25:57 -07:00
|
|
|
bool Start(int w, int h, u64 start_ticks);
|
2020-10-21 08:37:16 -06:00
|
|
|
void AddFrame(const FrameData&);
|
|
|
|
void Stop();
|
|
|
|
void DoState(PointerWrap&);
|
|
|
|
bool IsStarted() const;
|
2020-11-21 14:25:57 -07:00
|
|
|
FrameState FetchState(u64 ticks, int frame_number) const;
|
2020-10-21 08:37:16 -06:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool IsFirstFrameInCurrentFile() const;
|
2020-11-21 14:25:57 -07:00
|
|
|
bool PrepareEncoding(int w, int h, u64 start_ticks, u32 savestate_index);
|
2020-10-21 08:37:16 -06:00
|
|
|
bool CreateVideoFile();
|
|
|
|
void CloseVideoFile();
|
|
|
|
void CheckForConfigChange(const FrameData&);
|
2020-10-23 13:32:10 -06:00
|
|
|
void ProcessPackets();
|
2016-11-04 11:19:35 -06:00
|
|
|
|
2017-05-22 13:27:10 -06:00
|
|
|
#if defined(HAVE_FFMPEG)
|
2020-10-21 08:37:16 -06:00
|
|
|
std::unique_ptr<FrameDumpContext> m_context;
|
2016-11-04 11:19:35 -06:00
|
|
|
#endif
|
2020-10-21 08:37:16 -06:00
|
|
|
|
|
|
|
// Used for FetchState:
|
|
|
|
u32 m_savestate_index = 0;
|
|
|
|
|
|
|
|
// Used for filename generation.
|
|
|
|
std::time_t m_start_time = {};
|
|
|
|
u32 m_file_index = 0;
|
2009-03-28 15:27:48 -06:00
|
|
|
};
|
2020-10-21 08:37:16 -06:00
|
|
|
|
|
|
|
#if !defined(HAVE_FFMPEG)
|
2023-01-30 23:15:09 -07:00
|
|
|
inline FFMpegFrameDump::FFMpegFrameDump() = default;
|
|
|
|
inline FFMpegFrameDump::~FFMpegFrameDump() = default;
|
2020-10-21 08:37:16 -06:00
|
|
|
|
2023-01-30 23:15:09 -07:00
|
|
|
inline FrameState FFMpegFrameDump::FetchState(u64 ticks, int frame_number) const
|
2020-10-21 08:37:16 -06:00
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
#endif
|