123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- #ifndef CALL_RTP_VIDEO_SENDER_H_
- #define CALL_RTP_VIDEO_SENDER_H_
- #include <map>
- #include <memory>
- #include <unordered_set>
- #include <vector>
- #include "absl/types/optional.h"
- #include "api/array_view.h"
- #include "api/call/transport.h"
- #include "api/fec_controller.h"
- #include "api/fec_controller_override.h"
- #include "api/rtc_event_log/rtc_event_log.h"
- #include "api/transport/field_trial_based_config.h"
- #include "api/video_codecs/video_encoder.h"
- #include "call/rtp_config.h"
- #include "call/rtp_payload_params.h"
- #include "call/rtp_transport_controller_send_interface.h"
- #include "call/rtp_video_sender_interface.h"
- #include "modules/rtp_rtcp/include/flexfec_sender.h"
- #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
- #include "modules/rtp_rtcp/source/rtp_sender.h"
- #include "modules/rtp_rtcp/source/rtp_sender_video.h"
- #include "modules/rtp_rtcp/source/rtp_sequence_number_map.h"
- #include "modules/rtp_rtcp/source/rtp_video_header.h"
- #include "modules/utility/include/process_thread.h"
- #include "rtc_base/constructor_magic.h"
- #include "rtc_base/rate_limiter.h"
- #include "rtc_base/synchronization/mutex.h"
- #include "rtc_base/thread_annotations.h"
- #include "rtc_base/thread_checker.h"
- namespace webrtc {
- class FrameEncryptorInterface;
- class RtpTransportControllerSendInterface;
- namespace webrtc_internal_rtp_video_sender {
- struct RtpStreamSender {
- RtpStreamSender(std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp,
- std::unique_ptr<RTPSenderVideo> sender_video,
- std::unique_ptr<VideoFecGenerator> fec_generator);
- ~RtpStreamSender();
- RtpStreamSender(RtpStreamSender&&) = default;
- RtpStreamSender& operator=(RtpStreamSender&&) = default;
-
- std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp;
- std::unique_ptr<RTPSenderVideo> sender_video;
- std::unique_ptr<VideoFecGenerator> fec_generator;
- };
- }
- class RtpVideoSender : public RtpVideoSenderInterface,
- public VCMProtectionCallback,
- public StreamFeedbackObserver {
- public:
-
- RtpVideoSender(
- Clock* clock,
- std::map<uint32_t, RtpState> suspended_ssrcs,
- const std::map<uint32_t, RtpPayloadState>& states,
- const RtpConfig& rtp_config,
- int rtcp_report_interval_ms,
- Transport* send_transport,
- const RtpSenderObservers& observers,
- RtpTransportControllerSendInterface* transport,
- RtcEventLog* event_log,
- RateLimiter* retransmission_limiter,
- std::unique_ptr<FecController> fec_controller,
- FrameEncryptorInterface* frame_encryptor,
- const CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer);
- ~RtpVideoSender() override;
-
-
-
-
-
- void RegisterProcessThread(ProcessThread* module_process_thread)
- RTC_LOCKS_EXCLUDED(mutex_) override;
- void DeRegisterProcessThread() RTC_LOCKS_EXCLUDED(mutex_) override;
-
-
- void SetActive(bool active) RTC_LOCKS_EXCLUDED(mutex_) override;
-
-
- void SetActiveModules(const std::vector<bool> active_modules)
- RTC_LOCKS_EXCLUDED(mutex_) override;
- bool IsActive() RTC_LOCKS_EXCLUDED(mutex_) override;
- void OnNetworkAvailability(bool network_available)
- RTC_LOCKS_EXCLUDED(mutex_) override;
- std::map<uint32_t, RtpState> GetRtpStates() const
- RTC_LOCKS_EXCLUDED(mutex_) override;
- std::map<uint32_t, RtpPayloadState> GetRtpPayloadStates() const
- RTC_LOCKS_EXCLUDED(mutex_) override;
- void DeliverRtcp(const uint8_t* packet, size_t length)
- RTC_LOCKS_EXCLUDED(mutex_) override;
-
- int ProtectionRequest(const FecProtectionParams* delta_params,
- const FecProtectionParams* key_params,
- uint32_t* sent_video_rate_bps,
- uint32_t* sent_nack_rate_bps,
- uint32_t* sent_fec_rate_bps)
- RTC_LOCKS_EXCLUDED(mutex_) override;
-
- void SetFecAllowed(bool fec_allowed) RTC_LOCKS_EXCLUDED(mutex_) override;
-
-
- EncodedImageCallback::Result OnEncodedImage(
- const EncodedImage& encoded_image,
- const CodecSpecificInfo* codec_specific_info)
- RTC_LOCKS_EXCLUDED(mutex_) override;
- void OnBitrateAllocationUpdated(const VideoBitrateAllocation& bitrate)
- RTC_LOCKS_EXCLUDED(mutex_) override;
- void OnTransportOverheadChanged(size_t transport_overhead_bytes_per_packet)
- RTC_LOCKS_EXCLUDED(mutex_) override;
- void OnBitrateUpdated(BitrateAllocationUpdate update, int framerate)
- RTC_LOCKS_EXCLUDED(mutex_) override;
- uint32_t GetPayloadBitrateBps() const RTC_LOCKS_EXCLUDED(mutex_) override;
- uint32_t GetProtectionBitrateBps() const RTC_LOCKS_EXCLUDED(mutex_) override;
- void SetEncodingData(size_t width, size_t height, size_t num_temporal_layers)
- RTC_LOCKS_EXCLUDED(mutex_) override;
- std::vector<RtpSequenceNumberMap::Info> GetSentRtpPacketInfos(
- uint32_t ssrc,
- rtc::ArrayView<const uint16_t> sequence_numbers) const
- RTC_LOCKS_EXCLUDED(mutex_) override;
-
- void OnPacketFeedbackVector(
- std::vector<StreamPacketInfo> packet_feedback_vector)
- RTC_LOCKS_EXCLUDED(mutex_) override;
- private:
- bool IsActiveLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- void SetActiveModulesLocked(const std::vector<bool> active_modules)
- RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- void UpdateModuleSendingState() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- void ConfigureProtection();
- void ConfigureSsrcs();
- void ConfigureRids();
- bool NackEnabled() const;
- uint32_t GetPacketizationOverheadRate() const;
- const FieldTrialBasedConfig field_trials_;
- const bool send_side_bwe_with_overhead_;
- const bool account_for_packetization_overhead_;
- const bool use_early_loss_detection_;
- const bool has_packet_feedback_;
- const bool use_deferred_fec_;
-
-
- mutable Mutex mutex_;
- bool active_ RTC_GUARDED_BY(mutex_);
- ProcessThread* module_process_thread_;
- rtc::ThreadChecker module_process_thread_checker_;
- std::map<uint32_t, RtpState> suspended_ssrcs_;
- const std::unique_ptr<FecController> fec_controller_;
- bool fec_allowed_ RTC_GUARDED_BY(mutex_);
-
- const std::vector<webrtc_internal_rtp_video_sender::RtpStreamSender>
- rtp_streams_;
- const RtpConfig rtp_config_;
- const absl::optional<VideoCodecType> codec_type_;
- RtpTransportControllerSendInterface* const transport_;
-
-
-
-
- int64_t shared_frame_id_ = 0;
- std::vector<RtpPayloadParams> params_ RTC_GUARDED_BY(mutex_);
- size_t transport_overhead_bytes_per_packet_ RTC_GUARDED_BY(mutex_);
- uint32_t protection_bitrate_bps_;
- uint32_t encoder_target_rate_bps_;
- std::vector<bool> loss_mask_vector_ RTC_GUARDED_BY(mutex_);
- std::vector<FrameCounts> frame_counts_ RTC_GUARDED_BY(mutex_);
- FrameCountObserver* const frame_count_observer_;
-
-
-
- std::map<uint32_t, RtpRtcpInterface*> ssrc_to_rtp_module_;
- RTC_DISALLOW_COPY_AND_ASSIGN(RtpVideoSender);
- };
- }
- #endif
|