Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ChannelIce.h
1
2
3#ifndef CDATACHANNELICE_H
4#define CDATACHANNELICE_H
5
6#pragma once
7
8#include "rtc/rtc.hpp"
9#include "IceSignal.h"
10#include "Channel.h"
11#include <memory>
12#include <QMutex>
13#include <QSharedPointer>
14
26class CHANNEL_EXPORT CChannelIce : public CChannel
27{
28 Q_OBJECT
29
30public:
31 explicit CChannelIce(CIceSignal* pSignal,
32 QObject *parent = nullptr);
33 virtual ~CChannelIce();
34
40 int SetConfigure(const rtc::Configuration& config);
41
52 virtual bool open(const QString& user,
53 const QString& peer,
54 bool bChannelId);
63 virtual bool open(const QString& fromUser,
64 const QString& toUser,
65 const QString& channelId,
66 const QString& type,
67 const QString& sdp);
68 virtual void close();
69
70 QString GetUser();
71 QString GetPeerUser();
72 QString GetChannelId();
73
74private Q_SLOTS:
75 virtual void slotSignalConnected();
76 virtual void slotSignalDisconnected();
77 virtual void slotSignalReceiverCandidate(const QString& fromUser,
78 const QString& toUser,
79 const QString& channelId,
80 const QString& mid,
81 const QString& sdp);
82 virtual void slotSignalError(int error, const QString& szError);
83 virtual void slotSignalReceiverDescription(const QString& fromUser,
84 const QString& toUser,
85 const QString& channelId,
86 const QString& type,
87 const QString& sdp);
88
89private:
90 CChannelIce(QObject *parent = nullptr);
91
92 virtual int SetSignal(CIceSignal* signal);
93 virtual int SetDataChannel(std::shared_ptr<rtc::DataChannel>);
94 virtual int CreateDataChannel(bool bDataChannel);
95 QString GenerateID(const QString& label = QString());
96
97 CIceSignal* m_pSignal;
98 QString m_szUser;
99 QString m_szPeerUser;
100 QString m_szChannelId;
101 rtc::Configuration m_Config;
102 std::shared_ptr<rtc::PeerConnection> m_peerConnection;
103 std::shared_ptr<rtc::DataChannel> m_dataChannel;
104
105 QByteArray m_data;
106 QMutex m_MutexData;
107 QLoggingCategory m_Log;
108
109protected:
110 bool isSequential() const;
111 qint64 writeData(const char *data, qint64 len);
112 qint64 readData(char *data, qint64 maxlen);
113};
114
115// NOTE: Don't use it!!!
116class CLibDataChannelLogCallback: public QObject
117{
118 Q_OBJECT
119public:
120 explicit CLibDataChannelLogCallback(QObject *parent = nullptr);
121
122public Q_SLOTS:
123 void slotEnable(bool enable);
124
125private:
126 static QLoggingCategory m_Log;
127 static bool m_bEnable;
128 static void logCallback(rtc::LogLevel level, std::string message);
129};
130
131extern CLibDataChannelLogCallback g_LogCallback;
132
133#endif // CDATACHANNELICE_H
The ICE channel interface class.
Definition ChannelIce.h:27
The channel interface class.
Definition Channel.h:25
virtual bool open(OpenMode mode) override
Definition Channel.cpp:78
The ICE signal interface class.
Definition IceSignal.h:26
static QLoggingCategory m_Log
Definition ChannelIce.h:126