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

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host.cc

Issue 2068103003: Reland of Make default media device ID salts random by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix WebRTCAudioPrivateTest Created 4 years, 6 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/browser/renderer_host/media/audio_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_renderer_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 reader_.get())), 187 reader_.get())),
188 playing_(false) { 188 playing_(false) {
189 DCHECK(controller_.get()); 189 DCHECK(controller_.get());
190 } 190 }
191 191
192 AudioRendererHost::AudioEntry::~AudioEntry() {} 192 AudioRendererHost::AudioEntry::~AudioEntry() {}
193 193
194 /////////////////////////////////////////////////////////////////////////////// 194 ///////////////////////////////////////////////////////////////////////////////
195 // AudioRendererHost implementations. 195 // AudioRendererHost implementations.
196 196
197 AudioRendererHost::AudioRendererHost( 197 AudioRendererHost::AudioRendererHost(int render_process_id,
198 int render_process_id, 198 media::AudioManager* audio_manager,
199 media::AudioManager* audio_manager, 199 AudioMirroringManager* mirroring_manager,
200 AudioMirroringManager* mirroring_manager, 200 MediaInternals* media_internals,
201 MediaInternals* media_internals, 201 MediaStreamManager* media_stream_manager,
202 MediaStreamManager* media_stream_manager, 202 const std::string& salt)
203 const ResourceContext::SaltCallback& salt_callback)
204 : BrowserMessageFilter(AudioMsgStart), 203 : BrowserMessageFilter(AudioMsgStart),
205 render_process_id_(render_process_id), 204 render_process_id_(render_process_id),
206 audio_manager_(audio_manager), 205 audio_manager_(audio_manager),
207 mirroring_manager_(mirroring_manager), 206 mirroring_manager_(mirroring_manager),
208 audio_log_(media_internals->CreateAudioLog( 207 audio_log_(media_internals->CreateAudioLog(
209 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER)), 208 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER)),
210 media_stream_manager_(media_stream_manager), 209 media_stream_manager_(media_stream_manager),
211 num_playing_streams_(0), 210 num_playing_streams_(0),
212 salt_callback_(salt_callback), 211 salt_(salt),
213 max_simultaneous_streams_(0) { 212 max_simultaneous_streams_(0) {
214 DCHECK(audio_manager_); 213 DCHECK(audio_manager_);
215 DCHECK(media_stream_manager_); 214 DCHECK(media_stream_manager_);
216 } 215 }
217 216
218 AudioRendererHost::~AudioRendererHost() { 217 AudioRendererHost::~AudioRendererHost() {
219 DCHECK_CURRENTLY_ON(BrowserThread::IO); 218 DCHECK_CURRENTLY_ON(BrowserThread::IO);
220 CHECK(audio_entries_.empty()); 219 CHECK(audio_entries_.empty());
221 220
222 // If we had any streams, report UMA stats for the maximum number of 221 // If we had any streams, report UMA stats for the maximum number of
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 info->device.matched_output.channel_layout), 428 info->device.matched_output.channel_layout),
430 info->device.matched_output.sample_rate, 16, 429 info->device.matched_output.sample_rate, 16,
431 info->device.matched_output.frames_per_buffer); 430 info->device.matched_output.frames_per_buffer);
432 output_params.set_effects(info->device.matched_output.effects); 431 output_params.set_effects(info->device.matched_output.effects);
433 authorizations_.insert(MakeAuthorizationData( 432 authorizations_.insert(MakeAuthorizationData(
434 stream_id, true, info->device.matched_output_device_id)); 433 stream_id, true, info->device.matched_output_device_id));
435 MaybeFixAudioParameters(&output_params); 434 MaybeFixAudioParameters(&output_params);
436 // Hash matched device id and pass it to the renderer 435 // Hash matched device id and pass it to the renderer
437 Send(new AudioMsg_NotifyDeviceAuthorized( 436 Send(new AudioMsg_NotifyDeviceAuthorized(
438 stream_id, media::OUTPUT_DEVICE_STATUS_OK, output_params, 437 stream_id, media::OUTPUT_DEVICE_STATUS_OK, output_params,
439 GetHMACForMediaDeviceID(salt_callback_, security_origin, 438 GetHMACForMediaDeviceID(salt_, security_origin,
440 info->device.matched_output_device_id))); 439 info->device.matched_output_device_id)));
441 return; 440 return;
442 } 441 }
443 } 442 }
444 443
445 authorizations_.insert( 444 authorizations_.insert(
446 MakeAuthorizationData(stream_id, false, std::string())); 445 MakeAuthorizationData(stream_id, false, std::string()));
447 CheckOutputDeviceAccess( 446 CheckOutputDeviceAccess(
448 render_frame_id, device_id, security_origin, 447 render_frame_id, device_id, security_origin,
449 base::Bind(&AudioRendererHost::OnDeviceAuthorized, this, stream_id, 448 base::Bind(&AudioRendererHost::OnDeviceAuthorized, this, stream_id,
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 const OutputDeviceInfoCB& callback, 787 const OutputDeviceInfoCB& callback,
789 const AudioOutputDeviceEnumeration& enumeration) { 788 const AudioOutputDeviceEnumeration& enumeration) {
790 DCHECK_CURRENTLY_ON(BrowserThread::IO); 789 DCHECK_CURRENTLY_ON(BrowserThread::IO);
791 for (const AudioOutputDeviceInfo& device_info : enumeration.devices) { 790 for (const AudioOutputDeviceInfo& device_info : enumeration.devices) {
792 if (device_id.empty()) { 791 if (device_id.empty()) {
793 if (device_info.unique_id == 792 if (device_info.unique_id ==
794 media::AudioDeviceDescription::kDefaultDeviceId) { 793 media::AudioDeviceDescription::kDefaultDeviceId) {
795 callback.Run(true, device_info); 794 callback.Run(true, device_info);
796 return; 795 return;
797 } 796 }
798 } else if (content::DoesMediaDeviceIDMatchHMAC(salt_callback_, 797 } else if (content::DoesMediaDeviceIDMatchHMAC(
799 security_origin, device_id, 798 salt_, security_origin, device_id, device_info.unique_id)) {
800 device_info.unique_id)) {
801 callback.Run(true, device_info); 799 callback.Run(true, device_info);
802 return; 800 return;
803 } 801 }
804 } 802 }
805 DCHECK(!device_id.empty()); // Default device must always be found 803 DCHECK(!device_id.empty()); // Default device must always be found
806 AudioOutputDeviceInfo device_info = { 804 AudioOutputDeviceInfo device_info = {
807 std::string(), std::string(), 805 std::string(), std::string(),
808 media::AudioParameters::UnavailableDeviceParams()}; 806 media::AudioParameters::UnavailableDeviceParams()};
809 callback.Run(false, device_info); 807 callback.Run(false, device_info);
810 } 808 }
811 809
812 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { 810 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) {
813 DCHECK_CURRENTLY_ON(BrowserThread::IO); 811 DCHECK_CURRENTLY_ON(BrowserThread::IO);
814 const auto& i = authorizations_.find(stream_id); 812 const auto& i = authorizations_.find(stream_id);
815 return i != authorizations_.end(); 813 return i != authorizations_.end();
816 } 814 }
817 815
818 } // namespace content 816 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698