webrtc_m130/webrtc/video/encoder_state_feedback_unittest.cc

79 lines
2.8 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/video/encoder_state_feedback.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/modules/utility/include/mock/mock_process_thread.h"
#include "webrtc/video/vie_encoder.h"
using ::testing::NiceMock;
namespace webrtc {
class MockVieEncoder : public ViEEncoder {
public:
Revert of Add task queue to Call. (patchset #42 id:840001 of https://codereview.webrtc.org/2060403002/ ) Reason for revert: Failed on Win 10 Chrome FYI. https://build.chromium.org/p/chromium.webrtc.fyi/builders/Win10%20Tester/builds/3847/steps/content_browsertests/logs/stdio # # Fatal error in e:\b\c\b\win_builder\src\third_party\webrtc\base\task_queue_win.cc, line 138 # last system error: 87 # Check failed: ((DWORD)0xFFFFFFFF) != result (4294967295 vs. 4294967295) # WebRtcBrowserTest # Original issue's description: > - Add task queue to Call with the intent of replacing the use of one of the process threads. > > - Split VideoSendStream in two. VideoSendStreamInternal is created and used on the new task queue. > > - BitrateAllocator is now created on libjingle's worker thread but always used on the new task queue instead of both encoder threads and the process thread. > > - VideoEncoderConfig and VideoSendStream::Config support move semantics. > > - The encoder thread is moved from VideoSendStream to ViEEncoder. Frames are forwarded directly to ViEEncoder which is responsible for timestamping ? and encoding the frames. > > BUG=webrtc:5687 > > Committed: https://crrev.com/cc168360f41322332860cb075edeb1cde21aa473 > Cr-Commit-Position: refs/heads/master@{#13767} TBR=tommi@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org,sprang@webrtc.org,pbos@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5687 Review-Url: https://codereview.webrtc.org/2248713003 Cr-Commit-Position: refs/heads/master@{#13774}
2016-08-16 02:40:55 -07:00
explicit MockVieEncoder(ProcessThread* process_thread)
: ViEEncoder(1, process_thread, nullptr, nullptr, nullptr) {}
~MockVieEncoder() {}
MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t));
MOCK_METHOD1(OnReceivedSLI, void(uint8_t picture_id));
MOCK_METHOD1(OnReceivedRPSI, void(uint64_t picture_id));
};
class VieKeyRequestTest : public ::testing::Test {
public:
VieKeyRequestTest()
Revert of Add task queue to Call. (patchset #42 id:840001 of https://codereview.webrtc.org/2060403002/ ) Reason for revert: Failed on Win 10 Chrome FYI. https://build.chromium.org/p/chromium.webrtc.fyi/builders/Win10%20Tester/builds/3847/steps/content_browsertests/logs/stdio # # Fatal error in e:\b\c\b\win_builder\src\third_party\webrtc\base\task_queue_win.cc, line 138 # last system error: 87 # Check failed: ((DWORD)0xFFFFFFFF) != result (4294967295 vs. 4294967295) # WebRtcBrowserTest # Original issue's description: > - Add task queue to Call with the intent of replacing the use of one of the process threads. > > - Split VideoSendStream in two. VideoSendStreamInternal is created and used on the new task queue. > > - BitrateAllocator is now created on libjingle's worker thread but always used on the new task queue instead of both encoder threads and the process thread. > > - VideoEncoderConfig and VideoSendStream::Config support move semantics. > > - The encoder thread is moved from VideoSendStream to ViEEncoder. Frames are forwarded directly to ViEEncoder which is responsible for timestamping ? and encoding the frames. > > BUG=webrtc:5687 > > Committed: https://crrev.com/cc168360f41322332860cb075edeb1cde21aa473 > Cr-Commit-Position: refs/heads/master@{#13767} TBR=tommi@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org,sprang@webrtc.org,pbos@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5687 Review-Url: https://codereview.webrtc.org/2248713003 Cr-Commit-Position: refs/heads/master@{#13774}
2016-08-16 02:40:55 -07:00
: encoder_(&process_thread_),
simulated_clock_(123456789),
encoder_state_feedback_(
&simulated_clock_,
std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc),
&encoder_) {}
protected:
const uint32_t kSsrc = 1234;
Revert of Add task queue to Call. (patchset #42 id:840001 of https://codereview.webrtc.org/2060403002/ ) Reason for revert: Failed on Win 10 Chrome FYI. https://build.chromium.org/p/chromium.webrtc.fyi/builders/Win10%20Tester/builds/3847/steps/content_browsertests/logs/stdio # # Fatal error in e:\b\c\b\win_builder\src\third_party\webrtc\base\task_queue_win.cc, line 138 # last system error: 87 # Check failed: ((DWORD)0xFFFFFFFF) != result (4294967295 vs. 4294967295) # WebRtcBrowserTest # Original issue's description: > - Add task queue to Call with the intent of replacing the use of one of the process threads. > > - Split VideoSendStream in two. VideoSendStreamInternal is created and used on the new task queue. > > - BitrateAllocator is now created on libjingle's worker thread but always used on the new task queue instead of both encoder threads and the process thread. > > - VideoEncoderConfig and VideoSendStream::Config support move semantics. > > - The encoder thread is moved from VideoSendStream to ViEEncoder. Frames are forwarded directly to ViEEncoder which is responsible for timestamping ? and encoding the frames. > > BUG=webrtc:5687 > > Committed: https://crrev.com/cc168360f41322332860cb075edeb1cde21aa473 > Cr-Commit-Position: refs/heads/master@{#13767} TBR=tommi@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org,sprang@webrtc.org,pbos@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5687 Review-Url: https://codereview.webrtc.org/2248713003 Cr-Commit-Position: refs/heads/master@{#13774}
2016-08-16 02:40:55 -07:00
NiceMock<MockProcessThread> process_thread_;
MockVieEncoder encoder_;
SimulatedClock simulated_clock_;
EncoderStateFeedback encoder_state_feedback_;
};
TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) {
EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1);
encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
const uint8_t sli_picture_id = 3;
EXPECT_CALL(encoder_, OnReceivedSLI(sli_picture_id)).Times(1);
encoder_state_feedback_.OnReceivedSLI(kSsrc, sli_picture_id);
const uint64_t rpsi_picture_id = 9;
EXPECT_CALL(encoder_, OnReceivedRPSI(rpsi_picture_id)).Times(1);
encoder_state_feedback_.OnReceivedRPSI(kSsrc, rpsi_picture_id);
}
TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) {
EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1);
encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
simulated_clock_.AdvanceTimeMilliseconds(10);
encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1);
simulated_clock_.AdvanceTimeMilliseconds(300);
encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc);
}
} // namespace webrtc