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) |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 27 | RTC_LOG(LS_WARNING) |
Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 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()) |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 31 | RTC_LOG(LS_WARNING) << debug_id << "missing cname for ssrc " |
| 32 | << feedback_ssrc; |
Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 33 | if (cname.size() > 255) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 34 | RTC_LOG(LS_ERROR) << debug_id << "cname can be maximum 255 characters."; |
Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 35 | return false; |
| 36 | } |
| 37 | if (max_packet_size < 100) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 38 | RTC_LOG(LS_ERROR) << debug_id << "max packet size " << max_packet_size |
| 39 | << " is too small."; |
Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 40 | return false; |
| 41 | } |
| 42 | if (max_packet_size > IP_PACKET_SIZE) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 43 | RTC_LOG(LS_ERROR) << debug_id << "max packet size " << max_packet_size |
| 44 | << " more than " << IP_PACKET_SIZE << " is unsupported."; |
Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 45 | return false; |
| 46 | } |
Danil Chapovalov | 8c8d49e | 2017-10-30 15:21:41 +0100 | [diff] [blame] | 47 | if (!outgoing_transport) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 48 | RTC_LOG(LS_ERROR) << debug_id << "outgoing transport must be set"; |
Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 49 | return false; |
| 50 | } |
Danil Chapovalov | a7e418c | 2017-11-21 11:08:53 +0100 | [diff] [blame^] | 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 | } |
Danil Chapovalov | 8c8d49e | 2017-10-30 15:21:41 +0100 | [diff] [blame] | 56 | if (report_period_ms <= 0) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 57 | RTC_LOG(LS_ERROR) << debug_id << "period " << report_period_ms |
| 58 | << "ms between reports should be positive."; |
Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 59 | return false; |
| 60 | } |
Danil Chapovalov | 8c8d49e | 2017-10-30 15:21:41 +0100 | [diff] [blame] | 61 | if (schedule_periodic_compound_packets && !task_queue) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 62 | RTC_LOG(LS_ERROR) << debug_id |
| 63 | << "missing task queue for periodic compound packets"; |
Danil Chapovalov | 8c8d49e | 2017-10-30 15:21:41 +0100 | [diff] [blame] | 64 | return false; |
| 65 | } |
Danil Chapovalov | a7e418c | 2017-11-21 11:08:53 +0100 | [diff] [blame^] | 66 | if (rtcp_mode != RtcpMode::kCompound && rtcp_mode != RtcpMode::kReducedSize) { |
| 67 | RTC_LOG(LS_ERROR) << debug_id << "unsupported rtcp mode"; |
| 68 | return false; |
| 69 | } |
Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 70 | // TODO(danilchap): Remove or update the warning when RtcpTransceiver supports |
| 71 | // send-only sessions. |
| 72 | if (receive_statistics == nullptr) |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 73 | RTC_LOG(LS_WARNING) |
Danil Chapovalov | 398a7c6 | 2017-10-24 17:07:05 +0200 | [diff] [blame] | 74 | << debug_id |
| 75 | << "receive statistic should be set to generate rtcp report blocks."; |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | } // namespace webrtc |