| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 nack_list(nack_list), | 87 nack_list(nack_list), |
| 88 repeat(repeat), | 88 repeat(repeat), |
| 89 picture_id(picture_id), | 89 picture_id(picture_id), |
| 90 buffer(buffer), | 90 buffer(buffer), |
| 91 buffer_size(buffer_size), | 91 buffer_size(buffer_size), |
| 92 ntp_sec(0), | 92 ntp_sec(0), |
| 93 ntp_frac(0), | 93 ntp_frac(0), |
| 94 position(0) {} | 94 position(0) {} |
| 95 | 95 |
| 96 uint8_t* AllocateData(uint32_t bytes) { | 96 uint8_t* AllocateData(uint32_t bytes) { |
| 97 DCHECK_LE(position + bytes, buffer_size); | 97 RTC_DCHECK_LE(position + bytes, buffer_size); |
| 98 uint8_t* ptr = &buffer[position]; | 98 uint8_t* ptr = &buffer[position]; |
| 99 position += bytes; | 99 position += bytes; |
| 100 return ptr; | 100 return ptr; |
| 101 } | 101 } |
| 102 | 102 |
| 103 const FeedbackState& feedback_state; | 103 const FeedbackState& feedback_state; |
| 104 int32_t nack_size; | 104 int32_t nack_size; |
| 105 const uint16_t* nack_list; | 105 const uint16_t* nack_list; |
| 106 bool repeat; | 106 bool repeat; |
| 107 uint64_t picture_id; | 107 uint64_t picture_id; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 312 |
| 313 void RTCPSender::SetRemoteSSRC(uint32_t ssrc) { | 313 void RTCPSender::SetRemoteSSRC(uint32_t ssrc) { |
| 314 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); | 314 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); |
| 315 remote_ssrc_ = ssrc; | 315 remote_ssrc_ = ssrc; |
| 316 } | 316 } |
| 317 | 317 |
| 318 int32_t RTCPSender::SetCNAME(const char* c_name) { | 318 int32_t RTCPSender::SetCNAME(const char* c_name) { |
| 319 if (!c_name) | 319 if (!c_name) |
| 320 return -1; | 320 return -1; |
| 321 | 321 |
| 322 DCHECK_LT(strlen(c_name), static_cast<size_t>(RTCP_CNAME_SIZE)); | 322 RTC_DCHECK_LT(strlen(c_name), static_cast<size_t>(RTCP_CNAME_SIZE)); |
| 323 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); | 323 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); |
| 324 cname_ = c_name; | 324 cname_ = c_name; |
| 325 return 0; | 325 return 0; |
| 326 } | 326 } |
| 327 | 327 |
| 328 int32_t RTCPSender::AddMixedCNAME(uint32_t SSRC, const char* c_name) { | 328 int32_t RTCPSender::AddMixedCNAME(uint32_t SSRC, const char* c_name) { |
| 329 assert(c_name); | 329 assert(c_name); |
| 330 DCHECK_LT(strlen(c_name), static_cast<size_t>(RTCP_CNAME_SIZE)); | 330 RTC_DCHECK_LT(strlen(c_name), static_cast<size_t>(RTCP_CNAME_SIZE)); |
| 331 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); | 331 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); |
| 332 if (csrc_cnames_.size() >= kRtpCsrcSize) | 332 if (csrc_cnames_.size() >= kRtpCsrcSize) |
| 333 return -1; | 333 return -1; |
| 334 | 334 |
| 335 csrc_cnames_[SSRC] = c_name; | 335 csrc_cnames_[SSRC] = c_name; |
| 336 return 0; | 336 return 0; |
| 337 } | 337 } |
| 338 | 338 |
| 339 int32_t RTCPSender::RemoveMixedCNAME(uint32_t SSRC) { | 339 int32_t RTCPSender::RemoveMixedCNAME(uint32_t SSRC) { |
| 340 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); | 340 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 PacketBuiltCallback callback(ctx); | 509 PacketBuiltCallback callback(ctx); |
| 510 if (!callback.BuildPacket(report)) | 510 if (!callback.BuildPacket(report)) |
| 511 return BuildResult::kTruncated; | 511 return BuildResult::kTruncated; |
| 512 | 512 |
| 513 report_blocks_.clear(); | 513 report_blocks_.clear(); |
| 514 return BuildResult::kSuccess; | 514 return BuildResult::kSuccess; |
| 515 } | 515 } |
| 516 | 516 |
| 517 RTCPSender::BuildResult RTCPSender::BuildSDES(RtcpContext* ctx) { | 517 RTCPSender::BuildResult RTCPSender::BuildSDES(RtcpContext* ctx) { |
| 518 size_t length_cname = cname_.length(); | 518 size_t length_cname = cname_.length(); |
| 519 CHECK_LT(length_cname, static_cast<size_t>(RTCP_CNAME_SIZE)); | 519 RTC_CHECK_LT(length_cname, static_cast<size_t>(RTCP_CNAME_SIZE)); |
| 520 | 520 |
| 521 rtcp::Sdes sdes; | 521 rtcp::Sdes sdes; |
| 522 sdes.WithCName(ssrc_, cname_); | 522 sdes.WithCName(ssrc_, cname_); |
| 523 | 523 |
| 524 for (const auto it : csrc_cnames_) | 524 for (const auto it : csrc_cnames_) |
| 525 sdes.WithCName(it.first, it.second); | 525 sdes.WithCName(it.first, it.second); |
| 526 | 526 |
| 527 PacketBuiltCallback callback(ctx); | 527 PacketBuiltCallback callback(ctx); |
| 528 if (!callback.BuildPacket(sdes)) | 528 if (!callback.BuildPacket(sdes)) |
| 529 return BuildResult::kTruncated; | 529 return BuildResult::kTruncated; |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 // and all new volatile flags added will be consumed by the end of this call. | 975 // and all new volatile flags added will be consumed by the end of this call. |
| 976 SetFlags(packetTypes, true); | 976 SetFlags(packetTypes, true); |
| 977 | 977 |
| 978 if (packet_type_counter_.first_packet_time_ms == -1) | 978 if (packet_type_counter_.first_packet_time_ms == -1) |
| 979 packet_type_counter_.first_packet_time_ms = clock_->TimeInMilliseconds(); | 979 packet_type_counter_.first_packet_time_ms = clock_->TimeInMilliseconds(); |
| 980 | 980 |
| 981 bool generate_report; | 981 bool generate_report; |
| 982 if (IsFlagPresent(kRtcpSr) || IsFlagPresent(kRtcpRr)) { | 982 if (IsFlagPresent(kRtcpSr) || IsFlagPresent(kRtcpRr)) { |
| 983 // Report type already explicitly set, don't automatically populate. | 983 // Report type already explicitly set, don't automatically populate. |
| 984 generate_report = true; | 984 generate_report = true; |
| 985 DCHECK(ConsumeFlag(kRtcpReport) == false); | 985 RTC_DCHECK(ConsumeFlag(kRtcpReport) == false); |
| 986 } else { | 986 } else { |
| 987 generate_report = | 987 generate_report = |
| 988 (ConsumeFlag(kRtcpReport) && method_ == kRtcpNonCompound) || | 988 (ConsumeFlag(kRtcpReport) && method_ == kRtcpNonCompound) || |
| 989 method_ == kRtcpCompound; | 989 method_ == kRtcpCompound; |
| 990 if (generate_report) | 990 if (generate_report) |
| 991 SetFlag(sending_ ? kRtcpSr : kRtcpRr, true); | 991 SetFlag(sending_ ? kRtcpSr : kRtcpRr, true); |
| 992 } | 992 } |
| 993 | 993 |
| 994 if (IsFlagPresent(kRtcpSr) || (IsFlagPresent(kRtcpRr) && !cname_.empty())) | 994 if (IsFlagPresent(kRtcpSr) || (IsFlagPresent(kRtcpRr) && !cname_.empty())) |
| 995 SetFlag(kRtcpSdes, true); | 995 SetFlag(kRtcpSdes, true); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 &report_block)) { | 1034 &report_block)) { |
| 1035 AddReportBlock(report_block); | 1035 AddReportBlock(report_block); |
| 1036 } | 1036 } |
| 1037 } | 1037 } |
| 1038 } | 1038 } |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 auto it = report_flags_.begin(); | 1041 auto it = report_flags_.begin(); |
| 1042 while (it != report_flags_.end()) { | 1042 while (it != report_flags_.end()) { |
| 1043 auto builder = builders_.find(it->type); | 1043 auto builder = builders_.find(it->type); |
| 1044 DCHECK(builder != builders_.end()); | 1044 RTC_DCHECK(builder != builders_.end()); |
| 1045 if (it->is_volatile) { | 1045 if (it->is_volatile) { |
| 1046 report_flags_.erase(it++); | 1046 report_flags_.erase(it++); |
| 1047 } else { | 1047 } else { |
| 1048 ++it; | 1048 ++it; |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 uint32_t start_position = context.position; | 1051 uint32_t start_position = context.position; |
| 1052 BuildResult result = (this->*(builder->second))(&context); | 1052 BuildResult result = (this->*(builder->second))(&context); |
| 1053 switch (result) { | 1053 switch (result) { |
| 1054 case BuildResult::kError: | 1054 case BuildResult::kError: |
| 1055 return -1; | 1055 return -1; |
| 1056 case BuildResult::kTruncated: | 1056 case BuildResult::kTruncated: |
| 1057 return context.position; | 1057 return context.position; |
| 1058 case BuildResult::kAborted: | 1058 case BuildResult::kAborted: |
| 1059 context.position = start_position; | 1059 context.position = start_position; |
| 1060 FALLTHROUGH(); | 1060 FALLTHROUGH(); |
| 1061 case BuildResult::kSuccess: | 1061 case BuildResult::kSuccess: |
| 1062 continue; | 1062 continue; |
| 1063 default: | 1063 default: |
| 1064 abort(); | 1064 abort(); |
| 1065 } | 1065 } |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 if (packet_type_counter_observer_ != NULL) { | 1068 if (packet_type_counter_observer_ != NULL) { |
| 1069 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated( | 1069 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated( |
| 1070 remote_ssrc_, packet_type_counter_); | 1070 remote_ssrc_, packet_type_counter_); |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 DCHECK(AllVolatileFlagsConsumed()); | 1073 RTC_DCHECK(AllVolatileFlagsConsumed()); |
| 1074 | 1074 |
| 1075 return context.position; | 1075 return context.position; |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 bool RTCPSender::PrepareReport(const FeedbackState& feedback_state, | 1078 bool RTCPSender::PrepareReport(const FeedbackState& feedback_state, |
| 1079 uint32_t ssrc, | 1079 uint32_t ssrc, |
| 1080 StreamStatistician* statistician, | 1080 StreamStatistician* statistician, |
| 1081 RTCPReportBlock* report_block) { | 1081 RTCPReportBlock* report_block) { |
| 1082 // Do we have receive statistics to send? | 1082 // Do we have receive statistics to send? |
| 1083 RtcpStatistics stats; | 1083 RtcpStatistics stats; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 int32_t id_; | 1230 int32_t id_; |
| 1231 bool send_failure_; | 1231 bool send_failure_; |
| 1232 } sender(cbTransport_, id_); | 1232 } sender(cbTransport_, id_); |
| 1233 | 1233 |
| 1234 uint8_t buffer[IP_PACKET_SIZE]; | 1234 uint8_t buffer[IP_PACKET_SIZE]; |
| 1235 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && | 1235 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && |
| 1236 !sender.send_failure_; | 1236 !sender.send_failure_; |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 } // namespace webrtc | 1239 } // namespace webrtc |
| OLD | NEW |