xbmc
SavestateFlatBuffer.h
1 /*
2  * Copyright (C) 2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "ISavestate.h"
12 
13 #include <memory>
14 
15 #include <flatbuffers/flatbuffers.h>
16 
17 namespace flatbuffers
18 {
19 class FlatBufferBuilder;
20 }
21 
22 namespace KODI
23 {
24 namespace RETRO
25 {
26 struct Savestate;
27 struct SavestateBuilder;
28 
30 {
31 public:
33  ~CSavestateFlatBuffer() override;
34 
35  // Implementation of ISavestate
36  void Reset() override;
37  bool Serialize(const uint8_t*& data, size_t& size) const override;
38  SAVE_TYPE Type() const override;
39  uint8_t Slot() const override;
40  std::string Label() const override;
41  std::string Caption() const override;
42  CDateTime Created() const override;
43  std::string GameFileName() const override;
44  uint64_t TimestampFrames() const override;
45  double TimestampWallClock() const override;
46  std::string GameClientID() const override;
47  std::string GameClientVersion() const override;
48  AVPixelFormat GetPixelFormat() const override;
49  unsigned int GetNominalWidth() const override;
50  unsigned int GetNominalHeight() const override;
51  unsigned int GetMaxWidth() const override;
52  unsigned int GetMaxHeight() const override;
53  float GetPixelAspectRatio() const override;
54  const uint8_t* GetVideoData() const override;
55  size_t GetVideoSize() const override;
56  unsigned int GetVideoWidth() const override;
57  unsigned int GetVideoHeight() const override;
58  unsigned int GetRotationDegCCW() const override;
59  const uint8_t* GetMemoryData() const override;
60  size_t GetMemorySize() const override;
61  void SetType(SAVE_TYPE type) override;
62  void SetSlot(uint8_t slot) override;
63  void SetLabel(const std::string& label) override;
64  void SetCaption(const std::string& caption) override;
65  void SetCreated(const CDateTime& createdUTC) override;
66  void SetGameFileName(const std::string& gameFileName) override;
67  void SetTimestampFrames(uint64_t timestampFrames) override;
68  void SetTimestampWallClock(double timestampWallClock) override;
69  void SetGameClientID(const std::string& gameClient) override;
70  void SetGameClientVersion(const std::string& gameClient) override;
71  void SetPixelFormat(AVPixelFormat pixelFormat) override;
72  void SetNominalWidth(unsigned int nominalWidth) override;
73  void SetNominalHeight(unsigned int nominalHeight) override;
74  void SetMaxWidth(unsigned int maxWidth) override;
75  void SetMaxHeight(unsigned int maxHeight) override;
76  void SetPixelAspectRatio(float pixelAspectRatio) override;
77  uint8_t* GetVideoBuffer(size_t size) override;
78  void SetVideoWidth(unsigned int videoWidth) override;
79  void SetVideoHeight(unsigned int videoHeight) override;
80  void SetRotationDegCCW(unsigned int rotationCCW) override;
81  uint8_t* GetMemoryBuffer(size_t size) override;
82  void Finalize() override;
83  bool Deserialize(std::vector<uint8_t> data) override;
84 
85 private:
91  std::unique_ptr<flatbuffers::FlatBufferBuilder> m_builder;
92 
98  std::vector<uint8_t> m_data;
99 
103  const Savestate* m_savestate = nullptr;
104 
105  using StringOffset = flatbuffers::Offset<flatbuffers::String>;
106  using VectorOffset = flatbuffers::Offset<flatbuffers::Vector<uint8_t>>;
107 
108  // Temporary deserialization variables
109  SAVE_TYPE m_type = SAVE_TYPE::UNKNOWN;
110  uint8_t m_slot = 0;
111  std::unique_ptr<StringOffset> m_labelOffset;
112  std::unique_ptr<StringOffset> m_captionOffset;
113  std::unique_ptr<StringOffset> m_createdOffset;
114  std::unique_ptr<StringOffset> m_gameFileNameOffset;
115  uint64_t m_timestampFrames = 0;
116  double m_timestampWallClock = 0.0;
117  std::unique_ptr<StringOffset> m_emulatorAddonIdOffset;
118  std::unique_ptr<StringOffset> m_emulatorVersionOffset;
119  AVPixelFormat m_pixelFormat{AV_PIX_FMT_NONE};
120  unsigned int m_nominalWidth{0};
121  unsigned int m_nominalHeight{0};
122  unsigned int m_maxWidth{0};
123  unsigned int m_maxHeight{0};
124  float m_pixelAspectRatio{0.0f};
125  std::unique_ptr<VectorOffset> m_videoDataOffset;
126  unsigned int m_videoWidth{0};
127  unsigned int m_videoHeight{0};
128  unsigned int m_rotationCCW{0};
129  std::unique_ptr<VectorOffset> m_memoryDataOffset;
130 };
131 } // namespace RETRO
132 } // namespace KODI
Definition: SavestateFlatBuffer.h:29
Definition: ISavestate.h:28
Definition: SavestateFlatBuffer.h:17
Controller configuration window.
Definition: AudioDecoder.h:18
DateTime class, which uses FileTime as it&#39;s base.
Definition: XBDateTime.h:63