Skip to content

Commit

Permalink
Revert "Remove refs to SbPlayerSeek2, SbPlayerGetInfo2, SbPlayerWrite…
Browse files Browse the repository at this point in the history
…Sample2 …"

This reverts commit 2b99b15.
  • Loading branch information
madhurajayaraman authored Aug 8, 2024
1 parent 4cd9ffc commit a8b6133
Show file tree
Hide file tree
Showing 24 changed files with 386 additions and 2 deletions.
16 changes: 16 additions & 0 deletions cobalt/media/base/sbplayer_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,11 @@ void SbPlayerBridge::GetVideoResolution(int* frame_width, int* frame_height) {

DCHECK(SbPlayerIsValid(player_));

#if SB_API_VERSION >= 15
SbPlayerInfo out_player_info;
#else // SB_API_VERSION >= 15
SbPlayerInfo2 out_player_info;
#endif // SB_API_VERSION >= 15
sbplayer_interface_->GetInfo(player_, &out_player_info);

video_stream_info_.frame_width = out_player_info.frame_width;
Expand All @@ -545,7 +549,11 @@ TimeDelta SbPlayerBridge::GetDuration() {

DCHECK(SbPlayerIsValid(player_));

#if SB_API_VERSION >= 15
SbPlayerInfo info;
#else // SB_API_VERSION >= 15
SbPlayerInfo2 info;
#endif // SB_API_VERSION >= 15
sbplayer_interface_->GetInfo(player_, &info);
if (info.duration == SB_PLAYER_NO_DURATION) {
// URL-based player may not have loaded asset yet, so map no duration to 0.
Expand All @@ -563,7 +571,11 @@ TimeDelta SbPlayerBridge::GetStartDate() {

DCHECK(SbPlayerIsValid(player_));

#if SB_API_VERSION >= 15
SbPlayerInfo info;
#else // SB_API_VERSION >= 15
SbPlayerInfo2 info;
#endif // SB_API_VERSION >= 15
sbplayer_interface_->GetInfo(player_, &info);
return TimeDelta::FromMicroseconds(info.start_date);
}
Expand Down Expand Up @@ -977,7 +989,11 @@ void SbPlayerBridge::GetInfo_Locked(uint32* video_frames_decoded,

DCHECK(SbPlayerIsValid(player_));

#if SB_API_VERSION >= 15
SbPlayerInfo info;
#else // SB_API_VERSION >= 15
SbPlayerInfo2 info;
#endif // SB_API_VERSION >= 15
sbplayer_interface_->GetInfo(player_, &info);

if (media_time) {
Expand Down
14 changes: 14 additions & 0 deletions cobalt/media/base/sbplayer_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ void DefaultSbPlayerInterface::Destroy(SbPlayer player) {
void DefaultSbPlayerInterface::Seek(SbPlayer player,
base::TimeDelta seek_to_timestamp,
int ticket) {
#if SB_API_VERSION >= 15
SbPlayerSeek(player, seek_to_timestamp.InMicroseconds(), ticket);
#else // SB_API_VERSION >= 15
SbPlayerSeek2(player, seek_to_timestamp.InMicroseconds(), ticket);
#endif // SB_API_VERSION >= 15
}

bool DefaultSbPlayerInterface::IsEnhancedAudioExtensionEnabled() const {
Expand All @@ -102,8 +106,13 @@ void DefaultSbPlayerInterface::WriteSamples(
SbPlayer player, SbMediaType sample_type,
const SbPlayerSampleInfo* sample_infos, int number_of_sample_infos) {
DCHECK(!IsEnhancedAudioExtensionEnabled());
#if SB_API_VERSION >= 15
SbPlayerWriteSamples(player, sample_type, sample_infos,
number_of_sample_infos);
#else // SB_API_VERSION >= 15
SbPlayerWriteSample2(player, sample_type, sample_infos,
number_of_sample_infos);
#endif // SB_API_VERSION >= 15
}

void DefaultSbPlayerInterface::WriteSamples(
Expand Down Expand Up @@ -140,8 +149,13 @@ void DefaultSbPlayerInterface::SetVolume(SbPlayer player, double volume) {
}

void DefaultSbPlayerInterface::GetInfo(SbPlayer player,
#if SB_API_VERSION >= 15
SbPlayerInfo* out_player_info) {
SbPlayerGetInfo(player, out_player_info);
#else // SB_API_VERSION >= 15
SbPlayerInfo2* out_player_info2) {
SbPlayerGetInfo2(player, out_player_info2);
#endif // SB_API_VERSION >= 15
}

SbDecodeTarget DefaultSbPlayerInterface::GetCurrentFrame(SbPlayer player) {
Expand Down
8 changes: 8 additions & 0 deletions cobalt/media/base/sbplayer_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ class SbPlayerInterface {
virtual bool SetPlaybackRate(SbPlayer player, double playback_rate) = 0;
virtual void SetVolume(SbPlayer player, double volume) = 0;

#if SB_API_VERSION >= 15
virtual void GetInfo(SbPlayer player, SbPlayerInfo* out_player_info) = 0;
#else // SB_API_VERSION >= 15
virtual void GetInfo(SbPlayer player, SbPlayerInfo2* out_player_info2) = 0;
#endif // SB_API_VERSION >= 15
virtual SbDecodeTarget GetCurrentFrame(SbPlayer player) = 0;

#if SB_HAS(PLAYER_WITH_URL)
Expand Down Expand Up @@ -125,7 +129,11 @@ class DefaultSbPlayerInterface final : public SbPlayerInterface {
int height) override;
bool SetPlaybackRate(SbPlayer player, double playback_rate) override;
void SetVolume(SbPlayer player, double volume) override;
#if SB_API_VERSION >= 15
void GetInfo(SbPlayer player, SbPlayerInfo* out_player_info) override;
#else // SB_API_VERSION >= 15
void GetInfo(SbPlayer player, SbPlayerInfo2* out_player_info2) override;
#endif // SB_API_VERSION >= 15
SbDecodeTarget GetCurrentFrame(SbPlayer player) override;

#if SB_HAS(PLAYER_WITH_URL)
Expand Down
14 changes: 14 additions & 0 deletions starboard/elf_loader/exported_symbols.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,31 @@ ExportedSymbols::ExportedSymbols() {
#endif // SB_API_VERSION < 16
REGISTER_SYMBOL(SbPlayerCreate);
REGISTER_SYMBOL(SbPlayerDestroy);
#if SB_API_VERSION >= 15
REGISTER_SYMBOL(SbPlayerGetAudioConfiguration);
#endif // SB_API_VERSION >= 15
REGISTER_SYMBOL(SbPlayerGetCurrentFrame);
#if SB_API_VERSION >= 15
REGISTER_SYMBOL(SbPlayerGetInfo);
#else // SB_API_VERSION >= 15
REGISTER_SYMBOL(SbPlayerGetInfo2);
#endif // SB_API_VERSION >= 15
REGISTER_SYMBOL(SbPlayerGetMaximumNumberOfSamplesPerWrite);
REGISTER_SYMBOL(SbPlayerGetPreferredOutputMode);
#if SB_API_VERSION >= 15
REGISTER_SYMBOL(SbPlayerSeek);
#else // SB_API_VERSION >= 15
REGISTER_SYMBOL(SbPlayerSeek2);
#endif // SB_API_VERSION >= 15
REGISTER_SYMBOL(SbPlayerSetBounds);
REGISTER_SYMBOL(SbPlayerSetPlaybackRate);
REGISTER_SYMBOL(SbPlayerSetVolume);
REGISTER_SYMBOL(SbPlayerWriteEndOfStream);
#if SB_API_VERSION >= 15
REGISTER_SYMBOL(SbPlayerWriteSamples);
#else // SB_API_VERSION >= 15
REGISTER_SYMBOL(SbPlayerWriteSample2);
#endif // SB_API_VERSION >= 15
REGISTER_SYMBOL(SbSocketAccept);
REGISTER_SYMBOL(SbSocketBind);
REGISTER_SYMBOL(SbSocketClearLastError);
Expand Down
1 change: 1 addition & 0 deletions starboard/linux/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//starboard/shared/enhanced_audio/enhanced_audio.gni")
import("//starboard/shared/starboard/media/media_tests.gni")
import("//starboard/shared/starboard/player/buildfiles.gni")
import("//starboard/shared/starboard/player/player_tests.gni")
Expand Down
6 changes: 6 additions & 0 deletions starboard/linux/shared/system_get_extensions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "starboard/linux/shared/ifa.h"
#include "starboard/linux/shared/platform_service.h"
#include "starboard/linux/shared/time_zone.h"
#include "starboard/shared/enhanced_audio/enhanced_audio.h"
#include "starboard/shared/ffmpeg/ffmpeg_demuxer.h"
#include "starboard/shared/posix/free_space.h"
#include "starboard/shared/posix/memory_mapped_file.h"
Expand Down Expand Up @@ -70,6 +71,11 @@ const void* SbSystemGetExtension(const char* name) {
if (strcmp(name, kCobaltExtensionFreeSpaceName) == 0) {
return starboard::shared::posix::GetFreeSpaceApi();
}
#if SB_API_VERSION < 15
if (strcmp(name, kCobaltExtensionEnhancedAudioName) == 0) {
return starboard::shared::enhanced_audio::GetEnhancedAudioApi();
}
#endif // SB_API_VERSION < 15
if (strcmp(name, kCobaltExtensionDemuxerApi) == 0) {
auto command_line =
starboard::shared::starboard::Application::Get()->GetCommandLine();
Expand Down
31 changes: 30 additions & 1 deletion starboard/nplb/media_set_audio_write_duration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ class SbMediaSetAudioWriteDurationTest
}

// Check if we're about to input too far beyond the current playback time.
#if SB_API_VERSION >= 15
SbPlayerInfo info;
SbPlayerGetInfo(pending_decoder_status_->player, &info);
#else // SB_API_VERSION >= 15
SbPlayerInfo2 info;
SbPlayerGetInfo2(pending_decoder_status_->player, &info);
#endif // SB_API_VERSION >= 15
if ((last_input_timestamp_ - info.current_media_timestamp) > kDuration) {
// Postpone writing samples.
return;
Expand Down Expand Up @@ -185,18 +190,30 @@ TEST_P(SbMediaSetAudioWriteDurationTest, WriteLimitedInput) {
WaitForPlayerState(kSbPlayerStateInitialized);

// Seek to preroll.
#if SB_API_VERSION >= 15
SbPlayerSeek(player, first_input_timestamp_, /* ticket */ 1);
#else // SB_API_VERSION >= 15
SbPlayerSeek2(player, first_input_timestamp_, /* ticket */ 1);
#endif // SB_API_VERSION >= 15

WaitForPlayerState(kSbPlayerStatePresenting);

// Wait until the playback time is > 0.
const int64_t kMaxWaitTime = 5'000'000; // 5 seconds
int64_t start_of_wait = CurrentMonotonicTime();
#if SB_API_VERSION >= 15
SbPlayerInfo info = {};
#else // SB_API_VERSION >= 15
SbPlayerInfo2 info = {};
#endif // SB_API_VERSION >= 15
while (CurrentMonotonicTime() - start_of_wait < kMaxWaitTime &&
info.current_media_timestamp == 0) {
usleep(500'000);
#if SB_API_VERSION >= 15
SbPlayerGetInfo(player, &info);
#else // SB_API_VERSION >= 15
SbPlayerGetInfo2(player, &info);
#endif // SB_API_VERSION >= 15
}

EXPECT_GT(info.current_media_timestamp, 0);
Expand All @@ -215,20 +232,32 @@ TEST_P(SbMediaSetAudioWriteDurationTest, WriteContinuedLimitedInput) {
WaitForPlayerState(kSbPlayerStateInitialized);

// Seek to preroll.
#if SB_API_VERSION >= 15
SbPlayerSeek(player, first_input_timestamp_, /* ticket */ 1);
#else // SB_API_VERSION >= 15
SbPlayerSeek2(player, first_input_timestamp_, /* ticket */ 1);
#endif // SB_API_VERSION >= 15
WaitForPlayerState(kSbPlayerStatePresenting);

// Wait for the player to play far enough. It may not play all the way to
// the end, but it should leave off no more than |kDuration|.
int64_t min_ending_playback_time = total_duration_ - kDuration;
int64_t start_of_wait = CurrentMonotonicTime();
const int64_t kMaxWaitTime = total_duration_ + 5'000'000LL;
#if SB_API_VERSION >= 15
SbPlayerInfo info;
SbPlayerGetInfo(player, &info);

#else // SB_API_VERSION >= 15
SbPlayerInfo2 info;
SbPlayerGetInfo2(player, &info);
#endif // SB_API_VERSION >= 15
while (info.current_media_timestamp < min_ending_playback_time &&
(CurrentMonotonicTime() - start_of_wait) < kMaxWaitTime) {
#if SB_API_VERSION >= 15
SbPlayerGetInfo(player, &info);
#else // SB_API_VERSION >= 15
SbPlayerGetInfo2(player, &info);
#endif // SB_API_VERSION >= 15
usleep(kSmallWaitInterval);
TryToWritePendingSample();
}
Expand Down
9 changes: 9 additions & 0 deletions starboard/nplb/player_test_fixture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ void SbPlayerTestFixture::Seek(const int64_t time) {
audio_end_of_stream_written_ = false;
video_end_of_stream_written_ = false;

#if SB_API_VERSION >= 15
SbPlayerSeek(player_, time, ++ticket_);
#else // SB_API_VERSION >= 15
SbPlayerSeek2(player_, time, ++ticket_);
#endif // SB_API_VERSION >= 15
}

void SbPlayerTestFixture::Write(const GroupedSamples& grouped_samples) {
Expand Down Expand Up @@ -345,8 +349,13 @@ void SbPlayerTestFixture::WaitForPlayerEndOfStream() {
}

int64_t SbPlayerTestFixture::GetCurrentMediaTime() const {
#if SB_API_VERSION >= 15
SbPlayerInfo info = {};
SbPlayerGetInfo(player_, &info);
#else // SB_API_VERSION >= 15
SbPlayerInfo2 info = {};
SbPlayerGetInfo2(player_, &info);
#endif // SB_API_VERSION >= 15
return info.current_media_timestamp;
}

Expand Down
5 changes: 5 additions & 0 deletions starboard/nplb/player_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,13 @@ void CallSbPlayerWriteSamples(
discarded_durations_from_back[i];
}
}
#if SB_API_VERSION >= 15
SbPlayerWriteSamples(player, sample_type, sample_infos.data(),
number_of_samples_to_write);
#else // SB_API_VERSION >= 15
SbPlayerWriteSample2(player, sample_type, sample_infos.data(),
number_of_samples_to_write);
#endif // SB_API_VERSION >= 15
}

bool IsOutputModeSupported(SbPlayerOutputMode output_mode,
Expand Down
23 changes: 23 additions & 0 deletions starboard/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ typedef struct SbPlayerSampleInfo {
} SbPlayerSampleInfo;

// Information about the current media playback state.
#if SB_API_VERSION >= 15
typedef struct SbPlayerInfo {
#else // SB_API_VERSION >= 15
typedef struct SbPlayerInfo2 {
#endif // SB_API_VERSION >= 15
// The position of the playback head, as precisely as possible, in
// microseconds.
int64_t current_media_timestamp;
Expand Down Expand Up @@ -222,7 +226,11 @@ typedef struct SbPlayerInfo {
// is played in a slower than normal speed. Negative speeds are not
// supported.
double playback_rate;
#if SB_API_VERSION >= 15
} SbPlayerInfo;
#else // SB_API_VERSION >= 15
} SbPlayerInfo2;
#endif // SB_API_VERSION >= 15

// An opaque handle to an implementation-private structure representing a
// player.
Expand Down Expand Up @@ -466,9 +474,15 @@ SB_EXPORT void SbPlayerDestroy(SbPlayer player);
// when SbPlayerSeek was called. To be very specific, once SbPlayerSeek has
// been called with ticket X, a client should ignore all
// |SbPlayerDecoderStatusFunc| calls that do not pass in ticket X.
#if SB_API_VERSION >= 15
SB_EXPORT void SbPlayerSeek(SbPlayer player,
int64_t seek_to_timestamp,
int ticket);
#else // SB_API_VERSION >= 15
SB_EXPORT void SbPlayerSeek2(SbPlayer player,
int64_t seek_to_timestamp,
int ticket);
#endif // SB_API_VERSION >= 15

// Writes samples of the given media type to |player|'s input stream. The
// lifetime of |sample_infos|, and the members of its elements like |buffer|,
Expand Down Expand Up @@ -496,7 +510,11 @@ SB_EXPORT void SbPlayerSeek(SbPlayer player,
// |number_of_sample_infos|: Specify the number of samples contained inside
// |sample_infos|. It has to be at least one, and at most the return value
// of SbPlayerGetMaximumNumberOfSamplesPerWrite().
#if SB_API_VERSION >= 15
SB_EXPORT void SbPlayerWriteSamples(SbPlayer player,
#else // SB_API_VERSION >= 15
SB_EXPORT void SbPlayerWriteSample2(SbPlayer player,
#endif // SB_API_VERSION >= 15
SbMediaType sample_type,
const SbPlayerSampleInfo* sample_infos,
int number_of_sample_infos);
Expand Down Expand Up @@ -592,7 +610,12 @@ SB_EXPORT void SbPlayerSetVolume(SbPlayer player, double volume);
// |kSbPlayerInvalid|.
//
// |out_player_info|: The information retrieved for the player.
#if SB_API_VERSION >= 15
SB_EXPORT void SbPlayerGetInfo(SbPlayer player, SbPlayerInfo* out_player_info);
#else // SB_API_VERSION >= 15
SB_EXPORT void SbPlayerGetInfo2(SbPlayer player,
SbPlayerInfo2* out_player_info2);
#endif // SB_API_VERSION >= 15

// Given a player created with the kSbPlayerOutputModeDecodeToTexture
// output mode, it will return a SbDecodeTarget representing the current frame
Expand Down
Loading

0 comments on commit a8b6133

Please sign in to comment.