stefan@webrtc.org | c3d8910 | 2011-09-08 06:50:28 +0000 | [diff] [blame] | 1 | /* |
stefan@webrtc.org | 4ce0ba0 | 2012-02-28 12:09:09 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
stefan@webrtc.org | c3d8910 | 2011-09-08 06:50:28 +0000 | [diff] [blame] | 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 | |
| 11 | #include <string.h> |
| 12 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 13 | #include "webrtc/modules/include/module_common_types.h" |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 14 | #include "webrtc/modules/video_coding/packet.h" |
| 15 | #include "webrtc/modules/video_coding/session_info.h" |
kwiberg | ac9f876 | 2016-09-30 22:29:43 -0700 | [diff] [blame] | 16 | #include "webrtc/test/gtest.h" |
stefan@webrtc.org | c3d8910 | 2011-09-08 06:50:28 +0000 | [diff] [blame] | 17 | |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 18 | namespace webrtc { |
stefan@webrtc.org | c3d8910 | 2011-09-08 06:50:28 +0000 | [diff] [blame] | 19 | |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 20 | class TestSessionInfo : public ::testing::Test { |
stefan@webrtc.org | c3d8910 | 2011-09-08 06:50:28 +0000 | [diff] [blame] | 21 | protected: |
| 22 | virtual void SetUp() { |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 23 | memset(packet_buffer_, 0, sizeof(packet_buffer_)); |
| 24 | memset(frame_buffer_, 0, sizeof(frame_buffer_)); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 25 | session_.Reset(); |
| 26 | packet_.Reset(); |
| 27 | packet_.frameType = kVideoFrameDelta; |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 28 | packet_.sizeBytes = packet_buffer_size(); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 29 | packet_.dataPtr = packet_buffer_; |
| 30 | packet_.seqNum = 0; |
| 31 | packet_.timestamp = 0; |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 32 | frame_data.rtt_ms = 0; |
| 33 | frame_data.rolling_average_packets_per_frame = -1; |
stefan@webrtc.org | c3d8910 | 2011-09-08 06:50:28 +0000 | [diff] [blame] | 34 | } |
| 35 | |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 36 | void FillPacket(uint8_t start_value) { |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 37 | for (size_t i = 0; i < packet_buffer_size(); ++i) |
stefan@webrtc.org | c3d8910 | 2011-09-08 06:50:28 +0000 | [diff] [blame] | 38 | packet_buffer_[i] = start_value + i; |
| 39 | } |
| 40 | |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 41 | void VerifyPacket(uint8_t* start_ptr, uint8_t start_value) { |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 42 | for (size_t j = 0; j < packet_buffer_size(); ++j) { |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 43 | ASSERT_EQ(start_value + j, start_ptr[j]); |
| 44 | } |
| 45 | } |
| 46 | |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 47 | size_t packet_buffer_size() const { |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 48 | return sizeof(packet_buffer_) / sizeof(packet_buffer_[0]); |
| 49 | } |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 50 | size_t frame_buffer_size() const { |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 51 | return sizeof(frame_buffer_) / sizeof(frame_buffer_[0]); |
| 52 | } |
| 53 | |
| 54 | enum { kPacketBufferSize = 10 }; |
| 55 | |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 56 | uint8_t packet_buffer_[kPacketBufferSize]; |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 57 | uint8_t frame_buffer_[10 * kPacketBufferSize]; |
| 58 | |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 59 | VCMSessionInfo session_; |
| 60 | VCMPacket packet_; |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 61 | FrameData frame_data; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 64 | class TestNalUnits : public TestSessionInfo { |
| 65 | protected: |
| 66 | virtual void SetUp() { |
| 67 | TestSessionInfo::SetUp(); |
pwestin@webrtc.org | 5621057 | 2012-01-17 12:45:47 +0000 | [diff] [blame] | 68 | packet_.codec = kVideoCodecVP8; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | bool VerifyNalu(int offset, int packets_expected, int start_value) { |
| 72 | EXPECT_GE(session_.SessionLength(), |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 73 | packets_expected * packet_buffer_size()); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 74 | for (int i = 0; i < packets_expected; ++i) { |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 75 | int packet_index = (offset + i) * packet_buffer_size(); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 76 | VerifyPacket(frame_buffer_ + packet_index, start_value + i); |
| 77 | } |
| 78 | return true; |
| 79 | } |
| 80 | }; |
| 81 | |
mikhal@webrtc.org | cd64886 | 2012-01-03 23:59:42 +0000 | [diff] [blame] | 82 | class TestNackList : public TestSessionInfo { |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 83 | protected: |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 84 | static const size_t kMaxSeqNumListLength = 30; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 85 | |
| 86 | virtual void SetUp() { |
| 87 | TestSessionInfo::SetUp(); |
| 88 | seq_num_list_length_ = 0; |
| 89 | memset(seq_num_list_, 0, sizeof(seq_num_list_)); |
| 90 | } |
| 91 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 92 | void BuildSeqNumList(uint16_t low, uint16_t high) { |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 93 | size_t i = 0; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 94 | while (low != high + 1) { |
| 95 | EXPECT_LT(i, kMaxSeqNumListLength); |
| 96 | if (i >= kMaxSeqNumListLength) { |
| 97 | seq_num_list_length_ = kMaxSeqNumListLength; |
| 98 | return; |
| 99 | } |
| 100 | seq_num_list_[i] = low; |
| 101 | low++; |
| 102 | i++; |
| 103 | } |
| 104 | seq_num_list_length_ = i; |
| 105 | } |
| 106 | |
| 107 | void VerifyAll(int value) { |
| 108 | for (int i = 0; i < seq_num_list_length_; ++i) |
| 109 | EXPECT_EQ(seq_num_list_[i], value); |
| 110 | } |
| 111 | |
| 112 | int seq_num_list_[kMaxSeqNumListLength]; |
| 113 | int seq_num_list_length_; |
| 114 | }; |
| 115 | |
| 116 | TEST_F(TestSessionInfo, TestSimpleAPIs) { |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 117 | packet_.isFirstPacket = true; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 118 | packet_.seqNum = 0xFFFE; |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 119 | packet_.sizeBytes = packet_buffer_size(); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 120 | packet_.frameType = kVideoFrameKey; |
| 121 | FillPacket(0); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 122 | EXPECT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 123 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 124 | kNoErrors, frame_data))); |
phoglund@webrtc.org | d1a860b | 2012-01-26 14:49:28 +0000 | [diff] [blame] | 125 | EXPECT_FALSE(session_.HaveLastPacket()); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 126 | EXPECT_EQ(kVideoFrameKey, session_.FrameType()); |
| 127 | |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 128 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 129 | packet_.markerBit = true; |
| 130 | packet_.seqNum += 1; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 131 | EXPECT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 132 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 133 | kNoErrors, frame_data))); |
phoglund@webrtc.org | d1a860b | 2012-01-26 14:49:28 +0000 | [diff] [blame] | 134 | EXPECT_TRUE(session_.HaveLastPacket()); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 135 | EXPECT_EQ(packet_.seqNum, session_.HighSequenceNumber()); |
| 136 | EXPECT_EQ(0xFFFE, session_.LowSequenceNumber()); |
| 137 | |
| 138 | // Insert empty packet which will be the new high sequence number. |
| 139 | // To make things more difficult we will make sure to have a wrap here. |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 140 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 141 | packet_.markerBit = true; |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 142 | packet_.seqNum = 2; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 143 | packet_.sizeBytes = 0; |
pbos | 22993e1 | 2015-10-19 02:39:06 -0700 | [diff] [blame] | 144 | packet_.frameType = kEmptyFrame; |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 145 | EXPECT_EQ( |
| 146 | 0, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 147 | EXPECT_EQ(packet_.seqNum, session_.HighSequenceNumber()); |
| 148 | } |
| 149 | |
| 150 | TEST_F(TestSessionInfo, NormalOperation) { |
| 151 | packet_.seqNum = 0xFFFF; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 152 | packet_.isFirstPacket = true; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 153 | packet_.markerBit = false; |
| 154 | FillPacket(0); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 155 | EXPECT_EQ(packet_buffer_size(), |
| 156 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 157 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 158 | |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 159 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 160 | for (int i = 1; i < 9; ++i) { |
| 161 | packet_.seqNum += 1; |
| 162 | FillPacket(i); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 163 | ASSERT_EQ(packet_buffer_size(), |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 164 | static_cast<size_t>(session_.InsertPacket( |
| 165 | packet_, frame_buffer_, kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | packet_.seqNum += 1; |
| 169 | packet_.markerBit = true; |
| 170 | FillPacket(9); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 171 | EXPECT_EQ(packet_buffer_size(), |
| 172 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 173 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 174 | |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 175 | EXPECT_EQ(10 * packet_buffer_size(), session_.SessionLength()); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 176 | for (int i = 0; i < 10; ++i) { |
| 177 | SCOPED_TRACE("Calling VerifyPacket"); |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 178 | VerifyPacket(frame_buffer_ + i * packet_buffer_size(), i); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 182 | TEST_F(TestSessionInfo, ErrorsEqualDecodableState) { |
| 183 | packet_.seqNum = 0xFFFF; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 184 | packet_.isFirstPacket = false; |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 185 | packet_.markerBit = false; |
| 186 | FillPacket(3); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 187 | EXPECT_EQ(packet_buffer_size(), |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 188 | static_cast<size_t>(session_.InsertPacket( |
| 189 | packet_, frame_buffer_, kWithErrors, frame_data))); |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 190 | EXPECT_TRUE(session_.decodable()); |
| 191 | } |
| 192 | |
| 193 | TEST_F(TestSessionInfo, SelectiveDecodableState) { |
| 194 | packet_.seqNum = 0xFFFF; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 195 | packet_.isFirstPacket = false; |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 196 | packet_.markerBit = false; |
| 197 | FillPacket(1); |
| 198 | frame_data.rolling_average_packets_per_frame = 11; |
| 199 | frame_data.rtt_ms = 150; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 200 | EXPECT_EQ(packet_buffer_size(), |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 201 | static_cast<size_t>(session_.InsertPacket( |
| 202 | packet_, frame_buffer_, kSelectiveErrors, frame_data))); |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 203 | EXPECT_FALSE(session_.decodable()); |
| 204 | |
| 205 | packet_.seqNum -= 1; |
| 206 | FillPacket(0); |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 207 | packet_.isFirstPacket = true; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 208 | EXPECT_EQ(packet_buffer_size(), |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 209 | static_cast<size_t>(session_.InsertPacket( |
| 210 | packet_, frame_buffer_, kSelectiveErrors, frame_data))); |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 211 | EXPECT_TRUE(session_.decodable()); |
| 212 | |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 213 | packet_.isFirstPacket = false; |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 214 | packet_.seqNum += 1; |
| 215 | for (int i = 2; i < 8; ++i) { |
| 216 | packet_.seqNum += 1; |
| 217 | FillPacket(i); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 218 | EXPECT_EQ(packet_buffer_size(), |
| 219 | static_cast<size_t>(session_.InsertPacket( |
| 220 | packet_, frame_buffer_, kSelectiveErrors, frame_data))); |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 221 | EXPECT_TRUE(session_.decodable()); |
| 222 | } |
| 223 | |
| 224 | packet_.seqNum += 1; |
| 225 | FillPacket(8); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 226 | EXPECT_EQ(packet_buffer_size(), |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 227 | static_cast<size_t>(session_.InsertPacket( |
| 228 | packet_, frame_buffer_, kSelectiveErrors, frame_data))); |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 229 | EXPECT_TRUE(session_.decodable()); |
| 230 | } |
| 231 | |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 232 | TEST_F(TestSessionInfo, OutOfBoundsPackets1PacketFrame) { |
| 233 | packet_.seqNum = 0x0001; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 234 | packet_.isFirstPacket = true; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 235 | packet_.markerBit = true; |
| 236 | FillPacket(1); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 237 | EXPECT_EQ(packet_buffer_size(), |
| 238 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 239 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 240 | |
| 241 | packet_.seqNum = 0x0004; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 242 | packet_.isFirstPacket = true; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 243 | packet_.markerBit = true; |
| 244 | FillPacket(1); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 245 | EXPECT_EQ( |
| 246 | -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 247 | packet_.seqNum = 0x0000; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 248 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 249 | packet_.markerBit = false; |
| 250 | FillPacket(1); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 251 | EXPECT_EQ( |
| 252 | -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | TEST_F(TestSessionInfo, SetMarkerBitOnce) { |
| 256 | packet_.seqNum = 0x0005; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 257 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 258 | packet_.markerBit = true; |
| 259 | FillPacket(1); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 260 | EXPECT_EQ(packet_buffer_size(), |
| 261 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 262 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 263 | ++packet_.seqNum; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 264 | packet_.isFirstPacket = true; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 265 | packet_.markerBit = true; |
| 266 | FillPacket(1); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 267 | EXPECT_EQ( |
| 268 | -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | TEST_F(TestSessionInfo, OutOfBoundsPacketsBase) { |
| 272 | // Allow packets in the range 5-6. |
| 273 | packet_.seqNum = 0x0005; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 274 | packet_.isFirstPacket = true; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 275 | packet_.markerBit = false; |
| 276 | FillPacket(1); |
| 277 | EXPECT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 278 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 279 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 280 | // Insert an older packet with a first packet set. |
| 281 | packet_.seqNum = 0x0004; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 282 | packet_.isFirstPacket = true; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 283 | packet_.markerBit = true; |
| 284 | FillPacket(1); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 285 | EXPECT_EQ( |
| 286 | -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 287 | packet_.seqNum = 0x0006; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 288 | packet_.isFirstPacket = true; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 289 | packet_.markerBit = true; |
| 290 | FillPacket(1); |
| 291 | EXPECT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 292 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 293 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 294 | packet_.seqNum = 0x0008; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 295 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 296 | packet_.markerBit = true; |
| 297 | FillPacket(1); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 298 | EXPECT_EQ( |
| 299 | -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | TEST_F(TestSessionInfo, OutOfBoundsPacketsWrap) { |
| 303 | packet_.seqNum = 0xFFFE; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 304 | packet_.isFirstPacket = true; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 305 | packet_.markerBit = false; |
| 306 | FillPacket(1); |
| 307 | EXPECT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 308 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 309 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 310 | |
| 311 | packet_.seqNum = 0x0004; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 312 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 313 | packet_.markerBit = true; |
| 314 | FillPacket(1); |
| 315 | EXPECT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 316 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 317 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 318 | packet_.seqNum = 0x0002; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 319 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 320 | packet_.markerBit = false; |
| 321 | FillPacket(1); |
| 322 | ASSERT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 323 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 324 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 325 | packet_.seqNum = 0xFFF0; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 326 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 327 | packet_.markerBit = false; |
| 328 | FillPacket(1); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 329 | EXPECT_EQ( |
| 330 | -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 331 | packet_.seqNum = 0x0006; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 332 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 333 | packet_.markerBit = false; |
| 334 | FillPacket(1); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 335 | EXPECT_EQ( |
| 336 | -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | TEST_F(TestSessionInfo, OutOfBoundsOutOfOrder) { |
| 340 | // Insert out of bound regular packets, and then the first and last packet. |
| 341 | // Verify that correct bounds are maintained. |
| 342 | packet_.seqNum = 0x0003; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 343 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 344 | packet_.markerBit = false; |
| 345 | FillPacket(1); |
| 346 | EXPECT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 347 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 348 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 349 | // Insert an older packet with a first packet set. |
| 350 | packet_.seqNum = 0x0005; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 351 | packet_.isFirstPacket = true; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 352 | packet_.markerBit = false; |
| 353 | FillPacket(1); |
| 354 | EXPECT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 355 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 356 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 357 | packet_.seqNum = 0x0004; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 358 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 359 | packet_.markerBit = false; |
| 360 | FillPacket(1); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 361 | EXPECT_EQ( |
| 362 | -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 363 | packet_.seqNum = 0x0010; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 364 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 365 | packet_.markerBit = false; |
| 366 | FillPacket(1); |
| 367 | EXPECT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 368 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 369 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 370 | packet_.seqNum = 0x0008; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 371 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 372 | packet_.markerBit = true; |
| 373 | FillPacket(1); |
| 374 | EXPECT_EQ(packet_buffer_size(), |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 375 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 376 | kNoErrors, frame_data))); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 377 | |
| 378 | packet_.seqNum = 0x0009; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 379 | packet_.isFirstPacket = false; |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 380 | packet_.markerBit = false; |
| 381 | FillPacket(1); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 382 | EXPECT_EQ( |
| 383 | -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
mikhal@webrtc.org | f31a47a | 2013-08-26 17:10:11 +0000 | [diff] [blame] | 384 | } |
| 385 | |
stefan@webrtc.org | 4ce0ba0 | 2012-02-28 12:09:09 +0000 | [diff] [blame] | 386 | TEST_F(TestNalUnits, OnlyReceivedEmptyPacket) { |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 387 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 4ce0ba0 | 2012-02-28 12:09:09 +0000 | [diff] [blame] | 388 | packet_.completeNALU = kNaluComplete; |
pbos | 22993e1 | 2015-10-19 02:39:06 -0700 | [diff] [blame] | 389 | packet_.frameType = kEmptyFrame; |
stefan@webrtc.org | 4ce0ba0 | 2012-02-28 12:09:09 +0000 | [diff] [blame] | 390 | packet_.sizeBytes = 0; |
| 391 | packet_.seqNum = 0; |
| 392 | packet_.markerBit = false; |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 393 | EXPECT_EQ( |
| 394 | 0, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
stefan@webrtc.org | 4ce0ba0 | 2012-02-28 12:09:09 +0000 | [diff] [blame] | 395 | |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 396 | EXPECT_EQ(0U, session_.MakeDecodable()); |
| 397 | EXPECT_EQ(0U, session_.SessionLength()); |
stefan@webrtc.org | 4ce0ba0 | 2012-02-28 12:09:09 +0000 | [diff] [blame] | 398 | } |
| 399 | |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 400 | TEST_F(TestNalUnits, OneIsolatedNaluLoss) { |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 401 | packet_.isFirstPacket = true; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 402 | packet_.completeNALU = kNaluComplete; |
| 403 | packet_.seqNum = 0; |
| 404 | packet_.markerBit = false; |
| 405 | FillPacket(0); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 406 | EXPECT_EQ(packet_buffer_size(), |
| 407 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 408 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 409 | |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 410 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 411 | packet_.completeNALU = kNaluComplete; |
| 412 | packet_.seqNum += 2; |
| 413 | packet_.markerBit = true; |
| 414 | FillPacket(2); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 415 | EXPECT_EQ(packet_buffer_size(), |
| 416 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 417 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 418 | |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 419 | EXPECT_EQ(0U, session_.MakeDecodable()); |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 420 | EXPECT_EQ(2 * packet_buffer_size(), session_.SessionLength()); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 421 | SCOPED_TRACE("Calling VerifyNalu"); |
| 422 | EXPECT_TRUE(VerifyNalu(0, 1, 0)); |
| 423 | SCOPED_TRACE("Calling VerifyNalu"); |
| 424 | EXPECT_TRUE(VerifyNalu(1, 1, 2)); |
| 425 | } |
| 426 | |
| 427 | TEST_F(TestNalUnits, LossInMiddleOfNalu) { |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 428 | packet_.isFirstPacket = true; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 429 | packet_.completeNALU = kNaluComplete; |
| 430 | packet_.seqNum = 0; |
| 431 | packet_.markerBit = false; |
| 432 | FillPacket(0); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 433 | EXPECT_EQ(packet_buffer_size(), |
| 434 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 435 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 436 | |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 437 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 438 | packet_.completeNALU = kNaluEnd; |
| 439 | packet_.seqNum += 2; |
| 440 | packet_.markerBit = true; |
| 441 | FillPacket(2); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 442 | EXPECT_EQ(packet_buffer_size(), |
| 443 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 444 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 445 | |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 446 | EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable()); |
| 447 | EXPECT_EQ(packet_buffer_size(), session_.SessionLength()); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 448 | SCOPED_TRACE("Calling VerifyNalu"); |
| 449 | EXPECT_TRUE(VerifyNalu(0, 1, 0)); |
| 450 | } |
| 451 | |
| 452 | TEST_F(TestNalUnits, StartAndEndOfLastNalUnitLost) { |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 453 | packet_.isFirstPacket = true; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 454 | packet_.completeNALU = kNaluComplete; |
| 455 | packet_.seqNum = 0; |
| 456 | packet_.markerBit = false; |
| 457 | FillPacket(0); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 458 | EXPECT_EQ(packet_buffer_size(), |
| 459 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 460 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 461 | |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 462 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 463 | packet_.completeNALU = kNaluIncomplete; |
| 464 | packet_.seqNum += 2; |
| 465 | packet_.markerBit = false; |
| 466 | FillPacket(1); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 467 | EXPECT_EQ(packet_buffer_size(), |
| 468 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 469 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 470 | |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 471 | EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable()); |
| 472 | EXPECT_EQ(packet_buffer_size(), session_.SessionLength()); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 473 | SCOPED_TRACE("Calling VerifyNalu"); |
| 474 | EXPECT_TRUE(VerifyNalu(0, 1, 0)); |
| 475 | } |
| 476 | |
| 477 | TEST_F(TestNalUnits, ReorderWrapNoLoss) { |
| 478 | packet_.seqNum = 0xFFFF; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 479 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 480 | packet_.completeNALU = kNaluIncomplete; |
| 481 | packet_.seqNum += 1; |
| 482 | packet_.markerBit = false; |
| 483 | FillPacket(1); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 484 | EXPECT_EQ(packet_buffer_size(), |
| 485 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 486 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 487 | |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 488 | packet_.isFirstPacket = true; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 489 | packet_.completeNALU = kNaluComplete; |
| 490 | packet_.seqNum -= 1; |
| 491 | packet_.markerBit = false; |
| 492 | FillPacket(0); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 493 | EXPECT_EQ(packet_buffer_size(), |
| 494 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 495 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 496 | |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 497 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 498 | packet_.completeNALU = kNaluEnd; |
| 499 | packet_.seqNum += 2; |
| 500 | packet_.markerBit = true; |
| 501 | FillPacket(2); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 502 | EXPECT_EQ(packet_buffer_size(), |
| 503 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 504 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 505 | |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 506 | EXPECT_EQ(0U, session_.MakeDecodable()); |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 507 | EXPECT_EQ(3 * packet_buffer_size(), session_.SessionLength()); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 508 | SCOPED_TRACE("Calling VerifyNalu"); |
| 509 | EXPECT_TRUE(VerifyNalu(0, 1, 0)); |
| 510 | } |
| 511 | |
| 512 | TEST_F(TestNalUnits, WrapLosses) { |
| 513 | packet_.seqNum = 0xFFFF; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 514 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 515 | packet_.completeNALU = kNaluIncomplete; |
| 516 | packet_.markerBit = false; |
| 517 | FillPacket(1); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 518 | EXPECT_EQ(packet_buffer_size(), |
| 519 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 520 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 521 | |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 522 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 523 | packet_.completeNALU = kNaluEnd; |
| 524 | packet_.seqNum += 2; |
| 525 | packet_.markerBit = true; |
| 526 | FillPacket(2); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 527 | EXPECT_EQ(packet_buffer_size(), |
| 528 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 529 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 530 | |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 531 | EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable()); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 532 | EXPECT_EQ(0U, session_.SessionLength()); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | TEST_F(TestNalUnits, ReorderWrapLosses) { |
| 536 | packet_.seqNum = 0xFFFF; |
| 537 | |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 538 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 539 | packet_.completeNALU = kNaluEnd; |
| 540 | packet_.seqNum += 2; |
| 541 | packet_.markerBit = true; |
| 542 | FillPacket(2); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 543 | EXPECT_EQ(packet_buffer_size(), |
| 544 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 545 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 546 | |
| 547 | packet_.seqNum -= 2; |
danilchap | 0ad2111 | 2016-12-19 09:36:33 -0800 | [diff] [blame^] | 548 | packet_.isFirstPacket = false; |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 549 | packet_.completeNALU = kNaluIncomplete; |
| 550 | packet_.markerBit = false; |
| 551 | FillPacket(1); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 552 | EXPECT_EQ(packet_buffer_size(), |
| 553 | static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
| 554 | kNoErrors, frame_data))); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 555 | |
pbos@webrtc.org | 3004c79 | 2013-05-07 12:36:21 +0000 | [diff] [blame] | 556 | EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable()); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 557 | EXPECT_EQ(0U, session_.SessionLength()); |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 558 | } |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 559 | |
stefan@webrtc.org | 076fa6e | 2011-12-13 07:54:56 +0000 | [diff] [blame] | 560 | } // namespace webrtc |