#ifndef TGCALLS_GROUP_INSTANCE_IMPL_H #define TGCALLS_GROUP_INSTANCE_IMPL_H #include #include #include #include #include #include "../Instance.h" #include "../StaticThreads.h" #include "GroupJoinPayload.h" namespace webrtc { class AudioDeviceModule; class TaskQueueFactory; class VideoTrackSourceInterface; } namespace rtc { template class scoped_refptr; } namespace tgcalls { class LogSinkImpl; class GroupInstanceManager; struct AudioFrame; struct GroupConfig { bool need_log{true}; FilePath logPath; }; struct GroupLevelValue { float level = 0.; bool voice = false; bool isMuted = false; }; struct GroupLevelUpdate { uint32_t ssrc = 0; GroupLevelValue value; }; struct GroupLevelsUpdate { std::vector updates; }; class BroadcastPartTask { public: virtual ~BroadcastPartTask() = default; virtual void cancel() = 0; }; struct BroadcastPart { enum class Status { Success, NotReady, ResyncNeeded }; int64_t timestampMilliseconds = 0; double responseTimestamp = 0; Status status = Status::NotReady; std::vector oggData; }; enum class GroupConnectionMode { GroupConnectionModeNone, GroupConnectionModeRtc, GroupConnectionModeBroadcast }; struct GroupNetworkState { bool isConnected = false; bool isTransitioningFromBroadcastToRtc = false; }; enum class VideoContentType { None, Screencast, Generic }; enum class VideoCodecName { VP8, VP9 }; class RequestMediaChannelDescriptionTask { public: virtual ~RequestMediaChannelDescriptionTask() = default; virtual void cancel() = 0; }; struct MediaChannelDescription { enum class Type { Audio, Video }; Type type = Type::Audio; uint32_t audioSsrc = 0; std::string videoInformation; }; struct MediaSsrcGroup { std::string semantics; std::vector ssrcs; }; struct VideoChannelDescription { enum class Quality { Thumbnail, Medium, Full }; uint32_t audioSsrc = 0; std::string endpointId; std::vector ssrcGroups; Quality minQuality = Quality::Thumbnail; Quality maxQuality = Quality::Thumbnail; }; struct GroupInstanceDescriptor { std::shared_ptr threads; GroupConfig config; std::function networkStateUpdated; std::function audioLevelsUpdated; std::function onAudioFrame; std::string initialInputDeviceId; std::string initialOutputDeviceId; bool useDummyChannel{true}; bool disableIncomingChannels{false}; std::function(webrtc::TaskQueueFactory*)> createAudioDeviceModule; std::shared_ptr videoCapture; // deprecated std::function getVideoSource; std::function(std::shared_ptr, int64_t, int64_t, std::function)> requestBroadcastPart; int outgoingAudioBitrateKbit{32}; bool disableOutgoingAudioProcessing{false}; VideoContentType videoContentType{VideoContentType::None}; bool initialEnableNoiseSuppression{false}; std::vector videoCodecPreferences; std::function(std::vector const &, std::function &&)>)> requestMediaChannelDescriptions; int minOutgoingVideoBitrateKbit{100}; std::shared_ptr platformContext; }; template class ThreadLocalObject; class GroupInstanceInterface { protected: GroupInstanceInterface() = default; public: virtual ~GroupInstanceInterface() = default; virtual void stop() = 0; virtual void setConnectionMode(GroupConnectionMode connectionMode, bool keepBroadcastIfWasEnabled) = 0; virtual void emitJoinPayload(std::function completion) = 0; virtual void setJoinResponsePayload(std::string const &payload) = 0; virtual void removeSsrcs(std::vector ssrcs) = 0; virtual void removeIncomingVideoSource(uint32_t ssrc) = 0; virtual void setIsMuted(bool isMuted) = 0; virtual void setIsNoiseSuppressionEnabled(bool isNoiseSuppressionEnabled) = 0; virtual void setVideoCapture(std::shared_ptr videoCapture) = 0; virtual void setVideoSource(std::function getVideoSource) = 0; virtual void setAudioOutputDevice(std::string id) = 0; virtual void setAudioInputDevice(std::string id) = 0; virtual void addIncomingVideoOutput(std::string const &endpointId, std::weak_ptr> sink) = 0; virtual void setVolume(uint32_t ssrc, double volume) = 0; virtual void setRequestedVideoChannels(std::vector &&requestedVideoChannels) = 0; struct AudioDevice { enum class Type {Input, Output}; std::string name; std::string guid; }; static std::vector getAudioDevices(AudioDevice::Type type); }; } // namespace tgcalls #endif