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

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

Issue 816193003: Add a new audio constraint, 'googHotword', that requests the hotword input (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 5 years, 11 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
« no previous file with comments | « no previous file | content/common/media/media_stream_options.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 void FilterAudioEffects(const StreamOptions& options, int* effects) { 127 void FilterAudioEffects(const StreamOptions& options, int* effects) {
128 DCHECK(effects); 128 DCHECK(effects);
129 // TODO(ajm): Should we also handle ECHO_CANCELLER here? 129 // TODO(ajm): Should we also handle ECHO_CANCELLER here?
130 std::string value; 130 std::string value;
131 if (options.GetFirstAudioConstraintByName( 131 if (options.GetFirstAudioConstraintByName(
132 kMediaStreamAudioDucking, &value, NULL) && value == "false") { 132 kMediaStreamAudioDucking, &value, NULL) && value == "false") {
133 *effects &= ~media::AudioParameters::DUCKING; 133 *effects &= ~media::AudioParameters::DUCKING;
134 } 134 }
135 } 135 }
136 136
137 // Unlike other effects, hotword is off by default, so turn it on if it's
138 // requested and available.
139 void EnableHotwordEffect(const StreamOptions& options, int* effects) {
140 DCHECK(effects);
141 std::string value;
142 if (options.GetFirstAudioConstraintByName(
143 kMediaStreamAudioHotword, &value, NULL) && value == "true") {
144 #if defined(OS_CHROMEOS)
145 chromeos::AudioDeviceList devices;
146 chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices);
DaleCurtis 2015/01/05 22:57:52 Is this something you want to check every time? De
Anand Mistry (off Chromium) 2015/01/06 02:02:40 As far as I can tell, this is a non-blocking opera
147 // Only enable if a hotword device exists.
148 for (size_t i = 0; i < devices.size(); ++i) {
149 if (devices[i].type == chromeos::AUDIO_TYPE_AOKR) {
150 DCHECK(devices[i].is_input);
151 *effects |= media::AudioParameters::HOTWORD;
152 }
153 }
154 #endif
155 }
156 }
157
137 // Private helper method for SendMessageToNativeLog() that obtains the global 158 // Private helper method for SendMessageToNativeLog() that obtains the global
138 // MediaStreamManager instance on the UI thread before sending |message| to the 159 // MediaStreamManager instance on the UI thread before sending |message| to the
139 // webrtcLoggingPrivate API. 160 // webrtcLoggingPrivate API.
140 void DoAddLogMessage(const std::string& message) { 161 void DoAddLogMessage(const std::string& message) {
141 // Must be on the UI thread to access BrowserMainLoop. 162 // Must be on the UI thread to access BrowserMainLoop.
142 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 163 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
143 // May be null in tests. 164 // May be null in tests.
144 // TODO(vrk): Handle this more elegantly by having native log messages become 165 // TODO(vrk): Handle this more elegantly by having native log messages become
145 // no-ops until MediaStreamManager is aware that a renderer process has 166 // no-ops until MediaStreamManager is aware that a renderer process has
146 // started logging. crbug.com/333894 167 // started logging. crbug.com/333894
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 for (StreamDeviceInfoArray::const_iterator device_it = 1426 for (StreamDeviceInfoArray::const_iterator device_it =
1406 request->devices.begin(); 1427 request->devices.begin();
1407 device_it != request->devices.end(); ++device_it) { 1428 device_it != request->devices.end(); ++device_it) {
1408 if (device_it->device.id == source_id && 1429 if (device_it->device.id == source_id &&
1409 device_it->device.type == new_device_info.type) { 1430 device_it->device.type == new_device_info.type) {
1410 *existing_device_info = *device_it; 1431 *existing_device_info = *device_it;
1411 // Make sure that the audio |effects| reflect what the request 1432 // Make sure that the audio |effects| reflect what the request
1412 // is set to and not what the capabilities are. 1433 // is set to and not what the capabilities are.
1413 FilterAudioEffects(request->options, 1434 FilterAudioEffects(request->options,
1414 &existing_device_info->device.input.effects); 1435 &existing_device_info->device.input.effects);
1436 EnableHotwordEffect(request->options,
1437 &existing_device_info->device.input.effects);
1415 *existing_request_state = request->state(device_it->device.type); 1438 *existing_request_state = request->state(device_it->device.type);
1416 return true; 1439 return true;
1417 } 1440 }
1418 } 1441 }
1419 } 1442 }
1420 } 1443 }
1421 return false; 1444 return false;
1422 } 1445 }
1423 1446
1424 void MediaStreamManager::FinalizeGenerateStream(const std::string& label, 1447 void MediaStreamManager::FinalizeGenerateStream(const std::string& label,
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 audio_input_device_manager_->GetOpenedDeviceInfoById( 1667 audio_input_device_manager_->GetOpenedDeviceInfoById(
1645 device_it->session_id); 1668 device_it->session_id);
1646 device_it->device.input = info->device.input; 1669 device_it->device.input = info->device.input;
1647 1670
1648 // Since the audio input device manager will set the input 1671 // Since the audio input device manager will set the input
1649 // parameters to the default settings (including supported effects), 1672 // parameters to the default settings (including supported effects),
1650 // we need to adjust those settings here according to what the 1673 // we need to adjust those settings here according to what the
1651 // request asks for. 1674 // request asks for.
1652 FilterAudioEffects(request->options, 1675 FilterAudioEffects(request->options,
1653 &device_it->device.input.effects); 1676 &device_it->device.input.effects);
1677 EnableHotwordEffect(request->options,
1678 &device_it->device.input.effects);
1654 1679
1655 device_it->device.matched_output = info->device.matched_output; 1680 device_it->device.matched_output = info->device.matched_output;
1656 } 1681 }
1657 } 1682 }
1658 if (RequestDone(*request)) 1683 if (RequestDone(*request))
1659 HandleRequestDone(label, request); 1684 HandleRequestDone(label, request);
1660 break; 1685 break;
1661 } 1686 }
1662 } 1687 }
1663 } 1688 }
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 } 2156 }
2132 } 2157 }
2133 2158
2134 void MediaStreamManager::SetKeyboardMicOnDeviceThread() { 2159 void MediaStreamManager::SetKeyboardMicOnDeviceThread() {
2135 DCHECK(device_task_runner_->BelongsToCurrentThread()); 2160 DCHECK(device_task_runner_->BelongsToCurrentThread());
2136 audio_manager_->SetHasKeyboardMic(); 2161 audio_manager_->SetHasKeyboardMic();
2137 } 2162 }
2138 #endif 2163 #endif
2139 2164
2140 } // namespace content 2165 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/media/media_stream_options.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698