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

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

Issue 1936503002: Removed SSRC knowledge from ViEEncoder. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@move_payload_router2
Patch Set: Rebased Created 4 years, 7 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/encoder_state_feedback.cc ('k') | webrtc/video/video_send_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/video/encoder_state_feedback.h" 11 #include "webrtc/video/encoder_state_feedback.h"
12 12
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15
16 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
17 #include "webrtc/modules/pacing/paced_sender.h"
18 #include "webrtc/modules/pacing/packet_router.h"
19 #include "webrtc/modules/utility/include/mock/mock_process_thread.h" 15 #include "webrtc/modules/utility/include/mock/mock_process_thread.h"
20 #include "webrtc/video/vie_encoder.h" 16 #include "webrtc/video/vie_encoder.h"
21 17
22 using ::testing::NiceMock; 18 using ::testing::NiceMock;
23 19
24 namespace webrtc { 20 namespace webrtc {
25 21
26 class MockVieEncoder : public ViEEncoder { 22 class MockVieEncoder : public ViEEncoder {
27 public: 23 public:
28 explicit MockVieEncoder(ProcessThread* process_thread) 24 explicit MockVieEncoder(ProcessThread* process_thread)
29 : ViEEncoder(1, 25 : ViEEncoder(1,
30 std::vector<uint32_t>(),
31 process_thread, 26 process_thread,
32 nullptr, 27 nullptr,
33 nullptr) {} 28 nullptr) {}
34 ~MockVieEncoder() {} 29 ~MockVieEncoder() {}
35 30
36 MOCK_METHOD1(OnReceivedIntraFrameRequest, 31 MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t));
37 void(uint32_t)); 32 MOCK_METHOD1(OnReceivedSLI, void(uint8_t picture_id));
38 MOCK_METHOD2(OnReceivedSLI, 33 MOCK_METHOD1(OnReceivedRPSI, void(uint64_t picture_id));
39 void(uint32_t ssrc, uint8_t picture_id));
40 MOCK_METHOD2(OnReceivedRPSI,
41 void(uint32_t ssrc, uint64_t picture_id));
42 }; 34 };
43 35
44 TEST(VieKeyRequestTest, CreateAndTriggerRequests) { 36 class VieKeyRequestTest : public ::testing::Test {
45 static const uint32_t kSsrc = 1234; 37 public:
46 NiceMock<MockProcessThread> process_thread; 38 VieKeyRequestTest()
47 PacketRouter router; 39 : encoder_(&process_thread_),
48 MockVieEncoder encoder(&process_thread); 40 simulated_clock_(123456789),
41 encoder_state_feedback_(
42 &simulated_clock_,
43 std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc),
44 &encoder_) {}
49 45
50 EncoderStateFeedback encoder_state_feedback; 46 protected:
51 encoder_state_feedback.Init(std::vector<uint32_t>(1, kSsrc), &encoder); 47 const uint32_t kSsrc = 1234;
48 NiceMock<MockProcessThread> process_thread_;
49 MockVieEncoder encoder_;
50 SimulatedClock simulated_clock_;
51 EncoderStateFeedback encoder_state_feedback_;
52 };
52 53
53 EXPECT_CALL(encoder, OnReceivedIntraFrameRequest(kSsrc)) 54 TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) {
54 .Times(1); 55 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1);
55 encoder_state_feedback.OnReceivedIntraFrameRequest(kSsrc); 56 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
56 57
57 const uint8_t sli_picture_id = 3; 58 const uint8_t sli_picture_id = 3;
58 EXPECT_CALL(encoder, OnReceivedSLI(kSsrc, sli_picture_id)) 59 EXPECT_CALL(encoder_, OnReceivedSLI(sli_picture_id)).Times(1);
59 .Times(1); 60 encoder_state_feedback_.OnReceivedSLI(kSsrc, sli_picture_id);
60 encoder_state_feedback.OnReceivedSLI(kSsrc, sli_picture_id);
61 61
62 const uint64_t rpsi_picture_id = 9; 62 const uint64_t rpsi_picture_id = 9;
63 EXPECT_CALL(encoder, OnReceivedRPSI(kSsrc, rpsi_picture_id)) 63 EXPECT_CALL(encoder_, OnReceivedRPSI(rpsi_picture_id)).Times(1);
64 .Times(1); 64 encoder_state_feedback_.OnReceivedRPSI(kSsrc, rpsi_picture_id);
65 encoder_state_feedback.OnReceivedRPSI(kSsrc, rpsi_picture_id); 65 }
66
67 TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) {
68 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1);
69 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
70 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
71 simulated_clock_.AdvanceTimeMilliseconds(10);
72 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
73
74 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1);
75 simulated_clock_.AdvanceTimeMilliseconds(300);
76 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
77 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
78 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
66 } 79 }
67 80
68 } // namespace webrtc 81 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/encoder_state_feedback.cc ('k') | webrtc/video/video_send_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698