-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
b/248859788 Change-Id: I2f737a973b219360d106ebf89bfb7e329d0011b9 (cherry picked from commit 0825e37) Co-authored-by: Austin Osagie <[email protected]>
- Loading branch information
1 parent
1922262
commit e4bc260
Showing
9 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
// 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. | ||
|
||
#include <string> | ||
#include <tuple> | ||
#include <vector> | ||
|
||
#include "starboard/common/log.h" | ||
#include "starboard/media.h" | ||
#include "starboard/nplb/player_test_fixture.h" | ||
#include "starboard/nplb/player_test_util.h" | ||
#include "starboard/player.h" | ||
#include "starboard/shared/starboard/player/video_dmp_reader.h" | ||
#include "starboard/time.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace starboard { | ||
namespace nplb { | ||
namespace { | ||
|
||
using shared::starboard::player::video_dmp::VideoDmpReader; | ||
using ::testing::ValuesIn; | ||
|
||
typedef SbPlayerTestFixture::GroupedSamples GroupedSamples; | ||
|
||
class VerticalVideoTest : public ::testing::TestWithParam<SbPlayerTestConfig> { | ||
}; | ||
|
||
void CheckVerticalResolutionSupport(const char* mime) { | ||
SB_LOG_IF(WARNING, SbMediaCanPlayMimeAndKeySystem(mime, "") != | ||
kSbMediaSupportTypeProbably) | ||
<< "Vertical video (" << mime | ||
<< ") should be supported on this platform."; | ||
} | ||
|
||
std::vector<SbPlayerTestConfig> GetVerticalVideoTestConfigs() { | ||
const char* kVideoFilenames[] = {"vertical_1080p_30_fps_137_avc.dmp", | ||
"vertical_4k_30_fps_313_vp9.dmp", | ||
"vertical_8k_30_fps_571_av1.dmp"}; | ||
const char* kAudioFilename = "silence_aac_stereo.dmp"; | ||
|
||
const SbPlayerOutputMode kOutputModes[] = {kSbPlayerOutputModeDecodeToTexture, | ||
kSbPlayerOutputModePunchOut}; | ||
|
||
std::vector<const char*> video_files; | ||
for (auto video_filename : kVideoFilenames) { | ||
VideoDmpReader video_dmp_reader(video_filename, | ||
VideoDmpReader::kEnableReadOnDemand); | ||
SB_DCHECK(video_dmp_reader.number_of_video_buffers() > 0); | ||
if (SbMediaCanPlayMimeAndKeySystem( | ||
video_dmp_reader.video_mime_type().c_str(), "")) { | ||
video_files.push_back(video_filename); | ||
} | ||
} | ||
|
||
VideoDmpReader audio_dmp_reader(kAudioFilename, | ||
VideoDmpReader::kEnableReadOnDemand); | ||
SbMediaAudioCodec audio_codec = audio_dmp_reader.audio_codec(); | ||
|
||
std::vector<SbPlayerTestConfig> test_configs; | ||
for (auto video_filename : video_files) { | ||
SbMediaVideoCodec video_codec = kSbMediaVideoCodecNone; | ||
VideoDmpReader video_dmp_reader(video_filename, | ||
VideoDmpReader::kEnableReadOnDemand); | ||
video_codec = video_dmp_reader.video_codec(); | ||
|
||
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, "")); | ||
} | ||
} | ||
} | ||
|
||
return test_configs; | ||
} | ||
|
||
TEST(VerticalVideoTest, CapabilityQuery) { | ||
SbMediaSupportType support = SbMediaCanPlayMimeAndKeySystem( | ||
"video/mp4; codecs=\"avc1.4d002a\"; width=1920; height=1080", ""); | ||
if (support == kSbMediaSupportTypeProbably) { | ||
CheckVerticalResolutionSupport( | ||
"video/mp4; codecs=\"avc1.4d002a\"; width=608; height=1080"); | ||
} | ||
|
||
support = SbMediaCanPlayMimeAndKeySystem( | ||
"video/webm; codecs=\"vp9\"; width=2560; height=1440", ""); | ||
if (support == kSbMediaSupportTypeProbably) { | ||
CheckVerticalResolutionSupport( | ||
"video/webm; codecs=\"vp9\"; width=810; height=1440"); | ||
} | ||
|
||
support = SbMediaCanPlayMimeAndKeySystem( | ||
"video/webm; codecs=\"vp9\"; width=3840; height=2160", ""); | ||
if (support == kSbMediaSupportTypeProbably) { | ||
CheckVerticalResolutionSupport( | ||
"video/webm; codecs=\"vp9\"; width=1215; height=2160"); | ||
} | ||
|
||
support = SbMediaCanPlayMimeAndKeySystem( | ||
"video/mp4; codecs=\"av01.0.16M.08\"; width=7680; height=4320", ""); | ||
if (support == kSbMediaSupportTypeProbably) { | ||
CheckVerticalResolutionSupport( | ||
"video/mp4; codecs=\"av01.0.16M.08\"; width=2430; height=4320"); | ||
} | ||
} | ||
|
||
TEST_P(VerticalVideoTest, WriteSamples) { | ||
SbPlayerTestFixture player_fixture(GetParam()); | ||
if (HasFatalFailure()) { | ||
return; | ||
} | ||
|
||
SB_DCHECK(player_fixture.HasVideo()); | ||
SB_DCHECK(player_fixture.HasAudio()); | ||
|
||
int audio_samples_to_write = player_fixture.ConvertDurationToAudioBufferCount( | ||
200 * kSbTimeMillisecond); | ||
int video_samples_to_write = player_fixture.ConvertDurationToVideoBufferCount( | ||
200 * kSbTimeMillisecond); | ||
|
||
GroupedSamples samples; | ||
samples.AddVideoSamplesWithEOS(0, audio_samples_to_write); | ||
samples.AddAudioSamplesWithEOS(0, video_samples_to_write); | ||
|
||
ASSERT_NO_FATAL_FAILURE(player_fixture.Write(samples)); | ||
ASSERT_NO_FATAL_FAILURE(player_fixture.WaitForPlayerEndOfStream()); | ||
} | ||
|
||
std::vector<SbPlayerTestConfig> GetSupportedTestConfigs() { | ||
static std::vector<SbPlayerTestConfig> supported_configs; | ||
if (supported_configs.size() > 0) { | ||
return supported_configs; | ||
} | ||
|
||
std::vector<SbPlayerTestConfig> configs = GetVerticalVideoTestConfigs(); | ||
supported_configs.insert(supported_configs.end(), configs.begin(), | ||
configs.end()); | ||
return supported_configs; | ||
} | ||
|
||
INSTANTIATE_TEST_CASE_P(VerticalVideoTests, | ||
VerticalVideoTest, | ||
ValuesIn(GetSupportedTestConfigs()), | ||
GetSbPlayerTestConfigName); | ||
|
||
} // namespace | ||
} // namespace nplb | ||
} // namespace starboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
starboard/shared/starboard/player/testdata/silence_aac_stereo.dmp.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a4e1cc998dd27018aaa3d247c6316b248be2bbcb |
1 change: 1 addition & 0 deletions
1
starboard/shared/starboard/player/testdata/vertical_1080p_30_fps_137_avc.dmp.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9a6a0747a9b9669ccade0ad36c8582f7a74a59f2 |
1 change: 1 addition & 0 deletions
1
starboard/shared/starboard/player/testdata/vertical_4k_30_fps_313_vp9.dmp.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
09568d08a3611271c2bde94fef610bfc88862961 |
1 change: 1 addition & 0 deletions
1
starboard/shared/starboard/player/testdata/vertical_8k_30_fps_571_av1.dmp.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
461c333fdda619c5ac5df1d2ed4fdc5d75e604d4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters