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

Side by Side Diff: webrtc/video/audio_receive_stream_unittest.cc

Issue 1360913004: Fix BWE bug where audio has timestamps in us. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: . 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
« no previous file with comments | « webrtc/video/audio_receive_stream.cc ('k') | webrtc/webrtc_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h"
14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
15 #include "webrtc/video/audio_receive_stream.h"
16
17 namespace webrtc {
18
19 const size_t kAbsoluteSendTimeLength = 4;
20
21 void BuildAbsoluteSendTimeExtension(uint8_t* buffer,
22 int id,
23 uint32_t abs_send_time) {
24 const size_t kRtpOneByteHeaderLength = 4;
25 const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE;
26 ByteWriter<uint16_t>::WriteBigEndian(buffer, kRtpOneByteHeaderExtensionId);
27
28 const uint32_t kPosLength = 2;
29 ByteWriter<uint16_t>::WriteBigEndian(buffer + kPosLength,
30 kAbsoluteSendTimeLength / 4);
31
32 const uint8_t kLengthOfData = 3;
33 buffer[kRtpOneByteHeaderLength] = (id << 4) + (kLengthOfData - 1);
34 ByteWriter<uint32_t, kLengthOfData>::WriteBigEndian(
35 buffer + kRtpOneByteHeaderLength + 1, abs_send_time);
36 }
37
38 size_t CreateRtpHeaderWithAbsSendTime(uint8_t* header,
39 int extension_id,
40 uint32_t abs_send_time) {
41 header[0] = 0x80; // Version 2.
42 header[0] |= 0x10; // Set extension bit.
43 header[1] = 100; // Payload type.
44 header[1] |= 0x80; // Marker bit is set.
45 ByteWriter<uint16_t>::WriteBigEndian(header + 2, 0x1234); // Sequence number.
46 ByteWriter<uint32_t>::WriteBigEndian(header + 4, 0x5678); // Timestamp.
47 ByteWriter<uint32_t>::WriteBigEndian(header + 8, 0x4321); // SSRC.
48 int32_t rtp_header_length = kRtpHeaderSize;
49
50 BuildAbsoluteSendTimeExtension(header + rtp_header_length, extension_id,
51 abs_send_time);
52 rtp_header_length += kAbsoluteSendTimeLength;
53 return rtp_header_length;
54 }
55
56 TEST(AudioReceiveStreamTest, AudioPacketUpdatesBweWithTimestamp) {
57 MockRemoteBitrateEstimator rbe;
58 AudioReceiveStream::Config config;
59 config.combined_audio_video_bwe = true;
60 config.voe_channel_id = 1;
61 const int kAbsSendTimeId = 3;
62 config.rtp.extensions.push_back(
63 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId));
64 internal::AudioReceiveStream recv_stream(&rbe, config);
65 uint8_t rtp_packet[30];
66 const int kAbsSendTimeValue = 1234;
67 CreateRtpHeaderWithAbsSendTime(rtp_packet, kAbsSendTimeId, kAbsSendTimeValue);
68 PacketTime packet_time(5678000, 0);
69 const size_t kExpectedHeaderLength = 20;
70 EXPECT_CALL(rbe, IncomingPacket(packet_time.timestamp / 1000,
71 sizeof(rtp_packet) - kExpectedHeaderLength,
72 testing::_, false))
73 .Times(1);
74 EXPECT_TRUE(
75 recv_stream.DeliverRtp(rtp_packet, sizeof(rtp_packet), packet_time));
76 }
77 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/audio_receive_stream.cc ('k') | webrtc/webrtc_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698