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

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

Issue 1721273002: MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests broken by recent MSAudioTrack::Stop() reworking. Created 4 years, 9 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/renderer/media/mock_media_stream_registry.h" 5 #include "content/renderer/media/mock_media_stream_registry.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.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" 11 #include "content/renderer/media/media_stream_audio_source.h"
12 #include "content/renderer/media/media_stream_video_track.h" 12 #include "content/renderer/media/media_stream_video_track.h"
13 #include "content/renderer/media/mock_media_constraint_factory.h"
14 #include "content/renderer/media/mock_media_stream_video_source.h" 13 #include "content/renderer/media/mock_media_stream_video_source.h"
15 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" 14 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
16 #include "content/renderer/media/webrtc_local_audio_track.h" 15 #include "content/renderer/media/webrtc_local_audio_track.h"
17 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 16 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 17 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
19 #include "third_party/WebKit/public/platform/WebString.h" 18 #include "third_party/WebKit/public/platform/WebString.h"
20 #include "third_party/WebKit/public/platform/WebVector.h" 19 #include "third_party/WebKit/public/platform/WebVector.h"
21 20
22 namespace content { 21 namespace content {
23 22
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 55 }
57 56
58 void MockMediaStreamRegistry::AddAudioTrack(const std::string& track_id) { 57 void MockMediaStreamRegistry::AddAudioTrack(const std::string& track_id) {
59 blink::WebMediaStreamSource audio_source; 58 blink::WebMediaStreamSource audio_source;
60 audio_source.initialize( 59 audio_source.initialize(
61 "mock audio source id", blink::WebMediaStreamSource::TypeAudio, 60 "mock audio source id", blink::WebMediaStreamSource::TypeAudio,
62 "mock audio source name", false /* remote */, true /* readonly */); 61 "mock audio source name", false /* remote */, true /* readonly */);
63 audio_source.setExtraData(new MediaStreamAudioSource()); 62 audio_source.setExtraData(new MediaStreamAudioSource());
64 blink::WebMediaStreamTrack blink_track; 63 blink::WebMediaStreamTrack blink_track;
65 blink_track.initialize(audio_source); 64 blink_track.initialize(audio_source);
66 const StreamDeviceInfo device_info(
67 MEDIA_DEVICE_AUDIO_CAPTURE, "Mock audio device", "mock_audio_device_id");
68 const MockMediaConstraintFactory constraint_factory;
69 const blink::WebMediaConstraints constraints =
70 constraint_factory.CreateWebMediaConstraints();
71 const scoped_refptr<WebRtcAudioCapturer> capturer(
72 WebRtcAudioCapturer::CreateCapturer(-1, /* render frame id */
73 device_info, constraints,
74 nullptr, /* audio device */
75 nullptr /* audio source */));
76 const scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter( 65 const scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter(
77 WebRtcLocalAudioTrackAdapter::Create(track_id, 66 WebRtcLocalAudioTrackAdapter::Create(track_id,
78 nullptr /* track source */)); 67 nullptr /* track source */));
79 scoped_ptr<WebRtcLocalAudioTrack> native_track(new WebRtcLocalAudioTrack( 68 scoped_ptr<WebRtcLocalAudioTrack> native_track(
80 adapter.get(), capturer, nullptr /* webaudio source */)); 69 new WebRtcLocalAudioTrack(adapter.get()));
81 blink_track.setExtraData(native_track.release()); 70 blink_track.setExtraData(native_track.release());
82 test_stream_.addTrack(blink_track); 71 test_stream_.addTrack(blink_track);
83 } 72 }
84 73
85 blink::WebMediaStream MockMediaStreamRegistry::GetMediaStream( 74 blink::WebMediaStream MockMediaStreamRegistry::GetMediaStream(
86 const std::string& url) { 75 const std::string& url) {
87 return (url != stream_url_) ? blink::WebMediaStream() : test_stream_; 76 return (url != stream_url_) ? blink::WebMediaStream() : test_stream_;
88 } 77 }
89 78
90 } // namespace content 79 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698