Skip to content

Commit

Permalink
[media] Setup code formatting for //media/starboard (#4285)
Browse files Browse the repository at this point in the history
1. Add //media/starboard/ to .github/CODEOWNERS and
.pre-commit-config.yaml so any files in it will be re-formatted during
pre-commit.
2. Format all files in it, without any other modifications, to set them
up for future changes.

b/328305706
  • Loading branch information
xiaomings authored and borongc committed Nov 27, 2024
1 parent 43c5de1 commit e3d899b
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 76 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* @youtube/cobalt-3p-repository-owners
/.github/ # no owners
/cobalt/ # no owners
/media/starboard/ # no owners
/starboard/ # no owners
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ files: |
(?x)^(
.github/|
cobalt/|
media/starboard/|
starboard/|
.pre-commit-config.yaml|
.pylintrc|
Expand Down
66 changes: 45 additions & 21 deletions media/starboard/sbplayer_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@ void SbPlayerBridge::CallbackHelper::ResetPlayer() {
SbPlayerBridge::SbPlayerBridge(
SbPlayerInterface* interface,
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const std::string& url, SbWindow window, Host* host,
SbPlayerSetBoundsHelper* set_bounds_helper, bool allow_resume_after_suspend,
const std::string& url,
SbWindow window,
Host* host,
SbPlayerSetBoundsHelper* set_bounds_helper,
bool allow_resume_after_suspend,
SbPlayerOutputMode default_output_mode,
const OnEncryptedMediaInitDataEncounteredCB&
on_encrypted_media_init_data_encountered_cb,
Expand Down Expand Up @@ -217,13 +220,19 @@ SbPlayerBridge::SbPlayerBridge(
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const GetDecodeTargetGraphicsContextProviderFunc&
get_decode_target_graphics_context_provider_func,
const AudioDecoderConfig& audio_config, const std::string& audio_mime_type,
const VideoDecoderConfig& video_config, const std::string& video_mime_type,
SbWindow window, SbDrmSystem drm_system, Host* host,
SbPlayerSetBoundsHelper* set_bounds_helper, bool allow_resume_after_suspend,
const AudioDecoderConfig& audio_config,
const std::string& audio_mime_type,
const VideoDecoderConfig& video_config,
const std::string& video_mime_type,
SbWindow window,
SbDrmSystem drm_system,
Host* host,
SbPlayerSetBoundsHelper* set_bounds_helper,
bool allow_resume_after_suspend,
SbPlayerOutputMode default_output_mode,
DecodeTargetProvider* const decode_target_provider,
const std::string& max_video_capabilities, int max_video_input_size,
const std::string& max_video_capabilities,
int max_video_input_size,
std::string pipeline_identifier)
: sbplayer_interface_(interface),
task_runner_(task_runner),
Expand Down Expand Up @@ -486,7 +495,8 @@ SbPlayerBridge::GetAudioConfigurations() {

#if SB_HAS(PLAYER_WITH_URL)
void SbPlayerBridge::GetUrlPlayerBufferedTimeRanges(
TimeDelta* buffer_start_time, TimeDelta* buffer_length_time) {
TimeDelta* buffer_start_time,
TimeDelta* buffer_length_time) {
DCHECK(buffer_start_time || buffer_length_time);
DCHECK(is_url_based_);

Expand Down Expand Up @@ -659,8 +669,11 @@ DecodeTargetProvider::OutputMode ToVideoFrameProviderOutputMode(
#if SB_HAS(PLAYER_WITH_URL)
// static
void SbPlayerBridge::EncryptedMediaInitDataEncounteredCB(
SbPlayer player, void* context, const char* init_data_type,
const unsigned char* init_data, unsigned int init_data_length) {
SbPlayer player,
void* context,
const char* init_data_type,
const unsigned char* init_data,
unsigned int init_data_length) {
SbPlayerBridge* helper = static_cast<SbPlayerBridge*>(context);
DCHECK(!helper->on_encrypted_media_init_data_encountered_cb_.is_null());
// TODO: Use callback_helper here.
Expand Down Expand Up @@ -1018,8 +1031,10 @@ void SbPlayerBridge::ClearDecoderBufferCache() {
TimeDelta::FromMilliseconds(kClearDecoderCacheIntervalInMilliseconds));
}

void SbPlayerBridge::OnDecoderStatus(SbPlayer player, SbMediaType type,
SbPlayerDecoderState state, int ticket) {
void SbPlayerBridge::OnDecoderStatus(SbPlayer player,
SbMediaType type,
SbPlayerDecoderState state,
int ticket) {
#if SB_HAS(PLAYER_WITH_URL)
DCHECK(!is_url_based_);
#endif // SB_HAS(PLAYER_WITH_URL)
Expand Down Expand Up @@ -1064,7 +1079,8 @@ void SbPlayerBridge::OnDecoderStatus(SbPlayer player, SbMediaType type,
host_->OnNeedData(stream_type, max_number_of_samples_to_write);
}

void SbPlayerBridge::OnPlayerStatus(SbPlayer player, SbPlayerState state,
void SbPlayerBridge::OnPlayerStatus(SbPlayer player,
SbPlayerState state,
int ticket) {
TRACE_EVENT1("cobalt::media", "SbPlayerBridge::OnPlayerStatus", "state",
state);
Expand Down Expand Up @@ -1105,7 +1121,8 @@ void SbPlayerBridge::OnPlayerStatus(SbPlayer player, SbPlayerState state,
host_->OnPlayerStatus(state);
}

void SbPlayerBridge::OnPlayerError(SbPlayer player, SbPlayerError error,
void SbPlayerBridge::OnPlayerError(SbPlayer player,
SbPlayerError error,
const std::string& message) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());

Expand Down Expand Up @@ -1148,9 +1165,11 @@ bool SbPlayerBridge::TryToSetPlayerCreationErrorMessage(
}

// static
void SbPlayerBridge::DecoderStatusCB(SbPlayer player, void* context,
void SbPlayerBridge::DecoderStatusCB(SbPlayer player,
void* context,
SbMediaType type,
SbPlayerDecoderState state, int ticket) {
SbPlayerDecoderState state,
int ticket) {
SbPlayerBridge* helper = static_cast<SbPlayerBridge*>(context);
helper->task_runner_->PostTask(
FROM_HERE,
Expand All @@ -1159,17 +1178,21 @@ void SbPlayerBridge::DecoderStatusCB(SbPlayer player, void* context,
}

// static
void SbPlayerBridge::PlayerStatusCB(SbPlayer player, void* context,
SbPlayerState state, int ticket) {
void SbPlayerBridge::PlayerStatusCB(SbPlayer player,
void* context,
SbPlayerState state,
int ticket) {
SbPlayerBridge* helper = static_cast<SbPlayerBridge*>(context);
helper->task_runner_->PostTask(
FROM_HERE, base::Bind(&SbPlayerBridge::CallbackHelper::OnPlayerStatus,
helper->callback_helper_, player, state, ticket));
}

// static
void SbPlayerBridge::PlayerErrorCB(SbPlayer player, void* context,
SbPlayerError error, const char* message) {
void SbPlayerBridge::PlayerErrorCB(SbPlayer player,
void* context,
SbPlayerError error,
const char* message) {
SbPlayerBridge* helper = static_cast<SbPlayerBridge*>(context);
if (player == kSbPlayerInvalid) {
// TODO: Simplify by combining the functionality of
Expand All @@ -1185,7 +1208,8 @@ void SbPlayerBridge::PlayerErrorCB(SbPlayer player, void* context,
}

// static
void SbPlayerBridge::DeallocateSampleCB(SbPlayer player, void* context,
void SbPlayerBridge::DeallocateSampleCB(SbPlayer player,
void* context,
const void* sample_buffer) {
SbPlayerBridge* helper = static_cast<SbPlayerBridge*>(context);
helper->task_runner_->PostTask(
Expand Down
61 changes: 42 additions & 19 deletions media/starboard/sbplayer_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class SbPlayerBridge {
// Create an SbPlayerBridge with url-based player.
SbPlayerBridge(SbPlayerInterface* interface,
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const std::string& url, SbWindow window, Host* host,
const std::string& url,
SbWindow window,
Host* host,
SbPlayerSetBoundsHelper* set_bounds_helper,
bool allow_resume_after_suspend,
SbPlayerOutputMode default_output_mode,
Expand All @@ -88,14 +90,17 @@ class SbPlayerBridge {
const AudioDecoderConfig& audio_config,
const std::string& audio_mime_type,
const VideoDecoderConfig& video_config,
const std::string& video_mime_type, SbWindow window,
SbDrmSystem drm_system, Host* host,
const std::string& video_mime_type,
SbWindow window,
SbDrmSystem drm_system,
Host* host,
SbPlayerSetBoundsHelper* set_bounds_helper,
bool allow_resume_after_suspend,
SbPlayerOutputMode default_output_mode,
DecodeTargetProvider* const decode_target_provider,
const std::string& max_video_capabilities,
int max_video_input_size, std::string pipeline_identifier);
int max_video_input_size,
std::string pipeline_identifier);

~SbPlayerBridge();

Expand All @@ -116,7 +121,8 @@ class SbPlayerBridge {

void SetVolume(float volume);
void SetPlaybackRate(double playback_rate);
void GetInfo(uint32* video_frames_decoded, uint32* video_frames_dropped,
void GetInfo(uint32* video_frames_decoded,
uint32* video_frames_dropped,
base::TimeDelta* media_time);
std::vector<SbMediaAudioConfiguration> GetAudioConfigurations();

Expand Down Expand Up @@ -165,10 +171,13 @@ class SbPlayerBridge {

void ClearDecoderBufferCache();

void OnDecoderStatus(SbPlayer player, SbMediaType type,
SbPlayerDecoderState state, int ticket);
void OnDecoderStatus(SbPlayer player,
SbMediaType type,
SbPlayerDecoderState state,
int ticket);
void OnPlayerStatus(SbPlayer player, SbPlayerState state, int ticket);
void OnPlayerError(SbPlayer player, SbPlayerError error,
void OnPlayerError(SbPlayer player,
SbPlayerError error,
const std::string& message);
void OnDeallocateSample(const void* sample_buffer);

Expand All @@ -193,8 +202,11 @@ class SbPlayerBridge {
on_encrypted_media_init_data_encountered_cb_;

static void EncryptedMediaInitDataEncounteredCB(
SbPlayer player, void* context, const char* init_data_type,
const unsigned char* init_data, unsigned int init_data_length);
SbPlayer player,
void* context,
const char* init_data_type,
const unsigned char* init_data,
unsigned int init_data_length);

void CreateUrlPlayer(const std::string& url);
#endif // SB_HAS(PLAYER_WITH_URL)
Expand All @@ -217,20 +229,31 @@ class SbPlayerBridge {

void ClearDecoderBufferCache();

void OnDecoderStatus(SbPlayer player, SbMediaType type,
SbPlayerDecoderState state, int ticket);
void OnDecoderStatus(SbPlayer player,
SbMediaType type,
SbPlayerDecoderState state,
int ticket);
void OnPlayerStatus(SbPlayer player, SbPlayerState state, int ticket);
void OnPlayerError(SbPlayer player, SbPlayerError error,
void OnPlayerError(SbPlayer player,
SbPlayerError error,
const std::string& message);
void OnDeallocateSample(const void* sample_buffer);

static void DecoderStatusCB(SbPlayer player, void* context, SbMediaType type,
SbPlayerDecoderState state, int ticket);
static void PlayerStatusCB(SbPlayer player, void* context,
SbPlayerState state, int ticket);
static void PlayerErrorCB(SbPlayer player, void* context, SbPlayerError error,
static void DecoderStatusCB(SbPlayer player,
void* context,
SbMediaType type,
SbPlayerDecoderState state,
int ticket);
static void PlayerStatusCB(SbPlayer player,
void* context,
SbPlayerState state,
int ticket);
static void PlayerErrorCB(SbPlayer player,
void* context,
SbPlayerError error,
const char* message);
static void DeallocateSampleCB(SbPlayer player, void* context,
static void DeallocateSampleCB(SbPlayer player,
void* context,
const void* sample_buffer);

#if SB_HAS(PLAYER_WITH_URL)
Expand Down
42 changes: 29 additions & 13 deletions media/starboard/sbplayer_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ DefaultSbPlayerInterface::DefaultSbPlayerInterface() {
}

SbPlayer DefaultSbPlayerInterface::Create(
SbWindow window, const SbPlayerCreationParam* creation_param,
SbWindow window,
const SbPlayerCreationParam* creation_param,
SbPlayerDeallocateSampleFunc sample_deallocate_func,
SbPlayerDecoderStatusFunc decoder_status_func,
SbPlayerStatusFunc player_status_func, SbPlayerErrorFunc player_error_func,
void* context, SbDecodeTargetGraphicsContextProvider* context_provider) {
SbPlayerStatusFunc player_status_func,
SbPlayerErrorFunc player_error_func,
void* context,
SbDecodeTargetGraphicsContextProvider* context_provider) {
media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_CREATE);
auto player = SbPlayerCreate(window, creation_param, sample_deallocate_func,
decoder_status_func, player_status_func,
Expand Down Expand Up @@ -106,15 +109,18 @@ bool DefaultSbPlayerInterface::IsEnhancedAudioExtensionEnabled() const {
}

void DefaultSbPlayerInterface::WriteSamples(
SbPlayer player, SbMediaType sample_type,
const SbPlayerSampleInfo* sample_infos, int number_of_sample_infos) {
SbPlayer player,
SbMediaType sample_type,
const SbPlayerSampleInfo* sample_infos,
int number_of_sample_infos) {
DCHECK(!IsEnhancedAudioExtensionEnabled());
SbPlayerWriteSamples(player, sample_type, sample_infos,
number_of_sample_infos);
}

void DefaultSbPlayerInterface::WriteSamples(
SbPlayer player, SbMediaType sample_type,
SbPlayer player,
SbMediaType sample_type,
const CobaltExtensionEnhancedAudioPlayerSampleInfo* sample_infos,
int number_of_sample_infos) {
DCHECK(IsEnhancedAudioExtensionEnabled());
Expand All @@ -123,7 +129,8 @@ void DefaultSbPlayerInterface::WriteSamples(
}

int DefaultSbPlayerInterface::GetMaximumNumberOfSamplesPerWrite(
SbPlayer player, SbMediaType sample_type) {
SbPlayer player,
SbMediaType sample_type) {
return SbPlayerGetMaximumNumberOfSamplesPerWrite(player, sample_type);
}

Expand All @@ -137,8 +144,12 @@ void DefaultSbPlayerInterface::WriteEndOfStream(SbPlayer player,
media_metrics_provider_.EndTrackingAction(media_action);
}

void DefaultSbPlayerInterface::SetBounds(SbPlayer player, int z_index, int x,
int y, int width, int height) {
void DefaultSbPlayerInterface::SetBounds(SbPlayer player,
int z_index,
int x,
int y,
int width,
int height) {
media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_SET_BOUNDS);
SbPlayerSetBounds(player, z_index, x, y, width, height);
media_metrics_provider_.EndTrackingAction(MediaAction::SBPLAYER_SET_BOUNDS);
Expand Down Expand Up @@ -178,10 +189,13 @@ SbDecodeTarget DefaultSbPlayerInterface::GetCurrentFrame(SbPlayer player) {

#if SB_HAS(PLAYER_WITH_URL)
SbPlayer DefaultSbPlayerInterface::CreateUrlPlayer(
const char* url, SbWindow window, SbPlayerStatusFunc player_status_func,
const char* url,
SbWindow window,
SbPlayerStatusFunc player_status_func,
SbPlayerEncryptedMediaInitDataEncounteredCB
encrypted_media_init_data_encountered_cb,
SbPlayerErrorFunc player_error_func, void* context) {
SbPlayerErrorFunc player_error_func,
void* context) {
media_metrics_provider_.StartTrackingAction(
MediaAction::SBPLAYER_CREATE_URL_PLAYER);
auto player = SbUrlPlayerCreate(url, window, player_status_func,
Expand All @@ -203,13 +217,15 @@ bool DefaultSbPlayerInterface::GetUrlPlayerOutputModeSupported(
}

void DefaultSbPlayerInterface::GetUrlPlayerExtraInfo(
SbPlayer player, SbUrlPlayerExtraInfo* out_url_player_info) {
SbPlayer player,
SbUrlPlayerExtraInfo* out_url_player_info) {
SbUrlPlayerGetExtraInfo(player, out_url_player_info);
}
#endif // SB_HAS(PLAYER_WITH_URL)

bool DefaultSbPlayerInterface::GetAudioConfiguration(
SbPlayer player, int index,
SbPlayer player,
int index,
SbMediaAudioConfiguration* out_audio_configuration) {
media_metrics_provider_.StartTrackingAction(
MediaAction::SBPLAYER_GET_AUDIO_CONFIG);
Expand Down
Loading

0 comments on commit e3d899b

Please sign in to comment.