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

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

Issue 2007743003: Add sender controlled playout delay limits (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@cleanup_rtp_hdr_extensions
Patch Set: Rename OnReceivedRtcpReport to OnReceivedRtcpReportBlocks Created 4 years, 6 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) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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
(...skipping 24 matching lines...) Expand all
35 35
36 class Vp9SsMapTest : public ::testing::Test { 36 class Vp9SsMapTest : public ::testing::Test {
37 protected: 37 protected:
38 Vp9SsMapTest() : packet_(data_, 1400, 1234, 1, true) {} 38 Vp9SsMapTest() : packet_(data_, 1400, 1234, 1, true) {}
39 39
40 virtual void SetUp() { 40 virtual void SetUp() {
41 packet_.isFirstPacket = true; 41 packet_.isFirstPacket = true;
42 packet_.markerBit = true; 42 packet_.markerBit = true;
43 packet_.frameType = kVideoFrameKey; 43 packet_.frameType = kVideoFrameKey;
44 packet_.codec = kVideoCodecVP9; 44 packet_.codec = kVideoCodecVP9;
45 packet_.codecSpecificHeader.codec = kRtpVideoVp9; 45 packet_.video_header.codec = kRtpVideoVp9;
46 packet_.codecSpecificHeader.codecHeader.VP9.flexible_mode = false; 46 packet_.video_header.codecHeader.VP9.flexible_mode = false;
47 packet_.codecSpecificHeader.codecHeader.VP9.gof_idx = 0; 47 packet_.video_header.codecHeader.VP9.gof_idx = 0;
48 packet_.codecSpecificHeader.codecHeader.VP9.temporal_idx = kNoTemporalIdx; 48 packet_.video_header.codecHeader.VP9.temporal_idx = kNoTemporalIdx;
49 packet_.codecSpecificHeader.codecHeader.VP9.temporal_up_switch = false; 49 packet_.video_header.codecHeader.VP9.temporal_up_switch = false;
50 packet_.codecSpecificHeader.codecHeader.VP9.ss_data_available = true; 50 packet_.video_header.codecHeader.VP9.ss_data_available = true;
51 packet_.codecSpecificHeader.codecHeader.VP9.gof.SetGofInfoVP9( 51 packet_.video_header.codecHeader.VP9.gof.SetGofInfoVP9(
52 kTemporalStructureMode3); // kTemporalStructureMode3: 0-2-1-2.. 52 kTemporalStructureMode3); // kTemporalStructureMode3: 0-2-1-2..
53 } 53 }
54 54
55 Vp9SsMap map_; 55 Vp9SsMap map_;
56 uint8_t data_[1500]; 56 uint8_t data_[1500];
57 VCMPacket packet_; 57 VCMPacket packet_;
58 }; 58 };
59 59
60 TEST_F(Vp9SsMapTest, Insert) { 60 TEST_F(Vp9SsMapTest, Insert) {
61 EXPECT_TRUE(map_.Insert(packet_)); 61 EXPECT_TRUE(map_.Insert(packet_));
62 } 62 }
63 63
64 TEST_F(Vp9SsMapTest, Insert_NoSsData) { 64 TEST_F(Vp9SsMapTest, Insert_NoSsData) {
65 packet_.codecSpecificHeader.codecHeader.VP9.ss_data_available = false; 65 packet_.video_header.codecHeader.VP9.ss_data_available = false;
66 EXPECT_FALSE(map_.Insert(packet_)); 66 EXPECT_FALSE(map_.Insert(packet_));
67 } 67 }
68 68
69 TEST_F(Vp9SsMapTest, Find) { 69 TEST_F(Vp9SsMapTest, Find) {
70 EXPECT_TRUE(map_.Insert(packet_)); 70 EXPECT_TRUE(map_.Insert(packet_));
71 Vp9SsMap::SsMap::iterator it; 71 Vp9SsMap::SsMap::iterator it;
72 EXPECT_TRUE(map_.Find(packet_.timestamp, &it)); 72 EXPECT_TRUE(map_.Find(packet_.timestamp, &it));
73 EXPECT_EQ(packet_.timestamp, it->first); 73 EXPECT_EQ(packet_.timestamp, it->first);
74 } 74 }
75 75
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 packet_.timestamp = kSsTimestamp3; 132 packet_.timestamp = kSsTimestamp3;
133 EXPECT_TRUE(map_.Insert(packet_)); 133 EXPECT_TRUE(map_.Insert(packet_));
134 134
135 map_.RemoveOld(kSsTimestamp3); 135 map_.RemoveOld(kSsTimestamp3);
136 EXPECT_FALSE(map_.Find(kSsTimestamp1, &it)); 136 EXPECT_FALSE(map_.Find(kSsTimestamp1, &it));
137 EXPECT_FALSE(map_.Find(kSsTimestamp2, &it)); 137 EXPECT_FALSE(map_.Find(kSsTimestamp2, &it));
138 EXPECT_TRUE(map_.Find(kSsTimestamp3, &it)); 138 EXPECT_TRUE(map_.Find(kSsTimestamp3, &it));
139 } 139 }
140 140
141 TEST_F(Vp9SsMapTest, UpdatePacket_NoSsData) { 141 TEST_F(Vp9SsMapTest, UpdatePacket_NoSsData) {
142 packet_.codecSpecificHeader.codecHeader.VP9.gof_idx = 0; 142 packet_.video_header.codecHeader.VP9.gof_idx = 0;
143 EXPECT_FALSE(map_.UpdatePacket(&packet_)); 143 EXPECT_FALSE(map_.UpdatePacket(&packet_));
144 } 144 }
145 145
146 TEST_F(Vp9SsMapTest, UpdatePacket_NoGofIdx) { 146 TEST_F(Vp9SsMapTest, UpdatePacket_NoGofIdx) {
147 EXPECT_TRUE(map_.Insert(packet_)); 147 EXPECT_TRUE(map_.Insert(packet_));
148 packet_.codecSpecificHeader.codecHeader.VP9.gof_idx = kNoGofIdx; 148 packet_.video_header.codecHeader.VP9.gof_idx = kNoGofIdx;
149 EXPECT_FALSE(map_.UpdatePacket(&packet_)); 149 EXPECT_FALSE(map_.UpdatePacket(&packet_));
150 } 150 }
151 151
152 TEST_F(Vp9SsMapTest, UpdatePacket_InvalidGofIdx) { 152 TEST_F(Vp9SsMapTest, UpdatePacket_InvalidGofIdx) {
153 EXPECT_TRUE(map_.Insert(packet_)); 153 EXPECT_TRUE(map_.Insert(packet_));
154 packet_.codecSpecificHeader.codecHeader.VP9.gof_idx = 4; 154 packet_.video_header.codecHeader.VP9.gof_idx = 4;
155 EXPECT_FALSE(map_.UpdatePacket(&packet_)); 155 EXPECT_FALSE(map_.UpdatePacket(&packet_));
156 } 156 }
157 157
158 TEST_F(Vp9SsMapTest, UpdatePacket) { 158 TEST_F(Vp9SsMapTest, UpdatePacket) {
159 EXPECT_TRUE(map_.Insert(packet_)); // kTemporalStructureMode3: 0-2-1-2.. 159 EXPECT_TRUE(map_.Insert(packet_)); // kTemporalStructureMode3: 0-2-1-2..
160 160
161 packet_.codecSpecificHeader.codecHeader.VP9.gof_idx = 0; 161 packet_.video_header.codecHeader.VP9.gof_idx = 0;
162 EXPECT_TRUE(map_.UpdatePacket(&packet_)); 162 EXPECT_TRUE(map_.UpdatePacket(&packet_));
163 EXPECT_EQ(0, packet_.codecSpecificHeader.codecHeader.VP9.temporal_idx); 163 EXPECT_EQ(0, packet_.video_header.codecHeader.VP9.temporal_idx);
164 EXPECT_FALSE(packet_.codecSpecificHeader.codecHeader.VP9.temporal_up_switch); 164 EXPECT_FALSE(packet_.video_header.codecHeader.VP9.temporal_up_switch);
165 EXPECT_EQ(1U, packet_.codecSpecificHeader.codecHeader.VP9.num_ref_pics); 165 EXPECT_EQ(1U, packet_.video_header.codecHeader.VP9.num_ref_pics);
166 EXPECT_EQ(4, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[0]); 166 EXPECT_EQ(4, packet_.video_header.codecHeader.VP9.pid_diff[0]);
167 167
168 packet_.codecSpecificHeader.codecHeader.VP9.gof_idx = 1; 168 packet_.video_header.codecHeader.VP9.gof_idx = 1;
169 EXPECT_TRUE(map_.UpdatePacket(&packet_)); 169 EXPECT_TRUE(map_.UpdatePacket(&packet_));
170 EXPECT_EQ(2, packet_.codecSpecificHeader.codecHeader.VP9.temporal_idx); 170 EXPECT_EQ(2, packet_.video_header.codecHeader.VP9.temporal_idx);
171 EXPECT_TRUE(packet_.codecSpecificHeader.codecHeader.VP9.temporal_up_switch); 171 EXPECT_TRUE(packet_.video_header.codecHeader.VP9.temporal_up_switch);
172 EXPECT_EQ(1U, packet_.codecSpecificHeader.codecHeader.VP9.num_ref_pics); 172 EXPECT_EQ(1U, packet_.video_header.codecHeader.VP9.num_ref_pics);
173 EXPECT_EQ(1, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[0]); 173 EXPECT_EQ(1, packet_.video_header.codecHeader.VP9.pid_diff[0]);
174 174
175 packet_.codecSpecificHeader.codecHeader.VP9.gof_idx = 2; 175 packet_.video_header.codecHeader.VP9.gof_idx = 2;
176 EXPECT_TRUE(map_.UpdatePacket(&packet_)); 176 EXPECT_TRUE(map_.UpdatePacket(&packet_));
177 EXPECT_EQ(1, packet_.codecSpecificHeader.codecHeader.VP9.temporal_idx); 177 EXPECT_EQ(1, packet_.video_header.codecHeader.VP9.temporal_idx);
178 EXPECT_TRUE(packet_.codecSpecificHeader.codecHeader.VP9.temporal_up_switch); 178 EXPECT_TRUE(packet_.video_header.codecHeader.VP9.temporal_up_switch);
179 EXPECT_EQ(1U, packet_.codecSpecificHeader.codecHeader.VP9.num_ref_pics); 179 EXPECT_EQ(1U, packet_.video_header.codecHeader.VP9.num_ref_pics);
180 EXPECT_EQ(2, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[0]); 180 EXPECT_EQ(2, packet_.video_header.codecHeader.VP9.pid_diff[0]);
181 181
182 packet_.codecSpecificHeader.codecHeader.VP9.gof_idx = 3; 182 packet_.video_header.codecHeader.VP9.gof_idx = 3;
183 EXPECT_TRUE(map_.UpdatePacket(&packet_)); 183 EXPECT_TRUE(map_.UpdatePacket(&packet_));
184 EXPECT_EQ(2, packet_.codecSpecificHeader.codecHeader.VP9.temporal_idx); 184 EXPECT_EQ(2, packet_.video_header.codecHeader.VP9.temporal_idx);
185 EXPECT_FALSE(packet_.codecSpecificHeader.codecHeader.VP9.temporal_up_switch); 185 EXPECT_FALSE(packet_.video_header.codecHeader.VP9.temporal_up_switch);
186 EXPECT_EQ(2U, packet_.codecSpecificHeader.codecHeader.VP9.num_ref_pics); 186 EXPECT_EQ(2U, packet_.video_header.codecHeader.VP9.num_ref_pics);
187 EXPECT_EQ(1, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[0]); 187 EXPECT_EQ(1, packet_.video_header.codecHeader.VP9.pid_diff[0]);
188 EXPECT_EQ(2, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[1]); 188 EXPECT_EQ(2, packet_.video_header.codecHeader.VP9.pid_diff[1]);
189 } 189 }
190 190
191 class ProcessThreadMock : public ProcessThread { 191 class ProcessThreadMock : public ProcessThread {
192 public: 192 public:
193 MOCK_METHOD0(Start, void()); 193 MOCK_METHOD0(Start, void());
194 MOCK_METHOD0(Stop, void()); 194 MOCK_METHOD0(Stop, void());
195 MOCK_METHOD1(WakeUp, void(Module* module)); 195 MOCK_METHOD1(WakeUp, void(Module* module));
196 MOCK_METHOD1(RegisterModule, void(Module* module)); 196 MOCK_METHOD1(RegisterModule, void(Module* module));
197 MOCK_METHOD1(DeRegisterModule, void(Module* module)); 197 MOCK_METHOD1(DeRegisterModule, void(Module* module));
198 void PostTask(std::unique_ptr<rtc::QueuedTask> task) /*override*/ {} 198 void PostTask(std::unique_ptr<rtc::QueuedTask> task) /*override*/ {}
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 data_[i + 2] = 0; 239 data_[i + 2] = 0;
240 data_[i + 3] = 0x80; 240 data_[i + 3] = 0x80;
241 count = 3; 241 count = 3;
242 i += 3; 242 i += 3;
243 } 243 }
244 } 244 }
245 packet_.reset(new VCMPacket(data_, size_, seq_num_, timestamp_, true)); 245 packet_.reset(new VCMPacket(data_, size_, seq_num_, timestamp_, true));
246 } 246 }
247 247
248 VCMEncodedFrame* DecodeCompleteFrame() { 248 VCMEncodedFrame* DecodeCompleteFrame() {
249 uint32_t timestamp = 0; 249 VCMEncodedFrame* found_frame = jitter_buffer_->NextCompleteFrame(10);
250 bool found_frame = jitter_buffer_->NextCompleteTimestamp(10, &timestamp);
251 if (!found_frame) 250 if (!found_frame)
252 return NULL; 251 return nullptr;
253 VCMEncodedFrame* frame = jitter_buffer_->ExtractAndSetDecode(timestamp); 252 return jitter_buffer_->ExtractAndSetDecode(found_frame->TimeStamp());
254 return frame;
255 } 253 }
256 254
257 VCMEncodedFrame* DecodeIncompleteFrame() { 255 VCMEncodedFrame* DecodeIncompleteFrame() {
258 uint32_t timestamp = 0; 256 uint32_t timestamp = 0;
259 bool found_frame = jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp); 257 bool found_frame = jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp);
260 if (!found_frame) 258 if (!found_frame)
261 return NULL; 259 return NULL;
262 VCMEncodedFrame* frame = jitter_buffer_->ExtractAndSetDecode(timestamp); 260 VCMEncodedFrame* frame = jitter_buffer_->ExtractAndSetDecode(timestamp);
263 return frame; 261 return frame;
264 } 262 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 400
403 void DropFrame(int num_packets) { 401 void DropFrame(int num_packets) {
404 stream_generator_->GenerateFrame(kVideoFrameDelta, num_packets, 0, 402 stream_generator_->GenerateFrame(kVideoFrameDelta, num_packets, 0,
405 clock_->TimeInMilliseconds()); 403 clock_->TimeInMilliseconds());
406 for (int i = 0; i < num_packets; ++i) 404 for (int i = 0; i < num_packets; ++i)
407 stream_generator_->DropLastPacket(); 405 stream_generator_->DropLastPacket();
408 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); 406 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs);
409 } 407 }
410 408
411 bool DecodeCompleteFrame() { 409 bool DecodeCompleteFrame() {
412 uint32_t timestamp = 0; 410 VCMEncodedFrame* found_frame = jitter_buffer_->NextCompleteFrame(0);
413 bool found_frame = jitter_buffer_->NextCompleteTimestamp(0, &timestamp);
414 if (!found_frame) 411 if (!found_frame)
415 return false; 412 return false;
416 413
417 VCMEncodedFrame* frame = jitter_buffer_->ExtractAndSetDecode(timestamp); 414 VCMEncodedFrame* frame =
415 jitter_buffer_->ExtractAndSetDecode(found_frame->TimeStamp());
418 bool ret = (frame != NULL); 416 bool ret = (frame != NULL);
419 jitter_buffer_->ReleaseFrame(frame); 417 jitter_buffer_->ReleaseFrame(frame);
420 return ret; 418 return ret;
421 } 419 }
422 420
423 bool DecodeIncompleteFrame() { 421 bool DecodeIncompleteFrame() {
424 uint32_t timestamp = 0; 422 uint32_t timestamp = 0;
425 bool found_frame = jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp); 423 bool found_frame = jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp);
426 if (!found_frame) 424 if (!found_frame)
427 return false; 425 return false;
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 // ------------------------------------------------- 923 // -------------------------------------------------
926 // | 65485 | 65486 | 65487 | 65488 | 65489 | ... 924 // | 65485 | 65486 | 65487 | 65488 | 65489 | ...
927 // | pid:5 | pid:6 | pid:7 | pid:8 | pid:9 | ... 925 // | pid:5 | pid:6 | pid:7 | pid:8 | pid:9 | ...
928 // | tid:0 | tid:2 | tid:1 | tid:2 | tid:0 | ... 926 // | tid:0 | tid:2 | tid:1 | tid:2 | tid:0 | ...
929 // | ss | x | x | x | | 927 // | ss | x | x | x | |
930 // ------------------------------------------------- 928 // -------------------------------------------------
931 // |<----------tl0idx:200--------->|<---tl0idx:201--- 929 // |<----------tl0idx:200--------->|<---tl0idx:201---
932 930
933 bool re = false; 931 bool re = false;
934 packet_->codec = kVideoCodecVP9; 932 packet_->codec = kVideoCodecVP9;
935 packet_->codecSpecificHeader.codec = kRtpVideoVp9; 933 packet_->video_header.codec = kRtpVideoVp9;
936 packet_->isFirstPacket = true; 934 packet_->isFirstPacket = true;
937 packet_->markerBit = true; 935 packet_->markerBit = true;
938 packet_->codecSpecificHeader.codecHeader.VP9.flexible_mode = false; 936 packet_->video_header.codecHeader.VP9.flexible_mode = false;
939 packet_->codecSpecificHeader.codecHeader.VP9.spatial_idx = 0; 937 packet_->video_header.codecHeader.VP9.spatial_idx = 0;
940 packet_->codecSpecificHeader.codecHeader.VP9.beginning_of_frame = true; 938 packet_->video_header.codecHeader.VP9.beginning_of_frame = true;
941 packet_->codecSpecificHeader.codecHeader.VP9.end_of_frame = true; 939 packet_->video_header.codecHeader.VP9.end_of_frame = true;
942 packet_->codecSpecificHeader.codecHeader.VP9.temporal_up_switch = false; 940 packet_->video_header.codecHeader.VP9.temporal_up_switch = false;
943 941
944 packet_->seqNum = 65485; 942 packet_->seqNum = 65485;
945 packet_->timestamp = 1000; 943 packet_->timestamp = 1000;
946 packet_->frameType = kVideoFrameKey; 944 packet_->frameType = kVideoFrameKey;
947 packet_->codecSpecificHeader.codecHeader.VP9.picture_id = 5; 945 packet_->video_header.codecHeader.VP9.picture_id = 5;
948 packet_->codecSpecificHeader.codecHeader.VP9.tl0_pic_idx = 200; 946 packet_->video_header.codecHeader.VP9.tl0_pic_idx = 200;
949 packet_->codecSpecificHeader.codecHeader.VP9.temporal_idx = 0; 947 packet_->video_header.codecHeader.VP9.temporal_idx = 0;
950 packet_->codecSpecificHeader.codecHeader.VP9.ss_data_available = true; 948 packet_->video_header.codecHeader.VP9.ss_data_available = true;
951 packet_->codecSpecificHeader.codecHeader.VP9.gof.SetGofInfoVP9( 949 packet_->video_header.codecHeader.VP9.gof.SetGofInfoVP9(
952 kTemporalStructureMode3); // kTemporalStructureMode3: 0-2-1-2.. 950 kTemporalStructureMode3); // kTemporalStructureMode3: 0-2-1-2..
953 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re)); 951 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re));
954 952
955 // Insert next temporal layer 0. 953 // Insert next temporal layer 0.
956 packet_->seqNum = 65489; 954 packet_->seqNum = 65489;
957 packet_->timestamp = 13000; 955 packet_->timestamp = 13000;
958 packet_->frameType = kVideoFrameDelta; 956 packet_->frameType = kVideoFrameDelta;
959 packet_->codecSpecificHeader.codecHeader.VP9.picture_id = 9; 957 packet_->video_header.codecHeader.VP9.picture_id = 9;
960 packet_->codecSpecificHeader.codecHeader.VP9.tl0_pic_idx = 201; 958 packet_->video_header.codecHeader.VP9.tl0_pic_idx = 201;
961 packet_->codecSpecificHeader.codecHeader.VP9.temporal_idx = 0; 959 packet_->video_header.codecHeader.VP9.temporal_idx = 0;
962 packet_->codecSpecificHeader.codecHeader.VP9.ss_data_available = false; 960 packet_->video_header.codecHeader.VP9.ss_data_available = false;
963 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re)); 961 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re));
964 962
965 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 963 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
966 EXPECT_EQ(1000U, frame_out->TimeStamp()); 964 EXPECT_EQ(1000U, frame_out->TimeStamp());
967 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 965 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
968 jitter_buffer_->ReleaseFrame(frame_out); 966 jitter_buffer_->ReleaseFrame(frame_out);
969 967
970 frame_out = DecodeCompleteFrame(); 968 frame_out = DecodeCompleteFrame();
971 EXPECT_EQ(13000U, frame_out->TimeStamp()); 969 EXPECT_EQ(13000U, frame_out->TimeStamp());
972 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 970 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
973 jitter_buffer_->ReleaseFrame(frame_out); 971 jitter_buffer_->ReleaseFrame(frame_out);
974 } 972 }
975 973
976 TEST_P(TestBasicJitterBuffer, ReorderedVp9SsData_3TlLayers) { 974 TEST_P(TestBasicJitterBuffer, ReorderedVp9SsData_3TlLayers) {
977 // Verify that frames are updated with SS data when SS packet is reordered. 975 // Verify that frames are updated with SS data when SS packet is reordered.
978 // -------------------------------- 976 // --------------------------------
979 // | 65486 | 65487 | 65485 |... 977 // | 65486 | 65487 | 65485 |...
980 // | pid:6 | pid:7 | pid:5 |... 978 // | pid:6 | pid:7 | pid:5 |...
981 // | tid:2 | tid:1 | tid:0 |... 979 // | tid:2 | tid:1 | tid:0 |...
982 // | | | ss | 980 // | | | ss |
983 // -------------------------------- 981 // --------------------------------
984 // |<--------tl0idx:200--------->| 982 // |<--------tl0idx:200--------->|
985 983
986 bool re = false; 984 bool re = false;
987 packet_->codec = kVideoCodecVP9; 985 packet_->codec = kVideoCodecVP9;
988 packet_->codecSpecificHeader.codec = kRtpVideoVp9; 986 packet_->video_header.codec = kRtpVideoVp9;
989 packet_->isFirstPacket = true; 987 packet_->isFirstPacket = true;
990 packet_->markerBit = true; 988 packet_->markerBit = true;
991 packet_->codecSpecificHeader.codecHeader.VP9.flexible_mode = false; 989 packet_->video_header.codecHeader.VP9.flexible_mode = false;
992 packet_->codecSpecificHeader.codecHeader.VP9.spatial_idx = 0; 990 packet_->video_header.codecHeader.VP9.spatial_idx = 0;
993 packet_->codecSpecificHeader.codecHeader.VP9.beginning_of_frame = true; 991 packet_->video_header.codecHeader.VP9.beginning_of_frame = true;
994 packet_->codecSpecificHeader.codecHeader.VP9.end_of_frame = true; 992 packet_->video_header.codecHeader.VP9.end_of_frame = true;
995 packet_->codecSpecificHeader.codecHeader.VP9.tl0_pic_idx = 200; 993 packet_->video_header.codecHeader.VP9.tl0_pic_idx = 200;
996 994
997 packet_->seqNum = 65486; 995 packet_->seqNum = 65486;
998 packet_->timestamp = 6000; 996 packet_->timestamp = 6000;
999 packet_->frameType = kVideoFrameDelta; 997 packet_->frameType = kVideoFrameDelta;
1000 packet_->codecSpecificHeader.codecHeader.VP9.picture_id = 6; 998 packet_->video_header.codecHeader.VP9.picture_id = 6;
1001 packet_->codecSpecificHeader.codecHeader.VP9.temporal_idx = 2; 999 packet_->video_header.codecHeader.VP9.temporal_idx = 2;
1002 packet_->codecSpecificHeader.codecHeader.VP9.temporal_up_switch = true; 1000 packet_->video_header.codecHeader.VP9.temporal_up_switch = true;
1003 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re)); 1001 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re));
1004 1002
1005 packet_->seqNum = 65487; 1003 packet_->seqNum = 65487;
1006 packet_->timestamp = 9000; 1004 packet_->timestamp = 9000;
1007 packet_->frameType = kVideoFrameDelta; 1005 packet_->frameType = kVideoFrameDelta;
1008 packet_->codecSpecificHeader.codecHeader.VP9.picture_id = 7; 1006 packet_->video_header.codecHeader.VP9.picture_id = 7;
1009 packet_->codecSpecificHeader.codecHeader.VP9.temporal_idx = 1; 1007 packet_->video_header.codecHeader.VP9.temporal_idx = 1;
1010 packet_->codecSpecificHeader.codecHeader.VP9.temporal_up_switch = true; 1008 packet_->video_header.codecHeader.VP9.temporal_up_switch = true;
1011 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re)); 1009 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re));
1012 1010
1013 // Insert first frame with SS data. 1011 // Insert first frame with SS data.
1014 packet_->seqNum = 65485; 1012 packet_->seqNum = 65485;
1015 packet_->timestamp = 3000; 1013 packet_->timestamp = 3000;
1016 packet_->frameType = kVideoFrameKey; 1014 packet_->frameType = kVideoFrameKey;
1017 packet_->width = 352; 1015 packet_->width = 352;
1018 packet_->height = 288; 1016 packet_->height = 288;
1019 packet_->codecSpecificHeader.codecHeader.VP9.picture_id = 5; 1017 packet_->video_header.codecHeader.VP9.picture_id = 5;
1020 packet_->codecSpecificHeader.codecHeader.VP9.temporal_idx = 0; 1018 packet_->video_header.codecHeader.VP9.temporal_idx = 0;
1021 packet_->codecSpecificHeader.codecHeader.VP9.temporal_up_switch = false; 1019 packet_->video_header.codecHeader.VP9.temporal_up_switch = false;
1022 packet_->codecSpecificHeader.codecHeader.VP9.ss_data_available = true; 1020 packet_->video_header.codecHeader.VP9.ss_data_available = true;
1023 packet_->codecSpecificHeader.codecHeader.VP9.gof.SetGofInfoVP9( 1021 packet_->video_header.codecHeader.VP9.gof.SetGofInfoVP9(
1024 kTemporalStructureMode3); // kTemporalStructureMode3: 0-2-1-2.. 1022 kTemporalStructureMode3); // kTemporalStructureMode3: 0-2-1-2..
1025 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re)); 1023 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re));
1026 1024
1027 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 1025 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
1028 EXPECT_EQ(3000U, frame_out->TimeStamp()); 1026 EXPECT_EQ(3000U, frame_out->TimeStamp());
1029 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 1027 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
1030 EXPECT_EQ(0, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx); 1028 EXPECT_EQ(0, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx);
1031 EXPECT_FALSE( 1029 EXPECT_FALSE(
1032 frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch); 1030 frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch);
1033 jitter_buffer_->ReleaseFrame(frame_out); 1031 jitter_buffer_->ReleaseFrame(frame_out);
(...skipping 20 matching lines...) Expand all
1054 // | pid:6 | pid:6 | pid:5 | pid:5 |... 1052 // | pid:6 | pid:6 | pid:5 | pid:5 |...
1055 // | tid:1 | tid:1 | tid:0 | tid:0 |... 1053 // | tid:1 | tid:1 | tid:0 | tid:0 |...
1056 // | sid:0 | sid:1 | sid:1 | sid:0 |... 1054 // | sid:0 | sid:1 | sid:1 | sid:0 |...
1057 // | t:6000 | t:6000 | t:3000 | t:3000 | 1055 // | t:6000 | t:6000 | t:3000 | t:3000 |
1058 // | | | | ss | 1056 // | | | | ss |
1059 // ----------------------------------------- 1057 // -----------------------------------------
1060 // |<-----------tl0idx:200------------>| 1058 // |<-----------tl0idx:200------------>|
1061 1059
1062 bool re = false; 1060 bool re = false;
1063 packet_->codec = kVideoCodecVP9; 1061 packet_->codec = kVideoCodecVP9;
1064 packet_->codecSpecificHeader.codec = kRtpVideoVp9; 1062 packet_->video_header.codec = kRtpVideoVp9;
1065 packet_->codecSpecificHeader.codecHeader.VP9.flexible_mode = false; 1063 packet_->video_header.codecHeader.VP9.flexible_mode = false;
1066 packet_->codecSpecificHeader.codecHeader.VP9.beginning_of_frame = true; 1064 packet_->video_header.codecHeader.VP9.beginning_of_frame = true;
1067 packet_->codecSpecificHeader.codecHeader.VP9.end_of_frame = true; 1065 packet_->video_header.codecHeader.VP9.end_of_frame = true;
1068 packet_->codecSpecificHeader.codecHeader.VP9.tl0_pic_idx = 200; 1066 packet_->video_header.codecHeader.VP9.tl0_pic_idx = 200;
1069 1067
1070 packet_->isFirstPacket = true; 1068 packet_->isFirstPacket = true;
1071 packet_->markerBit = false; 1069 packet_->markerBit = false;
1072 packet_->seqNum = 65486; 1070 packet_->seqNum = 65486;
1073 packet_->timestamp = 6000; 1071 packet_->timestamp = 6000;
1074 packet_->frameType = kVideoFrameDelta; 1072 packet_->frameType = kVideoFrameDelta;
1075 packet_->codecSpecificHeader.codecHeader.VP9.spatial_idx = 0; 1073 packet_->video_header.codecHeader.VP9.spatial_idx = 0;
1076 packet_->codecSpecificHeader.codecHeader.VP9.picture_id = 6; 1074 packet_->video_header.codecHeader.VP9.picture_id = 6;
1077 packet_->codecSpecificHeader.codecHeader.VP9.temporal_idx = 1; 1075 packet_->video_header.codecHeader.VP9.temporal_idx = 1;
1078 packet_->codecSpecificHeader.codecHeader.VP9.temporal_up_switch = true; 1076 packet_->video_header.codecHeader.VP9.temporal_up_switch = true;
1079 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(*packet_, &re)); 1077 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(*packet_, &re));
1080 1078
1081 packet_->isFirstPacket = false; 1079 packet_->isFirstPacket = false;
1082 packet_->markerBit = true; 1080 packet_->markerBit = true;
1083 packet_->seqNum = 65487; 1081 packet_->seqNum = 65487;
1084 packet_->frameType = kVideoFrameDelta; 1082 packet_->frameType = kVideoFrameDelta;
1085 packet_->codecSpecificHeader.codecHeader.VP9.spatial_idx = 1; 1083 packet_->video_header.codecHeader.VP9.spatial_idx = 1;
1086 packet_->codecSpecificHeader.codecHeader.VP9.picture_id = 6; 1084 packet_->video_header.codecHeader.VP9.picture_id = 6;
1087 packet_->codecSpecificHeader.codecHeader.VP9.temporal_idx = 1; 1085 packet_->video_header.codecHeader.VP9.temporal_idx = 1;
1088 packet_->codecSpecificHeader.codecHeader.VP9.temporal_up_switch = true; 1086 packet_->video_header.codecHeader.VP9.temporal_up_switch = true;
1089 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re)); 1087 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re));
1090 1088
1091 packet_->isFirstPacket = false; 1089 packet_->isFirstPacket = false;
1092 packet_->markerBit = true; 1090 packet_->markerBit = true;
1093 packet_->seqNum = 65485; 1091 packet_->seqNum = 65485;
1094 packet_->timestamp = 3000; 1092 packet_->timestamp = 3000;
1095 packet_->frameType = kVideoFrameKey; 1093 packet_->frameType = kVideoFrameKey;
1096 packet_->codecSpecificHeader.codecHeader.VP9.spatial_idx = 1; 1094 packet_->video_header.codecHeader.VP9.spatial_idx = 1;
1097 packet_->codecSpecificHeader.codecHeader.VP9.picture_id = 5; 1095 packet_->video_header.codecHeader.VP9.picture_id = 5;
1098 packet_->codecSpecificHeader.codecHeader.VP9.temporal_idx = 0; 1096 packet_->video_header.codecHeader.VP9.temporal_idx = 0;
1099 packet_->codecSpecificHeader.codecHeader.VP9.temporal_up_switch = false; 1097 packet_->video_header.codecHeader.VP9.temporal_up_switch = false;
1100 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(*packet_, &re)); 1098 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(*packet_, &re));
1101 1099
1102 // Insert first frame with SS data. 1100 // Insert first frame with SS data.
1103 packet_->isFirstPacket = true; 1101 packet_->isFirstPacket = true;
1104 packet_->markerBit = false; 1102 packet_->markerBit = false;
1105 packet_->seqNum = 65484; 1103 packet_->seqNum = 65484;
1106 packet_->frameType = kVideoFrameKey; 1104 packet_->frameType = kVideoFrameKey;
1107 packet_->width = 352; 1105 packet_->width = 352;
1108 packet_->height = 288; 1106 packet_->height = 288;
1109 packet_->codecSpecificHeader.codecHeader.VP9.spatial_idx = 0; 1107 packet_->video_header.codecHeader.VP9.spatial_idx = 0;
1110 packet_->codecSpecificHeader.codecHeader.VP9.picture_id = 5; 1108 packet_->video_header.codecHeader.VP9.picture_id = 5;
1111 packet_->codecSpecificHeader.codecHeader.VP9.temporal_idx = 0; 1109 packet_->video_header.codecHeader.VP9.temporal_idx = 0;
1112 packet_->codecSpecificHeader.codecHeader.VP9.temporal_up_switch = false; 1110 packet_->video_header.codecHeader.VP9.temporal_up_switch = false;
1113 packet_->codecSpecificHeader.codecHeader.VP9.ss_data_available = true; 1111 packet_->video_header.codecHeader.VP9.ss_data_available = true;
1114 packet_->codecSpecificHeader.codecHeader.VP9.gof.SetGofInfoVP9( 1112 packet_->video_header.codecHeader.VP9.gof.SetGofInfoVP9(
1115 kTemporalStructureMode2); // kTemporalStructureMode3: 0-1-0-1.. 1113 kTemporalStructureMode2); // kTemporalStructureMode3: 0-1-0-1..
1116 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re)); 1114 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re));
1117 1115
1118 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 1116 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
1119 EXPECT_EQ(3000U, frame_out->TimeStamp()); 1117 EXPECT_EQ(3000U, frame_out->TimeStamp());
1120 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 1118 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
1121 EXPECT_EQ(0, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx); 1119 EXPECT_EQ(0, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx);
1122 EXPECT_FALSE( 1120 EXPECT_FALSE(
1123 frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch); 1121 frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch);
1124 jitter_buffer_->ReleaseFrame(frame_out); 1122 jitter_buffer_->ReleaseFrame(frame_out);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 packet_->frameType = kVideoFrameKey; 1168 packet_->frameType = kVideoFrameKey;
1171 packet_->isFirstPacket = true; 1169 packet_->isFirstPacket = true;
1172 packet_->markerBit = false; 1170 packet_->markerBit = false;
1173 packet_->seqNum = seq_num_; 1171 packet_->seqNum = seq_num_;
1174 packet_->timestamp = timestamp_; 1172 packet_->timestamp = timestamp_;
1175 1173
1176 bool retransmitted = false; 1174 bool retransmitted = false;
1177 EXPECT_EQ(kIncomplete, 1175 EXPECT_EQ(kIncomplete,
1178 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1176 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1179 uint32_t timestamp = 0; 1177 uint32_t timestamp = 0;
1180 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1178 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1181 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1179 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1182 1180
1183 packet_->isFirstPacket = false; 1181 packet_->isFirstPacket = false;
1184 for (int i = 1; i < 9; ++i) { 1182 for (int i = 1; i < 9; ++i) {
1185 packet_->seqNum++; 1183 packet_->seqNum++;
1186 EXPECT_EQ(kIncomplete, 1184 EXPECT_EQ(kIncomplete,
1187 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1185 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1188 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1186 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1189 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1187 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1190 } 1188 }
1191 1189
1192 // last packet 1190 // last packet
1193 packet_->markerBit = true; 1191 packet_->markerBit = true;
1194 packet_->seqNum++; 1192 packet_->seqNum++;
1195 1193
1196 EXPECT_EQ(kCompleteSession, 1194 EXPECT_EQ(kCompleteSession,
1197 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1195 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1198 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 1196 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
1199 CheckOutFrame(frame_out, 10 * size_, false); 1197 CheckOutFrame(frame_out, 10 * size_, false);
1200 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 1198 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
1201 jitter_buffer_->ReleaseFrame(frame_out); 1199 jitter_buffer_->ReleaseFrame(frame_out);
1202 1200
1203 // An incomplete frame can only be decoded once a subsequent frame has begun 1201 // An incomplete frame can only be decoded once a subsequent frame has begun
1204 // to arrive. Insert packet in distant frame for this purpose. 1202 // to arrive. Insert packet in distant frame for this purpose.
1205 packet_->frameType = kVideoFrameDelta; 1203 packet_->frameType = kVideoFrameDelta;
1206 packet_->isFirstPacket = true; 1204 packet_->isFirstPacket = true;
1207 packet_->markerBit = false; 1205 packet_->markerBit = false;
1208 packet_->seqNum += 100; 1206 packet_->seqNum += 100;
1209 packet_->timestamp += 33 * 90 * 8; 1207 packet_->timestamp += 33 * 90 * 8;
1210 1208
1211 EXPECT_EQ(kDecodableSession, 1209 EXPECT_EQ(kDecodableSession,
1212 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1210 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1213 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1211 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1214 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1212 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1215 1213
1216 // Insert second frame 1214 // Insert second frame
1217 packet_->seqNum -= 99; 1215 packet_->seqNum -= 99;
1218 packet_->timestamp -= 33 * 90 * 7; 1216 packet_->timestamp -= 33 * 90 * 7;
1219 1217
1220 EXPECT_EQ(kDecodableSession, 1218 EXPECT_EQ(kDecodableSession,
1221 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1219 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1222 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1220 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1223 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1221 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1224 1222
1225 packet_->isFirstPacket = false; 1223 packet_->isFirstPacket = false;
1226 for (int i = 1; i < 8; ++i) { 1224 for (int i = 1; i < 8; ++i) {
1227 packet_->seqNum++; 1225 packet_->seqNum++;
1228 EXPECT_EQ(kDecodableSession, 1226 EXPECT_EQ(kDecodableSession,
1229 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1227 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1230 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1228 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1231 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1229 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1232 } 1230 }
1233 1231
1234 packet_->seqNum++; 1232 packet_->seqNum++;
1235 EXPECT_EQ(kDecodableSession, 1233 EXPECT_EQ(kDecodableSession,
1236 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1234 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1237 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1235 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1238 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1236 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1239 1237
1240 frame_out = DecodeIncompleteFrame(); 1238 frame_out = DecodeIncompleteFrame();
1241 ASSERT_FALSE(NULL == frame_out); 1239 ASSERT_FALSE(NULL == frame_out);
1242 CheckOutFrame(frame_out, 9 * size_, false); 1240 CheckOutFrame(frame_out, 9 * size_, false);
1243 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 1241 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
1244 jitter_buffer_->ReleaseFrame(frame_out); 1242 jitter_buffer_->ReleaseFrame(frame_out);
1245 1243
1246 packet_->markerBit = true; 1244 packet_->markerBit = true;
1247 packet_->seqNum++; 1245 packet_->seqNum++;
(...skipping 21 matching lines...) Expand all
1269 // An incomplete frame can only be decoded once a subsequent frame has begun 1267 // An incomplete frame can only be decoded once a subsequent frame has begun
1270 // to arrive. Insert packet in distant frame for this purpose. 1268 // to arrive. Insert packet in distant frame for this purpose.
1271 packet_->frameType = kVideoFrameDelta; 1269 packet_->frameType = kVideoFrameDelta;
1272 packet_->isFirstPacket = false; 1270 packet_->isFirstPacket = false;
1273 packet_->markerBit = false; 1271 packet_->markerBit = false;
1274 packet_->seqNum += 100; 1272 packet_->seqNum += 100;
1275 packet_->timestamp += 33 * 90 * 8; 1273 packet_->timestamp += 33 * 90 * 8;
1276 EXPECT_EQ(kIncomplete, 1274 EXPECT_EQ(kIncomplete,
1277 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1275 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1278 uint32_t timestamp; 1276 uint32_t timestamp;
1279 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1277 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1280 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1278 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1281 1279
1282 // Insert second frame - an incomplete key frame. 1280 // Insert second frame - an incomplete key frame.
1283 packet_->frameType = kVideoFrameKey; 1281 packet_->frameType = kVideoFrameKey;
1284 packet_->isFirstPacket = true; 1282 packet_->isFirstPacket = true;
1285 packet_->seqNum -= 99; 1283 packet_->seqNum -= 99;
1286 packet_->timestamp -= 33 * 90 * 7; 1284 packet_->timestamp -= 33 * 90 * 7;
1287 1285
1288 EXPECT_EQ(kIncomplete, 1286 EXPECT_EQ(kIncomplete,
1289 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1287 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1290 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1288 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1291 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1289 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1292 1290
1293 // Insert a few more packets. Make sure we're waiting for the key frame to be 1291 // Insert a few more packets. Make sure we're waiting for the key frame to be
1294 // complete. 1292 // complete.
1295 packet_->isFirstPacket = false; 1293 packet_->isFirstPacket = false;
1296 for (int i = 1; i < 5; ++i) { 1294 for (int i = 1; i < 5; ++i) {
1297 packet_->seqNum++; 1295 packet_->seqNum++;
1298 EXPECT_EQ(kIncomplete, 1296 EXPECT_EQ(kIncomplete,
1299 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1297 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1300 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1298 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1301 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1299 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1302 } 1300 }
1303 1301
1304 // Complete key frame. 1302 // Complete key frame.
1305 packet_->markerBit = true; 1303 packet_->markerBit = true;
1306 packet_->seqNum++; 1304 packet_->seqNum++;
1307 EXPECT_EQ(kCompleteSession, 1305 EXPECT_EQ(kCompleteSession,
1308 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1306 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1309 frame_out = DecodeCompleteFrame(); 1307 frame_out = DecodeCompleteFrame();
1310 CheckOutFrame(frame_out, 6 * size_, false); 1308 CheckOutFrame(frame_out, 6 * size_, false);
(...skipping 22 matching lines...) Expand all
1333 // An incomplete frame can only be decoded once a subsequent frame has begun 1331 // An incomplete frame can only be decoded once a subsequent frame has begun
1334 // to arrive. Insert packet in distant frame for this purpose. 1332 // to arrive. Insert packet in distant frame for this purpose.
1335 packet_->frameType = kVideoFrameDelta; 1333 packet_->frameType = kVideoFrameDelta;
1336 packet_->isFirstPacket = false; 1334 packet_->isFirstPacket = false;
1337 packet_->markerBit = false; 1335 packet_->markerBit = false;
1338 packet_->seqNum += 100; 1336 packet_->seqNum += 100;
1339 packet_->timestamp += 33 * 90 * 8; 1337 packet_->timestamp += 33 * 90 * 8;
1340 EXPECT_EQ(kIncomplete, 1338 EXPECT_EQ(kIncomplete,
1341 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1339 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1342 uint32_t timestamp; 1340 uint32_t timestamp;
1343 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1341 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1344 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1342 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1345 1343
1346 // Insert second frame with the first packet missing. Make sure we're waiting 1344 // Insert second frame with the first packet missing. Make sure we're waiting
1347 // for the key frame to be complete. 1345 // for the key frame to be complete.
1348 packet_->seqNum -= 98; 1346 packet_->seqNum -= 98;
1349 packet_->timestamp -= 33 * 90 * 7; 1347 packet_->timestamp -= 33 * 90 * 7;
1350 1348
1351 EXPECT_EQ(kIncomplete, 1349 EXPECT_EQ(kIncomplete,
1352 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1350 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1353 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1351 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1354 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1352 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1355 1353
1356 for (int i = 0; i < 5; ++i) { 1354 for (int i = 0; i < 5; ++i) {
1357 packet_->seqNum++; 1355 packet_->seqNum++;
1358 EXPECT_EQ(kIncomplete, 1356 EXPECT_EQ(kIncomplete,
1359 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1357 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1360 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1358 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1361 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1359 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1362 } 1360 }
1363 1361
1364 // Add first packet. Frame should now be decodable, but incomplete. 1362 // Add first packet. Frame should now be decodable, but incomplete.
1365 packet_->isFirstPacket = true; 1363 packet_->isFirstPacket = true;
1366 packet_->seqNum -= 6; 1364 packet_->seqNum -= 6;
1367 EXPECT_EQ(kDecodableSession, 1365 EXPECT_EQ(kDecodableSession,
1368 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1366 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1369 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &timestamp)); 1367 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1370 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1368 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1371 1369
1372 frame_out = DecodeIncompleteFrame(); 1370 frame_out = DecodeIncompleteFrame();
1373 CheckOutFrame(frame_out, 7 * size_, false); 1371 CheckOutFrame(frame_out, 7 * size_, false);
1374 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 1372 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
1375 jitter_buffer_->ReleaseFrame(frame_out); 1373 jitter_buffer_->ReleaseFrame(frame_out);
1376 } 1374 }
1377 1375
1378 TEST_P(TestBasicJitterBuffer, DiscontinuousStreamWhenDecodingWithErrors) { 1376 TEST_P(TestBasicJitterBuffer, DiscontinuousStreamWhenDecodingWithErrors) {
1379 // Will use one packet per frame. 1377 // Will use one packet per frame.
1380 jitter_buffer_->SetDecodeErrorMode(kWithErrors); 1378 jitter_buffer_->SetDecodeErrorMode(kWithErrors);
1381 packet_->frameType = kVideoFrameKey; 1379 packet_->frameType = kVideoFrameKey;
1382 packet_->isFirstPacket = true; 1380 packet_->isFirstPacket = true;
1383 packet_->markerBit = true; 1381 packet_->markerBit = true;
1384 packet_->seqNum = seq_num_; 1382 packet_->seqNum = seq_num_;
1385 packet_->timestamp = timestamp_; 1383 packet_->timestamp = timestamp_;
1386 bool retransmitted = false; 1384 bool retransmitted = false;
1387 EXPECT_EQ(kCompleteSession, 1385 EXPECT_EQ(kCompleteSession,
1388 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1386 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1389 uint32_t next_timestamp; 1387 uint32_t next_timestamp;
1390 EXPECT_TRUE(jitter_buffer_->NextCompleteTimestamp(0, &next_timestamp)); 1388 VCMEncodedFrame* frame = jitter_buffer_->NextCompleteFrame(0);
1391 EXPECT_EQ(packet_->timestamp, next_timestamp); 1389 EXPECT_NE(frame, nullptr);
1392 VCMEncodedFrame* frame = jitter_buffer_->ExtractAndSetDecode(next_timestamp); 1390 EXPECT_EQ(packet_->timestamp, frame->TimeStamp());
1391 frame = jitter_buffer_->ExtractAndSetDecode(frame->TimeStamp());
1393 EXPECT_TRUE(frame != NULL); 1392 EXPECT_TRUE(frame != NULL);
1394 jitter_buffer_->ReleaseFrame(frame); 1393 jitter_buffer_->ReleaseFrame(frame);
1395 1394
1396 // Drop a complete frame. 1395 // Drop a complete frame.
1397 timestamp_ += 2 * 33 * 90; 1396 timestamp_ += 2 * 33 * 90;
1398 seq_num_ += 2; 1397 seq_num_ += 2;
1399 packet_->frameType = kVideoFrameDelta; 1398 packet_->frameType = kVideoFrameDelta;
1400 packet_->isFirstPacket = true; 1399 packet_->isFirstPacket = true;
1401 packet_->markerBit = false; 1400 packet_->markerBit = false;
1402 packet_->seqNum = seq_num_; 1401 packet_->seqNum = seq_num_;
1403 packet_->timestamp = timestamp_; 1402 packet_->timestamp = timestamp_;
1404 EXPECT_EQ(kDecodableSession, 1403 EXPECT_EQ(kDecodableSession,
1405 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1404 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1406 // Insert a packet (so the previous one will be released). 1405 // Insert a packet (so the previous one will be released).
1407 timestamp_ += 33 * 90; 1406 timestamp_ += 33 * 90;
1408 seq_num_ += 2; 1407 seq_num_ += 2;
1409 packet_->frameType = kVideoFrameDelta; 1408 packet_->frameType = kVideoFrameDelta;
1410 packet_->isFirstPacket = true; 1409 packet_->isFirstPacket = true;
1411 packet_->markerBit = false; 1410 packet_->markerBit = false;
1412 packet_->seqNum = seq_num_; 1411 packet_->seqNum = seq_num_;
1413 packet_->timestamp = timestamp_; 1412 packet_->timestamp = timestamp_;
1414 EXPECT_EQ(kDecodableSession, 1413 EXPECT_EQ(kDecodableSession,
1415 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1414 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1416 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &next_timestamp)); 1415 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1417 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&next_timestamp)); 1416 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&next_timestamp));
1418 EXPECT_EQ(packet_->timestamp - 33 * 90, next_timestamp); 1417 EXPECT_EQ(packet_->timestamp - 33 * 90, next_timestamp);
1419 } 1418 }
1420 1419
1421 TEST_P(TestBasicJitterBuffer, PacketLoss) { 1420 TEST_P(TestBasicJitterBuffer, PacketLoss) {
1422 // Verify missing packets statistics and not decodable packets statistics. 1421 // Verify missing packets statistics and not decodable packets statistics.
1423 // Insert 10 frames consisting of 4 packets and remove one from all of them. 1422 // Insert 10 frames consisting of 4 packets and remove one from all of them.
1424 // The last packet is an empty (non-media) packet. 1423 // The last packet is an empty (non-media) packet.
1425 1424
1426 // Select a start seqNum which triggers a difficult wrap situation 1425 // Select a start seqNum which triggers a difficult wrap situation
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 2658
2660 // Stream should be decodable from this point. 2659 // Stream should be decodable from this point.
2661 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); 2660 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs);
2662 InsertFrame(kVideoFrameDelta); 2661 InsertFrame(kVideoFrameDelta);
2663 EXPECT_TRUE(DecodeCompleteFrame()); 2662 EXPECT_TRUE(DecodeCompleteFrame());
2664 nack_list = jitter_buffer_->GetNackList(&extended); 2663 nack_list = jitter_buffer_->GetNackList(&extended);
2665 EXPECT_EQ(0u, nack_list.size()); 2664 EXPECT_EQ(0u, nack_list.size());
2666 } 2665 }
2667 2666
2668 } // namespace webrtc 2667 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698