-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideostream.h
More file actions
65 lines (46 loc) · 1.47 KB
/
videostream.h
File metadata and controls
65 lines (46 loc) · 1.47 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
54
55
56
57
58
59
60
61
62
63
64
65
//
// Created by Ian Parker on 06/03/2025.
//
#ifndef VIDEOSTREAM_H
#define VIDEOSTREAM_H
#include <thread>
#include <gst/gst.h>
#include <gst/rtsp-server/rtsp-server.h>
#include "logger.h"
struct Display;
class XStreamPlugin;
class VideoStream;
enum Codec
{
CODEC_H264,
CODEC_MJPEG
};
struct DisplayContext
{
std::shared_ptr<Display> display;
VideoStream* videoStream;
};
class VideoStream : private Logger
{
private:
XStreamPlugin* m_xscreenPlugin;
std::shared_ptr<std::thread> m_streamMainThread;
GMainLoop* m_loop = nullptr;
GstRTSPServer* m_server = nullptr;
bool m_streaming = false;
Codec m_codec = CODEC_MJPEG;
static void needDataCallback(GstElement* appsrc, guint unused, const DisplayContext* displayData);
void needData(const std::shared_ptr<Display> &display);
static void enoughDataCallback(GstElement* appsrc, guint unused, DisplayContext* displayData);
void enoughData(const std::shared_ptr<Display> &display);
static void mediaConfigureCallback(GstRTSPMediaFactory* factory, GstRTSPMedia* media, DisplayContext* displayData);
void mediaConfigure(GstRTSPMedia* media, const std::shared_ptr<Display> &display);
void streamMain();
public:
explicit VideoStream(XStreamPlugin* plugin) : Logger("VideoStream"), m_xscreenPlugin(plugin) {}
~VideoStream() override = default;
bool start();
bool stop();
[[nodiscard]] bool isStreaming() const { return m_streaming; }
};
#endif //VIDEOSTREAM_H