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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE); | 320 RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE); |
321 rtc::CritScope lock(&critical_section_rtcp_sender_); | 321 rtc::CritScope lock(&critical_section_rtcp_sender_); |
322 cname_ = c_name; | 322 cname_ = c_name; |
323 return 0; | 323 return 0; |
324 } | 324 } |
325 | 325 |
326 int32_t RTCPSender::AddMixedCNAME(uint32_t SSRC, const char* c_name) { | 326 int32_t RTCPSender::AddMixedCNAME(uint32_t SSRC, const char* c_name) { |
327 RTC_DCHECK(c_name); | 327 RTC_DCHECK(c_name); |
328 RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE); | 328 RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE); |
329 rtc::CritScope lock(&critical_section_rtcp_sender_); | 329 rtc::CritScope lock(&critical_section_rtcp_sender_); |
330 if (csrc_cnames_.size() >= kRtpCsrcSize) | 330 // One spot is reserved for ssrc_/cname_. |
| 331 // TODO(danilchap): Add support for more than 30 contributes by sending |
| 332 // several sdes packets. |
| 333 if (csrc_cnames_.size() >= rtcp::Sdes::kMaxNumberOfChunks - 1) |
331 return -1; | 334 return -1; |
332 | 335 |
333 csrc_cnames_[SSRC] = c_name; | 336 csrc_cnames_[SSRC] = c_name; |
334 return 0; | 337 return 0; |
335 } | 338 } |
336 | 339 |
337 int32_t RTCPSender::RemoveMixedCNAME(uint32_t SSRC) { | 340 int32_t RTCPSender::RemoveMixedCNAME(uint32_t SSRC) { |
338 rtc::CritScope lock(&critical_section_rtcp_sender_); | 341 rtc::CritScope lock(&critical_section_rtcp_sender_); |
339 auto it = csrc_cnames_.find(SSRC); | 342 auto it = csrc_cnames_.find(SSRC); |
340 | 343 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 459 } |
457 | 460 |
458 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSDES( | 461 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSDES( |
459 const RtcpContext& ctx) { | 462 const RtcpContext& ctx) { |
460 size_t length_cname = cname_.length(); | 463 size_t length_cname = cname_.length(); |
461 RTC_CHECK_LT(length_cname, RTCP_CNAME_SIZE); | 464 RTC_CHECK_LT(length_cname, RTCP_CNAME_SIZE); |
462 | 465 |
463 rtcp::Sdes* sdes = new rtcp::Sdes(); | 466 rtcp::Sdes* sdes = new rtcp::Sdes(); |
464 sdes->AddCName(ssrc_, cname_); | 467 sdes->AddCName(ssrc_, cname_); |
465 | 468 |
466 for (const auto it : csrc_cnames_) | 469 for (const auto& it : csrc_cnames_) |
467 sdes->AddCName(it.first, it.second); | 470 RTC_CHECK(sdes->AddCName(it.first, it.second)); |
468 | 471 |
469 return std::unique_ptr<rtcp::RtcpPacket>(sdes); | 472 return std::unique_ptr<rtcp::RtcpPacket>(sdes); |
470 } | 473 } |
471 | 474 |
472 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildRR(const RtcpContext& ctx) { | 475 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildRR(const RtcpContext& ctx) { |
473 rtcp::ReceiverReport* report = new rtcp::ReceiverReport(); | 476 rtcp::ReceiverReport* report = new rtcp::ReceiverReport(); |
474 report->SetSenderSsrc(ssrc_); | 477 report->SetSenderSsrc(ssrc_); |
475 for (auto it : report_blocks_) | 478 for (auto it : report_blocks_) |
476 report->AddReportBlock(it.second); | 479 report->AddReportBlock(it.second); |
477 | 480 |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 max_packet_size = max_packet_size_; | 1003 max_packet_size = max_packet_size_; |
1001 } | 1004 } |
1002 | 1005 |
1003 RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE); | 1006 RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE); |
1004 uint8_t buffer[IP_PACKET_SIZE]; | 1007 uint8_t buffer[IP_PACKET_SIZE]; |
1005 return packet.BuildExternalBuffer(buffer, max_packet_size, &sender) && | 1008 return packet.BuildExternalBuffer(buffer, max_packet_size, &sender) && |
1006 !sender.send_failure_; | 1009 !sender.send_failure_; |
1007 } | 1010 } |
1008 | 1011 |
1009 } // namespace webrtc | 1012 } // namespace webrtc |
OLD | NEW |