#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 #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: MediaManager( rtc::Thread *thread, bool isOutgoing, std::function packetEmitted ); ~MediaManager(); void setIsConnected(bool isConnected); void receivePacket(const rtc::CopyOnWriteBuffer &packet); void notifyPacketSent(const rtc::SentPacket &sentPacket); void setIncomingVideoOutput(std::shared_ptr> sink); void setOutgoingVideoOutput(std::shared_ptr> sink); protected: std::function _packetEmitted; private: rtc::Thread *_thread; std::unique_ptr _eventLog; std::unique_ptr _taskQueueFactory; SSRC _ssrcAudio; SSRC _ssrcVideo; 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; rtc::scoped_refptr _nativeVideoSource; std::unique_ptr _videoCapturer; std::shared_ptr> _currentIncomingVideoSink; std::shared_ptr> _currentOutgoingVideoSink; std::unique_ptr _audioNetworkInterface; std::unique_ptr _videoNetworkInterface; }; #ifdef TGVOIP_NAMESPACE } #endif #endif