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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 : audio_(audio), | 154 : audio_(audio), |
155 clock_(clock), | 155 clock_(clock), |
156 random_(clock_->TimeInMicroseconds()), | 156 random_(clock_->TimeInMicroseconds()), |
157 method_(RtcpMode::kOff), | 157 method_(RtcpMode::kOff), |
158 event_log_(event_log), | 158 event_log_(event_log), |
159 transport_(outgoing_transport), | 159 transport_(outgoing_transport), |
160 using_nack_(false), | 160 using_nack_(false), |
161 sending_(false), | 161 sending_(false), |
162 remb_enabled_(false), | 162 remb_enabled_(false), |
163 next_time_to_send_rtcp_(0), | 163 next_time_to_send_rtcp_(0), |
164 start_timestamp_(0), | 164 timestamp_offset_(0), |
165 last_rtp_timestamp_(0), | 165 last_rtp_timestamp_(0), |
166 last_frame_capture_time_ms_(-1), | 166 last_frame_capture_time_ms_(-1), |
167 ssrc_(0), | 167 ssrc_(0), |
168 remote_ssrc_(0), | 168 remote_ssrc_(0), |
169 receive_statistics_(receive_statistics), | 169 receive_statistics_(receive_statistics), |
170 | 170 |
171 sequence_number_fir_(0), | 171 sequence_number_fir_(0), |
172 | 172 |
173 remb_bitrate_(0), | 173 remb_bitrate_(0), |
174 | 174 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 SetFlag(RTCPPacketType::kRtcpTmmbr, false); | 281 SetFlag(RTCPPacketType::kRtcpTmmbr, false); |
282 } else { | 282 } else { |
283 ConsumeFlag(RTCPPacketType::kRtcpTmmbr, true); | 283 ConsumeFlag(RTCPPacketType::kRtcpTmmbr, true); |
284 } | 284 } |
285 } | 285 } |
286 | 286 |
287 void RTCPSender::SetMaxPayloadLength(size_t max_payload_length) { | 287 void RTCPSender::SetMaxPayloadLength(size_t max_payload_length) { |
288 max_payload_length_ = max_payload_length; | 288 max_payload_length_ = max_payload_length; |
289 } | 289 } |
290 | 290 |
291 void RTCPSender::SetStartTimestamp(uint32_t start_timestamp) { | 291 void RTCPSender::SetTimestampOffset(uint32_t timestamp_offset) { |
292 rtc::CritScope lock(&critical_section_rtcp_sender_); | 292 rtc::CritScope lock(&critical_section_rtcp_sender_); |
293 start_timestamp_ = start_timestamp; | 293 timestamp_offset_ = timestamp_offset; |
294 } | 294 } |
295 | 295 |
296 void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp, | 296 void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp, |
297 int64_t capture_time_ms) { | 297 int64_t capture_time_ms) { |
298 rtc::CritScope lock(&critical_section_rtcp_sender_); | 298 rtc::CritScope lock(&critical_section_rtcp_sender_); |
299 last_rtp_timestamp_ = rtp_timestamp; | 299 last_rtp_timestamp_ = rtp_timestamp; |
300 if (capture_time_ms < 0) { | 300 if (capture_time_ms < 0) { |
301 // We don't currently get a capture time from VoiceEngine. | 301 // We don't currently get a capture time from VoiceEngine. |
302 last_frame_capture_time_ms_ = clock_->TimeInMilliseconds(); | 302 last_frame_capture_time_ms_ = clock_->TimeInMilliseconds(); |
303 } else { | 303 } else { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 } | 437 } |
438 | 438 |
439 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSR(const RtcpContext& ctx) { | 439 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSR(const RtcpContext& ctx) { |
440 // Timestamp shouldn't be estimated before first media frame. | 440 // Timestamp shouldn't be estimated before first media frame. |
441 RTC_DCHECK_GE(last_frame_capture_time_ms_, 0); | 441 RTC_DCHECK_GE(last_frame_capture_time_ms_, 0); |
442 // The timestamp of this RTCP packet should be estimated as the timestamp of | 442 // The timestamp of this RTCP packet should be estimated as the timestamp of |
443 // the frame being captured at this moment. We are calculating that | 443 // the frame being captured at this moment. We are calculating that |
444 // timestamp as the last frame's timestamp + the time since the last frame | 444 // timestamp as the last frame's timestamp + the time since the last frame |
445 // was captured. | 445 // was captured. |
446 uint32_t rtp_timestamp = | 446 uint32_t rtp_timestamp = |
447 start_timestamp_ + last_rtp_timestamp_ + | 447 timestamp_offset_ + last_rtp_timestamp_ + |
448 (clock_->TimeInMilliseconds() - last_frame_capture_time_ms_) * | 448 (clock_->TimeInMilliseconds() - last_frame_capture_time_ms_) * |
449 (ctx.feedback_state_.frequency_hz / 1000); | 449 (ctx.feedback_state_.frequency_hz / 1000); |
450 | 450 |
451 rtcp::SenderReport* report = new rtcp::SenderReport(); | 451 rtcp::SenderReport* report = new rtcp::SenderReport(); |
452 report->From(ssrc_); | 452 report->From(ssrc_); |
453 report->WithNtp(NtpTime(ctx.ntp_sec_, ctx.ntp_frac_)); | 453 report->WithNtp(NtpTime(ctx.ntp_sec_, ctx.ntp_frac_)); |
454 report->WithRtpTimestamp(rtp_timestamp); | 454 report->WithRtpTimestamp(rtp_timestamp); |
455 report->WithPacketCount(ctx.feedback_state_.packets_sent); | 455 report->WithPacketCount(ctx.feedback_state_.packets_sent); |
456 report->WithOctetCount(ctx.feedback_state_.media_bytes_sent); | 456 report->WithOctetCount(ctx.feedback_state_.media_bytes_sent); |
457 | 457 |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 // but we can't because of an incorrect warning (C4822) in MVS 2013. | 1052 // but we can't because of an incorrect warning (C4822) in MVS 2013. |
1053 } sender(transport_, event_log_); | 1053 } sender(transport_, event_log_); |
1054 | 1054 |
1055 RTC_DCHECK_LE(max_payload_length_, static_cast<size_t>(IP_PACKET_SIZE)); | 1055 RTC_DCHECK_LE(max_payload_length_, static_cast<size_t>(IP_PACKET_SIZE)); |
1056 uint8_t buffer[IP_PACKET_SIZE]; | 1056 uint8_t buffer[IP_PACKET_SIZE]; |
1057 return packet.BuildExternalBuffer(buffer, max_payload_length_, &sender) && | 1057 return packet.BuildExternalBuffer(buffer, max_payload_length_, &sender) && |
1058 !sender.send_failure_; | 1058 !sender.send_failure_; |
1059 } | 1059 } |
1060 | 1060 |
1061 } // namespace webrtc | 1061 } // namespace webrtc |
OLD | NEW |