| 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 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "media/base/media_keys.h" | 43 #include "media/base/media_keys.h" |
| 44 #include "media/base/media_log.h" | 44 #include "media/base/media_log.h" |
| 45 #include "media/base/media_switches.h" | 45 #include "media/base/media_switches.h" |
| 46 #include "media/base/timestamp_constants.h" | 46 #include "media/base/timestamp_constants.h" |
| 47 #include "media/base/video_frame.h" | 47 #include "media/base/video_frame.h" |
| 48 #include "media/blink/webcontentdecryptionmodule_impl.h" | 48 #include "media/blink/webcontentdecryptionmodule_impl.h" |
| 49 #include "media/blink/webmediaplayer_delegate.h" | 49 #include "media/blink/webmediaplayer_delegate.h" |
| 50 #include "media/blink/webmediaplayer_util.h" | 50 #include "media/blink/webmediaplayer_util.h" |
| 51 #include "net/base/mime_util.h" | 51 #include "net/base/mime_util.h" |
| 52 #include "third_party/WebKit/public/platform/Platform.h" | 52 #include "third_party/WebKit/public/platform/Platform.h" |
| 53 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 53 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" | 54 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
| 54 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" | 55 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" |
| 55 #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h" | 56 #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h" |
| 56 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 57 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" |
| 57 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.
h" | 58 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.
h" |
| 58 #include "third_party/WebKit/public/platform/WebString.h" | 59 #include "third_party/WebKit/public/platform/WebString.h" |
| 59 #include "third_party/WebKit/public/platform/WebURL.h" | 60 #include "third_party/WebKit/public/platform/WebURL.h" |
| 60 #include "third_party/WebKit/public/web/WebDocument.h" | 61 #include "third_party/WebKit/public/web/WebDocument.h" |
| 61 #include "third_party/WebKit/public/web/WebFrame.h" | 62 #include "third_party/WebKit/public/web/WebFrame.h" |
| 62 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 63 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 return; | 301 return; |
| 301 } | 302 } |
| 302 DoLoad(load_type, url, cors_mode); | 303 DoLoad(load_type, url, cors_mode); |
| 303 } | 304 } |
| 304 | 305 |
| 305 void WebMediaPlayerAndroid::DoLoad(LoadType load_type, | 306 void WebMediaPlayerAndroid::DoLoad(LoadType load_type, |
| 306 const blink::WebURL& url, | 307 const blink::WebURL& url, |
| 307 CORSMode cors_mode) { | 308 CORSMode cors_mode) { |
| 308 DCHECK(main_thread_checker_.CalledOnValidThread()); | 309 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 309 | 310 |
| 310 media::ReportMetrics(load_type, GURL(url), | 311 media::ReportMetrics( |
| 311 GURL(frame_->document().securityOrigin().toString())); | 312 load_type, GURL(url), |
| 313 blink::WebStringToGURL(frame_->document().securityOrigin().toString())); |
| 312 | 314 |
| 313 switch (load_type) { | 315 switch (load_type) { |
| 314 case LoadTypeURL: | 316 case LoadTypeURL: |
| 315 player_type_ = MEDIA_PLAYER_TYPE_URL; | 317 player_type_ = MEDIA_PLAYER_TYPE_URL; |
| 316 break; | 318 break; |
| 317 | 319 |
| 318 case LoadTypeMediaSource: | 320 case LoadTypeMediaSource: |
| 319 player_type_ = MEDIA_PLAYER_TYPE_MEDIA_SOURCE; | 321 player_type_ = MEDIA_PLAYER_TYPE_MEDIA_SOURCE; |
| 320 break; | 322 break; |
| 321 | 323 |
| (...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 proxy_decryptor_.reset(new media::ProxyDecryptor( | 1607 proxy_decryptor_.reset(new media::ProxyDecryptor( |
| 1606 media_permission_, | 1608 media_permission_, |
| 1607 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo(), | 1609 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo(), |
| 1608 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, | 1610 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, |
| 1609 weak_factory_.GetWeakPtr()), | 1611 weak_factory_.GetWeakPtr()), |
| 1610 base::Bind(&WebMediaPlayerAndroid::OnKeyError, | 1612 base::Bind(&WebMediaPlayerAndroid::OnKeyError, |
| 1611 weak_factory_.GetWeakPtr()), | 1613 weak_factory_.GetWeakPtr()), |
| 1612 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage, | 1614 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage, |
| 1613 weak_factory_.GetWeakPtr()))); | 1615 weak_factory_.GetWeakPtr()))); |
| 1614 | 1616 |
| 1615 GURL security_origin(frame_->document().securityOrigin().toString()); | 1617 GURL security_origin( |
| 1618 blink::WebStringToGURL(frame_->document().securityOrigin().toString())); |
| 1616 proxy_decryptor_->CreateCdm( | 1619 proxy_decryptor_->CreateCdm( |
| 1617 cdm_factory_, key_system, security_origin, | 1620 cdm_factory_, key_system, security_origin, |
| 1618 base::Bind(&WebMediaPlayerAndroid::OnCdmContextReady, | 1621 base::Bind(&WebMediaPlayerAndroid::OnCdmContextReady, |
| 1619 weak_factory_.GetWeakPtr())); | 1622 weak_factory_.GetWeakPtr())); |
| 1620 current_key_system_ = key_system; | 1623 current_key_system_ = key_system; |
| 1621 } | 1624 } |
| 1622 | 1625 |
| 1623 // We do not support run-time switching between key systems for now. | 1626 // We do not support run-time switching between key systems for now. |
| 1624 DCHECK(!current_key_system_.empty()); | 1627 DCHECK(!current_key_system_.empty()); |
| 1625 if (key_system != current_key_system_) | 1628 if (key_system != current_key_system_) |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 } | 1936 } |
| 1934 | 1937 |
| 1935 void WebMediaPlayerAndroid::ReportHLSMetrics() const { | 1938 void WebMediaPlayerAndroid::ReportHLSMetrics() const { |
| 1936 if (player_type_ != MEDIA_PLAYER_TYPE_URL) | 1939 if (player_type_ != MEDIA_PLAYER_TYPE_URL) |
| 1937 return; | 1940 return; |
| 1938 | 1941 |
| 1939 bool is_hls = IsHLSStream(); | 1942 bool is_hls = IsHLSStream(); |
| 1940 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); | 1943 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); |
| 1941 if (is_hls) { | 1944 if (is_hls) { |
| 1942 media::RecordOriginOfHLSPlayback( | 1945 media::RecordOriginOfHLSPlayback( |
| 1943 GURL(frame_->document().securityOrigin().toString())); | 1946 blink::WebStringToGURL(frame_->document().securityOrigin().toString())); |
| 1944 } | 1947 } |
| 1945 | 1948 |
| 1946 // Assuming that |is_hls| is the ground truth, test predictions. | 1949 // Assuming that |is_hls| is the ground truth, test predictions. |
| 1947 bool is_hls_path = media::MediaCodecUtil::IsHLSPath(url_); | 1950 bool is_hls_path = media::MediaCodecUtil::IsHLSPath(url_); |
| 1948 bool is_hls_url = media::MediaCodecUtil::IsHLSURL(url_); | 1951 bool is_hls_url = media::MediaCodecUtil::IsHLSURL(url_); |
| 1949 MediaTypePredictionResult result = PREDICTION_RESULT_ALL_INCORRECT; | 1952 MediaTypePredictionResult result = PREDICTION_RESULT_ALL_INCORRECT; |
| 1950 if (is_hls_path == is_hls && is_hls_url == is_hls) { | 1953 if (is_hls_path == is_hls && is_hls_url == is_hls) { |
| 1951 result = PREDICTION_RESULT_ALL_CORRECT; | 1954 result = PREDICTION_RESULT_ALL_CORRECT; |
| 1952 } else if (is_hls_path == is_hls) { | 1955 } else if (is_hls_path == is_hls) { |
| 1953 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; | 1956 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; |
| 1954 } else if (is_hls_url == is_hls) { | 1957 } else if (is_hls_url == is_hls) { |
| 1955 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; | 1958 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; |
| 1956 } | 1959 } |
| 1957 UMA_HISTOGRAM_ENUMERATION( | 1960 UMA_HISTOGRAM_ENUMERATION( |
| 1958 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", | 1961 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", |
| 1959 result, PREDICTION_RESULT_MAX); | 1962 result, PREDICTION_RESULT_MAX); |
| 1960 } | 1963 } |
| 1961 | 1964 |
| 1962 } // namespace content | 1965 } // namespace content |
| OLD | NEW |