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

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

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

Powered by Google App Engine
This is Rietveld 408576698