From 7a206441c86cd2aa84cbbbc6be803f03b2f355ab Mon Sep 17 00:00:00 2001 From: trilene Date: Fri, 10 Jul 2020 19:19:48 -0400 Subject: Support voice calls --- src/WebRTCSession.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/WebRTCSession.h (limited to 'src/WebRTCSession.h') diff --git a/src/WebRTCSession.h b/src/WebRTCSession.h new file mode 100644 index 00000000..fffefb25 --- /dev/null +++ b/src/WebRTCSession.h @@ -0,0 +1,58 @@ +#pragma once + +#include +#include + +#include + +#include "mtx/events/voip.hpp" + +typedef struct _GstElement GstElement; + +class WebRTCSession : public QObject +{ + Q_OBJECT + +public: + static WebRTCSession& instance() + { + static WebRTCSession instance; + return instance; + } + + bool init(std::string *errorMessage = nullptr); + + bool createOffer(); + bool acceptOffer(const std::string &sdp); + bool acceptAnswer(const std::string &sdp); + void acceptICECandidates(const std::vector&); + + bool isActive() { return pipe_ != nullptr; } + bool toggleMuteAudioSrc(bool &isMuted); + void end(); + + void setStunServer(const std::string &stunServer) {stunServer_ = stunServer;} + void setTurnServers(const std::vector &uris) {turnServers_ = uris;} + +signals: + void offerCreated(const std::string &sdp, const std::vector&); + void answerCreated(const std::string &sdp, const std::vector&); + void pipelineChanged(bool started); + +private: + WebRTCSession() : QObject() {} + + bool initialised_ = false; + GstElement *pipe_ = nullptr; + GstElement *webrtc_ = nullptr; + std::string stunServer_; + std::vector turnServers_; + + bool startPipeline(int opusPayloadType); + bool createPipeline(int opusPayloadType); + void addTurnServers(); + +public: + WebRTCSession(WebRTCSession const&) = delete; + void operator=(WebRTCSession const&) = delete; +}; -- cgit 1.4.1