mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-16 23:30:48 +01:00

Bug: webrtc:9719 Change-Id: I82aa962d1cb8f2c8f56f766cb12562690e595045 Reviewed-on: https://webrtc-review.googlesource.com/c/105661 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Peter Slatala <psla@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Anton Sukhanov <sukhanov@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25196}
60 lines
2 KiB
C++
60 lines
2 KiB
C++
/*
|
|
* Copyright 2018 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 <vector>
|
|
|
|
#include "api/test/loopback_media_transport.h"
|
|
#include "test/gmock.h"
|
|
|
|
namespace webrtc {
|
|
|
|
namespace {
|
|
|
|
class MockMediaTransportAudioSinkInterface
|
|
: public MediaTransportAudioSinkInterface {
|
|
public:
|
|
MOCK_METHOD2(OnData, void(uint64_t, MediaTransportEncodedAudioFrame));
|
|
};
|
|
|
|
// Test only uses the sequence number.
|
|
MediaTransportEncodedAudioFrame CreateAudioFrame(int sequence_number) {
|
|
static constexpr int kSamplingRateHz = 48000;
|
|
static constexpr int kStartingSampleIndex = 0;
|
|
static constexpr int kSamplesPerChannel = 480;
|
|
static constexpr uint8_t kPayloadType = 17;
|
|
|
|
return MediaTransportEncodedAudioFrame(
|
|
kSamplingRateHz, kStartingSampleIndex, kSamplesPerChannel,
|
|
sequence_number, MediaTransportEncodedAudioFrame::FrameType::kSpeech,
|
|
kPayloadType, std::vector<uint8_t>(kSamplesPerChannel));
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST(LoopbackMediaTransport, AudioWithNoSinkSilentlyIgnored) {
|
|
MediaTransportPair transport_pair;
|
|
transport_pair.first()->SendAudioFrame(1, CreateAudioFrame(0));
|
|
transport_pair.second()->SendAudioFrame(2, CreateAudioFrame(0));
|
|
}
|
|
|
|
TEST(LoopbackMediaTransport, AudioDeliveredToSink) {
|
|
MediaTransportPair transport_pair;
|
|
testing::StrictMock<MockMediaTransportAudioSinkInterface> sink;
|
|
EXPECT_CALL(sink,
|
|
OnData(1, testing::Property(
|
|
&MediaTransportEncodedAudioFrame::sequence_number,
|
|
testing::Eq(10))));
|
|
transport_pair.second()->SetReceiveAudioSink(&sink);
|
|
transport_pair.first()->SendAudioFrame(1, CreateAudioFrame(10));
|
|
|
|
transport_pair.second()->SetReceiveAudioSink(nullptr);
|
|
}
|
|
|
|
} // namespace webrtc
|