Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_sender.cc

Issue 1412683004: Fix bug in how send timestamps are converted to 24 bits. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: some stuff Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 14 #include <utility>
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/modules/rtp_rtcp/interface/rtp_cvo.h" 17 #include "webrtc/modules/rtp_rtcp/interface/rtp_cvo.h"
18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
19 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h" 19 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h" 20 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h"
21 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 21 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
22 #include "webrtc/system_wrappers/interface/logging.h" 22 #include "webrtc/system_wrappers/interface/logging.h"
23 #include "webrtc/system_wrappers/interface/tick_util.h" 23 #include "webrtc/system_wrappers/interface/tick_util.h"
24 #include "webrtc/system_wrappers/interface/trace_event.h" 24 #include "webrtc/system_wrappers/interface/trace_event.h"
25 25
26 namespace webrtc { 26 namespace webrtc {
27 27
28 // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP. 28 // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP.
29 const size_t kMaxPaddingLength = 224; 29 static const size_t kMaxPaddingLength = 224;
30 const int kSendSideDelayWindowMs = 1000; 30 static const int kSendSideDelayWindowMs = 1000;
31 static const uint32_t kAbsSendTimeFraction = 18;
31 32
32 namespace { 33 namespace {
33 34
34 const size_t kRtpHeaderLength = 12; 35 const size_t kRtpHeaderLength = 12;
35 36
36 const char* FrameTypeToString(FrameType frame_type) { 37 const char* FrameTypeToString(FrameType frame_type) {
37 switch (frame_type) { 38 switch (frame_type) {
38 case kEmptyFrame: 39 case kEmptyFrame:
39 return "empty"; 40 return "empty";
40 case kAudioFrameSpeech: return "audio_speech"; 41 case kAudioFrameSpeech: return "audio_speech";
41 case kAudioFrameCN: return "audio_cn"; 42 case kAudioFrameCN: return "audio_cn";
42 case kVideoFrameKey: return "video_key"; 43 case kVideoFrameKey: return "video_key";
43 case kVideoFrameDelta: return "video_delta"; 44 case kVideoFrameDelta: return "video_delta";
44 } 45 }
45 return ""; 46 return "";
46 } 47 }
47 48
49 // TODO(holmer): Merge this with the implementation in
50 // remote_bitrate_estimator_abs_send_time.cc.
51 uint32_t ConvertMsTo24Bits(int64_t time_ms) {
52 uint32_t time_24_bits =
53 static_cast<uint32_t>(
54 ((static_cast<uint64_t>(time_ms) << kAbsSendTimeFraction) + 500) /
55 1000) &
56 0x00FFFFFF;
57 return time_24_bits;
58 }
48 } // namespace 59 } // namespace
49 60
50 class BitrateAggregator { 61 class BitrateAggregator {
51 public: 62 public:
52 explicit BitrateAggregator(BitrateStatisticsObserver* bitrate_callback) 63 explicit BitrateAggregator(BitrateStatisticsObserver* bitrate_callback)
53 : callback_(bitrate_callback), 64 : callback_(bitrate_callback),
54 total_bitrate_observer_(*this), 65 total_bitrate_observer_(*this),
55 retransmit_bitrate_observer_(*this), 66 retransmit_bitrate_observer_(*this),
56 ssrc_(0) {} 67 ssrc_(0) {}
57 68
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 return; 1600 return;
1590 case ExtensionStatus::kOk: 1601 case ExtensionStatus::kOk:
1591 break; 1602 break;
1592 default: 1603 default:
1593 RTC_NOTREACHED(); 1604 RTC_NOTREACHED();
1594 } 1605 }
1595 1606
1596 // Update absolute send time field (convert ms to 24-bit unsigned with 18 bit 1607 // Update absolute send time field (convert ms to 24-bit unsigned with 18 bit
1597 // fractional part). 1608 // fractional part).
1598 ByteWriter<uint32_t, 3>::WriteBigEndian(rtp_packet + offset + 1, 1609 ByteWriter<uint32_t, 3>::WriteBigEndian(rtp_packet + offset + 1,
1599 ((now_ms << 18) / 1000) & 0x00ffffff); 1610 ConvertMsTo24Bits(now_ms));
1600 } 1611 }
1601 1612
1602 uint16_t RTPSender::UpdateTransportSequenceNumber( 1613 uint16_t RTPSender::UpdateTransportSequenceNumber(
1603 uint8_t* rtp_packet, 1614 uint8_t* rtp_packet,
1604 size_t rtp_packet_length, 1615 size_t rtp_packet_length,
1605 const RTPHeader& rtp_header) const { 1616 const RTPHeader& rtp_header) const {
1606 size_t offset; 1617 size_t offset;
1607 CriticalSectionScoped cs(send_critsect_.get()); 1618 CriticalSectionScoped cs(send_critsect_.get());
1608 1619
1609 switch (VerifyExtension(kRtpExtensionTransportSequenceNumber, rtp_packet, 1620 switch (VerifyExtension(kRtpExtensionTransportSequenceNumber, rtp_packet,
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 CriticalSectionScoped lock(send_critsect_.get()); 1904 CriticalSectionScoped lock(send_critsect_.get());
1894 1905
1895 RtpState state; 1906 RtpState state;
1896 state.sequence_number = sequence_number_rtx_; 1907 state.sequence_number = sequence_number_rtx_;
1897 state.start_timestamp = start_timestamp_; 1908 state.start_timestamp = start_timestamp_;
1898 1909
1899 return state; 1910 return state;
1900 } 1911 }
1901 1912
1902 } // namespace webrtc 1913 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698