Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(915)

Side by Side Diff: content/renderer/media/media_stream_audio_processor_unittest.cc

Issue 1547073003: Switch to standard integer types in content/renderer/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h>
6 #include <stdint.h>
7
5 #include <vector> 8 #include <vector>
6 9
7 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
9 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h"
10 #include "base/memory/aligned_memory.h" 14 #include "base/memory/aligned_memory.h"
11 #include "base/path_service.h" 15 #include "base/path_service.h"
12 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "build/build_config.h"
13 #include "content/public/common/media_stream_request.h" 18 #include "content/public/common/media_stream_request.h"
14 #include "content/renderer/media/media_stream_audio_processor.h" 19 #include "content/renderer/media/media_stream_audio_processor.h"
15 #include "content/renderer/media/media_stream_audio_processor_options.h" 20 #include "content/renderer/media/media_stream_audio_processor_options.h"
16 #include "content/renderer/media/mock_media_constraint_factory.h" 21 #include "content/renderer/media/mock_media_constraint_factory.h"
17 #include "media/audio/audio_parameters.h" 22 #include "media/audio/audio_parameters.h"
18 #include "media/base/audio_bus.h" 23 #include "media/base/audio_bus.h"
19 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 26 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
22 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" 27 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
(...skipping 30 matching lines...) Expand all
53 const int kMaxNumberOfPlayoutDataChannels = 2; 58 const int kMaxNumberOfPlayoutDataChannels = 2;
54 59
55 void ReadDataFromSpeechFile(char* data, int length) { 60 void ReadDataFromSpeechFile(char* data, int length) {
56 base::FilePath file; 61 base::FilePath file;
57 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file)); 62 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file));
58 file = file.Append(FILE_PATH_LITERAL("media")) 63 file = file.Append(FILE_PATH_LITERAL("media"))
59 .Append(FILE_PATH_LITERAL("test")) 64 .Append(FILE_PATH_LITERAL("test"))
60 .Append(FILE_PATH_LITERAL("data")) 65 .Append(FILE_PATH_LITERAL("data"))
61 .Append(FILE_PATH_LITERAL("speech_16b_stereo_48kHz.raw")); 66 .Append(FILE_PATH_LITERAL("speech_16b_stereo_48kHz.raw"));
62 DCHECK(base::PathExists(file)); 67 DCHECK(base::PathExists(file));
63 int64 data_file_size64 = 0; 68 int64_t data_file_size64 = 0;
64 DCHECK(base::GetFileSize(file, &data_file_size64)); 69 DCHECK(base::GetFileSize(file, &data_file_size64));
65 EXPECT_EQ(length, base::ReadFile(file, data, length)); 70 EXPECT_EQ(length, base::ReadFile(file, data, length));
66 DCHECK(data_file_size64 > length); 71 DCHECK(data_file_size64 > length);
67 } 72 }
68 73
69 } // namespace 74 } // namespace
70 75
71 class MediaStreamAudioProcessorTest : public ::testing::Test { 76 class MediaStreamAudioProcessorTest : public ::testing::Test {
72 public: 77 public:
73 MediaStreamAudioProcessorTest() 78 MediaStreamAudioProcessorTest()
74 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 79 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
75 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 512) { 80 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 512) {
76 } 81 }
77 82
78 protected: 83 protected:
79 // Helper method to save duplicated code. 84 // Helper method to save duplicated code.
80 void ProcessDataAndVerifyFormat(MediaStreamAudioProcessor* audio_processor, 85 void ProcessDataAndVerifyFormat(MediaStreamAudioProcessor* audio_processor,
81 int expected_output_sample_rate, 86 int expected_output_sample_rate,
82 int expected_output_channels, 87 int expected_output_channels,
83 int expected_output_buffer_size) { 88 int expected_output_buffer_size) {
84 // Read the audio data from a file. 89 // Read the audio data from a file.
85 const media::AudioParameters& params = audio_processor->InputFormat(); 90 const media::AudioParameters& params = audio_processor->InputFormat();
86 const int packet_size = 91 const int packet_size =
87 params.frames_per_buffer() * 2 * params.channels(); 92 params.frames_per_buffer() * 2 * params.channels();
88 const size_t length = packet_size * kNumberOfPacketsForTest; 93 const size_t length = packet_size * kNumberOfPacketsForTest;
89 scoped_ptr<char[]> capture_data(new char[length]); 94 scoped_ptr<char[]> capture_data(new char[length]);
90 ReadDataFromSpeechFile(capture_data.get(), length); 95 ReadDataFromSpeechFile(capture_data.get(), length);
91 const int16* data_ptr = reinterpret_cast<const int16*>(capture_data.get()); 96 const int16_t* data_ptr =
97 reinterpret_cast<const int16_t*>(capture_data.get());
92 scoped_ptr<media::AudioBus> data_bus = media::AudioBus::Create( 98 scoped_ptr<media::AudioBus> data_bus = media::AudioBus::Create(
93 params.channels(), params.frames_per_buffer()); 99 params.channels(), params.frames_per_buffer());
94 100
95 // |data_bus_playout| is used if the number of capture channels is larger 101 // |data_bus_playout| is used if the number of capture channels is larger
96 // that max allowed playout channels. |data_bus_playout_to_use| points to 102 // that max allowed playout channels. |data_bus_playout_to_use| points to
97 // the AudioBus to use, either |data_bus| or |data_bus_playout|. 103 // the AudioBus to use, either |data_bus| or |data_bus_playout|.
98 scoped_ptr<media::AudioBus> data_bus_playout; 104 scoped_ptr<media::AudioBus> data_bus_playout;
99 media::AudioBus* data_bus_playout_to_use = data_bus.get(); 105 media::AudioBus* data_bus_playout_to_use = data_bus.get();
100 if (params.channels() > kMaxNumberOfPlayoutDataChannels) { 106 if (params.channels() > kMaxNumberOfPlayoutDataChannels) {
101 data_bus_playout = 107 data_bus_playout =
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 ProcessDataAndVerifyFormat(audio_processor.get(), 594 ProcessDataAndVerifyFormat(audio_processor.get(),
589 kAudioProcessingSampleRate, 595 kAudioProcessingSampleRate,
590 kAudioProcessingNumberOfChannel, 596 kAudioProcessingNumberOfChannel,
591 kAudioProcessingSampleRate / 100); 597 kAudioProcessingSampleRate / 100);
592 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives 598 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives
593 // |audio_processor|. 599 // |audio_processor|.
594 audio_processor = NULL; 600 audio_processor = NULL;
595 } 601 }
596 602
597 } // namespace content 603 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_audio_processor_options.cc ('k') | content/renderer/media/media_stream_audio_sink_owner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698