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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 return ready_state_; | 514 return ready_state_; |
514 } | 515 } |
515 | 516 |
516 blink::WebTimeRanges WebMediaPlayerAndroid::buffered() const { | 517 blink::WebTimeRanges WebMediaPlayerAndroid::buffered() const { |
517 if (media_source_delegate_) | 518 if (media_source_delegate_) |
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 // Media without duration are considered streaming and should not be seekable. |
524 // are no seekable ranges. | 525 const double seekable_end = duration(); |
525 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) | 526 if (!base::IsFinite(seekable_end)) |
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 // If we have a finite duration then use [0, duration] as the seekable range. |
529 const double seekable_end = duration(); | |
530 if (!seekable_end) | |
531 return blink::WebTimeRanges(); | |
532 | |
533 blink::WebTimeRange seekable_range(0.0, seekable_end); | 530 blink::WebTimeRange seekable_range(0.0, seekable_end); |
534 return blink::WebTimeRanges(&seekable_range, 1); | 531 return blink::WebTimeRanges(&seekable_range, 1); |
535 } | 532 } |
536 | 533 |
537 bool WebMediaPlayerAndroid::didLoadingProgress() { | 534 bool WebMediaPlayerAndroid::didLoadingProgress() { |
538 bool ret = did_loading_progress_; | 535 bool ret = did_loading_progress_; |
539 did_loading_progress_ = false; | 536 did_loading_progress_ = false; |
540 return ret; | 537 return ret; |
541 } | 538 } |
542 | 539 |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 | 1826 |
1830 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1827 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1831 std::string mime; | 1828 std::string mime; |
1832 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1829 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1833 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1830 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
1834 return false; | 1831 return false; |
1835 return !mime.compare("application/x-mpegurl"); | 1832 return !mime.compare("application/x-mpegurl"); |
1836 } | 1833 } |
1837 | 1834 |
1838 } // namespace content | 1835 } // namespace content |
OLD | NEW |