forked from youtube/cobalt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maximum_player_configuration_explorer.h
93 lines (78 loc) · 3.49 KB
/
maximum_player_configuration_explorer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 2023 The Cobalt Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef STARBOARD_NPLB_MAXIMUM_PLAYER_CONFIGURATION_EXPLORER_H_
#define STARBOARD_NPLB_MAXIMUM_PLAYER_CONFIGURATION_EXPLORER_H_
#include <set>
#include <string>
#include <vector>
#include "starboard/drm.h"
#include "starboard/nplb/player_test_util.h"
#include "starboard/player.h"
#include "starboard/shared/starboard/media/media_util.h"
#include "starboard/testing/fake_graphics_context_provider.h"
namespace starboard {
namespace nplb {
typedef const std::function<bool(const std::vector<int>&)> PosetSearchFunctor;
typedef std::vector<SbPlayerTestConfig> SbPlayerMultiplePlayerTestConfig;
// Expose the two functions below for testing.
bool PosetContainedByMaxElementsSet(
const std::set<std::vector<int>>& max_elements_set,
const std::vector<int>& v);
std::set<std::vector<int>> SearchPosetMaximalElementsDFS(
int resource_types,
int max_instances_per_resource,
const PosetSearchFunctor& test_functor);
// The MaximumPlayerConfigurationExplorer is to get the maximum feasible
// configurations for a group of players that the platform can create and run
// concurrently.
class MaximumPlayerConfigurationExplorer {
public:
// Note that with the initial implementation, the audio config is ignored.
MaximumPlayerConfigurationExplorer(
const std::vector<SbPlayerTestConfig>& player_configs,
int max_instances_per_config,
int max_total_instances,
testing::FakeGraphicsContextProvider* fake_graphics_context_provider);
~MaximumPlayerConfigurationExplorer();
std::vector<SbPlayerMultiplePlayerTestConfig> CalculateMaxTestConfigs();
private:
struct PlayerInstance {
PlayerInstance()
: config(nullptr, nullptr, kSbPlayerOutputModeInvalid, "") {}
PlayerInstance(SbPlayer player,
SbDrmSystem drm_system,
const SbPlayerTestConfig& config)
: player(player), drm_system(drm_system), config(config) {}
SbPlayer player = kSbPlayerInvalid;
SbDrmSystem drm_system = kSbDrmSystemInvalid;
SbPlayerTestConfig config;
};
// Test whether the system can support this particular configuration of
// players by creating it.
bool IsConfigCreatable(const std::vector<int>& configs_to_create);
PlayerInstance CreatePlayerInstance(const SbPlayerTestConfig& config);
void DestroyPlayerInstance(const PlayerInstance& instance);
const std::vector<SbPlayerTestConfig> player_configs_;
const int max_instances_per_config_;
const int max_total_instances_;
testing::FakeGraphicsContextProvider* fake_graphics_context_provider_;
std::vector<std::vector<PlayerInstance>> player_instances_;
MaximumPlayerConfigurationExplorer(
const MaximumPlayerConfigurationExplorer& other) = delete;
MaximumPlayerConfigurationExplorer& operator=(
const MaximumPlayerConfigurationExplorer& other) = delete;
};
} // namespace nplb
} // namespace starboard
#endif // STARBOARD_NPLB_MAXIMUM_PLAYER_CONFIGURATION_EXPLORER_H_