diff --git a/cobalt/browser/user_agent_platform_info.cc b/cobalt/browser/user_agent_platform_info.cc index 380aec7c7ea8..5c0d65895531 100644 --- a/cobalt/browser/user_agent_platform_info.cc +++ b/cobalt/browser/user_agent_platform_info.cc @@ -395,7 +395,11 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) { info.set_original_design_manufacturer(input.second); LOG(INFO) << "Set original design manufacturer to " << input.second; } else if (!input.first.compare("device_type")) { +#if SB_API_VERSION < 15 + info.set_device_type(GetDeviceType(input.second)); +#else info.set_device_type(input.second); +#endif LOG(INFO) << "Set device type to " << input.second; } else if (!input.first.compare("chipset_model_number")) { info.set_chipset_model_number(input.second); diff --git a/cobalt/dom/html_media_element.cc b/cobalt/dom/html_media_element.cc index e811bfcd6440..6aa4a1713616 100644 --- a/cobalt/dom/html_media_element.cc +++ b/cobalt/dom/html_media_element.cc @@ -706,12 +706,16 @@ void HTMLMediaElement::ScheduleEvent(const scoped_refptr& event) { } std::string HTMLMediaElement::h5vcc_audio_connectors() const { +#if SB_API_VERSION >= 15 if (!player_) { return ""; } std::vector configs = player_->GetAudioConnectors(); return base::JoinString(configs, ";"); +#else // SB_API_VERSION >= 15 + return ""; +#endif // SB_API_VERSION >= 15 } void HTMLMediaElement::CreateMediaPlayer() { diff --git a/cobalt/dom/keyboard_event.cc b/cobalt/dom/keyboard_event.cc index 37cda49e9a7d..ad854118b1db 100644 --- a/cobalt/dom/keyboard_event.cc +++ b/cobalt/dom/keyboard_event.cc @@ -337,8 +337,10 @@ std::string KeyboardEvent::NonPrintableKey(int32_t key_code) const { return "MediaStop"; case keycode::kMediaPlayPause: return "MediaPlayPause"; +#if SB_API_VERSION >= 15 case keycode::kMediaRecord: return "MediaRecord"; +#endif case keycode::kMediaLaunchMail: return "LaunchMail"; case keycode::kMediaLaunchMediaSelect: diff --git a/cobalt/dom/keyboard_event_test.cc b/cobalt/dom/keyboard_event_test.cc index c189ccc1ddc4..0f9843e72881 100644 --- a/cobalt/dom/keyboard_event_test.cc +++ b/cobalt/dom/keyboard_event_test.cc @@ -135,12 +135,14 @@ TEST_F(KeyboardEventTest, CanGetKeyIdentifierAndKeyAndCode) { EXPECT_EQ(keyboard_event_space->key(), " "); EXPECT_EQ(keyboard_event_space->code(), "Space"); +#if SB_API_VERSION >= 15 init.set_key_code(keycode::kMediaRecord); scoped_refptr keyboard_event_record = new KeyboardEvent("keydown", init); EXPECT_EQ(keyboard_event_record->key_identifier(), "MediaRecord"); EXPECT_EQ(keyboard_event_record->key(), "MediaRecord"); EXPECT_EQ(keyboard_event_record->code(), "MediaRecord"); +#endif } TEST_F(KeyboardEventTest, CanGetAltKey) { diff --git a/cobalt/dom/keycode.h b/cobalt/dom/keycode.h index 5623e52f745b..afda18fa6df4 100644 --- a/cobalt/dom/keycode.h +++ b/cobalt/dom/keycode.h @@ -200,7 +200,9 @@ enum { // Not present in Windows virtual key codes, but would be used by the client. kMediaRewind = 0xE3, kMediaFastForward = 0xE4, +#if SB_API_VERSION >= 15 kMediaRecord = 0x1A0, +#endif }; } // namespace keycode diff --git a/cobalt/extension/configuration.h b/cobalt/extension/configuration.h new file mode 100644 index 000000000000..36f5ae456cf6 --- /dev/null +++ b/cobalt/extension/configuration.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_CONFIGURATION_H_ +#define COBALT_EXTENSION_CONFIGURATION_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/configuration.h" +#else +#error "Extensions have moved, please see CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_CONFIGURATION_H_ diff --git a/cobalt/extension/crash_handler.h b/cobalt/extension/crash_handler.h new file mode 100644 index 000000000000..628c27eea1dd --- /dev/null +++ b/cobalt/extension/crash_handler.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_CRASH_HANDLER_H_ +#define COBALT_EXTENSION_CRASH_HANDLER_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/crash_handler.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_CRASH_HANDLER_H_ diff --git a/cobalt/extension/demuxer.h b/cobalt/extension/demuxer.h new file mode 100644 index 000000000000..96e210b6fe15 --- /dev/null +++ b/cobalt/extension/demuxer.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_DEMUXER_H_ +#define COBALT_EXTENSION_DEMUXER_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/demuxer.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_DEMUXER_H_ diff --git a/cobalt/extension/font.h b/cobalt/extension/font.h new file mode 100644 index 000000000000..6eaac679eaac --- /dev/null +++ b/cobalt/extension/font.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_FONT_H_ +#define COBALT_EXTENSION_FONT_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/font.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_FONT_H_ diff --git a/cobalt/extension/free_space.h b/cobalt/extension/free_space.h new file mode 100644 index 000000000000..856cf17cab39 --- /dev/null +++ b/cobalt/extension/free_space.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_FREE_SPACE_H_ +#define COBALT_EXTENSION_FREE_SPACE_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/free_space.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_FREE_SPACE_H_ diff --git a/cobalt/extension/graphics.h b/cobalt/extension/graphics.h new file mode 100644 index 000000000000..e7943c942822 --- /dev/null +++ b/cobalt/extension/graphics.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_GRAPHICS_H_ +#define COBALT_EXTENSION_GRAPHICS_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/graphics.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_GRAPHICS_H_ diff --git a/cobalt/extension/installation_manager.h b/cobalt/extension/installation_manager.h new file mode 100644 index 000000000000..97a07579efe5 --- /dev/null +++ b/cobalt/extension/installation_manager.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_INSTALLATION_MANAGER_H_ +#define COBALT_EXTENSION_INSTALLATION_MANAGER_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/installation_manager.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_INSTALLATION_MANAGER_H_ diff --git a/cobalt/extension/javascript_cache.h b/cobalt/extension/javascript_cache.h new file mode 100644 index 000000000000..ef58a742b751 --- /dev/null +++ b/cobalt/extension/javascript_cache.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_JAVASCRIPT_CACHE_H_ +#define COBALT_EXTENSION_JAVASCRIPT_CACHE_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/javascript_cache.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_JAVASCRIPT_CACHE_H_ diff --git a/cobalt/extension/media_session.h b/cobalt/extension/media_session.h new file mode 100644 index 000000000000..1aebd300b75d --- /dev/null +++ b/cobalt/extension/media_session.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_MEDIA_SESSION_H_ +#define COBALT_EXTENSION_MEDIA_SESSION_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/media_session.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_MEDIA_SESSION_H_ diff --git a/cobalt/extension/memory_mapped_file.h b/cobalt/extension/memory_mapped_file.h new file mode 100644 index 000000000000..c5ac54c3c517 --- /dev/null +++ b/cobalt/extension/memory_mapped_file.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_MEMORY_MAPPED_FILE_H_ +#define COBALT_EXTENSION_MEMORY_MAPPED_FILE_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/memory_mapped_file.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_MEMORY_MAPPED_FILE_H_ diff --git a/cobalt/extension/platform_service.h b/cobalt/extension/platform_service.h new file mode 100644 index 000000000000..fca88ef9aef9 --- /dev/null +++ b/cobalt/extension/platform_service.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_PLATFORM_SERVICE_H_ +#define COBALT_EXTENSION_PLATFORM_SERVICE_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/platform_service.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_PLATFORM_SERVICE_H_ diff --git a/cobalt/extension/updater_notification.h b/cobalt/extension/updater_notification.h new file mode 100644 index 000000000000..e56e77dae826 --- /dev/null +++ b/cobalt/extension/updater_notification.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_UPDATER_NOTIFICATION_H_ +#define COBALT_EXTENSION_UPDATER_NOTIFICATION_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/updater_notification.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_UPDATER_NOTIFICATION_H_ diff --git a/cobalt/extension/url_fetcher_observer.h b/cobalt/extension/url_fetcher_observer.h new file mode 100644 index 000000000000..65619d3bbc31 --- /dev/null +++ b/cobalt/extension/url_fetcher_observer.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef COBALT_EXTENSION_URL_FETCHER_OBSERVER_H_ +#define COBALT_EXTENSION_URL_FETCHER_OBSERVER_H_ + +#if SB_API_VERSION <= 14 +#include "starboard/extension/url_fetcher_observer.h" +#else +#error "Extensions have moved, please see Starboard CHANGELOG for details." +#endif + +#endif // COBALT_EXTENSION_URL_FETCHER_OBSERVER_H_ diff --git a/cobalt/media/base/sbplayer_bridge.cc b/cobalt/media/base/sbplayer_bridge.cc index 4c6831837fb7..3d0305fb7fff 100644 --- a/cobalt/media/base/sbplayer_bridge.cc +++ b/cobalt/media/base/sbplayer_bridge.cc @@ -73,7 +73,11 @@ void SetStreamInfo(const SbMediaAudioStreamInfo& stream_info, SbMediaAudioSampleInfo* sample_info) { DCHECK(sample_info); +#if SB_API_VERSION >= 15 sample_info->stream_info = stream_info; +#else // SB_API_VERSION >= 15 + *sample_info = stream_info; +#endif // SB_API_VERSION >= 15} } void SetStreamInfo( @@ -93,7 +97,11 @@ void SetStreamInfo(const SbMediaVideoStreamInfo& stream_info, SbMediaVideoSampleInfo* sample_info) { DCHECK(sample_info); +#if SB_API_VERSION >= 15 sample_info->stream_info = stream_info; +#else // SB_API_VERSION >= 15 + *sample_info = stream_info; +#endif // SB_API_VERSION >= 15} } void SetDiscardPadding( @@ -112,10 +120,12 @@ void SetDiscardPadding( SbMediaAudioSampleInfo* sample_info) { DCHECK(sample_info); +#if SB_API_VERSION >= 15 sample_info->discarded_duration_from_front = discard_padding.first.InMicroseconds(); sample_info->discarded_duration_from_back = discard_padding.second.InMicroseconds(); +#endif // SB_API_VERSION >= 15} } } // namespace @@ -457,6 +467,7 @@ void SbPlayerBridge::GetInfo(uint32* video_frames_decoded, GetInfo_Locked(video_frames_decoded, video_frames_dropped, media_time); } +#if SB_API_VERSION >= 15 std::vector SbPlayerBridge::GetAudioConfigurations() { base::AutoLock auto_lock(lock_); @@ -485,6 +496,7 @@ SbPlayerBridge::GetAudioConfigurations() { return configurations; } +#endif // SB_API_VERSION >= 15 #if SB_HAS(PLAYER_WITH_URL) void SbPlayerBridge::GetUrlPlayerBufferedTimeRanges( @@ -748,13 +760,22 @@ void SbPlayerBridge::CreatePlayer() { SbPlayerCreationParam creation_param = {}; creation_param.drm_system = drm_system_; +#if SB_API_VERSION >= 15 creation_param.audio_stream_info = audio_stream_info_; creation_param.video_stream_info = video_stream_info_; +#else // SB_API_VERSION >= 15 + creation_param.audio_sample_info = audio_stream_info_; + creation_param.video_sample_info = video_stream_info_; +#endif // SB_API_VERSION >= 15 // TODO: This is temporary for supporting background media playback. // Need to be removed with media refactor. if (!is_visible) { +#if SB_API_VERSION >= 15 creation_param.video_stream_info.codec = kSbMediaVideoCodecNone; +#else // SB_API_VERSION >= 15 + creation_param.video_sample_info.codec = kSbMediaVideoCodecNone; +#endif // SB_API_VERSION >= 15 } creation_param.output_mode = output_mode_; DCHECK_EQ(sbplayer_interface_->GetPreferredOutputMode(&creation_param), @@ -1239,8 +1260,13 @@ SbPlayerOutputMode SbPlayerBridge::ComputeSbPlayerOutputMode( SbPlayerCreationParam creation_param = {}; creation_param.drm_system = drm_system_; +#if SB_API_VERSION >= 15 creation_param.audio_stream_info = audio_stream_info_; creation_param.video_stream_info = video_stream_info_; +#else // SB_API_VERSION >= 15 + creation_param.audio_sample_info = audio_stream_info_; + creation_param.video_sample_info = video_stream_info_; +#endif // SB_API_VERSION >= 15 if (default_output_mode != kSbPlayerOutputModeDecodeToTexture && video_stream_info_.codec != kSbMediaVideoCodecNone) { diff --git a/cobalt/media/base/sbplayer_bridge.h b/cobalt/media/base/sbplayer_bridge.h index 98ab7fdf4ba8..f6cc6879c12b 100644 --- a/cobalt/media/base/sbplayer_bridge.h +++ b/cobalt/media/base/sbplayer_bridge.h @@ -118,7 +118,9 @@ class SbPlayerBridge { void SetPlaybackRate(double playback_rate); void GetInfo(uint32* video_frames_decoded, uint32* video_frames_dropped, base::TimeDelta* media_time); +#if SB_API_VERSION >= 15 std::vector GetAudioConfigurations(); +#endif // SB_API_VERSION >= 15 #if SB_HAS(PLAYER_WITH_URL) void GetUrlPlayerBufferedTimeRanges(base::TimeDelta* buffer_start_time, diff --git a/cobalt/media/base/sbplayer_interface.cc b/cobalt/media/base/sbplayer_interface.cc index 217441f5e596..ec7b76d1acc1 100644 --- a/cobalt/media/base/sbplayer_interface.cc +++ b/cobalt/media/base/sbplayer_interface.cc @@ -194,11 +194,15 @@ void DefaultSbPlayerInterface::GetUrlPlayerExtraInfo( } #endif // SB_HAS(PLAYER_WITH_URL) +#if SB_API_VERSION >= 15 + bool DefaultSbPlayerInterface::GetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration) { return SbPlayerGetAudioConfiguration(player, index, out_audio_configuration); } +#endif // SB_API_VERSION >= 15 + } // namespace media } // namespace cobalt diff --git a/cobalt/media/base/sbplayer_interface.h b/cobalt/media/base/sbplayer_interface.h index cef271c5c53d..4aba0395eaa0 100644 --- a/cobalt/media/base/sbplayer_interface.h +++ b/cobalt/media/base/sbplayer_interface.h @@ -84,9 +84,11 @@ class SbPlayerInterface { SbPlayer player, SbUrlPlayerExtraInfo* out_url_player_info) = 0; #endif // SB_HAS(PLAYER_WITH_URL) +#if SB_API_VERSION >= 15 virtual bool GetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration) = 0; +#endif // SB_API_VERSION >= 15 // disabled by default, but can be enabled via h5vcc setting. void EnableCValStats(bool should_enable) { @@ -149,9 +151,11 @@ class DefaultSbPlayerInterface final : public SbPlayerInterface { SbPlayer player, SbUrlPlayerExtraInfo* out_url_player_info) override; #endif // SB_HAS(PLAYER_WITH_URL) +#if SB_API_VERSION >= 15 bool GetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration) override; +#endif // SB_API_VERSION >= 15 private: void (*enhanced_audio_player_write_samples_)( diff --git a/cobalt/media/base/sbplayer_pipeline.cc b/cobalt/media/base/sbplayer_pipeline.cc index 7b69fd52fde3..12efde9c12e1 100644 --- a/cobalt/media/base/sbplayer_pipeline.cc +++ b/cobalt/media/base/sbplayer_pipeline.cc @@ -59,6 +59,7 @@ const int kPrerollGuardAudioBuffer = 1; unsigned int g_pipeline_identifier_counter = 0; +#if SB_API_VERSION >= 15 bool HasRemoteAudioOutputs( const std::vector& configurations) { for (auto&& configuration : configurations) { @@ -87,6 +88,7 @@ bool HasRemoteAudioOutputs( return false; } +#endif // SB_API_VERSION >= 15 // The function adjusts audio write duration proportionally to the playback // rate, when the playback rate is greater than 1.0. @@ -133,9 +135,11 @@ SbPlayerPipeline::SbPlayerPipeline( const GetDecodeTargetGraphicsContextProviderFunc& get_decode_target_graphics_context_provider_func, bool allow_resume_after_suspend, int max_audio_samples_per_write, - bool force_punch_out_by_default, TimeDelta audio_write_duration_local, - TimeDelta audio_write_duration_remote, MediaLog* media_log, - MediaMetricsProvider* media_metrics_provider, + bool force_punch_out_by_default, +#if SB_API_VERSION >= 15 + TimeDelta audio_write_duration_local, TimeDelta audio_write_duration_remote, +#endif // SB_API_VERSION >= 15 + MediaLog* media_log, MediaMetricsProvider* media_metrics_provider, DecodeTargetProvider* decode_target_provider) : pipeline_identifier_( base::StringPrintf("%X", g_pipeline_identifier_counter++)), @@ -177,8 +181,10 @@ SbPlayerPipeline::SbPlayerPipeline( kSbPlayerStateInitialized, "The underlying SbPlayer state of the media pipeline."), decode_target_provider_(decode_target_provider), +#if SB_API_VERSION >= 15 audio_write_duration_local_(audio_write_duration_local), audio_write_duration_remote_(audio_write_duration_remote), +#endif // SB_API_VERSION >= 15 media_metrics_provider_(media_metrics_provider), last_media_time_(base::StringPrintf("Media.Pipeline.%s.LastMediaTime", pipeline_identifier_.c_str()), @@ -196,7 +202,6 @@ SbPlayerPipeline::SbPlayerPipeline( SbPlayerPipeline::~SbPlayerPipeline() { DCHECK(!player_bridge_); } - void SbPlayerPipeline::Suspend() { DCHECK(!task_runner_->RunsTasksInCurrentSequence()); @@ -580,6 +585,7 @@ void SbPlayerPipeline::GetNaturalVideoSize(gfx::Size* out_size) const { } std::vector SbPlayerPipeline::GetAudioConnectors() const { +#if SB_API_VERSION >= 15 base::AutoLock auto_lock(lock_); if (!player_bridge_) { return std::vector(); @@ -600,6 +606,9 @@ std::vector SbPlayerPipeline::GetAudioConnectors() const { } return connectors; +#else // SB_API_VERSION >= 15 + return std::vector(); +#endif // SB_API_VERSION >= 15 } bool SbPlayerPipeline::DidLoadingProgress() const { @@ -859,6 +868,7 @@ void SbPlayerPipeline::CreatePlayer(SbDrmSystem drm_system) { default_output_mode_, decode_target_provider_, max_video_capabilities_, max_video_input_size_, pipeline_identifier_)); if (player_bridge_->IsValid()) { +#if SB_API_VERSION >= 15 // TODO(b/267678497): When `player_bridge_->GetAudioConfigurations()` // returns no audio configurations, update the write durations again // before the SbPlayer reaches `kSbPlayerStatePresenting`. @@ -868,6 +878,7 @@ void SbPlayerPipeline::CreatePlayer(SbDrmSystem drm_system) { : audio_write_duration_local_; LOG(INFO) << "SbPlayerBridge created, with audio write duration at " << audio_write_duration_for_preroll_; +#endif // SB_API_VERSION >= 15 SetPlaybackRateTask(playback_rate_); SetVolumeTask(volume_); @@ -1301,12 +1312,14 @@ void SbPlayerPipeline::OnPlayerStatus(SbPlayerState state) { } #endif // SB_HAS(PLAYER_WITH_URL) +#if SB_API_VERSION >= 15 audio_write_duration_for_preroll_ = audio_write_duration_ = HasRemoteAudioOutputs(player_bridge_->GetAudioConfigurations()) ? audio_write_duration_remote_ : audio_write_duration_local_; LOG(INFO) << "SbPlayerBridge reaches kSbPlayerStatePresenting, with audio" << " write duration at " << audio_write_duration_; +#endif // SB_API_VERSION >= 15 break; } case kSbPlayerStateEndOfStream: diff --git a/cobalt/media/base/sbplayer_pipeline.h b/cobalt/media/base/sbplayer_pipeline.h index 419a3f9d158f..a8c0cabe7e41 100644 --- a/cobalt/media/base/sbplayer_pipeline.h +++ b/cobalt/media/base/sbplayer_pipeline.h @@ -65,13 +65,15 @@ class MEDIA_EXPORT SbPlayerPipeline : public Pipeline, bool allow_resume_after_suspend, int max_audio_samples_per_write, bool force_punch_out_by_default, +#if SB_API_VERSION >= 15 TimeDelta audio_write_duration_local, - TimeDelta audio_write_duration_remote, MediaLog* media_log, + TimeDelta audio_write_duration_remote, +#endif // SB_API_VERSION >= 15 + MediaLog* media_log, MediaMetricsProvider* media_metrics_provider, DecodeTargetProvider* decode_target_provider); ~SbPlayerPipeline() override; - void Suspend() override; // TODO: This is temporary for supporting background media playback. // Need to be removed with media refactor. @@ -323,6 +325,7 @@ class MEDIA_EXPORT SbPlayerPipeline : public Pipeline, DecodeTargetProvider* decode_target_provider_; +#if SB_API_VERSION >= 15 const TimeDelta audio_write_duration_local_; const TimeDelta audio_write_duration_remote_; @@ -331,6 +334,16 @@ class MEDIA_EXPORT SbPlayerPipeline : public Pipeline, // is, which simplifies the implementation across multiple Starboard versions. TimeDelta audio_write_duration_; TimeDelta audio_write_duration_for_preroll_ = audio_write_duration_; +#else // SB_API_VERSION >= 15 + // Read audio from the stream if |timestamp_of_last_written_audio_| is less + // than |seek_time_| + |audio_write_duration_for_preroll_|, this effectively + // allows 10 seconds of audio to be written to the SbPlayer after playback + // startup or seek. + TimeDelta audio_write_duration_for_preroll_ = TimeDelta::FromSeconds(10); + // Don't read audio from the stream more than |audio_write_duration_| ahead of + // the current media time during playing. + TimeDelta audio_write_duration_ = TimeDelta::FromSeconds(1); +#endif // SB_API_VERSION >= 15 // Only call GetMediaTime() from OnNeedData if it has been // |kMediaTimeCheckInterval| since the last call to GetMediaTime(). static constexpr TimeDelta kMediaTimeCheckInterval = diff --git a/cobalt/media/media_module.cc b/cobalt/media/media_module.cc index 4092416b25aa..f245ac43a9e3 100644 --- a/cobalt/media/media_module.cc +++ b/cobalt/media/media_module.cc @@ -200,6 +200,7 @@ bool MediaModule::SetConfiguration(const std::string& name, int32 value) { LOG(INFO) << (value ? "Enabling" : "Disabling") << " media metrics collection."; return true; +#if SB_API_VERSION >= 15 } else if (name == "AudioWriteDurationLocal" && value > 0) { audio_write_duration_local_ = base::TimeDelta::FromMicroseconds(value); LOG(INFO) << "Set AudioWriteDurationLocal to " @@ -210,14 +211,13 @@ bool MediaModule::SetConfiguration(const std::string& name, int32 value) { LOG(INFO) << "Set AudioWriteDurationRemote to " << audio_write_duration_remote_.InMicroseconds(); return true; +#endif // SB_API_VERSION >= 15 } else if (name == "PlayerConfiguration.DecodeToTexturePreferred") { if (sbplayer_interface_->SetDecodeToTexturePreferred(value)) { LOG(INFO) << "Set DecodeToTexturePreferred to " << (value ? "true" : "false"); return true; } - - } else if (name == "AsyncReleaseMediaCodecBridge") { const StarboardExtensionMediaSettingsApi* media_settings_api = static_cast( @@ -265,7 +265,10 @@ std::unique_ptr MediaModule::CreateWebMediaPlayer( base::Unretained(this)), client, this, options_.allow_resume_after_suspend, max_audio_samples_per_write_, force_punch_out_by_default_, - audio_write_duration_local_, audio_write_duration_remote_, &media_log_)); +#if SB_API_VERSION >= 15 + audio_write_duration_local_, audio_write_duration_remote_, +#endif // SB_API_VERSION >= 15 + &media_log_)); } void MediaModule::Suspend() { diff --git a/cobalt/media/media_module.h b/cobalt/media/media_module.h index 591e95474345..f29973a1f615 100644 --- a/cobalt/media/media_module.h +++ b/cobalt/media/media_module.h @@ -133,10 +133,12 @@ class MediaModule : public WebMediaPlayerFactory, // previous behavior. bool force_punch_out_by_default_ = false; +#if SB_API_VERSION >= 15 base::TimeDelta audio_write_duration_local_ = base::TimeDelta::FromMicroseconds(kSbPlayerWriteDurationLocal); base::TimeDelta audio_write_duration_remote_ = base::TimeDelta::FromMicroseconds(kSbPlayerWriteDurationRemote); +#endif // SB_API_VERSION >= 15 DecoderBufferAllocator decoder_buffer_allocator_; }; diff --git a/cobalt/media/player/web_media_player_impl.cc b/cobalt/media/player/web_media_player_impl.cc index 92af6fed21f4..62189b7b3061 100644 --- a/cobalt/media/player/web_media_player_impl.cc +++ b/cobalt/media/player/web_media_player_impl.cc @@ -104,15 +104,17 @@ typedef base::Callback, int)> OnNeedKeyCB; - WebMediaPlayerImpl::WebMediaPlayerImpl( SbPlayerInterface* interface, PipelineWindow window, const Pipeline::GetDecodeTargetGraphicsContextProviderFunc& get_decode_target_graphics_context_provider_func, WebMediaPlayerClient* client, WebMediaPlayerDelegate* delegate, bool allow_resume_after_suspend, int max_audio_samples_per_write, - bool force_punch_out_by_default, base::TimeDelta audio_write_duration_local, + bool force_punch_out_by_default, +#if SB_API_VERSION >= 15 + base::TimeDelta audio_write_duration_local, base::TimeDelta audio_write_duration_remote, +#endif // SB_API_VERSION >= 15 ::media::MediaLog* const media_log) : pipeline_thread_("media_pipeline"), network_state_(WebMediaPlayer::kNetworkStateEmpty), @@ -142,9 +144,11 @@ WebMediaPlayerImpl::WebMediaPlayerImpl( interface, window, pipeline_thread_.task_runner(), get_decode_target_graphics_context_provider_func, allow_resume_after_suspend_, max_audio_samples_per_write_, - force_punch_out_by_default_, audio_write_duration_local, - audio_write_duration_remote, media_log_, &media_metrics_provider_, - decode_target_provider_.get()); + force_punch_out_by_default_, +#if SB_API_VERSION >= 15 + audio_write_duration_local, audio_write_duration_remote, +#endif // SB_API_VERSION >= 15 + media_log_, &media_metrics_provider_, decode_target_provider_.get()); // Also we want to be notified of thread destruction. base::CurrentThread::Get()->AddDestructionObserver(this); diff --git a/cobalt/media/player/web_media_player_impl.h b/cobalt/media/player/web_media_player_impl.h index 205080a2f693..6d4c55f39f9c 100644 --- a/cobalt/media/player/web_media_player_impl.h +++ b/cobalt/media/player/web_media_player_impl.h @@ -112,8 +112,10 @@ class WebMediaPlayerImpl : public WebMediaPlayer, bool allow_resume_after_suspend, int max_audio_samples_per_write, bool force_punch_out_by_default, +#if SB_API_VERSION >= 15 base::TimeDelta audio_write_duration_local, base::TimeDelta audio_write_duration_remote, +#endif // SB_API_VERSION >= 15 ::media::MediaLog* const media_log); ~WebMediaPlayerImpl() override; diff --git a/media/base/starboard_utils.cc b/media/base/starboard_utils.cc index efa5411d9b10..9c3adabdf1f6 100644 --- a/media/base/starboard_utils.cc +++ b/media/base/starboard_utils.cc @@ -75,8 +75,10 @@ SbMediaAudioCodec MediaAudioCodecToSbMediaAudioCodec(AudioCodec codec) { return kSbMediaAudioCodecFlac; case AudioCodec::kPCM: return kSbMediaAudioCodecPcm; +#if SB_API_VERSION >= 15 case AudioCodec::kIAMF: return kSbMediaAudioCodecIamf; +#endif // SB_API_VERSION >= 15 default: // Cobalt only supports a subset of audio codecs defined by Chromium. DLOG(ERROR) << "Unsupported audio codec " << GetCodecName(codec); @@ -124,10 +126,17 @@ SbMediaAudioStreamInfo MediaAudioConfigToSbMediaAudioStreamInfo( MediaAudioCodecToSbMediaAudioCodec(audio_decoder_config.codec()); audio_stream_info.mime = mime_type; +#if SB_API_VERSION < 15 + audio_stream_info.format_tag = 0x00ff; +#endif // SB_API_VERSION < 15 audio_stream_info.number_of_channels = ChannelLayoutToChannelCount(audio_decoder_config.channel_layout()); audio_stream_info.samples_per_second = audio_decoder_config.samples_per_second(); +#if SB_API_VERSION < 15 + audio_stream_info.average_bytes_per_second = 1; + audio_stream_info.block_alignment = 4; +#endif // SB_API_VERSION < 15 audio_stream_info.bits_per_sample = audio_decoder_config.bits_per_channel(); const auto& extra_data = audio_stream_info.codec == kSbMediaAudioCodecAac diff --git a/starboard/android/shared/android_main.cc b/starboard/android/shared/android_main.cc index d091b0bf5f53..68f2ed249715 100644 --- a/starboard/android/shared/android_main.cc +++ b/starboard/android/shared/android_main.cc @@ -239,8 +239,36 @@ void* ThreadEntryPoint(void* context) { pthread_setname_np(pthread_self(), "StarboardMain"); g_app_created_semaphore = static_cast(context); +#if SB_API_VERSION >= 15 int unused_value = -1; int error_level = SbRunStarboardMain(unused_value, nullptr, SbEventHandle); +#else + ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); + ApplicationAndroid app(looper); + + CommandLine command_line(GetArgs()); + LogInit(command_line); + +#if SB_IS(EVERGREEN_COMPATIBLE) + InstallCrashpadHandler(command_line); +#endif // SB_IS(EVERGREEN_COMPATIBLE) + + // Mark the app running before signaling app created so there's no race to + // allow sending the first AndroidCommand after onCreate() returns. + g_app_running.store(true); + + // Signal GameActivity_onCreate() that it may proceed. + g_app_created_semaphore->Put(); + + // Enter the Starboard run loop until stopped. + int error_level = + app.Run(std::move(command_line), GetStartDeepLink().c_str()); + + // Mark the app not running before informing StarboardBridge that the app is + // stopped so that we won't send any more AndroidCommands as a result of + // shutting down the Activity. + g_app_running.store(false); +#endif // SB_API_VERSION >= 15 // Our launcher.py looks for this to know when the app (test) is done. SB_LOG(INFO) << "***Application Stopped*** " << error_level; @@ -388,6 +416,7 @@ Java_dev_cobalt_coat_VolumeStateReceiver_nativeMuteChanged(JNIEnv* env, } // namespace +#if SB_API_VERSION >= 15 extern "C" int SbRunStarboardMain(int argc, char** argv, SbEventHandleCallback callback) { @@ -419,6 +448,8 @@ extern "C" int SbRunStarboardMain(int argc, return error_level; } +#endif // SB_API_VERSION >= 15 + } // namespace shared } // namespace android } // namespace starboard diff --git a/starboard/android/shared/application_android.cc b/starboard/android/shared/application_android.cc index d040ca4cdb0e..820b339d6f45 100644 --- a/starboard/android/shared/application_android.cc +++ b/starboard/android/shared/application_android.cc @@ -98,9 +98,13 @@ int64_t GetAppStartTimestamp() { // "using" doesn't work with class members, so make a local convenience type. typedef ::starboard::shared::starboard::Application::Event Event; +#if SB_API_VERSION >= 15 ApplicationAndroid::ApplicationAndroid( ALooper* looper, SbEventHandleCallback sb_event_handle_callback) +#else +ApplicationAndroid::ApplicationAndroid(ALooper* looper) +#endif // SB_API_VERSION >= 15 : looper_(looper), native_window_(NULL), android_command_readfd_(-1), @@ -110,7 +114,9 @@ ApplicationAndroid::ApplicationAndroid( android_command_condition_(android_command_mutex_), activity_state_(AndroidCommand::kUndefined), window_(kSbWindowInvalid), +#if SB_API_VERSION >= 15 QueueApplication(sb_event_handle_callback), +#endif // SB_API_VERSION >= 15 last_is_accessibility_high_contrast_text_enabled_(false) { handle_system_events_.store(true); // Initialize Time Zone early so that local time works correctly. diff --git a/starboard/android/shared/application_android.h b/starboard/android/shared/application_android.h index aa372bba92f2..3abb860892dc 100644 --- a/starboard/android/shared/application_android.h +++ b/starboard/android/shared/application_android.h @@ -61,8 +61,12 @@ class ApplicationAndroid void* data = nullptr; }; +#if SB_API_VERSION >= 15 ApplicationAndroid(ALooper* looper, SbEventHandleCallback sb_event_handle_callback); +#else + explicit ApplicationAndroid(ALooper* looper); +#endif // SB_API_VERSION >= 15 ~ApplicationAndroid() override; static ApplicationAndroid* Get() { diff --git a/starboard/android/shared/audio_track_audio_sink_type.cc b/starboard/android/shared/audio_track_audio_sink_type.cc index 4af3a1751f18..3a92470983b8 100644 --- a/starboard/android/shared/audio_track_audio_sink_type.cc +++ b/starboard/android/shared/audio_track_audio_sink_type.cc @@ -74,6 +74,7 @@ int GetMaxFramesPerRequestForTunnelMode(int sampling_frequency_hz) { } bool HasRemoteAudioOutput() { +#if SB_API_VERSION >= 15 // SbPlayerBridge::GetAudioConfigurations() reads up to 32 configurations. The // limit here is to avoid infinite loop and also match // SbPlayerBridge::GetAudioConfigurations(). @@ -100,6 +101,8 @@ bool HasRemoteAudioOutput() { index++; } return false; +#endif // SB_API_VERSION >= 15 + return false; } } // namespace diff --git a/starboard/android/shared/input_events_generator.cc b/starboard/android/shared/input_events_generator.cc index be0ec9334262..aed501be42c6 100644 --- a/starboard/android/shared/input_events_generator.cc +++ b/starboard/android/shared/input_events_generator.cc @@ -232,8 +232,10 @@ SbKey AInputEventToSbKey(GameActivityKeyEvent* event) { return kSbKeyMediaRewind; case AKEYCODE_MEDIA_FAST_FORWARD: return kSbKeyMediaFastForward; +#if SB_API_VERSION >= 15 case AKEYCODE_MEDIA_RECORD: return kSbKeyRecord; +#endif // TV Remote specific case AKEYCODE_CHANNEL_UP: diff --git a/starboard/android/shared/media_capabilities_cache.cc b/starboard/android/shared/media_capabilities_cache.cc index 10e2d1998d84..19d5c71d7111 100644 --- a/starboard/android/shared/media_capabilities_cache.cc +++ b/starboard/android/shared/media_capabilities_cache.cc @@ -74,6 +74,7 @@ constexpr int TYPE_USB_HEADSET = 22; constexpr int TYPE_WIRED_HEADPHONES = 4; constexpr int TYPE_WIRED_HEADSET = 3; +#if SB_API_VERSION >= 15 SbMediaAudioConnector GetConnectorFromAndroidOutputType( int android_output_device_type) { switch (android_output_device_type) { @@ -145,6 +146,7 @@ SbMediaAudioConnector GetConnectorFromAndroidOutputType( << android_output_device_type; return kSbMediaAudioConnectorUnknown; } +#endif // SB_API_VERSION >= 15 bool EndsWith(const std::string& str, const std::string& suffix) { if (str.size() < suffix.size()) { @@ -267,8 +269,12 @@ bool GetAudioConfiguration(int index, return env->CallIntMethodOrAbort(j_output_device_info.Get(), name, "()I"); }; +#if SB_API_VERSION >= 15 configuration->connector = GetConnectorFromAndroidOutputType(call_int_method("getType")); +#else // SB_API_VERSION >= 15 + configuration->connector = kSbMediaAudioConnectorHdmi; +#endif // SB_API_VERSION >= 15 configuration->latency = 0; configuration->coding_type = kSbMediaAudioCodingTypePcm; configuration->number_of_channels = call_int_method("getChannels"); diff --git a/starboard/android/shared/player_create.cc b/starboard/android/shared/player_create.cc index bcd827a675dd..78b4ba46f252 100644 --- a/starboard/android/shared/player_create.cc +++ b/starboard/android/shared/player_create.cc @@ -53,10 +53,17 @@ SbPlayer SbPlayerCreate(SbWindow window, return kSbPlayerInvalid; } +#if SB_API_VERSION >= 15 const SbMediaAudioStreamInfo& audio_stream_info = creation_param->audio_stream_info; const SbMediaVideoStreamInfo& video_stream_info = creation_param->video_stream_info; +#else // SB_API_VERSION >= 15 + const SbMediaAudioSampleInfo& audio_stream_info = + creation_param->audio_sample_info; + const SbMediaVideoSampleInfo& video_stream_info = + creation_param->video_sample_info; +#endif // SB_API_VERSION >= 15 bool has_audio = audio_stream_info.codec != kSbMediaAudioCodecNone; bool has_video = video_stream_info.codec != kSbMediaVideoCodecNone; diff --git a/starboard/android/shared/player_get_preferred_output_mode.cc b/starboard/android/shared/player_get_preferred_output_mode.cc index f32d63712881..185f8e1bd3dd 100644 --- a/starboard/android/shared/player_get_preferred_output_mode.cc +++ b/starboard/android/shared/player_get_preferred_output_mode.cc @@ -30,10 +30,17 @@ SbPlayerOutputMode SbPlayerGetPreferredOutputMode( return kSbPlayerOutputModeInvalid; } +#if SB_API_VERSION >= 15 const SbMediaAudioStreamInfo& audio_stream_info = creation_param->audio_stream_info; const SbMediaVideoStreamInfo& video_stream_info = creation_param->video_stream_info; +#else // SB_API_VERSION >= 15 + const SbMediaAudioSampleInfo& audio_stream_info = + creation_param->audio_sample_info; + const SbMediaVideoSampleInfo& video_stream_info = + creation_param->video_sample_info; +#endif // SB_API_VERSION >= 15 if (audio_stream_info.codec != kSbMediaAudioCodecNone && !audio_stream_info.mime) { diff --git a/starboard/android/shared/system_get_property.cc b/starboard/android/shared/system_get_property.cc index 8cf1ccd57df0..3f14106b8362 100644 --- a/starboard/android/shared/system_get_property.cc +++ b/starboard/android/shared/system_get_property.cc @@ -161,9 +161,11 @@ bool SbSystemGetProperty(SbSystemPropertyId property_id, return CopyStringAndTestIfSuccess(out_value, value_length, limit_ad_tracking_enabled ? "1" : "0"); } +#if SB_API_VERSION >= 15 case kSbSystemPropertyDeviceType: return CopyStringAndTestIfSuccess(out_value, value_length, starboard::kSystemDeviceTypeAndroidTV); +#endif default: SB_DLOG(WARNING) << __FUNCTION__ << ": Unrecognized property: " << property_id; diff --git a/starboard/common/media.cc b/starboard/common/media.cc index d1a7294634f1..a7ee8d724c38 100644 --- a/starboard/common/media.cc +++ b/starboard/common/media.cc @@ -597,8 +597,10 @@ const char* GetMediaAudioCodecName(SbMediaAudioCodec codec) { return "flac"; case kSbMediaAudioCodecPcm: return "pcm"; +#if SB_API_VERSION >= 15 case kSbMediaAudioCodecIamf: return "iamf"; +#endif // SB_API_VERSION >= 15 } SB_NOTREACHED(); return "invalid"; @@ -631,22 +633,34 @@ const char* GetMediaVideoCodecName(SbMediaVideoCodec codec) { const char* GetMediaAudioConnectorName(SbMediaAudioConnector connector) { switch (connector) { +#if SB_API_VERSION >= 15 case kSbMediaAudioConnectorUnknown: return "unknown"; +#else // SB_API_VERSION >= 15 + case kSbMediaAudioConnectorNone: + return "none"; +#endif // SB_API_VERSION >= 15 case kSbMediaAudioConnectorAnalog: return "analog"; case kSbMediaAudioConnectorBluetooth: return "bluetooth"; +#if SB_API_VERSION >= 15 case kSbMediaAudioConnectorBuiltIn: return "builtin"; +#endif // SB_API_VERSION >= 15 case kSbMediaAudioConnectorHdmi: return "hdmi"; +#if SB_API_VERSION >= 15 case kSbMediaAudioConnectorRemoteWired: return "remote-wired"; case kSbMediaAudioConnectorRemoteWireless: return "remote-wireless"; case kSbMediaAudioConnectorRemoteOther: return "remote-other"; +#else // SB_API_VERSION >= 15 + case kSbMediaAudioConnectorNetwork: + return "network"; +#endif // SB_API_VERSION >= 15 case kSbMediaAudioConnectorSpdif: return "spdif"; case kSbMediaAudioConnectorUsb: @@ -921,7 +935,11 @@ std::ostream& operator<<(std::ostream& os, const SbMediaVideoSampleInfo& sample_info) { using starboard::GetMediaVideoCodecName; +#if SB_API_VERSION >= 15 const SbMediaVideoStreamInfo& stream_info = sample_info.stream_info; +#else // SB_API_VERSION >= 15 + const SbMediaVideoSampleInfo& stream_info = sample_info; +#endif // SB_API_VERSION >= 15 if (stream_info.codec == kSbMediaVideoCodecNone) { return os; @@ -949,7 +967,11 @@ std::ostream& operator<<(std::ostream& os, using starboard::GetMediaAudioCodecName; using starboard::HexEncode; +#if SB_API_VERSION >= 15 const SbMediaAudioStreamInfo& stream_info = sample_info.stream_info; +#else // SB_API_VERSION >= 15 + const SbMediaAudioSampleInfo& stream_info = sample_info; +#endif // SB_API_VERSION >= 15 if (stream_info.codec == kSbMediaAudioCodecNone) { return os; @@ -971,6 +993,7 @@ std::ostream& operator<<(std::ostream& os, return os; } +#if SB_API_VERSION >= 15 std::ostream& operator<<(std::ostream& os, const SbMediaVideoStreamInfo& stream_info) { using starboard::GetMediaVideoCodecName; @@ -1016,3 +1039,5 @@ std::ostream& operator<<(std::ostream& os, return os; } + +#endif // SB_API_VERSION >= 15 diff --git a/starboard/common/media.h b/starboard/common/media.h index 74b2fb59753b..25fa8283eda3 100644 --- a/starboard/common/media.h +++ b/starboard/common/media.h @@ -65,9 +65,11 @@ std::ostream& operator<<(std::ostream& os, std::ostream& operator<<(std::ostream& os, const SbMediaAudioSampleInfo& sample_info); +#if SB_API_VERSION >= 15 std::ostream& operator<<(std::ostream& os, const SbMediaVideoStreamInfo& stream_info); std::ostream& operator<<(std::ostream& os, const SbMediaAudioStreamInfo& stream_info); +#endif // SB_API_VERSION >= 15 #endif // STARBOARD_COMMON_MEDIA_H_ diff --git a/starboard/event.h b/starboard/event.h index 119a94d72676..b7f245559b3b 100644 --- a/starboard/event.h +++ b/starboard/event.h @@ -345,12 +345,14 @@ static SB_C_FORCE_INLINE bool SbEventIsIdValid(SbEventId handle) { return handle != kSbEventIdInvalid; } +#if SB_API_VERSION >= 15 typedef void (*SbEventHandleCallback)(const SbEvent* event); // Serves as the entry point in the Starboard library for running the Starboard // event loop with the application event handler. SB_EXPORT int SbRunStarboardMain(int argc, char** argv, SbEventHandleCallback callback); +#endif // SB_API_VERSION >= 15 // The entry point that Starboard applications MUST implement. Any memory // pointed at by |event| or the |data| field inside |event| is owned by the // system, and that memory is reclaimed after this function returns, so the @@ -362,7 +364,11 @@ SB_EXPORT int SbRunStarboardMain(int argc, // specification about what other work might happen on this thread, so the // application should generally do as little work as possible on this thread, // and just dispatch it over to another thread. +#if SB_API_VERSION >= 15 SB_EXPORT_PLATFORM void SbEventHandle(const SbEvent* event); +#else +SB_IMPORT void SbEventHandle(const SbEvent* event); +#endif // SB_API_VERSION >= 15 // Schedules an event |callback| into the main Starboard event loop. // This function may be called from any thread, but |callback| is always diff --git a/starboard/extension/enhanced_audio_test.cc b/starboard/extension/enhanced_audio_test.cc index c2c7563aac78..c11598ba7c33 100644 --- a/starboard/extension/enhanced_audio_test.cc +++ b/starboard/extension/enhanced_audio_test.cc @@ -24,6 +24,8 @@ namespace starboard { namespace extension { +#if SB_API_VERSION >= 15 + TEST(EnhancedAudioTest, VerifyBinaryLayouts) { // Sanity check that the layouts of the extension specific types are the same // as corresponding SbMedia and SbPlayer types. @@ -108,5 +110,7 @@ TEST(EnhancedAudioTest, VerifyBinaryLayouts) { offsetof(SbPlayerSampleInfo, drm_info)); } +#endif // SB_API_VERSION >= 15 + } // namespace extension } // namespace starboard diff --git a/starboard/extension/extension_test.cc b/starboard/extension/extension_test.cc index 6b6472e43212..5d320292351f 100644 --- a/starboard/extension/extension_test.cc +++ b/starboard/extension/extension_test.cc @@ -403,6 +403,7 @@ TEST(ExtensionTest, EnhancedAudio) { return; } +#if SB_API_VERSION >= 15 ASSERT_FALSE(extension_api) << "EnhancedAudio extension shouldn't be used under SB_API_VERSION " << SB_API_VERSION @@ -412,6 +413,7 @@ TEST(ExtensionTest, EnhancedAudio) { << " implementation to `SbPlayerWriteSample()` (as they are compatible" << " at abi level) and disable the EnhancedAudio extension from" << " `SbSystemGetExtension()`."; +#endif // SB_API_VERSION >= 15 EXPECT_STREQ(extension_api->name, kExtensionName); EXPECT_EQ(extension_api->version, 1u); diff --git a/starboard/key.h b/starboard/key.h index d71ec2f06e04..a0762f416bba 100644 --- a/starboard/key.h +++ b/starboard/key.h @@ -215,7 +215,9 @@ typedef enum SbKey { kSbKeyYellow = 0x195, kSbKeyBlue = 0x196, +#if SB_API_VERSION >= 15 kSbKeyRecord = 0x1A0, +#endif kSbKeyChannelUp = 0x1AB, kSbKeyChannelDown = 0x1AC, kSbKeySubtitle = 0x1CC, diff --git a/starboard/linux/x64x11/main.cc b/starboard/linux/x64x11/main.cc index 54dd41a96d0b..58137c4e2778 100644 --- a/starboard/linux/x64x11/main.cc +++ b/starboard/linux/x64x11/main.cc @@ -62,7 +62,16 @@ extern "C" SB_EXPORT_PLATFORM int main(int argc, char** argv) { SbLogRawDumpStack(3); #endif +#if SB_API_VERSION >= 15 int result = SbRunStarboardMain(argc, argv, SbEventHandle); +#else + starboard::shared::x11::ApplicationX11 application; + int result = 0; + { + starboard::shared::starboard::LinkReceiver receiver(&application); + result = application.Run(argc, argv); + } +#endif // SB_API_VERSION >= 15 starboard::shared::signal::UninstallSuspendSignalHandlers(); starboard::shared::signal::UninstallDebugSignalHandlers(); starboard::shared::signal::UninstallCrashSignalHandlers(); diff --git a/starboard/linux/x64x11/run_starboard_main.cc b/starboard/linux/x64x11/run_starboard_main.cc index 96b605f96a68..813e1df5716e 100644 --- a/starboard/linux/x64x11/run_starboard_main.cc +++ b/starboard/linux/x64x11/run_starboard_main.cc @@ -17,6 +17,7 @@ #include "starboard/shared/starboard/link_receiver.h" #include "starboard/shared/x11/application_x11.h" +#if SB_API_VERSION >= 15 int SbRunStarboardMain(int argc, char** argv, SbEventHandleCallback callback) { starboard::shared::x11::ApplicationX11 application(callback); int result = 0; @@ -26,3 +27,4 @@ int SbRunStarboardMain(int argc, char** argv, SbEventHandleCallback callback) { } return result; } +#endif // SB_API_VERSION >= 15 diff --git a/starboard/linux/x64x11/system_get_property_impl.cc b/starboard/linux/x64x11/system_get_property_impl.cc index b10471c65ceb..5612b2d7c300 100644 --- a/starboard/linux/x64x11/system_get_property_impl.cc +++ b/starboard/linux/x64x11/system_get_property_impl.cc @@ -129,9 +129,11 @@ bool GetSystemProperty(SbSystemPropertyId property_id, return CopyStringAndTestIfSuccess( out_value, value_length, GetEnvironment("COBALT_LIMIT_AD_TRACKING").c_str()); +#if SB_API_VERSION >= 15 case kSbSystemPropertyDeviceType: return CopyStringAndTestIfSuccess(out_value, value_length, kSystemDeviceTypeDesktopPC); +#endif default: SB_DLOG(WARNING) << __FUNCTION__ << ": Unrecognized property: " << property_id; diff --git a/starboard/media.h b/starboard/media.h index c067426e9247..182e8000e91e 100644 --- a/starboard/media.h +++ b/starboard/media.h @@ -65,7 +65,9 @@ typedef enum SbMediaAudioCodec { kSbMediaAudioCodecMp3, kSbMediaAudioCodecFlac, kSbMediaAudioCodecPcm, +#if SB_API_VERSION >= 15 kSbMediaAudioCodecIamf, +#endif // SB_API_VERSION >= 15 } SbMediaAudioCodec; // Indicates how confident the device is that it can play media resources of the @@ -85,17 +87,28 @@ typedef enum SbMediaSupportType { // Possible audio connector types. typedef enum SbMediaAudioConnector { +#if SB_API_VERSION >= 15 kSbMediaAudioConnectorUnknown, +#else // SB_API_VERSION >= 15 + kSbMediaAudioConnectorNone, +#endif // SB_API_VERSION >= 15 + kSbMediaAudioConnectorAnalog, kSbMediaAudioConnectorBluetooth, +#if SB_API_VERSION >= 15 kSbMediaAudioConnectorBuiltIn, +#endif // SB_API_VERSION >= 15 kSbMediaAudioConnectorHdmi, +#if SB_API_VERSION >= 15 // A wired remote audio output, like a remote speaker via Ethernet. kSbMediaAudioConnectorRemoteWired, // A wireless remote audio output, like a remote speaker via Wi-Fi. kSbMediaAudioConnectorRemoteWireless, // A remote audio output cannot be classified into other existing types. kSbMediaAudioConnectorRemoteOther, +#else // SB_API_VERSION >= 15 + kSbMediaAudioConnectorNetwork, +#endif // SB_API_VERSION >= 15 kSbMediaAudioConnectorSpdif, kSbMediaAudioConnectorUsb, } SbMediaAudioConnector; @@ -374,6 +387,8 @@ typedef struct SbMediaColorMetadata { float custom_primary_matrix[12]; } SbMediaColorMetadata; +#if SB_API_VERSION >= 15 + // The set of information required by the decoder or player for each video // stream. typedef struct SbMediaVideoStreamInfo { @@ -429,6 +444,58 @@ typedef struct SbMediaVideoSampleInfo { bool is_key_frame; } SbMediaVideoSampleInfo; +#else // SB_API_VERSION >= 15 + +// The set of information required by the decoder or player for each video +// sample. +typedef struct SbMediaVideoSampleInfo { + // The video codec of this sample. + SbMediaVideoCodec codec; + + // The mime of the video stream when |codec| isn't kSbMediaVideoCodecNone. It + // may point to an empty string if the mime is not available, and it can only + // be set to NULL when |codec| is kSbMediaVideoCodecNone. + const char* mime; + + // Indicates the max video capabilities required. The web app will not provide + // a video stream exceeding the maximums described by this parameter. Allows + // the platform to optimize playback pipeline for low quality video streams if + // it knows that it will never adapt to higher quality streams. The string + // uses the same format as the string passed in to + // SbMediaCanPlayMimeAndKeySystem(), for example, when it is set to + // "width=1920; height=1080; framerate=15;", the video will never adapt to + // resolution higher than 1920x1080 or frame per second higher than 15 fps. + // When the maximums are unknown, this will be set to an empty string. It can + // only be set to NULL when |codec| is kSbMediaVideoCodecNone. + const char* max_video_capabilities; + + // Indicates whether the associated sample is a key frame (I-frame). Video key + // frames must always start with SPS and PPS NAL units. + bool is_key_frame; + + // The frame width of this sample, in pixels. Also could be parsed from the + // Sequence Parameter Set (SPS) NAL Unit. Frame dimensions must only change on + // key frames, but may change on any key frame. + int frame_width; + + // The frame height of this sample, in pixels. Also could be parsed from the + // Sequence Parameter Set (SPS) NAL Unit. Frame dimensions must only change on + // key frames, but may change on any key frame. + int frame_height; + + // HDR metadata common for HDR10 and WebM/VP9-based HDR formats as + // well as the Color Space, and Color elements: MatrixCoefficients, + // BitsPerChannel, ChromaSubsamplingHorz, ChromaSubsamplingVert, + // CbSubsamplingHorz, CbSubsamplingVert, ChromaSitingHorz, + // ChromaSitingVert, Range, TransferCharacteristics, and Primaries + // described here: https://matroska.org/technical/specs/index.html . + // This will only be specified on frames where the HDR metadata and + // color / color space might have changed (e.g. keyframes). + SbMediaColorMetadata color_metadata; +} SbMediaVideoSampleInfo, SbMediaVideoStreamInfo; + +#endif // SB_API_VERSION >= 15 + // A structure describing the audio configuration parameters of a single audio // output. typedef struct SbMediaAudioConfiguration { @@ -437,8 +504,13 @@ typedef struct SbMediaAudioConfiguration { int index; #endif // SB_API_VERSION < 15 +#if SB_API_VERSION >= 15 // The type of audio connector. Will be |kSbMediaAudioConnectorUnknown| if // this device cannot provide this information. +#else // SB_API_VERSION >= 15 + // The type of audio connector. Will be the empty |kSbMediaAudioConnectorNone| + // if this device cannot provide this information. +#endif // SB_API_VERSION >= 15 SbMediaAudioConnector connector; // The expected latency of audio over this output, in microseconds, or |0| if @@ -454,6 +526,8 @@ typedef struct SbMediaAudioConfiguration { int number_of_channels; } SbMediaAudioConfiguration; +#if SB_API_VERSION >= 15 + // The set of information required by the decoder or player for each audio // stream. typedef struct SbMediaAudioStreamInfo { @@ -490,6 +564,51 @@ typedef struct SbMediaAudioSampleInfo { int64_t discarded_duration_from_back; // in microseconds. } SbMediaAudioSampleInfo; +#else // SB_API_VERSION >= 15 + +// An audio sample info, which is a description of a given audio sample. This +// acts as a set of instructions to the audio decoder. +// +// The audio sample info consists of information found in the |WAVEFORMATEX| +// structure, as well as other information for the audio decoder, including the +// Audio-specific configuration field. The |WAVEFORMATEX| structure is +// specified at http://msdn.microsoft.com/en-us/library/dd390970(v=vs.85).aspx . +typedef struct SbMediaAudioSampleInfo { + // The audio codec of this sample. + SbMediaAudioCodec codec; + + // The mime of the audio stream when |codec| isn't kSbMediaAudioCodecNone. It + // may point to an empty string if the mime is not available, and it can only + // be set to NULL when |codec| is kSbMediaAudioCodecNone. + const char* mime; + + // The waveform-audio format type code. + uint16_t format_tag; + + // The number of audio channels in this format. |1| for mono, |2| for stereo. + uint16_t number_of_channels; + + // The sampling rate. + uint32_t samples_per_second; + + // The number of bytes per second expected with this format. + uint32_t average_bytes_per_second; + + // Byte block alignment, e.g., 4. + uint16_t block_alignment; + + // The bit depth for the stream this represents, e.g. |8| or |16|. + uint16_t bits_per_sample; + + // The size, in bytes, of the audio_specific_config. + uint16_t audio_specific_config_size; + + // The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1. + const void* audio_specific_config; +} SbMediaAudioSampleInfo, SbMediaAudioStreamInfo; + +#endif // SB_API_VERSION >= 15 + // --- Functions ------------------------------------------------------------- // Returns information about whether the playback of the specific media diff --git a/starboard/nplb/media_can_play_mime_and_key_system_test.cc b/starboard/nplb/media_can_play_mime_and_key_system_test.cc index e2d08a9e31e1..6c2619942b4e 100644 --- a/starboard/nplb/media_can_play_mime_and_key_system_test.cc +++ b/starboard/nplb/media_can_play_mime_and_key_system_test.cc @@ -793,7 +793,11 @@ TEST(SbMediaCanPlayMimeAndKeySystem, ValidateQueriesUnderPeakCapability) { } TEST(SbMediaCanPlayMimeAndKeySystem, VerifyMaxBitrate) { +#if SB_API_VERSION >= 15 constexpr int kAv14kBitrate = 40000000; +#else + constexpr int kAv14kBitrate = 42000000; +#endif // SB_API_VERSION >= 15 const std::pair kCodecSupportQueries[] = { {// AV1 1080P SDR diff --git a/starboard/nplb/player_create_test.cc b/starboard/nplb/player_create_test.cc index 20d0d6a6b52e..5dd8c2567f74 100644 --- a/starboard/nplb/player_create_test.cc +++ b/starboard/nplb/player_create_test.cc @@ -334,7 +334,9 @@ TEST_F(SbPlayerTest, MultiPlayer) { kSbMediaAudioCodecMp3, kSbMediaAudioCodecFlac, kSbMediaAudioCodecPcm, +#if SB_API_VERSION >= 15 kSbMediaAudioCodecIamf, +#endif // SB_API_VERSION >= 15 }; // clang-format on @@ -353,7 +355,9 @@ TEST_F(SbPlayerTest, MultiPlayer) { case kAudioCodecs[6]: case kAudioCodecs[7]: case kAudioCodecs[8]: +#if SB_API_VERSION >= 15 case kAudioCodecs[9]: +#endif // SB_API_VERSION >= 15 break; } diff --git a/starboard/nplb/player_creation_param_helpers.cc b/starboard/nplb/player_creation_param_helpers.cc index fc41c27c443a..a9dfc3c58aba 100644 --- a/starboard/nplb/player_creation_param_helpers.cc +++ b/starboard/nplb/player_creation_param_helpers.cc @@ -92,12 +92,14 @@ AudioStreamInfo CreateAudioStreamInfo(SbMediaAudioCodec codec) { audio_stream_info.bits_per_sample = 32; break; } +#if SB_API_VERSION >= 15 case kSbMediaAudioCodecIamf: { audio_stream_info.number_of_channels = 2; audio_stream_info.samples_per_second = 48000; audio_stream_info.bits_per_sample = 32; break; } +#endif // SB_API_VERSION >= 15 } return audio_stream_info; } diff --git a/starboard/nplb/player_creation_param_helpers.h b/starboard/nplb/player_creation_param_helpers.h index a068dbfda3fc..3c607dcdbe99 100644 --- a/starboard/nplb/player_creation_param_helpers.h +++ b/starboard/nplb/player_creation_param_helpers.h @@ -50,8 +50,13 @@ struct PlayerCreationParam { creation_param->drm_system = drm_system; +#if SB_API_VERSION >= 15 audio_stream_info.ConvertTo(&creation_param->audio_stream_info); video_stream_info.ConvertTo(&creation_param->video_stream_info); +#else // SB_API_VERSION >= 15 + audio_stream_info.ConvertTo(&creation_param->audio_sample_info); + video_stream_info.ConvertTo(&creation_param->video_sample_info); +#endif // SB_API_VERSION >= 15 creation_param->output_mode = output_mode; } diff --git a/starboard/nplb/player_get_audio_configuration_test.cc b/starboard/nplb/player_get_audio_configuration_test.cc index 8a2bb8818d48..7cd5a7e5a8bc 100644 --- a/starboard/nplb/player_get_audio_configuration_test.cc +++ b/starboard/nplb/player_get_audio_configuration_test.cc @@ -19,6 +19,8 @@ #include "starboard/testing/fake_graphics_context_provider.h" #include "testing/gtest/include/gtest/gtest.h" +#if SB_API_VERSION >= 15 + bool operator==(const SbMediaAudioConfiguration& left, const SbMediaAudioConfiguration& right) { return memcmp(&left, &right, sizeof(SbMediaAudioConfiguration)) == 0; @@ -273,3 +275,5 @@ INSTANTIATE_TEST_CASE_P(SbPlayerGetAudioConfigurationTests, } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION >= 15 diff --git a/starboard/nplb/player_get_preferred_output_mode_test.cc b/starboard/nplb/player_get_preferred_output_mode_test.cc index d38502a68e23..69e5be37b511 100644 --- a/starboard/nplb/player_get_preferred_output_mode_test.cc +++ b/starboard/nplb/player_get_preferred_output_mode_test.cc @@ -56,7 +56,9 @@ TEST(SbPlayerGetPreferredOutputModeTest, AllCodecs) { kSbMediaAudioCodecMp3, kSbMediaAudioCodecFlac, kSbMediaAudioCodecPcm, +#if SB_API_VERSION >= 15 kSbMediaAudioCodecIamf, +#endif // SB_API_VERSION >= 15 }; const SbMediaVideoCodec kVideoCodecs[] = { kSbMediaVideoCodecNone, diff --git a/starboard/nplb/player_test_util.cc b/starboard/nplb/player_test_util.cc index a1e6e5d65db8..b02038ff1bc2 100644 --- a/starboard/nplb/player_test_util.cc +++ b/starboard/nplb/player_test_util.cc @@ -56,8 +56,10 @@ const char* kAudioOnlyTestFiles[] = { "beneath_the_canopy_opus_5_1.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_5s_flac.dmp", "sintel_5s_mp3.dmp", "sintel_5s_pcm_s16le.dmp", @@ -291,7 +293,9 @@ void CallSbPlayerWriteSamples( static auto const* enhanced_audio_extension = static_cast( SbSystemGetExtension(kCobaltExtensionEnhancedAudioName)); +#if SB_API_VERSION >= 15 ASSERT_FALSE(enhanced_audio_extension); +#endif // SB_API_VERSION >= 15 if (enhanced_audio_extension) { ASSERT_STREQ(enhanced_audio_extension->name, @@ -347,6 +351,7 @@ void CallSbPlayerWriteSamples( sample_infos.push_back( dmp_reader->GetPlayerSampleInfo(sample_type, start_index++)); sample_infos.back().timestamp += timestamp_offset; +#if SB_API_VERSION >= 15 if (!discarded_durations_from_front.empty()) { sample_infos.back().audio_sample_info.discarded_duration_from_front = discarded_durations_from_front[i]; @@ -355,6 +360,7 @@ void CallSbPlayerWriteSamples( sample_infos.back().audio_sample_info.discarded_duration_from_back = discarded_durations_from_back[i]; } +#endif // SB_API_VERSION >= 15 } #if SB_API_VERSION >= 15 SbPlayerWriteSamples(player, sample_type, sample_infos.data(), @@ -397,11 +403,15 @@ bool IsOutputModeSupported(SbPlayerOutputMode output_mode, } bool IsPartialAudioSupported() { +#if SB_API_VERSION >= 15 #if SB_API_VERSION >= 16 return kHasPartialAudioFramesSupport; -#else // SB_API_VERSION >= 16 +#else return true; -#endif // SB_API_VERSION >= 16 +#endif +#else // SB_API_VERSION >= 15 + return SbSystemGetExtension(kCobaltExtensionEnhancedAudioName) != nullptr; +#endif // SB_API_VERSION >= 15 } bool IsAudioPassthroughUsed(const SbPlayerTestConfig& config) { diff --git a/starboard/nplb/system_get_property_test.cc b/starboard/nplb/system_get_property_test.cc index f57e14c64711..a50f0821f7a4 100644 --- a/starboard/nplb/system_get_property_test.cc +++ b/starboard/nplb/system_get_property_test.cc @@ -188,6 +188,7 @@ TEST(SbSystemGetPropertyTest, SpeechApiKeyNotLeaked) { } } +#if SB_API_VERSION >= 15 TEST(SbSystemGetPropertyTest, DeviceTypeAllowed) { std::string device_type = GetSystemPropertyString(kSbSystemPropertyDeviceType); @@ -218,6 +219,7 @@ TEST(SbSystemGetPropertyTest, DeviceTypeAllowed) { } ASSERT_TRUE(result); } +#endif } // namespace } // namespace nplb diff --git a/starboard/player.h b/starboard/player.h index 835e0580e403..340a89bca86e 100644 --- a/starboard/player.h +++ b/starboard/player.h @@ -105,6 +105,7 @@ typedef struct SbPlayerCreationParam { // encrypted portions. SbDrmSystem drm_system; +#if SB_API_VERSION >= 15 // Contains a populated SbMediaAudioStreamInfo if |audio_stream_info.codec| // isn't |kSbMediaAudioCodecNone|. When |audio_stream_info.codec| is // |kSbMediaAudioCodecNone|, the video doesn't have an audio track. @@ -113,6 +114,16 @@ typedef struct SbPlayerCreationParam { // isn't |kSbMediaVideoCodecNone|. When |video_stream_info.codec| is // |kSbMediaVideoCodecNone|, the video is audio only. SbMediaVideoStreamInfo video_stream_info; +#else // SB_API_VERSION >= 15 + // Contains a populated SbMediaAudioSampleInfo if |audio_sample_info.codec| + // isn't |kSbMediaAudioCodecNone|. When |audio_sample_info.codec| is + // |kSbMediaAudioCodecNone|, the video doesn't have an audio track. + SbMediaAudioSampleInfo audio_sample_info; + // Contains a populated SbMediaVideoSampleInfo if |video_sample_info.codec| + // isn't |kSbMediaVideoCodecNone|. When |video_sample_info.codec| is + // |kSbMediaVideoCodecNone|, the video is audio only. + SbMediaVideoSampleInfo video_sample_info; +#endif // SB_API_VERSION >= 15 // Selects how the decoded video frames will be output. For example, // |kSbPlayerOutputModePunchOut| indicates that the decoded video frames will @@ -295,6 +306,8 @@ typedef void (*SbPlayerDeallocateSampleFunc)(SbPlayer player, // Well-defined value for an invalid player. #define kSbPlayerInvalid ((SbPlayer)NULL) +#if SB_API_VERSION >= 15 + // The audio write duration when all the audio connectors are local. #define kSbPlayerWriteDurationLocal (1000000 / 2) // 0.5 seconds @@ -302,6 +315,8 @@ typedef void (*SbPlayerDeallocateSampleFunc)(SbPlayer player, // remote. #define kSbPlayerWriteDurationRemote (1000000 * 10) // 10 seconds +#endif // SB_API_VERSION >= 15 + // Returns whether the given player handle is valid. static inline bool SbPlayerIsValid(SbPlayer player) { return player != kSbPlayerInvalid; @@ -681,10 +696,12 @@ SB_EXPORT SbDecodeTarget SbPlayerGetCurrentFrame(SbPlayer player); // // |out_audio_configuration|: The information about the audio output, refer to // |SbMediaAudioConfiguration| for more details. Must not be NULL. +#if SB_API_VERSION >= 15 SB_EXPORT bool SbPlayerGetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration); +#endif // SB_API_VERSION >= 15 #ifdef __cplusplus } // extern "C" diff --git a/starboard/raspi/shared/application_dispmanx.h b/starboard/raspi/shared/application_dispmanx.h index ecd088d7b6c6..c36eafd79825 100644 --- a/starboard/raspi/shared/application_dispmanx.h +++ b/starboard/raspi/shared/application_dispmanx.h @@ -34,8 +34,12 @@ namespace shared { class ApplicationDispmanx : public ::starboard::shared::starboard::QueueApplication { public: +#if SB_API_VERSION >= 15 explicit ApplicationDispmanx(SbEventHandleCallback sb_event_handle_callback) : window_(kSbWindowInvalid), QueueApplication(sb_event_handle_callback) {} +#else + ApplicationDispmanx() : window_(kSbWindowInvalid) {} +#endif // SB_API_VERSION >= 15 ~ApplicationDispmanx() override {} static ApplicationDispmanx* Get() { diff --git a/starboard/raspi/shared/main.cc b/starboard/raspi/shared/main.cc index c62759549277..45575c3164da 100644 --- a/starboard/raspi/shared/main.cc +++ b/starboard/raspi/shared/main.cc @@ -53,7 +53,12 @@ int main(int argc, char** argv) { third_party::crashpad::wrapper::InstallCrashpadHandler(ca_certificates_path); #endif // SB_IS(EVERGREEN_COMPATIBLE) +#if SB_API_VERSION >= 15 int result = SbRunStarboardMain(argc, argv, SbEventHandle); +#else + starboard::raspi::shared::ApplicationDispmanx application; + int result = application.Run(argc, argv); +#endif // SB_API_VERSION >= 15 starboard::shared::signal::UninstallSuspendSignalHandlers(); starboard::shared::signal::UninstallDebugSignalHandlers(); starboard::shared::signal::UninstallCrashSignalHandlers(); diff --git a/starboard/raspi/shared/run_starboard_main.cc b/starboard/raspi/shared/run_starboard_main.cc index d5f97c9511c0..9e957afcb394 100644 --- a/starboard/raspi/shared/run_starboard_main.cc +++ b/starboard/raspi/shared/run_starboard_main.cc @@ -15,8 +15,10 @@ #include "starboard/event.h" #include "starboard/raspi/shared/application_dispmanx.h" +#if SB_API_VERSION >= 15 int SbRunStarboardMain(int argc, char** argv, SbEventHandleCallback callback) { starboard::raspi::shared::ApplicationDispmanx application(callback); int result = application.Run(argc, argv); return result; } +#endif // SB_API_VERSION >= 15 diff --git a/starboard/raspi/shared/system_get_property.cc b/starboard/raspi/shared/system_get_property.cc index 6208dee8bb5c..72cc9cce098f 100644 --- a/starboard/raspi/shared/system_get_property.cc +++ b/starboard/raspi/shared/system_get_property.cc @@ -163,9 +163,11 @@ bool SbSystemGetProperty(SbSystemPropertyId property_id, return CopyStringAndTestIfSuccess(out_value, value_length, "X11; Linux armv7l"); } +#if SB_API_VERSION >= 15 case kSbSystemPropertyDeviceType: return CopyStringAndTestIfSuccess(out_value, value_length, starboard::kSystemDeviceTypeUnknown); +#endif default: SB_DLOG(WARNING) << __FUNCTION__ diff --git a/starboard/shared/starboard/application.cc b/starboard/shared/starboard/application.cc index af80809ff031..1afc480ba9a9 100644 --- a/starboard/shared/starboard/application.cc +++ b/starboard/shared/starboard/application.cc @@ -42,7 +42,11 @@ 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); } @@ -63,6 +67,7 @@ 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()), @@ -71,6 +76,13 @@ 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(SbAtomicAcquire_CompareAndSwapPtr( reinterpret_cast(&g_instance), @@ -407,7 +419,11 @@ 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: diff --git a/starboard/shared/starboard/application.h b/starboard/shared/starboard/application.h index 4d0c269b2b12..ab7892fa7693 100644 --- a/starboard/shared/starboard/application.h +++ b/starboard/shared/starboard/application.h @@ -46,8 +46,10 @@ 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. @@ -155,7 +157,11 @@ 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 diff --git a/starboard/shared/starboard/media/media_get_audio_configuration.cc b/starboard/shared/starboard/media/media_get_audio_configuration.cc index 542ac80fff78..038a766decf3 100644 --- a/starboard/shared/starboard/media/media_get_audio_configuration.cc +++ b/starboard/shared/starboard/media/media_get_audio_configuration.cc @@ -31,7 +31,12 @@ 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(); diff --git a/starboard/shared/starboard/media/media_util.cc b/starboard/shared/starboard/media/media_util.cc index e772b4fafff4..e0541d47dc08 100644 --- a/starboard/shared/starboard/media/media_util.cc +++ b/starboard/shared/starboard/media/media_util.cc @@ -169,9 +169,13 @@ 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; } @@ -189,11 +193,15 @@ 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( @@ -249,7 +257,11 @@ 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; } @@ -266,7 +278,11 @@ 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; } @@ -462,8 +478,13 @@ 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; @@ -492,6 +513,8 @@ 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) { @@ -517,6 +540,8 @@ 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); @@ -527,7 +552,9 @@ 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 diff --git a/starboard/shared/starboard/media/media_util.h b/starboard/shared/starboard/media/media_util.h index 99f24c4cbe98..030a53fd084c 100644 --- a/starboard/shared/starboard/media/media_util.h +++ b/starboard/shared/starboard/media/media_util.h @@ -178,15 +178,19 @@ bool operator==(const SbMediaColorMetadata& metadata_1, 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_ diff --git a/starboard/shared/starboard/media/media_util_test.cc b/starboard/shared/starboard/media/media_util_test.cc index c49698f49ae6..a76f5c4059e1 100644 --- a/starboard/shared/starboard/media/media_util_test.cc +++ b/starboard/shared/starboard/media/media_util_test.cc @@ -175,7 +175,11 @@ 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"; @@ -240,7 +244,11 @@ 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; diff --git a/starboard/shared/starboard/media/mime_util.cc b/starboard/shared/starboard/media/mime_util.cc index e0fc0280558d..23f83dd7bcff 100644 --- a/starboard/shared/starboard/media/mime_util.cc +++ b/starboard/shared/starboard/media/mime_util.cc @@ -111,11 +111,13 @@ 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, diff --git a/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc b/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc index c905deb85720..f55a639d2448 100644 --- a/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc +++ b/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc @@ -77,11 +77,19 @@ 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); } diff --git a/starboard/shared/starboard/player/filter/stub_audio_decoder.cc b/starboard/shared/starboard/player/filter/stub_audio_decoder.cc index b2d0d3929001..15c93ec428b8 100644 --- a/starboard/shared/starboard/player/filter/stub_audio_decoder.cc +++ b/starboard/shared/starboard/player/filter/stub_audio_decoder.cc @@ -245,10 +245,12 @@ 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_; } diff --git a/starboard/shared/starboard/player/filter/testing/test_util.cc b/starboard/shared/starboard/player/filter/testing/test_util.cc index ddab7db227ad..3cc4bf5078e7 100644 --- a/starboard/shared/starboard/player/filter/testing/test_util.cc +++ b/starboard/shared/starboard/player/filter/testing/test_util.cc @@ -66,9 +66,11 @@ 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(); } @@ -109,8 +111,10 @@ std::vector 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"}; @@ -283,7 +287,11 @@ 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 GetAudioInputBuffer( @@ -305,12 +313,34 @@ scoped_refptr 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; } diff --git a/starboard/shared/starboard/player/player_create.cc b/starboard/shared/starboard/player/player_create.cc index 7a990afc5aa4..291854b22581 100644 --- a/starboard/shared/starboard/player/player_create.cc +++ b/starboard/shared/starboard/player/player_create.cc @@ -61,10 +61,17 @@ SbPlayer SbPlayerCreate(SbWindow window, return kSbPlayerInvalid; } +#if SB_API_VERSION >= 15 const SbMediaAudioStreamInfo& audio_stream_info = creation_param->audio_stream_info; const SbMediaVideoStreamInfo& video_stream_info = creation_param->video_stream_info; +#else // SB_API_VERSION >= 15 + const SbMediaAudioSampleInfo& audio_stream_info = + creation_param->audio_sample_info; + const SbMediaVideoSampleInfo& video_stream_info = + creation_param->video_sample_info; +#endif // SB_API_VERSION >= 15 bool has_audio = audio_stream_info.codec != kSbMediaAudioCodecNone; bool has_video = video_stream_info.codec != kSbMediaVideoCodecNone; diff --git a/starboard/shared/starboard/player/player_get_audio_configuration.cc b/starboard/shared/starboard/player/player_get_audio_configuration.cc index 90ccc81d65e2..36a3e110bd84 100644 --- a/starboard/shared/starboard/player/player_get_audio_configuration.cc +++ b/starboard/shared/starboard/player/player_get_audio_configuration.cc @@ -18,6 +18,8 @@ #include "starboard/media.h" #include "starboard/shared/starboard/player/player_internal.h" +#if SB_API_VERSION >= 15 + bool SbPlayerGetAudioConfiguration( SbPlayer player, int index, @@ -28,3 +30,5 @@ bool SbPlayerGetAudioConfiguration( return player->GetAudioConfiguration(index, out_audio_configuration); } + +#endif // SB_API_VERSION >= 15 diff --git a/starboard/shared/starboard/player/player_get_preferred_output_mode_prefer_punchout.cc b/starboard/shared/starboard/player/player_get_preferred_output_mode_prefer_punchout.cc index f4863a262e31..a766f13604ad 100644 --- a/starboard/shared/starboard/player/player_get_preferred_output_mode_prefer_punchout.cc +++ b/starboard/shared/starboard/player/player_get_preferred_output_mode_prefer_punchout.cc @@ -28,10 +28,17 @@ SbPlayerOutputMode SbPlayerGetPreferredOutputMode( return kSbPlayerOutputModeInvalid; } +#if SB_API_VERSION >= 15 const SbMediaAudioStreamInfo& audio_stream_info = creation_param->audio_stream_info; const SbMediaVideoStreamInfo& video_stream_info = creation_param->video_stream_info; +#else // SB_API_VERSION >= 15 + const SbMediaAudioSampleInfo& audio_stream_info = + creation_param->audio_sample_info; + const SbMediaVideoSampleInfo& video_stream_info = + creation_param->video_sample_info; +#endif // SB_API_VERSION >= 15 if (audio_stream_info.codec != kSbMediaAudioCodecNone && !audio_stream_info.mime) { diff --git a/starboard/shared/starboard/player/video_dmp_reader.cc b/starboard/shared/starboard/player/video_dmp_reader.cc index d65b1f68bafd..bfdf43515361 100644 --- a/starboard/shared/starboard/player/video_dmp_reader.cc +++ b/starboard/shared/starboard/player/video_dmp_reader.cc @@ -162,9 +162,11 @@ std::string VideoDmpReader::audio_mime_type() const { case kSbMediaAudioCodecPcm: ss << "audio/wav; codecs=\"1\";"; break; +#if SB_API_VERSION >= 15 case kSbMediaAudioCodecIamf: ss << "audio/mp4; codecs=\"iamf\";"; break; +#endif // SB_API_VERSION >= 15 default: SB_NOTREACHED() << "Unsupported audio codec: " << dmp_info_.audio_codec; } diff --git a/starboard/shared/starboard/queue_application.h b/starboard/shared/starboard/queue_application.h index c8c90ecccd4a..8f039d9b7adb 100644 --- a/starboard/shared/starboard/queue_application.h +++ b/starboard/shared/starboard/queue_application.h @@ -35,8 +35,12 @@ namespace starboard { // manage event dispatching. class QueueApplication : public Application { public: +#if SB_API_VERSION >= 15 explicit QueueApplication(SbEventHandleCallback sb_event_handle_callback) : Application(sb_event_handle_callback) {} +#else + QueueApplication() {} +#endif // SB_API_VERSION >= 15 ~QueueApplication() override {} protected: diff --git a/starboard/shared/stub/player_get_audio_configuration.cc b/starboard/shared/stub/player_get_audio_configuration.cc index 3c685f150a39..78b44f7c5c0b 100644 --- a/starboard/shared/stub/player_get_audio_configuration.cc +++ b/starboard/shared/stub/player_get_audio_configuration.cc @@ -14,9 +14,13 @@ #include "starboard/player.h" +#if SB_API_VERSION >= 15 + bool SbPlayerGetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration) { return false; } + +#endif // SB_API_VERSION >= 15 diff --git a/starboard/shared/uwp/application_uwp.h b/starboard/shared/uwp/application_uwp.h index 504ce1a486e9..745b84e8dd81 100644 --- a/starboard/shared/uwp/application_uwp.h +++ b/starboard/shared/uwp/application_uwp.h @@ -54,7 +54,11 @@ class ApplicationUwp : public shared::starboard::Application, public: const float kDefaultScreenRefreshRate = 60.f; +#if SB_API_VERSION >= 15 explicit ApplicationUwp(SbEventHandleCallback sb_event_handle_callback); +#else + ApplicationUwp(); +#endif ~ApplicationUwp() override; static ApplicationUwp* Get() { diff --git a/starboard/shared/uwp/system_get_property.cc b/starboard/shared/uwp/system_get_property.cc index 253178967d7a..53baad1ed69f 100644 --- a/starboard/shared/uwp/system_get_property.cc +++ b/starboard/shared/uwp/system_get_property.cc @@ -337,8 +337,10 @@ bool SbSystemGetProperty(SbSystemPropertyId property_id, return CopyStringAndTestIfSuccess(out_value, value_length, advertising_id.empty() ? "1" : "0"); } +#if SB_API_VERSION >= 15 case kSbSystemPropertyDeviceType: return GetDeviceType(out_value, value_length); +#endif default: SB_DLOG(WARNING) << __FUNCTION__ << ": Unrecognized property: " << property_id; diff --git a/starboard/shared/win32/application_win32.cc b/starboard/shared/win32/application_win32.cc index 356c6a698b0d..0e337f06d48b 100644 --- a/starboard/shared/win32/application_win32.cc +++ b/starboard/shared/win32/application_win32.cc @@ -119,10 +119,15 @@ namespace starboard { namespace shared { namespace win32 { +#if SB_API_VERSION >= 15 ApplicationWin32::ApplicationWin32( SbEventHandleCallback sb_event_handle_callback) : localized_strings_(SbSystemGetLocaleId()), QueueApplication(sb_event_handle_callback) {} +#else +ApplicationWin32::ApplicationWin32() + : localized_strings_(SbSystemGetLocaleId()) {} +#endif // SB_API_VERSION >= 15 ApplicationWin32::~ApplicationWin32() {} SbWindow ApplicationWin32::CreateWindowForWin32( diff --git a/starboard/shared/win32/application_win32.h b/starboard/shared/win32/application_win32.h index f0ebcef9b46a..52955d044c71 100644 --- a/starboard/shared/win32/application_win32.h +++ b/starboard/shared/win32/application_win32.h @@ -37,7 +37,11 @@ namespace win32 { class ApplicationWin32 : public starboard::QueueApplication { public: +#if SB_API_VERSION >= 15 explicit ApplicationWin32(SbEventHandleCallback sb_event_handle_callback); +#else + ApplicationWin32(); +#endif // SB_API_VERSION >= 15 ~ApplicationWin32() override; static ApplicationWin32* Get() { diff --git a/starboard/shared/win32/starboard_main.cc b/starboard/shared/win32/starboard_main.cc index 0b8ae37e1a99..372d797a982b 100644 --- a/starboard/shared/win32/starboard_main.cc +++ b/starboard/shared/win32/starboard_main.cc @@ -73,9 +73,21 @@ extern "C" int StarboardMain(int argc, char** argv) { SB_DCHECK(SUCCEEDED(hr)); WaitForNetLogIfNecessary(CommandLine(argc, argv)); +#if SB_API_VERSION >= 15 return SbRunStarboardMain(argc, argv, SbEventHandle); +#else + ApplicationWin32 application; + // This will run the message loop. + const int main_return_value = application.Run(argc, argv); + NetLogFlushThenClose(); + + MFShutdown(); + WSACleanup(); + return main_return_value; +#endif // SB_API_VERSION >= 15 } +#if SB_API_VERSION >= 15 int SbRunStarboardMain(int argc, char** argv, SbEventHandleCallback callback) { ApplicationWin32 application(callback); // This will run the message loop. @@ -86,3 +98,4 @@ int SbRunStarboardMain(int argc, char** argv, SbEventHandleCallback callback) { WSACleanup(); return main_return_value; } +#endif // SB_API_VERSION >= 15 diff --git a/starboard/shared/win32/system_get_property.cc b/starboard/shared/win32/system_get_property.cc index d9cda3dbcf6f..76eb1f05fcb9 100644 --- a/starboard/shared/win32/system_get_property.cc +++ b/starboard/shared/win32/system_get_property.cc @@ -66,9 +66,13 @@ bool SbSystemGetProperty(SbSystemPropertyId property_id, return CopyStringAndTestIfSuccess( out_value, value_length, starboard::GetEnvironment("COBALT_LIMIT_AD_TRACKING").c_str()); + +#if SB_API_VERSION >= 15 case kSbSystemPropertyDeviceType: return CopyStringAndTestIfSuccess(out_value, value_length, starboard::kSystemDeviceTypeDesktopPC); +#endif + default: SB_DLOG(WARNING) << __FUNCTION__ << ": Unrecognized property: " << property_id; diff --git a/starboard/shared/x11/application_x11.cc b/starboard/shared/x11/application_x11.cc index c6a838efa5d1..1e1f5f4226b6 100644 --- a/starboard/shared/x11/application_x11.cc +++ b/starboard/shared/x11/application_x11.cc @@ -693,11 +693,17 @@ int ErrorHandler(Display* display, XErrorEvent* event) { using shared::starboard::player::filter::CpuVideoFrame; +#if SB_API_VERSION >= 15 ApplicationX11::ApplicationX11(SbEventHandleCallback sb_event_handle_callback) +#else +ApplicationX11::ApplicationX11() +#endif // SB_API_VERSION >= 15 : wake_up_atom_(None), wm_delete_atom_(None), wm_change_state_atom_(None), +#if SB_API_VERSION >= 15 QueueApplication(sb_event_handle_callback), +#endif // SB_API_VERSION >= 15 composite_event_id_(kSbEventIdInvalid), display_(NULL), paste_buffer_key_release_pending_(false) { diff --git a/starboard/shared/x11/application_x11.h b/starboard/shared/x11/application_x11.h index 5d8f715a3e57..6182371c3aac 100644 --- a/starboard/shared/x11/application_x11.h +++ b/starboard/shared/x11/application_x11.h @@ -38,7 +38,11 @@ namespace x11 { // This application engine combines the generic queue with the X11 event queue. class ApplicationX11 : public shared::starboard::QueueApplication { public: +#if SB_API_VERSION >= 15 explicit ApplicationX11(SbEventHandleCallback sb_event_handle_callback); +#else + ApplicationX11(); +#endif // SB_API_VERSION >= 15 ~ApplicationX11() override; static ApplicationX11* Get() { diff --git a/starboard/stub/application_stub.cc b/starboard/stub/application_stub.cc index 5d48238a38b7..7aeb224b092c 100644 --- a/starboard/stub/application_stub.cc +++ b/starboard/stub/application_stub.cc @@ -20,8 +20,12 @@ namespace starboard { namespace stub { +#if SB_API_VERSION >= 15 ApplicationStub::ApplicationStub(SbEventHandleCallback sb_event_handle_callback) : QueueApplication(sb_event_handle_callback) {} +#else +ApplicationStub::ApplicationStub() {} +#endif // SB_API_VERSION >= 15 ApplicationStub::~ApplicationStub() {} diff --git a/starboard/stub/application_stub.h b/starboard/stub/application_stub.h index b2aeb84d23e4..72a8cd2ade70 100644 --- a/starboard/stub/application_stub.h +++ b/starboard/stub/application_stub.h @@ -27,7 +27,11 @@ namespace stub { // Stub application engine using the generic queue and a stub implementation. class ApplicationStub : public shared::starboard::QueueApplication { public: +#if SB_API_VERSION >= 15 explicit ApplicationStub(SbEventHandleCallback sb_event_handle_callback); +#else + ApplicationStub(); +#endif // SB_API_VERSION >= 15 ~ApplicationStub() override; diff --git a/starboard/stub/main.cc b/starboard/stub/main.cc index 8bcb60f82171..48d568d4c318 100644 --- a/starboard/stub/main.cc +++ b/starboard/stub/main.cc @@ -16,10 +16,17 @@ #include "starboard/stub/application_stub.h" int main(int argc, char** argv) { +#if SB_API_VERSION >= 15 return SbRunStarboardMain(argc, argv, SbEventHandle); +#else + starboard::stub::ApplicationStub application; + return application.Run(argc, argv); +#endif // SB_API_VERSION >= 15 } +#if SB_API_VERSION >= 15 int SbRunStarboardMain(int argc, char** argv, SbEventHandleCallback callback) { starboard::stub::ApplicationStub application(callback); return application.Run(argc, argv); } +#endif // SB_API_VERSION >= 15