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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 } | 159 } |
160 | 160 |
161 private: | 161 private: |
162 blink::WebGraphicsContext3D* web_graphics_context_; | 162 blink::WebGraphicsContext3D* web_graphics_context_; |
163 }; | 163 }; |
164 | 164 |
165 } // namespace | 165 } // namespace |
166 | 166 |
167 namespace content { | 167 namespace content { |
168 | 168 |
169 // static | |
170 bool WebMediaPlayerAndroid::IsHLSPath(const GURL& url) { | |
171 if (!url.SchemeIsHTTPOrHTTPS() && !url.SchemeIsFile()) | |
172 return false; | |
173 | |
174 std::string path = url.path(); | |
175 return base::EndsWith(path, ".m3u8", base::CompareCase::INSENSITIVE_ASCII); | |
176 } | |
177 | |
178 // static | |
179 bool WebMediaPlayerAndroid::IsHLSURL(const GURL& url) { | |
180 if (!url.SchemeIsHTTPOrHTTPS() && !url.SchemeIsFile()) | |
181 return false; | |
182 | |
183 std::string spec = url.spec(); | |
184 if (base::EndsWith(spec, ".m3u8", base::CompareCase::INSENSITIVE_ASCII)) | |
185 return true; | |
186 return (spec.find("m3u8") != std::string::npos); | |
187 } | |
188 | |
189 | |
watk
2016/01/06 20:06:47
extra newline or subtle style rule?
| |
169 WebMediaPlayerAndroid::WebMediaPlayerAndroid( | 190 WebMediaPlayerAndroid::WebMediaPlayerAndroid( |
170 blink::WebFrame* frame, | 191 blink::WebFrame* frame, |
171 blink::WebMediaPlayerClient* client, | 192 blink::WebMediaPlayerClient* client, |
172 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | 193 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
173 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, | 194 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, |
174 RendererMediaPlayerManager* player_manager, | 195 RendererMediaPlayerManager* player_manager, |
175 media::CdmFactory* cdm_factory, | 196 media::CdmFactory* cdm_factory, |
176 scoped_refptr<StreamTextureFactory> factory, | 197 scoped_refptr<StreamTextureFactory> factory, |
177 int frame_id, | 198 int frame_id, |
178 const media::WebMediaPlayerParams& params) | 199 const media::WebMediaPlayerParams& params) |
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1921 } | 1942 } |
1922 | 1943 |
1923 void WebMediaPlayerAndroid::enterFullscreen() { | 1944 void WebMediaPlayerAndroid::enterFullscreen() { |
1924 if (is_player_initialized_) | 1945 if (is_player_initialized_) |
1925 player_manager_->EnterFullscreen(player_id_); | 1946 player_manager_->EnterFullscreen(player_id_); |
1926 SetNeedsEstablishPeer(false); | 1947 SetNeedsEstablishPeer(false); |
1927 is_fullscreen_ = true; | 1948 is_fullscreen_ = true; |
1928 suppress_deleting_texture_ = false; | 1949 suppress_deleting_texture_ = false; |
1929 } | 1950 } |
1930 | 1951 |
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 { | 1952 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1952 const GURL& url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1953 const GURL& url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1953 return IsHLSURL(url); | 1954 return IsHLSURL(url); |
1954 } | 1955 } |
1955 | 1956 |
1956 void WebMediaPlayerAndroid::ReportHLSMetrics() const { | 1957 void WebMediaPlayerAndroid::ReportHLSMetrics() const { |
1957 if (player_type_ != MEDIA_PLAYER_TYPE_URL) | 1958 if (player_type_ != MEDIA_PLAYER_TYPE_URL) |
1958 return; | 1959 return; |
1959 | 1960 |
1960 bool is_hls = IsHLSStream(); | 1961 bool is_hls = IsHLSStream(); |
(...skipping 13 matching lines...) Expand all Loading... | |
1974 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; | 1975 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; |
1975 } else if (is_hls_url == is_hls) { | 1976 } else if (is_hls_url == is_hls) { |
1976 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; | 1977 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; |
1977 } | 1978 } |
1978 UMA_HISTOGRAM_ENUMERATION( | 1979 UMA_HISTOGRAM_ENUMERATION( |
1979 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", | 1980 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", |
1980 result, PREDICTION_RESULT_MAX); | 1981 result, PREDICTION_RESULT_MAX); |
1981 } | 1982 } |
1982 | 1983 |
1983 } // namespace content | 1984 } // namespace content |
OLD | NEW |