• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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 MEDIA_BLINK_WEBMEDIAPLAYER_PARAMS_H_
6 #define MEDIA_BLINK_WEBMEDIAPLAYER_PARAMS_H_
7 
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "media/base/media_export.h"
11 #include "media/blink/encrypted_media_player_support.h"
12 
13 namespace base {
14 class SingleThreadTaskRunner;
15 }
16 
17 namespace blink {
18 class WebMediaPlayerClient;
19 }
20 
21 namespace media {
22 class AudioHardwareConfig;
23 class AudioRendererSink;
24 class GpuVideoAcceleratorFactories;
25 class MediaLog;
26 
27 // Holds parameters for constructing WebMediaPlayerImpl without having
28 // to plumb arguments through various abstraction layers.
29 class MEDIA_EXPORT WebMediaPlayerParams {
30  public:
31   // Callback used to create EncryptedMediaPlayerSupport instances. This
32   // callback must always return a valid EncryptedMediaPlayerSupport object.
33   typedef base::Callback<scoped_ptr<EncryptedMediaPlayerSupport>(
34       blink::WebMediaPlayerClient*)> EncryptedMediaPlayerSupportCreateCB;
35   typedef base::Callback<void(const base::Closure&)> DeferLoadCB;
36 
37   // |defer_load_cb|, |audio_renderer_sink|, and |compositor_task_runner| may be
38   // null.
39   WebMediaPlayerParams(
40       const DeferLoadCB& defer_load_cb,
41       const scoped_refptr<AudioRendererSink>& audio_renderer_sink,
42       const AudioHardwareConfig& audio_hardware_config,
43       const scoped_refptr<MediaLog>& media_log,
44       const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories,
45       const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
46       const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
47       const EncryptedMediaPlayerSupportCreateCB&
48           encrypted_media_player_support_cb,
49       blink::WebContentDecryptionModule* initial_cdm);
50 
51   ~WebMediaPlayerParams();
52 
defer_load_cb()53   base::Callback<void(const base::Closure&)> defer_load_cb() const {
54     return defer_load_cb_;
55   }
56 
audio_renderer_sink()57   const scoped_refptr<AudioRendererSink>& audio_renderer_sink() const {
58     return audio_renderer_sink_;
59   }
60 
audio_hardware_config()61   const AudioHardwareConfig& audio_hardware_config() const {
62     return audio_hardware_config_;
63   }
64 
media_log()65   const scoped_refptr<MediaLog>& media_log() const {
66     return media_log_;
67   }
68 
69   const scoped_refptr<GpuVideoAcceleratorFactories>&
gpu_factories()70   gpu_factories() const {
71     return gpu_factories_;
72   }
73 
74   const scoped_refptr<base::SingleThreadTaskRunner>&
media_task_runner()75   media_task_runner() const {
76     return media_task_runner_;
77   }
78 
79   const scoped_refptr<base::SingleThreadTaskRunner>&
compositor_task_runner()80   compositor_task_runner() const {
81     return compositor_task_runner_;
82   }
83 
84   scoped_ptr<EncryptedMediaPlayerSupport>
85   CreateEncryptedMediaPlayerSupport(blink::WebMediaPlayerClient* client) const;
86 
87  private:
88   base::Callback<void(const base::Closure&)> defer_load_cb_;
89   scoped_refptr<AudioRendererSink> audio_renderer_sink_;
90   const AudioHardwareConfig& audio_hardware_config_;
91   scoped_refptr<MediaLog> media_log_;
92   scoped_refptr<GpuVideoAcceleratorFactories> gpu_factories_;
93   scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
94   scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
95   EncryptedMediaPlayerSupportCreateCB encrypted_media_player_support_cb_;
96   blink::WebContentDecryptionModule* initial_cdm_;
97 
98   DISALLOW_IMPLICIT_CONSTRUCTORS(WebMediaPlayerParams);
99 };
100 
101 }  // namespace media
102 
103 #endif  // MEDIA_BLINK_WEBMEDIAPLAYER_PARAMS_H_
104