blob: 9256d2474e155fa43660747959640cd328e2e8c8 [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 Chapovalov8c8d49e2017-10-30 15:21:41 +010051 if (report_period_ms <= 0) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010052 RTC_LOG(LS_ERROR) << debug_id << "period " << report_period_ms
53 << "ms between reports should be positive.";
Danil Chapovalov398a7c62017-10-24 17:07:05 +020054 return false;
55 }
Danil Chapovalov8c8d49e2017-10-30 15:21:41 +010056 if (schedule_periodic_compound_packets && !task_queue) {
Mirko Bonadei675513b2017-11-09 11:09:25 +010057 RTC_LOG(LS_ERROR) << debug_id
58 << "missing task queue for periodic compound packets";
Danil Chapovalov8c8d49e2017-10-30 15:21:41 +010059 return false;
60 }
Danil Chapovalov398a7c62017-10-24 17:07:05 +020061 // TODO(danilchap): Remove or update the warning when RtcpTransceiver supports
62 // send-only sessions.
63 if (receive_statistics == nullptr)
Mirko Bonadei675513b2017-11-09 11:09:25 +010064 RTC_LOG(LS_WARNING)
Danil Chapovalov398a7c62017-10-24 17:07:05 +020065 << debug_id
66 << "receive statistic should be set to generate rtcp report blocks.";
67 return true;
68}
69
70} // namespace webrtc