12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 67dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "media/base/audio_buffer.h" 77dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "media/base/audio_bus.h" 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "media/base/audio_splicer.h" 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "media/base/audio_timestamp_helper.h" 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "media/base/buffers.h" 117dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "media/base/test_helpers.h" 122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace media { 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 167dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochstatic const SampleFormat kSampleFormat = kSampleFormatF32; 177dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochstatic const int kChannels = 1; 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)static const int kDefaultSampleRate = 44100; 197dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochstatic const int kDefaultBufferSize = 100; 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class AudioSplicerTest : public ::testing::Test { 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public: 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AudioSplicerTest() 247dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch : splicer_(kDefaultSampleRate), 257dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch input_timestamp_helper_(kDefaultSampleRate) { 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) input_timestamp_helper_.SetBaseTimestamp(base::TimeDelta()); 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 297dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> GetNextInputBuffer(float value) { 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return GetNextInputBuffer(value, kDefaultBufferSize); 312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 337dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> GetNextInputBuffer(float value, int frame_size) { 347dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> buffer = MakeInterleavedAudioBuffer<float>( 357dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch kSampleFormat, 367dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch kChannels, 377dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch value, 387dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 0.0f, 397dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch frame_size, 407dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch input_timestamp_helper_.GetTimestamp(), 417dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch input_timestamp_helper_.GetFrameDuration(frame_size)); 427dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch input_timestamp_helper_.AddFrames(frame_size); 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return buffer; 442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 467dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch bool VerifyData(scoped_refptr<AudioBuffer> buffer, float value) { 477dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch int frames = buffer->frame_count(); 487dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_ptr<AudioBus> bus = AudioBus::Create(kChannels, frames); 497dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch buffer->ReadFrames(frames, 0, 0, bus.get()); 507dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch for (int i = 0; i < frames; ++i) { 517dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch if (bus->channel(0)[i] != value) 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return false; 532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return true; 552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected: 582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AudioSplicer splicer_; 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AudioTimestampHelper input_timestamp_helper_; 602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(AudioSplicerTest); 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(AudioSplicerTest, PassThru) { 652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Test single buffer pass-thru behavior. 687dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_1 = GetNextInputBuffer(0.1f); 692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_1)); 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 727dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_1 = splicer_.GetNextBuffer(); 732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 74eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->timestamp(), output_1->timestamp()); 75eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->duration(), output_1->duration()); 767dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_1->frame_count(), output_1->frame_count()); 777dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(VerifyData(output_1, 0.1f)); 782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Test that multiple buffers can be queued in the splicer. 807dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_2 = GetNextInputBuffer(0.2f); 817dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_3 = GetNextInputBuffer(0.3f); 822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_2)); 832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_3)); 842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 867dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_2 = splicer_.GetNextBuffer(); 872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 88eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_2->timestamp(), output_2->timestamp()); 89eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_2->duration(), output_2->duration()); 907dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_2->frame_count(), output_2->frame_count()); 912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 927dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_3 = splicer_.GetNextBuffer(); 932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 94eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_3->timestamp(), output_3->timestamp()); 95eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_3->duration(), output_3->duration()); 967dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_3->frame_count(), output_3->frame_count()); 972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(AudioSplicerTest, Reset) { 1007dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_1 = GetNextInputBuffer(0.1f); 1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_1)); 1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) splicer_.Reset(); 1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Add some bytes to the timestamp helper so that the 1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // next buffer starts many frames beyond the end of 1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // |input_1|. This is to make sure that Reset() actually 1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // clears its state and doesn't try to insert a gap. 1117dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch input_timestamp_helper_.AddFrames(100); 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that a new input buffer passes through as expected. 1147dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_2 = GetNextInputBuffer(0.2f); 1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_2)); 1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1187dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_2 = splicer_.GetNextBuffer(); 1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 120eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_2->timestamp(), output_2->timestamp()); 121eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_2->duration(), output_2->duration()); 1227dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_2->frame_count(), output_2->frame_count()); 1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(AudioSplicerTest, EndOfStream) { 1267dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_1 = GetNextInputBuffer(0.1f); 1277dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_2 = AudioBuffer::CreateEOSBuffer(); 1287dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_3 = GetNextInputBuffer(0.2f); 129eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_TRUE(input_2->end_of_stream()); 1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_1)); 1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_2)); 1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1357dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_1 = splicer_.GetNextBuffer(); 1367dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_2 = splicer_.GetNextBuffer(); 1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 138eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->timestamp(), output_1->timestamp()); 139eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->duration(), output_1->duration()); 1407dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_1->frame_count(), output_1->frame_count()); 1412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 142eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_TRUE(output_2->end_of_stream()); 1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that buffers can be added again after Reset(). 1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) splicer_.Reset(); 1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_3)); 1477dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_3 = splicer_.GetNextBuffer(); 1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 149eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_3->timestamp(), output_3->timestamp()); 150eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_3->duration(), output_3->duration()); 1517dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_3->frame_count(), output_3->frame_count()); 1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Test the gap insertion code. 1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+ +--------------+ 1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |11111111111111| |22222222222222| 1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+ +--------------+ 1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Results in: 1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+----+--------------+ 1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |11111111111111|0000|22222222222222| 1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+----+--------------+ 1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(AudioSplicerTest, GapInsertion) { 1647dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_1 = GetNextInputBuffer(0.1f); 1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Add bytes to the timestamp helper so that the next buffer 1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // will have a starting timestamp that indicates a gap is 1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // present. 1697dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const int kGapSize = 7; 1707dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch input_timestamp_helper_.AddFrames(kGapSize); 1717dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_2 = GetNextInputBuffer(0.2f); 1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_1)); 1742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_2)); 1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that a gap buffer is generated. 1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 1787dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_1 = splicer_.GetNextBuffer(); 1797dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_2 = splicer_.GetNextBuffer(); 1807dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_3 = splicer_.GetNextBuffer(); 1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that the first input buffer passed through unmodified. 184eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->timestamp(), output_1->timestamp()); 185eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->duration(), output_1->duration()); 1867dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_1->frame_count(), output_1->frame_count()); 1877dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(VerifyData(output_1, 0.1f)); 1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify the contents of the gap buffer. 1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::TimeDelta gap_timestamp = 191eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch input_1->timestamp() + input_1->duration(); 192eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch base::TimeDelta gap_duration = input_2->timestamp() - gap_timestamp; 1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_GT(gap_duration, base::TimeDelta()); 194eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(gap_timestamp, output_2->timestamp()); 195eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(gap_duration, output_2->duration()); 1967dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(kGapSize, output_2->frame_count()); 1977dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(VerifyData(output_2, 0.0f)); 1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that the second input buffer passed through unmodified. 200eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_2->timestamp(), output_3->timestamp()); 201eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_2->duration(), output_3->duration()); 2027dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_2->frame_count(), output_3->frame_count()); 2037dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(VerifyData(output_3, 0.2f)); 2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Test that an error is signalled when the gap between input buffers is 2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// too large. 2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(AudioSplicerTest, GapTooLarge) { 2107dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_1 = GetNextInputBuffer(0.1f); 2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Add a seconds worth of bytes so that an unacceptably large 2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // gap exists between |input_1| and |input_2|. 2147dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const int kGapSize = kDefaultSampleRate; 2157dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch input_timestamp_helper_.AddFrames(kGapSize); 2167dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_2 = GetNextInputBuffer(0.2f); 2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_1)); 2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.AddInput(input_2)); 2202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 2227dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_1 = splicer_.GetNextBuffer(); 2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that the first input buffer passed through unmodified. 225eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->timestamp(), output_1->timestamp()); 226eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->duration(), output_1->duration()); 2277dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_1->frame_count(), output_1->frame_count()); 2287dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(VerifyData(output_1, 0.1f)); 2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that the second buffer is not available. 2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Reset the timestamp helper so it can generate a buffer that is 2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // right after |input_1|. 2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) input_timestamp_helper_.SetBaseTimestamp( 236eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch input_1->timestamp() + input_1->duration()); 2372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that valid buffers are still accepted. 2397dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_3 = GetNextInputBuffer(0.3f); 2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_3)); 2412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 2427dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_2 = splicer_.GetNextBuffer(); 2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 244eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_3->timestamp(), output_2->timestamp()); 245eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_3->duration(), output_2->duration()); 2467dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_3->frame_count(), output_2->frame_count()); 2477dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(VerifyData(output_2, 0.3f)); 2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Verifies that an error is signalled if AddInput() is called 2522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// with a timestamp that is earlier than the first buffer added. 2532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(AudioSplicerTest, BufferAddedBeforeBase) { 2542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) input_timestamp_helper_.SetBaseTimestamp( 2552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::TimeDelta::FromMicroseconds(10)); 2567dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_1 = GetNextInputBuffer(0.1f); 2572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Reset the timestamp helper so the next buffer will have a timestamp earlier 2592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // than |input_1|. 2602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) input_timestamp_helper_.SetBaseTimestamp(base::TimeDelta::FromSeconds(0)); 2617dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_2 = GetNextInputBuffer(0.1f); 2622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 263eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_GT(input_1->timestamp(), input_2->timestamp()); 2642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_1)); 2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.AddInput(input_2)); 2662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Test when one buffer partially overlaps another. 2702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+ 2712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |11111111111111| 2722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+ 2732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+ 2742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |22222222222222| 2752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+ 2762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Results in: 2772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+----------+ 2782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |11111111111111|2222222222| 2792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+----------+ 2802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(AudioSplicerTest, PartialOverlap) { 2817dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_1 = GetNextInputBuffer(0.1f); 2822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Reset timestamp helper so that the next buffer will have a 2842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // timestamp that starts in the middle of |input_1|. 2857dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const int kOverlapSize = input_1->frame_count() / 4; 286eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch input_timestamp_helper_.SetBaseTimestamp(input_1->timestamp()); 2877dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch input_timestamp_helper_.AddFrames(input_1->frame_count() - kOverlapSize); 2882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2897dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_2 = GetNextInputBuffer(0.2f); 2902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_1)); 2922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_2)); 2932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 2957dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_1 = splicer_.GetNextBuffer(); 2967dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_2 = splicer_.GetNextBuffer(); 2972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 2982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that the first input buffer passed through unmodified. 300eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->timestamp(), output_1->timestamp()); 301eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->duration(), output_1->duration()); 3027dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_1->frame_count(), output_1->frame_count()); 3037dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(VerifyData(output_1, 0.1f)); 3042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that the second input buffer was truncated to only contain 3067dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // the samples that are after the end of |input_1|. Note that data is not 3077dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // copied, so |input_2|'s values are modified. 3082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::TimeDelta expected_timestamp = 309eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch input_1->timestamp() + input_1->duration(); 3102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::TimeDelta expected_duration = 311eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch (input_2->timestamp() + input_2->duration()) - expected_timestamp; 312eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(expected_timestamp, output_2->timestamp()); 313eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(expected_duration, output_2->duration()); 3147dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(VerifyData(output_2, 0.2f)); 3152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 3162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Test that an input buffer that is completely overlapped by a buffer 3192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// that was already added is dropped. 3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+ 3212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |11111111111111| 3222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+ 3232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +-----+ 3242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |22222| 3252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +-----+ 3262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +-------------+ 3272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |3333333333333| 3282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +-------------+ 3292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Results in: 3302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+-------------+ 3312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |11111111111111|3333333333333| 3322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// +--------------+-------------+ 3332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(AudioSplicerTest, DropBuffer) { 3347dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_1 = GetNextInputBuffer(0.1f); 3352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Reset timestamp helper so that the next buffer will have a 3372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // timestamp that starts in the middle of |input_1|. 3387dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const int kOverlapOffset = input_1->frame_count() / 2; 3397dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const int kOverlapSize = input_1->frame_count() / 4; 340eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch input_timestamp_helper_.SetBaseTimestamp(input_1->timestamp()); 3417dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch input_timestamp_helper_.AddFrames(kOverlapOffset); 3422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3437dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_2 = GetNextInputBuffer(0.2f, kOverlapSize); 3442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Reset the timestamp helper so the next buffer will be right after 3462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // |input_1|. 347eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch input_timestamp_helper_.SetBaseTimestamp(input_1->timestamp()); 3487dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch input_timestamp_helper_.AddFrames(input_1->frame_count()); 3497dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> input_3 = GetNextInputBuffer(0.3f); 3502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_1)); 3522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_2)); 3532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.AddInput(input_3)); 3542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(splicer_.HasNextBuffer()); 3567dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_1 = splicer_.GetNextBuffer(); 3577dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<AudioBuffer> output_2 = splicer_.GetNextBuffer(); 3582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_FALSE(splicer_.HasNextBuffer()); 3592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that the first input buffer passed through unmodified. 361eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->timestamp(), output_1->timestamp()); 362eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_1->duration(), output_1->duration()); 3637dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_1->frame_count(), output_1->frame_count()); 3647dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(VerifyData(output_1, 0.1f)); 3652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Verify that the second output buffer only contains 3672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // the samples that are in |input_3|. 368eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_3->timestamp(), output_2->timestamp()); 369eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_EQ(input_3->duration(), output_2->duration()); 3707dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_EQ(input_3->frame_count(), output_2->frame_count()); 3717dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch EXPECT_TRUE(VerifyData(output_2, 0.3f)); 3722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 3732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} // namespace media 375