Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement IAMF decoder #3709

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
12 changes: 12 additions & 0 deletions starboard/android/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,18 @@ static_library("starboard_platform") {
if (sb_evergreen_compatible_use_libunwind) {
deps += [ "//third_party/llvm-project/libunwind:unwind_starboard" ]
}

defines = []
if (enable_iamf_decode) {
sources += [
"//starboard/shared/libiamf/iamf_audio_decoder.cc",
"//starboard/shared/libiamf/iamf_audio_decoder.h",
"//starboard/shared/libiamf/iamf_buffer_parser.cc",
"//starboard/shared/libiamf/iamf_buffer_parser.h",
]

defines += [ "ENABLE_IAMF_DECODE" ]
}
}

static_library("starboard_base_symbolize") {
Expand Down
5 changes: 5 additions & 0 deletions starboard/android/shared/media_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ inline const char* SupportedAudioCodecToMimeType(
if (audio_codec == kSbMediaAudioCodecOpus) {
return "audio/opus";
}
#if SB_API_VERSION >= 15
if (audio_codec == kSbMediaAudioCodecIamf) {
return "audio/iamf";
}
#endif // SB_API_VERSION >= 15
return nullptr;
}

Expand Down
6 changes: 6 additions & 0 deletions starboard/android/shared/media_is_audio_supported.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,
return true;
}

#if SB_API_VERSION >= 15 && ENABLE_IAMF_DECODE
if (audio_codec == kSbMediaAudioCodecIamf) {
return true;
}
#endif // SB_API_VERSION >= 15 && ENABLE_IAMF_DECODE

bool media_codec_supported =
MediaCapabilitiesCache::GetInstance()->HasAudioDecoderFor(mime, bitrate);

Expand Down
9 changes: 9 additions & 0 deletions starboard/android/shared/platform_configuration/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ config("platform_configuration") {
"-Wl,--wrap=readdir_r",
]
}
if (enable_iamf_decode) {
configs += [ ":libiamf_config" ]
}
}

config("size") {
Expand Down Expand Up @@ -217,3 +220,9 @@ config("pedantic_warnings") {
"-Wno-unused-parameter",
]
}

if (enable_iamf_decode) {
config("libiamf_config") {
libs = [ "//third_party/libiamf/platforms/android/libiamf.a" ]
}
}
16 changes: 16 additions & 0 deletions starboard/android/shared/player_components_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
#include "starboard/shared/starboard/player/filter/video_renderer_internal_impl.h"
#include "starboard/shared/starboard/player/filter/video_renderer_sink.h"

#if ENABLE_IAMF_DECODE
#include "starboard/shared/libiamf/iamf_audio_decoder.h"
#endif // ENABLE_IAMF_DECODE

