Skip to content

Commit

Permalink
Add build args
Browse files Browse the repository at this point in the history
Also clean up logs and reformat decoder.
  • Loading branch information
osagie98 committed Jul 18, 2024
1 parent 0c75785 commit 01d087d
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 151 deletions.
16 changes: 12 additions & 4 deletions starboard/android/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ static_library("starboard_platform") {
"//starboard/shared/libevent/socket_waiter_wait.cc",
"//starboard/shared/libevent/socket_waiter_wait_timed.cc",
"//starboard/shared/libevent/socket_waiter_wake_up.cc",
"//starboard/shared/libiamf/iamf_audio_decoder.cc",
"//starboard/shared/libiamf/iamf_audio_decoder.h",
"//starboard/shared/libiamf/iamf_config_reader.cc",
"//starboard/shared/libiamf/iamf_config_reader.h",
"//starboard/shared/linux/byte_swap.cc",
"//starboard/shared/linux/cpu_features_get.cc",
"//starboard/shared/linux/memory_get_stack_bounds.cc",
Expand Down Expand Up @@ -491,6 +487,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_config_reader.cc",
"//starboard/shared/libiamf/iamf_config_reader.h",
]

defines += [ "ENABLE_IAMF_DECODE" ]
}
}

static_library("starboard_base_symbolize") {
Expand Down
2 changes: 1 addition & 1 deletion starboard/android/shared/media_is_audio_supported.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,
return true;
}

#if SB_API_VERSION >= 15
#if SB_API_VERSION >= 15 && ENABLE_IAMF_DECODE
if (audio_codec == kSbMediaAudioCodecIamf) {
return true;
}
Expand Down
10 changes: 7 additions & 3 deletions starboard/android/shared/platform_configuration/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ config("platform_configuration") {
"-Wl,--wrap=readdir_r",
]
}
configs += [ ":libraries" ]
if (enable_iamf_decode) {
configs += [ ":libiamf_config" ]
}
}

config("size") {
Expand Down Expand Up @@ -219,6 +221,8 @@ config("pedantic_warnings") {
]
}

config("libraries") {
libs = [ "//third_party/libiamf/code/android/libiamf.a" ]
if (enable_iamf_decode) {
config("libiamf_config") {
libs = [ "//third_party/libiamf/code/android/libiamf.a" ]
}
}
14 changes: 10 additions & 4 deletions starboard/android/shared/player_components_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "starboard/common/media.h"
#include "starboard/common/ref_counted.h"
#include "starboard/media.h"
#include "starboard/shared/libiamf/iamf_audio_decoder.h"
#include "starboard/shared/opus/opus_audio_decoder.h"
#include "starboard/shared/starboard/media/media_util.h"
#include "starboard/shared/starboard/media/mime_type.h"
Expand All @@ -49,6 +48,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 @@ -180,7 +183,6 @@ class PlayerComponentsPassthrough
class PlayerComponentsFactory : public starboard::shared::starboard::player::
filter::PlayerComponents::Factory {
typedef starboard::shared::starboard::media::MimeType MimeType;
typedef starboard::shared::libiamf::IamfAudioDecoder IamfAudioDecoder;
typedef starboard::shared::opus::OpusAudioDecoder OpusAudioDecoder;
typedef starboard::shared::starboard::player::filter::AdaptiveAudioDecoder
AdaptiveAudioDecoder;
Expand Down Expand Up @@ -446,14 +448,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<IamfAudioDecoder> audio_decoder_impl(
new IamfAudioDecoder(audio_stream_info));
std::unique_ptr<starboard::shared::libiamf::IamfAudioDecoder>
audio_decoder_impl(
new starboard::shared::libiamf::IamfAudioDecoder(
audio_stream_info, /* prefer_binarual_audio */ false));
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
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
15 changes: 11 additions & 4 deletions starboard/linux/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ static_library("starboard_platform_sources") {
"//starboard/shared/libfdkaac/fdk_aac_audio_decoder.h",
"//starboard/shared/libfdkaac/libfdkaac_library_loader.cc",
"//starboard/shared/libfdkaac/libfdkaac_library_loader.h",
"//starboard/shared/libiamf/iamf_audio_decoder.cc",
"//starboard/shared/libiamf/iamf_audio_decoder.h",
"//starboard/shared/libiamf/iamf_config_reader.cc",
"//starboard/shared/libiamf/iamf_config_reader.h",
"//starboard/shared/libvpx/vpx_video_decoder.cc",
"//starboard/shared/libvpx/vpx_video_decoder.h",
"//starboard/shared/linux/byte_swap.cc",
Expand Down Expand Up @@ -445,6 +441,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_config_reader.cc",
"//starboard/shared/libiamf/iamf_config_reader.h",
]

defines += [ "ENABLE_IAMF_DECODE" ]
}
}

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

