2017-04-28 23:54:58 +00:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <deque>
|
|
|
|
#include "INotificationListener.h"
|
|
|
|
#include "RewindData.h"
|
2017-11-20 04:08:23 +00:00
|
|
|
#include "IInputProvider.h"
|
|
|
|
#include "IInputRecorder.h"
|
2017-04-28 23:54:58 +00:00
|
|
|
|
|
|
|
enum class RewindState
|
|
|
|
{
|
|
|
|
Stopped = 0,
|
|
|
|
Stopping = 1,
|
|
|
|
Starting = 2,
|
2017-08-02 02:49:50 +00:00
|
|
|
Started = 3,
|
|
|
|
Debugging = 4
|
2017-04-28 23:54:58 +00:00
|
|
|
};
|
|
|
|
|
2017-11-20 04:08:23 +00:00
|
|
|
class RewindManager : public INotificationListener, public IInputProvider, public IInputRecorder
|
2017-04-28 23:54:58 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
static const uint32_t BufferSize = 30; //Number of frames between each save state
|
|
|
|
static RewindManager* _instance;
|
|
|
|
std::deque<RewindData> _history;
|
|
|
|
std::deque<RewindData> _historyBackup;
|
|
|
|
RewindData _currentHistory;
|
|
|
|
|
|
|
|
RewindState _rewindState;
|
|
|
|
int32_t _framesToFastForward;
|
|
|
|
|
|
|
|
std::deque<vector<uint32_t>> _videoHistory;
|
|
|
|
vector<vector<uint32_t>> _videoHistoryBuilder;
|
|
|
|
std::deque<int16_t> _audioHistory;
|
|
|
|
vector<int16_t> _audioHistoryBuilder;
|
|
|
|
|
|
|
|
void AddHistoryBlock();
|
|
|
|
void PopHistory();
|
|
|
|
|
2017-08-02 02:49:50 +00:00
|
|
|
void Start(bool forDebugger);
|
2017-04-28 23:54:58 +00:00
|
|
|
void Stop();
|
2017-08-02 02:49:50 +00:00
|
|
|
void ForceStop();
|
2017-04-28 23:54:58 +00:00
|
|
|
|
|
|
|
void ProcessFrame(void *frameBuffer, uint32_t width, uint32_t height);
|
|
|
|
bool ProcessAudio(int16_t *soundBuffer, uint32_t sampleCount, uint32_t sampleRate);
|
2017-11-14 05:00:00 +00:00
|
|
|
|
|
|
|
void ClearBuffer();
|
2017-04-28 23:54:58 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
RewindManager();
|
|
|
|
~RewindManager();
|
|
|
|
|
|
|
|
void ProcessNotification(ConsoleNotificationType type, void* parameter) override;
|
|
|
|
void ProcessEndOfFrame();
|
2017-11-20 04:08:23 +00:00
|
|
|
|
2017-11-21 22:54:54 +00:00
|
|
|
void RecordInput(vector<shared_ptr<BaseControlDevice>> devices) override;
|
2017-11-20 04:08:23 +00:00
|
|
|
bool SetInput(BaseControlDevice *device) override;
|
2017-04-28 23:54:58 +00:00
|
|
|
|
2017-08-02 02:49:50 +00:00
|
|
|
static void StartRewinding(bool forDebugger = false);
|
|
|
|
static void StopRewinding(bool forDebugger = false);
|
2017-04-28 23:54:58 +00:00
|
|
|
static bool IsRewinding();
|
2017-08-02 02:49:50 +00:00
|
|
|
static bool IsStepBack();
|
2017-04-28 23:54:58 +00:00
|
|
|
static void RewindSeconds(uint32_t seconds);
|
|
|
|
|
|
|
|
static void SendFrame(void *frameBuffer, uint32_t width, uint32_t height);
|
|
|
|
static bool SendAudio(int16_t *soundBuffer, uint32_t sampleCount, uint32_t sampleRate);
|
|
|
|
};
|