-
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.
Ensure that MP3, FLAC, and PCM are not supported for MediaSource. (#1359
) This change makes the logic of CanPlayAdaptive more like CanPlayProgressive, wherein unsupported containers are immediately filtered out. Bug: b/297060983 Test: Added unit tests. Also manually ran Cobalt and verified that MediaSource.isTypeSupported returns false for these MIME strings: 'audio/mpeg; codecs="mp3"' 'audio/mpeg' 'audio/ogg; codecs="flac"' 'audio/flac; codecs="flac"' 'audio/wav; codecs="1"'
- Loading branch information
1 parent
fbe1ba5
commit 9fd3a9c
Showing
3 changed files
with
93 additions
and
3 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
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,81 @@ | ||
// 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 "cobalt/media/media_module.h" | ||
|
||
#include "testing/gmock/include/gmock/gmock.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace cobalt { | ||
namespace media { | ||
namespace { | ||
|
||
using ::testing::NotNull; | ||
|
||
#if SB_API_VERSION >= 14 | ||
TEST(MediaModuleTest, DoesNotSupportMp3Adaptive) { | ||
std::unique_ptr<CanPlayTypeHandler> handler = | ||
MediaModule::CreateCanPlayTypeHandler(); | ||
ASSERT_THAT(handler, NotNull()); | ||
EXPECT_FALSE(handler->CanPlayAdaptive("audio/mpeg; codecs=\"mp3\"", | ||
/*key_system=*/"")); | ||
EXPECT_FALSE(handler->CanPlayAdaptive("audio/mpeg", /*key_system=*/"")); | ||
} | ||
|
||
TEST(MediaModuleTest, DoesNotSupportMp3Progressive) { | ||
std::unique_ptr<CanPlayTypeHandler> handler = | ||
MediaModule::CreateCanPlayTypeHandler(); | ||
ASSERT_THAT(handler, NotNull()); | ||
EXPECT_FALSE(handler->CanPlayProgressive("audio/mpeg; codecs=\"mp3\"")); | ||
EXPECT_FALSE(handler->CanPlayProgressive("audio/mpeg")); | ||
} | ||
|
||
TEST(MediaModuleTest, DoesNotSupportFlacAdaptive) { | ||
std::unique_ptr<CanPlayTypeHandler> handler = | ||
MediaModule::CreateCanPlayTypeHandler(); | ||
ASSERT_THAT(handler, NotNull()); | ||
EXPECT_FALSE(handler->CanPlayAdaptive("audio/ogg; codecs=\"flac\"", | ||
/*key_system=*/"")); | ||
EXPECT_FALSE(handler->CanPlayAdaptive("audio/flac; codecs=\"flac\"", | ||
/*key_system=*/"")); | ||
} | ||
|
||
TEST(MediaModuleTest, DoesNotSupportFlacProgressive) { | ||
std::unique_ptr<CanPlayTypeHandler> handler = | ||
MediaModule::CreateCanPlayTypeHandler(); | ||
ASSERT_THAT(handler, NotNull()); | ||
EXPECT_FALSE(handler->CanPlayProgressive("audio/ogg; codecs=\"flac\"")); | ||
EXPECT_FALSE(handler->CanPlayProgressive("audio/flac; codecs=\"flac\"")); | ||
} | ||
|
||
TEST(MediaModuleTest, DoesNotSupportPcmAdaptive) { | ||
std::unique_ptr<CanPlayTypeHandler> handler = | ||
MediaModule::CreateCanPlayTypeHandler(); | ||
ASSERT_THAT(handler, NotNull()); | ||
EXPECT_FALSE(handler->CanPlayAdaptive("audio/wav; codecs=\"1\"", | ||
/*key_system=*/"")); | ||
} | ||
|
||
TEST(MediaModuleTest, DoesNotSupportPcmProgressive) { | ||
std::unique_ptr<CanPlayTypeHandler> handler = | ||
MediaModule::CreateCanPlayTypeHandler(); | ||
ASSERT_THAT(handler, NotNull()); | ||
EXPECT_FALSE(handler->CanPlayProgressive("audio/wav; codecs=\"1\"")); | ||
} | ||
|
||
#endif // SB_API_VERSION >= 14 | ||
|
||
} // namespace | ||
} // namespace media | ||
} // namespace cobalt |