#if SB_API_VERSION >= 15
#if SB_API_VERSION >= 15 && ENABLE_IAMF_DECODE
if (audio_codec == kSbMediaAudioCodecIamf) {
return bitrate <= kSbMediaMaxAudioBitrateInBitsPerSecond;
}
Expand Down
11 changes: 8 additions & 3 deletions starboard/linux/shared/player_components_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "starboard/shared/libde265/de265_video_decoder.h"
#include "starboard/shared/libfdkaac/fdk_aac_audio_decoder.h"
#include "starboard/shared/libfdkaac/libfdkaac_library_loader.h"
#include "starboard/shared/libiamf/iamf_audio_decoder.h"
#include "starboard/shared/libvpx/vpx_video_decoder.h"
#include "starboard/shared/openh264/openh264_library_loader.h"
#include "starboard/shared/openh264/openh264_video_decoder.h"
Expand All @@ -42,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 @@ -69,7 +72,6 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
SB_DCHECK(audio_renderer_sink);

typedef ::starboard::shared::ffmpeg::AudioDecoder FfmpegAudioDecoder;
typedef ::starboard::shared::libiamf::IamfAudioDecoder IamfAudioDecoder;
typedef ::starboard::shared::opus::OpusAudioDecoder OpusAudioDecoder;
typedef ::starboard::shared::libfdkaac::FdkAacAudioDecoder
FdkAacAudioDecoder;
Expand All @@ -88,10 +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 IamfAudioDecoder(audio_stream_info));
new ::starboard::shared::libiamf::IamfAudioDecoder(
audio_stream_info, /* prefer_binarual_audio */ false));
#endif // SB_API_VERSION >= 15 && ENABLE_IAMF_DECODE
} else {
std::unique_ptr<FfmpegAudioDecoder> audio_decoder_impl(
FfmpegAudioDecoder::Create(audio_stream_info));
Expand Down
1 change: 1 addition & 0 deletions starboard/linux/x64x11/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ if (sb_is_modular && !sb_is_evergreen) {
sources = [ "//starboard/linux/x64x11/main.cc" ]
configs += [ "//starboard/build/config:starboard_implementation" ]
public_deps = [ ":starboard_platform" ]
deps = [ "//third_party/flac" ]
}
}
10 changes: 6 additions & 4 deletions starboard/linux/x64x11/shared/platform_configuration/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ config("platform_configuration") {

config("libraries") {
configs = [ "//starboard/linux/shared/platform_configuration:libraries" ]
libs = [
"//third_party/libiamf/code/libiamf.a",
"//third_party/libiamf/source/code/dep_codecs/lib/libfdk-aac.a",
]
if (enable_iamf_decode) {
libs = [
"//third_party/libiamf/code/libiamf.a",
"//third_party/libiamf/source/code/dep_codecs/lib/libfdk-aac.a",
]
}
}

config("linker_flags") {
Expand Down
Loading

0 comments on commit 01d087d

Please sign in to comment.