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

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

Issue 1647773002: MediaStream audio sourcing: Bypass audio processing for non-WebRTC cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NOT FOR REVIEW -- This will be broken-up across multiple CLs. Created 4 years, 10 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> 5 #include <stddef.h>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "content/renderer/media/media_stream_audio_track.h"
9 #include "content/renderer/media/mock_media_constraint_factory.h"
10 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
11 #include "content/renderer/media/webrtc_audio_capturer.h"
12 #include "content/renderer/media/webrtc_local_audio_source_provider.h" 9 #include "content/renderer/media/webrtc_local_audio_source_provider.h"
13 #include "content/renderer/media/webrtc_local_audio_track.h"
14 #include "media/audio/audio_parameters.h" 10 #include "media/audio/audio_parameters.h"
15 #include "media/base/audio_bus.h" 11 #include "media/base/audio_bus.h"
16 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 13 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
14 #include "third_party/WebKit/public/platform/WebString.h"
18 #include "third_party/WebKit/public/web/WebHeap.h" 15 #include "third_party/WebKit/public/web/WebHeap.h"
19 16
20 namespace content { 17 namespace content {
21 18
22 class WebRtcLocalAudioSourceProviderTest : public testing::Test { 19 class WebRtcLocalAudioSourceProviderTest : public testing::Test {
23 protected: 20 protected:
24 void SetUp() override { 21 void SetUp() override {
25 source_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 22 source_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
26 media::CHANNEL_LAYOUT_MONO, 48000, 16, 480); 23 media::CHANNEL_LAYOUT_MONO, 48000, 16, 480);
27 sink_params_.Reset( 24 sink_params_.Reset(
28 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 25 media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
29 media::CHANNEL_LAYOUT_STEREO, 44100, 16, 26 media::CHANNEL_LAYOUT_STEREO, 44100, 16,
30 WebRtcLocalAudioSourceProvider::kWebAudioRenderBufferSize); 27 WebRtcLocalAudioSourceProvider::kWebAudioRenderBufferSize);
31 sink_bus_ = media::AudioBus::Create(sink_params_); 28 sink_bus_ = media::AudioBus::Create(sink_params_);
32 MockMediaConstraintFactory constraint_factory; 29 scoped_ptr<MediaStreamAudioTrack> native_track(
33 scoped_refptr<WebRtcAudioCapturer> capturer( 30 new MediaStreamAudioTrack(true /* is_local_track */));
34 WebRtcAudioCapturer::CreateCapturer(
35 -1, StreamDeviceInfo(),
36 constraint_factory.CreateWebMediaConstraints(), NULL, NULL));
37 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter(
38 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL));
39 scoped_ptr<WebRtcLocalAudioTrack> native_track(
40 new WebRtcLocalAudioTrack(adapter.get(), capturer, NULL));
41 blink::WebMediaStreamSource audio_source; 31 blink::WebMediaStreamSource audio_source;
42 audio_source.initialize(base::UTF8ToUTF16("dummy_source_id"), 32 audio_source.initialize(blink::WebString::fromUTF8("dummy_source_id"),
43 blink::WebMediaStreamSource::TypeAudio, 33 blink::WebMediaStreamSource::TypeAudio,
44 base::UTF8ToUTF16("dummy_source_name"), 34 blink::WebString::fromUTF8("dummy_source_name"),
45 false /* remote */, true /* readonly */); 35 false /* remote */, true /* readonly */);
46 blink_track_.initialize(blink::WebString::fromUTF8("audio_track"), 36 blink_track_.initialize(blink::WebString::fromUTF8("audio_track"),
47 audio_source); 37 audio_source);
48 blink_track_.setExtraData(native_track.release()); 38 blink_track_.setExtraData(native_track.release());
49 source_provider_.reset(new WebRtcLocalAudioSourceProvider(blink_track_)); 39 source_provider_.reset(new WebRtcLocalAudioSourceProvider(blink_track_));
50 source_provider_->SetSinkParamsForTesting(sink_params_); 40 source_provider_->SetSinkParamsForTesting(sink_params_);
51 source_provider_->OnSetFormat(source_params_); 41 source_provider_->OnSetFormat(source_params_);
52 } 42 }
53 43
54 void TearDown() override { 44 void TearDown() override {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 EXPECT_NEAR(0.5f, sink_bus_->channel(1)[0], 0.001f); 109 EXPECT_NEAR(0.5f, sink_bus_->channel(1)[0], 0.001f);
120 EXPECT_DOUBLE_EQ(sink_bus_->channel(0)[0], sink_bus_->channel(1)[0]); 110 EXPECT_DOUBLE_EQ(sink_bus_->channel(0)[0], sink_bus_->channel(1)[0]);
121 } 111 }
122 } 112 }
123 113
124 TEST_F(WebRtcLocalAudioSourceProviderTest, 114 TEST_F(WebRtcLocalAudioSourceProviderTest,
125 DeleteSourceProviderBeforeStoppingTrack) { 115 DeleteSourceProviderBeforeStoppingTrack) {
126 source_provider_.reset(); 116 source_provider_.reset();
127 117
128 // Stop the audio track. 118 // Stop the audio track.
129 WebRtcLocalAudioTrack* native_track = static_cast<WebRtcLocalAudioTrack*>( 119 MediaStreamAudioTrack::Get(blink_track_)->Stop();
130 MediaStreamTrack::GetTrack(blink_track_));
131 native_track->Stop();
132 } 120 }
133 121
134 TEST_F(WebRtcLocalAudioSourceProviderTest, 122 TEST_F(WebRtcLocalAudioSourceProviderTest,
135 StopTrackBeforeDeletingSourceProvider) { 123 StopTrackBeforeDeletingSourceProvider) {
136 // Stop the audio track. 124 // Stop the audio track.
137 WebRtcLocalAudioTrack* native_track = static_cast<WebRtcLocalAudioTrack*>( 125 MediaStreamAudioTrack::Get(blink_track_)->Stop();
138 MediaStreamTrack::GetTrack(blink_track_));
139 native_track->Stop();
140 126
141 // Delete the source provider. 127 // Delete the source provider.
142 source_provider_.reset(); 128 source_provider_.reset();
143 } 129 }
144 130
145 } // namespace content 131 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_local_audio_source_provider.h ('k') | content/renderer/media/webrtc_local_audio_track.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698