Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions media/starboard/sbplayer_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ GetStarboardExtensionExperimentalFeatures(
SB_ONCE_INITIALIZE_FUNCTION(StatisticsWrapper, StatisticsWrapper::GetInstance);
#endif // BUILDFLAG(COBALT_MEDIA_ENABLE_STARTUP_LATENCY_TRACKING)

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
SbPlayerBridge::SbPlayerBridge(
SbPlayerInterface* interface,
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
Expand Down Expand Up @@ -214,7 +214,7 @@ SbPlayerBridge::SbPlayerBridge(
weak_factory_.GetWeakPtr()));
#endif // BUILDFLAG(COBALT_MEDIA_ENABLE_SUSPEND_RESUME)
}
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

SbPlayerBridge::SbPlayerBridge(
SbPlayerInterface* interface,
Expand Down Expand Up @@ -266,10 +266,10 @@ SbPlayerBridge::SbPlayerBridge(
,
surface_view_(surface_view)
#endif // BUILDFLAG(IS_ANDROID)
#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
,
is_url_based_(false)
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)
#if BUILDFLAG(COBALT_MEDIA_ENABLE_CVAL)
,
cval_stats_(&interface->cval_stats_),
Expand Down Expand Up @@ -373,9 +373,9 @@ void SbPlayerBridge::WriteBuffers(
DemuxerStream::Type type,
const std::vector<scoped_refptr<DecoderBuffer>>& buffers) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
DCHECK(!is_url_based_);
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

#if BUILDFLAG(COBALT_MEDIA_ENABLE_SUSPEND_RESUME)
if (allow_resume_after_suspend_) {
Expand Down Expand Up @@ -512,7 +512,7 @@ SbPlayerBridge::GetAudioConfigurations() {
return configurations;
}

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
void SbPlayerBridge::GetUrlPlayerBufferedTimeRanges(
TimeDelta* buffer_start_time,
TimeDelta* buffer_length_time) {
Expand Down Expand Up @@ -600,7 +600,7 @@ void SbPlayerBridge::SetDrmSystem(SbDrmSystem drm_system) {
drm_system_ = drm_system;
sbplayer_interface_->SetUrlPlayerDrmSystem(player_, drm_system);
}
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

void SbPlayerBridge::Suspend() {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
Expand Down Expand Up @@ -646,7 +646,7 @@ void SbPlayerBridge::Resume(SbWindow window) {
decoder_buffer_cache_.StartResuming();
#endif // BUILDFLAG(COBALT_MEDIA_ENABLE_SUSPEND_RESUME)

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
if (is_url_based_) {
CreateUrlPlayer(url_);
if (SbDrmSystemIsValid(drm_system_)) {
Expand All @@ -655,17 +655,17 @@ void SbPlayerBridge::Resume(SbWindow window) {
} else {
CreatePlayer();
}
#else // SB_HAS(PLAYER_WITH_URL)
#else // BUILDFLAG(IS_IOS_TVOS)
CreatePlayer();
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

if (SbPlayerIsValid(player_)) {
state_ = kResuming;
UpdateBounds();
}
}

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
// static
void SbPlayerBridge::EncryptedMediaInitDataEncounteredCB(
SbPlayer player,
Expand Down Expand Up @@ -715,7 +715,7 @@ void SbPlayerBridge::CreateUrlPlayer(const std::string& url) {

UpdateBounds();
}
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

void SbPlayerBridge::CreatePlayer() {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
Expand Down Expand Up @@ -842,9 +842,9 @@ void SbPlayerBridge::CreatePlayer() {
void SbPlayerBridge::WriteNextBuffersFromCache(DemuxerStream::Type type,
int max_buffers_per_write) {
DCHECK(state_ != kSuspended);
#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
DCHECK(!is_url_based_);
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

DCHECK(SbPlayerIsValid(player_));

Expand Down Expand Up @@ -875,9 +875,9 @@ void SbPlayerBridge::WriteBuffersInternal(
const SbMediaAudioStreamInfo* audio_stream_info,
const SbMediaVideoStreamInfo* video_stream_info) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
DCHECK(!is_url_based_);
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

auto sample_type = DemuxerStreamTypeToSbMediaType(type);
if (buffers.size() == 1 && buffers[0]->end_of_stream()) {
Expand Down Expand Up @@ -1112,9 +1112,9 @@ void SbPlayerBridge::OnDecoderStatus(SbPlayer player,
SbMediaType type,
SbPlayerDecoderState state,
int ticket) {
#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
DCHECK(!is_url_based_);
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)
DCHECK(task_runner_->RunsTasksInCurrentSequence());

if (player_ != player || ticket != ticket_) {
Expand Down Expand Up @@ -1230,9 +1230,9 @@ void SbPlayerBridge::OnPlayerError(SbPlayer player,
}

void SbPlayerBridge::OnDeallocateSample(const void* sample_buffer) {
#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
DCHECK(!is_url_based_);
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)
DCHECK(task_runner_->RunsTasksInCurrentSequence());

if (enable_batched_buffer_deallocation_) {
Expand Down Expand Up @@ -1447,7 +1447,7 @@ void SbPlayerBridge::DeallocateSampleCB(SbPlayer player,
sample_buffer));
}

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
SbPlayerOutputMode SbPlayerBridge::ComputeSbUrlPlayerOutputMode(
SbPlayerOutputMode default_output_mode) {
// Try to choose the output mode according to the passed in value of
Expand All @@ -1468,7 +1468,7 @@ SbPlayerOutputMode SbPlayerBridge::ComputeSbUrlPlayerOutputMode(

return output_mode;
}
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

SbPlayerOutputMode SbPlayerBridge::ComputeSbPlayerOutputMode(
SbPlayerOutputMode default_output_mode) const {
Expand Down
25 changes: 13 additions & 12 deletions media/starboard/sbplayer_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/decoder_buffer.h"
#include "media/base/demuxer_stream.h"
Expand Down Expand Up @@ -77,7 +78,7 @@ class SbPlayerBridge {
using GetDecodeTargetGraphicsContextProviderFunc =
base::RepeatingCallback<SbDecodeTargetGraphicsContextProvider*()>;

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
using OnEncryptedMediaInitDataEncounteredCB = base::RepeatingCallback<
void(const char*, const unsigned char*, unsigned)>;
// Create an SbPlayerBridge with url-based player.
Expand All @@ -95,7 +96,7 @@ class SbPlayerBridge {
std::string pipeline_identifier
#endif // BUILDFLAG(COBALT_MEDIA_ENABLE_CVAL)
);
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)
using ExperimentalFeatures = StarboardRendererConfig::ExperimentalFeatures;
// Create a SbPlayerBridge with normal player
SbPlayerBridge(SbPlayerInterface* interface,
Expand Down Expand Up @@ -146,14 +147,14 @@ class SbPlayerBridge {
void GetInfo(PlayerInfo* out_info);
std::vector<SbMediaAudioConfiguration> GetAudioConfigurations();

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
void GetUrlPlayerBufferedTimeRanges(base::TimeDelta* buffer_start_time,
base::TimeDelta* buffer_length_time);
void GetVideoResolution(int* frame_width, int* frame_height);
base::TimeDelta GetDuration();
base::TimeDelta GetStartDate();
void SetDrmSystem(SbDrmSystem drm_system);
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

void Suspend();
// TODO: This is temporary for supporting background media playback.
Expand Down Expand Up @@ -211,7 +212,7 @@ class SbPlayerBridge {
absl::flat_hash_map<const DecoderBuffer::Allocator::Handle,
DecodingBuffer>;

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
OnEncryptedMediaInitDataEncounteredCB
on_encrypted_media_init_data_encountered_cb_;

Expand All @@ -223,7 +224,7 @@ class SbPlayerBridge {
unsigned int init_data_length);

void CreateUrlPlayer(const std::string& url);
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)
void CreatePlayer();

#if BUILDFLAG(COBALT_MEDIA_ENABLE_SUSPEND_RESUME)
Expand Down Expand Up @@ -285,10 +286,10 @@ class SbPlayerBridge {
void* context,
const void* sample_buffer);

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
SbPlayerOutputMode ComputeSbUrlPlayerOutputMode(
SbPlayerOutputMode default_output_mode);
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)
// Returns the output mode that should be used for a video with the given
// specifications.
SbPlayerOutputMode ComputeSbPlayerOutputMode(
Expand All @@ -298,9 +299,9 @@ class SbPlayerBridge {
void SendColorSpaceHistogram() const;

// The following variables are initialized in the ctor and never changed.
#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
std::string url_;
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)
SbPlayerInterface* sbplayer_interface_;
const scoped_refptr<base::SequencedTaskRunner> task_runner_;
const GetDecodeTargetGraphicsContextProviderFunc
Expand Down Expand Up @@ -384,9 +385,9 @@ class SbPlayerBridge {
base::Time first_video_sample_time_{};
base::Time sb_player_state_presenting_time_{};

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
const bool is_url_based_;
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

// Used for Gathered Sample Write.
bool pending_audio_eos_buffer_ = false;
Expand Down
4 changes: 2 additions & 2 deletions media/starboard/sbplayer_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ SbDecodeTarget DefaultSbPlayerInterface::GetCurrentFrame(SbPlayer player) {
return current_frame;
}

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
SbPlayer DefaultSbPlayerInterface::CreateUrlPlayer(
const char* url,
SbWindow window,
Expand Down Expand Up @@ -188,7 +188,7 @@ void DefaultSbPlayerInterface::GetUrlPlayerExtraInfo(
SbUrlPlayerExtraInfo* out_url_player_info) {
SbUrlPlayerGetExtraInfo(player, out_url_player_info);
}
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

bool DefaultSbPlayerInterface::GetAudioConfiguration(
SbPlayer player,
Expand Down
15 changes: 8 additions & 7 deletions media/starboard/sbplayer_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define MEDIA_STARBOARD_SBPLAYER_INTERFACE_H_

#include "base/time/time.h"
#include "build/build_config.h"
#include "media/starboard/buildflags.h"
#include "starboard/player.h"

Expand All @@ -26,9 +27,9 @@
#include "cobalt/media/base/metrics_provider.h"
#endif // BUILDFLAG(COBALT_MEDIA_ENABLE_UMA_METRICS)

#if SB_HAS(PLAYER_WITH_URL)
#include SB_URL_PLAYER_INCLUDE_PATH
#endif // SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
#include "starboard/tvos/shared/media/url_player.h"
#endif // BUILDFLAG(IS_IOS_TVOS)
Comment thread
abhijeetk marked this conversation as resolved.

namespace media {

Expand Down Expand Up @@ -73,7 +74,7 @@ class SbPlayerInterface {

virtual SbDecodeTarget GetCurrentFrame(SbPlayer player) = 0;

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
virtual SbPlayer CreateUrlPlayer(const char* url,
SbWindow window,
SbPlayerStatusFunc player_status_func,
Expand All @@ -88,7 +89,7 @@ class SbPlayerInterface {
virtual void GetUrlPlayerExtraInfo(
SbPlayer player,
SbUrlPlayerExtraInfo* out_url_player_info) = 0;
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

virtual bool GetAudioConfiguration(
SbPlayer player,
Expand Down Expand Up @@ -171,7 +172,7 @@ class DefaultSbPlayerInterface final : public SbPlayerInterface {
void GetInfo(SbPlayer player, SbPlayerInfo* out_player_info) override;
SbDecodeTarget GetCurrentFrame(SbPlayer player) override;

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
SbPlayer CreateUrlPlayer(const char* url,
SbWindow window,
SbPlayerStatusFunc player_status_func,
Expand All @@ -184,7 +185,7 @@ class DefaultSbPlayerInterface final : public SbPlayerInterface {
void GetUrlPlayerExtraInfo(
SbPlayer player,
SbUrlPlayerExtraInfo* out_url_player_info) override;
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

bool GetAudioConfiguration(
SbPlayer player,
Expand Down
5 changes: 3 additions & 2 deletions media/starboard/starboard_renderer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "base/test/gmock_callback_support.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "media/base/demuxer_stream.h"
#include "media/base/media_util.h"
#include "media/base/mock_filters.h"
Expand Down Expand Up @@ -93,7 +94,7 @@ class MockSbPlayerInterface : public SbPlayerInterface {
return kSbDecodeTargetInvalid;
}

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
MOCK_METHOD6(CreateUrlPlayer,
SbPlayer(const char*,
SbWindow,
Expand All @@ -108,7 +109,7 @@ class MockSbPlayerInterface : public SbPlayerInterface {
SbPlayerOutputMode output_mode) override {
return true;
}
#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

bool GetAudioConfiguration(
SbPlayer player,
Expand Down
11 changes: 6 additions & 5 deletions starboard/nplb/url_player_create_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@

#include <vector>

#include "build/build_config.h"
#include "starboard/decode_target.h"
#include "starboard/player.h"

#if SB_HAS(PLAYER_WITH_URL)
#include "starboard/shared/uikit/url_player.h"
#endif // SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)
#include "starboard/tvos/shared/media/url_player.h"
#endif // BUILDFLAG(IS_IOS_TVOS)
Comment thread
abhijeetk marked this conversation as resolved.

#include "starboard/window.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace nplb {
namespace {

#if SB_HAS(PLAYER_WITH_URL)
#if BUILDFLAG(IS_IOS_TVOS)

const char kPlayerUrl[] = "about:blank";

Expand Down Expand Up @@ -159,7 +160,7 @@ TEST(SbPlayerUrlTest, MultiPlayer) {
SbWindowDestroy(window);
}

#endif // SB_HAS(PLAYER_WITH_URL)
#endif // BUILDFLAG(IS_IOS_TVOS)

} // namespace
} // namespace nplb
Loading
Loading