Chromium Code Reviews| 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/optional.h" | 9 #include "base/optional.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 FACTORY_TYPE_MAX = ADAPTIVE, | 26 FACTORY_TYPE_MAX = COURIER, |
| 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 base factory to be returned, when there are no signals telling us | 35 // Sets the base factory to be returned, when there are no signals telling us |
| 33 // to select any specific factory. | 36 // to select any specific factory. |
| 34 // NOTE: |type| can be different than FactoryType::DEFAULT. DEFAULT is used to | 37 // NOTE: |type| can be different than FactoryType::DEFAULT. DEFAULT is used to |
| 35 // identify the DefaultRendererFactory, not to indicate that a factory should | 38 // identify the DefaultRendererFactory, not to indicate that a factory should |
| 36 // be used by default. | 39 // be used by default. |
| 37 void SetBaseFactoryType(FactoryType type); | 40 void SetBaseFactoryType(FactoryType type); |
| 38 | 41 |
| 39 // Updates |current_factory_| if necessary, and returns its value. | 42 // Updates |current_factory_| if necessary, and returns its value. |
| 40 // NOTE: SetBaseFactoryType() must be called before calling this method. | 43 // NOTE: SetBaseFactoryType() must be called before calling this method. |
| 41 RendererFactory* GetCurrentFactory(); | 44 RendererFactory* GetCurrentFactory(); |
| 42 | 45 |
| 43 #if defined(OS_ANDROID) | 46 #if defined(OS_ANDROID) |
| 44 // Sets whether we should be using the MEDIA_PLAYER factory instead of the | 47 // Sets whether we should be using the MEDIA_PLAYER factory instead of the |
| 45 // base factory. | 48 // base factory. |
| 46 void SetUseMediaPlayer(bool use_media_player); | 49 void SetUseMediaPlayer(bool use_media_player); |
| 47 #endif | 50 #endif |
| 48 | 51 |
| 52 // Sets the callback to check whether we should be temporarily use the COURIER | |
| 53 // factory. | |
| 54 void SetUseCourierCB(UseCourierCB use_courier_cb); | |
| 55 | |
| 49 private: | 56 private: |
| 50 void UpdateCurrentFactory(); | 57 void UpdateCurrentFactory(); |
| 51 | 58 |
| 52 bool use_media_player_ = false; | 59 bool use_media_player_ = false; |
| 53 | 60 |
| 61 UseCourierCB use_courier_cb_; | |
|
miu
2017/05/02 22:40:04
nit: When I see this used in the code, it feels li
tguilbert
2017/05/03 01:34:25
I am using QueryIsRemotingActiveCB for now. I also
| |
| 62 | |
| 54 bool current_factory_needs_update_ = true; | 63 bool current_factory_needs_update_ = true; |
|
miu
2017/05/02 22:40:04
Can we simplify by getting rid of |current_factory
tguilbert
2017/05/03 01:34:25
You are right, this was probably excessive in the
| |
| 55 RendererFactory* current_factory_ = nullptr; | 64 RendererFactory* current_factory_ = nullptr; |
| 56 | 65 |
| 57 base::Optional<FactoryType> base_factory_type_; | 66 base::Optional<FactoryType> base_factory_type_; |
| 58 std::unique_ptr<RendererFactory> factories_[FACTORY_TYPE_MAX + 1]; | 67 std::unique_ptr<RendererFactory> factories_[FACTORY_TYPE_MAX + 1]; |
| 59 DISALLOW_COPY_AND_ASSIGN(RendererFactorySelector); | 68 DISALLOW_COPY_AND_ASSIGN(RendererFactorySelector); |
| 60 }; | 69 }; |
| 61 | 70 |
| 62 } // namespace media | 71 } // namespace media |
| 63 | 72 |
| 64 #endif // MEDIA_BASE_RENDERER_FACTORY_H_ | 73 #endif // MEDIA_BASE_RENDERER_FACTORY_H_ |
| OLD | NEW |