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 |
11 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" |
12 | 12 |
13 #include <stdlib.h> // srand | 13 #include <stdlib.h> // srand |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <utility> | 15 #include <utility> |
16 | 16 |
17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
18 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
19 #include "webrtc/base/trace_event.h" | 19 #include "webrtc/base/trace_event.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" |
21 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 21 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
22 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h" |
| 24 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
24 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
25 #include "webrtc/system_wrappers/include/tick_util.h" | 26 #include "webrtc/system_wrappers/include/tick_util.h" |
26 | 27 |
27 namespace webrtc { | 28 namespace webrtc { |
28 | 29 |
29 // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP. | 30 // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP. |
30 static const size_t kMaxPaddingLength = 224; | 31 static const size_t kMaxPaddingLength = 224; |
31 static const int kSendSideDelayWindowMs = 1000; | 32 static const int kSendSideDelayWindowMs = 1000; |
32 static const uint32_t kAbsSendTimeFraction = 18; | 33 static const uint32_t kAbsSendTimeFraction = 18; |
33 | 34 |
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 } | 1637 } |
1637 | 1638 |
1638 uint16_t seq = transport_sequence_number_allocator_->AllocateSequenceNumber(); | 1639 uint16_t seq = transport_sequence_number_allocator_->AllocateSequenceNumber(); |
1639 BuildTransportSequenceNumberExtension(rtp_packet + offset, seq); | 1640 BuildTransportSequenceNumberExtension(rtp_packet + offset, seq); |
1640 return seq; | 1641 return seq; |
1641 } | 1642 } |
1642 | 1643 |
1643 void RTPSender::SetSendingStatus(bool enabled) { | 1644 void RTPSender::SetSendingStatus(bool enabled) { |
1644 if (enabled) { | 1645 if (enabled) { |
1645 uint32_t frequency_hz = SendPayloadFrequency(); | 1646 uint32_t frequency_hz = SendPayloadFrequency(); |
1646 uint32_t RTPtime = RtpUtility::GetCurrentRTP(clock_, frequency_hz); | 1647 uint32_t RTPtime = CurrentRtp(*clock_, frequency_hz); |
1647 | 1648 |
1648 // Will be ignored if it's already configured via API. | 1649 // Will be ignored if it's already configured via API. |
1649 SetStartTimestamp(RTPtime, false); | 1650 SetStartTimestamp(RTPtime, false); |
1650 } else { | 1651 } else { |
1651 CriticalSectionScoped lock(send_critsect_.get()); | 1652 CriticalSectionScoped lock(send_critsect_.get()); |
1652 if (!ssrc_forced_) { | 1653 if (!ssrc_forced_) { |
1653 // Generate a new SSRC. | 1654 // Generate a new SSRC. |
1654 ssrc_db_.ReturnSSRC(ssrc_); | 1655 ssrc_db_.ReturnSSRC(ssrc_); |
1655 ssrc_ = ssrc_db_.CreateSSRC(); // Can't be 0. | 1656 ssrc_ = ssrc_db_.CreateSSRC(); // Can't be 0. |
1656 bitrates_->set_ssrc(ssrc_); | 1657 bitrates_->set_ssrc(ssrc_); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 CriticalSectionScoped lock(send_critsect_.get()); | 1907 CriticalSectionScoped lock(send_critsect_.get()); |
1907 | 1908 |
1908 RtpState state; | 1909 RtpState state; |
1909 state.sequence_number = sequence_number_rtx_; | 1910 state.sequence_number = sequence_number_rtx_; |
1910 state.start_timestamp = start_timestamp_; | 1911 state.start_timestamp = start_timestamp_; |
1911 | 1912 |
1912 return state; | 1913 return state; |
1913 } | 1914 } |
1914 | 1915 |
1915 } // namespace webrtc | 1916 } // namespace webrtc |
OLD | NEW |