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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 if (frame_count_observer_) { | 549 if (frame_count_observer_) { |
550 frame_count_observer_->FrameCountUpdated(frame_counts_, ssrc); | 550 frame_count_observer_->FrameCountUpdated(frame_counts_, ssrc); |
551 } | 551 } |
552 | 552 |
553 return ret_val; | 553 return ret_val; |
554 } | 554 } |
555 | 555 |
556 size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send) { | 556 size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send) { |
557 { | 557 { |
558 rtc::CritScope lock(&send_critsect_); | 558 rtc::CritScope lock(&send_critsect_); |
559 if (!sending_media_) | |
560 return 0; | |
559 if ((rtx_ & kRtxRedundantPayloads) == 0) | 561 if ((rtx_ & kRtxRedundantPayloads) == 0) |
560 return 0; | 562 return 0; |
561 } | 563 } |
562 | 564 |
563 uint8_t buffer[IP_PACKET_SIZE]; | 565 uint8_t buffer[IP_PACKET_SIZE]; |
564 int bytes_left = static_cast<int>(bytes_to_send); | 566 int bytes_left = static_cast<int>(bytes_to_send); |
565 while (bytes_left > 0) { | 567 while (bytes_left > 0) { |
566 size_t length = bytes_left; | 568 size_t length = bytes_left; |
567 int64_t capture_time_ms; | 569 int64_t capture_time_ms; |
568 if (!packet_history_.GetBestFittingPacket(buffer, &length, | 570 if (!packet_history_.GetBestFittingPacket(buffer, &length, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 for (; bytes > 0; bytes -= padding_bytes_in_packet) { | 613 for (; bytes > 0; bytes -= padding_bytes_in_packet) { |
612 if (bytes < padding_bytes_in_packet) | 614 if (bytes < padding_bytes_in_packet) |
613 bytes = padding_bytes_in_packet; | 615 bytes = padding_bytes_in_packet; |
614 | 616 |
615 uint32_t ssrc; | 617 uint32_t ssrc; |
616 uint16_t sequence_number; | 618 uint16_t sequence_number; |
617 int payload_type; | 619 int payload_type; |
618 bool over_rtx; | 620 bool over_rtx; |
619 { | 621 { |
620 rtc::CritScope lock(&send_critsect_); | 622 rtc::CritScope lock(&send_critsect_); |
623 if (!sending_media_) | |
624 return bytes_sent; | |
621 if (!timestamp_provided) { | 625 if (!timestamp_provided) { |
622 timestamp = timestamp_; | 626 timestamp = timestamp_; |
623 capture_time_ms = capture_time_ms_; | 627 capture_time_ms = capture_time_ms_; |
624 } | 628 } |
625 if (rtx_ == kRtxOff) { | 629 if (rtx_ == kRtxOff) { |
626 // Without RTX we can't send padding in the middle of frames. | 630 // Without RTX we can't send padding in the middle of frames. |
627 if (!last_packet_marker_bit_) | 631 if (!last_packet_marker_bit_) |
628 return 0; | 632 return 0; |
629 ssrc = ssrc_; | 633 ssrc = ssrc_; |
630 sequence_number = sequence_number_; | 634 sequence_number = sequence_number_; |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1004 uint8_t pt_fec; | 1008 uint8_t pt_fec; |
1005 video_->GenericFECStatus(&fec_enabled, &pt_red, &pt_fec); | 1009 video_->GenericFECStatus(&fec_enabled, &pt_red, &pt_fec); |
1006 return fec_enabled && | 1010 return fec_enabled && |
1007 header.payloadType == pt_red && | 1011 header.payloadType == pt_red && |
1008 buffer[header.headerLength] == pt_fec; | 1012 buffer[header.headerLength] == pt_fec; |
1009 } | 1013 } |
1010 | 1014 |
1011 size_t RTPSender::TimeToSendPadding(size_t bytes) { | 1015 size_t RTPSender::TimeToSendPadding(size_t bytes) { |
1012 if (audio_configured_ || bytes == 0) | 1016 if (audio_configured_ || bytes == 0) |
1013 return 0; | 1017 return 0; |
1014 { | |
pbos-webrtc
2016/02/19 15:11:29
This check is now done in TrySendRedundantPayloads
| |
1015 rtc::CritScope lock(&send_critsect_); | |
1016 if (!sending_media_) | |
1017 return 0; | |
1018 } | |
1019 size_t bytes_sent = TrySendRedundantPayloads(bytes); | 1018 size_t bytes_sent = TrySendRedundantPayloads(bytes); |
1020 if (bytes_sent < bytes) | 1019 if (bytes_sent < bytes) |
1021 bytes_sent += SendPadData(bytes - bytes_sent, false, 0, 0); | 1020 bytes_sent += SendPadData(bytes - bytes_sent, false, 0, 0); |
1022 return bytes_sent; | 1021 return bytes_sent; |
1023 } | 1022 } |
1024 | 1023 |
1025 // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again. | 1024 // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again. |
1026 int32_t RTPSender::SendToNetwork(uint8_t* buffer, | 1025 int32_t RTPSender::SendToNetwork(uint8_t* buffer, |
1027 size_t payload_length, | 1026 size_t payload_length, |
1028 size_t rtp_header_length, | 1027 size_t rtp_header_length, |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1912 rtc::CritScope lock(&send_critsect_); | 1911 rtc::CritScope lock(&send_critsect_); |
1913 | 1912 |
1914 RtpState state; | 1913 RtpState state; |
1915 state.sequence_number = sequence_number_rtx_; | 1914 state.sequence_number = sequence_number_rtx_; |
1916 state.start_timestamp = start_timestamp_; | 1915 state.start_timestamp = start_timestamp_; |
1917 | 1916 |
1918 return state; | 1917 return state; |
1919 } | 1918 } |
1920 | 1919 |
1921 } // namespace webrtc | 1920 } // namespace webrtc |
OLD | NEW |