Skip to content

Commit

Permalink
[nplb] Add tests for partial audio frames (#545)
Browse files Browse the repository at this point in the history
b/274020873

(cherry picked from commit c7039d1)
  • Loading branch information
jasonzhangxx authored and anonymous1-me committed Jun 26, 2023
1 parent e78cd4a commit d96be80
Show file tree
Hide file tree
Showing 10 changed files with 622 additions and 170 deletions.
10 changes: 6 additions & 4 deletions starboard/nplb/multiple_player_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ void NoInput(const SbPlayerTestConfig& player_config,

GroupedSamples samples;
if (player_fixture.HasAudio()) {
samples.AddAudioSamplesWithEOS(0, 0);
samples.AddAudioEOS();
}
if (player_fixture.HasVideo()) {
samples.AddVideoSamplesWithEOS(0, 0);
samples.AddVideoEOS();
}
ASSERT_NO_FATAL_FAILURE(player_fixture.Write(samples));
ASSERT_NO_FATAL_FAILURE(player_fixture.WaitForPlayerEndOfStream());
Expand All @@ -103,12 +103,14 @@ void WriteSamples(const SbPlayerTestConfig& player_config,

GroupedSamples samples;
if (player_fixture.HasAudio()) {
samples.AddAudioSamplesWithEOS(
samples.AddAudioSamples(
0, player_fixture.ConvertDurationToAudioBufferCount(kDurationToPlay));
samples.AddAudioEOS();
}
if (player_fixture.HasVideo()) {
samples.AddVideoSamplesWithEOS(
samples.AddVideoSamples(
0, player_fixture.ConvertDurationToVideoBufferCount(kDurationToPlay));
samples.AddVideoEOS();
}

ASSERT_NO_FATAL_FAILURE(player_fixture.Write(samples));
Expand Down
22 changes: 14 additions & 8 deletions starboard/nplb/player_get_audio_configuration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ TEST_P(SbPlayerGetAudioConfigurationTest, SunnyDay) {

GroupedSamples samples;
if (player_fixture.HasAudio()) {
samples.AddAudioSamplesWithEOS(0, kSamplesToWrite);
samples.AddAudioSamples(0, kSamplesToWrite);
samples.AddAudioEOS();
}
if (player_fixture.HasVideo()) {
samples.AddVideoSamplesWithEOS(0, kSamplesToWrite);
samples.AddVideoSamples(0, kSamplesToWrite);
samples.AddVideoEOS();
}
ASSERT_NO_FATAL_FAILURE(player_fixture.Write(samples));
ASSERT_NO_FATAL_FAILURE(player_fixture.WaitForPlayerPresenting());
Expand Down Expand Up @@ -165,10 +167,10 @@ TEST_P(SbPlayerGetAudioConfigurationTest, NoInput) {

GroupedSamples samples;
if (player_fixture.HasAudio()) {
samples.AddAudioSamplesWithEOS(0, 0);
samples.AddAudioEOS();
}
if (player_fixture.HasVideo()) {
samples.AddVideoSamplesWithEOS(0, 0);
samples.AddVideoEOS();
}
ASSERT_NO_FATAL_FAILURE(player_fixture.Write(samples));
ASSERT_NO_FATAL_FAILURE(player_fixture.WaitForPlayerPresenting());
Expand Down Expand Up @@ -206,10 +208,12 @@ TEST_P(SbPlayerGetAudioConfigurationTest, MultipleSeeks) {

GroupedSamples samples;
if (player_fixture.HasAudio()) {
samples.AddAudioSamplesWithEOS(0, kSamplesToWrite);
samples.AddAudioSamples(0, kSamplesToWrite);
samples.AddAudioEOS();
}
if (player_fixture.HasVideo()) {
samples.AddVideoSamplesWithEOS(0, kSamplesToWrite);
samples.AddVideoSamples(0, kSamplesToWrite);
samples.AddVideoEOS();
}
ASSERT_NO_FATAL_FAILURE(player_fixture.Write(samples));
ASSERT_NO_FATAL_FAILURE(player_fixture.WaitForPlayerPresenting());
Expand All @@ -236,14 +240,16 @@ TEST_P(SbPlayerGetAudioConfigurationTest, MultipleSeeks) {

samples = GroupedSamples();
if (player_fixture.HasAudio()) {
samples.AddAudioSamplesWithEOS(
samples.AddAudioSamples(
0, player_fixture.ConvertDurationToAudioBufferCount(seek_to_time) +
kSamplesToWrite);
samples.AddAudioEOS();
}
if (player_fixture.HasVideo()) {
samples.AddVideoSamplesWithEOS(
samples.AddVideoSamples(
0, player_fixture.ConvertDurationToVideoBufferCount(seek_to_time) +
kSamplesToWrite);
samples.AddVideoEOS();
}
ASSERT_NO_FATAL_FAILURE(player_fixture.Write(samples));
ASSERT_NO_FATAL_FAILURE(player_fixture.WaitForPlayerPresenting());
Expand Down
Loading

0 comments on commit d96be80

Please sign in to comment.