summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_parameters_unittest.cc
diff options
context:
space:
mode:
authorannacc@chromium.org <annacc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-16 22:18:32 +0000
committerannacc@chromium.org <annacc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-16 22:18:32 +0000
commitb630cb97c620593f9c987fdad0b3271ddbf39a3e (patch)
tree21295811329d31b302e29be7e16198fdfd5bc463 /media/audio/audio_parameters_unittest.cc
parent99d22e8b1c2c0b6f6457147ab90ce2df98ef02d3 (diff)
downloadchromium_src-b630cb97c620593f9c987fdad0b3271ddbf39a3e.zip
chromium_src-b630cb97c620593f9c987fdad0b3271ddbf39a3e.tar.gz
chromium_src-b630cb97c620593f9c987fdad0b3271ddbf39a3e.tar.bz2
Description:
This patch gets the channel layout for surround sound channel order from ffmpeg and stores it so that chromium will be able to re-order the channels for various sound cards and OSes later. - AudioParameters gets a new field (channel_layout). - channel_layout.h stores an enum that we will use in chromium for channel values. - ffmpeg_common.h gets a new method for mapping the channel layout received from ffmpeg to an internal chromium enum value. BUG=None (though storing the channel order should help us solve some other bugs soon) TEST=media_unittests Review URL: http://codereview.chromium.org/6930039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85541 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_parameters_unittest.cc')
-rw-r--r--media/audio/audio_parameters_unittest.cc159
1 files changed, 113 insertions, 46 deletions
diff --git a/media/audio/audio_parameters_unittest.cc b/media/audio/audio_parameters_unittest.cc
index 9f5bb2b..afcf6ff 100644
--- a/media/audio/audio_parameters_unittest.cc
+++ b/media/audio/audio_parameters_unittest.cc
@@ -13,6 +13,7 @@ TEST(AudioParameters, Constructor_Default) {
AudioParameters::Format expected_format = AudioParameters::AUDIO_PCM_LINEAR;
int expected_bits = 0;
int expected_channels = 0;
+ ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_NONE;
int expected_rate = 0;
int expected_samples = 0;
@@ -21,6 +22,7 @@ TEST(AudioParameters, Constructor_Default) {
EXPECT_EQ(expected_format, params.format);
EXPECT_EQ(expected_bits, params.bits_per_sample);
EXPECT_EQ(expected_channels, params.channels);
+ EXPECT_EQ(expected_channel_layout, params.channel_layout);
EXPECT_EQ(expected_rate, params.sample_rate);
EXPECT_EQ(expected_samples, params.samples_per_packet);
}
@@ -29,82 +31,147 @@ TEST(AudioParameters, Constructor_AudioDecoderConfig) {
AudioParameters::Format expected_format = AudioParameters::AUDIO_PCM_LINEAR;
int expected_bits = 8;
int expected_channels = 2;
+ ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_STEREO;
int expected_rate = 44000;
int expected_samples = 0;
- AudioDecoderConfig config(expected_bits, expected_channels, expected_rate);
+ AudioDecoderConfig config(expected_bits, expected_channel_layout,
+ expected_rate);
AudioParameters params(config);
EXPECT_EQ(expected_format, params.format);
EXPECT_EQ(expected_bits, params.bits_per_sample);
EXPECT_EQ(expected_channels, params.channels);
+ EXPECT_EQ(expected_channel_layout, params.channel_layout);
+ EXPECT_EQ(expected_rate, params.sample_rate);
+ EXPECT_EQ(expected_samples, params.samples_per_packet);
+}
+
+TEST(AudioParameters, Constructor_ParameterValues) {
+ AudioParameters::Format expected_format =
+ AudioParameters::AUDIO_PCM_LOW_LATENCY;
+ int expected_bits = 16;
+ int expected_channels = 6;
+ ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_5POINT1;
+ int expected_rate = 44100;
+ int expected_samples = 880;
+
+ AudioParameters params(expected_format, expected_channel_layout,
+ expected_rate, expected_bits, expected_samples);
+
+ EXPECT_EQ(expected_format, params.format);
+ EXPECT_EQ(expected_bits, params.bits_per_sample);
+ EXPECT_EQ(expected_channels, params.channels);
+ EXPECT_EQ(expected_channel_layout, params.channel_layout);
EXPECT_EQ(expected_rate, params.sample_rate);
EXPECT_EQ(expected_samples, params.samples_per_packet);
}
TEST(AudioParameters, GetPacketSize) {
EXPECT_EQ(100, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
- 1, 1000, 8, 100).GetPacketSize());
+ CHANNEL_LAYOUT_MONO, 1000, 8, 100)
+ .GetPacketSize());
EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
- 1, 1000, 16, 100).GetPacketSize());
+ CHANNEL_LAYOUT_MONO, 1000, 16, 100)
+ .GetPacketSize());
EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
- 2, 1000, 8, 100).GetPacketSize());
+ CHANNEL_LAYOUT_STEREO, 1000, 8, 100)
+ .GetPacketSize());
EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
- 1, 1000, 8, 200).GetPacketSize());
+ CHANNEL_LAYOUT_MONO, 1000, 8, 200)
+ .GetPacketSize());
EXPECT_EQ(800, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
- 2, 1000, 16, 200).GetPacketSize());
+ CHANNEL_LAYOUT_STEREO, 1000, 16, 200)
+ .GetPacketSize());
}
TEST(AudioParameters, GetBytesPerSecond) {
EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
- 0, 0, 0, 0).GetBytesPerSecond());
+ CHANNEL_LAYOUT_NONE, 0, 0, 0)
+ .GetBytesPerSecond());
EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
- 2, 0, 0, 0).GetBytesPerSecond());
+ CHANNEL_LAYOUT_STEREO, 0, 0, 0)
+ .GetBytesPerSecond());
EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
- 0, 100, 0, 0).GetBytesPerSecond());
+ CHANNEL_LAYOUT_NONE, 100, 0, 0)
+ .GetBytesPerSecond());
EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
- 0, 0, 8, 0).GetBytesPerSecond());
+ CHANNEL_LAYOUT_NONE, 0, 8, 0)
+ .GetBytesPerSecond());
EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
- 2, 100, 8, 0).GetBytesPerSecond());
+ CHANNEL_LAYOUT_STEREO, 100, 8, 0)
+ .GetBytesPerSecond());
}
TEST(AudioParameters, Compare) {
AudioParameters values[] = {
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 1, 1000, 8, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 1, 1000, 8, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 1, 1000, 16, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 1, 1000, 16, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 1, 2000, 8, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 1, 2000, 8, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 1, 2000, 16, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 1, 2000, 16, 200),
-
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, 1000, 8, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, 1000, 8, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, 1000, 16, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, 1000, 16, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, 2000, 8, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, 2000, 8, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, 2000, 16, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, 2000, 16, 200),
-
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 1, 1000, 8, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 1, 1000, 8, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 1, 1000, 16, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 1, 1000, 16, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 1, 2000, 8, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 1, 2000, 8, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 1, 2000, 16, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 1, 2000, 16, 200),
-
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 2, 1000, 8, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 2, 1000, 8, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 2, 1000, 16, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 2, 1000, 16, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 2, 2000, 8, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 2, 2000, 8, 200),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 2, 2000, 16, 100),
- AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 2, 2000, 16, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
+ 1000, 8, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
+ 1000, 8, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
+ 1000, 16, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
+ 1000, 16, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
+ 2000, 8, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
+ 2000, 8, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
+ 2000, 16, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
+ 2000, 16, 200),
+
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
+ 1000, 8, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
+ 1000, 8, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
+ 1000, 16, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
+ 1000, 16, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
+ 2000, 8, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
+ 2000, 8, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
+ 2000, 16, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
+ 2000, 16, 200),
+
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_MONO,
+ 1000, 8, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_MONO,
+ 1000, 8, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_MONO,
+ 1000, 16, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_MONO,
+ 1000, 16, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_MONO,
+ 2000, 8, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_MONO,
+ 2000, 8, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_MONO,
+ 2000, 16, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_MONO,
+ 2000, 16, 200),
+
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ CHANNEL_LAYOUT_STEREO, 1000, 8, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ CHANNEL_LAYOUT_STEREO, 1000, 8, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ CHANNEL_LAYOUT_STEREO, 1000, 16, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ CHANNEL_LAYOUT_STEREO, 1000, 16, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ CHANNEL_LAYOUT_STEREO, 2000, 8, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ CHANNEL_LAYOUT_STEREO, 2000, 8, 200),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ CHANNEL_LAYOUT_STEREO, 2000, 16, 100),
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ CHANNEL_LAYOUT_STEREO, 2000, 16, 200),
};
AudioParameters::Compare target;