| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/media_log.h" | 5 #include "media/base/media_log.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Audio only "watch time" metrics. | 34 // Audio only "watch time" metrics. |
| 35 const char MediaLog::kWatchTimeAudioAll[] = "Media.WatchTime.Audio.All"; | 35 const char MediaLog::kWatchTimeAudioAll[] = "Media.WatchTime.Audio.All"; |
| 36 const char MediaLog::kWatchTimeAudioMse[] = "Media.WatchTime.Audio.MSE"; | 36 const char MediaLog::kWatchTimeAudioMse[] = "Media.WatchTime.Audio.MSE"; |
| 37 const char MediaLog::kWatchTimeAudioEme[] = "Media.WatchTime.Audio.EME"; | 37 const char MediaLog::kWatchTimeAudioEme[] = "Media.WatchTime.Audio.EME"; |
| 38 const char MediaLog::kWatchTimeAudioSrc[] = "Media.WatchTime.Audio.SRC"; | 38 const char MediaLog::kWatchTimeAudioSrc[] = "Media.WatchTime.Audio.SRC"; |
| 39 const char MediaLog::kWatchTimeAudioBattery[] = "Media.WatchTime.Audio.Battery"; | 39 const char MediaLog::kWatchTimeAudioBattery[] = "Media.WatchTime.Audio.Battery"; |
| 40 const char MediaLog::kWatchTimeAudioAc[] = "Media.WatchTime.Audio.AC"; | 40 const char MediaLog::kWatchTimeAudioAc[] = "Media.WatchTime.Audio.AC"; |
| 41 const char MediaLog::kWatchTimeAudioEmbeddedExperience[] = | 41 const char MediaLog::kWatchTimeAudioEmbeddedExperience[] = |
| 42 "Media.WatchTime.Audio.EmbeddedExperience"; | 42 "Media.WatchTime.Audio.EmbeddedExperience"; |
| 43 | 43 |
| 44 // Audio+video background watch time metrics. |
| 45 const char MediaLog::kWatchTimeAudioVideoBackgroundAll[] = |
| 46 "Media.WatchTime.AudioVideo.Background.All"; |
| 47 const char MediaLog::kWatchTimeAudioVideoBackgroundMse[] = |
| 48 "Media.WatchTime.AudioVideo.Background.MSE"; |
| 49 const char MediaLog::kWatchTimeAudioVideoBackgroundEme[] = |
| 50 "Media.WatchTime.AudioVideo.Background.EME"; |
| 51 const char MediaLog::kWatchTimeAudioVideoBackgroundSrc[] = |
| 52 "Media.WatchTime.AudioVideo.Background.SRC"; |
| 53 const char MediaLog::kWatchTimeAudioVideoBackgroundBattery[] = |
| 54 "Media.WatchTime.AudioVideo.Background.Battery"; |
| 55 const char MediaLog::kWatchTimeAudioVideoBackgroundAc[] = |
| 56 "Media.WatchTime.AudioVideo.Background.AC"; |
| 57 const char MediaLog::kWatchTimeAudioVideoBackgroundEmbeddedExperience[] = |
| 58 "Media.WatchTime.AudioVideo.Background.EmbeddedExperience"; |
| 59 |
| 44 const char MediaLog::kWatchTimeFinalize[] = "FinalizeWatchTime"; | 60 const char MediaLog::kWatchTimeFinalize[] = "FinalizeWatchTime"; |
| 45 const char MediaLog::kWatchTimeFinalizePower[] = "FinalizePowerWatchTime"; | 61 const char MediaLog::kWatchTimeFinalizePower[] = "FinalizePowerWatchTime"; |
| 46 | 62 |
| 63 base::flat_set<base::StringPiece> MediaLog::GetWatchTimeKeys() { |
| 64 return {kWatchTimeAudioAll, |
| 65 kWatchTimeAudioMse, |
| 66 kWatchTimeAudioEme, |
| 67 kWatchTimeAudioSrc, |
| 68 kWatchTimeAudioBattery, |
| 69 kWatchTimeAudioAc, |
| 70 kWatchTimeAudioEmbeddedExperience, |
| 71 kWatchTimeAudioVideoAll, |
| 72 kWatchTimeAudioVideoMse, |
| 73 kWatchTimeAudioVideoEme, |
| 74 kWatchTimeAudioVideoSrc, |
| 75 kWatchTimeAudioVideoBattery, |
| 76 kWatchTimeAudioVideoAc, |
| 77 kWatchTimeAudioVideoEmbeddedExperience, |
| 78 kWatchTimeAudioVideoBackgroundAll, |
| 79 kWatchTimeAudioVideoBackgroundMse, |
| 80 kWatchTimeAudioVideoBackgroundEme, |
| 81 kWatchTimeAudioVideoBackgroundSrc, |
| 82 kWatchTimeAudioVideoBackgroundBattery, |
| 83 kWatchTimeAudioVideoBackgroundAc, |
| 84 kWatchTimeAudioVideoBackgroundEmbeddedExperience}; |
| 85 } |
| 86 |
| 87 base::flat_set<base::StringPiece> MediaLog::GetWatchTimePowerKeys() { |
| 88 return {kWatchTimeAudioBattery, |
| 89 kWatchTimeAudioAc, |
| 90 kWatchTimeAudioVideoBattery, |
| 91 kWatchTimeAudioVideoAc, |
| 92 kWatchTimeAudioVideoBackgroundBattery, |
| 93 kWatchTimeAudioVideoBackgroundAc}; |
| 94 } |
| 95 |
| 47 std::string MediaLog::MediaLogLevelToString(MediaLogLevel level) { | 96 std::string MediaLog::MediaLogLevelToString(MediaLogLevel level) { |
| 48 switch (level) { | 97 switch (level) { |
| 49 case MEDIALOG_ERROR: | 98 case MEDIALOG_ERROR: |
| 50 return "error"; | 99 return "error"; |
| 51 case MEDIALOG_INFO: | 100 case MEDIALOG_INFO: |
| 52 return "info"; | 101 return "info"; |
| 53 case MEDIALOG_DEBUG: | 102 case MEDIALOG_DEBUG: |
| 54 return "debug"; | 103 return "debug"; |
| 55 } | 104 } |
| 56 NOTREACHED(); | 105 NOTREACHED(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 208 } |
| 160 | 209 |
| 161 std::string MediaLog::MediaEventToLogString(const MediaLogEvent& event) { | 210 std::string MediaLog::MediaEventToLogString(const MediaLogEvent& event) { |
| 162 // Special case for PIPELINE_ERROR, since that's by far the most useful | 211 // Special case for PIPELINE_ERROR, since that's by far the most useful |
| 163 // event for figuring out media pipeline failures, and just reporting | 212 // event for figuring out media pipeline failures, and just reporting |
| 164 // pipeline status as numeric code is not very helpful/user-friendly. | 213 // pipeline status as numeric code is not very helpful/user-friendly. |
| 165 int error_code = 0; | 214 int error_code = 0; |
| 166 if (event.type == MediaLogEvent::PIPELINE_ERROR && | 215 if (event.type == MediaLogEvent::PIPELINE_ERROR && |
| 167 event.params.GetInteger("pipeline_error", &error_code)) { | 216 event.params.GetInteger("pipeline_error", &error_code)) { |
| 168 PipelineStatus status = static_cast<PipelineStatus>(error_code); | 217 PipelineStatus status = static_cast<PipelineStatus>(error_code); |
| 169 return EventTypeToString(event.type) + " " + | 218 return EventTypeToString(event.type) + " " + PipelineStatusToString(status); |
| 170 media::MediaLog::PipelineStatusToString(status); | |
| 171 } | 219 } |
| 172 std::string params_json; | 220 std::string params_json; |
| 173 base::JSONWriter::Write(event.params, ¶ms_json); | 221 base::JSONWriter::Write(event.params, ¶ms_json); |
| 174 return EventTypeToString(event.type) + " " + params_json; | 222 return EventTypeToString(event.type) + " " + params_json; |
| 175 } | 223 } |
| 176 | 224 |
| 177 std::string MediaLog::BufferingStateToString(BufferingState state) { | 225 std::string MediaLog::BufferingStateToString(BufferingState state) { |
| 178 switch (state) { | 226 switch (state) { |
| 179 case BUFFERING_HAVE_NOTHING: | 227 case BUFFERING_HAVE_NOTHING: |
| 180 return "BUFFERING_HAVE_NOTHING"; | 228 return "BUFFERING_HAVE_NOTHING"; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 const scoped_refptr<MediaLog>& media_log) | 381 const scoped_refptr<MediaLog>& media_log) |
| 334 : level_(level), media_log_(media_log) { | 382 : level_(level), media_log_(media_log) { |
| 335 DCHECK(media_log_.get()); | 383 DCHECK(media_log_.get()); |
| 336 } | 384 } |
| 337 | 385 |
| 338 LogHelper::~LogHelper() { | 386 LogHelper::~LogHelper() { |
| 339 media_log_->AddLogEvent(level_, stream_.str()); | 387 media_log_->AddLogEvent(level_, stream_.str()); |
| 340 } | 388 } |
| 341 | 389 |
| 342 } //namespace media | 390 } //namespace media |
| OLD | NEW |