diff options
author | trilene <trilene@runbox.com> | 2020-07-10 19:19:48 -0400 |
---|---|---|
committer | trilene <trilene@runbox.com> | 2020-07-10 19:19:48 -0400 |
commit | 7a206441c86cd2aa84cbbbc6be803f03b2f355ab (patch) | |
tree | 1fe734ab983daa8998eb23432bd560d7dabf7866 /src/WebRTCSession.h | |
parent | Fix m.relates_to being sent as 'null' when not set in encrypted messages. (diff) | |
download | nheko-7a206441c86cd2aa84cbbbc6be803f03b2f355ab.tar.xz |
Support voice calls
Diffstat (limited to 'src/WebRTCSession.h')
-rw-r--r-- | src/WebRTCSession.h | 58 |
1 files changed, 58 insertions, 0 deletions
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 <string> +#include <vector> + +#include <QObject> + +#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<mtx::events::msg::CallCandidates::Candidate>&); + + bool isActive() { return pipe_ != nullptr; } + bool toggleMuteAudioSrc(bool &isMuted); + void end(); + + void setStunServer(const std::string &stunServer) {stunServer_ = stunServer;} + void setTurnServers(const std::vector<std::string> &uris) {turnServers_ = uris;} + +signals: + void offerCreated(const std::string &sdp, const std::vector<mtx::events::msg::CallCandidates::Candidate>&); + void answerCreated(const std::string &sdp, const std::vector<mtx::events::msg::CallCandidates::Candidate>&); + void pipelineChanged(bool started); + +private: + WebRTCSession() : QObject() {} + + bool initialised_ = false; + GstElement *pipe_ = nullptr; + GstElement *webrtc_ = nullptr; + std::string stunServer_; + std::vector<std::string> turnServers_; + + bool startPipeline(int opusPayloadType); + bool createPipeline(int opusPayloadType); + void addTurnServers(); + +public: + WebRTCSession(WebRTCSession const&) = delete; + void operator=(WebRTCSession const&) = delete; +}; |