Skip to content

Commit

Permalink
Force reset surface view for every playback
Browse files Browse the repository at this point in the history
b/380880749
  • Loading branch information
jasonzhangxx committed Nov 25, 2024
1 parent 8a934a6 commit 9c98b50
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
11 changes: 9 additions & 2 deletions starboard/android/shared/player_components_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player::
std::string* error_message) {
bool force_big_endian_hdr_metadata = false;
bool enable_flush_during_seek = false;
// The default value of |force_reset_surface| would be true.
bool force_reset_surface = true;
if (creation_parameters.video_codec() != kSbMediaVideoCodecNone &&
!creation_parameters.video_mime().empty()) {
// Use mime param to determine endianness of HDR metadata. If param is
Expand All @@ -550,6 +552,10 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player::
video_mime_type.ValidateBoolParameter("enableflushduringseek");
enable_flush_during_seek =
video_mime_type.GetParamBoolValue("enableflushduringseek", false);

video_mime_type.ValidateBoolParameter("forceresetsurface");
force_reset_surface =
video_mime_type.GetParamBoolValue("forceresetsurface", true);
}
if (kForceFlushDecoderDuringReset && !enable_flush_during_seek) {
SB_LOG(INFO)
Expand All @@ -564,8 +570,9 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player::
creation_parameters.decode_target_graphics_context_provider(),
creation_parameters.max_video_capabilities(),
tunnel_mode_audio_session_id, force_secure_pipeline_under_tunnel_mode,
kForceResetSurfaceUnderTunnelMode, force_big_endian_hdr_metadata,
max_video_input_size, enable_flush_during_seek, error_message));
force_reset_surface, kForceResetSurfaceUnderTunnelMode,
force_big_endian_hdr_metadata, max_video_input_size,
enable_flush_during_seek, error_message));
if (creation_parameters.video_codec() == kSbMediaVideoCodecAv1 ||
video_decoder->is_decoder_created()) {
return video_decoder;
Expand Down
4 changes: 3 additions & 1 deletion starboard/android/shared/video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ VideoDecoder::VideoDecoder(const VideoStreamInfo& video_stream_info,
const std::string& max_video_capabilities,
int tunnel_mode_audio_session_id,
bool force_secure_pipeline_under_tunnel_mode,
bool force_reset_surface,
bool force_reset_surface_under_tunnel_mode,
bool force_big_endian_hdr_metadata,
int max_video_input_size,
Expand All @@ -367,6 +368,7 @@ VideoDecoder::VideoDecoder(const VideoStreamInfo& video_stream_info,
tunnel_mode_audio_session_id_(tunnel_mode_audio_session_id),
max_video_input_size_(max_video_input_size),
enable_flush_during_seek_(enable_flush_during_seek),
force_reset_surface_(force_reset_surface),
force_reset_surface_under_tunnel_mode_(
force_reset_surface_under_tunnel_mode),
is_video_frame_tracker_enabled_(IsFrameRenderedCallbackEnabled() ||
Expand Down Expand Up @@ -415,7 +417,7 @@ VideoDecoder::~VideoDecoder() {
if (tunnel_mode_audio_session_id_ != -1) {
ClearVideoWindow(force_reset_surface_under_tunnel_mode_);
} else {
ClearVideoWindow(false);
ClearVideoWindow(force_reset_surface_);
}
}

Expand Down
5 changes: 5 additions & 0 deletions starboard/android/shared/video_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class VideoDecoder
const std::string& max_video_capabilities,
int tunnel_mode_audio_session_id,
bool force_secure_pipeline_under_tunnel_mode,
bool force_reset_surface,
bool force_reset_surface_under_tunnel_mode,
bool force_big_endian_hdr_metadata,
int max_input_size,
Expand Down Expand Up @@ -153,9 +154,13 @@ class VideoDecoder

const bool enable_flush_during_seek_;

// Force resetting the video surface after every playback.
const bool force_reset_surface_;

// Force resetting the video surface after tunnel mode playback, which
// prevents video distortion on some devices.
const bool force_reset_surface_under_tunnel_mode_;

// On some platforms tunnel mode is only supported in the secure pipeline. So
// we create a dummy drm system to force the video playing in secure pipeline
// to enable tunnel mode.
Expand Down
1 change: 1 addition & 0 deletions starboard/android/shared/video_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ void VideoSurfaceHolder::ClearVideoWindow(bool force_reset_surface) {

if (force_reset_surface) {
env->CallStarboardVoidMethodOrAbort("resetVideoSurface", "()V");
SB_LOG(INFO) << "Video surface has been reset.";
return;
} else if (g_reset_surface_on_clear_window) {
int width = ANativeWindow_getWidth(g_native_video_window);
Expand Down

0 comments on commit 9c98b50

Please sign in to comment.