| #include <vector> |
| 6 | #include <string> |
| 7 | #include <memory> |
| 8 | #include <map> |
| 9 |
| 10 | #include "../Instance.h" |
| 11 |
| 12 | namespace webrtc { |
| 13 | class AudioDeviceModule; |
| 14 | class TaskQueueFactory; |
| 15 | } |
| 16 |
| 17 | namespace tgcalls { |
| 18 |
| 19 | class LogSinkImpl; |
| 20 | class GroupInstanceManager; |
| 21 |
| 22 | struct GroupConfig { |
| 23 | FilePath logPath; |
| 24 | }; |
| 25 |
| 26 | struct GroupLevelValue { |
| 27 | float level = 0.; |
| 28 | bool voice = false; |
| 29 | }; |
| 30 |
| 31 | struct GroupLevelUpdate { |
| 32 | uint32_t ssrc = 0; |
| 33 | GroupLevelValue value; |
| 34 | }; |
| 35 |
| 36 | struct GroupLevelsUpdate { |
| 37 | std::vector<GroupLevelUpdate> updates; |
| 38 | }; |
| 39 |
| 40 | struct GroupInstanceDescriptor { |
| 41 | GroupConfig config; |
| 42 | std::function<void(bool)> networkStateUpdated; |
| 43 | std::function<void(GroupLevelsUpdate const &)> audioLevelsUpdated; |
| 44 | std::string initialInputDeviceId; |
| 45 | std::string initialOutputDeviceId; |
| 46 | bool debugIgnoreMissingSsrcs = false; |
| 47 | std::shared_ptr<PlatformContext> platformContext; |
| 48 | }; |
| 49 |
| 50 | struct GroupJoinPayloadFingerprint { |
| 51 | std::string hash; |
| 52 | std::string setup; |
| 53 | std::string fingerprint; |
| 54 | }; |
| 55 |
| 56 | struct GroupJoinPayload { |
| 57 | std::string ufrag; |
| 58 | std::string pwd; |
| 59 | std::vector<GroupJoinPayloadFingerprint> fingerprints; |
| 60 |
| 61 | uint32_t ssrc = 0; |
| 62 | }; |
| 63 |
| 64 | struct GroupJoinResponseCandidate { |
| 65 | std::string port; |
| 66 | std::string protocol; |
| 67 | std::string network; |
| 68 | std::string generation; |
| 69 | std::string id; |
| 70 | std::string component; |
| 71 | std::string foundation; |
| 72 | std::string priority; |
| 73 | std::string ip; |
| 74 | std::string type; |
| 75 |
| 76 | std::string tcpType; |
| 77 | std::string relAddr; |
| 78 | std::string relPort; |
| 79 | }; |
| 80 |
| 81 | struct GroupJoinResponsePayload { |
| 82 | std::string ufrag; |
| 83 | std::string pwd; |
| 84 | std::vector<GroupJoinPayloadFingerprint> fingerprints; |
| 85 | std::vector<GroupJoinResponseCandidate> candidates; |
| 86 | }; |
| 87 |
| 88 | template <typename T> |
| 89 | class ThreadLocalObject; |
| 90 |
| 91 | class GroupInstanceImpl final { |
| 92 | public: |
| 93 | explicit GroupInstanceImpl(GroupInstanceDescriptor &&descriptor); |
| 94 | ~GroupInstanceImpl(); |
| 95 |
| 96 | void stop(); |
| 97 |
| 98 | void emitJoinPayload(std::function<void(GroupJoinPayload)> completion); |
| 99 | void setJoinResponsePayload(GroupJoinResponsePayload payload); |
| 100 | void removeSsrcs(std::vector<uint32_t> ssrcs); |
| 101 |
| 102 | void setIsMuted(bool isMuted); |
| 103 | void setAudioOutputDevice(std::string id); |
| 104 | void setAudioInputDevice(std::string id); |
| 105 |
| 106 | struct AudioDevice { |
| 107 | enum class Type {Input, Output}; |
| 108 | std::string name; |
| 109 | std::string guid; |
| 110 | }; |
| 111 | static std::vector<AudioDevice> getAudioDevices(AudioDevice::Type type); |
| 112 | private: |
| 113 | std::unique_ptr<ThreadLocalObject<GroupInstanceManager>> _manager; |
| 114 | std::unique_ptr<LogSinkImpl> _logSink; |
| 115 |
| 116 | }; |
| 117 |
| 118 | } // namespace tgcalls |
| 119 |
| 120 | #endif |
| 121 |