-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvideo.hpp
More file actions
78 lines (63 loc) · 2.03 KB
/
video.hpp
File metadata and controls
78 lines (63 loc) · 2.03 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
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#include "connection.hpp"
#include "file_manager.hpp"
#include "glib.hpp"
#include "input.hpp"
#include "util.hpp"
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <assert.h>
#include <atomic>
#include <chrono>
#include <gst/gst.h>
#include <gst/video/videooverlay.h>
#include <mutex>
#include <rtc/rtc.hpp>
struct VideoInfo {
std::mutex mutex;
int width;
int height;
};
class VideoWindow : public Fl_Double_Window {
protected:
ConnectionInfo conn_info;
std::shared_ptr<rtc::PeerConnection> conn;
std::shared_ptr<rtc::Track> video_track;
std::shared_ptr<rtc::Track> audio_track;
std::shared_ptr<rtc::DataChannel> ordered_channel;
std::shared_ptr<rtc::DataChannel> unordered_channel;
std::unique_ptr<RawMouseManager> mouse_manager;
std::unique_ptr<KeyboardGrabManager> keyboard_grab_manager;
VideoInfo video_info;
glib::Object<GstElement> video_pipeline;
glib::Object<GstElement> audio_pipeline;
GstVideoOverlay* overlay = nullptr;
bool connected = false;
bool playing = false;
bool connection_error = false;
std::shared_ptr<std::atomic<bool>> cancel_token;
std::shared_ptr<Waiter> gathering_waiter;
std::chrono::steady_clock::time_point loading_start_time;
static void loading_timer_callback(void* data);
static int system_event_handler(void* event, void* data);
public:
std::unique_ptr<FileManager> file_manager;
VideoWindow(int x, int y, int width, int height, ConnectionInfo conn_info);
~VideoWindow() {
hide();
}
bool is_connected() const;
bool is_playing() const;
bool has_connection_error() const;
rtc::PeerConnection::IceState ice_state() const;
void show() override;
void hide() override;
void draw() override;
void flush() override;
int handle(int event) override;
void position_in_video(int x, int y, int& x_ret, int& y_ret);
unsigned int get_bitrate() const;
void set_bitrate(unsigned int bitrate);
void request_keyframe();
void release_all_keys();
};