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 <algorithm> | 11 #include <algorithm> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "webrtc/common_types.h" | 16 #include "webrtc/common_types.h" |
17 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" | 17 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" |
18 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" | 18 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" |
19 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" | 19 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" |
21 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" | 21 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" |
22 | 22 |
23 using namespace webrtc; | 23 using namespace webrtc; |
24 | 24 |
25 const uint64_t kTestPictureId = 12345678; | 25 const uint64_t kTestPictureId = 12345678; |
| 26 const uint8_t kSliPictureId = 156; |
26 | 27 |
27 class RtcpCallback : public RtcpIntraFrameObserver { | 28 class RtcpCallback : public RtcpIntraFrameObserver { |
28 public: | 29 public: |
29 void SetModule(RtpRtcp* module) { | 30 void SetModule(RtpRtcp* module) { |
30 _rtpRtcpModule = module; | 31 _rtpRtcpModule = module; |
31 }; | 32 }; |
32 virtual void OnRTCPPacketTimeout(const int32_t id) { | 33 virtual void OnRTCPPacketTimeout(const int32_t id) { |
33 } | 34 } |
34 virtual void OnLipSyncUpdate(const int32_t id, | 35 virtual void OnLipSyncUpdate(const int32_t id, |
35 const int32_t audioVideoOffset) { | 36 const int32_t audioVideoOffset) { |
36 }; | 37 }; |
37 virtual void OnReceivedIntraFrameRequest(uint32_t ssrc) { | 38 virtual void OnReceivedIntraFrameRequest(uint32_t ssrc) { |
38 }; | 39 }; |
39 virtual void OnReceivedSLI(uint32_t ssrc, | 40 virtual void OnReceivedSLI(uint32_t ssrc, |
40 uint8_t pictureId) { | 41 uint8_t pictureId) { |
41 EXPECT_EQ(28, pictureId); | 42 EXPECT_EQ(kSliPictureId & 0x3f, pictureId); |
42 }; | 43 }; |
43 virtual void OnReceivedRPSI(uint32_t ssrc, | 44 virtual void OnReceivedRPSI(uint32_t ssrc, |
44 uint64_t pictureId) { | 45 uint64_t pictureId) { |
45 EXPECT_EQ(kTestPictureId, pictureId); | 46 EXPECT_EQ(kTestPictureId, pictureId); |
46 }; | 47 }; |
47 virtual void OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) {}; | 48 virtual void OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) {}; |
48 private: | 49 private: |
49 RtpRtcp* _rtpRtcpModule; | 50 RtpRtcp* _rtpRtcpModule; |
50 }; | 51 }; |
51 | 52 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 198 |
198 uint32_t test_ssrc; | 199 uint32_t test_ssrc; |
199 uint32_t test_timestamp; | 200 uint32_t test_timestamp; |
200 uint16_t test_sequence_number; | 201 uint16_t test_sequence_number; |
201 std::vector<uint32_t> test_csrcs; | 202 std::vector<uint32_t> test_csrcs; |
202 SimulatedClock fake_clock; | 203 SimulatedClock fake_clock; |
203 }; | 204 }; |
204 | 205 |
205 TEST_F(RtpRtcpRtcpTest, RTCP_PLI_RPSI) { | 206 TEST_F(RtpRtcpRtcpTest, RTCP_PLI_RPSI) { |
206 EXPECT_EQ(0, module1->SendRTCPReferencePictureSelection(kTestPictureId)); | 207 EXPECT_EQ(0, module1->SendRTCPReferencePictureSelection(kTestPictureId)); |
207 EXPECT_EQ(0, module1->SendRTCPSliceLossIndication(156)); | 208 EXPECT_EQ(0, module1->SendRTCPSliceLossIndication(kSliPictureId)); |
208 } | 209 } |
209 | 210 |
210 TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) { | 211 TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) { |
211 uint32_t testOfCSRC[webrtc::kRtpCsrcSize]; | 212 uint32_t testOfCSRC[webrtc::kRtpCsrcSize]; |
212 EXPECT_EQ(2, rtp_receiver2_->CSRCs(testOfCSRC)); | 213 EXPECT_EQ(2, rtp_receiver2_->CSRCs(testOfCSRC)); |
213 EXPECT_EQ(test_csrcs[0], testOfCSRC[0]); | 214 EXPECT_EQ(test_csrcs[0], testOfCSRC[0]); |
214 EXPECT_EQ(test_csrcs[1], testOfCSRC[1]); | 215 EXPECT_EQ(test_csrcs[1], testOfCSRC[1]); |
215 | 216 |
216 // Set cname of mixed. | 217 // Set cname of mixed. |
217 EXPECT_EQ(0, module1->AddMixedCNAME(test_csrcs[0], "john@192.168.0.1")); | 218 EXPECT_EQ(0, module1->AddMixedCNAME(test_csrcs[0], "john@192.168.0.1")); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 264 |
264 // |test_ssrc+1| is the SSRC of module2 that send the report. | 265 // |test_ssrc+1| is the SSRC of module2 that send the report. |
265 EXPECT_EQ(test_ssrc+1, report_blocks[0].remoteSSRC); | 266 EXPECT_EQ(test_ssrc+1, report_blocks[0].remoteSSRC); |
266 EXPECT_EQ(test_ssrc, report_blocks[0].sourceSSRC); | 267 EXPECT_EQ(test_ssrc, report_blocks[0].sourceSSRC); |
267 | 268 |
268 EXPECT_EQ(0u, report_blocks[0].cumulativeLost); | 269 EXPECT_EQ(0u, report_blocks[0].cumulativeLost); |
269 EXPECT_LT(0u, report_blocks[0].delaySinceLastSR); | 270 EXPECT_LT(0u, report_blocks[0].delaySinceLastSR); |
270 EXPECT_EQ(test_sequence_number, report_blocks[0].extendedHighSeqNum); | 271 EXPECT_EQ(test_sequence_number, report_blocks[0].extendedHighSeqNum); |
271 EXPECT_EQ(0u, report_blocks[0].fractionLost); | 272 EXPECT_EQ(0u, report_blocks[0].fractionLost); |
272 } | 273 } |
OLD | NEW |