| 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/renderer/renderer_blink_platform_impl.h" | 5 #include "content/renderer/renderer_blink_platform_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "media/filters/stream_parser_factory.h" | 79 #include "media/filters/stream_parser_factory.h" |
| 80 #include "mojo/public/cpp/bindings/associated_group.h" | 80 #include "mojo/public/cpp/bindings/associated_group.h" |
| 81 #include "ppapi/features/features.h" | 81 #include "ppapi/features/features.h" |
| 82 #include "services/service_manager/public/cpp/interface_provider.h" | 82 #include "services/service_manager/public/cpp/interface_provider.h" |
| 83 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 83 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" |
| 84 #include "storage/common/database/database_identifier.h" | 84 #include "storage/common/database/database_identifier.h" |
| 85 #include "storage/common/quota/quota_types.h" | 85 #include "storage/common/quota/quota_types.h" |
| 86 #include "third_party/WebKit/public/platform/BlameContext.h" | 86 #include "third_party/WebKit/public/platform/BlameContext.h" |
| 87 #include "third_party/WebKit/public/platform/FilePathConversion.h" | 87 #include "third_party/WebKit/public/platform/FilePathConversion.h" |
| 88 #include "third_party/WebKit/public/platform/URLConversion.h" | 88 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 89 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.h" |
| 89 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 90 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
| 90 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" | 91 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" |
| 91 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 92 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
| 92 #include "third_party/WebKit/public/platform/WebGamepads.h" | 93 #include "third_party/WebKit/public/platform/WebGamepads.h" |
| 93 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 94 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
| 94 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" | 95 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" |
| 95 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 96 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
| 96 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 97 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 97 #include "third_party/WebKit/public/platform/WebURL.h" | 98 #include "third_party/WebKit/public/platform/WebURL.h" |
| 98 #include "third_party/WebKit/public/platform/WebVector.h" | 99 #include "third_party/WebKit/public/platform/WebVector.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior | 135 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior |
| 135 #endif | 136 #endif |
| 136 | 137 |
| 137 #if BUILDFLAG(ENABLE_WEBRTC) | 138 #if BUILDFLAG(ENABLE_WEBRTC) |
| 138 #include "content/renderer/media/rtc_certificate_generator.h" | 139 #include "content/renderer/media/rtc_certificate_generator.h" |
| 139 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 140 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
| 140 #endif | 141 #endif |
| 141 | 142 |
| 142 using blink::Platform; | 143 using blink::Platform; |
| 143 using blink::WebAudioDevice; | 144 using blink::WebAudioDevice; |
| 145 using blink::WebAudioLatencyHint; |
| 144 using blink::WebBlobRegistry; | 146 using blink::WebBlobRegistry; |
| 145 using blink::WebCanvasCaptureHandler; | 147 using blink::WebCanvasCaptureHandler; |
| 146 using blink::WebDatabaseObserver; | 148 using blink::WebDatabaseObserver; |
| 147 using blink::WebFileInfo; | 149 using blink::WebFileInfo; |
| 148 using blink::WebFileSystem; | 150 using blink::WebFileSystem; |
| 149 using blink::WebGamepad; | 151 using blink::WebGamepad; |
| 150 using blink::WebGamepads; | 152 using blink::WebGamepads; |
| 151 using blink::WebIDBFactory; | 153 using blink::WebIDBFactory; |
| 152 using blink::WebImageCaptureFrameGrabber; | 154 using blink::WebImageCaptureFrameGrabber; |
| 153 using blink::WebMIDIAccessor; | 155 using blink::WebMIDIAccessor; |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 | 654 |
| 653 unsigned RendererBlinkPlatformImpl::audioHardwareOutputChannels() { | 655 unsigned RendererBlinkPlatformImpl::audioHardwareOutputChannels() { |
| 654 return GetAudioHardwareParams().channels(); | 656 return GetAudioHardwareParams().channels(); |
| 655 } | 657 } |
| 656 | 658 |
| 657 WebDatabaseObserver* RendererBlinkPlatformImpl::databaseObserver() { | 659 WebDatabaseObserver* RendererBlinkPlatformImpl::databaseObserver() { |
| 658 return web_database_observer_impl_.get(); | 660 return web_database_observer_impl_.get(); |
| 659 } | 661 } |
| 660 | 662 |
| 661 WebAudioDevice* RendererBlinkPlatformImpl::createAudioDevice( | 663 WebAudioDevice* RendererBlinkPlatformImpl::createAudioDevice( |
| 662 size_t buffer_size, | |
| 663 unsigned input_channels, | 664 unsigned input_channels, |
| 664 unsigned channels, | 665 unsigned channels, |
| 665 double sample_rate, | 666 const blink::WebAudioLatencyHint& latency_hint, |
| 666 WebAudioDevice::RenderCallback* callback, | 667 WebAudioDevice::RenderCallback* callback, |
| 667 const blink::WebString& input_device_id, | 668 const blink::WebString& input_device_id, |
| 668 const blink::WebSecurityOrigin& security_origin) { | 669 const blink::WebSecurityOrigin& security_origin) { |
| 669 // Use a mock for testing. | 670 // Use a mock for testing. |
| 670 blink::WebAudioDevice* mock_device = | 671 blink::WebAudioDevice* mock_device = |
| 671 GetContentClient()->renderer()->OverrideCreateAudioDevice(sample_rate); | 672 GetContentClient()->renderer()->OverrideCreateAudioDevice(); |
| 672 if (mock_device) | 673 if (mock_device) |
| 673 return mock_device; | 674 return mock_device; |
| 674 | 675 |
| 675 // The |channels| does not exactly identify the channel layout of the | 676 // The |channels| does not exactly identify the channel layout of the |
| 676 // device. The switch statement below assigns a best guess to the channel | 677 // device. The switch statement below assigns a best guess to the channel |
| 677 // layout based on number of channels. | 678 // layout based on number of channels. |
| 678 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED; | 679 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED; |
| 679 switch (channels) { | 680 switch (channels) { |
| 680 case 1: | 681 case 1: |
| 681 layout = media::CHANNEL_LAYOUT_MONO; | 682 layout = media::CHANNEL_LAYOUT_MONO; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 695 case 6: | 696 case 6: |
| 696 layout = media::CHANNEL_LAYOUT_5_1; | 697 layout = media::CHANNEL_LAYOUT_5_1; |
| 697 break; | 698 break; |
| 698 case 7: | 699 case 7: |
| 699 layout = media::CHANNEL_LAYOUT_7_0; | 700 layout = media::CHANNEL_LAYOUT_7_0; |
| 700 break; | 701 break; |
| 701 case 8: | 702 case 8: |
| 702 layout = media::CHANNEL_LAYOUT_7_1; | 703 layout = media::CHANNEL_LAYOUT_7_1; |
| 703 break; | 704 break; |
| 704 default: | 705 default: |
| 705 // If the layout is not supported (more than 9 channels), falls back to | 706 // TODO need to also pass 'channels' into RendererWebAudioDeviceImpl for |
| 706 // discrete mode. | 707 // CHANNEL_LAYOUT_DISCRETE |
| 707 layout = media::CHANNEL_LAYOUT_DISCRETE; | 708 NOTREACHED(); |
| 708 } | 709 } |
| 709 | 710 |
| 710 int session_id = 0; | 711 int session_id = 0; |
| 711 if (input_device_id.isNull() || | 712 if (input_device_id.isNull() || |
| 712 !base::StringToInt(input_device_id.utf8(), &session_id)) { | 713 !base::StringToInt(input_device_id.utf8(), &session_id)) { |
| 713 if (input_channels > 0) | 714 if (input_channels > 0) |
| 714 DLOG(WARNING) << "createAudioDevice(): request for audio input ignored"; | 715 DLOG(WARNING) << "createAudioDevice(): request for audio input ignored"; |
| 715 | 716 |
| 716 input_channels = 0; | 717 input_channels = 0; |
| 717 } | 718 } |
| 718 | 719 |
| 719 // For CHANNEL_LAYOUT_DISCRETE, pass the explicit channel count along with | 720 return RendererWebAudioDeviceImpl::Create( |
| 720 // the channel layout when creating an |AudioParameters| object. | 721 layout, latency_hint, callback, session_id, |
| 721 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 722 static_cast<url::Origin>(security_origin)); |
| 722 layout, static_cast<int>(sample_rate), 16, | |
| 723 buffer_size); | |
| 724 params.set_channels_for_discrete(channels); | |
| 725 | |
| 726 return new RendererWebAudioDeviceImpl( | |
| 727 params, callback, session_id, static_cast<url::Origin>(security_origin)); | |
| 728 } | 723 } |
| 729 | 724 |
| 730 bool RendererBlinkPlatformImpl::loadAudioResource( | 725 bool RendererBlinkPlatformImpl::loadAudioResource( |
| 731 blink::WebAudioBus* destination_bus, | 726 blink::WebAudioBus* destination_bus, |
| 732 const char* audio_file_data, | 727 const char* audio_file_data, |
| 733 size_t data_size) { | 728 size_t data_size) { |
| 734 return DecodeAudioFileData( | 729 return DecodeAudioFileData( |
| 735 destination_bus, audio_file_data, data_size); | 730 destination_bus, audio_file_data, data_size); |
| 736 } | 731 } |
| 737 | 732 |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 return &trial_token_validator_; | 1283 return &trial_token_validator_; |
| 1289 } | 1284 } |
| 1290 | 1285 |
| 1291 void RendererBlinkPlatformImpl::workerContextCreated( | 1286 void RendererBlinkPlatformImpl::workerContextCreated( |
| 1292 const v8::Local<v8::Context>& worker) { | 1287 const v8::Local<v8::Context>& worker) { |
| 1293 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( | 1288 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( |
| 1294 worker); | 1289 worker); |
| 1295 } | 1290 } |
| 1296 | 1291 |
| 1297 } // namespace content | 1292 } // namespace content |
| OLD | NEW |