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.
5 #ifndef COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_
6 #define COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/thread.h"
12 #include "media/audio/fake_audio_log_factory.h"
13 #include "media/base/audio_hardware_config.h"
14 #include "mojo/application/public/interfaces/service_provider.mojom.h"
17 class SingleThreadTaskRunner
;
21 class WebContentDecryptionModule
;
22 class WebEncryptedMediaClient
;
26 class WebMediaPlayerClient
;
31 class AudioRendererSink
;
33 class MediaPermission
;
34 class WebEncryptedMediaClientImpl
;
38 class ServiceProvider
;
42 namespace html_viewer
{
44 // Helper class used to create blink::WebMediaPlayer objects.
45 // This class stores the "global state" shared across all WebMediaPlayer
50 const scoped_refptr
<base::SingleThreadTaskRunner
>& compositor_task_runner
,
54 blink::WebMediaPlayer
* CreateMediaPlayer(
55 blink::WebLocalFrame
* frame
,
56 const blink::WebURL
& url
,
57 blink::WebMediaPlayerClient
* client
,
58 blink::WebContentDecryptionModule
* initial_cdm
,
61 blink::WebEncryptedMediaClient
* GetEncryptedMediaClient();
64 mojo::ServiceProvider
* GetMediaServiceProvider();
65 media::MediaPermission
* GetMediaPermission();
66 media::CdmFactory
* GetCdmFactory();
68 #if !defined(OS_ANDROID)
69 const media::AudioHardwareConfig
& GetAudioHardwareConfig();
70 scoped_refptr
<media::AudioRendererSink
> CreateAudioRendererSink();
71 scoped_refptr
<base::SingleThreadTaskRunner
> GetMediaThreadTaskRunner();
73 base::Thread media_thread_
;
74 media::FakeAudioLogFactory fake_audio_log_factory_
;
75 scoped_ptr
<media::AudioManager
> audio_manager_
;
76 media::AudioHardwareConfig audio_hardware_config_
;
79 const bool enable_mojo_media_renderer_
;
80 scoped_refptr
<base::SingleThreadTaskRunner
> compositor_task_runner_
;
83 // Lazily initialized objects.
84 mojo::ServiceProviderPtr media_service_provider_
;
85 scoped_ptr
<media::WebEncryptedMediaClientImpl
> web_encrypted_media_client_
;
86 scoped_ptr
<media::MediaPermission
> media_permission_
;
87 scoped_ptr
<media::CdmFactory
> cdm_factory_
;
89 DISALLOW_COPY_AND_ASSIGN(MediaFactory
);
92 } // namespace html_viewer
94 #endif // COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_