| OLD | NEW |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } else if (video_stream_source == kMediaStreamSourceDesktop) { | 111 } else if (video_stream_source == kMediaStreamSourceDesktop) { |
| 112 *video_type = content::MEDIA_DESKTOP_VIDEO_CAPTURE; | 112 *video_type = content::MEDIA_DESKTOP_VIDEO_CAPTURE; |
| 113 } | 113 } |
| 114 } else { | 114 } else { |
| 115 // This is normal video device capture. | 115 // This is normal video device capture. |
| 116 *video_type = MEDIA_DEVICE_VIDEO_CAPTURE; | 116 *video_type = MEDIA_DEVICE_VIDEO_CAPTURE; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 // Turns off available audio effects (removes the flag) if the options |
| 122 // explicitly turn them off. |
| 123 void FilterAudioEffects(const StreamOptions& options, int* effects) { |
| 124 DCHECK(effects); |
| 125 // TODO(ajm): Should we also handle ECHO_CANCELLER here? |
| 126 std::string value; |
| 127 if (options.GetFirstAudioConstraintByName( |
| 128 kMediaStreamAudioDucking, &value, NULL) && value == "false") { |
| 129 *effects &= ~media::AudioParameters::DUCKING; |
| 130 } |
| 131 } |
| 132 |
| 121 // Private helper method for SendMessageToNativeLog() that obtains the global | 133 // Private helper method for SendMessageToNativeLog() that obtains the global |
| 122 // MediaStreamManager instance on the UI thread before sending |message| to the | 134 // MediaStreamManager instance on the UI thread before sending |message| to the |
| 123 // webrtcLoggingPrivate API. | 135 // webrtcLoggingPrivate API. |
| 124 void DoAddLogMessage(const std::string& message) { | 136 void DoAddLogMessage(const std::string& message) { |
| 125 // Must be on the UI thread to access BrowserMainLoop. | 137 // Must be on the UI thread to access BrowserMainLoop. |
| 126 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 138 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 127 // May be null in tests. | 139 // May be null in tests. |
| 128 // TODO(vrk): Handle this more elegantly by having native log messages become | 140 // TODO(vrk): Handle this more elegantly by having native log messages become |
| 129 // no-ops until MediaStreamManager is aware that a renderer process has | 141 // no-ops until MediaStreamManager is aware that a renderer process has |
| 130 // started logging. crbug.com/333894 | 142 // started logging. crbug.com/333894 |
| (...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 it != requests_.end() ; ++it) { | 1391 it != requests_.end() ; ++it) { |
| 1380 const DeviceRequest* request = it->second; | 1392 const DeviceRequest* request = it->second; |
| 1381 if (request->requesting_process_id == new_request.requesting_process_id && | 1393 if (request->requesting_process_id == new_request.requesting_process_id && |
| 1382 request->requesting_frame_id == new_request.requesting_frame_id && | 1394 request->requesting_frame_id == new_request.requesting_frame_id && |
| 1383 request->request_type == new_request.request_type) { | 1395 request->request_type == new_request.request_type) { |
| 1384 for (StreamDeviceInfoArray::const_iterator device_it = | 1396 for (StreamDeviceInfoArray::const_iterator device_it = |
| 1385 request->devices.begin(); | 1397 request->devices.begin(); |
| 1386 device_it != request->devices.end(); ++device_it) { | 1398 device_it != request->devices.end(); ++device_it) { |
| 1387 if (device_it->device.id == source_id && | 1399 if (device_it->device.id == source_id && |
| 1388 device_it->device.type == new_device_info.type) { | 1400 device_it->device.type == new_device_info.type) { |
| 1389 *existing_device_info = *device_it; | 1401 *existing_device_info = *device_it; |
| 1390 *existing_request_state = request->state(device_it->device.type); | 1402 // Make sure that the audio |effects| reflect what the request |
| 1403 // is set to and not what the capabilities are. |
| 1404 FilterAudioEffects(request->options, |
| 1405 &existing_device_info->device.input.effects); |
| 1406 *existing_request_state = request->state(device_it->device.type); |
| 1391 return true; | 1407 return true; |
| 1392 } | 1408 } |
| 1393 } | 1409 } |
| 1394 } | 1410 } |
| 1395 } | 1411 } |
| 1396 return false; | 1412 return false; |
| 1397 } | 1413 } |
| 1398 | 1414 |
| 1399 void MediaStreamManager::FinalizeGenerateStream(const std::string& label, | 1415 void MediaStreamManager::FinalizeGenerateStream(const std::string& label, |
| 1400 DeviceRequest* request) { | 1416 DeviceRequest* request) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 | 1577 |
| 1562 if (IsAudioInputMediaType(device_it->device.type)) { | 1578 if (IsAudioInputMediaType(device_it->device.type)) { |
| 1563 // Store the native audio parameters in the device struct. | 1579 // Store the native audio parameters in the device struct. |
| 1564 // TODO(xians): Handle the tab capture sample rate/channel layout | 1580 // TODO(xians): Handle the tab capture sample rate/channel layout |
| 1565 // in AudioInputDeviceManager::Open(). | 1581 // in AudioInputDeviceManager::Open(). |
| 1566 if (device_it->device.type != content::MEDIA_TAB_AUDIO_CAPTURE) { | 1582 if (device_it->device.type != content::MEDIA_TAB_AUDIO_CAPTURE) { |
| 1567 const StreamDeviceInfo* info = | 1583 const StreamDeviceInfo* info = |
| 1568 audio_input_device_manager_->GetOpenedDeviceInfoById( | 1584 audio_input_device_manager_->GetOpenedDeviceInfoById( |
| 1569 device_it->session_id); | 1585 device_it->session_id); |
| 1570 device_it->device.input = info->device.input; | 1586 device_it->device.input = info->device.input; |
| 1587 |
| 1588 // Since the audio input device manager will set the input |
| 1589 // parameters to the default settings (including supported effects), |
| 1590 // we need to adjust those settings here according to what the |
| 1591 // request asks for. |
| 1592 FilterAudioEffects(request->options, |
| 1593 &device_it->device.input.effects); |
| 1594 |
| 1571 device_it->device.matched_output = info->device.matched_output; | 1595 device_it->device.matched_output = info->device.matched_output; |
| 1572 } | 1596 } |
| 1573 } | 1597 } |
| 1574 if (RequestDone(*request)) | 1598 if (RequestDone(*request)) |
| 1575 HandleRequestDone(label, request); | 1599 HandleRequestDone(label, request); |
| 1576 break; | 1600 break; |
| 1577 } | 1601 } |
| 1578 } | 1602 } |
| 1579 } | 1603 } |
| 1580 } | 1604 } |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2015 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { | 2039 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { |
| 2016 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, | 2040 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, |
| 2017 window_id); | 2041 window_id); |
| 2018 break; | 2042 break; |
| 2019 } | 2043 } |
| 2020 } | 2044 } |
| 2021 } | 2045 } |
| 2022 } | 2046 } |
| 2023 | 2047 |
| 2024 } // namespace content | 2048 } // namespace content |
| OLD | NEW |