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

Side by Side Diff: content/renderer/media/webrtc/webrtc_media_stream_adapter_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "content/child/child_process.h" 9 #include "content/child/child_process.h"
10 #include "content/renderer/media/media_stream.h" 10 #include "content/renderer/media/media_stream.h"
11 #include "content/renderer/media/media_stream_audio_source.h"
12 #include "content/renderer/media/media_stream_video_source.h" 11 #include "content/renderer/media/media_stream_video_source.h"
13 #include "content/renderer/media/media_stream_video_track.h" 12 #include "content/renderer/media/media_stream_video_track.h"
14 #include "content/renderer/media/mock_media_constraint_factory.h" 13 #include "content/renderer/media/mock_media_constraint_factory.h"
15 #include "content/renderer/media/mock_media_stream_video_source.h" 14 #include "content/renderer/media/mock_media_stream_video_source.h"
16 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory. h" 15 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory. h"
16 #include "content/renderer/media/webrtc/processed_local_audio_source.h"
17 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" 17 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
18 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" 18 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h"
19 #include "content/renderer/media/webrtc_local_audio_track.h"
20 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/WebKit/public/platform/WebMediaStream.h" 20 #include "third_party/WebKit/public/platform/WebMediaStream.h"
22 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 21 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
23 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 22 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
24 #include "third_party/WebKit/public/platform/WebVector.h" 23 #include "third_party/WebKit/public/platform/WebVector.h"
25 #include "third_party/WebKit/public/web/WebHeap.h" 24 #include "third_party/WebKit/public/web/WebHeap.h"
26 25
27 namespace content { 26 namespace content {
28 27
29 class WebRtcMediaStreamAdapterTest : public ::testing::Test { 28 class WebRtcMediaStreamAdapterTest : public ::testing::Test {
30 public: 29 public:
31 void SetUp() override { 30 void SetUp() override {
32 child_process_.reset(new ChildProcess()); 31 child_process_.reset(new ChildProcess());
33 dependency_factory_.reset(new MockPeerConnectionDependencyFactory()); 32 dependency_factory_.reset(new MockPeerConnectionDependencyFactory());
34 } 33 }
35 34
36 void TearDown() override { 35 void TearDown() override {
37 adapter_.reset(); 36 adapter_.reset();
38 blink::WebHeap::collectAllGarbageForTesting(); 37 blink::WebHeap::collectAllGarbageForTesting();
39 } 38 }
40 39
41 blink::WebMediaStream CreateBlinkMediaStream(bool audio, bool video) { 40 blink::WebMediaStream CreateBlinkMediaStream(bool audio, bool video) {
42 blink::WebVector<blink::WebMediaStreamTrack> audio_track_vector( 41 blink::WebVector<blink::WebMediaStreamTrack> audio_track_vector(
43 audio ? static_cast<size_t>(1) : 0); 42 audio ? static_cast<size_t>(1) : 0);
44 if (audio) { 43 if (audio) {
45 blink::WebMediaStreamSource audio_source; 44 blink::WebMediaStreamSource blink_audio_source;
46 audio_source.initialize("audio", 45 blink_audio_source.initialize("audio",
47 blink::WebMediaStreamSource::TypeAudio, 46 blink::WebMediaStreamSource::TypeAudio,
48 "audio", 47 "audio",
49 false /* remote */, true /* readonly */); 48 false /* remote */, true /* readonly */);
50 audio_source.setExtraData(new MediaStreamAudioSource()); 49 ProcessedLocalAudioSource* const audio_source =
51 50 new ProcessedLocalAudioSource(
52 audio_track_vector[0].initialize(audio_source); 51 -1,
53 StreamDeviceInfo device_info(MEDIA_DEVICE_AUDIO_CAPTURE, "Mock device", 52 StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "Mock device",
54 "mock_device_id"); 53 "mock_device_id"),
55 MockMediaConstraintFactory constraint_factory; 54 dependency_factory_.get());
56 const blink::WebMediaConstraints constraints = 55 audio_source->SetAllowInvalidRenderFrameIdForTesting(true);
57 constraint_factory.CreateWebMediaConstraints(); 56 audio_source->SetSourceConstraints(
58 scoped_refptr<WebRtcAudioCapturer> capturer( 57 MockMediaConstraintFactory().CreateWebMediaConstraints());
59 WebRtcAudioCapturer::CreateCapturer(-1, device_info, constraints, 58 blink_audio_source.setExtraData(audio_source); // Takes ownership.
60 nullptr, nullptr)); 59 audio_track_vector[0].initialize(blink_audio_source);
61 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter( 60 CHECK(audio_source->ConnectToTrack(audio_track_vector[0]));
62 WebRtcLocalAudioTrackAdapter::Create(
63 audio_track_vector[0].id().utf8(), nullptr));
64 scoped_ptr<WebRtcLocalAudioTrack> native_track(
65 new WebRtcLocalAudioTrack(adapter.get(), capturer, nullptr));
66 audio_track_vector[0].setExtraData(native_track.release());
67 } 61 }
68 62
69 blink::WebVector<blink::WebMediaStreamTrack> video_track_vector( 63 blink::WebVector<blink::WebMediaStreamTrack> video_track_vector(
70 video ? static_cast<size_t>(1) : 0); 64 video ? static_cast<size_t>(1) : 0);
71 MediaStreamSource::SourceStoppedCallback dummy_callback; 65 MediaStreamSource::SourceStoppedCallback dummy_callback;
72 if (video) { 66 if (video) {
73 blink::WebMediaStreamSource video_source; 67 blink::WebMediaStreamSource video_source;
74 video_source.initialize("video", 68 video_source.initialize("video",
75 blink::WebMediaStreamSource::TypeVideo, 69 blink::WebMediaStreamSource::TypeVideo,
76 "video", 70 "video",
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 EXPECT_TRUE(webrtc_stream()->GetVideoTracks().empty()); 160 EXPECT_TRUE(webrtc_stream()->GetVideoTracks().empty());
167 161
168 native_stream->AddTrack(audio_tracks[0]); 162 native_stream->AddTrack(audio_tracks[0]);
169 EXPECT_EQ(1u, webrtc_stream()->GetAudioTracks().size()); 163 EXPECT_EQ(1u, webrtc_stream()->GetAudioTracks().size());
170 164
171 native_stream->AddTrack(video_tracks[0]); 165 native_stream->AddTrack(video_tracks[0]);
172 EXPECT_EQ(1u, webrtc_stream()->GetVideoTracks().size()); 166 EXPECT_EQ(1u, webrtc_stream()->GetVideoTracks().size());
173 } 167 }
174 168
175 } // namespace content 169 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc/webrtc_media_stream_adapter.cc ('k') | content/renderer/media/webrtc_audio_capturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698