OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/blink/webmediaplayer_util.h" | 5 #include "media/blink/webmediaplayer_util.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
13 #include "media/base/bind_to_current_loop.h" | 13 #include "media/base/bind_to_current_loop.h" |
14 #include "media/base/media_client.h" | 14 #include "media/base/media_log.h" |
15 #include "third_party/WebKit/public/platform/URLConversion.h" | 15 #include "third_party/WebKit/public/platform/URLConversion.h" |
16 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.
h" | 16 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.
h" |
17 | 17 |
18 namespace media { | 18 namespace media { |
19 | 19 |
20 blink::WebTimeRanges ConvertToWebTimeRanges( | 20 blink::WebTimeRanges ConvertToWebTimeRanges( |
21 const Ranges<base::TimeDelta>& ranges) { | 21 const Ranges<base::TimeDelta>& ranges) { |
22 blink::WebTimeRanges result(ranges.size()); | 22 blink::WebTimeRanges result(ranges.size()); |
23 for (size_t i = 0; i < ranges.size(); ++i) { | 23 for (size_t i = 0; i < ranges.size(); ++i) { |
24 result[i].start = ranges.start(i).InSecondsF(); | 24 result[i].start = ranges.start(i).InSecondsF(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 | 103 |
104 NOTREACHED(); | 104 NOTREACHED(); |
105 return "Unknown"; | 105 return "Unknown"; |
106 } | 106 } |
107 | 107 |
108 } // namespace | 108 } // namespace |
109 | 109 |
110 void ReportMetrics(blink::WebMediaPlayer::LoadType load_type, | 110 void ReportMetrics(blink::WebMediaPlayer::LoadType load_type, |
111 const GURL& url, | 111 const GURL& url, |
112 const blink::WebSecurityOrigin& security_origin) { | 112 const blink::WebSecurityOrigin& security_origin, |
| 113 scoped_refptr<MediaLog> media_log) { |
| 114 DCHECK(media_log); |
| 115 |
113 // Report URL scheme, such as http, https, file, blob etc. | 116 // Report URL scheme, such as http, https, file, blob etc. |
114 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(url), | 117 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(url), |
115 kMaxURLScheme + 1); | 118 kMaxURLScheme + 1); |
116 | 119 |
117 // Report load type, such as URL, MediaSource or MediaStream. | 120 // Report load type, such as URL, MediaSource or MediaStream. |
118 UMA_HISTOGRAM_ENUMERATION("Media.LoadType", load_type, | 121 UMA_HISTOGRAM_ENUMERATION("Media.LoadType", load_type, |
119 blink::WebMediaPlayer::LoadTypeMax + 1); | 122 blink::WebMediaPlayer::LoadTypeMax + 1); |
120 | 123 |
121 // Report the origin from where the media player is created. | 124 // Report the origin from where the media player is created. |
122 if (GetMediaClient()) { | 125 media_log->RecordRapporWithSecurityOrigin("Media.OriginUrl." + |
123 GURL security_origin_url(url::Origin(security_origin).GetURL()); | 126 LoadTypeToString(load_type)); |
124 | 127 |
125 GetMediaClient()->RecordRapporURL( | 128 // For MSE, also report usage by secure/insecure origin. |
126 "Media.OriginUrl." + LoadTypeToString(load_type), security_origin_url); | 129 if (load_type == blink::WebMediaPlayer::LoadTypeMediaSource) { |
127 | 130 if (security_origin.isPotentiallyTrustworthy()) { |
128 // For MSE, also report usage by secure/insecure origin. | 131 media_log->RecordRapporWithSecurityOrigin("Media.OriginUrl.MSE.Secure"); |
129 if (load_type == blink::WebMediaPlayer::LoadTypeMediaSource) { | 132 } else { |
130 if (security_origin.isPotentiallyTrustworthy()) { | 133 media_log->RecordRapporWithSecurityOrigin("Media.OriginUrl.MSE.Insecure"); |
131 GetMediaClient()->RecordRapporURL("Media.OriginUrl.MSE.Secure", | |
132 security_origin_url); | |
133 } else { | |
134 GetMediaClient()->RecordRapporURL("Media.OriginUrl.MSE.Insecure", | |
135 security_origin_url); | |
136 } | |
137 } | 134 } |
138 } | 135 } |
139 } | 136 } |
140 | 137 |
141 void ReportPipelineError(blink::WebMediaPlayer::LoadType load_type, | 138 void ReportPipelineError(blink::WebMediaPlayer::LoadType load_type, |
142 const blink::WebSecurityOrigin& security_origin, | 139 PipelineStatus error, |
143 PipelineStatus error) { | 140 scoped_refptr<MediaLog> media_log) { |
144 DCHECK_NE(PIPELINE_OK, error); | 141 DCHECK_NE(PIPELINE_OK, error); |
145 | 142 |
146 // Report the origin from where the media player is created. | 143 // Report the origin from where the media player is created. |
147 if (!GetMediaClient()) | 144 media_log->RecordRapporWithSecurityOrigin( |
148 return; | 145 "Media.OriginUrl." + LoadTypeToString(load_type) + ".PipelineError"); |
149 | |
150 GetMediaClient()->RecordRapporURL( | |
151 "Media.OriginUrl." + LoadTypeToString(load_type) + ".PipelineError", | |
152 url::Origin(security_origin).GetURL()); | |
153 } | |
154 | |
155 void RecordOriginOfHLSPlayback(const GURL& origin_url) { | |
156 if (media::GetMediaClient()) | |
157 GetMediaClient()->RecordRapporURL("Media.OriginUrl.HLS", origin_url); | |
158 } | 146 } |
159 | 147 |
160 EmeInitDataType ConvertToEmeInitDataType( | 148 EmeInitDataType ConvertToEmeInitDataType( |
161 blink::WebEncryptedMediaInitDataType init_data_type) { | 149 blink::WebEncryptedMediaInitDataType init_data_type) { |
162 switch (init_data_type) { | 150 switch (init_data_type) { |
163 case blink::WebEncryptedMediaInitDataType::Webm: | 151 case blink::WebEncryptedMediaInitDataType::Webm: |
164 return EmeInitDataType::WEBM; | 152 return EmeInitDataType::WEBM; |
165 case blink::WebEncryptedMediaInitDataType::Cenc: | 153 case blink::WebEncryptedMediaInitDataType::Cenc: |
166 return EmeInitDataType::CENC; | 154 return EmeInitDataType::CENC; |
167 case blink::WebEncryptedMediaInitDataType::Keyids: | 155 case blink::WebEncryptedMediaInitDataType::Keyids: |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 236 |
249 } // namespace | 237 } // namespace |
250 | 238 |
251 OutputDeviceStatusCB ConvertToOutputDeviceStatusCB( | 239 OutputDeviceStatusCB ConvertToOutputDeviceStatusCB( |
252 blink::WebSetSinkIdCallbacks* web_callbacks) { | 240 blink::WebSetSinkIdCallbacks* web_callbacks) { |
253 return media::BindToCurrentLoop( | 241 return media::BindToCurrentLoop( |
254 base::Bind(RunSetSinkIdCallback, SetSinkIdCallback(web_callbacks))); | 242 base::Bind(RunSetSinkIdCallback, SetSinkIdCallback(web_callbacks))); |
255 } | 243 } |
256 | 244 |
257 } // namespace media | 245 } // namespace media |
OLD | NEW |