Refactoring PayloadRouter.
- Move PayloadRouter to RtpTransportControllerInterface.
- Move RetransmissionLimiter inside RtpTransportControllerSend from
VideoSendStreamImpl.
- Move video RTP specifics into PayloadRouter, in particular ownership
of the RTP modules.
- PayloadRouter now contains all video specific RTP code, and will be
renamed in a follow-up to VideoRtpSender.
- Introduce VideoRtpSenderInterface.
Bug: webrtc:9517
Change-Id: I1c7b293fa6f9c320286c80533b3c584498034a38
Reviewed-on: https://webrtc-review.googlesource.com/88240
Commit-Queue: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24009}
diff --git a/call/payload_router.h b/call/payload_router.h
index c62bc75..cb43f27 100644
--- a/call/payload_router.h
+++ b/call/payload_router.h
@@ -12,41 +12,83 @@
#define CALL_PAYLOAD_ROUTER_H_
#include <map>
+#include <memory>
#include <vector>
+#include "api/call/transport.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/video_rtp_sender_interface.h"
#include "common_types.h" // NOLINT(build/include)
+#include "logging/rtc_event_log/rtc_event_log.h"
+#include "modules/rtp_rtcp/include/flexfec_sender.h"
#include "modules/rtp_rtcp/source/rtp_video_header.h"
+#include "modules/utility/include/process_thread.h"
#include "rtc_base/constructormagic.h"
#include "rtc_base/criticalsection.h"
+#include "rtc_base/rate_limiter.h"
#include "rtc_base/thread_annotations.h"
+#include "rtc_base/thread_checker.h"
namespace webrtc {
class RTPFragmentationHeader;
class RtpRtcp;
+class RtpTransportControllerSendInterface;
// PayloadRouter routes outgoing data to the correct sending RTP module, based
// on the simulcast layer in RTPVideoHeader.
-class PayloadRouter : public EncodedImageCallback {
+class PayloadRouter : public VideoRtpSenderInterface {
public:
// Rtp modules are assumed to be sorted in simulcast index order.
- PayloadRouter(const std::vector<RtpRtcp*>& rtp_modules,
- const std::vector<uint32_t>& ssrcs,
- int payload_type,
- const std::map<uint32_t, RtpPayloadState>& states);
+ PayloadRouter(
+ const std::vector<uint32_t>& ssrcs,
+ std::map<uint32_t, RtpState> suspended_ssrcs,
+ const std::map<uint32_t, RtpPayloadState>& states,
+ const RtpConfig& rtp_config,
+ const RtcpConfig& rtcp_config,
+ Transport* send_transport,
+ const RtpSenderObservers& observers,
+ RtpTransportControllerSendInterface* transport,
+ RtcEventLog* event_log,
+ RateLimiter* retransmission_limiter); // move inside RtpTransport
~PayloadRouter() override;
+ // RegisterProcessThread register |module_process_thread| with those objects
+ // that use it. Registration has to happen on the thread were
+ // |module_process_thread| was created (libjingle's worker thread).
+ // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue,
+ // maybe |worker_queue|.
+ void RegisterProcessThread(ProcessThread* module_process_thread) override;
+ void DeRegisterProcessThread() override;
+
// PayloadRouter will only route packets if being active, all packets will be
// dropped otherwise.
- void SetActive(bool active);
+ void SetActive(bool active) override;
// Sets the sending status of the rtp modules and appropriately sets the
// payload router to active if any rtp modules are active.
- void SetActiveModules(const std::vector<bool> active_modules);
- bool IsActive();
+ void SetActiveModules(const std::vector<bool> active_modules) override;
+ bool IsActive() override;
- std::map<uint32_t, RtpPayloadState> GetRtpPayloadStates() const;
+ void OnNetworkAvailability(bool network_available) override;
+ std::map<uint32_t, RtpState> GetRtpStates() const override;
+ std::map<uint32_t, RtpPayloadState> GetRtpPayloadStates() const override;
+
+ bool FecEnabled() const override;
+
+ bool NackEnabled() const override;
+
+ void DeliverRtcp(const uint8_t* packet, size_t length) override;
+
+ void 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) override;
+
+ void SetMaxRtpPacketSize(size_t max_rtp_packet_size) override;
// Implements EncodedImageCallback.
// Returns 0 if the packet was routed / sent, -1 otherwise.
@@ -55,17 +97,26 @@
const CodecSpecificInfo* codec_specific_info,
const RTPFragmentationHeader* fragmentation) override;
- void OnBitrateAllocationUpdated(const VideoBitrateAllocation& bitrate);
+ void OnBitrateAllocationUpdated(
+ const VideoBitrateAllocation& bitrate) override;
private:
void UpdateModuleSendingState() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ void ConfigureProtection(const RtpConfig& rtp_config);
+ void ConfigureSsrcs(const RtpConfig& rtp_config);
rtc::CriticalSection crit_;
bool active_ RTC_GUARDED_BY(crit_);
+ ProcessThread* module_process_thread_;
+ rtc::ThreadChecker module_process_thread_checker_;
+ std::map<uint32_t, RtpState> suspended_ssrcs_;
+
+ std::unique_ptr<FlexfecSender> flexfec_sender_;
// Rtp modules are assumed to be sorted in simulcast index order. Not owned.
- const std::vector<RtpRtcp*> rtp_modules_;
- const int payload_type_;
+ const std::vector<std::unique_ptr<RtpRtcp>> rtp_modules_;
+ const RtpConfig rtp_config_;
+ RtpTransportControllerSendInterface* const transport_;
std::vector<RtpPayloadParams> params_ RTC_GUARDED_BY(crit_);