Skip to content

Commit

Permalink
[nplb] Convert SbPlayerTestConfig to struct (#702)
Browse files Browse the repository at this point in the history
b/283002236

(cherry picked from commit 61d02c6)
  • Loading branch information
jasonzhangxx authored and anonymous1-me committed Jun 23, 2023
1 parent a1b4bed commit 044ea28
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
12 changes: 4 additions & 8 deletions starboard/nplb/multiple_player_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,14 @@ std::string GetMultipleSbPlayerTestConfigName(
const SbPlayerMultiplePlayerTestConfig& multiplayer_test_config = info.param;

SB_DCHECK(multiplayer_test_config.size() > 0);
const SbPlayerOutputMode output_mode =
std::get<2>(multiplayer_test_config[0]);
const char* key_system = std::get<3>(multiplayer_test_config[0]);
const SbPlayerOutputMode output_mode = multiplayer_test_config[0].output_mode;
const char* key_system = multiplayer_test_config[0].key_system;

std::string name;
for (int i = 0; i < multiplayer_test_config.size(); i++) {
const SbPlayerTestConfig& config = multiplayer_test_config[i];
const char* audio_filename = std::get<0>(config);
const char* video_filename = std::get<1>(config);
SB_DCHECK(std::get<2>(multiplayer_test_config[i]) == output_mode);
// We simply check the string pointers here.
SB_DCHECK(std::get<3>(multiplayer_test_config[i]) == key_system);
const char* audio_filename = config.audio_filename;
const char* video_filename = config.video_filename;

if (i > 0) {
name += "_";
Expand Down
8 changes: 4 additions & 4 deletions starboard/nplb/player_test_fixture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ SbPlayerTestFixture::CallbackEvent::CallbackEvent(SbPlayer player,
SbPlayerTestFixture::SbPlayerTestFixture(
const SbPlayerTestConfig& config,
FakeGraphicsContextProvider* fake_graphics_context_provider)
: output_mode_(std::get<2>(config)),
key_system_(std::get<3>(config)),
: output_mode_(config.output_mode),
key_system_(config.key_system),
fake_graphics_context_provider_(fake_graphics_context_provider) {
SB_DCHECK(output_mode_ == kSbPlayerOutputModeDecodeToTexture ||
output_mode_ == kSbPlayerOutputModePunchOut);

const char* audio_dmp_filename = std::get<0>(config);
const char* video_dmp_filename = std::get<1>(config);
const char* audio_dmp_filename = config.audio_filename;
const char* video_dmp_filename = config.video_filename;

if (audio_dmp_filename && strlen(audio_dmp_filename) > 0) {
audio_dmp_reader_.reset(new VideoDmpReader(
Expand Down
16 changes: 8 additions & 8 deletions starboard/nplb/player_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ std::vector<SbPlayerTestConfig> GetSupportedSbPlayerTestConfigs(
for (auto output_mode : kOutputModes) {
if (IsOutputModeSupported(output_mode, audio_codec, video_codec,
key_system)) {
test_configs.push_back(std::make_tuple(audio_filename, video_filename,
output_mode, key_system));
test_configs.emplace_back(audio_filename, video_filename, output_mode,
key_system);
}
}
}
Expand All @@ -137,8 +137,8 @@ std::vector<SbPlayerTestConfig> GetSupportedSbPlayerTestConfigs(
for (auto output_mode : kOutputModes) {
if (IsOutputModeSupported(output_mode, dmp_reader.audio_codec(),
kSbMediaVideoCodecNone, key_system)) {
test_configs.push_back(std::make_tuple(audio_filename, kEmptyName,
output_mode, key_system));
test_configs.emplace_back(audio_filename, kEmptyName, output_mode,
key_system);
}
}
}
Expand All @@ -150,10 +150,10 @@ std::vector<SbPlayerTestConfig> GetSupportedSbPlayerTestConfigs(
std::string GetSbPlayerTestConfigName(
::testing::TestParamInfo<SbPlayerTestConfig> info) {
const SbPlayerTestConfig& config = info.param;
const char* audio_filename = std::get<0>(config);
const char* video_filename = std::get<1>(config);
const SbPlayerOutputMode output_mode = std::get<2>(config);
const char* key_system = std::get<3>(config);
const char* audio_filename = config.audio_filename;
const char* video_filename = config.video_filename;
const SbPlayerOutputMode output_mode = config.output_mode;
const char* key_system = config.key_system;
std::string name(FormatString(
"audio_%s_video_%s_output_%s_key_system_%s",
audio_filename && strlen(audio_filename) > 0 ? audio_filename : "null",
Expand Down
21 changes: 14 additions & 7 deletions starboard/nplb/player_test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@
namespace starboard {
namespace nplb {

// TODO(b/283002236): create a struct for SbPlayerTestConfig instead of using
// std::tuple.
typedef std::tuple<const char* /* audio_filename */,
const char* /* video_filename */,
SbPlayerOutputMode /* output_mode */,
const char* /* key_system */>
SbPlayerTestConfig;
struct SbPlayerTestConfig {
SbPlayerTestConfig(const char* audio_filename,
const char* video_filename,
SbPlayerOutputMode output_mode,
const char* key_system)
: audio_filename(audio_filename),
video_filename(video_filename),
output_mode(output_mode),
key_system(key_system) {}
const char* audio_filename;
const char* video_filename;
SbPlayerOutputMode output_mode;
const char* key_system;
};

std::vector<SbPlayerTestConfig> GetSupportedSbPlayerTestConfigs(
const char* key_system = "");
Expand Down
4 changes: 2 additions & 2 deletions starboard/nplb/vertical_video_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ std::vector<SbPlayerTestConfig> GetVerticalVideoTestConfigs() {

for (auto output_mode : kOutputModes) {
if (IsOutputModeSupported(output_mode, audio_codec, video_codec, "")) {
test_configs.push_back(
std::make_tuple(kAudioFilename, video_filename, output_mode, ""));
test_configs.emplace_back(kAudioFilename, video_filename, output_mode,
"");
}
}
}
Expand Down

0 comments on commit 044ea28

Please sign in to comment.