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

Side by Side Diff: webrtc/modules/video_coding/video_coding_robustness_unittest.cc

Issue 2744013002: Updates to VCMDecodedFrameCallback, VideoReceiver and a few related classes/tests. (Closed)
Patch Set: Update DCHECKs Created 3 years, 9 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
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 <memory> 11 #include <memory>
12 12
13 #include "webrtc/modules/video_coding/include/mock/mock_vcm_callbacks.h" 13 #include "webrtc/modules/video_coding/include/mock/mock_vcm_callbacks.h"
14 #include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h" 14 #include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h"
15 #include "webrtc/modules/video_coding/include/video_coding.h" 15 #include "webrtc/modules/video_coding/include/video_coding.h"
16 #include "webrtc/modules/video_coding/test/test_util.h" 16 #include "webrtc/modules/video_coding/test/test_util.h"
17 #include "webrtc/system_wrappers/include/clock.h" 17 #include "webrtc/system_wrappers/include/clock.h"
18 #include "webrtc/test/gmock.h" 18 #include "webrtc/test/gmock.h"
19 #include "webrtc/test/gtest.h" 19 #include "webrtc/test/gtest.h"
20 20
21 namespace webrtc { 21 namespace webrtc {
22 22
23 using ::testing::_;
24 using ::testing::AllOf;
25 using ::testing::AnyNumber;
26 using ::testing::Args;
27 using ::testing::ElementsAre;
28 using ::testing::Field;
29 using ::testing::NiceMock;
30 using ::testing::Pointee;
23 using ::testing::Return; 31 using ::testing::Return;
24 using ::testing::_;
25 using ::testing::ElementsAre;
26 using ::testing::AllOf;
27 using ::testing::Args;
28 using ::testing::Field;
29 using ::testing::Pointee;
30 using ::testing::NiceMock;
31 using ::testing::Sequence; 32 using ::testing::Sequence;
32 33
33 class VCMRobustnessTest : public ::testing::Test { 34 class VCMRobustnessTest : public ::testing::Test {
34 protected: 35 protected:
35 static const size_t kPayloadLen = 10; 36 static const size_t kPayloadLen = 10;
36 37
37 virtual void SetUp() { 38 virtual void SetUp() {
38 clock_.reset(new SimulatedClock(0)); 39 clock_.reset(new SimulatedClock(0));
39 ASSERT_TRUE(clock_.get() != NULL); 40 ASSERT_TRUE(clock_.get() != NULL);
40 vcm_.reset(VideoCodingModule::Create(clock_.get(), &event_factory_)); 41 vcm_.reset(VideoCodingModule::Create(clock_.get(), &event_factory_));
41 ASSERT_TRUE(vcm_ != NULL); 42 ASSERT_TRUE(vcm_ != NULL);
42 const size_t kMaxNackListSize = 250; 43 const size_t kMaxNackListSize = 250;
43 const int kMaxPacketAgeToNack = 450; 44 const int kMaxPacketAgeToNack = 450;
44 vcm_->SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, 0); 45 vcm_->SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, 0);
45 ASSERT_EQ(0, vcm_->RegisterFrameTypeCallback(&frame_type_callback_)); 46 ASSERT_EQ(0, vcm_->RegisterFrameTypeCallback(&frame_type_callback_));
46 ASSERT_EQ(0, vcm_->RegisterPacketRequestCallback(&request_callback_)); 47 ASSERT_EQ(0, vcm_->RegisterPacketRequestCallback(&request_callback_));
47 VideoCodingModule::Codec(kVideoCodecVP8, &video_codec_); 48 VideoCodingModule::Codec(kVideoCodecVP8, &video_codec_);
48 ASSERT_EQ(VCM_OK, vcm_->RegisterReceiveCodec(&video_codec_, 1)); 49 ASSERT_EQ(VCM_OK, vcm_->RegisterReceiveCodec(&video_codec_, 1));
49 vcm_->RegisterExternalDecoder(&decoder_, video_codec_.plType); 50 vcm_->RegisterExternalDecoder(&decoder_, video_codec_.plType);
51
52 // Since we call Decode, we need to provide a valid receive callback.
53 // However, for the purposes of these tests, we ignore the callbacks.
54 EXPECT_CALL(receive_callback_, OnIncomingPayloadType(_)).Times(AnyNumber());
55 EXPECT_CALL(receive_callback_, OnDecoderImplementationName(_))
56 .Times(AnyNumber());
57 vcm_->RegisterReceiveCallback(&receive_callback_);
50 } 58 }
51 59
52 virtual void TearDown() { vcm_.reset(); } 60 virtual void TearDown() { vcm_.reset(); }
53 61
54 void InsertPacket(uint32_t timestamp, 62 void InsertPacket(uint32_t timestamp,
55 uint16_t seq_no, 63 uint16_t seq_no,
56 bool first, 64 bool first,
57 bool marker_bit, 65 bool marker_bit,
58 FrameType frame_type) { 66 FrameType frame_type) {
59 const uint8_t payload[kPayloadLen] = {0}; 67 const uint8_t payload[kPayloadLen] = {0};
60 WebRtcRTPHeader rtp_info; 68 WebRtcRTPHeader rtp_info;
61 memset(&rtp_info, 0, sizeof(rtp_info)); 69 memset(&rtp_info, 0, sizeof(rtp_info));
62 rtp_info.frameType = frame_type; 70 rtp_info.frameType = frame_type;
63 rtp_info.header.timestamp = timestamp; 71 rtp_info.header.timestamp = timestamp;
64 rtp_info.header.sequenceNumber = seq_no; 72 rtp_info.header.sequenceNumber = seq_no;
65 rtp_info.header.markerBit = marker_bit; 73 rtp_info.header.markerBit = marker_bit;
66 rtp_info.header.payloadType = video_codec_.plType; 74 rtp_info.header.payloadType = video_codec_.plType;
67 rtp_info.type.Video.codec = kRtpVideoVp8; 75 rtp_info.type.Video.codec = kRtpVideoVp8;
68 rtp_info.type.Video.codecHeader.VP8.InitRTPVideoHeaderVP8(); 76 rtp_info.type.Video.codecHeader.VP8.InitRTPVideoHeaderVP8();
69 rtp_info.type.Video.is_first_packet_in_frame = first; 77 rtp_info.type.Video.is_first_packet_in_frame = first;
70 78
71 ASSERT_EQ(VCM_OK, vcm_->IncomingPacket(payload, kPayloadLen, rtp_info)); 79 ASSERT_EQ(VCM_OK, vcm_->IncomingPacket(payload, kPayloadLen, rtp_info));
72 } 80 }
73 81
74 std::unique_ptr<VideoCodingModule> vcm_; 82 std::unique_ptr<VideoCodingModule> vcm_;
83 MockVCMReceiveCallback receive_callback_;
75 VideoCodec video_codec_; 84 VideoCodec video_codec_;
76 MockVCMFrameTypeCallback frame_type_callback_; 85 MockVCMFrameTypeCallback frame_type_callback_;
77 MockPacketRequestCallback request_callback_; 86 MockPacketRequestCallback request_callback_;
78 NiceMock<MockVideoDecoder> decoder_; 87 NiceMock<MockVideoDecoder> decoder_;
79 NiceMock<MockVideoDecoder> decoderCopy_; 88 NiceMock<MockVideoDecoder> decoderCopy_;
80 std::unique_ptr<SimulatedClock> clock_; 89 std::unique_ptr<SimulatedClock> clock_;
81 NullEventFactory event_factory_; 90 NullEventFactory event_factory_;
82 }; 91 };
83 92
84 TEST_F(VCMRobustnessTest, TestHardNack) { 93 TEST_F(VCMRobustnessTest, TestHardNack) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 228
220 clock_->AdvanceTimeMilliseconds(23); 229 clock_->AdvanceTimeMilliseconds(23);
221 InsertPacket(3000, 4, false, false, kVideoFrameDelta); 230 InsertPacket(3000, 4, false, false, kVideoFrameDelta);
222 231
223 InsertPacket(9000, 9, true, false, kVideoFrameDelta); 232 InsertPacket(9000, 9, true, false, kVideoFrameDelta);
224 InsertPacket(9000, 10, false, false, kVideoFrameDelta); 233 InsertPacket(9000, 10, false, false, kVideoFrameDelta);
225 InsertPacket(9000, 11, false, true, kVideoFrameDelta); 234 InsertPacket(9000, 11, false, true, kVideoFrameDelta);
226 EXPECT_EQ(VCM_OK, vcm_->Decode(33)); // Decode timestamp 9000 complete. 235 EXPECT_EQ(VCM_OK, vcm_->Decode(33)); // Decode timestamp 9000 complete.
227 } 236 }
228 } // namespace webrtc 237 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/video_coding_impl.cc ('k') | webrtc/modules/video_coding/video_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698