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 "content/browser/media/media_internals.h" | 5 #include "content/browser/media/media_internals.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
14 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
15 #include "content/public/browser/notification_types.h" | 15 #include "content/public/browser/notification_types.h" |
16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
17 #include "content/public/browser/web_ui.h" | 17 #include "content/public/browser/web_ui.h" |
18 #include "media/audio/audio_parameters.h" | 18 #include "media/audio/audio_parameters.h" |
19 #include "media/base/media_log_event.h" | 19 #include "media/base/media_log_event.h" |
20 #include "media/filters/decrypting_video_decoder.h" | |
20 #include "media/filters/gpu_video_decoder.h" | 21 #include "media/filters/gpu_video_decoder.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 static base::LazyInstance<content::MediaInternals>::Leaky g_media_internals = | 25 static base::LazyInstance<content::MediaInternals>::Leaky g_media_internals = |
25 LAZY_INSTANCE_INITIALIZER; | 26 LAZY_INSTANCE_INITIALIZER; |
26 | 27 |
27 base::string16 SerializeUpdate(const std::string& function, | 28 base::string16 SerializeUpdate(const std::string& function, |
28 const base::Value* value) { | 29 const base::Value* value) { |
29 return content::WebUI::GetJavascriptCall( | 30 return content::WebUI::GetJavascriptCall( |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 | 192 |
192 // Helper function to save the event payload to RendererPlayerMap. | 193 // Helper function to save the event payload to RendererPlayerMap. |
193 void SavePlayerState(const media::MediaLogEvent& event, | 194 void SavePlayerState(const media::MediaLogEvent& event, |
194 int render_process_id); | 195 int render_process_id); |
195 | 196 |
196 private: | 197 private: |
197 struct PipelineInfo { | 198 struct PipelineInfo { |
198 media::PipelineStatus last_pipeline_status; | 199 media::PipelineStatus last_pipeline_status; |
199 bool has_audio; | 200 bool has_audio; |
200 bool has_video; | 201 bool has_video; |
202 bool video_dds; | |
201 std::string audio_codec_name; | 203 std::string audio_codec_name; |
202 std::string video_codec_name; | 204 std::string video_codec_name; |
203 std::string video_decoder; | 205 std::string video_decoder; |
204 PipelineInfo() | 206 PipelineInfo() |
205 : last_pipeline_status(media::PIPELINE_OK), | 207 : last_pipeline_status(media::PIPELINE_OK), |
206 has_audio(false), | 208 has_audio(false), |
207 has_video(false) {} | 209 has_video(false), |
210 video_dds(false) {} | |
208 }; | 211 }; |
209 | 212 |
210 // Helper function to report PipelineStatus associated with a player to UMA. | 213 // Helper function to report PipelineStatus associated with a player to UMA. |
211 void ReportUMAForPipelineStatus(const PipelineInfo& player_info); | 214 void ReportUMAForPipelineStatus(const PipelineInfo& player_info); |
212 | 215 |
216 // Helper to generate pipelinestatus_UMA_prefix for AudioVideo streams. | |
xhwang
2014/12/04 00:37:33
pipelinestatus_UMA_prefix is not correct
prabhur1
2014/12/04 01:49:02
Done.
| |
217 std::string GetUMANameForAVStream(const PipelineInfo& player_info); | |
218 | |
213 // Key is playerid | 219 // Key is playerid |
214 typedef std::map<int, PipelineInfo> PlayerInfoMap; | 220 typedef std::map<int, PipelineInfo> PlayerInfoMap; |
215 | 221 |
216 // Key is renderer id | 222 // Key is renderer id |
217 typedef std::map<int, PlayerInfoMap> RendererPlayerMap; | 223 typedef std::map<int, PlayerInfoMap> RendererPlayerMap; |
xhwang
2014/12/04 00:37:33
Not related to your change, why a map of PipelineI
prabhur1
2014/12/04 01:49:02
The map stores some state (pipelineInfo in this ca
| |
218 | 224 |
219 // Stores player information per renderer | 225 // Stores player information per renderer |
220 RendererPlayerMap renderer_info_; | 226 RendererPlayerMap renderer_info_; |
221 | 227 |
222 NotificationRegistrar registrar_; | 228 NotificationRegistrar registrar_; |
223 | 229 |
224 DISALLOW_COPY_AND_ASSIGN(MediaInternalsUMAHandler); | 230 DISALLOW_COPY_AND_ASSIGN(MediaInternalsUMAHandler); |
225 }; | 231 }; |
226 | 232 |
227 MediaInternals::MediaInternalsUMAHandler::MediaInternalsUMAHandler() { | 233 MediaInternals::MediaInternalsUMAHandler::MediaInternalsUMAHandler() { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 &player_info[event.id].audio_codec_name); | 285 &player_info[event.id].audio_codec_name); |
280 } | 286 } |
281 if (event.params.HasKey("video_codec_name")) { | 287 if (event.params.HasKey("video_codec_name")) { |
282 event.params.GetString("video_codec_name", | 288 event.params.GetString("video_codec_name", |
283 &player_info[event.id].video_codec_name); | 289 &player_info[event.id].video_codec_name); |
284 } | 290 } |
285 if (event.params.HasKey("video_decoder")) { | 291 if (event.params.HasKey("video_decoder")) { |
286 event.params.GetString("video_decoder", | 292 event.params.GetString("video_decoder", |
287 &player_info[event.id].video_decoder); | 293 &player_info[event.id].video_decoder); |
288 } | 294 } |
295 if (event.params.HasKey("video_dds")) { | |
296 event.params.GetBoolean("video_dds", &player_info[event.id].video_dds); | |
297 } | |
289 break; | 298 break; |
290 default: | 299 default: |
291 break; | 300 break; |
292 } | 301 } |
293 return; | 302 return; |
294 } | 303 } |
295 | 304 |
305 std::string MediaInternals::MediaInternalsUMAHandler::GetUMANameForAVStream( | |
306 const PipelineInfo& player_info) { | |
xhwang
2014/12/04 00:37:33
ditto about pipelineinfo vs playerinfo
prabhur1
2014/12/04 01:49:02
see earlier response.
| |
307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
308 static const char kPipelineUmaPrefix[] = "Media.PipelineStatus.AudioVideo."; | |
309 std::string uma_name = kPipelineUmaPrefix; | |
310 if (player_info.video_codec_name == "vp8") { | |
311 uma_name += "VP8."; | |
312 } else if (player_info.video_codec_name == "vp9") { | |
313 uma_name += "VP9."; | |
314 } else if (player_info.video_codec_name == "h264") { | |
315 uma_name += "H264."; | |
316 } else { | |
317 return uma_name + "Other"; | |
318 } | |
xhwang
2014/12/04 00:37:33
nit: add empty line here.
prabhur1
2014/12/04 01:49:02
Done.
| |
319 if (player_info.video_decoder == | |
320 media::DecryptingVideoDecoder::kDecoderName) { | |
321 uma_name += "DVD."; | |
xhwang
2014/12/04 00:37:33
You can return here. DVD.SW is redundant. DVD woul
prabhur1
2014/12/04 01:49:02
Done.
| |
322 } else if (player_info.video_dds) { | |
xhwang
2014/12/04 00:37:33
If you return above, you don't need "else" here.
prabhur1
2014/12/04 01:49:02
Done.
| |
323 uma_name += "DDS."; | |
324 } | |
xhwang
2014/12/04 00:37:33
nit: add empty line here.
prabhur1
2014/12/04 01:49:02
Done.
| |
325 if (player_info.video_decoder == media::GpuVideoDecoder::kDecoderName) { | |
326 uma_name += "HW"; | |
327 } else { | |
328 uma_name += "SW"; | |
329 } | |
330 return uma_name; | |
331 } | |
332 | |
296 void MediaInternals::MediaInternalsUMAHandler::ReportUMAForPipelineStatus( | 333 void MediaInternals::MediaInternalsUMAHandler::ReportUMAForPipelineStatus( |
297 const PipelineInfo& player_info) { | 334 const PipelineInfo& player_info) { |
298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
299 if (player_info.has_video && player_info.has_audio) { | 336 if (player_info.has_video && player_info.has_audio) { |
300 if (player_info.video_codec_name == "vp8") { | 337 base::LinearHistogram::FactoryGet( |
301 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioVideo.VP8.SW", | 338 GetUMANameForAVStream(player_info), 1, media::PIPELINE_STATUS_MAX, |
302 player_info.last_pipeline_status, | 339 media::PIPELINE_STATUS_MAX + 1, |
303 media::PIPELINE_STATUS_MAX + 1); | 340 base::HistogramBase::kUmaTargetedHistogramFlag) |
304 } else if (player_info.video_codec_name == "vp9") { | 341 ->Add(player_info.last_pipeline_status); |
305 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioVideo.VP9.SW", | |
306 player_info.last_pipeline_status, | |
307 media::PIPELINE_STATUS_MAX + 1); | |
308 } else if (player_info.video_codec_name == "h264") { | |
309 if (player_info.video_decoder == media::GpuVideoDecoder::kDecoderName) { | |
310 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioVideo.H264.HW", | |
311 player_info.last_pipeline_status, | |
312 media::PIPELINE_STATUS_MAX + 1); | |
313 } else { | |
314 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioVideo.H264.SW", | |
315 player_info.last_pipeline_status, | |
316 media::PIPELINE_STATUS_MAX + 1); | |
317 } | |
318 } else { | |
319 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioVideo.Other", | |
320 player_info.last_pipeline_status, | |
321 media::PIPELINE_STATUS_MAX + 1); | |
322 } | |
323 } else if (player_info.has_audio) { | 342 } else if (player_info.has_audio) { |
324 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioOnly", | 343 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioOnly", |
325 player_info.last_pipeline_status, | 344 player_info.last_pipeline_status, |
326 media::PIPELINE_STATUS_MAX + 1); | 345 media::PIPELINE_STATUS_MAX + 1); |
327 } else if (player_info.has_video) { | 346 } else if (player_info.has_video) { |
328 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.VideoOnly", | 347 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.VideoOnly", |
329 player_info.last_pipeline_status, | 348 player_info.last_pipeline_status, |
330 media::PIPELINE_STATUS_MAX + 1); | 349 media::PIPELINE_STATUS_MAX + 1); |
331 } else { | 350 } else { |
332 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.Unsupported", | 351 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.Unsupported", |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 const std::string& function, | 511 const std::string& function, |
493 const base::DictionaryValue* value) { | 512 const base::DictionaryValue* value) { |
494 SendUpdate(SerializeUpdate(function, value)); | 513 SendUpdate(SerializeUpdate(function, value)); |
495 | 514 |
496 base::AutoLock auto_lock(lock_); | 515 base::AutoLock auto_lock(lock_); |
497 scoped_ptr<base::Value> out_value; | 516 scoped_ptr<base::Value> out_value; |
498 CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value)); | 517 CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value)); |
499 } | 518 } |
500 | 519 |
501 } // namespace content | 520 } // namespace content |
OLD | NEW |