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

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

Issue 1966043006: Revert of MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/renderer/media/audio_track_recorder.h" 5 #include "content/renderer/media/audio_track_recorder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
11 #include "base/macros.h" 9 #include "base/macros.h"
12 #include "base/run_loop.h" 10 #include "base/run_loop.h"
13 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/utf_string_conversions.h"
14 #include "content/renderer/media/media_stream_audio_source.h" 13 #include "content/renderer/media/media_stream_audio_source.h"
14 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
15 #include "content/renderer/media/webrtc_local_audio_track.h"
15 #include "media/audio/simple_sources.h" 16 #include "media/audio/simple_sources.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/WebKit/public/platform/WebString.h"
19 #include "third_party/WebKit/public/web/WebHeap.h" 19 #include "third_party/WebKit/public/web/WebHeap.h"
20 #include "third_party/opus/src/include/opus.h" 20 #include "third_party/opus/src/include/opus.h"
21 21
22 using ::testing::_; 22 using ::testing::_;
23 using ::testing::DoAll; 23 using ::testing::DoAll;
24 using ::testing::InSequence; 24 using ::testing::InSequence;
25 using ::testing::Mock; 25 using ::testing::Mock;
26 using ::testing::Return; 26 using ::testing::Return;
27 using ::testing::SaveArg; 27 using ::testing::SaveArg;
28 using ::testing::TestWithParam; 28 using ::testing::TestWithParam;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 // Decoder for verifying data was properly encoded. 203 // Decoder for verifying data was properly encoded.
204 OpusDecoder* opus_decoder_; 204 OpusDecoder* opus_decoder_;
205 std::unique_ptr<float[]> buffer_; 205 std::unique_ptr<float[]> buffer_;
206 206
207 private: 207 private:
208 // Prepares a blink track of a given MediaStreamType and attaches the native 208 // Prepares a blink track of a given MediaStreamType and attaches the native
209 // track, which can be used to capture audio data and pass it to the producer. 209 // track, which can be used to capture audio data and pass it to the producer.
210 // Adapted from media::WebRTCLocalAudioSourceProviderTest. 210 // Adapted from media::WebRTCLocalAudioSourceProviderTest.
211 void PrepareBlinkTrack() { 211 void PrepareBlinkTrack() {
212 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter(
213 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL));
214 std::unique_ptr<WebRtcLocalAudioTrack> native_track(
215 new WebRtcLocalAudioTrack(adapter.get()));
212 blink::WebMediaStreamSource audio_source; 216 blink::WebMediaStreamSource audio_source;
213 audio_source.initialize(blink::WebString::fromUTF8("dummy_source_id"), 217 audio_source.initialize(base::UTF8ToUTF16("dummy_source_id"),
214 blink::WebMediaStreamSource::TypeAudio, 218 blink::WebMediaStreamSource::TypeAudio,
215 blink::WebString::fromUTF8("dummy_source_name"), 219 base::UTF8ToUTF16("dummy_source_name"),
216 false /* remote */); 220 false /* remote */);
217 audio_source.setExtraData(new MediaStreamAudioSource(true));
218 blink_track_.initialize(blink::WebString::fromUTF8("audio_track"), 221 blink_track_.initialize(blink::WebString::fromUTF8("audio_track"),
219 audio_source); 222 audio_source);
220 CHECK(MediaStreamAudioSource::From(audio_source) 223 blink_track_.setExtraData(native_track.release());
221 ->ConnectToTrack(blink_track_));
222 } 224 }
223 225
224 DISALLOW_COPY_AND_ASSIGN(AudioTrackRecorderTest); 226 DISALLOW_COPY_AND_ASSIGN(AudioTrackRecorderTest);
225 }; 227 };
226 228
227 TEST_P(AudioTrackRecorderTest, OnData) { 229 TEST_P(AudioTrackRecorderTest, OnData) {
228 InSequence s; 230 InSequence s;
229 base::RunLoop run_loop; 231 base::RunLoop run_loop;
230 base::Closure quit_closure = run_loop.QuitClosure(); 232 base::Closure quit_closure = run_loop.QuitClosure();
231 233
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 294
293 if (GetParam().sample_rate % 100) 295 if (GetParam().sample_rate % 100)
294 audio_track_recorder_->OnData(*GetFirstSourceAudioBus(), TimeTicks::Now()); 296 audio_track_recorder_->OnData(*GetFirstSourceAudioBus(), TimeTicks::Now());
295 297
296 run_loop.Run(); 298 run_loop.Run();
297 Mock::VerifyAndClearExpectations(this); 299 Mock::VerifyAndClearExpectations(this);
298 } 300 }
299 301
300 INSTANTIATE_TEST_CASE_P(, AudioTrackRecorderTest, ValuesIn(kATRTestParams)); 302 INSTANTIATE_TEST_CASE_P(, AudioTrackRecorderTest, ValuesIn(kATRTestParams));
301 } // namespace content 303 } // namespace content
OLDNEW
« no previous file with comments | « content/public/renderer/media_stream_utils.cc ('k') | content/renderer/media/external_media_stream_audio_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698