OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_BASE_RENDERER_FACTORY_SELECTOR_H_ |
| 6 #define MEDIA_BASE_RENDERER_FACTORY_SELECTOR_H_ |
| 7 |
| 8 #include "base/optional.h" |
| 9 #include "media/base/renderer_factory.h" |
| 10 |
| 11 namespace media { |
| 12 |
| 13 // RendererFactorySelector owns RendererFactory instances used within WMPI. |
| 14 // 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 class MEDIA_EXPORT RendererFactorySelector { |
| 17 public: |
| 18 enum FactoryType { |
| 19 DEFAULT, // DefaultRendererFactory. |
| 20 MOJO, // MojoRendererFactory. |
| 21 MEDIA_PLAYER, // MediaPlayerRendererClientFactory. |
| 22 ADAPTIVE, // AdaptiveRendererFactory. |
| 23 FACTORY_TYPE_MAX = ADAPTIVE, |
| 24 }; |
| 25 |
| 26 RendererFactorySelector(); |
| 27 ~RendererFactorySelector(); |
| 28 |
| 29 // NOTE: There should be at most one factory per factory type. |
| 30 void AddFactory(FactoryType type, std::unique_ptr<RendererFactory> factory); |
| 31 |
| 32 // Sets the base factory to be returned, when there are no signals telling us |
| 33 // to select any specific factory. |
| 34 // NOTE: |type| can be different than FactoryType::DEFAULT. DEFAULT is used to |
| 35 // identify the DefaultRendererFactory, not to indicate that a factory should |
| 36 // be used by default. |
| 37 void SetBaseFactoryType(FactoryType type); |
| 38 |
| 39 // SetBaseFactoryType() must be called before calling this method. |
| 40 // NOTE: This only returns the base factory type at the moment. |
| 41 RendererFactory* GetCurrentFactory(); |
| 42 |
| 43 private: |
| 44 base::Optional<FactoryType> base_factory_type_; |
| 45 std::unique_ptr<RendererFactory> factories_[FACTORY_TYPE_MAX + 1]; |
| 46 DISALLOW_COPY_AND_ASSIGN(RendererFactorySelector); |
| 47 }; |
| 48 |
| 49 } // namespace media |
| 50 |
| 51 #endif // MEDIA_BASE_RENDERER_FACTORY_H_ |
OLD | NEW |