Skip to content

Commit

Permalink
SB_API_VERSION variable cleanup
Browse files Browse the repository at this point in the history
b/362374622

Change-Id: I93649c5fd97c2deb5e59c0ac794c0f280e6f2ee1
  • Loading branch information
madhurajayaraman committed Sep 10, 2024
1 parent 3950b01 commit 0b3b54a
Show file tree
Hide file tree
Showing 31 changed files with 3 additions and 200 deletions.
16 changes: 0 additions & 16 deletions starboard/shared/starboard/application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ void Dispatch(SbEventType type, void* data, SbEventDataDestructor destructor) {
SbEvent event;
event.type = type;
event.data = data;
#if SB_API_VERSION >= 15
Application::Get()->sb_event_handle_callback_(&event);
#else
SbEventHandle(&event);
#endif // SB_API_VERSION >= 15
if (destructor) {
destructor(event.data);
}
Expand All @@ -67,7 +63,6 @@ volatile SbAtomic32 g_next_event_id = 0;

Application* Application::g_instance = NULL;

#if SB_API_VERSION >= 15
Application::Application(SbEventHandleCallback sb_event_handle_callback)
: error_level_(0),
thread_(pthread_self()),
Expand All @@ -76,13 +71,6 @@ Application::Application(SbEventHandleCallback sb_event_handle_callback)
sb_event_handle_callback_(sb_event_handle_callback) {
SB_CHECK(sb_event_handle_callback_)
<< "sb_event_handle_callback_ has not been set.";
#else
Application::Application()
: error_level_(0),
thread_(pthread_self()),
start_link_(NULL),
state_(kStateUnstarted) {
#endif // SB_API_VERSION >= 15
Application* old_instance =
reinterpret_cast<Application*>(SbAtomicAcquire_CompareAndSwapPtr(
reinterpret_cast<SbAtomicPtr*>(&g_instance),
Expand Down Expand Up @@ -419,11 +407,7 @@ bool Application::HandleEventAndUpdateState(Application::Event* event) {
OnSuspend();
}

#if SB_API_VERSION >= 15
sb_event_handle_callback_(scoped_event->event);
#else
SbEventHandle(scoped_event->event);
#endif // SB_API_VERSION >= 15

switch (scoped_event->event->type) {
case kSbEventTypePreload:
Expand Down
6 changes: 0 additions & 6 deletions starboard/shared/starboard/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ class Application {
public:
typedef player::filter::VideoFrame VideoFrame;

#if SB_API_VERSION >= 15
// Executes a SbEventHandle method callback.
SbEventHandleCallback sb_event_handle_callback_ = NULL;
#endif // SB_API_VERSION >= 15

// You can use a void(void *) function to signal that a state-transition event
// has completed.
Expand Down Expand Up @@ -157,11 +155,7 @@ class Application {
int error_level;
};

#if SB_API_VERSION >= 15
explicit Application(SbEventHandleCallback sb_event_handle_callback);
#else
Application();
#endif // SB_API_VERSION >= 15
virtual ~Application();

// Gets the current instance of the Application. DCHECKS if called before the
Expand Down
4 changes: 0 additions & 4 deletions starboard/shared/starboard/log_raw_format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
#include "starboard/common/log.h"

#include <stdarg.h>
#if SB_API_VERSION >= 16
#include <stdio.h>
#else
#include "starboard/common/string.h"
#endif // SB_API_VERSION >= 16

void SbLogRawFormat(const char* format, va_list arguments) {
char message[128];
Expand Down
2 changes: 0 additions & 2 deletions starboard/shared/starboard/media/codec_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ SbMediaAudioCodec GetAudioCodecFromString(const char* codec,
if (is_wav && strcmp(codec, "1") == 0) {
return kSbMediaAudioCodecPcm;
}
#if SB_API_VERSION >= 15
if (strcmp(codec, "iamf") == 0 || strncmp(codec, "iamf.", 5) == 0) {
return kSbMediaAudioCodecIamf;
}
#endif // SB_API_VERSION >= 15
return kSbMediaAudioCodecNone;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ bool SbMediaGetAudioConfiguration(

*out_configuration = {};

#if SB_API_VERSION >= 15
out_configuration->connector = kSbMediaAudioConnectorUnknown;
#else // SB_API_VERSION >= 15
out_configuration->index = 0;
out_configuration->connector = kSbMediaAudioConnectorNone;
#endif // SB_API_VERSION >= 15
out_configuration->latency = 0;
out_configuration->coding_type = kSbMediaAudioCodingTypePcm;
out_configuration->number_of_channels = SbAudioSinkGetMaxChannels();
Expand Down
10 changes: 0 additions & 10 deletions starboard/shared/starboard/media/media_get_buffer_alignment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@

#include "starboard/media.h"

#if SB_API_VERSION >= 16

int SbMediaGetBufferAlignment() {
return sizeof(void*);
}

#else // SB_API_VERSION >= 16

int SbMediaGetBufferAlignment() {
return 1;
}

#endif // SB_API_VERSION >= 16
27 changes: 0 additions & 27 deletions starboard/shared/starboard/media/media_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,9 @@ bool operator!=(const AudioStreamInfo& left, const AudioStreamInfo& right) {

AudioSampleInfo& AudioSampleInfo::operator=(
const SbMediaAudioSampleInfo& that) {
#if SB_API_VERSION >= 15
stream_info = that.stream_info;
discarded_duration_from_front = that.discarded_duration_from_front;
discarded_duration_from_back = that.discarded_duration_from_back;
#else // SB_API_VERSION >= 15
stream_info = that;
#endif // SB_API_VERSION >= 15

return *this;
}
Expand All @@ -183,15 +179,11 @@ void AudioSampleInfo::ConvertTo(
SB_DCHECK(audio_sample_info);

*audio_sample_info = {};
#if SB_API_VERSION >= 15
stream_info.ConvertTo(&audio_sample_info->stream_info);
audio_sample_info->discarded_duration_from_front =
discarded_duration_from_front;
audio_sample_info->discarded_duration_from_back =
discarded_duration_from_back;
#else // SB_API_VERSION >= 15
stream_info.ConvertTo(audio_sample_info);
#endif // SB_API_VERSION >= 15
}

void AudioSampleInfo::ConvertTo(
Expand Down Expand Up @@ -247,11 +239,7 @@ bool operator!=(const VideoStreamInfo& left, const VideoStreamInfo& right) {

VideoSampleInfo& VideoSampleInfo::operator=(
const SbMediaVideoSampleInfo& that) {
#if SB_API_VERSION >= 15
stream_info = that.stream_info;
#else // SB_API_VERSION >= 15
stream_info = that;
#endif // SB_API_VERSION >= 15
is_key_frame = that.is_key_frame;
return *this;
}
Expand All @@ -268,11 +256,7 @@ void VideoSampleInfo::ConvertTo(
SB_DCHECK(video_sample_info);

*video_sample_info = {};
#if SB_API_VERSION >= 15
stream_info.ConvertTo(&video_sample_info->stream_info);
#else // SB_API_VERSION >= 15
stream_info.ConvertTo(video_sample_info);
#endif // SB_API_VERSION >= 15
video_sample_info->is_key_frame = is_key_frame;
}

Expand Down Expand Up @@ -468,13 +452,8 @@ bool operator==(const SbMediaColorMetadata& metadata_1,

bool operator==(const SbMediaVideoSampleInfo& sample_info_1,
const SbMediaVideoSampleInfo& sample_info_2) {
#if SB_API_VERSION >= 15
const SbMediaVideoStreamInfo& stream_info_1 = sample_info_1.stream_info;
const SbMediaVideoStreamInfo& stream_info_2 = sample_info_2.stream_info;
#else // SB_API_VERSION >= 15
const SbMediaVideoStreamInfo& stream_info_1 = sample_info_1;
const SbMediaVideoStreamInfo& stream_info_2 = sample_info_2;
#endif // SB_API_VERSION >= 15

if (stream_info_1.codec != stream_info_2.codec) {
return false;
Expand Down Expand Up @@ -503,8 +482,6 @@ bool operator==(const SbMediaVideoSampleInfo& sample_info_1,
return stream_info_1.color_metadata == stream_info_2.color_metadata;
}

#if SB_API_VERSION >= 15

bool operator==(const SbMediaVideoStreamInfo& stream_info_1,
const SbMediaVideoStreamInfo& stream_info_2) {
if (stream_info_1.codec != stream_info_2.codec) {
Expand All @@ -530,8 +507,6 @@ bool operator==(const SbMediaVideoStreamInfo& stream_info_1,
return stream_info_1.color_metadata == stream_info_2.color_metadata;
}

#endif // SB_API_VERSION >= 15

bool operator!=(const SbMediaColorMetadata& metadata_1,
const SbMediaColorMetadata& metadata_2) {
return !(metadata_1 == metadata_2);
Expand All @@ -542,9 +517,7 @@ bool operator!=(const SbMediaVideoSampleInfo& sample_info_1,
return !(sample_info_1 == sample_info_2);
}

#if SB_API_VERSION >= 15
bool operator!=(const SbMediaVideoStreamInfo& stream_info_1,
const SbMediaVideoStreamInfo& stream_info_2) {
return !(stream_info_1 == stream_info_2);
}
#endif // SB_API_VERSION >= 15
6 changes: 2 additions & 4 deletions starboard/shared/starboard/media/media_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,20 @@ int64_t AudioFramesToDuration(int frames, int samples_per_second);

bool operator==(const SbMediaColorMetadata& metadata_1,
const SbMediaColorMetadata& metadata_2);

bool operator==(const SbMediaVideoSampleInfo& sample_info_1,
const SbMediaVideoSampleInfo& sample_info_2);

#if SB_API_VERSION >= 15
bool operator==(const SbMediaVideoStreamInfo& stream_info_1,
const SbMediaVideoStreamInfo& stream_info_2);
#endif // SB_API_VERSION >= 15

bool operator!=(const SbMediaColorMetadata& metadata_1,
const SbMediaColorMetadata& metadata_2);

bool operator!=(const SbMediaVideoSampleInfo& sample_info_1,
const SbMediaVideoSampleInfo& sample_info_2);

#if SB_API_VERSION >= 15
bool operator!=(const SbMediaVideoStreamInfo& stream_info_1,
const SbMediaVideoStreamInfo& stream_info_2);
#endif // SB_API_VERSION >= 15

#endif // STARBOARD_SHARED_STARBOARD_MEDIA_MEDIA_UTIL_H_
8 changes: 0 additions & 8 deletions starboard/shared/starboard/media/media_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,7 @@ TEST(AudioSampleInfoTest, DefaultCtor) {

TEST(AudioSampleInfoTest, SbMediaAudioSampleInfo) {
SbMediaAudioSampleInfo original = {};
#if SB_API_VERSION >= 15
SbMediaAudioStreamInfo& stream_info = original.stream_info;
#else // SB_API_VERSION >= 15
SbMediaAudioStreamInfo& stream_info = original;
#endif // SB_API_VERSION >= 15

stream_info.codec = kSbMediaAudioCodecOpus;
stream_info.mime = "audio/webm";
Expand Down Expand Up @@ -244,11 +240,7 @@ TEST(VideoSampleInfoTest, DefaultCtor) {

TEST(VideoSampleInfoTest, SbMediaVideoSampleInfo) {
SbMediaVideoSampleInfo original = {};
#if SB_API_VERSION >= 15
SbMediaVideoStreamInfo& stream_info = original.stream_info;
#else // SB_API_VERSION >= 15
SbMediaVideoStreamInfo& stream_info = original;
#endif // SB_API_VERSION >= 15

original.is_key_frame = true;
stream_info.codec = kSbMediaVideoCodecAv1;
Expand Down
2 changes: 0 additions & 2 deletions starboard/shared/starboard/media/mime_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,11 @@ bool IsSupportedAudioCodec(const ParsedMimeInfo& mime_info) {
return false;
}
break;
#if SB_API_VERSION >= 15
case kSbMediaAudioCodecIamf:
if (mime_type.subtype() != "mp4") {
return false;
}
break;
#endif // SB_API_VERSION >= 15
}

if (!IsAudioOutputSupported(kSbMediaAudioCodingTypePcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,11 @@ FilterBasedPlayerWorkerHandler::FilterBasedPlayerWorkerHandler(
SbDecodeTargetGraphicsContextProvider* provider)
: JobOwner(kDetached),
drm_system_(creation_param->drm_system),
#if SB_API_VERSION >= 15
audio_stream_info_(creation_param->audio_stream_info),
#else // SB_API_VERSION >= 15
audio_stream_info_(creation_param->audio_sample_info),
#endif // SB_API_VERSION >= 15
output_mode_(creation_param->output_mode),
max_video_input_size_(0),
decode_target_graphics_context_provider_(provider),
#if SB_API_VERSION >= 15
video_stream_info_(creation_param->video_stream_info) {
#else // SB_API_VERSION >= 15
video_stream_info_(creation_param->video_sample_info) {
#endif // SB_API_VERSION >= 15
update_job_ = std::bind(&FilterBasedPlayerWorkerHandler::Update, this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,10 @@ void StubAudioDecoder::DecodeEndOfStream() {
} else if (codec_ == kSbMediaAudioCodecAc3 ||
codec_ == kSbMediaAudioCodecEac3) {
frames_per_input_ = 1536;
#if SB_API_VERSION >= 15
} else if (codec_ == kSbMediaAudioCodecIamf) {
// The max iamf frames per input varies depending on the stream.
// Assume 2048 max.
frames_per_input_ = 2048;
#endif // SB_API_VERSION >= 15
} else {
SB_NOTREACHED() << "Unsupported audio codec " << codec_;
}
Expand Down
30 changes: 0 additions & 30 deletions starboard/shared/starboard/player/filter/testing/test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ std::string GetContentTypeFromAudioCodec(SbMediaAudioCodec audio_codec,
case kSbMediaAudioCodecEac3:
content_type = "audio/mp4; codecs=\"ec-3\"";
break;
#if SB_API_VERSION >= 15
case kSbMediaAudioCodecIamf:
content_type = "audio/mp4; codecs=\"iamf\"";
break;
#endif // SB_API_VERSION >= 15
default:
SB_NOTREACHED();
}
Expand Down Expand Up @@ -111,10 +109,8 @@ std::vector<const char*> GetSupportedAudioTestFiles(
"beneath_the_canopy_opus_stereo.dmp",
"beneath_the_canopy_opus_mono.dmp",
"heaac.dmp",
#if SB_API_VERSION >= 15
"iamf_base_profile_stereo_ambisonics.dmp",
"iamf_simple_profile_5_1.dmp",
#endif // SB_API_VERSION >= 15
"sintel_329_ec3.dmp",
"sintel_381_ac3.dmp"};

Expand Down Expand Up @@ -287,11 +283,7 @@ media::VideoStreamInfo CreateVideoStreamInfo(SbMediaVideoCodec codec) {
}

bool IsPartialAudioSupported() {
#if SB_API_VERSION >= 15
return true;
#else // SB_API_VERSION >= 15
return SbSystemGetExtension(kCobaltExtensionEnhancedAudioName) != nullptr;
#endif // SB_API_VERSION >= 15
}

scoped_refptr<InputBuffer> GetAudioInputBuffer(
Expand All @@ -313,34 +305,12 @@ scoped_refptr<InputBuffer> GetAudioInputBuffer(
SB_DCHECK(dmp_reader);
auto player_sample_info =
dmp_reader->GetPlayerSampleInfo(kSbMediaTypeAudio, index);
#if SB_API_VERSION >= 15
player_sample_info.audio_sample_info.discarded_duration_from_front =
discarded_duration_from_front;
player_sample_info.audio_sample_info.discarded_duration_from_back =
discarded_duration_from_back;
auto input_buffer = new InputBuffer(StubDeallocateSampleFunc, nullptr,
nullptr, player_sample_info);
#else // SB_API_VERSION >= 15
media::AudioSampleInfo audio_sample_info(
player_sample_info.audio_sample_info);
audio_sample_info.discarded_duration_from_front =
discarded_duration_from_front;
audio_sample_info.discarded_duration_from_back = discarded_duration_from_back;

CobaltExtensionEnhancedAudioPlayerSampleInfo enhanced_audio_sample_info;
enhanced_audio_sample_info.type = player_sample_info.type;
enhanced_audio_sample_info.buffer = player_sample_info.buffer;
enhanced_audio_sample_info.buffer_size = player_sample_info.buffer_size;
enhanced_audio_sample_info.timestamp = player_sample_info.timestamp;
enhanced_audio_sample_info.side_data = player_sample_info.side_data;
enhanced_audio_sample_info.side_data_count =
player_sample_info.side_data_count;
audio_sample_info.ConvertTo(&enhanced_audio_sample_info.audio_sample_info);
enhanced_audio_sample_info.drm_info = player_sample_info.drm_info;

auto input_buffer = new InputBuffer(StubDeallocateSampleFunc, nullptr,
nullptr, enhanced_audio_sample_info);
#endif // SB_API_VERSION >= 15
return input_buffer;
}

Expand Down
Loading

0 comments on commit 0b3b54a

Please sign in to comment.