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

Unified Diff: webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc

Issue 2523843002: Send audio and video codecs to RTPPayloadRegistry (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc
index abb2ae91c4eedbbfca564949ac6f2ee5bcab946b..9e8f4c44e82087c4bd771ac1c0fab2d36151ba37 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc
@@ -35,6 +35,11 @@ class RtpPayloadRegistryTest : public ::testing::Test {
// Note: the payload registry takes ownership of the strategy.
mock_payload_strategy_ = new testing::NiceMock<MockRTPPayloadStrategy>();
rtp_payload_registry_.reset(new RTPPayloadRegistry(mock_payload_strategy_));
+
+ strcpy(typical_audio_codec_.plname, kTypicalPayloadName);
+ typical_audio_codec_.plfreq = kTypicalFrequency;
+ typical_audio_codec_.channels = kTypicalChannels;
+ typical_audio_codec_.rate = kTypicalRate;
}
protected:
@@ -51,15 +56,17 @@ class RtpPayloadRegistryTest : public ::testing::Test {
// of the created object.
RtpUtility::Payload* returned_payload_on_heap =
new RtpUtility::Payload(returned_payload);
- EXPECT_CALL(*mock_payload_strategy_,
- CreatePayloadType(kTypicalPayloadName, payload_type,
- kTypicalFrequency, kTypicalChannels, rate))
+ EXPECT_CALL(
+ *mock_payload_strategy_,
+ 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.
+ kTypicalFrequency, kTypicalChannels, rate))
.WillOnce(Return(returned_payload_on_heap));
return returned_payload_on_heap;
}
std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_;
testing::NiceMock<MockRTPPayloadStrategy>* mock_payload_strategy_;
+ 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
};
TEST_F(RtpPayloadRegistryTest, RegistersAndRemembersPayloadsUntilDeregistered) {
@@ -68,9 +75,10 @@ TEST_F(RtpPayloadRegistryTest, RegistersAndRemembersPayloadsUntilDeregistered) {
ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate);
bool new_payload_created = false;
+ CodecInst audio_codec = typical_audio_codec_;
+ audio_codec.pltype = payload_type;
EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type, kTypicalFrequency,
- kTypicalChannels, kTypicalRate, &new_payload_created));
+ audio_codec, &new_payload_created));
EXPECT_TRUE(new_payload_created) << "A new payload WAS created.";
@@ -98,9 +106,14 @@ TEST_F(RtpPayloadRegistryTest, AudioRedWorkProperly) {
new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true)));
bool new_payload_created = false;
+ CodecInst red_audio_codec;
+ strcpy(red_audio_codec.plname, "red");
+ red_audio_codec.pltype = kRedPayloadType;
+ red_audio_codec.plfreq = kRedSampleRate;
+ red_audio_codec.channels = kRedChannels;
+ red_audio_codec.rate = kRedBitRate;
EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- "red", kRedPayloadType, kRedSampleRate, kRedChannels,
- kRedBitRate, &new_payload_created));
+ red_audio_codec, &new_payload_created));
EXPECT_TRUE(new_payload_created);
EXPECT_EQ(kRedPayloadType, rtp_payload_registry_->red_payload_type());
@@ -123,20 +136,21 @@ TEST_F(RtpPayloadRegistryTest,
bool ignored = false;
RtpUtility::Payload* first_payload_on_heap =
ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate);
- EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type, kTypicalFrequency,
- kTypicalChannels, kTypicalRate, &ignored));
+ CodecInst audio_codec = typical_audio_codec_;
+ audio_codec.pltype = payload_type;
+ EXPECT_EQ(
+ 0, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored));
- EXPECT_EQ(-1, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type, kTypicalFrequency,
- kTypicalChannels, kTypicalRate, &ignored))
+ EXPECT_EQ(
+ -1, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored))
<< "Adding same codec twice = bad.";
RtpUtility::Payload* second_payload_on_heap =
ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate);
- EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type - 1, kTypicalFrequency,
- kTypicalChannels, kTypicalRate, &ignored))
+ CodecInst audio_codec_2 = typical_audio_codec_;
+ audio_codec_2.pltype = payload_type - 1;
+ EXPECT_EQ(
+ 0, rtp_payload_registry_->RegisterReceivePayload(audio_codec_2, &ignored))
<< "With a different payload type is fine though.";
// Ensure both payloads are preserved.
@@ -156,9 +170,8 @@ TEST_F(RtpPayloadRegistryTest,
.WillByDefault(Return(true));
EXPECT_CALL(*mock_payload_strategy_,
UpdatePayloadRate(first_payload_on_heap, kTypicalRate));
- EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type, kTypicalFrequency,
- kTypicalChannels, kTypicalRate, &ignored));
+ EXPECT_EQ(
+ 0, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored));
}
TEST_F(RtpPayloadRegistryTest,
@@ -172,13 +185,15 @@ TEST_F(RtpPayloadRegistryTest,
bool ignored = false;
ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate);
- EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type, kTypicalFrequency,
- kTypicalChannels, kTypicalRate, &ignored));
+ CodecInst audio_codec = typical_audio_codec_;
+ audio_codec.pltype = payload_type;
+ EXPECT_EQ(
+ 0, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored));
ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate);
- EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type - 1, kTypicalFrequency,
- kTypicalChannels, kTypicalRate, &ignored));
+ CodecInst audio_codec_2 = typical_audio_codec_;
+ audio_codec_2.pltype = payload_type - 1;
+ EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(audio_codec_2,
+ &ignored));
EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type))
<< "The first payload should be "
@@ -190,9 +205,10 @@ TEST_F(RtpPayloadRegistryTest,
ON_CALL(*mock_payload_strategy_, PayloadIsCompatible(_, _, _, _))
.WillByDefault(Return(false));
ExpectReturnOfTypicalAudioPayload(payload_type + 1, kTypicalRate);
- EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type + 1, kTypicalFrequency,
- kTypicalChannels, kTypicalRate, &ignored));
+ CodecInst audio_codec_3 = typical_audio_codec_;
+ audio_codec_3.pltype = payload_type + 1;
+ EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(audio_codec_3,
+ &ignored));
EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1))
<< "Not compatible; both payloads should be kept.";
@@ -212,9 +228,10 @@ TEST_F(RtpPayloadRegistryTest,
bool ignored;
ExpectReturnOfTypicalAudioPayload(34, kTypicalRate);
- EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, 34, kTypicalFrequency, kTypicalChannels,
- kTypicalRate, &ignored));
+ CodecInst audio_codec = typical_audio_codec_;
+ audio_codec.pltype = 34;
+ EXPECT_EQ(
+ 0, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored));
EXPECT_EQ(-1, rtp_payload_registry_->last_received_payload_type());
media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18);
@@ -230,9 +247,14 @@ TEST_P(ParameterizedRtpPayloadRegistryTest,
int payload_type = GetParam();
bool ignored;
- EXPECT_EQ(-1, rtp_payload_registry_->RegisterReceivePayload(
- "whatever", static_cast<uint8_t>(payload_type), 19, 1, 17,
- &ignored));
+ CodecInst audio_codec;
+ strcpy(audio_codec.plname, "whatever");
+ audio_codec.pltype = static_cast<uint8_t>(payload_type);
+ audio_codec.plfreq = 19;
+ audio_codec.channels = 1;
+ audio_codec.rate = 17;
+ EXPECT_EQ(
+ -1, rtp_payload_registry_->RegisterReceivePayload(audio_codec, &ignored));
}
INSTANTIATE_TEST_CASE_P(TestKnownBadPayloadTypes,
@@ -248,9 +270,15 @@ TEST_P(RtpPayloadRegistryGenericTest, RegisterGenericReceivePayloadType) {
bool ignored;
- EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- "generic-codec", static_cast<int8_t>(payload_type), 19, 1,
- 17, &ignored)); // dummy values, except for payload_type
+ CodecInst audio_codec;
+ strcpy(audio_codec.plname, "generic-codec");
+ audio_codec.pltype = static_cast<uint8_t>(payload_type);
+ audio_codec.plfreq = 19;
+ audio_codec.channels = 1;
+ audio_codec.rate = 17;
+ EXPECT_EQ(
+ 0, rtp_payload_registry_->RegisterReceivePayload(
+ 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.
}
// Generates an RTX packet for the given length and original sequence number.

Powered by Google App Engine
This is Rietveld 408576698