#ifndef TGVOIP_WEBRTC_MEDIA_MANAGER_H #define TGVOIP_WEBRTC_MEDIA_MANAGER_H #include "rtc_base/thread.h" #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "api/transport/field_trial_based_config.h" #include "pc/rtp_sender.h" #include "TgVoip.h" #include #include namespace webrtc { class Call; class RtcEventLogNull; class TaskQueueFactory; class VideoBitrateAllocatorFactory; class VideoTrackSourceInterface; }; namespace cricket { class MediaEngineInterface; class VoiceMediaChannel; class VideoMediaChannel; }; #ifdef TGVOIP_NAMESPACE namespace TGVOIP_NAMESPACE { #endif class VideoCapturerInterface; class MediaManager : public sigslot::has_slots<>, public std::enable_shared_from_this { private: struct SSRC { uint32_t incoming; uint32_t outgoing; uint32_t fecIncoming; uint32_t fecOutgoing; }; class NetworkInterfaceImpl : public cricket::MediaChannel::NetworkInterface { public: NetworkInterfaceImpl(MediaManager *mediaManager, bool isVideo); bool SendPacket(rtc::CopyOnWriteBuffer *packet, const rtc::PacketOptions& options) override; bool SendRtcp(rtc::CopyOnWriteBuffer *packet, const rtc::PacketOptions& options) override; int SetOption(SocketType type, rtc::Socket::Option opt, int option) override; private: MediaManager *_mediaManager; bool _isVideo; }; friend class MediaManager::NetworkInterfaceImpl; public: static rtc::Thread *getWorkerThread(); MediaManager( rtc::Thread *thread, bool isOutgoing, std::shared_ptr videoCapture, std::function packetEmitted, std::function localVideoCaptureActiveUpdated ); ~MediaManager(); void setIsConnected(bool isConnected); void receivePacket(const rtc::CopyOnWriteBuffer &packet); void notifyPacketSent(const rtc::SentPacket &sentPacket); void setSendVideo(std::shared_ptr videoCapture); void setMuteOutgoingAudio(bool mute); void setIncomingVideoOutput(std::shared_ptr> sink); protected: std::function _packetEmitted; std::function _localVideoCaptureActiveUpdated; private: rtc::Thread *_thread; std::unique_ptr _eventLog; std::unique_ptr _taskQueueFactory; SSRC _ssrcAudio; SSRC _ssrcVideo; bool _enableFlexfec; bool _isConnected; bool _muteOutgoingAudio; std::vector _videoCodecs; bool _isSendingVideo; std::unique_ptr _mediaEngine; std::unique_ptr _call; webrtc::FieldTrialBasedConfig _fieldTrials; webrtc::LocalAudioSinkAdapter _audioSource; std::unique_ptr _audioChannel; std::unique_ptr _videoChannel; std::unique_ptr _videoBitrateAllocatorFactory; std::shared_ptr _videoCapture; std::shared_ptr> _currentIncomingVideoSink; std::unique_ptr _audioNetworkInterface; std::unique_ptr _videoNetworkInterface; }; #ifdef TGVOIP_NAMESPACE } #endif #endif