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

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

Issue 1769933002: Looking up device id by session id for AudioRendererMixerInput (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment and bug ref to remove AudioManagerBase dependency Created 4 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_device_factory.h" 5 #include "content/renderer/media/audio_device_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/renderer/media/audio_input_message_filter.h" 8 #include "content/renderer/media/audio_input_message_filter.h"
9 #include "content/renderer/media/audio_message_filter.h" 9 #include "content/renderer/media/audio_message_filter.h"
10 #include "content/renderer/media/audio_renderer_mixer_manager.h" 10 #include "content/renderer/media/audio_renderer_mixer_manager.h"
(...skipping 29 matching lines...) Expand all
40 if (source_type == AudioDeviceFactory::kSourceMediaElement) 40 if (source_type == AudioDeviceFactory::kSourceMediaElement)
41 return true; // Must ALWAYS go through mixer. 41 return true; // Must ALWAYS go through mixer.
42 42
43 // TODO(olka): make a decision for the rest of the sources basing on OS 43 // TODO(olka): make a decision for the rest of the sources basing on OS
44 // type and configuration parameters. 44 // type and configuration parameters.
45 return false; 45 return false;
46 } 46 }
47 47
48 scoped_refptr<media::SwitchableAudioRendererSink> NewMixableSink( 48 scoped_refptr<media::SwitchableAudioRendererSink> NewMixableSink(
49 int render_frame_id, 49 int render_frame_id,
50 int session_id,
50 const std::string& device_id, 51 const std::string& device_id,
51 const url::Origin& security_origin) { 52 const url::Origin& security_origin) {
52 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 53 RenderThreadImpl* render_thread = RenderThreadImpl::current();
53 return scoped_refptr<media::AudioRendererMixerInput>( 54 return scoped_refptr<media::AudioRendererMixerInput>(
54 render_thread->GetAudioRendererMixerManager()->CreateInput( 55 render_thread->GetAudioRendererMixerManager()->CreateInput(
55 render_frame_id, device_id, security_origin)); 56 render_frame_id, session_id, device_id, security_origin));
56 }
57
58 scoped_refptr<media::AudioRendererSink> NewUnmixableSink(
59 int render_frame_id,
60 int session_id,
61 const std::string& device_id,
62 const url::Origin& security_origin) {
63 return NewOutputDevice(render_frame_id, session_id, device_id,
64 security_origin);
65 } 57 }
66 58
67 } // namespace 59 } // namespace
68 60
69 scoped_refptr<media::AudioRendererSink> 61 scoped_refptr<media::AudioRendererSink>
70 AudioDeviceFactory::NewAudioRendererMixerSink( 62 AudioDeviceFactory::NewAudioRendererMixerSink(
71 int render_frame_id, 63 int render_frame_id,
72 int session_id, 64 int session_id,
73 const std::string& device_id, 65 const std::string& device_id,
74 const url::Origin& security_origin) { 66 const url::Origin& security_origin) {
75 if (factory_) { 67 return NewFinalAudioRendererSink(render_frame_id, session_id, device_id,
76 scoped_refptr<media::AudioRendererSink> sink = 68 security_origin);
77 factory_->CreateAudioRendererMixerSink(render_frame_id, session_id,
78 device_id, security_origin);
79 if (sink)
80 return sink;
81 }
82 return NewOutputDevice(render_frame_id, session_id, device_id,
83 security_origin);
84 } 69 }
85 70
86 // static 71 // static
87 scoped_refptr<media::AudioRendererSink> 72 scoped_refptr<media::AudioRendererSink>
88 AudioDeviceFactory::NewAudioRendererSink(SourceType source_type, 73 AudioDeviceFactory::NewAudioRendererSink(SourceType source_type,
89 int render_frame_id, 74 int render_frame_id,
90 int session_id, 75 int session_id,
91 const std::string& device_id, 76 const std::string& device_id,
92 const url::Origin& security_origin) { 77 const url::Origin& security_origin) {
93 if (factory_) { 78 if (factory_) {
94 scoped_refptr<media::AudioRendererSink> device = 79 scoped_refptr<media::AudioRendererSink> device =
95 factory_->CreateAudioRendererSink(source_type, render_frame_id, 80 factory_->CreateAudioRendererSink(source_type, render_frame_id,
96 session_id, device_id, 81 session_id, device_id,
97 security_origin); 82 security_origin);
98 if (device) 83 if (device)
99 return device; 84 return device;
100 } 85 }
101 86
102 if (IsMixable(source_type)) 87 if (IsMixable(source_type))
103 return NewMixableSink(render_frame_id, device_id, security_origin); 88 return NewMixableSink(render_frame_id, session_id, device_id,
89 security_origin);
104 90
105 return NewUnmixableSink(render_frame_id, session_id, device_id, 91 return NewFinalAudioRendererSink(render_frame_id, session_id, device_id,
106 security_origin); 92 security_origin);
107 } 93 }
108 94
109 // static 95 // static
110 scoped_refptr<media::SwitchableAudioRendererSink> 96 scoped_refptr<media::SwitchableAudioRendererSink>
111 AudioDeviceFactory::NewSwitchableAudioRendererSink( 97 AudioDeviceFactory::NewSwitchableAudioRendererSink(
112 SourceType source_type, 98 SourceType source_type,
113 int render_frame_id, 99 int render_frame_id,
114 int session_id, 100 int session_id,
115 const std::string& device_id, 101 const std::string& device_id,
116 const url::Origin& security_origin) { 102 const url::Origin& security_origin) {
117 if (factory_) { 103 if (factory_) {
118 scoped_refptr<media::SwitchableAudioRendererSink> sink = 104 scoped_refptr<media::SwitchableAudioRendererSink> sink =
119 factory_->CreateSwitchableAudioRendererSink(source_type, 105 factory_->CreateSwitchableAudioRendererSink(source_type,
120 render_frame_id, session_id, 106 render_frame_id, session_id,
121 device_id, security_origin); 107 device_id, security_origin);
122 if (sink) 108 if (sink)
123 return sink; 109 return sink;
124 } 110 }
125 111
126 if (IsMixable(source_type)) 112 if (IsMixable(source_type))
127 return NewMixableSink(render_frame_id, device_id, security_origin); 113 return NewMixableSink(render_frame_id, session_id, device_id,
114 security_origin);
128 115
129 // AudioOutputDevice is not RestartableAudioRendererSink, so we can't return 116 // AudioOutputDevice is not RestartableAudioRendererSink, so we can't return
130 // anything for those who wants to create an unmixable sink. 117 // anything for those who wants to create an unmixable sink.
131 NOTIMPLEMENTED(); 118 NOTIMPLEMENTED();
132 return nullptr; 119 return nullptr;
133 } 120 }
134 121
135 // static 122 // static
136 scoped_refptr<media::AudioCapturerSource> 123 scoped_refptr<media::AudioCapturerSource>
137 AudioDeviceFactory::NewAudioCapturerSource(int render_frame_id) { 124 AudioDeviceFactory::NewAudioCapturerSource(int render_frame_id) {
(...skipping 10 matching lines...) Expand all
148 } 135 }
149 136
150 // static 137 // static
151 // TODO(http://crbug.com/587461): Find a better way to check if device exists 138 // TODO(http://crbug.com/587461): Find a better way to check if device exists
152 // and is authorized. 139 // and is authorized.
153 media::OutputDeviceInfo AudioDeviceFactory::GetOutputDeviceInfo( 140 media::OutputDeviceInfo AudioDeviceFactory::GetOutputDeviceInfo(
154 int render_frame_id, 141 int render_frame_id,
155 int session_id, 142 int session_id,
156 const std::string& device_id, 143 const std::string& device_id,
157 const url::Origin& security_origin) { 144 const url::Origin& security_origin) {
158 scoped_refptr<media::AudioOutputDevice> device = 145 scoped_refptr<media::AudioRendererSink> sink = NewFinalAudioRendererSink(
159 NewOutputDevice(render_frame_id, session_id, device_id, security_origin); 146 render_frame_id, session_id, device_id, security_origin);
160 147
161 const media::OutputDeviceInfo& device_info = device->GetOutputDeviceInfo(); 148 const media::OutputDeviceInfo& device_info = sink->GetOutputDeviceInfo();
162 device->Stop(); // Must be stopped. 149
150 // TODO(olka): Cache it and reuse, http://crbug.com/586161
151 sink->Stop(); // Must be stopped.
152
163 return device_info; 153 return device_info;
164 } 154 }
165 155
166 AudioDeviceFactory::AudioDeviceFactory() { 156 AudioDeviceFactory::AudioDeviceFactory() {
167 DCHECK(!factory_) << "Can't register two factories at once."; 157 DCHECK(!factory_) << "Can't register two factories at once.";
168 factory_ = this; 158 factory_ = this;
169 } 159 }
170 160
171 AudioDeviceFactory::~AudioDeviceFactory() { 161 AudioDeviceFactory::~AudioDeviceFactory() {
172 factory_ = NULL; 162 factory_ = NULL;
173 } 163 }
174 164
165 // static
166 scoped_refptr<media::AudioRendererSink>
167 AudioDeviceFactory::NewFinalAudioRendererSink(
168 int render_frame_id,
169 int session_id,
170 const std::string& device_id,
171 const url::Origin& security_origin) {
172 if (factory_) {
173 scoped_refptr<media::AudioRendererSink> sink =
174 factory_->CreateFinalAudioRendererSink(render_frame_id, session_id,
175 device_id, security_origin);
176 if (sink)
177 return sink;
178 }
179
180 return NewOutputDevice(render_frame_id, session_id, device_id,
181 security_origin);
182 }
183
175 } // namespace content 184 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/audio_device_factory.h ('k') | content/renderer/media/audio_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698