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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 return "chunk demuxer: application requested decode error on eos"; | 201 return "chunk demuxer: application requested decode error on eos"; |
202 case CHUNK_DEMUXER_ERROR_EOS_STATUS_NETWORK_ERROR: | 202 case CHUNK_DEMUXER_ERROR_EOS_STATUS_NETWORK_ERROR: |
203 return "chunk demuxer: application requested network error on eos"; | 203 return "chunk demuxer: application requested network error on eos"; |
204 case AUDIO_RENDERER_ERROR: | 204 case AUDIO_RENDERER_ERROR: |
205 return "audio renderer: output device reported an error"; | 205 return "audio renderer: output device reported an error"; |
206 } | 206 } |
207 NOTREACHED(); | 207 NOTREACHED(); |
208 return NULL; | 208 return NULL; |
209 } | 209 } |
210 | 210 |
211 std::string MediaLog::MediaEventToLogString(const MediaLogEvent& event) { | 211 std::string MediaLog::MediaEventToLogString(const MediaLogEvent& event, |
212 bool include_type) { | |
sandersd (OOO until July 31)
2017/04/12 01:09:38
Not a fan of this parameter, it's not clear from c
wolenetz
2017/04/13 23:59:10
Done.
| |
212 // Special case for PIPELINE_ERROR, since that's by far the most useful | 213 // Special case for PIPELINE_ERROR, since that's by far the most useful |
213 // event for figuring out media pipeline failures, and just reporting | 214 // event for figuring out media pipeline failures, and just reporting |
214 // pipeline status as numeric code is not very helpful/user-friendly. | 215 // pipeline status as numeric code is not very helpful/user-friendly. |
215 int error_code = 0; | 216 int error_code = 0; |
216 if (event.type == MediaLogEvent::PIPELINE_ERROR && | 217 if (event.type == MediaLogEvent::PIPELINE_ERROR && |
217 event.params.GetInteger("pipeline_error", &error_code)) { | 218 event.params.GetInteger("pipeline_error", &error_code)) { |
218 PipelineStatus status = static_cast<PipelineStatus>(error_code); | 219 PipelineStatus status = static_cast<PipelineStatus>(error_code); |
219 return EventTypeToString(event.type) + " " + PipelineStatusToString(status); | 220 if (include_type) { |
221 return EventTypeToString(event.type) + " " + | |
222 PipelineStatusToString(status); | |
223 } | |
224 return PipelineStatusToString(status); | |
220 } | 225 } |
226 | |
221 std::string params_json; | 227 std::string params_json; |
222 base::JSONWriter::Write(event.params, ¶ms_json); | 228 base::JSONWriter::Write(event.params, ¶ms_json); |
223 return EventTypeToString(event.type) + " " + params_json; | 229 if (include_type) |
230 return EventTypeToString(event.type) + " " + params_json; | |
231 return params_json; | |
224 } | 232 } |
225 | 233 |
226 std::string MediaLog::BufferingStateToString(BufferingState state) { | 234 std::string MediaLog::BufferingStateToString(BufferingState state) { |
227 switch (state) { | 235 switch (state) { |
228 case BUFFERING_HAVE_NOTHING: | 236 case BUFFERING_HAVE_NOTHING: |
229 return "BUFFERING_HAVE_NOTHING"; | 237 return "BUFFERING_HAVE_NOTHING"; |
230 case BUFFERING_HAVE_ENOUGH: | 238 case BUFFERING_HAVE_ENOUGH: |
231 return "BUFFERING_HAVE_ENOUGH"; | 239 return "BUFFERING_HAVE_ENOUGH"; |
232 } | 240 } |
233 NOTREACHED(); | 241 NOTREACHED(); |
234 return ""; | 242 return ""; |
235 } | 243 } |
236 | 244 |
237 MediaLog::MediaLog() : id_(g_media_log_count.GetNext()) {} | 245 MediaLog::MediaLog() : id_(g_media_log_count.GetNext()) {} |
238 | 246 |
239 MediaLog::~MediaLog() {} | 247 MediaLog::~MediaLog() {} |
240 | 248 |
241 void MediaLog::AddEvent(std::unique_ptr<MediaLogEvent> event) {} | 249 void MediaLog::AddEvent(std::unique_ptr<MediaLogEvent> event) {} |
242 | 250 |
243 std::string MediaLog::GetLastErrorMessage() { | 251 std::map<std::string, std::vector<std::string>> MediaLog::GetErrorMessages() { |
244 return ""; | 252 return std::map<std::string, std::vector<std::string>>(); |
245 } | 253 } |
246 | 254 |
247 void MediaLog::RecordRapporWithSecurityOrigin(const std::string& metric) { | 255 void MediaLog::RecordRapporWithSecurityOrigin(const std::string& metric) { |
248 DVLOG(1) << "Default MediaLog doesn't support rappor reporting."; | 256 DVLOG(1) << "Default MediaLog doesn't support rappor reporting."; |
249 } | 257 } |
250 | 258 |
251 std::unique_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) { | 259 std::unique_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) { |
252 std::unique_ptr<MediaLogEvent> event(new MediaLogEvent); | 260 std::unique_ptr<MediaLogEvent> event(new MediaLogEvent); |
253 event->id = id_; | 261 event->id = id_; |
254 event->type = type; | 262 event->type = type; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 const scoped_refptr<MediaLog>& media_log) | 390 const scoped_refptr<MediaLog>& media_log) |
383 : level_(level), media_log_(media_log) { | 391 : level_(level), media_log_(media_log) { |
384 DCHECK(media_log_.get()); | 392 DCHECK(media_log_.get()); |
385 } | 393 } |
386 | 394 |
387 LogHelper::~LogHelper() { | 395 LogHelper::~LogHelper() { |
388 media_log_->AddLogEvent(level_, stream_.str()); | 396 media_log_->AddLogEvent(level_, stream_.str()); |
389 } | 397 } |
390 | 398 |
391 } //namespace media | 399 } //namespace media |
OLD | NEW |