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

Side by Side Diff: media/base/renderer_factory_selector.h

Issue 2826883002: Rename AdaptiveRendererFactory (Closed)
Patch Set: Addressed comments Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | media/base/renderer_factory_selector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 QueryIsRemotingActiveCB = 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 query whether we are currently remoting, and if we
53 // should temporarily use the COURIER factory.
54 void SetQueryIsRemotingActiveCB(
55 QueryIsRemotingActiveCB query_is_remoting_active_cb);
56
49 private: 57 private:
50 void UpdateCurrentFactory();
51
52 bool use_media_player_ = false; 58 bool use_media_player_ = false;
53 59
54 bool current_factory_needs_update_ = true; 60 QueryIsRemotingActiveCB query_is_remoting_active_cb_;
55 RendererFactory* current_factory_ = nullptr;
56 61
57 base::Optional<FactoryType> base_factory_type_; 62 base::Optional<FactoryType> base_factory_type_;
58 std::unique_ptr<RendererFactory> factories_[FACTORY_TYPE_MAX + 1]; 63 std::unique_ptr<RendererFactory> factories_[FACTORY_TYPE_MAX + 1];
59 DISALLOW_COPY_AND_ASSIGN(RendererFactorySelector); 64 DISALLOW_COPY_AND_ASSIGN(RendererFactorySelector);
60 }; 65 };
61 66
62 } // namespace media 67 } // namespace media
63 68
64 #endif // MEDIA_BASE_RENDERER_FACTORY_H_ 69 #endif // MEDIA_BASE_RENDERER_FACTORY_H_
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | media/base/renderer_factory_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698