summaryrefslogtreecommitdiff
path: root/modules/webrtc/PublishStream.h
diff options
context:
space:
mode:
Diffstat (limited to 'modules/webrtc/PublishStream.h')
-rw-r--r--modules/webrtc/PublishStream.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/modules/webrtc/PublishStream.h b/modules/webrtc/PublishStream.h
new file mode 100644
index 0000000..1805528
--- /dev/null
+++ b/modules/webrtc/PublishStream.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <memory>
+#include <mutex>
+#include <string>
+
+#include "Config.h"
+#include "MqttServer.h"
+#include "WebRtcRoom.h"
+#include "WebRtcStream.h"
+
+class PublishStream {
+ // TODO: Notify & get status
+ public:
+ PublishStream() = delete;
+ PublishStream(const std::string &topic, const Config &config)
+ : topic_(topic),
+ config_(config),
+ server_(std::make_shared<MqttServer>(config)),
+ room_(std::make_shared<WebRtcRoom>(config.GetRoomId())),
+ prepared_stream_(nullptr){};
+ ~PublishStream();
+
+ void Start(void);
+ void Stop(void);
+ void SetSignalingServerCallbacks(void);
+ void SetRoomCallbacks(void);
+ void SetWebRtcStreamCallbacks(WebRtcPeer &peer);
+ void PrepareStream(void);
+
+ private:
+ static void OnStreamStateChangedPrepared(WebRtcState::Stream state, PublishStream &stream);
+ static void OnOfferCreatedPrepared(std::string sdp, PublishStream &stream);
+ static void OnSignalingServerConnectionStateChanged(IfaceServer::ConnectionState state,
+ WebRtcRoom &room, MqttServer &server);
+ static void OnRoomMessageArrived(const std::string &message, WebRtcRoom &room);
+ static void OnRoomJoined(PublishStream &publish_stream);
+ static void OnPeerJoined(const std::string &peer_id, PublishStream &publish_stream);
+ static void OnPeerLeft(const std::string &peer_id, WebRtcRoom &room);
+ static void OnStreamStateChanged(WebRtcState::Stream state, WebRtcPeer &peer,
+ MqttServer &server);
+
+ static void OnSignalingStateNotify(WebRtcState::Signaling state, WebRtcPeer &peer,
+ MqttServer &server);
+ static void OnIceConnectionStateNotify(WebRtcState::IceConnection state, WebRtcPeer &peer,
+ MqttServer &server);
+
+ private:
+ std::string topic_;
+ Config config_;
+ std::shared_ptr<MqttServer> server_;
+ std::shared_ptr<WebRtcRoom> room_;
+ std::mutex prepared_stream_lock_;
+ std::shared_ptr<WebRtcStream> prepared_stream_;
+};