aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc')
-rw-r--r--webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc141
1 files changed, 68 insertions, 73 deletions
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 0b9bf2751e..b73666d1af 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc
@@ -8,12 +8,12 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
+#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
-#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
+#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
#include "webrtc/modules/rtp_rtcp/source/mock/mock_rtp_payload_strategy.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
@@ -25,7 +25,7 @@ using ::testing::Return;
using ::testing::_;
static const char* kTypicalPayloadName = "name";
-static const uint8_t kTypicalChannels = 1;
+static const size_t kTypicalChannels = 1;
static const int kTypicalFrequency = 44000;
static const int kTypicalRate = 32 * 1024;
@@ -52,10 +52,9 @@ class RtpPayloadRegistryTest : public ::testing::Test {
RtpUtility::Payload* returned_payload_on_heap =
new RtpUtility::Payload(returned_payload);
EXPECT_CALL(*mock_payload_strategy_,
- CreatePayloadType(kTypicalPayloadName, payload_type,
- kTypicalFrequency,
- kTypicalChannels,
- rate)).WillOnce(Return(returned_payload_on_heap));
+ CreatePayloadType(kTypicalPayloadName, payload_type,
+ kTypicalFrequency, kTypicalChannels, rate))
+ .WillOnce(Return(returned_payload_on_heap));
return returned_payload_on_heap;
}
@@ -70,14 +69,14 @@ TEST_F(RtpPayloadRegistryTest, RegistersAndRemembersPayloadsUntilDeregistered) {
bool new_payload_created = false;
EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type, kTypicalFrequency, kTypicalChannels,
- kTypicalRate, &new_payload_created));
+ kTypicalPayloadName, payload_type, kTypicalFrequency,
+ kTypicalChannels, kTypicalRate, &new_payload_created));
EXPECT_TRUE(new_payload_created) << "A new payload WAS created.";
- RtpUtility::Payload* retrieved_payload = NULL;
- EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type,
- retrieved_payload));
+ const RtpUtility::Payload* retrieved_payload =
+ rtp_payload_registry_->PayloadTypeToPayload(payload_type);
+ EXPECT_TRUE(retrieved_payload);
// We should get back the exact pointer to the payload returned by the
// payload strategy.
@@ -85,32 +84,30 @@ TEST_F(RtpPayloadRegistryTest, RegistersAndRemembersPayloadsUntilDeregistered) {
// Now forget about it and verify it's gone.
EXPECT_EQ(0, rtp_payload_registry_->DeRegisterReceivePayload(payload_type));
- EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(
- payload_type, retrieved_payload));
+ EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type));
}
TEST_F(RtpPayloadRegistryTest, AudioRedWorkProperly) {
const uint8_t kRedPayloadType = 127;
const int kRedSampleRate = 8000;
- const int kRedChannels = 1;
+ const size_t kRedChannels = 1;
const int kRedBitRate = 0;
// This creates an audio RTP payload strategy.
- rtp_payload_registry_.reset(new RTPPayloadRegistry(
- RTPPayloadStrategy::CreateStrategy(true)));
+ rtp_payload_registry_.reset(
+ new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true)));
bool new_payload_created = false;
EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- "red", kRedPayloadType, kRedSampleRate, kRedChannels, kRedBitRate,
- &new_payload_created));
+ "red", kRedPayloadType, kRedSampleRate, kRedChannels,
+ kRedBitRate, &new_payload_created));
EXPECT_TRUE(new_payload_created);
EXPECT_EQ(kRedPayloadType, rtp_payload_registry_->red_payload_type());
- RtpUtility::Payload* retrieved_payload = NULL;
- EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(kRedPayloadType,
- retrieved_payload));
- ASSERT_TRUE(retrieved_payload);
+ const RtpUtility::Payload* retrieved_payload =
+ rtp_payload_registry_->PayloadTypeToPayload(kRedPayloadType);
+ EXPECT_TRUE(retrieved_payload);
EXPECT_TRUE(retrieved_payload->audio);
EXPECT_STRCASEEQ("red", retrieved_payload->name);
@@ -127,27 +124,29 @@ TEST_F(RtpPayloadRegistryTest,
RtpUtility::Payload* first_payload_on_heap =
ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate);
EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type, kTypicalFrequency, kTypicalChannels,
- kTypicalRate, &ignored));
+ kTypicalPayloadName, payload_type, kTypicalFrequency,
+ kTypicalChannels, kTypicalRate, &ignored));
EXPECT_EQ(-1, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type, kTypicalFrequency, kTypicalChannels,
- kTypicalRate, &ignored)) << "Adding same codec twice = bad.";
+ kTypicalPayloadName, payload_type, kTypicalFrequency,
+ kTypicalChannels, kTypicalRate, &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)) <<
- "With a different payload type is fine though.";
+ kTypicalPayloadName, payload_type - 1, kTypicalFrequency,
+ kTypicalChannels, kTypicalRate, &ignored))
+ << "With a different payload type is fine though.";
// Ensure both payloads are preserved.
- RtpUtility::Payload* retrieved_payload = NULL;
- EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type,
- retrieved_payload));
+ const RtpUtility::Payload* retrieved_payload =
+ rtp_payload_registry_->PayloadTypeToPayload(payload_type);
+ EXPECT_TRUE(retrieved_payload);
EXPECT_EQ(first_payload_on_heap, retrieved_payload);
- EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1,
- retrieved_payload));
+ retrieved_payload =
+ rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1);
+ EXPECT_TRUE(retrieved_payload);
EXPECT_EQ(second_payload_on_heap, retrieved_payload);
// Ok, update the rate for one of the codecs. If either the incoming rate or
@@ -158,8 +157,8 @@ TEST_F(RtpPayloadRegistryTest,
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));
+ kTypicalPayloadName, payload_type, kTypicalFrequency,
+ kTypicalChannels, kTypicalRate, &ignored));
}
TEST_F(RtpPayloadRegistryTest,
@@ -174,35 +173,31 @@ TEST_F(RtpPayloadRegistryTest,
bool ignored = false;
ExpectReturnOfTypicalAudioPayload(payload_type, kTypicalRate);
EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type, kTypicalFrequency, kTypicalChannels,
- kTypicalRate, &ignored));
+ kTypicalPayloadName, payload_type, kTypicalFrequency,
+ kTypicalChannels, kTypicalRate, &ignored));
ExpectReturnOfTypicalAudioPayload(payload_type - 1, kTypicalRate);
EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, payload_type - 1, kTypicalFrequency,
- kTypicalChannels, kTypicalRate, &ignored));
+ kTypicalPayloadName, payload_type - 1, kTypicalFrequency,
+ kTypicalChannels, kTypicalRate, &ignored));
- RtpUtility::Payload* retrieved_payload = NULL;
- EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(
- payload_type, retrieved_payload)) << "The first payload should be "
- "deregistered because the only thing that differs is payload type.";
- EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(
- payload_type - 1, retrieved_payload)) <<
- "The second payload should still be registered though.";
+ EXPECT_FALSE(rtp_payload_registry_->PayloadTypeToPayload(payload_type))
+ << "The first payload should be "
+ "deregistered because the only thing that differs is payload type.";
+ EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1))
+ << "The second payload should still be registered though.";
// Now ensure non-compatible codecs aren't removed.
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));
-
- EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(
- payload_type - 1, retrieved_payload)) <<
- "Not compatible; both payloads should be kept.";
- EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(
- payload_type + 1, retrieved_payload)) <<
- "Not compatible; both payloads should be kept.";
+ kTypicalPayloadName, payload_type + 1, kTypicalFrequency,
+ kTypicalChannels, kTypicalRate, &ignored));
+
+ EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type - 1))
+ << "Not compatible; both payloads should be kept.";
+ EXPECT_TRUE(rtp_payload_registry_->PayloadTypeToPayload(payload_type + 1))
+ << "Not compatible; both payloads should be kept.";
}
TEST_F(RtpPayloadRegistryTest,
@@ -218,18 +213,17 @@ TEST_F(RtpPayloadRegistryTest,
bool ignored;
ExpectReturnOfTypicalAudioPayload(34, kTypicalRate);
EXPECT_EQ(0, rtp_payload_registry_->RegisterReceivePayload(
- kTypicalPayloadName, 34, kTypicalFrequency, kTypicalChannels,
- kTypicalRate, &ignored));
+ kTypicalPayloadName, 34, kTypicalFrequency, kTypicalChannels,
+ kTypicalRate, &ignored));
EXPECT_EQ(-1, rtp_payload_registry_->last_received_payload_type());
media_type_unchanged = rtp_payload_registry_->ReportMediaPayloadType(18);
EXPECT_FALSE(media_type_unchanged);
}
-class ParameterizedRtpPayloadRegistryTest :
- public RtpPayloadRegistryTest,
- public ::testing::WithParamInterface<int> {
-};
+class ParameterizedRtpPayloadRegistryTest
+ : public RtpPayloadRegistryTest,
+ public ::testing::WithParamInterface<int> {};
TEST_P(ParameterizedRtpPayloadRegistryTest,
FailsToRegisterKnownPayloadsWeAreNotInterestedIn) {
@@ -237,26 +231,26 @@ TEST_P(ParameterizedRtpPayloadRegistryTest,
bool ignored;
EXPECT_EQ(-1, rtp_payload_registry_->RegisterReceivePayload(
- "whatever", static_cast<uint8_t>(payload_type), 19, 1, 17, &ignored));
+ "whatever", static_cast<uint8_t>(payload_type), 19, 1, 17,
+ &ignored));
}
INSTANTIATE_TEST_CASE_P(TestKnownBadPayloadTypes,
ParameterizedRtpPayloadRegistryTest,
testing::Values(64, 72, 73, 74, 75, 76, 77, 78, 79));
-class RtpPayloadRegistryGenericTest :
- public RtpPayloadRegistryTest,
- public ::testing::WithParamInterface<int> {
-};
+class RtpPayloadRegistryGenericTest
+ : public RtpPayloadRegistryTest,
+ public ::testing::WithParamInterface<int> {};
TEST_P(RtpPayloadRegistryGenericTest, RegisterGenericReceivePayloadType) {
int payload_type = GetParam();
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
+ 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
}
// Generates an RTX packet for the given length and original sequence number.
@@ -395,7 +389,8 @@ TEST_F(RtpPayloadRegistryTest, InvalidRtxConfiguration) {
TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false);
}
-INSTANTIATE_TEST_CASE_P(TestDynamicRange, RtpPayloadRegistryGenericTest,
- testing::Range(96, 127+1));
+INSTANTIATE_TEST_CASE_P(TestDynamicRange,
+ RtpPayloadRegistryGenericTest,
+ testing::Range(96, 127 + 1));
} // namespace webrtc