From d1f3a3ef40a69fe50efe6e2b76400e7f5f5dfb6c Mon Sep 17 00:00:00 2001 From: trilene Date: Tue, 27 Oct 2020 13:14:06 -0400 Subject: Support video calls --- src/WebRTCSession.h | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'src/WebRTCSession.h') diff --git a/src/WebRTCSession.h b/src/WebRTCSession.h index 83cabf5c..d5e195a8 100644 --- a/src/WebRTCSession.h +++ b/src/WebRTCSession.h @@ -4,10 +4,13 @@ #include #include +#include #include "mtx/events/voip.hpp" typedef struct _GstElement GstElement; +class QQuickItem; +class UserSettings; namespace webrtc { Q_NAMESPACE @@ -39,10 +42,13 @@ public: return instance; } - bool init(std::string *errorMessage = nullptr); + bool havePlugins(bool isVideo, std::string *errorMessage = nullptr); webrtc::State state() const { return state_; } + bool isVideo() const { return isVideo_; } + bool isOffering() const { return isOffering_; } + bool isRemoteVideoRecvOnly() const { return isRemoteVideoRecvOnly_; } - bool createOffer(); + bool createOffer(bool isVideo); bool acceptOffer(const std::string &sdp); bool acceptAnswer(const std::string &sdp); void acceptICECandidates(const std::vector &); @@ -51,11 +57,18 @@ public: bool toggleMicMute(); void end(); - void setStunServer(const std::string &stunServer) { stunServer_ = stunServer; } + void setSettings(QSharedPointer settings) { settings_ = settings; } void setTurnServers(const std::vector &uris) { turnServers_ = uris; } - std::vector getAudioSourceNames(const std::string &defaultDevice); - void setAudioSource(int audioDeviceIndex) { audioSourceIndex_ = audioDeviceIndex; } + void refreshDevices(); + std::vector getDeviceNames(bool isVideo, + const std::string &defaultDevice) const; + std::vector getResolutions(const std::string &cameraName) const; + std::vector getFrameRates(const std::string &cameraName, + const std::string &resolution) const; + + void setVideoItem(QQuickItem *item) { videoItem_ = item; } + QQuickItem *getVideoItem() const { return videoItem_; } signals: void offerCreated(const std::string &sdp, @@ -71,18 +84,24 @@ private slots: private: WebRTCSession(); - bool initialised_ = false; - webrtc::State state_ = webrtc::State::DISCONNECTED; - GstElement *pipe_ = nullptr; - GstElement *webrtc_ = nullptr; - unsigned int busWatchId_ = 0; - std::string stunServer_; + bool initialised_ = false; + bool haveVoicePlugins_ = false; + bool haveVideoPlugins_ = false; + webrtc::State state_ = webrtc::State::DISCONNECTED; + bool isVideo_ = false; + bool isOffering_ = false; + bool isRemoteVideoRecvOnly_ = false; + QQuickItem *videoItem_ = nullptr; + GstElement *pipe_ = nullptr; + GstElement *webrtc_ = nullptr; + unsigned int busWatchId_ = 0; + QSharedPointer settings_; std::vector turnServers_; - int audioSourceIndex_ = -1; - bool startPipeline(int opusPayloadType); - bool createPipeline(int opusPayloadType); - void refreshDevices(); + bool init(std::string *errorMessage = nullptr); + bool startPipeline(int opusPayloadType, int vp8PayloadType); + bool createPipeline(int opusPayloadType, int vp8PayloadType); + bool addVideoPipeline(int vp8PayloadType); void startDeviceMonitor(); public: -- cgit 1.5.1