StreamManager refactoring
[platform/core/ml/aitt.git] / modules / webrtc / Module.h
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #pragma once
18
19 #include <AittDiscovery.h>
20 #include <AittStreamModule.h>
21
22 #include <map>
23 #include <memory>
24 #include <mutex>
25 #include <string>
26
27 #include "StreamManager.h"
28
29 using AittDiscovery = aitt::AittDiscovery;
30 using AittStreamModule = aitt::AittStreamModule;
31
32 #define MODULE_NAMESPACE AittWebRTCNamespace
33 namespace AittWebRTCNamespace {
34
35 class Module : public AittStreamModule {
36   public:
37     explicit Module(AittDiscovery &discovery, const std::string &topic, AittStreamRole role);
38     virtual ~Module(void);
39
40     void SetConfig(const std::string &key, const std::string &value) override;
41     void SetConfig(const std::string &key, void *obj) override;
42     void Start(void) override;
43     void Stop(void) override;
44     void SetStateCallback(StateCallback cb, void *user_data) override;
45     void SetReceiveCallback(ReceiveCallback cb, void *user_data) override;
46
47   private:
48     // TODO: Update Ice Candidates when stream add candidates.
49     void OnIceCandidateAdded(void);
50     void OnStreamStarted(void);
51     void OnStreamStopped(void);
52     void DiscoveryMessageCallback(const std::string &clientId, const std::string &status,
53           const void *msg, const int szmsg);
54
55     bool is_source_;
56     AittDiscovery &discovery_;
57     int discovery_cb_;
58
59     // TODO: What if user copies the module?
60     // Think about that case with destructor
61     StreamManager *stream_manager_;
62     StateCallback state_callback_;
63     void *state_cb_user_data_;
64     ReceiveCallback receive_callback_;
65     void *receive_cb_user_data_;
66 };
67 }  // namespace AittWebRTCNamespace