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 16 matching lines...) Expand all Loading... |
27 #include "content/renderer/media/android/renderer_demuxer_android.h" | 27 #include "content/renderer/media/android/renderer_demuxer_android.h" |
28 #include "content/renderer/media/android/renderer_media_player_manager.h" | 28 #include "content/renderer/media/android/renderer_media_player_manager.h" |
29 #include "content/renderer/media/cdm/render_cdm_factory.h" | 29 #include "content/renderer/media/cdm/render_cdm_factory.h" |
30 #include "content/renderer/media/cdm/renderer_cdm_manager.h" | 30 #include "content/renderer/media/cdm/renderer_cdm_manager.h" |
31 #include "content/renderer/render_frame_impl.h" | 31 #include "content/renderer/render_frame_impl.h" |
32 #include "content/renderer/render_thread_impl.h" | 32 #include "content/renderer/render_thread_impl.h" |
33 #include "content/renderer/render_view_impl.h" | 33 #include "content/renderer/render_view_impl.h" |
34 #include "gpu/GLES2/gl2extchromium.h" | 34 #include "gpu/GLES2/gl2extchromium.h" |
35 #include "gpu/command_buffer/client/gles2_interface.h" | 35 #include "gpu/command_buffer/client/gles2_interface.h" |
36 #include "gpu/command_buffer/common/mailbox_holder.h" | 36 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 37 #include "media/base/android/media_codec_util.h" |
37 #include "media/base/android/media_common_android.h" | 38 #include "media/base/android/media_common_android.h" |
38 #include "media/base/android/media_player_android.h" | 39 #include "media/base/android/media_player_android.h" |
39 #include "media/base/bind_to_current_loop.h" | 40 #include "media/base/bind_to_current_loop.h" |
40 #include "media/base/cdm_context.h" | 41 #include "media/base/cdm_context.h" |
41 #include "media/base/key_systems.h" | 42 #include "media/base/key_systems.h" |
42 #include "media/base/media_keys.h" | 43 #include "media/base/media_keys.h" |
43 #include "media/base/media_log.h" | 44 #include "media/base/media_log.h" |
44 #include "media/base/media_switches.h" | 45 #include "media/base/media_switches.h" |
45 #include "media/base/timestamp_constants.h" | 46 #include "media/base/timestamp_constants.h" |
46 #include "media/base/video_frame.h" | 47 #include "media/base/video_frame.h" |
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 } | 1922 } |
1922 | 1923 |
1923 void WebMediaPlayerAndroid::enterFullscreen() { | 1924 void WebMediaPlayerAndroid::enterFullscreen() { |
1924 if (is_player_initialized_) | 1925 if (is_player_initialized_) |
1925 player_manager_->EnterFullscreen(player_id_); | 1926 player_manager_->EnterFullscreen(player_id_); |
1926 SetNeedsEstablishPeer(false); | 1927 SetNeedsEstablishPeer(false); |
1927 is_fullscreen_ = true; | 1928 is_fullscreen_ = true; |
1928 suppress_deleting_texture_ = false; | 1929 suppress_deleting_texture_ = false; |
1929 } | 1930 } |
1930 | 1931 |
1931 // Test whether the path of a URL ends with '.m3u8'. | |
1932 static bool IsHLSPath(const GURL& url) { | |
1933 if (!url.SchemeIsHTTPOrHTTPS() && !url.SchemeIsFile()) | |
1934 return false; | |
1935 | |
1936 std::string path = url.path(); | |
1937 return base::EndsWith(path, ".m3u8", base::CompareCase::INSENSITIVE_ASCII); | |
1938 } | |
1939 | |
1940 // Predict whether NuPlayer will use HTTPLiveSource. | |
1941 static bool IsHLSURL(const GURL& url) { | |
1942 if (!url.SchemeIsHTTPOrHTTPS() && !url.SchemeIsFile()) | |
1943 return false; | |
1944 | |
1945 std::string spec = url.spec(); | |
1946 if (base::EndsWith(spec, ".m3u8", base::CompareCase::INSENSITIVE_ASCII)) | |
1947 return true; | |
1948 return (spec.find("m3u8") != std::string::npos); | |
1949 } | |
1950 | |
1951 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1932 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1952 const GURL& url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1933 const GURL& url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1953 return IsHLSURL(url); | 1934 return media::MediaCodecUtil::IsHLSURL(url); |
1954 } | 1935 } |
1955 | 1936 |
1956 void WebMediaPlayerAndroid::ReportHLSMetrics() const { | 1937 void WebMediaPlayerAndroid::ReportHLSMetrics() const { |
1957 if (player_type_ != MEDIA_PLAYER_TYPE_URL) | 1938 if (player_type_ != MEDIA_PLAYER_TYPE_URL) |
1958 return; | 1939 return; |
1959 | 1940 |
1960 bool is_hls = IsHLSStream(); | 1941 bool is_hls = IsHLSStream(); |
1961 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); | 1942 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); |
1962 if (is_hls) { | 1943 if (is_hls) { |
1963 media::RecordOriginOfHLSPlayback( | 1944 media::RecordOriginOfHLSPlayback( |
1964 GURL(frame_->document().securityOrigin().toString())); | 1945 GURL(frame_->document().securityOrigin().toString())); |
1965 } | 1946 } |
1966 | 1947 |
1967 // Assuming that |is_hls| is the ground truth, test predictions. | 1948 // Assuming that |is_hls| is the ground truth, test predictions. |
1968 bool is_hls_path = IsHLSPath(url_); | 1949 bool is_hls_path = media::MediaCodecUtil::IsHLSPath(url_); |
1969 bool is_hls_url = IsHLSURL(url_); | 1950 bool is_hls_url = media::MediaCodecUtil::IsHLSURL(url_); |
1970 MediaTypePredictionResult result = PREDICTION_RESULT_ALL_INCORRECT; | 1951 MediaTypePredictionResult result = PREDICTION_RESULT_ALL_INCORRECT; |
1971 if (is_hls_path == is_hls && is_hls_url == is_hls) { | 1952 if (is_hls_path == is_hls && is_hls_url == is_hls) { |
1972 result = PREDICTION_RESULT_ALL_CORRECT; | 1953 result = PREDICTION_RESULT_ALL_CORRECT; |
1973 } else if (is_hls_path == is_hls) { | 1954 } else if (is_hls_path == is_hls) { |
1974 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; | 1955 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; |
1975 } else if (is_hls_url == is_hls) { | 1956 } else if (is_hls_url == is_hls) { |
1976 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; | 1957 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; |
1977 } | 1958 } |
1978 UMA_HISTOGRAM_ENUMERATION( | 1959 UMA_HISTOGRAM_ENUMERATION( |
1979 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", | 1960 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", |
1980 result, PREDICTION_RESULT_MAX); | 1961 result, PREDICTION_RESULT_MAX); |
1981 } | 1962 } |
1982 | 1963 |
1983 } // namespace content | 1964 } // namespace content |
OLD | NEW |