-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdl_screen.h
More file actions
53 lines (42 loc) · 1.45 KB
/
Copy pathsdl_screen.h
File metadata and controls
53 lines (42 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <cstdint>
#include <string>
#include <functional>
#include <memory>
#include <exception>
#include <stdexcept>
extern "C"
{
#include <libavutil/pixfmt.h>
#include <libswscale/swscale.h>
}
#include <SDL.h>
#include "frame_consumer.h"
class SDLScreen final : public FrameConsumer
{
SDLScreen(const SDLScreen&) = delete;
const SDLScreen& operator=(const SDLScreen&) = delete;
SDLScreen(SDLScreen&&) = delete;
const SDLScreen& operator=(SDLScreen&&) = delete;
public:
SDLScreen();
~SDLScreen();
// implementation of FrameConsumer interface
void AcceptFrame(const Frame& frame) override;
public:
void Initialize(const char* caption, int width, int height) throw(std::runtime_error);
void SetInputConversion(AVPixelFormat in_pix_fmt, int in_width, int in_height) throw (std::logic_error, std::runtime_error);
private:
int _width;
int _height;
struct SwsContext* _scale_context; // TO DO: replace by unique_ptr with deleter function
std::unique_ptr<SDL_Window, std::function<void (SDL_Window*)>> _window;
std::unique_ptr<SDL_Renderer, std::function<void (SDL_Renderer*)>> _renderer;
std::unique_ptr<SDL_Texture, std::function<void (SDL_Texture*)>> _texture;
int _in_height; // needed by sws_scale
//Frame _frame;
std::unique_ptr<std::uint8_t, std::function<void(void*)>> _yplane;
std::unique_ptr<std::uint8_t, std::function<void(void*)>> _uplane;
std::unique_ptr<std::uint8_t, std::function<void(void*)>> _vplane;
int _uv_pitch;
};