1 /*
2  *  Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef MODULES_RTP_RTCP_SOURCE_RTCP_TRANSCEIVER_CONFIG_H_
12 #define MODULES_RTP_RTCP_SOURCE_RTCP_TRANSCEIVER_CONFIG_H_
13 
14 #include <string>
15 
16 #include "api/rtp_headers.h"
17 #include "api/task_queue/task_queue_base.h"
18 #include "api/video/video_bitrate_allocation.h"
19 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
20 #include "system_wrappers/include/ntp_time.h"
21 
22 namespace webrtc {
23 class ReceiveStatisticsProvider;
24 class Transport;
25 
26 // Interface to watch incoming rtcp packets by media (rtp) receiver.
27 class MediaReceiverRtcpObserver {
28  public:
29   virtual ~MediaReceiverRtcpObserver() = default;
30 
31   // All message handlers have default empty implementation. This way users only
32   // need to implement the ones they are interested in.
OnSenderReport(uint32_t sender_ssrc,NtpTime ntp_time,uint32_t rtp_time)33   virtual void OnSenderReport(uint32_t sender_ssrc,
34                               NtpTime ntp_time,
35                               uint32_t rtp_time) {}
OnBye(uint32_t sender_ssrc)36   virtual void OnBye(uint32_t sender_ssrc) {}
OnBitrateAllocation(uint32_t sender_ssrc,const VideoBitrateAllocation & allocation)37   virtual void OnBitrateAllocation(uint32_t sender_ssrc,
38                                    const VideoBitrateAllocation& allocation) {}
39 };
40 
41 struct RtcpTransceiverConfig {
42   RtcpTransceiverConfig();
43   RtcpTransceiverConfig(const RtcpTransceiverConfig&);
44   RtcpTransceiverConfig& operator=(const RtcpTransceiverConfig&);
45   ~RtcpTransceiverConfig();
46 
47   // Logs the error and returns false if configuration miss key objects or
48   // is inconsistant. May log warnings.
49   bool Validate() const;
50 
51   // Used to prepend all log messages. Can be empty.
52   std::string debug_id;
53 
54   // Ssrc to use as default sender ssrc, e.g. for transport-wide feedbacks.
55   uint32_t feedback_ssrc = 1;
56 
57   // Canonical End-Point Identifier of the local particiapnt.
58   // Defined in rfc3550 section 6 note 2 and section 6.5.1.
59   std::string cname;
60 
61   // Maximum packet size outgoing transport accepts.
62   size_t max_packet_size = 1200;
63 
64   // Transport to send rtcp packets to. Should be set.
65   Transport* outgoing_transport = nullptr;
66 
67   // Queue for scheduling delayed tasks, e.g. sending periodic compound packets.
68   TaskQueueBase* task_queue = nullptr;
69 
70   // Rtcp report block generator for outgoing receiver reports.
71   ReceiveStatisticsProvider* receive_statistics = nullptr;
72 
73   // Callback to pass result of rtt calculation. Should outlive RtcpTransceiver.
74   // Callbacks will be invoked on the task_queue.
75   RtcpRttStats* rtt_observer = nullptr;
76 
77   // Configures if sending should
78   //  enforce compound packets: https://tools.ietf.org/html/rfc4585#section-3.1
79   //  or allow reduced size packets: https://tools.ietf.org/html/rfc5506
80   // Receiving accepts both compound and reduced-size packets.
81   RtcpMode rtcp_mode = RtcpMode::kCompound;
82   //
83   // Tuning parameters.
84   //
85   // Initial state if |outgoing_transport| ready to accept packets.
86   bool initial_ready_to_send = true;
87   // Delay before 1st periodic compound packet.
88   int initial_report_delay_ms = 500;
89 
90   // Period between periodic compound packets.
91   int report_period_ms = 1000;
92 
93   //
94   // Flags for features and experiments.
95   //
96   bool schedule_periodic_compound_packets = true;
97   // Estimate RTT as non-sender as described in
98   // https://tools.ietf.org/html/rfc3611#section-4.4 and #section-4.5
99   bool non_sender_rtt_measurement = false;
100 
101   // Allows a REMB message to be sent immediately when SetRemb is called without
102   // having to wait for the next compount message to be sent.
103   bool send_remb_on_change = false;
104 };
105 
106 }  // namespace webrtc
107 
108 #endif  // MODULES_RTP_RTCP_SOURCE_RTCP_TRANSCEIVER_CONFIG_H_
109