You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2012 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. #include "video/encoder_rtcp_feedback.h"
  11. #include <memory>
  12. #include "test/gmock.h"
  13. #include "test/gtest.h"
  14. #include "video/test/mock_video_stream_encoder.h"
  15. namespace webrtc {
  16. class VieKeyRequestTest : public ::testing::Test {
  17. public:
  18. VieKeyRequestTest()
  19. : simulated_clock_(123456789),
  20. encoder_(),
  21. encoder_rtcp_feedback_(
  22. &simulated_clock_,
  23. std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc),
  24. &encoder_) {}
  25. protected:
  26. const uint32_t kSsrc = 1234;
  27. SimulatedClock simulated_clock_;
  28. ::testing::StrictMock<MockVideoStreamEncoder> encoder_;
  29. EncoderRtcpFeedback encoder_rtcp_feedback_;
  30. };
  31. TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) {
  32. EXPECT_CALL(encoder_, SendKeyFrame()).Times(1);
  33. encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
  34. }
  35. TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) {
  36. EXPECT_CALL(encoder_, SendKeyFrame()).Times(1);
  37. encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
  38. encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
  39. simulated_clock_.AdvanceTimeMilliseconds(10);
  40. encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
  41. EXPECT_CALL(encoder_, SendKeyFrame()).Times(1);
  42. simulated_clock_.AdvanceTimeMilliseconds(300);
  43. encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
  44. encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
  45. encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
  46. }
  47. TEST_F(VieKeyRequestTest, TriggerRequestFromMediaTransport) {
  48. EXPECT_CALL(encoder_, SendKeyFrame()).Times(1);
  49. encoder_rtcp_feedback_.OnKeyFrameRequested(kSsrc);
  50. }
  51. } // namespace webrtc