| 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 "content/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| 11 #include "base/android/build_info.h" | 11 #include "base/android/build_info.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "cc/blink/web_layer_impl.h" | 21 #include "cc/blink/web_layer_impl.h" |
| 22 #include "cc/layers/video_layer.h" | 22 #include "cc/layers/video_layer.h" |
| 23 #include "content/public/child/url_conversion.h" |
| 23 #include "content/public/common/content_client.h" | 24 #include "content/public/common/content_client.h" |
| 24 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
| 25 #include "content/public/common/renderer_preferences.h" | 26 #include "content/public/common/renderer_preferences.h" |
| 26 #include "content/public/renderer/render_frame.h" | 27 #include "content/public/renderer/render_frame.h" |
| 27 #include "content/renderer/media/android/renderer_demuxer_android.h" | 28 #include "content/renderer/media/android/renderer_demuxer_android.h" |
| 28 #include "content/renderer/media/android/renderer_media_player_manager.h" | 29 #include "content/renderer/media/android/renderer_media_player_manager.h" |
| 29 #include "content/renderer/media/cdm/render_cdm_factory.h" | 30 #include "content/renderer/media/cdm/render_cdm_factory.h" |
| 30 #include "content/renderer/media/cdm/renderer_cdm_manager.h" | 31 #include "content/renderer/media/cdm/renderer_cdm_manager.h" |
| 31 #include "content/renderer/render_frame_impl.h" | 32 #include "content/renderer/render_frame_impl.h" |
| 32 #include "content/renderer/render_thread_impl.h" | 33 #include "content/renderer/render_thread_impl.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 return; | 300 return; |
| 300 } | 301 } |
| 301 DoLoad(load_type, url, cors_mode); | 302 DoLoad(load_type, url, cors_mode); |
| 302 } | 303 } |
| 303 | 304 |
| 304 void WebMediaPlayerAndroid::DoLoad(LoadType load_type, | 305 void WebMediaPlayerAndroid::DoLoad(LoadType load_type, |
| 305 const blink::WebURL& url, | 306 const blink::WebURL& url, |
| 306 CORSMode cors_mode) { | 307 CORSMode cors_mode) { |
| 307 DCHECK(main_thread_checker_.CalledOnValidThread()); | 308 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 308 | 309 |
| 309 media::ReportMetrics(load_type, GURL(url), | 310 media::ReportMetrics( |
| 310 GURL(frame_->document().securityOrigin().toString())); | 311 load_type, GURL(url), |
| 312 WebStringToGURL(frame_->document().securityOrigin().toString())); |
| 311 | 313 |
| 312 switch (load_type) { | 314 switch (load_type) { |
| 313 case LoadTypeURL: | 315 case LoadTypeURL: |
| 314 player_type_ = MEDIA_PLAYER_TYPE_URL; | 316 player_type_ = MEDIA_PLAYER_TYPE_URL; |
| 315 break; | 317 break; |
| 316 | 318 |
| 317 case LoadTypeMediaSource: | 319 case LoadTypeMediaSource: |
| 318 player_type_ = MEDIA_PLAYER_TYPE_MEDIA_SOURCE; | 320 player_type_ = MEDIA_PLAYER_TYPE_MEDIA_SOURCE; |
| 319 break; | 321 break; |
| 320 | 322 |
| (...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 proxy_decryptor_.reset(new media::ProxyDecryptor( | 1606 proxy_decryptor_.reset(new media::ProxyDecryptor( |
| 1605 media_permission_, | 1607 media_permission_, |
| 1606 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo(), | 1608 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo(), |
| 1607 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, | 1609 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, |
| 1608 weak_factory_.GetWeakPtr()), | 1610 weak_factory_.GetWeakPtr()), |
| 1609 base::Bind(&WebMediaPlayerAndroid::OnKeyError, | 1611 base::Bind(&WebMediaPlayerAndroid::OnKeyError, |
| 1610 weak_factory_.GetWeakPtr()), | 1612 weak_factory_.GetWeakPtr()), |
| 1611 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage, | 1613 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage, |
| 1612 weak_factory_.GetWeakPtr()))); | 1614 weak_factory_.GetWeakPtr()))); |
| 1613 | 1615 |
| 1614 GURL security_origin(frame_->document().securityOrigin().toString()); | 1616 GURL security_origin( |
| 1617 WebStringToGURL(frame_->document().securityOrigin().toString())); |
| 1615 proxy_decryptor_->CreateCdm( | 1618 proxy_decryptor_->CreateCdm( |
| 1616 cdm_factory_, key_system, security_origin, | 1619 cdm_factory_, key_system, security_origin, |
| 1617 base::Bind(&WebMediaPlayerAndroid::OnCdmContextReady, | 1620 base::Bind(&WebMediaPlayerAndroid::OnCdmContextReady, |
| 1618 weak_factory_.GetWeakPtr())); | 1621 weak_factory_.GetWeakPtr())); |
| 1619 current_key_system_ = key_system; | 1622 current_key_system_ = key_system; |
| 1620 } | 1623 } |
| 1621 | 1624 |
| 1622 // We do not support run-time switching between key systems for now. | 1625 // We do not support run-time switching between key systems for now. |
| 1623 DCHECK(!current_key_system_.empty()); | 1626 DCHECK(!current_key_system_.empty()); |
| 1624 if (key_system != current_key_system_) | 1627 if (key_system != current_key_system_) |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 } | 1955 } |
| 1953 | 1956 |
| 1954 void WebMediaPlayerAndroid::ReportHLSMetrics() const { | 1957 void WebMediaPlayerAndroid::ReportHLSMetrics() const { |
| 1955 if (player_type_ != MEDIA_PLAYER_TYPE_URL) | 1958 if (player_type_ != MEDIA_PLAYER_TYPE_URL) |
| 1956 return; | 1959 return; |
| 1957 | 1960 |
| 1958 bool is_hls = IsHLSStream(); | 1961 bool is_hls = IsHLSStream(); |
| 1959 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); | 1962 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); |
| 1960 if (is_hls) { | 1963 if (is_hls) { |
| 1961 media::RecordOriginOfHLSPlayback( | 1964 media::RecordOriginOfHLSPlayback( |
| 1962 GURL(frame_->document().securityOrigin().toString())); | 1965 WebStringToGURL(frame_->document().securityOrigin().toString())); |
| 1963 } | 1966 } |
| 1964 | 1967 |
| 1965 // Assuming that |is_hls| is the ground truth, test predictions. | 1968 // Assuming that |is_hls| is the ground truth, test predictions. |
| 1966 bool is_hls_path = IsHLSPath(url_); | 1969 bool is_hls_path = IsHLSPath(url_); |
| 1967 bool is_hls_url = IsHLSURL(url_); | 1970 bool is_hls_url = IsHLSURL(url_); |
| 1968 MediaTypePredictionResult result = PREDICTION_RESULT_ALL_INCORRECT; | 1971 MediaTypePredictionResult result = PREDICTION_RESULT_ALL_INCORRECT; |
| 1969 if (is_hls_path == is_hls && is_hls_url == is_hls) { | 1972 if (is_hls_path == is_hls && is_hls_url == is_hls) { |
| 1970 result = PREDICTION_RESULT_ALL_CORRECT; | 1973 result = PREDICTION_RESULT_ALL_CORRECT; |
| 1971 } else if (is_hls_path == is_hls) { | 1974 } else if (is_hls_path == is_hls) { |
| 1972 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; | 1975 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; |
| 1973 } else if (is_hls_url == is_hls) { | 1976 } else if (is_hls_url == is_hls) { |
| 1974 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; | 1977 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; |
| 1975 } | 1978 } |
| 1976 UMA_HISTOGRAM_ENUMERATION( | 1979 UMA_HISTOGRAM_ENUMERATION( |
| 1977 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", | 1980 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", |
| 1978 result, PREDICTION_RESULT_MAX); | 1981 result, PREDICTION_RESULT_MAX); |
| 1979 } | 1982 } |
| 1980 | 1983 |
| 1981 } // namespace content | 1984 } // namespace content |
| OLD | NEW |