MediaX v1.0.0rc7 [7e6cb74]
Video streaming for military vehicles
Loading...
Searching...
No Matches
display_manager_sdl.h
Go to the documentation of this file.
1//
2// Copyright (c) 2025, Astute Systems PTY LTD
3//
4// This file is part of the VivoeX project developed by Astute Systems.
5//
6// Licensed under the Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
7// License. See the LICENSE file in the project root for full license details.
8//
10
11#ifndef HARDWARE_DISPLAY_MANAGER_SDL_H_
12#define HARDWARE_DISPLAY_MANAGER_SDL_H_
13
14// SDL2 Direct Rendering Manager
15#include <SDL2/SDL.h>
16#include <errno.h>
17#include <fcntl.h>
18#include <linux/fb.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22#include <sys/ioctl.h>
23#include <sys/mman.h>
24#include <sys/stat.h>
25#include <sys/types.h>
26#include <unistd.h>
27
28#include <cstdint>
29#include <mutex>
30#include <string>
31#include <vector>
32
33#include "common/datatypes.h"
35
36namespace mediax::sdl {
37
40 public:
45 DisplayManager(std::string name = "");
46
52
57 DisplayManager(const DisplayManager &) = delete;
58
65
75 Status Initalise(uint32_t width, uint32_t height, bool fullscreen);
76 Status Initalise() override;
77
83 Resolution GetResolution() override;
84
90 int GetBytesPerPixel() final { return 4; }
91
97 mediax::rtp::ColourspaceType GetColourspace() final { return mediax::rtp::ColourspaceType::kColourspaceRgba; }
98
108 Status DisplayBuffer(uint8_t *frame_buffer, Resolution resolution, std::string text) override;
109
114 void Flush() override;
115
120 void ToggleFullscreen() override;
121
125 void Run() override;
126
131 void Stop() override;
132
134 static std::string text_;
135
136 private:
138 static std::vector<uint8_t> frame_buffer_;
140 static int width_;
142 static int height_;
144 bool initaliased_ = false;
146 static std::mutex frame_buffer_mutex_;
148 static std::vector<uint8_t> draw_buffer_;
150 SDL_Window *window_ = nullptr;
152 SDL_Surface *surface_ = nullptr;
154 SDL_Renderer *renderer_ = nullptr;
156 static SDL_Texture *texture_;
158 SDL_Rect texr_ = {0, 0, 0, 0};
160 static bool running_;
162 static int fullscreen_;
163};
164
165} // namespace mediax::sdl
166
167#endif // HARDWARE_DISPLAY_MANAGER_SDL_H_
The display manager class.
Definition display_manager_base.h:35
The display manager class.
Definition display_manager_sdl.h:39
static std::mutex frame_buffer_mutex_
The mutex for the frame buffer.
Definition display_manager_sdl.h:146
Status Initalise() override
Initalise the display manager.
Definition display_manager_sdl.cc:54
void Flush() override
Flush the framebuffer if needed.
Definition display_manager_sdl.cc:204
void ToggleFullscreen() override
Toggle Fullscreen.
Definition display_manager_sdl.cc:188
static bool running_
The SDL event loop.
Definition display_manager_sdl.h:160
static std::string text_
The text to display.
Definition display_manager_sdl.h:134
void Stop() override
Stop the main loop if there is one.
Definition display_manager_sdl.cc:178
static int height_
The default height.
Definition display_manager_sdl.h:142
static std::vector< uint8_t > frame_buffer_
Frame buffer device.
Definition display_manager_sdl.h:138
static int width_
The default width.
Definition display_manager_sdl.h:140
static std::vector< uint8_t > draw_buffer_
The draw buffer.
Definition display_manager_sdl.h:148
Status DisplayBuffer(uint8_t *frame_buffer, Resolution resolution, std::string text) override
Buffer must be in the format RGBA.
Definition display_manager_sdl.cc:264
~DisplayManager()
Destroy the Display Manager object.
Definition display_manager_sdl.cc:49
static SDL_Texture * texture_
The SDL texture.
Definition display_manager_sdl.h:156
DisplayManager(const DisplayManager &)=delete
Construct a new Display Manager object (deleted)
int GetBytesPerPixel() final
Get the Bits Per Pixel object.
Definition display_manager_sdl.h:90
static int fullscreen_
The fullscreen flag.
Definition display_manager_sdl.h:162
Resolution GetResolution() override
Get the Resolution attribute.
Definition display_manager_sdl.cc:208
void Run() override
Run the main event loop.
Definition display_manager_sdl.cc:116
mediax::rtp::ColourspaceType GetColourspace() final
Get the Colourspace object.
Definition display_manager_sdl.h:97
DisplayManager & operator=(const DisplayManager &)=delete
Delete the copy operator.
SDL_Surface * surface_
The SDL surface.
Definition display_manager_sdl.h:152
bool initaliased_
Initalized flag.
Definition display_manager_sdl.h:144
SDL_Rect texr_
The SDL texture rect.
Definition display_manager_sdl.h:158
SDL_Renderer * renderer_
The SDL renderer.
Definition display_manager_sdl.h:154
SDL_Window * window_
The SDL window.
Definition display_manager_sdl.h:150
ColourspaceType
Supported colour spaces.
Definition rtp_types.h:102
Status
Enum of status.
Definition datatypes.h:21
The video resolution structure.
Definition datatypes.h:34