2 * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "StreamManager.h"
19 #include "aitt_internal.h"
21 namespace AittWebRTCNamespace {
23 StreamManager::StreamManager(const std::string &topic, const std::string &watching_topic,
24 const std::string &aitt_id, const std::string &thread_id)
25 : topic_(topic), watching_topic_(watching_topic), aitt_id_(aitt_id), thread_id_(thread_id)
29 void StreamManager::Start(void)
31 DBG("%s %s", __func__, GetTopic().c_str());
36 void StreamManager::Stop(void)
38 DBG("%s %s", __func__, GetTopic().c_str());
39 // TODO: You should take care about stream resource
40 for (auto itr = streams_.begin(); itr != streams_.end(); ++itr)
41 itr->second->Destroy();
48 void StreamManager::HandleRemovedClient(const std::string &discovery_id)
50 auto stream_itr = streams_.find(discovery_id);
51 if (stream_itr == streams_.end()) {
52 DBG("There's no stream %s", discovery_id.c_str());
56 // TODO: You should take care about stream resource
57 stream_itr->second->Destroy();
58 streams_.erase(stream_itr);
63 void StreamManager::HandleMsg(const std::string &discovery_id, const std::vector<uint8_t> &message)
65 if (flexbuffers::GetRoot(message).IsString())
66 HandleStreamState(discovery_id, message);
67 else if (flexbuffers::GetRoot(message).IsVector())
68 HandleStreamInfo(discovery_id, message);
71 std::string StreamManager::GetTopic(void) const
76 std::string StreamManager::GetWatchingTopic(void) const
78 return watching_topic_;
81 void StreamManager::SetIceCandidateAddedCallback(IceCandidateAddedCallback cb)
83 ice_candidate_added_cb_ = cb;
86 void StreamManager::SetStreamStartCallback(StreamStartCallback cb)
88 stream_start_cb_ = cb;
91 void StreamManager::SetStreamStopCallback(StreamStopCallback cb)
96 } // namespace AittWebRTCNamespace