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 #include "modules/rtp_rtcp/source/rtcp_transceiver_config.h"
12 
13 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
14 #include "rtc_base/logging.h"
15 
16 namespace webrtc {
17 
18 RtcpTransceiverConfig::RtcpTransceiverConfig() = default;
19 RtcpTransceiverConfig::RtcpTransceiverConfig(const RtcpTransceiverConfig&) =
20     default;
21 RtcpTransceiverConfig& RtcpTransceiverConfig::operator=(
22     const RtcpTransceiverConfig&) = default;
23 RtcpTransceiverConfig::~RtcpTransceiverConfig() = default;
24 
Validate() const25 bool RtcpTransceiverConfig::Validate() const {
26   if (feedback_ssrc == 0)
27     RTC_LOG(LS_WARNING)
28         << debug_id
29         << "Ssrc 0 may be treated by some implementation as invalid.";
30   if (cname.empty())
31     RTC_LOG(LS_WARNING) << debug_id << "missing cname for ssrc "
32                         << feedback_ssrc;
33   if (cname.size() > 255) {
34     RTC_LOG(LS_ERROR) << debug_id << "cname can be maximum 255 characters.";
35     return false;
36   }
37   if (max_packet_size < 100) {
38     RTC_LOG(LS_ERROR) << debug_id << "max packet size " << max_packet_size
39                       << " is too small.";
40     return false;
41   }
42   if (max_packet_size > IP_PACKET_SIZE) {
43     RTC_LOG(LS_ERROR) << debug_id << "max packet size " << max_packet_size
44                       << " more than " << IP_PACKET_SIZE << " is unsupported.";
45     return false;
46   }
47   if (!outgoing_transport) {
48     RTC_LOG(LS_ERROR) << debug_id << "outgoing transport must be set";
49     return false;
50   }
51   if (initial_report_delay_ms < 0) {
52     RTC_LOG(LS_ERROR) << debug_id << "delay " << initial_report_delay_ms
53                       << "ms before first report shouldn't be negative.";
54     return false;
55   }
56   if (report_period_ms <= 0) {
57     RTC_LOG(LS_ERROR) << debug_id << "period " << report_period_ms
58                       << "ms between reports should be positive.";
59     return false;
60   }
61   if (schedule_periodic_compound_packets && !task_queue) {
62     RTC_LOG(LS_ERROR) << debug_id
63                       << "missing task queue for periodic compound packets";
64     return false;
65   }
66   if (rtcp_mode != RtcpMode::kCompound && rtcp_mode != RtcpMode::kReducedSize) {
67     RTC_LOG(LS_ERROR) << debug_id << "unsupported rtcp mode";
68     return false;
69   }
70   // TODO(danilchap): Remove or update the warning when RtcpTransceiver supports
71   // send-only sessions.
72   if (receive_statistics == nullptr)
73     RTC_LOG(LS_WARNING)
74         << debug_id
75         << "receive statistic should be set to generate rtcp report blocks.";
76   return true;
77 }
78 
79 }  // namespace webrtc
80