Skip to content

Commit

Permalink
Avoid redundant player bounds setting
Browse files Browse the repository at this point in the history
1. Only change player bounds when there's a change.
2. Change Surface bounds from VideoRendererSink instead of hacking codde
   in SbPlayerSetBounds().

b/377754564
  • Loading branch information
jasonzhangxx committed Jan 23, 2025
1 parent e8334d7 commit 8393365
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 37 deletions.
2 changes: 0 additions & 2 deletions starboard/android/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ static_library("starboard_platform") {
"player_destroy.cc",
"player_get_maximum_number_of_samples_per_write.cc",
"player_get_preferred_output_mode.cc",
"player_set_bounds.cc",
"player_set_max_video_input_size.cc",
"player_set_max_video_input_size.h",
"player_set_playback_rate.cc",
Expand Down Expand Up @@ -308,7 +307,6 @@ static_library("starboard_platform") {
"//starboard/shared/starboard/player/player_destroy.cc",
"//starboard/shared/starboard/player/player_get_maximum_number_of_samples_per_write.cc",
"//starboard/shared/starboard/player/player_get_preferred_output_mode_prefer_punchout.cc",
"//starboard/shared/starboard/player/player_set_bounds.cc",
"//starboard/shared/starboard/player/player_set_playback_rate.cc",
]

Expand Down
34 changes: 0 additions & 34 deletions starboard/android/shared/player_set_bounds.cc

This file was deleted.

16 changes: 15 additions & 1 deletion starboard/android/shared/video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,17 @@ class VideoDecoder::Sink : public VideoDecoder::VideoRendererSink {
render_cb_ = render_cb;
}

void SetBounds(int z_index, int x, int y, int width, int height) override {}
void SetBounds(int z_index, int x, int y, int width, int height) override {
if (x_ != x || y != y_ || width != width_ || height != height_) {
x_ = x;
y_ = y;
width_ = width;
height_ = height;
starboard::android::shared::JniEnvExt::Get()
->CallStarboardVoidMethodOrAbort("setVideoSurfaceBounds", "(IIII)V",
x_, y_, width_, height_);
}
}

DrawFrameStatus DrawFrame(const scoped_refptr<VideoFrame>& frame,
int64_t release_time_in_nanoseconds) {
Expand All @@ -339,6 +349,10 @@ class VideoDecoder::Sink : public VideoDecoder::VideoRendererSink {

RenderCB render_cb_;
bool rendered_;
int x_ = 0;
int y_ = 0;
int width_ = 0;
int height_ = 0;
};

VideoDecoder::VideoDecoder(const VideoStreamInfo& video_stream_info,
Expand Down

0 comments on commit 8393365

Please sign in to comment.