Chromium Code Reviews| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/float_util.h" | |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 19 #include "cc/blink/web_layer_impl.h" | 20 #include "cc/blink/web_layer_impl.h" |
| 20 #include "cc/layers/video_layer.h" | 21 #include "cc/layers/video_layer.h" |
| 21 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
| 22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 23 #include "content/public/renderer/render_frame.h" | 24 #include "content/public/renderer/render_frame.h" |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 return media_source_delegate_->Buffered(); | 519 return media_source_delegate_->Buffered(); |
| 519 return buffered_; | 520 return buffered_; |
| 520 } | 521 } |
| 521 | 522 |
| 522 blink::WebTimeRanges WebMediaPlayerAndroid::seekable() const { | 523 blink::WebTimeRanges WebMediaPlayerAndroid::seekable() const { |
| 523 // If we haven't even gotten to ReadyStateHaveMetadata yet then there | 524 // If we haven't even gotten to ReadyStateHaveMetadata yet then there |
| 524 // are no seekable ranges. | 525 // are no seekable ranges. |
| 525 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) | 526 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) |
| 526 return blink::WebTimeRanges(); | 527 return blink::WebTimeRanges(); |
| 527 | 528 |
| 528 // If we have a duration then use [0, duration] as the seekable range. | 529 // Media without duration are considered streaming and should not be seekable. |
| 529 const double seekable_end = duration(); | 530 const double seekable_end = duration(); |
| 530 if (!seekable_end) | 531 if (!base::IsFinite(seekable_end)) |
|
philipj_slow
2014/10/01 09:37:50
With this change I believe you can remove the read
DaleCurtis
2014/10/06 23:55:42
Done.
| |
| 531 return blink::WebTimeRanges(); | 532 return blink::WebTimeRanges(); |
| 532 | 533 |
| 534 // If we have a finite duration then use [0, duration] as the seekable range. | |
| 533 blink::WebTimeRange seekable_range(0.0, seekable_end); | 535 blink::WebTimeRange seekable_range(0.0, seekable_end); |
| 534 return blink::WebTimeRanges(&seekable_range, 1); | 536 return blink::WebTimeRanges(&seekable_range, 1); |
| 535 } | 537 } |
| 536 | 538 |
| 537 bool WebMediaPlayerAndroid::didLoadingProgress() { | 539 bool WebMediaPlayerAndroid::didLoadingProgress() { |
| 538 bool ret = did_loading_progress_; | 540 bool ret = did_loading_progress_; |
| 539 did_loading_progress_ = false; | 541 did_loading_progress_ = false; |
| 540 return ret; | 542 return ret; |
| 541 } | 543 } |
| 542 | 544 |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1829 | 1831 |
| 1830 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1832 bool WebMediaPlayerAndroid::IsHLSStream() const { |
| 1831 std::string mime; | 1833 std::string mime; |
| 1832 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1834 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
| 1833 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1835 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
| 1834 return false; | 1836 return false; |
| 1835 return !mime.compare("application/x-mpegurl"); | 1837 return !mime.compare("application/x-mpegurl"); |
| 1836 } | 1838 } |
| 1837 | 1839 |
| 1838 } // namespace content | 1840 } // namespace content |
| OLD | NEW |