Commit 0cb34a43 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Add MEDIALOG_WARNING

Add a new MediaLog level so that we don't have to abuse MEDIALOG_ERROR,
which could end up in MediaError.message and should be carefully used.

Also update documentation on MediaLog levels.

Also use MEDIALOG_WARNING in audio_timestamp_validator.cc for non-fatal
issues.

Bug: 843808
Test: Manually tested and verified in about://media-internals
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I20350d305b3f55d1f59e6d2324cc3be7452bcbbe
Reviewed-on: https://chromium-review.googlesource.com/1063009Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559399}
parent 0c15cba4
...@@ -161,6 +161,8 @@ processes. Media operations are often asynchronous running in a sandbox. These ...@@ -161,6 +161,8 @@ processes. Media operations are often asynchronous running in a sandbox. These
make attaching a debugger (e.g. GDB) sometimes less efficient than other make attaching a debugger (e.g. GDB) sometimes less efficient than other
mechanisms like logging. mechanisms like logging.
## DVLOG
In media we use DVLOG() a lot. It makes filename-based filtering super easy. In media we use DVLOG() a lot. It makes filename-based filtering super easy.
Within one file, not all logs are created equal. To make log filtering Within one file, not all logs are created equal. To make log filtering
more convenient, use appropriate log levels. Here are some general more convenient, use appropriate log levels. Here are some general
...@@ -172,3 +174,10 @@ recommendations: ...@@ -172,3 +174,10 @@ recommendations:
* DVLOG(2): Recurring events per playback, e.g. seek/reset/flush, config change. * DVLOG(2): Recurring events per playback, e.g. seek/reset/flush, config change.
* DVLOG(3): Frequent events, e.g. demuxer read, audio/video buffer decrypt or * DVLOG(3): Frequent events, e.g. demuxer read, audio/video buffer decrypt or
decode, audio/video frame rendering. decode, audio/video frame rendering.
## MediaLog
MediaLog will send logs to `about://media-internals`, which is easily accessible
by developers (including web developes), testers and even users to get detailed
information about a playback instance. For guidance on how to use MediaLog, see
`media/base/media_log.h`.
\ No newline at end of file
...@@ -21,6 +21,8 @@ std::string MediaLog::MediaLogLevelToString(MediaLogLevel level) { ...@@ -21,6 +21,8 @@ std::string MediaLog::MediaLogLevelToString(MediaLogLevel level) {
switch (level) { switch (level) {
case MEDIALOG_ERROR: case MEDIALOG_ERROR:
return "error"; return "error";
case MEDIALOG_WARNING:
return "warning";
case MEDIALOG_INFO: case MEDIALOG_INFO:
return "info"; return "info";
case MEDIALOG_DEBUG: case MEDIALOG_DEBUG:
...@@ -34,6 +36,8 @@ MediaLogEvent::Type MediaLog::MediaLogLevelToEventType(MediaLogLevel level) { ...@@ -34,6 +36,8 @@ MediaLogEvent::Type MediaLog::MediaLogLevelToEventType(MediaLogLevel level) {
switch (level) { switch (level) {
case MEDIALOG_ERROR: case MEDIALOG_ERROR:
return MediaLogEvent::MEDIA_ERROR_LOG_ENTRY; return MediaLogEvent::MEDIA_ERROR_LOG_ENTRY;
case MEDIALOG_WARNING:
return MediaLogEvent::MEDIA_WARNING_LOG_ENTRY;
case MEDIALOG_INFO: case MEDIALOG_INFO:
return MediaLogEvent::MEDIA_INFO_LOG_ENTRY; return MediaLogEvent::MEDIA_INFO_LOG_ENTRY;
case MEDIALOG_DEBUG: case MEDIALOG_DEBUG:
...@@ -71,6 +75,8 @@ std::string MediaLog::EventTypeToString(MediaLogEvent::Type type) { ...@@ -71,6 +75,8 @@ std::string MediaLog::EventTypeToString(MediaLogEvent::Type type) {
return "TEXT_ENDED"; return "TEXT_ENDED";
case MediaLogEvent::MEDIA_ERROR_LOG_ENTRY: case MediaLogEvent::MEDIA_ERROR_LOG_ENTRY:
return "MEDIA_ERROR_LOG_ENTRY"; return "MEDIA_ERROR_LOG_ENTRY";
case MediaLogEvent::MEDIA_WARNING_LOG_ENTRY:
return "MEDIA_WARNING_LOG_ENTRY";
case MediaLogEvent::MEDIA_INFO_LOG_ENTRY: case MediaLogEvent::MEDIA_INFO_LOG_ENTRY:
return "MEDIA_INFO_LOG_ENTRY"; return "MEDIA_INFO_LOG_ENTRY";
case MediaLogEvent::MEDIA_DEBUG_LOG_ENTRY: case MediaLogEvent::MEDIA_DEBUG_LOG_ENTRY:
......
...@@ -30,8 +30,20 @@ namespace media { ...@@ -30,8 +30,20 @@ namespace media {
class MEDIA_EXPORT MediaLog { class MEDIA_EXPORT MediaLog {
public: public:
enum MediaLogLevel { enum MediaLogLevel {
// Fatal error, e.g. cause of playback failure. Since this is also used to
// form MediaError.message, do NOT use this for non-fatal errors to avoid
// contaminating MediaError.message.
MEDIALOG_ERROR, MEDIALOG_ERROR,
// Warning about non-fatal issues, e.g. quality of playback issues such as
// audio/video out of sync.
MEDIALOG_WARNING,
// General info useful for Chromium and/or web developers, testers and even
// users, e.g. audio/video codecs used in a playback instance.
MEDIALOG_INFO, MEDIALOG_INFO,
// Misc debug info for Chromium developers.
MEDIALOG_DEBUG, MEDIALOG_DEBUG,
}; };
......
...@@ -16,9 +16,7 @@ namespace media { ...@@ -16,9 +16,7 @@ namespace media {
struct MediaLogEvent { struct MediaLogEvent {
MediaLogEvent() {} MediaLogEvent() {}
MediaLogEvent(const MediaLogEvent& event) { MediaLogEvent(const MediaLogEvent& event) { *this = event; }
*this = event;
}
MediaLogEvent& operator=(const MediaLogEvent& event) { MediaLogEvent& operator=(const MediaLogEvent& event) {
id = event.id; id = event.id;
...@@ -76,6 +74,10 @@ struct MediaLogEvent { ...@@ -76,6 +74,10 @@ struct MediaLogEvent {
MEDIA_ERROR_LOG_ENTRY, MEDIA_ERROR_LOG_ENTRY,
// params: "error": Error string describing the error detected. // params: "error": Error string describing the error detected.
// Warning log reported by media code such as playback quality issues.
MEDIA_WARNING_LOG_ENTRY,
// params: "warning": String describing the warning.
// Informative log reported by media code. // Informative log reported by media code.
MEDIA_INFO_LOG_ENTRY, MEDIA_INFO_LOG_ENTRY,
// params: "info": String with details of an informative log entry. // params: "info": String with details of an informative log entry.
......
...@@ -101,7 +101,7 @@ void AudioTimestampValidator::CheckForTimestampGap( ...@@ -101,7 +101,7 @@ void AudioTimestampValidator::CheckForTimestampGap(
// Let developers know if their files timestamps are way off from // Let developers know if their files timestamps are way off from
if (num_unstable_audio_tries_ > limit_unstable_audio_tries_) { if (num_unstable_audio_tries_ > limit_unstable_audio_tries_) {
MEDIA_LOG(ERROR, media_log_) MEDIA_LOG(WARNING, media_log_)
<< "Failed to reconcile encoded audio times with decoded output."; << "Failed to reconcile encoded audio times with decoded output.";
} }
} }
...@@ -111,7 +111,7 @@ void AudioTimestampValidator::CheckForTimestampGap( ...@@ -111,7 +111,7 @@ void AudioTimestampValidator::CheckForTimestampGap(
} }
if (std::abs(ts_delta.InMilliseconds()) > drift_warning_threshold_msec_) { if (std::abs(ts_delta.InMilliseconds()) > drift_warning_threshold_msec_) {
MEDIA_LOG(ERROR, media_log_) MEDIA_LOG(WARNING, media_log_)
<< " Large timestamp gap detected; may cause AV sync to drift." << " Large timestamp gap detected; may cause AV sync to drift."
<< " time:" << buffer.timestamp().InMicroseconds() << "us" << " time:" << buffer.timestamp().InMicroseconds() << "us"
<< " expected:" << expected_ts.InMicroseconds() << "us" << " expected:" << expected_ts.InMicroseconds() << "us"
...@@ -141,4 +141,4 @@ void AudioTimestampValidator::RecordOutputDuration( ...@@ -141,4 +141,4 @@ void AudioTimestampValidator::RecordOutputDuration(
audio_output_ts_helper_->AddFrames(audio_buffer->frame_count()); audio_output_ts_helper_->AddFrames(audio_buffer->frame_count());
} }
} // namespace media } // namespace media
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment