blob: d6313ae1cd2085ce9163931e492bc48fe17c6e10 [file] [log] [blame]
Danil Chapovalov398a7c62017-10-24 17:07:05 +02001/*
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
16namespace webrtc {
17
18RtcpTransceiverConfig::RtcpTransceiverConfig() = default;
19RtcpTransceiverConfig::RtcpTransceiverConfig(const RtcpTransceiverConfig&) =
20 default;
21RtcpTransceiverConfig& RtcpTransceiverConfig::operator=(
22 const RtcpTransceiverConfig&) = default;
23RtcpTransceiverConfig::~RtcpTransceiverConfig() = default;
24
25bool RtcpTransceiverConfig::Validate() const {
26 if (feedback_ssrc == 0)
Mirko Bonadei675513b2017-11-09 11:09:25 +010027 RTC_LOG(LS_WARNING)
Danil Chapovalov398a7c62017-10-24 17:07:05 +020028 << debug_id
29 << "Ssrc 0 may be treated by some implementation as invalid.";
Danil Chapovalov78161ca2017-10-26 12:09:41 +020030 if (cname.empty())
Mirko Bonadei675513b2017-11-09 11:09:25 +010031 RTC_LOG(LS_WARNING) << debug_id << "missing cname for ssrc "
32 << feedback_ssrc;
Danil Chapovalov398a7c62017-10-24 17:07:05 +020033 if (cname.size() > 255) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010034 RTC_LOG(LS_ERROR) << debug_id << "cname can be maximum 255 characters.";
Danil Chapovalov398a7c62017-10-24 17:07:05 +020035 return false;
36 }
37 if (max_packet_size < 100) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010038 RTC_LOG(LS_ERROR) << debug_id << "max packet size " << max_packet_size
39 << " is too small.";
Danil Chapovalov398a7c62017-10-24 17:07:05 +020040 return false;
41 }
42 if (max_packet_size > IP_PACKET_SIZE) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010043 RTC_LOG(LS_ERROR) << debug_id << "max packet size " << max_packet_size
44 << " more than " << IP_PACKET_SIZE << " is unsupported.";
Danil Chapovalov398a7c62017-10-24 17:07:05 +020045 return false;
46 }
Danil Chapovalov8c8d49e2017-10-30 15:21:41 +010047 if (!outgoing_transport) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010048 RTC_LOG(LS_ERROR) << debug_id << "outgoing transport must be set";
Danil Chapovalov398a7c62017-10-24 17:07:05 +020049 return false;
50 }
Danil Chapovalova7e418c2017-11-21 11:08:53 +010051 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 }
Danil Chapovalov8c8d49e2017-10-30 15:21:41 +010056 if (report_period_ms <= 0) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010057 RTC_LOG(LS_ERROR) << debug_id << "period " << report_period_ms
58 << "ms between reports should be positive.";
Danil Chapovalov398a7c62017-10-24 17:07:05 +020059 return false;
60 }
Danil Chapovalov8c8d49e2017-10-30 15:21:41 +010061 if (schedule_periodic_compound_packets && !task_queue) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010062 RTC_LOG(LS_ERROR) << debug_id
63 << "missing task queue for periodic compound packets";
Danil Chapovalov8c8d49e2017-10-30 15:21:41 +010064 return false;
65 }
Danil Chapovalova7e418c2017-11-21 11:08:53 +010066 if (rtcp_mode != RtcpMode::kCompound && rtcp_mode != RtcpMode::kReducedSize) {
67 RTC_LOG(LS_ERROR) << debug_id << "unsupported rtcp mode";
68 return false;
69 }
Danil Chapovalov398a7c62017-10-24 17:07:05 +020070 // TODO(danilchap): Remove or update the warning when RtcpTransceiver supports
71 // send-only sessions.
72 if (receive_statistics == nullptr)
Mirko Bonadei675513b2017-11-09 11:09:25 +010073 RTC_LOG(LS_WARNING)
Danil Chapovalov398a7c62017-10-24 17:07:05 +020074 << debug_id
75 << "receive statistic should be set to generate rtcp report blocks.";
76 return true;
77}
78
79} // namespace webrtc