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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc

Issue 1493403003: modules/rtp_rtcp/include folder cleared of lint warnings (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 RtpUtility::Payload* returned_payload_on_heap = 67 RtpUtility::Payload* returned_payload_on_heap =
68 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); 68 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate);
69 69
70 bool new_payload_created = false; 70 bool new_payload_created = false;
71 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( 71 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
72 kTypicalPayloadName, payload_type, kTypicalFrequency, 72 kTypicalPayloadName, payload_type, kTypicalFrequency,
73 kTypicalChannels, kTypicalRate, &new_payload_created)); 73 kTypicalChannels, kTypicalRate, &new_payload_created));
74 74
75 EXPECT_TRUE(new_payload_created) << "A new payload WAS created."; 75 EXPECT_TRUE(new_payload_created) << "A new payload WAS created.";
76 76
77 RtpUtility::Payload* retrieved_payload = NULL; 77 const RtpUtility::Payload* retrieved_payload =
78 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type, 78 rtp_payload_registry_->PayloadTypeToPayload(payload_type);
79 retrieved_payload)); 79 EXPECT_TRUE(retrieved_payload);
80 80
81 // We should get back the exact pointer to the payload returned by the 81 // We should get back the exact pointer to the payload returned by the
82 // payload strategy. 82 // payload strategy.
83 EXPECT_EQ(returned_payload_on_heap, retrieved_payload); 83 EXPECT_EQ(returned_payload_on_heap, retrieved_payload);
84 84
85 // Now forget about it and verify it's gone. 85 // Now forget about it and verify it's gone.
86 EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type)); 86 EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type));
87 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type, 87 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type));
88 retrieved_payload));
89 } 88 }
90 89
91 TEST_F(RtpPayloadRegistryTest, AudioRedWorkProperly) { 90 TEST_F(RtpPayloadRegistryTest, AudioRedWorkProperly) {
92 const uint8_t kRedPayloadType = 127; 91 const uint8_t kRedPayloadType = 127;
93 const int kRedSampleRate = 8000; 92 const int kRedSampleRate = 8000;
94 const int kRedChannels = 1; 93 const int kRedChannels = 1;
95 const int kRedBitRate = 0; 94 const int kRedBitRate = 0;
96 95
97 // This creates an audio RTP payload strategy. 96 // This creates an audio RTP payload strategy.
98 rtp_payload_registry_.reset( 97 rtp_payload_registry_.reset(
99 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))); 98 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true)));
100 99
101 bool new_payload_created = false; 100 bool new_payload_created = false;
102 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( 101 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
103 "red", kRedPayloadType, kRedSampleRate, kRedChannels, 102 "red", kRedPayloadType, kRedSampleRate, kRedChannels,
104 kRedBitRate, &new_payload_created)); 103 kRedBitRate, &new_payload_created));
105 EXPECT_TRUE(new_payload_created); 104 EXPECT_TRUE(new_payload_created);
106 105
107 EXPECT_EQ(kRedPayloadType, rtp_payload_registry_->red_payload_type()); 106 EXPECT_EQ(kRedPayloadType, rtp_payload_registry_->red_payload_type());
108 107
109 RtpUtility::Payload* retrieved_payload = NULL; 108 const RtpUtility::Payload* retrieved_payload =
110 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(kRedPayloadType, 109 rtp_payload_registry_->PayloadTypeToPayload(kRedPayloadType);
111 retrieved_payload)); 110 EXPECT_TRUE(retrieved_payload);
112 ASSERT_TRUE(retrieved_payload);
113 EXPECT_TRUE(retrieved_payload->audio); 111 EXPECT_TRUE(retrieved_payload->audio);
114 EXPECT_STRCASEEQ("red", retrieved_payload->name); 112 EXPECT_STRCASEEQ("red", retrieved_payload->name);
115 113
116 // Sample rate is correctly registered. 114 // Sample rate is correctly registered.
117 EXPECT_EQ(kRedSampleRate, 115 EXPECT_EQ(kRedSampleRate,
118 rtp_payload_registry_->GetPayloadTypeFrequency(kRedPayloadType)); 116 rtp_payload_registry_->GetPayloadTypeFrequency(kRedPayloadType));
119 } 117 }
120 118
121 TEST_F(RtpPayloadRegistryTest, 119 TEST_F(RtpPayloadRegistryTest,
122 DoesNotAcceptSamePayloadTypeTwiceExceptIfPayloadIsCompatible) { 120 DoesNotAcceptSamePayloadTypeTwiceExceptIfPayloadIsCompatible) {
(...skipping 12 matching lines...) Expand all
135 << "Adding same codec twice = bad."; 133 << "Adding same codec twice = bad.";
136 134
137 RtpUtility::Payload* second_payload_on_heap = 135 RtpUtility::Payload* second_payload_on_heap =
138 ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate); 136 ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate);
139 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( 137 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
140 kTypicalPayloadName, payload_type - 1, kTypicalFrequency, 138 kTypicalPayloadName, payload_type - 1, kTypicalFrequency,
141 kTypicalChannels, kTypicalRate, &ignored)) 139 kTypicalChannels, kTypicalRate, &ignored))
142 << "With a different payload type is fine though."; 140 << "With a different payload type is fine though.";
143 141
144 // Ensure both payloads are preserved. 142 // Ensure both payloads are preserved.
145 RtpUtility::Payload* retrieved_payload = NULL; 143 const RtpUtility::Payload* retrieved_payload =
146 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type, 144 rtp_payload_registry_->PayloadTypeToPayload(payload_type);
147 retrieved_payload)); 145 EXPECT_TRUE(retrieved_payload);
148 EXPECT_EQ(first_payload_on_heap, retrieved_payload); 146 EXPECT_EQ(first_payload_on_heap, retrieved_payload);
149 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1, 147 retrieved_payload =
150 retrieved_payload)); 148 rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1);
149 EXPECT_TRUE(retrieved_payload);
151 EXPECT_EQ(second_payload_on_heap, retrieved_payload); 150 EXPECT_EQ(second_payload_on_heap, retrieved_payload);
152 151
153 // Ok, update the rate for one of the codecs. If either the incoming rate or 152 // Ok, update the rate for one of the codecs. If either the incoming rate or
154 // the stored rate is zero it's not really an error to register the same 153 // the stored rate is zero it's not really an error to register the same
155 // codec twice, and in that case roughly the following happens. 154 // codec twice, and in that case roughly the following happens.
156 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _)) 155 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _))
157 .WillByDefault(Return(true)); 156 .WillByDefault(Return(true));
158 EXPECT_CALL(*mock_payload_strategy_, 157 EXPECT_CALL(*mock_payload_strategy_,
159 UpdatePayloadRate(first_payload_on_heap, kTypicalRate)); 158 UpdatePayloadRate(first_payload_on_heap, kTypicalRate));
160 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( 159 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
(...skipping 13 matching lines...) Expand all
174 bool ignored = false; 173 bool ignored = false;
175 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); 174 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate);
176 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( 175 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
177 kTypicalPayloadName, payload_type, kTypicalFrequency, 176 kTypicalPayloadName, payload_type, kTypicalFrequency,
178 kTypicalChannels, kTypicalRate, &ignored)); 177 kTypicalChannels, kTypicalRate, &ignored));
179 ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate); 178 ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate);
180 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( 179 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
181 kTypicalPayloadName, payload_type - 1, kTypicalFrequency, 180 kTypicalPayloadName, payload_type - 1, kTypicalFrequency,
182 kTypicalChannels, kTypicalRate, &ignored)); 181 kTypicalChannels, kTypicalRate, &ignored));
183 182
184 RtpUtility::Payload* retrieved_payload = NULL; 183 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type))
185 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type,
186 retrieved_payload))
187 << "The first payload should be " 184 << "The first payload should be "
188 "deregistered because the only thing that differs is payload type."; 185 "deregistered because the only thing that differs is payload type.";
189 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1, 186 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1))
190 retrieved_payload))
191 << "The second payload should still be registered though."; 187 << "The second payload should still be registered though.";
192 188
193 // Now ensure non-compatible codecs aren't removed. 189 // Now ensure non-compatible codecs aren't removed.
194 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _)) 190 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _))
195 .WillByDefault(Return(false)); 191 .WillByDefault(Return(false));
196 ExpectReturnOfTypicalAudioPayload(payload_type + 1, kTypicalRate); 192 ExpectReturnOfTypicalAudioPayload(payload_type + 1, kTypicalRate);
197 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( 193 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
198 kTypicalPayloadName, payload_type + 1, kTypicalFrequency, 194 kTypicalPayloadName, payload_type + 1, kTypicalFrequency,
199 kTypicalChannels, kTypicalRate, &ignored)); 195 kTypicalChannels, kTypicalRate, &ignored));
200 196
201 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1, 197 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1))
202 retrieved_payload))
203 << "Not compatible; both payloads should be kept."; 198 << "Not compatible; both payloads should be kept.";
204 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type + 1, 199 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type + 1))
205 retrieved_payload))
206 << "Not compatible; both payloads should be kept."; 200 << "Not compatible; both payloads should be kept.";
207 } 201 }
208 202
209 TEST_F(RtpPayloadRegistryTest, 203 TEST_F(RtpPayloadRegistryTest,
210 LastReceivedCodecTypesAreResetWhenRegisteringNewPayloadTypes) { 204 LastReceivedCodecTypesAreResetWhenRegisteringNewPayloadTypes) {
211 rtp_payload_registry_->set_last_received_payload_type(17); 205 rtp_payload_registry_->set_last_received_payload_type(17);
212 EXPECT_EQ(17, rtp_payload_registry_->last_received_payload_type()); 206 EXPECT_EQ(17, rtp_payload_registry_->last_received_payload_type());
213 207
214 bool media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18); 208 bool media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18);
215 EXPECT_FALSE(media_type_unchanged); 209 EXPECT_FALSE(media_type_unchanged);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(true); 387 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(true);
394 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true); 388 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true);
395 TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false); 389 TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false);
396 } 390 }
397 391
398 INSTANTIATE_TEST_CASE_P(TestDynamicRange, 392 INSTANTIATE_TEST_CASE_P(TestDynamicRange,
399 RtpPayloadRegistryGenericTest, 393 RtpPayloadRegistryGenericTest,
400 testing::Range(96, 127 + 1)); 394 testing::Range(96, 127 + 1));
401 395
402 } // namespace webrtc 396 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698