OLD | NEW |
| (Empty) |
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 | |
5 #ifndef COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_ | |
6 #define COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/linked_ptr.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/threading/thread.h" | |
13 #include "build/build_config.h" | |
14 #include "media/audio/fake_audio_log_factory.h" | |
15 #include "media/base/audio_hardware_config.h" | |
16 #include "media/blink/url_index.h" | |
17 #include "media/mojo/interfaces/service_factory.mojom.h" | |
18 #include "mojo/shell/public/interfaces/service_provider.mojom.h" | |
19 | |
20 namespace base { | |
21 class SingleThreadTaskRunner; | |
22 } | |
23 | |
24 namespace blink { | |
25 class WebContentDecryptionModule; | |
26 class WebEncryptedMediaClient; | |
27 class WebMediaPlayer; | |
28 class WebLocalFrame; | |
29 class WebURL; | |
30 class WebMediaPlayerClient; | |
31 class WebMediaPlayerEncryptedMediaClient; | |
32 } | |
33 | |
34 namespace media { | |
35 class AudioManager; | |
36 class RestartableAudioRendererSink; | |
37 class CdmFactory; | |
38 class MediaPermission; | |
39 class UrlIndex; | |
40 class WebEncryptedMediaClientImpl; | |
41 } | |
42 | |
43 namespace mojo { | |
44 class Shell; | |
45 } | |
46 | |
47 namespace html_viewer { | |
48 | |
49 // Helper class used to create blink::WebMediaPlayer objects. | |
50 // This class stores the "global state" shared across all WebMediaPlayer | |
51 // instances. | |
52 class MediaFactory { | |
53 public: | |
54 MediaFactory( | |
55 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, | |
56 mojo::Shell* shell); | |
57 ~MediaFactory(); | |
58 | |
59 blink::WebMediaPlayer* CreateMediaPlayer( | |
60 blink::WebLocalFrame* frame, | |
61 const blink::WebURL& url, | |
62 blink::WebMediaPlayerClient* client, | |
63 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | |
64 blink::WebContentDecryptionModule* initial_cdm, | |
65 mojo::Shell* shell); | |
66 | |
67 blink::WebEncryptedMediaClient* GetEncryptedMediaClient(); | |
68 | |
69 private: | |
70 media::interfaces::ServiceFactory* GetMediaServiceFactory(); | |
71 media::MediaPermission* GetMediaPermission(); | |
72 media::CdmFactory* GetCdmFactory(); | |
73 | |
74 #if !defined(OS_ANDROID) | |
75 const media::AudioHardwareConfig& GetAudioHardwareConfig(); | |
76 scoped_refptr<media::RestartableAudioRendererSink> CreateAudioRendererSink(); | |
77 scoped_refptr<base::SingleThreadTaskRunner> GetMediaThreadTaskRunner(); | |
78 | |
79 base::Thread media_thread_; | |
80 media::FakeAudioLogFactory fake_audio_log_factory_; | |
81 scoped_ptr<media::AudioManager> audio_manager_; | |
82 media::AudioHardwareConfig audio_hardware_config_; | |
83 #endif | |
84 | |
85 const bool enable_mojo_media_renderer_; | |
86 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | |
87 mojo::Shell* shell_; | |
88 | |
89 // Lazily initialized objects. | |
90 media::interfaces::ServiceFactoryPtr media_service_factory_; | |
91 scoped_ptr<media::WebEncryptedMediaClientImpl> web_encrypted_media_client_; | |
92 scoped_ptr<media::MediaPermission> media_permission_; | |
93 scoped_ptr<media::CdmFactory> cdm_factory_; | |
94 | |
95 // Media resource cache, lazily initialized. | |
96 linked_ptr<media::UrlIndex> url_index_; | |
97 | |
98 DISALLOW_COPY_AND_ASSIGN(MediaFactory); | |
99 }; | |
100 | |
101 } // namespace html_viewer | |
102 | |
103 #endif // COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_ | |
OLD | NEW |