namespace starboard {
namespace android {
namespace shared {
Expand Down Expand Up @@ -445,6 +449,18 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player::
return std::unique_ptr<AudioDecoderBase>(
std::move(audio_decoder_impl));
}
#if SB_API_VERSION >= 15 && ENABLE_IAMF_DECODE
} else if (audio_stream_info.codec == kSbMediaAudioCodecIamf) {
SB_LOG(INFO) << "Creating IAMF audio decoder";
std::unique_ptr<starboard::shared::libiamf::IamfAudioDecoder>
audio_decoder_impl(
new starboard::shared::libiamf::IamfAudioDecoder(
audio_stream_info));
if (audio_decoder_impl->is_valid()) {
return std::unique_ptr<AudioDecoderBase>(
std::move(audio_decoder_impl));
}
#endif // SB_API_VERSION >= 15 && ENABLE_IAMF_DECODE
} else {
SB_LOG(ERROR) << "Unsupported audio codec "
<< audio_stream_info.codec;
Expand Down
6 changes: 5 additions & 1 deletion starboard/android/shared/player_create.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ SbPlayer SbPlayerCreate(SbWindow window,
audio_codec != kSbMediaAudioCodecAac &&
audio_codec != kSbMediaAudioCodecAc3 &&
audio_codec != kSbMediaAudioCodecEac3 &&
audio_codec != kSbMediaAudioCodecOpus) {
audio_codec != kSbMediaAudioCodecOpus
#if SB_API_VERSION >= 15
&& audio_codec != kSbMediaAudioCodecIamf
#endif // SB_API_VERSION >= 15
) {
SB_LOG(ERROR) << "Unsupported audio codec: "
<< starboard::GetMediaAudioCodecName(audio_codec) << ".";
player_error_func(
Expand Down
2 changes: 2 additions & 0 deletions starboard/build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ declare_args() {
build_with_separate_cobalt_toolchain = false

use_xcode_clang = false

enable_iamf_decode = false
}

_is_on_pythonpath = exec_script("//starboard/build/is_on_path.py", [], "json")
Expand Down
11 changes: 11 additions & 0 deletions starboard/linux/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,17 @@ static_library("starboard_platform_sources") {
if (is_debug || is_devel) {
defines += [ "SB_PLAYER_ENABLE_VIDEO_DUMPER" ]
}

if (enable_iamf_decode) {
sources += [
"//starboard/shared/libiamf/iamf_audio_decoder.cc",
"//starboard/shared/libiamf/iamf_audio_decoder.h",
"//starboard/shared/libiamf/iamf_buffer_parser.cc",
"//starboard/shared/libiamf/iamf_buffer_parser.h",
]

defines += [ "ENABLE_IAMF_DECODE" ]
}
}

if (current_toolchain == starboard_toolchain) {
Expand Down
6 changes: 6 additions & 0 deletions starboard/linux/shared/media_is_audio_supported.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,
return bitrate <= kSbMediaMaxAudioBitrateInBitsPerSecond;
}

#if SB_API_VERSION >= 15 && ENABLE_IAMF_DECODE
if (audio_codec == kSbMediaAudioCodecIamf) {
return bitrate <= kSbMediaMaxAudioBitrateInBitsPerSecond;
}
#endif // SB_API_VERSION >= 15

if (audio_codec == kSbMediaAudioCodecAc3 ||
audio_codec == kSbMediaAudioCodecEac3) {
return bitrate <= kSbMediaMaxAudioBitrateInBitsPerSecond;
Expand Down
11 changes: 11 additions & 0 deletions starboard/linux/shared/player_components_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include "starboard/shared/starboard/player/filter/video_render_algorithm_impl.h"
#include "starboard/shared/starboard/player/filter/video_renderer_sink.h"

#if ENABLE_IAMF_DECODE
#include "starboard/shared/libiamf/iamf_audio_decoder.h"
#endif // ENABLE_IAMF_DECODE

namespace starboard {
namespace shared {
namespace starboard {
Expand Down Expand Up @@ -86,6 +90,13 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
libfdkaac::LibfdkaacHandle::GetHandle()->IsLoaded()) {
SB_LOG(INFO) << "Playing audio using FdkAacAudioDecoder.";
return std::unique_ptr<AudioDecoder>(new FdkAacAudioDecoder());
#if SB_API_VERSION >= 15 && ENABLE_IAMF_DECODE
} else if (audio_stream_info.codec == kSbMediaAudioCodecIamf) {
SB_LOG(INFO) << "Playing audio using IamfAudioDecoder.";
return std::unique_ptr<AudioDecoder>(
new ::starboard::shared::libiamf::IamfAudioDecoder(
audio_stream_info));
#endif // SB_API_VERSION >= 15 && ENABLE_IAMF_DECODE
} else {
std::unique_ptr<FfmpegAudioDecoder> audio_decoder_impl(
FfmpegAudioDecoder::Create(audio_stream_info));
Expand Down
3 changes: 3 additions & 0 deletions starboard/linux/x64x11/shared/platform_configuration/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ config("platform_configuration") {

config("libraries") {
configs = [ "//starboard/linux/shared/platform_configuration:libraries" ]
if (enable_iamf_decode) {
libs = [ "//third_party/libiamf/platforms/linux/libiamf.a" ]
}
}

config("linker_flags") {
Expand Down
Loading
Loading