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

Unified 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: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/common/media/media_stream_options.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/media_stream_manager.cc
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc
index f10973e0e8c4dcc19d3e4beff83cc5b110be41db..2e0d77b2ebf1406c198a4cb19558fdeed7d4c268 100644
--- a/content/browser/renderer_host/media/media_stream_manager.cc
+++ b/content/browser/renderer_host/media/media_stream_manager.cc
@@ -134,6 +134,27 @@ void FilterAudioEffects(const StreamOptions& options, int* effects) {
}
}
+// Unlike other effects, hotword is off by default, so turn it on if it's
+// requested and available.
+void EnableHotwordEffect(const StreamOptions& options, int* effects) {
+ DCHECK(effects);
+ std::string value;
+ if (options.GetFirstAudioConstraintByName(
+ kMediaStreamAudioHotword, &value, NULL) && value == "true") {
+#if defined(OS_CHROMEOS)
+ chromeos::AudioDeviceList devices;
+ chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices);
+ // Only enable if a hotword device exists.
+ for (size_t i = 0; i < devices.size(); ++i) {
+ if (devices[i].type == chromeos::AUDIO_TYPE_AOKR) {
+ DCHECK(devices[i].is_input);
+ *effects |= media::AudioParameters::HOTWORD;
+ }
+ }
+#endif
+ }
+}
+
// Private helper method for SendMessageToNativeLog() that obtains the global
// MediaStreamManager instance on the UI thread before sending |message| to the
// webrtcLoggingPrivate API.
@@ -1412,6 +1433,8 @@ bool MediaStreamManager::FindExistingRequestedDeviceInfo(
// is set to and not what the capabilities are.
FilterAudioEffects(request->options,
&existing_device_info->device.input.effects);
+ EnableHotwordEffect(request->options,
+ &existing_device_info->device.input.effects);
*existing_request_state = request->state(device_it->device.type);
return true;
}
@@ -1651,6 +1674,8 @@ void MediaStreamManager::Opened(MediaStreamType stream_type,
// request asks for.
FilterAudioEffects(request->options,
&device_it->device.input.effects);
+ EnableHotwordEffect(request->options,
+ &device_it->device.input.effects);
device_it->device.matched_output = info->device.matched_output;
}
« 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