Skip to content

Commit

Permalink
[media] Add more logs for output mode (#1865)
Browse files Browse the repository at this point in the history
Also replaced some SB_LOG()/SB_DCHECK() macros in Cobalt to
LOG()/DCHECK().

b/307326956

Change-Id: I7f4763fc78c5d813629983fd9f08987d886567aa
  • Loading branch information
xiaomings authored Oct 27, 2023
1 parent 74a344b commit e7177db
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
4 changes: 4 additions & 0 deletions cobalt/dom/html_media_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,10 @@ void HTMLMediaElement::SetMaxVideoCapabilities(
exception_state);
return;
}

LOG(INFO) << "max video capabilities is changed from \""
<< max_video_capabilities_ << "\" to \"" << max_video_capabilities
<< "\"";
max_video_capabilities_ = max_video_capabilities;
}

Expand Down
38 changes: 20 additions & 18 deletions cobalt/media/base/sbplayer_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace media {

namespace {

using starboard::FormatString;
using starboard::GetPlayerOutputModeName;

class StatisticsWrapper {
Expand Down Expand Up @@ -707,9 +708,9 @@ void SbPlayerBridge::CreateUrlPlayer(const std::string& url) {
// a method of querying that texture.
decode_target_provider_->SetGetCurrentSbDecodeTargetFunction(base::Bind(
&SbPlayerBridge::GetCurrentSbDecodeTarget, base::Unretained(this)));
SB_LOG(INFO) << "Playing in decode-to-texture mode.";
LOG(INFO) << "Playing in decode-to-texture mode.";
} else {
SB_LOG(INFO) << "Playing in punch-out mode.";
LOG(INFO) << "Playing in punch-out mode.";
}

decode_target_provider_->SetOutputMode(
Expand Down Expand Up @@ -777,9 +778,9 @@ void SbPlayerBridge::CreatePlayer() {
// a method of querying that texture.
decode_target_provider_->SetGetCurrentSbDecodeTargetFunction(base::Bind(
&SbPlayerBridge::GetCurrentSbDecodeTarget, base::Unretained(this)));
SB_LOG(INFO) << "Playing in decode-to-texture mode.";
LOG(INFO) << "Playing in decode-to-texture mode.";
} else {
SB_LOG(INFO) << "Playing in punch-out mode.";
LOG(INFO) << "Playing in punch-out mode.";
}

decode_target_provider_->SetOutputMode(
Expand Down Expand Up @@ -1237,8 +1238,8 @@ SbPlayerOutputMode SbPlayerBridge::ComputeSbPlayerOutputMode(

if (default_output_mode != kSbPlayerOutputModeDecodeToTexture &&
video_stream_info_.codec != kSbMediaVideoCodecNone) {
SB_DCHECK(video_stream_info_.mime);
SB_DCHECK(video_stream_info_.max_video_capabilities);
DCHECK(video_stream_info_.mime);
DCHECK(video_stream_info_.max_video_capabilities);

// Set the `default_output_mode` to `kSbPlayerOutputModeDecodeToTexture` if
// any of the mime associated with it has `decode-to-texture=true` set.
Expand All @@ -1250,13 +1251,12 @@ SbPlayerOutputMode SbPlayerBridge::ComputeSbPlayerOutputMode(
"decode-to-texture=true");

if (is_decode_to_texture_preferred) {
SB_LOG(INFO) << "Setting `default_output_mode` from \""
<< GetPlayerOutputModeName(default_output_mode) << "\" to \""
<< GetPlayerOutputModeName(
kSbPlayerOutputModeDecodeToTexture)
<< "\" because mime is set to \"" << video_stream_info_.mime
<< "\", and max_video_capabilities is set to \""
<< video_stream_info_.max_video_capabilities << "\"";
LOG(INFO) << "Setting `default_output_mode` from \""
<< GetPlayerOutputModeName(default_output_mode) << "\" to \""
<< GetPlayerOutputModeName(kSbPlayerOutputModeDecodeToTexture)
<< "\" because mime is set to \"" << video_stream_info_.mime
<< "\", and max_video_capabilities is set to \""
<< video_stream_info_.max_video_capabilities << "\"";
default_output_mode = kSbPlayerOutputModeDecodeToTexture;
}
}
Expand All @@ -1265,22 +1265,24 @@ SbPlayerOutputMode SbPlayerBridge::ComputeSbPlayerOutputMode(

auto output_mode =
sbplayer_interface_->GetPreferredOutputMode(&creation_param);

LOG(INFO) << "Output mode is set to " << GetPlayerOutputModeName(output_mode);

CHECK_NE(kSbPlayerOutputModeInvalid, output_mode);
return output_mode;
}

void SbPlayerBridge::LogStartupLatency() const {
std::string first_events_str;
if (set_drm_system_ready_cb_time_ == -1) {
first_events_str =
starboard::FormatString("%-40s0 us", "SbPlayerCreate() called");
first_events_str = FormatString("%-40s0 us", "SbPlayerCreate() called");
} else if (set_drm_system_ready_cb_time_ < player_creation_time_) {
first_events_str = starboard::FormatString(
first_events_str = FormatString(
"%-40s0 us\n%-40s%" PRId64 " us", "set_drm_system_ready_cb called",
"SbPlayerCreate() called",
player_creation_time_ - set_drm_system_ready_cb_time_);
} else {
first_events_str = starboard::FormatString(
first_events_str = FormatString(
"%-40s0 us\n%-40s%" PRId64 " us", "SbPlayerCreate() called",
"set_drm_system_ready_cb called",
set_drm_system_ready_cb_time_ - player_creation_time_);
Expand All @@ -1305,7 +1307,7 @@ void SbPlayerBridge::LogStartupLatency() const {
1);

// clang-format off
LOG(INFO) << starboard::FormatString(
LOG(INFO) << FormatString(
"\nSbPlayer startup latencies: %" PRId64 " us\n"
" Event name time since last event\n"
" %s\n" // |first_events_str| populated above
Expand Down
9 changes: 9 additions & 0 deletions starboard/android/shared/video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "starboard/android/shared/media_common.h"
#include "starboard/android/shared/video_render_algorithm.h"
#include "starboard/android/shared/window_internal.h"
#include "starboard/common/media.h"
#include "starboard/common/player.h"
#include "starboard/common/string.h"
#include "starboard/configuration.h"
#include "starboard/decode_target.h"
Expand Down Expand Up @@ -395,6 +397,13 @@ VideoDecoder::VideoDecoder(const VideoStreamInfo& video_stream_info,
TeardownCodec();
}
}

SB_LOG(INFO) << "Created VideoDecoder for codec "
<< GetMediaVideoCodecName(video_codec_) << ", with output mode "
<< GetPlayerOutputModeName(output_mode_)
<< ", max video capabilities \"" << max_video_capabilities_
<< "\", and tunnel mode audio session id "
<< tunnel_mode_audio_session_id_;
}

VideoDecoder::~VideoDecoder() {
Expand Down

0 comments on commit e7177db

Please sign in to comment.