#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <cstdint>
#include <list>
#include <memory>
#include <string>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "remoting/client/audio/audio_jitter_buffer.h"
#include "remoting/client/audio/audio_stream_format.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace remoting {
namespace {
constexpr AudioPacket::BytesPerSample kBytesPerSample =
AudioPacket::BYTES_PER_SAMPLE_2;
constexpr AudioPacket::Channels kChannels = AudioPacket::CHANNELS_STEREO;
constexpr uint32_t kAudioSampleBytes = …;
constexpr uint32_t kNumConsumerBuffers = …;
constexpr uint32_t kConsumerBufferMaxByteSize = …;
constexpr uint8_t kDefaultBufferData = …;
constexpr uint8_t kDummyAudioData = …;
std::unique_ptr<AudioPacket> CreateAudioPacketWithSamplingRate(
AudioPacket::SamplingRate rate,
size_t bytes) { … }
void CheckDataBytes(const uint8_t* buffer, size_t bytes_written) { … }
}
class AudioJitterBufferTest : public ::testing::Test { … };
class AudioJitterBufferTest::SimpleGetDataRequest
: public AsyncAudioDataSupplier::GetDataRequest { … };
void AudioJitterBufferTest::SetUp() { … }
void AudioJitterBufferTest::TearDown() { … }
void AudioJitterBufferTest::SetSampleRate(
AudioPacket::SamplingRate sample_rate) { … }
std::unique_ptr<AudioPacket> AudioJitterBufferTest::CreatePacket(int time_ms) { … }
void AudioJitterBufferTest::AsyncConsumeData(size_t duration) { … }
void AudioJitterBufferTest::VerifyStreamFormat() { … }
void AudioJitterBufferTest::VerifyBuffersNotLost() { … }
size_t AudioJitterBufferTest::ByteFromTime(int time_ms) const { … }
size_t AudioJitterBufferTest::GetNumQueuedPackets() const { … }
int AudioJitterBufferTest::GetNumQueuedTime() const { … }
size_t AudioJitterBufferTest::GetNumQueuedRequests() const { … }
void AudioJitterBufferTest::OnFormatChanged(const AudioStreamFormat& format) { … }
AudioJitterBufferTest::SimpleGetDataRequest::SimpleGetDataRequest(
AudioJitterBufferTest* test,
size_t bytes_to_write)
: … { … }
AudioJitterBufferTest::SimpleGetDataRequest::~SimpleGetDataRequest() { … }
void AudioJitterBufferTest::SimpleGetDataRequest::OnDataFilled() { … }
TEST_F(AudioJitterBufferTest, Init) { … }
TEST_F(AudioJitterBufferTest, MultipleSamples) { … }
TEST_F(AudioJitterBufferTest, ExceedLatency) { … }
TEST_F(AudioJitterBufferTest, SingleAsyncRequest_UnderrunProtection) { … }
TEST_F(AudioJitterBufferTest, SingleAsyncRequest_Fulfilled) { … }
TEST_F(AudioJitterBufferTest, TwoAsyncRequest_FulfillOneByOne) { … }
TEST_F(AudioJitterBufferTest, TwoAsyncRequest_OnePacketFulfillsTwoRequests) { … }
TEST_F(AudioJitterBufferTest, TwoAsyncRequest_UnderrunProtectionKicksIn) { … }
TEST_F(AudioJitterBufferTest, TwoAsyncRequest_TwoPacketsFulfillTwoRequests) { … }
TEST_F(AudioJitterBufferTest, ChangeSampleRate) { … }
}