Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 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 | |
| 25 | bool RtcpTransceiverConfig::Validate() const { |
| 26 | if (feedback_ssrc == 0) |
| 27 | LOG(LS_WARNING) |
| 28 | << debug_id |
| 29 | << "Ssrc 0 may be treated by some implementation as invalid."; |
Danil Chapovalov | 78161ca | 2017-10-26 12:09:41 +0200 | [diff] [blame] | 30 | if (cname.empty()) |
| 31 | LOG(LS_WARNING) << debug_id << "missing cname for ssrc " << feedback_ssrc; |
Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 32 | if (cname.size() > 255) { |
| 33 | LOG(LS_ERROR) << debug_id << "cname can be maximum 255 characters."; |
| 34 | return false; |
| 35 | } |
| 36 | if (max_packet_size < 100) { |
| 37 | LOG(LS_ERROR) << debug_id << "max packet size " << max_packet_size |
| 38 | << " is too small."; |
| 39 | return false; |
| 40 | } |
| 41 | if (max_packet_size > IP_PACKET_SIZE) { |
| 42 | LOG(LS_ERROR) << debug_id << "max packet size " << max_packet_size |
| 43 | << " more than " << IP_PACKET_SIZE << " is unsupported."; |
| 44 | return false; |
| 45 | } |
| 46 | if (outgoing_transport == nullptr) { |
| 47 | LOG(LS_ERROR) << debug_id << "outgoing transport must be set"; |
| 48 | return false; |
| 49 | } |
| 50 | if (min_periodic_report_ms <= 0) { |
| 51 | LOG(LS_ERROR) << debug_id << "period " << min_periodic_report_ms |
| 52 | << "ms between reports should be positive."; |
| 53 | return false; |
| 54 | } |
| 55 | // TODO(danilchap): Remove or update the warning when RtcpTransceiver supports |
| 56 | // send-only sessions. |
| 57 | if (receive_statistics == nullptr) |
| 58 | LOG(LS_WARNING) |
| 59 | << debug_id |
| 60 | << "receive statistic should be set to generate rtcp report blocks."; |
| 61 | return true; |
| 62 | } |
| 63 | |
| 64 | } // namespace webrtc |