blob: dc486f4f3a21a213753a713f0887e29284514de9 [file] [log] [blame]
acolwell50b12542014-09-12 23:18:141// 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
xhwang658a6f12015-05-30 01:25:085#ifndef COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_
6#define COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_
acolwell50b12542014-09-12 23:18:147
8#include "base/macros.h"
hubbe5f0ad43b2015-12-14 20:57:269#include "base/memory/linked_ptr.h"
acolwell50b12542014-09-12 23:18:1410#include "base/memory/ref_counted.h"
11#include "base/memory/scoped_ptr.h"
12#include "base/threading/thread.h"
avi26062922015-12-26 00:14:1813#include "build/build_config.h"
acolwell50b12542014-09-12 23:18:1414#include "media/audio/fake_audio_log_factory.h"
15#include "media/base/audio_hardware_config.h"
hubbe5f0ad43b2015-12-14 20:57:2616#include "media/blink/url_index.h"
xhwangc0299ae32015-07-21 23:39:5017#include "media/mojo/interfaces/service_factory.mojom.h"
ben273c1e32016-01-12 02:44:0818#include "mojo/shell/public/interfaces/service_provider.mojom.h"
acolwell50b12542014-09-12 23:18:1419
20namespace base {
21class SingleThreadTaskRunner;
22}
23
24namespace blink {
xhwangf549b3d2014-12-23 18:44:0325class WebContentDecryptionModule;
xhwang658a6f12015-05-30 01:25:0826class WebEncryptedMediaClient;
acolwell50b12542014-09-12 23:18:1427class WebMediaPlayer;
28class WebLocalFrame;
29class WebURL;
30class WebMediaPlayerClient;
srirama.m26f864d02015-07-14 05:21:4631class WebMediaPlayerEncryptedMediaClient;
acolwell50b12542014-09-12 23:18:1432}
33
34namespace media {
35class AudioManager;
sandersdf0f22332015-11-09 21:46:4936class RestartableAudioRendererSink;
xhwangd7180832015-04-03 05:38:1537class CdmFactory;
xhwang60b430a2015-02-01 05:20:4638class MediaPermission;
hubbe5f0ad43b2015-12-14 20:57:2639class UrlIndex;
xhwang658a6f12015-05-30 01:25:0840class WebEncryptedMediaClientImpl;
acolwell50b12542014-09-12 23:18:1441}
42
43namespace mojo {
xhwang065b54b2015-06-03 22:25:5544class ServiceProvider;
xhwangf94a634d2014-10-22 22:07:2745class Shell;
davemoore1157ffe2014-12-19 00:09:3646}
47
48namespace html_viewer {
xhwangf94a634d2014-10-22 22:07:2749
acolwell50b12542014-09-12 23:18:1450// Helper class used to create blink::WebMediaPlayer objects.
51// This class stores the "global state" shared across all WebMediaPlayer
52// instances.
xhwang658a6f12015-05-30 01:25:0853class MediaFactory {
acolwell50b12542014-09-12 23:18:1454 public:
xhwang065b54b2015-06-03 22:25:5555 MediaFactory(
56 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
57 mojo::Shell* shell);
xhwang658a6f12015-05-30 01:25:0858 ~MediaFactory();
acolwell50b12542014-09-12 23:18:1459
xhwangf549b3d2014-12-23 18:44:0360 blink::WebMediaPlayer* CreateMediaPlayer(
61 blink::WebLocalFrame* frame,
62 const blink::WebURL& url,
63 blink::WebMediaPlayerClient* client,
srirama.m26f864d02015-07-14 05:21:4664 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client,
xhwangf549b3d2014-12-23 18:44:0365 blink::WebContentDecryptionModule* initial_cdm,
66 mojo::Shell* shell);
acolwell50b12542014-09-12 23:18:1467
xhwang658a6f12015-05-30 01:25:0868 blink::WebEncryptedMediaClient* GetEncryptedMediaClient();
69
acolwell50b12542014-09-12 23:18:1470 private:
xhwangc0299ae32015-07-21 23:39:5071 media::interfaces::ServiceFactory* GetMediaServiceFactory();
xhwang658a6f12015-05-30 01:25:0872 media::MediaPermission* GetMediaPermission();
73 media::CdmFactory* GetCdmFactory();
74
75#if !defined(OS_ANDROID)
acolwell50b12542014-09-12 23:18:1476 const media::AudioHardwareConfig& GetAudioHardwareConfig();
sandersdf0f22332015-11-09 21:46:4977 scoped_refptr<media::RestartableAudioRendererSink> CreateAudioRendererSink();
acolwell50b12542014-09-12 23:18:1478 scoped_refptr<base::SingleThreadTaskRunner> GetMediaThreadTaskRunner();
79
acolwell50b12542014-09-12 23:18:1480 base::Thread media_thread_;
81 media::FakeAudioLogFactory fake_audio_log_factory_;
82 scoped_ptr<media::AudioManager> audio_manager_;
83 media::AudioHardwareConfig audio_hardware_config_;
xhwang658a6f12015-05-30 01:25:0884#endif
acolwell50b12542014-09-12 23:18:1485
xhwang658a6f12015-05-30 01:25:0886 const bool enable_mojo_media_renderer_;
87 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
xhwang065b54b2015-06-03 22:25:5588 mojo::Shell* shell_;
xhwang658a6f12015-05-30 01:25:0889
90 // Lazily initialized objects.
xhwangc0299ae32015-07-21 23:39:5091 media::interfaces::ServiceFactoryPtr media_service_factory_;
xhwang658a6f12015-05-30 01:25:0892 scoped_ptr<media::WebEncryptedMediaClientImpl> web_encrypted_media_client_;
93 scoped_ptr<media::MediaPermission> media_permission_;
94 scoped_ptr<media::CdmFactory> cdm_factory_;
95
hubbe5f0ad43b2015-12-14 20:57:2696 // Media resource cache, lazily initialized.
97 linked_ptr<media::UrlIndex> url_index_;
98
xhwang658a6f12015-05-30 01:25:0899 DISALLOW_COPY_AND_ASSIGN(MediaFactory);
acolwell50b12542014-09-12 23:18:14100};
101
davemoore1157ffe2014-12-19 00:09:36102} // namespace html_viewer
acolwell50b12542014-09-12 23:18:14103
xhwang658a6f12015-05-30 01:25:08104#endif // COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_