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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 #include "media/filters/stream_parser_factory.h" | 81 #include "media/filters/stream_parser_factory.h" |
82 #include "mojo/common/common_type_converters.h" | 82 #include "mojo/common/common_type_converters.h" |
83 #include "mojo/public/cpp/bindings/associated_group.h" | 83 #include "mojo/public/cpp/bindings/associated_group.h" |
84 #include "ppapi/features/features.h" | 84 #include "ppapi/features/features.h" |
85 #include "services/service_manager/public/cpp/interface_provider.h" | 85 #include "services/service_manager/public/cpp/interface_provider.h" |
86 #include "storage/common/database/database_identifier.h" | 86 #include "storage/common/database/database_identifier.h" |
87 #include "storage/common/quota/quota_types.h" | 87 #include "storage/common/quota/quota_types.h" |
88 #include "third_party/WebKit/public/platform/BlameContext.h" | 88 #include "third_party/WebKit/public/platform/BlameContext.h" |
89 #include "third_party/WebKit/public/platform/FilePathConversion.h" | 89 #include "third_party/WebKit/public/platform/FilePathConversion.h" |
90 #include "third_party/WebKit/public/platform/URLConversion.h" | 90 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 91 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.h" |
91 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 92 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
92 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" | 93 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" |
93 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 94 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
94 #include "third_party/WebKit/public/platform/WebGamepads.h" | 95 #include "third_party/WebKit/public/platform/WebGamepads.h" |
95 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 96 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
96 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" | 97 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" |
97 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 98 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
98 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 99 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
99 #include "third_party/WebKit/public/platform/WebURL.h" | 100 #include "third_party/WebKit/public/platform/WebURL.h" |
100 #include "third_party/WebKit/public/platform/WebVector.h" | 101 #include "third_party/WebKit/public/platform/WebVector.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior | 137 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior |
137 #endif | 138 #endif |
138 | 139 |
139 #if BUILDFLAG(ENABLE_WEBRTC) | 140 #if BUILDFLAG(ENABLE_WEBRTC) |
140 #include "content/renderer/media/rtc_certificate_generator.h" | 141 #include "content/renderer/media/rtc_certificate_generator.h" |
141 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 142 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
142 #endif | 143 #endif |
143 | 144 |
144 using blink::Platform; | 145 using blink::Platform; |
145 using blink::WebAudioDevice; | 146 using blink::WebAudioDevice; |
| 147 using blink::WebAudioLatencyHint; |
146 using blink::WebBlobRegistry; | 148 using blink::WebBlobRegistry; |
147 using blink::WebCanvasCaptureHandler; | 149 using blink::WebCanvasCaptureHandler; |
148 using blink::WebDatabaseObserver; | 150 using blink::WebDatabaseObserver; |
149 using blink::WebFileInfo; | 151 using blink::WebFileInfo; |
150 using blink::WebFileSystem; | 152 using blink::WebFileSystem; |
151 using blink::WebGamepad; | 153 using blink::WebGamepad; |
152 using blink::WebGamepads; | 154 using blink::WebGamepads; |
153 using blink::WebIDBFactory; | 155 using blink::WebIDBFactory; |
154 using blink::WebImageCaptureFrameGrabber; | 156 using blink::WebImageCaptureFrameGrabber; |
155 using blink::WebMIDIAccessor; | 157 using blink::WebMIDIAccessor; |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 | 653 |
652 unsigned RendererBlinkPlatformImpl::audioHardwareOutputChannels() { | 654 unsigned RendererBlinkPlatformImpl::audioHardwareOutputChannels() { |
653 return GetAudioHardwareParams().channels(); | 655 return GetAudioHardwareParams().channels(); |
654 } | 656 } |
655 | 657 |
656 WebDatabaseObserver* RendererBlinkPlatformImpl::databaseObserver() { | 658 WebDatabaseObserver* RendererBlinkPlatformImpl::databaseObserver() { |
657 return web_database_observer_impl_.get(); | 659 return web_database_observer_impl_.get(); |
658 } | 660 } |
659 | 661 |
660 WebAudioDevice* RendererBlinkPlatformImpl::createAudioDevice( | 662 WebAudioDevice* RendererBlinkPlatformImpl::createAudioDevice( |
661 size_t buffer_size, | |
662 unsigned input_channels, | 663 unsigned input_channels, |
663 unsigned channels, | 664 unsigned channels, |
664 double sample_rate, | 665 const blink::WebAudioLatencyHint& latency_hint, |
665 WebAudioDevice::RenderCallback* callback, | 666 WebAudioDevice::RenderCallback* callback, |
666 const blink::WebString& input_device_id, | 667 const blink::WebString& input_device_id, |
667 const blink::WebSecurityOrigin& security_origin) { | 668 const blink::WebSecurityOrigin& security_origin) { |
668 // Use a mock for testing. | 669 // Use a mock for testing. |
669 blink::WebAudioDevice* mock_device = | 670 blink::WebAudioDevice* mock_device = |
670 GetContentClient()->renderer()->OverrideCreateAudioDevice(sample_rate); | 671 GetContentClient()->renderer()->OverrideCreateAudioDevice(); |
671 if (mock_device) | 672 if (mock_device) |
672 return mock_device; | 673 return mock_device; |
673 | 674 |
674 // The |channels| does not exactly identify the channel layout of the | 675 // The |channels| does not exactly identify the channel layout of the |
675 // device. The switch statement below assigns a best guess to the channel | 676 // device. The switch statement below assigns a best guess to the channel |
676 // layout based on number of channels. | 677 // layout based on number of channels. |
677 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED; | 678 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED; |
678 switch (channels) { | 679 switch (channels) { |
679 case 1: | 680 case 1: |
680 layout = media::CHANNEL_LAYOUT_MONO; | 681 layout = media::CHANNEL_LAYOUT_MONO; |
(...skipping 13 matching lines...) Expand all Loading... |
694 case 6: | 695 case 6: |
695 layout = media::CHANNEL_LAYOUT_5_1; | 696 layout = media::CHANNEL_LAYOUT_5_1; |
696 break; | 697 break; |
697 case 7: | 698 case 7: |
698 layout = media::CHANNEL_LAYOUT_7_0; | 699 layout = media::CHANNEL_LAYOUT_7_0; |
699 break; | 700 break; |
700 case 8: | 701 case 8: |
701 layout = media::CHANNEL_LAYOUT_7_1; | 702 layout = media::CHANNEL_LAYOUT_7_1; |
702 break; | 703 break; |
703 default: | 704 default: |
704 // If the layout is not supported (more than 9 channels), falls back to | 705 // TODO need to also pass 'channels' into RendererWebAudioDeviceImpl for |
705 // discrete mode. | 706 // CHANNEL_LAYOUT_DISCRETE |
706 layout = media::CHANNEL_LAYOUT_DISCRETE; | 707 NOTREACHED(); |
707 } | 708 } |
708 | 709 |
709 int session_id = 0; | 710 int session_id = 0; |
710 if (input_device_id.isNull() || | 711 if (input_device_id.isNull() || |
711 !base::StringToInt(base::UTF16ToUTF8( | 712 !base::StringToInt(base::UTF16ToUTF8( |
712 base::StringPiece16(input_device_id)), &session_id)) { | 713 base::StringPiece16(input_device_id)), &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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 return &trial_token_validator_; | 1295 return &trial_token_validator_; |
1301 } | 1296 } |
1302 | 1297 |
1303 void RendererBlinkPlatformImpl::workerContextCreated( | 1298 void RendererBlinkPlatformImpl::workerContextCreated( |
1304 const v8::Local<v8::Context>& worker) { | 1299 const v8::Local<v8::Context>& worker) { |
1305 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( | 1300 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( |
1306 worker); | 1301 worker); |
1307 } | 1302 } |
1308 | 1303 |
1309 } // namespace content | 1304 } // namespace content |
OLD | NEW |