Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 17 matching lines...) Expand all Loading... | |
| 28 static const size_t kTypicalChannels = 1; | 28 static const size_t kTypicalChannels = 1; |
| 29 static const int kTypicalFrequency = 44000; | 29 static const int kTypicalFrequency = 44000; |
| 30 static const int kTypicalRate = 32 * 1024; | 30 static const int kTypicalRate = 32 * 1024; |
| 31 | 31 |
| 32 class RtpPayloadRegistryTest : public ::testing::Test { | 32 class RtpPayloadRegistryTest : public ::testing::Test { |
| 33 public: | 33 public: |
| 34 void SetUp() { | 34 void SetUp() { |
| 35 // Note: the payload registry takes ownership of the strategy. | 35 // Note: the payload registry takes ownership of the strategy. |
| 36 mock_payload_strategy_ = new testing::NiceMock<MockRTPPayloadStrategy>(); | 36 mock_payload_strategy_ = new testing::NiceMock<MockRTPPayloadStrategy>(); |
| 37 rtp_payload_registry_.reset(new RTPPayloadRegistry(mock_payload_strategy_)); | 37 rtp_payload_registry_.reset(new RTPPayloadRegistry(mock_payload_strategy_)); |
| 38 | |
| 39 strcpy(typical_audio_codec_.plname, kTypicalPayloadName); | |
| 40 typical_audio_codec_.plfreq = kTypicalFrequency; | |
| 41 typical_audio_codec_.channels = kTypicalChannels; | |
| 42 typical_audio_codec_.rate = kTypicalRate; | |
| 38 } | 43 } |
| 39 | 44 |
| 40 protected: | 45 protected: |
| 41 RtpUtility::Payload* ExpectReturnOfTypicalAudioPayload(uint8_t payload_type, | 46 RtpUtility::Payload* ExpectReturnOfTypicalAudioPayload(uint8_t payload_type, |
| 42 uint32_t rate) { | 47 uint32_t rate) { |
| 43 bool audio = true; | 48 bool audio = true; |
| 44 RtpUtility::Payload returned_payload = { | 49 RtpUtility::Payload returned_payload = { |
| 45 "name", | 50 "name", |
| 46 audio, | 51 audio, |
| 47 {// Initialize the audio struct in this case. | 52 {// Initialize the audio struct in this case. |
| 48 {kTypicalFrequency, kTypicalChannels, rate}}}; | 53 {kTypicalFrequency, kTypicalChannels, rate}}}; |
| 49 | 54 |
| 50 // Note: we return a new payload since the payload registry takes ownership | 55 // Note: we return a new payload since the payload registry takes ownership |
| 51 // of the created object. | 56 // of the created object. |
| 52 RtpUtility::Payload* returned_payload_on_heap = | 57 RtpUtility::Payload* returned_payload_on_heap = |
| 53 new RtpUtility::Payload(returned_payload); | 58 new RtpUtility::Payload(returned_payload); |
| 54 EXPECT_CALL(*mock_payload_strategy_, | 59 EXPECT_CALL( |
| 55 CreatePayloadType(kTypicalPayloadName, payload_type, | 60 *mock_payload_strategy_, |
| 56 kTypicalFrequency, kTypicalChannels, rate)) | 61 CreatePayloadType(testing::StrEq(kTypicalPayloadName), payload_type, |
|
danilchap
2016/11/23 15:19:23
probably nicer to add using ::testing::StrEq above
magjed_webrtc
2016/11/23 16:35:53
Done.
| |
| 62 kTypicalFrequency, kTypicalChannels, rate)) | |
| 57 .WillOnce(Return(returned_payload_on_heap)); | 63 .WillOnce(Return(returned_payload_on_heap)); |
| 58 return returned_payload_on_heap; | 64 return returned_payload_on_heap; |
| 59 } | 65 } |
| 60 | 66 |
| 61 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_; | 67 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_; |
| 62 testing::NiceMock<MockRTPPayloadStrategy>* mock_payload_strategy_; | 68 testing::NiceMock<MockRTPPayloadStrategy>* mock_payload_strategy_; |
| 69 CodecInst typical_audio_codec_; | |
|
danilchap
2016/11/23 15:19:23
may be use constant outside of the fixture instead
magjed_webrtc
2016/11/23 16:35:53
Thanks, much better. I tried to do this but used k
| |
| 63 }; | 70 }; |
| 64 | 71 |
| 65 TEST_F(RtpPayloadRegistryTest, RegistersAndRemembersPayloadsUntilDeregistered) { | 72 TEST_F(RtpPayloadRegistryTest, RegistersAndRemembersPayloadsUntilDeregistered) { |
| 66 uint8_t payload_type = 97; | 73 uint8_t payload_type = 97; |
| 67 RtpUtility::Payload* returned_payload_on_heap = | 74 RtpUtility::Payload* returned_payload_on_heap = |
| 68 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); | 75 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); |
| 69 | 76 |
| 70 bool new_payload_created = false; | 77 bool new_payload_created = false; |
| 78 CodecInst audio_codec = typical_audio_codec_; | |
| 79 audio_codec.pltype = payload_type; | |
| 71 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 80 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( |
| 72 kTypicalPayloadName, payload_type, kTypicalFrequency, | 81 audio_codec, &new_payload_created)); |
| 73 kTypicalChannels, kTypicalRate, &new_payload_created)); | |
| 74 | 82 |
| 75 EXPECT_TRUE(new_payload_created) << "A new payload WAS created."; | 83 EXPECT_TRUE(new_payload_created) << "A new payload WAS created."; |
| 76 | 84 |
| 77 const RtpUtility::Payload* retrieved_payload = | 85 const RtpUtility::Payload* retrieved_payload = |
| 78 rtp_payload_registry_->PayloadTypeToPayload(payload_type); | 86 rtp_payload_registry_->PayloadTypeToPayload(payload_type); |
| 79 EXPECT_TRUE(retrieved_payload); | 87 EXPECT_TRUE(retrieved_payload); |
| 80 | 88 |
| 81 // We should get back the exact pointer to the payload returned by the | 89 // We should get back the exact pointer to the payload returned by the |
| 82 // payload strategy. | 90 // payload strategy. |
| 83 EXPECT_EQ(returned_payload_on_heap, retrieved_payload); | 91 EXPECT_EQ(returned_payload_on_heap, retrieved_payload); |
| 84 | 92 |
| 85 // Now forget about it and verify it's gone. | 93 // Now forget about it and verify it's gone. |
| 86 EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type)); | 94 EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type)); |
| 87 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type)); | 95 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type)); |
| 88 } | 96 } |
| 89 | 97 |
| 90 TEST_F(RtpPayloadRegistryTest, AudioRedWorkProperly) { | 98 TEST_F(RtpPayloadRegistryTest, AudioRedWorkProperly) { |
| 91 const uint8_t kRedPayloadType = 127; | 99 const uint8_t kRedPayloadType = 127; |
| 92 const int kRedSampleRate = 8000; | 100 const int kRedSampleRate = 8000; |
| 93 const size_t kRedChannels = 1; | 101 const size_t kRedChannels = 1; |
| 94 const int kRedBitRate = 0; | 102 const int kRedBitRate = 0; |
| 95 | 103 |
| 96 // This creates an audio RTP payload strategy. | 104 // This creates an audio RTP payload strategy. |
| 97 rtp_payload_registry_.reset( | 105 rtp_payload_registry_.reset( |
| 98 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))); | 106 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))); |
| 99 | 107 |
| 100 bool new_payload_created = false; | 108 bool new_payload_created = false; |
| 109 CodecInst red_audio_codec; | |
| 110 strcpy(red_audio_codec.plname, "red"); | |
| 111 red_audio_codec.pltype = kRedPayloadType; | |
| 112 red_audio_codec.plfreq = kRedSampleRate; | |
| 113 red_audio_codec.channels = kRedChannels; | |
| 114 red_audio_codec.rate = kRedBitRate; | |
| 101 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 115 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( |
| 102 "red", kRedPayloadType, kRedSampleRate, kRedChannels, | 116 red_audio_codec, &new_payload_created)); |
| 103 kRedBitRate, &new_payload_created)); | |
| 104 EXPECT_TRUE(new_payload_created); | 117 EXPECT_TRUE(new_payload_created); |
| 105 | 118 |
| 106 EXPECT_EQ(kRedPayloadType, rtp_payload_registry_->red_payload_type()); | 119 EXPECT_EQ(kRedPayloadType, rtp_payload_registry_->red_payload_type()); |
| 107 | 120 |
| 108 const RtpUtility::Payload* retrieved_payload = | 121 const RtpUtility::Payload* retrieved_payload = |
| 109 rtp_payload_registry_->PayloadTypeToPayload(kRedPayloadType); | 122 rtp_payload_registry_->PayloadTypeToPayload(kRedPayloadType); |
| 110 EXPECT_TRUE(retrieved_payload); | 123 EXPECT_TRUE(retrieved_payload); |
| 111 EXPECT_TRUE(retrieved_payload->audio); | 124 EXPECT_TRUE(retrieved_payload->audio); |
| 112 EXPECT_STRCASEEQ("red", retrieved_payload->name); | 125 EXPECT_STRCASEEQ("red", retrieved_payload->name); |
| 113 | 126 |
| 114 // Sample rate is correctly registered. | 127 // Sample rate is correctly registered. |
| 115 EXPECT_EQ(kRedSampleRate, | 128 EXPECT_EQ(kRedSampleRate, |
| 116 rtp_payload_registry_->GetPayloadTypeFrequency(kRedPayloadType)); | 129 rtp_payload_registry_->GetPayloadTypeFrequency(kRedPayloadType)); |
| 117 } | 130 } |
| 118 | 131 |
| 119 TEST_F(RtpPayloadRegistryTest, | 132 TEST_F(RtpPayloadRegistryTest, |
| 120 DoesNotAcceptSamePayloadTypeTwiceExceptIfPayloadIsCompatible) { | 133 DoesNotAcceptSamePayloadTypeTwiceExceptIfPayloadIsCompatible) { |
| 121 uint8_t payload_type = 97; | 134 uint8_t payload_type = 97; |
| 122 | 135 |
| 123 bool ignored = false; | 136 bool ignored = false; |
| 124 RtpUtility::Payload* first_payload_on_heap = | 137 RtpUtility::Payload* first_payload_on_heap = |
| 125 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); | 138 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); |
| 126 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 139 CodecInst audio_codec = typical_audio_codec_; |
| 127 kTypicalPayloadName, payload_type, kTypicalFrequency, | 140 audio_codec.pltype = payload_type; |
| 128 kTypicalChannels, kTypicalRate, &ignored)); | 141 EXPECT_EQ( |
| 142 0, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored)); | |
| 129 | 143 |
| 130 EXPECT_EQ(-1, rtp_payload_registry_->RegisterReceivePayload( | 144 EXPECT_EQ( |
| 131 kTypicalPayloadName, payload_type, kTypicalFrequency, | 145 -1, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored)) |
| 132 kTypicalChannels, kTypicalRate, &ignored)) | |
| 133 << "Adding same codec twice = bad."; | 146 << "Adding same codec twice = bad."; |
| 134 | 147 |
| 135 RtpUtility::Payload* second_payload_on_heap = | 148 RtpUtility::Payload* second_payload_on_heap = |
| 136 ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate); | 149 ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate); |
| 137 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 150 CodecInst audio_codec_2 = typical_audio_codec_; |
| 138 kTypicalPayloadName, payload_type - 1, kTypicalFrequency, | 151 audio_codec_2.pltype = payload_type - 1; |
| 139 kTypicalChannels, kTypicalRate, &ignored)) | 152 EXPECT_EQ( |
| 153 0, rtp_payload_registry_->RegisterReceivePayload(audio_codec_2, &ignored)) | |
| 140 << "With a different payload type is fine though."; | 154 << "With a different payload type is fine though."; |
| 141 | 155 |
| 142 // Ensure both payloads are preserved. | 156 // Ensure both payloads are preserved. |
| 143 const RtpUtility::Payload* retrieved_payload = | 157 const RtpUtility::Payload* retrieved_payload = |
| 144 rtp_payload_registry_->PayloadTypeToPayload(payload_type); | 158 rtp_payload_registry_->PayloadTypeToPayload(payload_type); |
| 145 EXPECT_TRUE(retrieved_payload); | 159 EXPECT_TRUE(retrieved_payload); |
| 146 EXPECT_EQ(first_payload_on_heap, retrieved_payload); | 160 EXPECT_EQ(first_payload_on_heap, retrieved_payload); |
| 147 retrieved_payload = | 161 retrieved_payload = |
| 148 rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1); | 162 rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1); |
| 149 EXPECT_TRUE(retrieved_payload); | 163 EXPECT_TRUE(retrieved_payload); |
| 150 EXPECT_EQ(second_payload_on_heap, retrieved_payload); | 164 EXPECT_EQ(second_payload_on_heap, retrieved_payload); |
| 151 | 165 |
| 152 // Ok, update the rate for one of the codecs. If either the incoming rate or | 166 // Ok, update the rate for one of the codecs. If either the incoming rate or |
| 153 // the stored rate is zero it's not really an error to register the same | 167 // the stored rate is zero it's not really an error to register the same |
| 154 // codec twice, and in that case roughly the following happens. | 168 // codec twice, and in that case roughly the following happens. |
| 155 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _)) | 169 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _)) |
| 156 .WillByDefault(Return(true)); | 170 .WillByDefault(Return(true)); |
| 157 EXPECT_CALL(*mock_payload_strategy_, | 171 EXPECT_CALL(*mock_payload_strategy_, |
| 158 UpdatePayloadRate(first_payload_on_heap, kTypicalRate)); | 172 UpdatePayloadRate(first_payload_on_heap, kTypicalRate)); |
| 159 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 173 EXPECT_EQ( |
| 160 kTypicalPayloadName, payload_type, kTypicalFrequency, | 174 0, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored)); |
| 161 kTypicalChannels, kTypicalRate, &ignored)); | |
| 162 } | 175 } |
| 163 | 176 |
| 164 TEST_F(RtpPayloadRegistryTest, | 177 TEST_F(RtpPayloadRegistryTest, |
| 165 RemovesCompatibleCodecsOnRegistryIfCodecsMustBeUnique) { | 178 RemovesCompatibleCodecsOnRegistryIfCodecsMustBeUnique) { |
| 166 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _)) | 179 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _)) |
| 167 .WillByDefault(Return(true)); | 180 .WillByDefault(Return(true)); |
| 168 ON_CALL(*mock_payload_strategy_, CodecsMustBeUnique()) | 181 ON_CALL(*mock_payload_strategy_, CodecsMustBeUnique()) |
| 169 .WillByDefault(Return(true)); | 182 .WillByDefault(Return(true)); |
| 170 | 183 |
| 171 uint8_t payload_type = 97; | 184 uint8_t payload_type = 97; |
| 172 | 185 |
| 173 bool ignored = false; | 186 bool ignored = false; |
| 174 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); | 187 ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate); |
| 175 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 188 CodecInst audio_codec = typical_audio_codec_; |
| 176 kTypicalPayloadName, payload_type, kTypicalFrequency, | 189 audio_codec.pltype = payload_type; |
| 177 kTypicalChannels, kTypicalRate, &ignored)); | 190 EXPECT_EQ( |
| 191 0, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored)); | |
| 178 ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate); | 192 ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate); |
| 179 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 193 CodecInst audio_codec_2 = typical_audio_codec_; |
| 180 kTypicalPayloadName, payload_type - 1, kTypicalFrequency, | 194 audio_codec_2.pltype = payload_type - 1; |
| 181 kTypicalChannels, kTypicalRate, &ignored)); | 195 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(audio_codec_2, |
| 196 &ignored)); | |
| 182 | 197 |
| 183 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type)) | 198 EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type)) |
| 184 << "The first payload should be " | 199 << "The first payload should be " |
| 185 "deregistered because the only thing that differs is payload type."; | 200 "deregistered because the only thing that differs is payload type."; |
| 186 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1)) | 201 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1)) |
| 187 << "The second payload should still be registered though."; | 202 << "The second payload should still be registered though."; |
| 188 | 203 |
| 189 // Now ensure non-compatible codecs aren't removed. | 204 // Now ensure non-compatible codecs aren't removed. |
| 190 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _)) | 205 ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _)) |
| 191 .WillByDefault(Return(false)); | 206 .WillByDefault(Return(false)); |
| 192 ExpectReturnOfTypicalAudioPayload(payload_type + 1, kTypicalRate); | 207 ExpectReturnOfTypicalAudioPayload(payload_type + 1, kTypicalRate); |
| 193 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 208 CodecInst audio_codec_3 = typical_audio_codec_; |
| 194 kTypicalPayloadName, payload_type + 1, kTypicalFrequency, | 209 audio_codec_3.pltype = payload_type + 1; |
| 195 kTypicalChannels, kTypicalRate, &ignored)); | 210 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(audio_codec_3, |
| 211 &ignored)); | |
| 196 | 212 |
| 197 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1)) | 213 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1)) |
| 198 << "Not compatible; both payloads should be kept."; | 214 << "Not compatible; both payloads should be kept."; |
| 199 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type + 1)) | 215 EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type + 1)) |
| 200 << "Not compatible; both payloads should be kept."; | 216 << "Not compatible; both payloads should be kept."; |
| 201 } | 217 } |
| 202 | 218 |
| 203 TEST_F(RtpPayloadRegistryTest, | 219 TEST_F(RtpPayloadRegistryTest, |
| 204 LastReceivedCodecTypesAreResetWhenRegisteringNewPayloadTypes) { | 220 LastReceivedCodecTypesAreResetWhenRegisteringNewPayloadTypes) { |
| 205 rtp_payload_registry_->set_last_received_payload_type(17); | 221 rtp_payload_registry_->set_last_received_payload_type(17); |
| 206 EXPECT_EQ(17, rtp_payload_registry_->last_received_payload_type()); | 222 EXPECT_EQ(17, rtp_payload_registry_->last_received_payload_type()); |
| 207 | 223 |
| 208 bool media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18); | 224 bool media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18); |
| 209 EXPECT_FALSE(media_type_unchanged); | 225 EXPECT_FALSE(media_type_unchanged); |
| 210 media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18); | 226 media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18); |
| 211 EXPECT_TRUE(media_type_unchanged); | 227 EXPECT_TRUE(media_type_unchanged); |
| 212 | 228 |
| 213 bool ignored; | 229 bool ignored; |
| 214 ExpectReturnOfTypicalAudioPayload(34, kTypicalRate); | 230 ExpectReturnOfTypicalAudioPayload(34, kTypicalRate); |
| 215 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 231 CodecInst audio_codec = typical_audio_codec_; |
| 216 kTypicalPayloadName, 34, kTypicalFrequency, kTypicalChannels, | 232 audio_codec.pltype = 34; |
| 217 kTypicalRate, &ignored)); | 233 EXPECT_EQ( |
| 234 0, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored)); | |
| 218 | 235 |
| 219 EXPECT_EQ(-1, rtp_payload_registry_->last_received_payload_type()); | 236 EXPECT_EQ(-1, rtp_payload_registry_->last_received_payload_type()); |
| 220 media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18); | 237 media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18); |
| 221 EXPECT_FALSE(media_type_unchanged); | 238 EXPECT_FALSE(media_type_unchanged); |
| 222 } | 239 } |
| 223 | 240 |
| 224 class ParameterizedRtpPayloadRegistryTest | 241 class ParameterizedRtpPayloadRegistryTest |
| 225 : public RtpPayloadRegistryTest, | 242 : public RtpPayloadRegistryTest, |
| 226 public ::testing::WithParamInterface<int> {}; | 243 public ::testing::WithParamInterface<int> {}; |
| 227 | 244 |
| 228 TEST_P(ParameterizedRtpPayloadRegistryTest, | 245 TEST_P(ParameterizedRtpPayloadRegistryTest, |
| 229 FailsToRegisterKnownPayloadsWeAreNotInterestedIn) { | 246 FailsToRegisterKnownPayloadsWeAreNotInterestedIn) { |
| 230 int payload_type = GetParam(); | 247 int payload_type = GetParam(); |
| 231 | 248 |
| 232 bool ignored; | 249 bool ignored; |
| 233 EXPECT_EQ(-1, rtp_payload_registry_->RegisterReceivePayload( | 250 CodecInst audio_codec; |
| 234 "whatever", static_cast<uint8_t>(payload_type), 19, 1, 17, | 251 strcpy(audio_codec.plname, "whatever"); |
| 235 &ignored)); | 252 audio_codec.pltype = static_cast<uint8_t>(payload_type); |
| 253 audio_codec.plfreq = 19; | |
| 254 audio_codec.channels = 1; | |
| 255 audio_codec.rate = 17; | |
| 256 EXPECT_EQ( | |
| 257 -1, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored)); | |
| 236 } | 258 } |
| 237 | 259 |
| 238 INSTANTIATE_TEST_CASE_P(TestKnownBadPayloadTypes, | 260 INSTANTIATE_TEST_CASE_P(TestKnownBadPayloadTypes, |
| 239 ParameterizedRtpPayloadRegistryTest, | 261 ParameterizedRtpPayloadRegistryTest, |
| 240 testing::Values(64, 72, 73, 74, 75, 76, 77, 78, 79)); | 262 testing::Values(64, 72, 73, 74, 75, 76, 77, 78, 79)); |
| 241 | 263 |
| 242 class RtpPayloadRegistryGenericTest | 264 class RtpPayloadRegistryGenericTest |
| 243 : public RtpPayloadRegistryTest, | 265 : public RtpPayloadRegistryTest, |
| 244 public ::testing::WithParamInterface<int> {}; | 266 public ::testing::WithParamInterface<int> {}; |
| 245 | 267 |
| 246 TEST_P(RtpPayloadRegistryGenericTest, RegisterGenericReceivePayloadType) { | 268 TEST_P(RtpPayloadRegistryGenericTest, RegisterGenericReceivePayloadType) { |
| 247 int payload_type = GetParam(); | 269 int payload_type = GetParam(); |
| 248 | 270 |
| 249 bool ignored; | 271 bool ignored; |
| 250 | 272 |
| 251 EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload( | 273 CodecInst audio_codec; |
| 252 "generic-codec", static_cast<int8_t>(payload_type), 19, 1, | 274 strcpy(audio_codec.plname, "generic-codec"); |
| 253 17, &ignored)); // dummy values, except for payload_type | 275 audio_codec.pltype = static_cast<uint8_t>(payload_type); |
| 276 audio_codec.plfreq = 19; | |
| 277 audio_codec.channels = 1; | |
| 278 audio_codec.rate = 17; | |
| 279 EXPECT_EQ( | |
| 280 0, rtp_payload_registry_->RegisterReceivePayload( | |
| 281 audio_codec, &ignored)); // dummy values, except for payload_type | |
|
danilchap
2016/11/23 15:19:23
May be fix comment as well: add dot in the end, st
magjed_webrtc
2016/11/23 16:35:53
Done.
| |
| 254 } | 282 } |
| 255 | 283 |
| 256 // Generates an RTX packet for the given length and original sequence number. | 284 // Generates an RTX packet for the given length and original sequence number. |
| 257 // The RTX sequence number and ssrc will use the default value of 9999. The | 285 // The RTX sequence number and ssrc will use the default value of 9999. The |
| 258 // caller takes ownership of the returned buffer. | 286 // caller takes ownership of the returned buffer. |
| 259 const uint8_t* GenerateRtxPacket(size_t header_length, | 287 const uint8_t* GenerateRtxPacket(size_t header_length, |
| 260 size_t payload_length, | 288 size_t payload_length, |
| 261 uint16_t original_sequence_number) { | 289 uint16_t original_sequence_number) { |
| 262 uint8_t* packet = | 290 uint8_t* packet = |
| 263 new uint8_t[kRtxHeaderSize + header_length + payload_length](); | 291 new uint8_t[kRtxHeaderSize + header_length + payload_length](); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 // Succeeds when the mapping is used, but fails for the implicit fallback. | 375 // Succeeds when the mapping is used, but fails for the implicit fallback. |
| 348 rtp_payload_registry_->SetRtxPayloadType(105, 95); | 376 rtp_payload_registry_->SetRtxPayloadType(105, 95); |
| 349 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true); | 377 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true); |
| 350 TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false); | 378 TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false); |
| 351 } | 379 } |
| 352 | 380 |
| 353 INSTANTIATE_TEST_CASE_P(TestDynamicRange, | 381 INSTANTIATE_TEST_CASE_P(TestDynamicRange, |
| 354 RtpPayloadRegistryGenericTest, | 382 RtpPayloadRegistryGenericTest, |
| 355 testing::Range(96, 127 + 1)); | 383 testing::Range(96, 127 + 1)); |
| 356 | 384 |
| 357 } // namespace webrtc | 385 } // namespace webrtc |
|
hta-webrtc
2016/11/23 16:08:24
There's a new function added that takes a VideoCod
magjed_webrtc
2016/11/23 16:35:53
Yeah, you are right. I added a default test for vi
| |
| OLD | NEW |