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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (transport_->SendRtcp(data, length)) { | 96 if (transport_->SendRtcp(data, length)) { |
97 bytes_sent_ += length; | 97 bytes_sent_ += length; |
98 if (event_log_) { | 98 if (event_log_) { |
99 event_log_->LogRtcpPacket(kOutgoingPacket, MediaType::ANY, data, | 99 event_log_->LogRtcpPacket(kOutgoingPacket, MediaType::ANY, data, |
100 length); | 100 length); |
101 } | 101 } |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 size_t SendPackets(size_t max_payload_length) { | 105 size_t SendPackets(size_t max_payload_length) { |
106 RTC_DCHECK_LE(max_payload_length, static_cast<size_t>(IP_PACKET_SIZE)); | 106 RTC_DCHECK_LE(max_payload_length, IP_PACKET_SIZE); |
107 uint8_t buffer[IP_PACKET_SIZE]; | 107 uint8_t buffer[IP_PACKET_SIZE]; |
108 BuildExternalBuffer(buffer, max_payload_length, this); | 108 BuildExternalBuffer(buffer, max_payload_length, this); |
109 return bytes_sent_; | 109 return bytes_sent_; |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 Transport* transport_; | 113 Transport* transport_; |
114 RtcEventLog* const event_log_; | 114 RtcEventLog* const event_log_; |
115 size_t bytes_sent_; | 115 size_t bytes_sent_; |
116 | 116 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 318 |
319 void RTCPSender::SetRemoteSSRC(uint32_t ssrc) { | 319 void RTCPSender::SetRemoteSSRC(uint32_t ssrc) { |
320 rtc::CritScope lock(&critical_section_rtcp_sender_); | 320 rtc::CritScope lock(&critical_section_rtcp_sender_); |
321 remote_ssrc_ = ssrc; | 321 remote_ssrc_ = ssrc; |
322 } | 322 } |
323 | 323 |
324 int32_t RTCPSender::SetCNAME(const char* c_name) { | 324 int32_t RTCPSender::SetCNAME(const char* c_name) { |
325 if (!c_name) | 325 if (!c_name) |
326 return -1; | 326 return -1; |
327 | 327 |
328 RTC_DCHECK_LT(strlen(c_name), static_cast<size_t>(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 cname_ = c_name; | 330 cname_ = c_name; |
331 return 0; | 331 return 0; |
332 } | 332 } |
333 | 333 |
334 int32_t RTCPSender::AddMixedCNAME(uint32_t SSRC, const char* c_name) { | 334 int32_t RTCPSender::AddMixedCNAME(uint32_t SSRC, const char* c_name) { |
335 RTC_DCHECK(c_name); | 335 RTC_DCHECK(c_name); |
336 RTC_DCHECK_LT(strlen(c_name), static_cast<size_t>(RTCP_CNAME_SIZE)); | 336 RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE); |
337 rtc::CritScope lock(&critical_section_rtcp_sender_); | 337 rtc::CritScope lock(&critical_section_rtcp_sender_); |
338 if (csrc_cnames_.size() >= kRtpCsrcSize) | 338 if (csrc_cnames_.size() >= kRtpCsrcSize) |
339 return -1; | 339 return -1; |
340 | 340 |
341 csrc_cnames_[SSRC] = c_name; | 341 csrc_cnames_[SSRC] = c_name; |
342 return 0; | 342 return 0; |
343 } | 343 } |
344 | 344 |
345 int32_t RTCPSender::RemoveMixedCNAME(uint32_t SSRC) { | 345 int32_t RTCPSender::RemoveMixedCNAME(uint32_t SSRC) { |
346 rtc::CritScope lock(&critical_section_rtcp_sender_); | 346 rtc::CritScope lock(&critical_section_rtcp_sender_); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 report->AddReportBlock(it.second); | 459 report->AddReportBlock(it.second); |
460 | 460 |
461 report_blocks_.clear(); | 461 report_blocks_.clear(); |
462 | 462 |
463 return std::unique_ptr<rtcp::RtcpPacket>(report); | 463 return std::unique_ptr<rtcp::RtcpPacket>(report); |
464 } | 464 } |
465 | 465 |
466 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSDES( | 466 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSDES( |
467 const RtcpContext& ctx) { | 467 const RtcpContext& ctx) { |
468 size_t length_cname = cname_.length(); | 468 size_t length_cname = cname_.length(); |
469 RTC_CHECK_LT(length_cname, static_cast<size_t>(RTCP_CNAME_SIZE)); | 469 RTC_CHECK_LT(length_cname, RTCP_CNAME_SIZE); |
470 | 470 |
471 rtcp::Sdes* sdes = new rtcp::Sdes(); | 471 rtcp::Sdes* sdes = new rtcp::Sdes(); |
472 sdes->AddCName(ssrc_, cname_); | 472 sdes->AddCName(ssrc_, cname_); |
473 | 473 |
474 for (const auto it : csrc_cnames_) | 474 for (const auto it : csrc_cnames_) |
475 sdes->AddCName(it.first, it.second); | 475 sdes->AddCName(it.first, it.second); |
476 | 476 |
477 return std::unique_ptr<rtcp::RtcpPacket>(sdes); | 477 return std::unique_ptr<rtcp::RtcpPacket>(sdes); |
478 } | 478 } |
479 | 479 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 uint32_t receiveTime = feedback_state.last_rr_ntp_secs & 0x0000FFFF; | 926 uint32_t receiveTime = feedback_state.last_rr_ntp_secs & 0x0000FFFF; |
927 receiveTime <<= 16; | 927 receiveTime <<= 16; |
928 receiveTime += (feedback_state.last_rr_ntp_frac & 0xffff0000) >> 16; | 928 receiveTime += (feedback_state.last_rr_ntp_frac & 0xffff0000) >> 16; |
929 | 929 |
930 block->SetDelayLastSr(now - receiveTime); | 930 block->SetDelayLastSr(now - receiveTime); |
931 } | 931 } |
932 return true; | 932 return true; |
933 } | 933 } |
934 | 934 |
935 void RTCPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) { | 935 void RTCPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) { |
936 RTC_DCHECK_LE(csrcs.size(), static_cast<size_t>(kRtpCsrcSize)); | 936 RTC_DCHECK_LE(csrcs.size(), kRtpCsrcSize); |
937 rtc::CritScope lock(&critical_section_rtcp_sender_); | 937 rtc::CritScope lock(&critical_section_rtcp_sender_); |
938 csrcs_ = csrcs; | 938 csrcs_ = csrcs; |
939 } | 939 } |
940 | 940 |
941 int32_t RTCPSender::SetApplicationSpecificData(uint8_t subType, | 941 int32_t RTCPSender::SetApplicationSpecificData(uint8_t subType, |
942 uint32_t name, | 942 uint32_t name, |
943 const uint8_t* data, | 943 const uint8_t* data, |
944 uint16_t length) { | 944 uint16_t length) { |
945 if (length % 4 != 0) { | 945 if (length % 4 != 0) { |
946 LOG(LS_ERROR) << "Failed to SetApplicationSpecificData."; | 946 LOG(LS_ERROR) << "Failed to SetApplicationSpecificData."; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 } | 1030 } |
1031 | 1031 |
1032 Transport* const transport_; | 1032 Transport* const transport_; |
1033 RtcEventLog* const event_log_; | 1033 RtcEventLog* const event_log_; |
1034 bool send_failure_; | 1034 bool send_failure_; |
1035 // TODO(terelius): We would like to | 1035 // TODO(terelius): We would like to |
1036 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender); | 1036 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender); |
1037 // but we can't because of an incorrect warning (C4822) in MVS 2013. | 1037 // but we can't because of an incorrect warning (C4822) in MVS 2013. |
1038 } sender(transport_, event_log_); | 1038 } sender(transport_, event_log_); |
1039 | 1039 |
1040 RTC_DCHECK_LE(max_payload_length_, static_cast<size_t>(IP_PACKET_SIZE)); | 1040 RTC_DCHECK_LE(max_payload_length_, IP_PACKET_SIZE); |
1041 uint8_t buffer[IP_PACKET_SIZE]; | 1041 uint8_t buffer[IP_PACKET_SIZE]; |
1042 return packet.BuildExternalBuffer(buffer, max_payload_length_, &sender) && | 1042 return packet.BuildExternalBuffer(buffer, max_payload_length_, &sender) && |
1043 !sender.send_failure_; | 1043 !sender.send_failure_; |
1044 } | 1044 } |
1045 | 1045 |
1046 } // namespace webrtc | 1046 } // namespace webrtc |
OLD | NEW |