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

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: webrtc do not use newly depricated functions itself. 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 RtpUtility::Payload* returned_payload_on_heap = 68 RtpUtility::Payload* returned_payload_on_heap =
69 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); 69 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate);
70 70
71 bool new_payload_created = false; 71 bool new_payload_created = false;
72 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( 72 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
73 kTypicalPayloadName, payload_type, kTypicalFrequency, kTypicalChannels, 73 kTypicalPayloadName, payload_type, kTypicalFrequency, kTypicalChannels,
74 kTypicalRate, &new_payload_created)); 74 kTypicalRate, &new_payload_created));
75 75
76 EXPECT_TRUE(new_payload_created) << "A new payload WAS created."; 76 EXPECT_TRUE(new_payload_created) << "A new payload WAS created.";
77 77
78 RtpUtility::Payload* retrieved_payload = NULL; 78 RtpUtility::Payload* retrieved_payload =
79 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type, 79 rtp_payload_registry_->PayloadTypeToPayload(payload_type);
80 retrieved_payload)); 80 EXPECT_TRUE(retrieved_payload);
81 81
82 // We should get back the exact pointer to the payload returned by the 82 // We should get back the exact pointer to the payload returned by the
83 // payload strategy. 83 // payload strategy.
84 EXPECT_EQ(returned_payload_on_heap, retrieved_payload); 84 EXPECT_EQ(returned_payload_on_heap, retrieved_payload);
85 85
86 // Now forget about it and verify it's gone. 86 // Now forget about it and verify it's gone.
87 EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type)); 87 EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type));
88 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload( 88 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type));
89 payload_type, retrieved_payload));
90 } 89 }
91 90
92 TEST_F(RtpPayloadRegistryTest, AudioRedWorkProperly) { 91 TEST_F(RtpPayloadRegistryTest, AudioRedWorkProperly) {
93 const uint8_t kRedPayloadType = 127; 92 const uint8_t kRedPayloadType = 127;
94 const int kRedSampleRate = 8000; 93 const int kRedSampleRate = 8000;
95 const int kRedChannels = 1; 94 const int kRedChannels = 1;
96 const int kRedBitRate = 0; 95 const int kRedBitRate = 0;
97 96
98 // This creates an audio RTP payload strategy. 97 // This creates an audio RTP payload strategy.
99 rtp_payload_registry_.reset(new RTPPayloadRegistry( 98 rtp_payload_registry_.reset(new RTPPayloadRegistry(
100 RTPPayloadStrategy::CreateStrategy(true))); 99 RTPPayloadStrategy::CreateStrategy(true)));
101 100
102 bool new_payload_created = false; 101 bool new_payload_created = false;
103 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( 102 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
104 "red", kRedPayloadType, kRedSampleRate, kRedChannels, kRedBitRate, 103 "red", kRedPayloadType, kRedSampleRate, kRedChannels, kRedBitRate,
105 &new_payload_created)); 104 &new_payload_created));
106 EXPECT_TRUE(new_payload_created); 105 EXPECT_TRUE(new_payload_created);
107 106
108 EXPECT_EQ(kRedPayloadType, rtp_payload_registry_->red_payload_type()); 107 EXPECT_EQ(kRedPayloadType, rtp_payload_registry_->red_payload_type());
109 108
110 RtpUtility::Payload* retrieved_payload = NULL; 109 RtpUtility::Payload* retrieved_payload =
111 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(kRedPayloadType, 110 rtp_payload_registry_->PayloadTypeToPayload(kRedPayloadType);
112 retrieved_payload)); 111 EXPECT_TRUE(retrieved_payload);
113 ASSERT_TRUE(retrieved_payload);
114 EXPECT_TRUE(retrieved_payload->audio); 112 EXPECT_TRUE(retrieved_payload->audio);
115 EXPECT_STRCASEEQ("red", retrieved_payload->name); 113 EXPECT_STRCASEEQ("red", retrieved_payload->name);
116 114
117 // Sample rate is correctly registered. 115 // Sample rate is correctly registered.
118 EXPECT_EQ(kRedSampleRate, 116 EXPECT_EQ(kRedSampleRate,
119 rtp_payload_registry_->GetPayloadTypeFrequency(kRedPayloadType)); 117 rtp_payload_registry_->GetPayloadTypeFrequency(kRedPayloadType));
120 } 118 }
121 119
122 TEST_F(RtpPayloadRegistryTest, 120 TEST_F(RtpPayloadRegistryTest,
123 DoesNotAcceptSamePayloadTypeTwiceExceptIfPayloadIsCompatible) { 121 DoesNotAcceptSamePayloadTypeTwiceExceptIfPayloadIsCompatible) {
(...skipping 11 matching lines...) Expand all
135 kTypicalRate, &ignored)) << "Adding same codec twice = bad."; 133 kTypicalRate, &ignored)) << "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, kTypicalChannels, 176 kTypicalPayloadName, payload_type, kTypicalFrequency, kTypicalChannels,
178 kTypicalRate, &ignored)); 177 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( 184 << "The first payload should be "
186 payload_type, retrieved_payload)) << "The first payload should be " 185 "deregistered because the only thing that differs is payload type.";
187 "deregistered because the only thing that differs is payload type."; 186 const RtpUtility::Payload* retrieved_payload =
188 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload( 187 rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1);
189 payload_type - 1, retrieved_payload)) << 188 EXPECT_TRUE(retrieved_payload)
190 "The second payload should still be registered though."; 189 << "The second payload should still be registered though.";
191 190
192 // Now ensure non-compatible codecs aren't removed. 191 // Now ensure non-compatible codecs aren't removed.
193 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _)) 192 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _))
194 .WillByDefault(Return(false)); 193 .WillByDefault(Return(false));
195 ExpectReturnOfTypicalAudioPayload(payload_type + 1, kTypicalRate); 194 ExpectReturnOfTypicalAudioPayload(payload_type + 1, kTypicalRate);
196 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( 195 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
197 kTypicalPayloadName, payload_type + 1, kTypicalFrequency, 196 kTypicalPayloadName, payload_type + 1, kTypicalFrequency,
198 kTypicalChannels, kTypicalRate, &ignored)); 197 kTypicalChannels, kTypicalRate, &ignored));
199 198
200 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload( 199 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1))
201 payload_type - 1, retrieved_payload)) << 200 << "Not compatible; both payloads should be kept.";
202 "Not compatible; both payloads should be kept."; 201 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type + 1))
203 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload( 202 << "Not compatible; both payloads should be kept.";
204 payload_type + 1, retrieved_payload)) <<
205 "Not compatible; both payloads should be kept.";
206 } 203 }
207 204
208 TEST_F(RtpPayloadRegistryTest, 205 TEST_F(RtpPayloadRegistryTest,
209 LastReceivedCodecTypesAreResetWhenRegisteringNewPayloadTypes) { 206 LastReceivedCodecTypesAreResetWhenRegisteringNewPayloadTypes) {
210 rtp_payload_registry_->set_last_received_payload_type(17); 207 rtp_payload_registry_->set_last_received_payload_type(17);
211 EXPECT_EQ(17, rtp_payload_registry_->last_received_payload_type()); 208 EXPECT_EQ(17, rtp_payload_registry_->last_received_payload_type());
212 209
213 bool media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18); 210 bool media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18);
214 EXPECT_FALSE(media_type_unchanged); 211 EXPECT_FALSE(media_type_unchanged);
215 media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18); 212 media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 rtp_payload_registry_->SetRtxPayloadType(105, 95); 389 rtp_payload_registry_->SetRtxPayloadType(105, 95);
393 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(true); 390 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(true);
394 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true); 391 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true);
395 TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false); 392 TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false);
396 } 393 }
397 394
398 INSTANTIATE_TEST_CASE_P(TestDynamicRange, RtpPayloadRegistryGenericTest, 395 INSTANTIATE_TEST_CASE_P(TestDynamicRange, RtpPayloadRegistryGenericTest,
399 testing::Range(96, 127+1)); 396 testing::Range(96, 127+1));
400 397
401 } // namespace webrtc 398 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698