OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_BASE_RENDERER_FACTORY_SELECTOR_H_ | 5 #ifndef MEDIA_BASE_RENDERER_FACTORY_SELECTOR_H_ |
6 #define MEDIA_BASE_RENDERER_FACTORY_SELECTOR_H_ | 6 #define MEDIA_BASE_RENDERER_FACTORY_SELECTOR_H_ |
7 | 7 |
| 8 #include "base/callback.h" |
8 #include "base/containers/flat_map.h" | 9 #include "base/containers/flat_map.h" |
9 #include "media/base/renderer_factory.h" | 10 #include "media/base/renderer_factory.h" |
10 | 11 |
11 namespace media { | 12 namespace media { |
12 | 13 |
13 // RendererFactorySelector owns RendererFactory instances used within WMPI. | 14 // RendererFactorySelector owns RendererFactory instances used within WMPI. |
14 // Its purpose is to aggregate the signals and centralize the logic behind | 15 // Its purpose is to aggregate the signals and centralize the logic behind |
15 // choosing which RendererFactory should be used when creating a new Renderer. | 16 // choosing which RendererFactory should be used when creating a new Renderer. |
16 class MEDIA_EXPORT RendererFactorySelector { | 17 class MEDIA_EXPORT RendererFactorySelector { |
17 public: | 18 public: |
| 19 using UseCourierCB = base::Callback<bool()>; |
| 20 |
18 enum FactoryType { | 21 enum FactoryType { |
19 DEFAULT, // DefaultRendererFactory. | 22 DEFAULT, // DefaultRendererFactory. |
20 MOJO, // MojoRendererFactory. | 23 MOJO, // MojoRendererFactory. |
21 MEDIA_PLAYER, // MediaPlayerRendererClientFactory. | 24 MEDIA_PLAYER, // MediaPlayerRendererClientFactory. |
22 ADAPTIVE, // AdaptiveRendererFactory. | 25 COURIER, // CourierRendererFactory. |
23 UNKNOWN, | 26 UNKNOWN, |
24 }; | 27 }; |
25 | 28 |
26 RendererFactorySelector(); | 29 RendererFactorySelector(); |
27 ~RendererFactorySelector(); | 30 ~RendererFactorySelector(); |
28 | 31 |
29 // NOTE: There should be at most one factory per factory type. | 32 // NOTE: There should be at most one factory per factory type. |
30 void AddFactory(FactoryType type, std::unique_ptr<RendererFactory> factory); | 33 void AddFactory(FactoryType type, std::unique_ptr<RendererFactory> factory); |
31 | 34 |
32 // Sets the "default" factory to be returned in the absence explicit signals | 35 // Sets the "default" factory to be returned in the absence explicit signals |
33 // indicating that another factory type should be selected instead. | 36 // indicating that another factory type should be selected instead. |
34 void SetBaseFactoryType(FactoryType type); | 37 void SetBaseFactoryType(FactoryType type); |
35 | 38 |
36 // Updates |current_factory_| if necessary, and returns its value. | 39 // Updates |current_factory_| if necessary, and returns its value. |
37 RendererFactory* GetCurrentFactory(); | 40 RendererFactory* GetCurrentFactory(); |
38 | 41 |
39 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
40 // Sets whether we should be using the MEDIA_PLAYER factory instead of the | 43 // Sets whether we should be using the MEDIA_PLAYER factory instead of the |
41 // base factory. | 44 // base factory. |
42 void SetUseMediaPlayer(bool use_media_player); | 45 void SetUseMediaPlayer(bool use_media_player); |
43 #endif | 46 #endif |
44 | 47 |
| 48 // Sets the callback to check whether we should be temporarily use the COURIER |
| 49 // factory. |
| 50 void SetUseCourierCB(UseCourierCB use_courier_cb); |
| 51 |
45 private: | 52 private: |
46 void UpdateCurrentFactory(); | 53 void UpdateCurrentFactory(); |
47 | 54 |
48 bool use_media_player_ = false; | 55 bool use_media_player_ = false; |
49 | 56 |
| 57 UseCourierCB use_courier_cb_; |
| 58 |
50 bool current_factory_needs_update_ = true; | 59 bool current_factory_needs_update_ = true; |
51 RendererFactory* current_factory_ = nullptr; | 60 RendererFactory* current_factory_ = nullptr; |
52 | 61 |
53 FactoryType base_factory_type_ = FactoryType::UNKNOWN; | 62 FactoryType base_factory_type_ = FactoryType::UNKNOWN; |
54 base::flat_map<FactoryType, std::unique_ptr<RendererFactory>> factories_; | 63 base::flat_map<FactoryType, std::unique_ptr<RendererFactory>> factories_; |
55 DISALLOW_COPY_AND_ASSIGN(RendererFactorySelector); | 64 DISALLOW_COPY_AND_ASSIGN(RendererFactorySelector); |
56 }; | 65 }; |
57 | 66 |
58 } // namespace media | 67 } // namespace media |
59 | 68 |
60 #endif // MEDIA_BASE_RENDERER_FACTORY_H_ | 69 #endif // MEDIA_BASE_RENDERER_FACTORY_H_ |
OLD | NEW |