| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "media/base/audio_buffer.h" | 6 #include "media/base/audio_buffer.h" |
| 7 #include "media/base/audio_bus.h" | 7 #include "media/base/audio_bus.h" |
| 8 #include "media/base/audio_splicer.h" | 8 #include "media/base/audio_splicer.h" |
| 9 #include "media/base/audio_timestamp_helper.h" | 9 #include "media/base/audio_timestamp_helper.h" |
| 10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
| 11 #include "media/base/test_helpers.h" | 11 #include "media/base/test_helpers.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 // Do not change this format. AddInput() and GetValue() only work with float. | 16 // Do not change this format. AddInput() and GetValue() only work with float. |
| 17 static const SampleFormat kSampleFormat = kSampleFormatF32; | 17 static const SampleFormat kSampleFormat = kSampleFormatF32; |
| 18 static_assert(kSampleFormat == kSampleFormatF32, "invalid splice format"); | 18 static_assert(kSampleFormat == kSampleFormatF32, "invalid splice format"); |
| 19 | 19 |
| 20 static const int kChannels = 1; | 20 static const int kChannels = 1; |
| 21 static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_MONO; | 21 static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_MONO; |
| 22 static const int kDefaultSampleRate = 44100; | 22 static const int kDefaultSampleRate = 44100; |
| 23 static const int kDefaultBufferSize = 100; | 23 static const int kDefaultBufferSize = 100; |
| 24 | 24 |
| 25 class AudioSplicerTest : public ::testing::Test { | 25 class AudioSplicerTest : public ::testing::Test { |
| 26 public: | 26 public: |
| 27 AudioSplicerTest() | 27 AudioSplicerTest() |
| 28 : splicer_(kDefaultSampleRate), | 28 : splicer_(kDefaultSampleRate, new MediaLog()), |
| 29 input_timestamp_helper_(kDefaultSampleRate) { | 29 input_timestamp_helper_(kDefaultSampleRate) { |
| 30 input_timestamp_helper_.SetBaseTimestamp(base::TimeDelta()); | 30 input_timestamp_helper_.SetBaseTimestamp(base::TimeDelta()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 scoped_refptr<AudioBuffer> GetNextInputBuffer(float value) { | 33 scoped_refptr<AudioBuffer> GetNextInputBuffer(float value) { |
| 34 return GetNextInputBuffer(value, kDefaultBufferSize); | 34 return GetNextInputBuffer(value, kDefaultBufferSize); |
| 35 } | 35 } |
| 36 | 36 |
| 37 scoped_refptr<AudioBuffer> GetNextInputBuffer(float value, int frame_size) { | 37 scoped_refptr<AudioBuffer> GetNextInputBuffer(float value, int frame_size) { |
| 38 scoped_refptr<AudioBuffer> buffer = | 38 scoped_refptr<AudioBuffer> buffer = |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 second_buffer->timestamp() + second_buffer->duration(); | 758 second_buffer->timestamp() + second_buffer->duration(); |
| 759 scoped_refptr<AudioBuffer> output = splicer_.GetNextBuffer(); | 759 scoped_refptr<AudioBuffer> output = splicer_.GetNextBuffer(); |
| 760 EXPECT_EQ(second_buffer_end_ts, output->timestamp()); | 760 EXPECT_EQ(second_buffer_end_ts, output->timestamp()); |
| 761 EXPECT_EQ(third_buffer->duration() - | 761 EXPECT_EQ(third_buffer->duration() - |
| 762 (second_buffer_end_ts - third_buffer->timestamp()), | 762 (second_buffer_end_ts - third_buffer->timestamp()), |
| 763 output->duration()); | 763 output->duration()); |
| 764 EXPECT_TRUE(VerifyData(output, GetValue(third_buffer))); | 764 EXPECT_TRUE(VerifyData(output, GetValue(third_buffer))); |
| 765 } | 765 } |
| 766 | 766 |
| 767 } // namespace media | 767 } // namespace media |
| OLD | NEW |