acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 5 | #ifndef COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_ |
| 6 | #define COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_ |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 7 | |
| 8 | #include "base/macros.h" |
hubbe | 5f0ad43b | 2015-12-14 20:57:26 | [diff] [blame] | 9 | #include "base/memory/linked_ptr.h" |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
| 11 | #include "base/memory/scoped_ptr.h" |
| 12 | #include "base/threading/thread.h" |
avi | 2606292 | 2015-12-26 00:14:18 | [diff] [blame] | 13 | #include "build/build_config.h" |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 14 | #include "media/audio/fake_audio_log_factory.h" |
| 15 | #include "media/base/audio_hardware_config.h" |
hubbe | 5f0ad43b | 2015-12-14 20:57:26 | [diff] [blame] | 16 | #include "media/blink/url_index.h" |
xhwang | c0299ae3 | 2015-07-21 23:39:50 | [diff] [blame] | 17 | #include "media/mojo/interfaces/service_factory.mojom.h" |
ben | 273c1e3 | 2016-01-12 02:44:08 | [diff] [blame] | 18 | #include "mojo/shell/public/interfaces/service_provider.mojom.h" |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 19 | |
| 20 | namespace base { |
| 21 | class SingleThreadTaskRunner; |
| 22 | } |
| 23 | |
| 24 | namespace blink { |
xhwang | f549b3d | 2014-12-23 18:44:03 | [diff] [blame] | 25 | class WebContentDecryptionModule; |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 26 | class WebEncryptedMediaClient; |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 27 | class WebMediaPlayer; |
| 28 | class WebLocalFrame; |
| 29 | class WebURL; |
| 30 | class WebMediaPlayerClient; |
srirama.m | 26f864d0 | 2015-07-14 05:21:46 | [diff] [blame] | 31 | class WebMediaPlayerEncryptedMediaClient; |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | namespace media { |
| 35 | class AudioManager; |
sandersd | f0f2233 | 2015-11-09 21:46:49 | [diff] [blame] | 36 | class RestartableAudioRendererSink; |
xhwang | d718083 | 2015-04-03 05:38:15 | [diff] [blame] | 37 | class CdmFactory; |
xhwang | 60b430a | 2015-02-01 05:20:46 | [diff] [blame] | 38 | class MediaPermission; |
hubbe | 5f0ad43b | 2015-12-14 20:57:26 | [diff] [blame] | 39 | class UrlIndex; |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 40 | class WebEncryptedMediaClientImpl; |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | namespace mojo { |
xhwang | 065b54b | 2015-06-03 22:25:55 | [diff] [blame] | 44 | class ServiceProvider; |
xhwang | f94a634d | 2014-10-22 22:07:27 | [diff] [blame] | 45 | class Shell; |
davemoore | 1157ffe | 2014-12-19 00:09:36 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | namespace html_viewer { |
xhwang | f94a634d | 2014-10-22 22:07:27 | [diff] [blame] | 49 | |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 50 | // Helper class used to create blink::WebMediaPlayer objects. |
| 51 | // This class stores the "global state" shared across all WebMediaPlayer |
| 52 | // instances. |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 53 | class MediaFactory { |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 54 | public: |
xhwang | 065b54b | 2015-06-03 22:25:55 | [diff] [blame] | 55 | MediaFactory( |
| 56 | const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, |
| 57 | mojo::Shell* shell); |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 58 | ~MediaFactory(); |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 59 | |
xhwang | f549b3d | 2014-12-23 18:44:03 | [diff] [blame] | 60 | blink::WebMediaPlayer* CreateMediaPlayer( |
| 61 | blink::WebLocalFrame* frame, |
| 62 | const blink::WebURL& url, |
| 63 | blink::WebMediaPlayerClient* client, |
srirama.m | 26f864d0 | 2015-07-14 05:21:46 | [diff] [blame] | 64 | blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
xhwang | f549b3d | 2014-12-23 18:44:03 | [diff] [blame] | 65 | blink::WebContentDecryptionModule* initial_cdm, |
| 66 | mojo::Shell* shell); |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 67 | |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 68 | blink::WebEncryptedMediaClient* GetEncryptedMediaClient(); |
| 69 | |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 70 | private: |
xhwang | c0299ae3 | 2015-07-21 23:39:50 | [diff] [blame] | 71 | media::interfaces::ServiceFactory* GetMediaServiceFactory(); |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 72 | media::MediaPermission* GetMediaPermission(); |
| 73 | media::CdmFactory* GetCdmFactory(); |
| 74 | |
| 75 | #if !defined(OS_ANDROID) |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 76 | const media::AudioHardwareConfig& GetAudioHardwareConfig(); |
sandersd | f0f2233 | 2015-11-09 21:46:49 | [diff] [blame] | 77 | scoped_refptr<media::RestartableAudioRendererSink> CreateAudioRendererSink(); |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 78 | scoped_refptr<base::SingleThreadTaskRunner> GetMediaThreadTaskRunner(); |
| 79 | |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 80 | base::Thread media_thread_; |
| 81 | media::FakeAudioLogFactory fake_audio_log_factory_; |
| 82 | scoped_ptr<media::AudioManager> audio_manager_; |
| 83 | media::AudioHardwareConfig audio_hardware_config_; |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 84 | #endif |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 85 | |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 86 | const bool enable_mojo_media_renderer_; |
| 87 | scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
xhwang | 065b54b | 2015-06-03 22:25:55 | [diff] [blame] | 88 | mojo::Shell* shell_; |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 89 | |
| 90 | // Lazily initialized objects. |
xhwang | c0299ae3 | 2015-07-21 23:39:50 | [diff] [blame] | 91 | media::interfaces::ServiceFactoryPtr media_service_factory_; |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 92 | scoped_ptr<media::WebEncryptedMediaClientImpl> web_encrypted_media_client_; |
| 93 | scoped_ptr<media::MediaPermission> media_permission_; |
| 94 | scoped_ptr<media::CdmFactory> cdm_factory_; |
| 95 | |
hubbe | 5f0ad43b | 2015-12-14 20:57:26 | [diff] [blame] | 96 | // Media resource cache, lazily initialized. |
| 97 | linked_ptr<media::UrlIndex> url_index_; |
| 98 | |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 99 | DISALLOW_COPY_AND_ASSIGN(MediaFactory); |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 100 | }; |
| 101 | |
davemoore | 1157ffe | 2014-12-19 00:09:36 | [diff] [blame] | 102 | } // namespace html_viewer |
acolwell | 50b1254 | 2014-09-12 23:18:14 | [diff] [blame] | 103 | |
xhwang | 658a6f1 | 2015-05-30 01:25:08 | [diff] [blame] | 104 | #endif // COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_ |