| Index: media/base/media_log.cc
|
| diff --git a/media/base/media_log.cc b/media/base/media_log.cc
|
| index 754a5f924cee03f1dd8476993660f47165aeb199..f25468279a2d3364af72ddcbb1801c0c6a1e42a3 100644
|
| --- a/media/base/media_log.cc
|
| +++ b/media/base/media_log.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "media/base/media_log.h"
|
|
|
| +#include <algorithm>
|
| +
|
| #include "base/atomic_sequence_num.h"
|
| #include "base/json/json_writer.h"
|
| #include "base/values.h"
|
| @@ -14,6 +16,46 @@ namespace media {
|
| // unique IDs.
|
| static base::StaticAtomicSequenceNumber g_media_log_count;
|
|
|
| +MediaLog::AudioSpliceStatistics::AudioSpliceStatistics()
|
| + : count_(0),
|
| + degenerate_count_(0),
|
| + total_duration_(0.0),
|
| + min_duration_(0.0),
|
| + max_duration_(0.0) {
|
| +}
|
| +
|
| +MediaLog::AudioSpliceStatistics::AudioSpliceStatistics(int count,
|
| + int degenerate_count,
|
| + double total_duration,
|
| + double min_duration,
|
| + double max_duration)
|
| + : count_(count),
|
| + degenerate_count_(degenerate_count),
|
| + total_duration_(total_duration),
|
| + min_duration_(min_duration),
|
| + max_duration_(max_duration) {
|
| +}
|
| +
|
| +void MediaLog::AudioSpliceStatistics::OnSplice(double duration) {
|
| + if (count_) {
|
| + min_duration_ = std::min(min_duration_, duration);
|
| + max_duration_ = std::max(max_duration_, duration);
|
| + total_duration_ += duration;
|
| + } else {
|
| + min_duration_ = max_duration_ = total_duration_ = duration;
|
| + }
|
| +
|
| + count_++;
|
| +}
|
| +
|
| +void MediaLog::AudioSpliceStatistics::OnDegenerateSplice() {
|
| + degenerate_count_++;
|
| +}
|
| +
|
| +double MediaLog::AudioSpliceStatistics::AverageDuration() const {
|
| + return (count_ > 0) ? total_duration_ / count_ : 0.0;
|
| +}
|
| +
|
| std::string MediaLog::MediaLogLevelToString(MediaLogLevel level) {
|
| switch (level) {
|
| case MEDIALOG_ERROR:
|
| @@ -72,6 +114,8 @@ std::string MediaLog::EventTypeToString(MediaLogEvent::Type type) {
|
| return "TEXT_ENDED";
|
| case MediaLogEvent::BUFFERED_EXTENTS_CHANGED:
|
| return "BUFFERED_EXTENTS_CHANGED";
|
| + case MediaLogEvent::BUFFERED_AUDIO_SPLICE_STATISTICS_CHANGED:
|
| + return "BUFFERED_AUDIO_SPLICE_STATISTICS_CHANGED";
|
| case MediaLogEvent::MEDIA_ERROR_LOG_ENTRY:
|
| return "MEDIA_ERROR_LOG_ENTRY";
|
| case MediaLogEvent::MEDIA_INFO_LOG_ENTRY:
|
| @@ -227,6 +271,22 @@ scoped_ptr<MediaLogEvent> MediaLog::CreateBufferedExtentsChangedEvent(
|
| return event.Pass();
|
| }
|
|
|
| +scoped_ptr<MediaLogEvent> MediaLog::CreateBufferedSpliceStatisticsChangedEvent(
|
| + const AudioSpliceStatistics& statistics) {
|
| + scoped_ptr<MediaLogEvent> event(
|
| + CreateEvent(MediaLogEvent::BUFFERED_AUDIO_SPLICE_STATISTICS_CHANGED));
|
| + event->params.SetInteger("audio_splice_count", statistics.count());
|
| + event->params.SetInteger("audio_splice_degenerate_count",
|
| + statistics.degenerate_count());
|
| + event->params.SetDouble("audio_splice_duration_average",
|
| + statistics.AverageDuration());
|
| + event->params.SetDouble("audio_splice_duration_min",
|
| + statistics.min_duration());
|
| + event->params.SetDouble("audio_splice_duration_max",
|
| + statistics.max_duration());
|
| + return event.Pass();
|
| +}
|
| +
|
| void MediaLog::AddLogEvent(MediaLogLevel level, const std::string& message) {
|
| scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogLevelToEventType(level)));
|
| event->params.SetString(MediaLogLevelToString(level), message);
|
|
|