Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: media/base/media_log.cc

Issue 877273002: Add media log messages to the main log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Report PIPELINE_ERROR to LOG(ERROR) + minor fixes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 7 #include <string>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 13
13 namespace media { 14 namespace media {
14 15
15 // A count of all MediaLogs created in the current process. Used to generate 16 // A count of all MediaLogs created in the current process. Used to generate
16 // unique IDs. 17 // unique IDs.
17 static base::StaticAtomicSequenceNumber g_media_log_count; 18 static base::StaticAtomicSequenceNumber g_media_log_count;
18 19
19 std::string MediaLog::EventTypeToString(MediaLogEvent::Type type) { 20 std::string MediaLog::EventTypeToString(MediaLogEvent::Type type) {
20 switch (type) { 21 switch (type) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return "demuxer: could not parse"; 92 return "demuxer: could not parse";
92 case DEMUXER_ERROR_NO_SUPPORTED_STREAMS: 93 case DEMUXER_ERROR_NO_SUPPORTED_STREAMS:
93 return "demuxer: no supported streams"; 94 return "demuxer: no supported streams";
94 case DECODER_ERROR_NOT_SUPPORTED: 95 case DECODER_ERROR_NOT_SUPPORTED:
95 return "decoder: not supported"; 96 return "decoder: not supported";
96 } 97 }
97 NOTREACHED(); 98 NOTREACHED();
98 return NULL; 99 return NULL;
99 } 100 }
100 101
102 std::string MediaLog::MediaEventToLogString(const MediaLogEvent& event) {
103 std::string param;
104 switch (event.type) {
105 case MediaLogEvent::WEBMEDIAPLAYER_CREATED:
106 case MediaLogEvent::WEBMEDIAPLAYER_DESTROYED:
107 case MediaLogEvent::PIPELINE_CREATED:
108 case MediaLogEvent::PIPELINE_DESTROYED:
109 case MediaLogEvent::PLAY:
110 case MediaLogEvent::PAUSE:
111 case MediaLogEvent::ENDED:
112 case MediaLogEvent::TEXT_ENDED:
113 case MediaLogEvent::BUFFERED_EXTENTS_CHANGED:
114 case MediaLogEvent::TOTAL_BYTES_SET:
115 case MediaLogEvent::NETWORK_ACTIVITY_SET:
116 case MediaLogEvent::PROPERTY_CHANGE:
117 return EventTypeToString(event.type);
118
119 case MediaLogEvent::LOAD:
wolenetz 2015/02/13 20:36:36 I still think this method is too fragile to change
servolk 2015/03/26 00:04:09 Ok, I understand your concert. I've looked a bit m
120 event.params.GetString("url", &param);
121 return EventTypeToString(event.type) + " url=" + param;
122
123 case MediaLogEvent::SEEK:
124 {
125 double seek_target = -1.0;
126 event.params.GetDouble("seek_target", &seek_target);
127 return EventTypeToString(event.type) + " seek_target=" +
128 base::DoubleToString(seek_target);
129 }
130
131 case MediaLogEvent::PIPELINE_STATE_CHANGED:
132 event.params.GetString("pipeline_state", &param);
133 return EventTypeToString(event.type) + " pipeline_state=" + param;
134
135 case MediaLogEvent::PIPELINE_ERROR:
136 {
137 int err;
138 event.params.GetInteger("pipeline_error", &err);
139 media::PipelineStatus status = static_cast<media::PipelineStatus>(err);
140 return EventTypeToString(event.type) + " " +
141 media::MediaLog::PipelineStatusToString(status);
142 }
143
144 case MediaLogEvent::VIDEO_SIZE_SET:
145 {
146 int width = 0;
147 int height = 0;
148 event.params.GetInteger("width", &width);
149 event.params.GetInteger("height", &height);
150 return EventTypeToString(event.type) + " " + base::IntToString(width) +
151 "x" + base::IntToString(height);
152 }
153
154 case MediaLogEvent::DURATION_SET:
155 {
156 double duration = -1.0;
157 event.params.GetDouble("duration", &duration);
158 return EventTypeToString(event.type) + " duration=" +
159 base::DoubleToString(duration);
160 }
161
162 case MediaLogEvent::MEDIA_SOURCE_ERROR:
163 event.params.GetString("error", &param);
164 return EventTypeToString(event.type) + " error=" + param;
165 }
166 NOTREACHED();
167 return NULL;
168 }
169
101 LogHelper::LogHelper(const LogCB& log_cb) : log_cb_(log_cb) {} 170 LogHelper::LogHelper(const LogCB& log_cb) : log_cb_(log_cb) {}
102 171
103 LogHelper::~LogHelper() { 172 LogHelper::~LogHelper() {
104 if (log_cb_.is_null()) 173 if (log_cb_.is_null())
105 return; 174 return;
106 log_cb_.Run(stream_.str()); 175 log_cb_.Run(stream_.str());
107 } 176 }
108 177
109 MediaLog::MediaLog() : id_(g_media_log_count.GetNext()) {} 178 MediaLog::MediaLog() : id_(g_media_log_count.GetNext()) {}
110 179
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 const std::string& key, base::TimeDelta value) { 306 const std::string& key, base::TimeDelta value) {
238 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); 307 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE));
239 if (value.is_max()) 308 if (value.is_max())
240 event->params.SetString(key, "unknown"); 309 event->params.SetString(key, "unknown");
241 else 310 else
242 event->params.SetDouble(key, value.InSecondsF()); 311 event->params.SetDouble(key, value.InSecondsF());
243 AddEvent(event.Pass()); 312 AddEvent(event.Pass());
244 } 313 }
245 314
246 } //namespace media 315 } //namespace media
OLDNEW
« content/renderer/media/render_media_log.cc ('K') | « media/base/media_log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698