xbmc
RetroPlayerVideo.h
1 /*
2  * Copyright (C) 2012-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 "IRetroPlayerStream.h"
12 #include "cores/RetroPlayer/RetroPlayerTypes.h"
13 
14 extern "C"
15 {
16 #include <libavutil/pixfmt.h>
17 }
18 
19 namespace KODI
20 {
21 namespace RETRO
22 {
23 class CRPProcessInfo;
24 class CRPRenderManager;
25 
27 {
28  VideoStreamProperties(AVPixelFormat pixfmt,
29  unsigned int nominalWidth,
30  unsigned int nominalHeight,
31  unsigned int maxWidth,
32  unsigned int maxHeight,
33  float pixelAspectRatio)
34  : pixfmt(pixfmt),
35  nominalWidth(nominalWidth),
36  nominalHeight(nominalHeight),
37  maxWidth(maxWidth),
38  maxHeight(maxHeight),
39  pixelAspectRatio(pixelAspectRatio)
40  {
41  }
42 
43  AVPixelFormat pixfmt;
44  unsigned int nominalWidth;
45  unsigned int nominalHeight;
46  unsigned int maxWidth;
47  unsigned int maxHeight;
48  float pixelAspectRatio;
49 };
50 
52 {
53  VideoStreamBuffer() = default;
54 
56  AVPixelFormat pixfmt, uint8_t* data, size_t size, DataAccess access, DataAlignment alignment)
57  : pixfmt(pixfmt), data(data), size(size), access(access), alignment(alignment)
58  {
59  }
60 
61  AVPixelFormat pixfmt{AV_PIX_FMT_NONE};
62  uint8_t* data{nullptr};
63  size_t size{0};
64  DataAccess access{DataAccess::READ_WRITE};
65  DataAlignment alignment{DataAlignment::DATA_UNALIGNED};
66 };
67 
69 {
70  VideoStreamPacket(unsigned int width,
71  unsigned int height,
72  VideoRotation rotation,
73  const uint8_t* data,
74  size_t size)
75  : width(width), height(height), rotation(rotation), data(data), size(size)
76  {
77  }
78 
79  unsigned int width;
80  unsigned int height;
81  VideoRotation rotation;
82  const uint8_t* data;
83  size_t size;
84 };
85 
92 {
93 public:
94  CRetroPlayerVideo(CRPRenderManager& m_renderManager, CRPProcessInfo& m_processInfo);
95  ~CRetroPlayerVideo() override;
96 
97  // implementation of IRetroPlayerStream
98  bool OpenStream(const StreamProperties& properties) override;
99  bool GetStreamBuffer(unsigned int width, unsigned int height, StreamBuffer& buffer) override;
100  void AddStreamData(const StreamPacket& packet) override;
101  void CloseStream() override;
102 
103 private:
104  // Construction parameters
105  CRPRenderManager& m_renderManager;
106  CRPProcessInfo& m_processInfo;
107 
108  // Stream properties
109  bool m_bOpen = false;
110  std::vector<VideoStreamBuffer> m_buffers;
111 };
112 } // namespace RETRO
113 } // namespace KODI
Renders video frames provided by the game loop.
Definition: RPRenderManager.h:67
Definition: RetroPlayerVideo.h:68
Controller configuration window.
Definition: AudioDecoder.h:18
Definition: RetroPlayerVideo.h:26
Definition: RetroPlayerVideo.h:51
Definition: IRetroPlayerStream.h:26
Definition: IRetroPlayerStream.h:22
Renders video frames provided by the game loop.
Definition: RetroPlayerVideo.h:91
Player process info.
Definition: RPProcessInfo.h:77
Definition: IRetroPlayerStream.h:18
Definition: IRetroPlayerStream.h:30