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

Unified Diff: webrtc/audio/audio_send_stream_tests.cc

Issue 3007383002: Replace voe_auto_test (Closed)
Patch Set: rebase Created 3 years, 3 months 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/audio/audio_send_stream_tests.cc
diff --git a/webrtc/audio/audio_send_stream_tests.cc b/webrtc/audio/audio_send_stream_tests.cc
new file mode 100644
index 0000000000000000000000000000000000000000..61be88e3c541c1ac56fb373792adad0016bf723d
--- /dev/null
+++ b/webrtc/audio/audio_send_stream_tests.cc
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/test/call_test.h"
+#include "webrtc/test/gtest.h"
+#include "webrtc/test/rtcp_packet_parser.h"
+
+namespace webrtc {
+namespace test {
+namespace {
+
+class AudioSendTest : public SendTest {
+ public:
+ AudioSendTest() : SendTest(CallTest::kDefaultTimeoutMs) {}
+
+ size_t GetNumVideoStreams() const override {
+ return 0;
+ }
+ size_t GetNumAudioStreams() const override {
+ return 1;
+ }
+ size_t GetNumFlexfecStreams() const override {
+ return 0;
+ }
+};
+} // namespace
+
+using AudioSendStreamCallTest = CallTest;
+
+TEST_F(AudioSendStreamCallTest, SupportsCName) {
+ static std::string kCName = "PjqatC14dGfbVwGPUOA9IH7RlsFDbWl4AhXEiDsBizo=";
+ class CNameObserver : public AudioSendTest {
+ public:
+ CNameObserver() : AudioSendTest() {}
ossu 2017/09/14 11:51:58 Will CNameObserver() = default; do?
the sun 2017/09/14 12:36:39 Done.
+
+ private:
+ Action OnSendRtcp(const uint8_t* packet, size_t length) override {
+ RtcpPacketParser parser;
+ EXPECT_TRUE(parser.Parse(packet, length));
+ if (parser.sdes()->num_packets() > 0) {
+ EXPECT_EQ(1u, parser.sdes()->chunks().size());
+ EXPECT_EQ(kCName, parser.sdes()->chunks()[0].cname);
+
+ observation_complete_.Set();
+ }
+
+ return SEND_PACKET;
+ }
+
+ void ModifyAudioConfigs(
+ AudioSendStream::Config* send_config,
+ std::vector<AudioReceiveStream::Config>* receive_configs) override {
+ send_config->rtp.c_name = kCName;
+ }
+
+ void PerformTest() override {
+ EXPECT_TRUE(Wait()) << "Timed out while waiting for RTCP with CNAME.";
+ }
+ } test;
+
+ RunBaseTest(&test);
+}
+
+TEST_F(AudioSendStreamCallTest, SupportsAudioLevel) {
+ class AudioLevelObserver : public AudioSendTest {
+ public:
+ AudioLevelObserver() : AudioSendTest() {
+ EXPECT_TRUE(parser_->RegisterRtpHeaderExtension(
+ kRtpExtensionAudioLevel, test::kAudioLevelExtensionId));
+ }
+
+ Action OnSendRtp(const uint8_t* packet, size_t length) override {
+ RTPHeader header;
+ EXPECT_TRUE(parser_->Parse(packet, length, &header));
+
+ EXPECT_TRUE(header.extension.hasAudioLevel);
ossu 2017/09/14 11:51:58 The old tests included one that checked that no au
the sun 2017/09/14 12:36:40 Done.
+ if (header.extension.audioLevel != 0) {
+ // Wait for at least one packet with a non-zero level.
+ observation_complete_.Set();
+ } else {
+ LOG(LS_WARNING) << "Got a packet with zero audioLevel - waiting"
ossu 2017/09/14 11:51:58 When can this happen? Where does the audio come fr
the sun 2017/09/14 12:36:39 The test signal is a periodic noise burst.
ossu 2017/09/14 12:51:32 Alright. I was thinking if this would often get lo
the sun 2017/09/14 20:05:05 It is benign as long as the test eventually comple
+ " for another packet...";
+ }
+
+ return SEND_PACKET;
+ }
+
+ void ModifyAudioConfigs(
+ AudioSendStream::Config* send_config,
+ std::vector<AudioReceiveStream::Config>* receive_configs) override {
+ send_config->rtp.extensions.clear();
+ send_config->rtp.extensions.push_back(RtpExtension(
+ RtpExtension::kAudioLevelUri, test::kAudioLevelExtensionId));
+ }
+
+ void PerformTest() override {
+ EXPECT_TRUE(Wait()) << "Timed out while waiting for single RTP packet.";
+ }
+ } test;
+
+ RunBaseTest(&test);
+}
+
+TEST_F(AudioSendStreamCallTest, SupportsTransportWideSequenceNumbers) {
ossu 2017/09/14 11:51:58 Is this test new? It looks like there are some see
the sun 2017/09/14 12:36:39 AbsoluteSendTime is no longer used. There was a le
ossu 2017/09/14 12:51:32 Acknowledged.
+ static const uint8_t kExtensionId = test::kTransportSequenceNumberExtensionId;
+ class TransportWideSequenceNumberObserver : public AudioSendTest {
+ public:
+ TransportWideSequenceNumberObserver() : AudioSendTest() {
+ EXPECT_TRUE(parser_->RegisterRtpHeaderExtension(
+ kRtpExtensionTransportSequenceNumber, kExtensionId));
+ }
+
+ private:
+ Action OnSendRtp(const uint8_t* packet, size_t length) override {
+ RTPHeader header;
+ EXPECT_TRUE(parser_->Parse(packet, length, &header));
+
+ EXPECT_TRUE(header.extension.hasTransportSequenceNumber);
+ EXPECT_FALSE(header.extension.hasTransmissionTimeOffset);
+ EXPECT_FALSE(header.extension.hasAbsoluteSendTime);
+
+ observation_complete_.Set();
+
+ return SEND_PACKET;
+ }
+
+ void ModifyAudioConfigs(
+ AudioSendStream::Config* send_config,
+ std::vector<AudioReceiveStream::Config>* receive_configs) override {
+ send_config->rtp.extensions.clear();
+ send_config->rtp.extensions.push_back(RtpExtension(
+ RtpExtension::kTransportSequenceNumberUri, kExtensionId));
+ }
+
+ void PerformTest() override {
+ EXPECT_TRUE(Wait()) << "Timed out while waiting for a single RTP packet.";
+ }
+ } test;
+
+ RunBaseTest(&test);
+}
+
+TEST_F(AudioSendStreamCallTest, SendDtmf) {
+ static const uint8_t kDtmfPayloadType = 120;
+ static const int kDtmfPayloadFrequency = 8000;
+ static const int kDtmfEventFirst = 12;
ossu 2017/09/14 11:51:58 It looks like this differs from the ranges tested
the sun 2017/09/14 12:36:39 It doesn't matter. The point is to test that event
ossu 2017/09/14 12:51:32 Acknowledged.
+ static const int kDtmfEventLast = 25;
+ static const int kDtmfDuration = 10;
+ class DtmfObserver : public AudioSendTest {
+ public:
+ DtmfObserver() : AudioSendTest() {}
ossu 2017/09/14 11:51:57 = default here as well?
the sun 2017/09/14 12:36:40 Done.
+
+ private:
+ Action OnSendRtp(const uint8_t* packet, size_t length) override {
+ RTPHeader header;
+ EXPECT_TRUE(parser_->Parse(packet, length, &header));
+
+ if (header.payloadType == kDtmfPayloadType) {
+ EXPECT_EQ(12u, header.headerLength);
+ const uint8_t event = packet[12];
+ if (expected_dtmf_event_ == event) {
ossu 2017/09/14 11:51:58 Will you want to ensure no other DTMF events are b
the sun 2017/09/14 12:36:40 In part, we're already testing this since for each
ossu 2017/09/14 12:51:32 Why not EXPECT_EQ(expected_dtmf_event_, event)? Ri
the sun 2017/09/14 20:05:06 Well, AFAIU (RFC 4733) extra events are perfectly
+ if (expected_dtmf_event_ == kDtmfEventLast) {
+ observation_complete_.Set();
+ } else {
+ ++expected_dtmf_event_;
+ }
+ }
+ }
+
+ return SEND_PACKET;
+ }
+
+ void OnAudioStreamsCreated(
+ AudioSendStream* send_stream,
+ const std::vector<AudioReceiveStream*>& receive_streams) override {
+ // Need to start stream here, else DTMF events are dropped.
+ send_stream->Start();
+ for (int event = kDtmfEventFirst; event <= kDtmfEventLast; ++event) {
+ send_stream->SendTelephoneEvent(kDtmfPayloadType, kDtmfPayloadFrequency,
+ event, kDtmfDuration);
+ }
+ }
+
+ void PerformTest() override {
+ EXPECT_TRUE(Wait()) << "Timed out while waiting for DTMF stream.";
+ }
+
+ int expected_dtmf_event_ = kDtmfEventFirst;
+ } test;
+
+ RunBaseTest(&test);
+}
+
+} // namespace test
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698