forked from leehuitao/RemoteDesktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.h
More file actions
154 lines (138 loc) · 4.74 KB
/
interface.h
File metadata and controls
154 lines (138 loc) · 4.74 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef INTERFACE_H
#define INTERFACE_H
#include <QObject>
#include "LogModule/romote_log.h"
#include "peerconnection_manager.h"
#include "SignalServerModule/signal_server_manager.h"
#include "DisplayModule/remote_desktop.h"
class DataCallBack{
public:
DataCallBack(){}
virtual ~DataCallBack(){}
virtual void OnInitPeerConnection(){}
virtual void OnInitDesktopCapture(){}
virtual void OnInitScreentopCapture(){}
virtual void OnInitWebSocket(){}
virtual void OnDataChannel(SingalingData){}
virtual void OnRemoteImage(uint8_t * data, int w, int h) = 0;
virtual void OnLocalDesktopImage(QImage image) = 0;
virtual void OnLocalScreenImage(QImage image) = 0;
virtual void OnLocalChooseDesktopImage(int sourceid,QString title,QImage image) = 0;
virtual void OnLocalChoseScreenImage(int sourceid,QString title,QImage image) = 0;
};
class Interface : public QObject
{
Q_OBJECT
public:
static Interface* Instance(){
return interface_;
}
/**
* @brief 初始化,传入回调类,包含需要显示的视频流
*/
bool init(/*DataCallBack* callback*/);
void startRemoteDesktop();
/**
* @brief 初始化peerconnection
* @param isDesktopCapture 是否为应用截图
* @param loaclTrackSourceid 本地源id
*/
void AddLocalTrack(bool isDesktopCapture,const int loaclTrackSourceid);
void joinRoom(int roomid,int uid);
void setLoaclShared(const QString & sourceid,const QString & sourcetitle);
void captureOneImage();
void sendDataChannel(SingalingData);
void sendDataChannel(const QString & msg);
void getScreenSourceList(QMap<int,QString>& SourceMap);
/**
* @brief 初始化peerconnection
* @param turnip 中继服务器ip
* @param turnport 中继服务器端口
* @param turnusername 中继服务器账号
* @param turnpwd 中继服务器密码
* @param dtls 是否开启dtls
*/
bool initPeerConnection(const std::string& turnip ,const std::string& turnport,const std::string& turnusername ,const std::string& turnpwd,bool dtls);
/**
* @brief 初始化日志系统
* @param level 日志等级
* @param logPath 日志路径
* @param maxSizeBytes 每个日志最大字节数
* @param maxOldLogCount 存储多少个历史文件
*/
bool initLog(QsLogging::Level level = QsLogging::Level::ErrorLevel,const QString & logPath = "./",long long maxSizeBytes = 1024*512,int maxOldLogCount = 10);
/**
* @brief 初始化信号服务器连接
* @param ip 信号服务器地址
* @param port 信号服务器端口
* @param uid 当前用户id
*/
bool initWebSocket(QString ip,unsigned short port,int uid);
/**
* @brief 重置 peerconnection
*/
void clearAll();
/**
* @brief 设置需要显示的UI(使用默认构造)
*/
void setRemoteParent(QWidget* parent);
/**
* @brief 设置UI鼠标事件的回调(由外部提升后的控件设置鼠标事件通道)
*/
//void setDisplayDatachannel(RemoteDesktopDisplay * disp);
void setDisplayDatachannel(RemoteDesktopDisplay *disp);
private:
Interface() = default;
~Interface();
/**
* @brief 初始化应用截屏
*/
bool initDesktopCapture();
/**
* @brief 初始化桌面截屏
*/
bool initScreentopCapture();
Q_SIGNALS:
//图片回调,跟上面的回调对应,实现其中一个就可以
/**
* @brief 收到远程流信号
*/
void signRemoteImage(QImage);
/**
* @brief 本地应用截屏流信号
*/
void signLocalDesktopImage(QImage);
/**
* @brief 本地桌面截屏流信号
*/
void signScreenImage(QImage image);
/**
* @brief 本地应用缩略截屏流信号
* @param sourceid 流id
* @param title 流的名字
*/
void signChooseDesktopImage(int sourceid,QString title,QImage image);
/**
* @brief 本地桌面缩略截屏流信号
* @param sourceid 流id
* @param title 流的名字
*/
void signChoseScreenImage(int sourceid,QString title,QImage image);
void signOnDataChannel(SingalingData);
void signOnIceConnected();
private Q_SLOTS:
void slotRemoteImage(QImage image);
void slotLocalDesktopImage(QImage image);
void slotScreenImage(QImage image);
void slotChooseDesktopImage(int sourceid,QString title,QImage image);
void slotChoseScreenImage(int sourceid,QString title,QImage image);
void slotOnDataChannel(SingalingData);
void slotOnIceConnected();
private:
static Interface *interface_;
DataCallBack* callback_ = nullptr;
rtc::scoped_refptr<PeerconnectionManager> peerConnection = nullptr;
Q_SIGNALS:
public Q_SLOTS:
};
#endif // INTERFACE_H