Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: media/base/renderer_factory_selector.h

Issue 2711153006: Add RendererFactorySelector (Closed)
Patch Set: Added UTs Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/renderer_factory_selector.h
diff --git a/media/base/renderer_factory_selector.h b/media/base/renderer_factory_selector.h
new file mode 100644
index 0000000000000000000000000000000000000000..cc96284e0adf578e7942c8d6c664f5e0c3d5d5ba
--- /dev/null
+++ b/media/base/renderer_factory_selector.h
@@ -0,0 +1,47 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_RENDERER_FACTORY_SELECTOR_H_
+#define MEDIA_BASE_RENDERER_FACTORY_SELECTOR_H_
+
+#include "base/containers/flat_map.h"
+#include "media/base/renderer_factory.h"
+
+namespace media {
+
+// RendererFactorySelector owns RendererFactory instances used within WMPI.
+// Its purpose is to aggregate the signals and centralize the logic behind
+// choosing which RendererFactory should be used when creating a new Renderer.
+class MEDIA_EXPORT RendererFactorySelector {
+ public:
+ enum FactoryType {
+ DEFAULT, // DefaultRendererFactory.
+ MOJO, // MojoRendererFactory.
+ MEDIA_PLAYER, // MediaPlayerRendererClientFactory.
+ ADAPTIVE, // AdaptiveRendererFactory.
+ UNKNOWN,
+ };
+
+ RendererFactorySelector();
+ ~RendererFactorySelector();
+
+ // NOTE: There should be at most one factory per factory type.
+ void AddFactory(FactoryType type, std::unique_ptr<RendererFactory> factory);
+
+ // Sets the "default" factory to be returned in the absence explicit signals
+ // indicating that another factory type should be selected instead.
+ void SetBaseFactoryType(FactoryType type);
+
+ // Note: This only returns the base factory type at the moment.
+ RendererFactory* GetCurrentFactory();
+
+ private:
+ FactoryType base_factory_type_ = FactoryType::UNKNOWN;
+ base::flat_map<FactoryType, std::unique_ptr<RendererFactory>> factories_;
+ DISALLOW_COPY_AND_ASSIGN(RendererFactorySelector);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_RENDERER_FACTORY_H_

Powered by Google App Engine
This is Rietveld 408576698