Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 1241923003: Work around unreliable metadata for HLS in WebMediaPlayerAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also check has_size_info_ Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 } 749 }
750 750
751 unsigned WebMediaPlayerAndroid::videoDecodedByteCount() const { 751 unsigned WebMediaPlayerAndroid::videoDecodedByteCount() const {
752 if (media_source_delegate_) 752 if (media_source_delegate_)
753 return media_source_delegate_->VideoDecodedByteCount(); 753 return media_source_delegate_->VideoDecodedByteCount();
754 NOTIMPLEMENTED(); 754 NOTIMPLEMENTED();
755 return 0; 755 return 0;
756 } 756 }
757 757
758 void WebMediaPlayerAndroid::OnMediaMetadataChanged( 758 void WebMediaPlayerAndroid::OnMediaMetadataChanged(
759 const base::TimeDelta& duration, int width, int height, bool success) { 759 base::TimeDelta duration, int width, int height, bool success) {
760 DCHECK(main_thread_checker_.CalledOnValidThread()); 760 DCHECK(main_thread_checker_.CalledOnValidThread());
761 bool need_to_signal_duration_changed = false; 761 bool need_to_signal_duration_changed = false;
762 762
763 if (is_local_resource_) 763 if (is_local_resource_)
764 UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded); 764 UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded);
765 765
766 // For HLS streams, the reported duration may be zero for infinite streams.
767 // See http://crbug.com/501213.
768 if (duration.is_zero() && IsHLSStream())
769 duration = media::kInfiniteDuration();
770
766 // Update duration, if necessary, prior to ready state updates that may 771 // Update duration, if necessary, prior to ready state updates that may
767 // cause duration() query. 772 // cause duration() query.
768 if (!ignore_metadata_duration_change_ && duration_ != duration) { 773 if (!ignore_metadata_duration_change_ && duration_ != duration) {
769 duration_ = duration; 774 duration_ = duration;
770 if (is_local_resource_) 775 if (is_local_resource_)
771 buffered_[0].end = duration_.InSecondsF(); 776 buffered_[0].end = duration_.InSecondsF();
772 // Client readyState transition from HAVE_NOTHING to HAVE_METADATA 777 // Client readyState transition from HAVE_NOTHING to HAVE_METADATA
773 // already triggers a durationchanged event. If this is a different 778 // already triggers a durationchanged event. If this is a different
774 // transition, remember to signal durationchanged. 779 // transition, remember to signal durationchanged.
775 // Do not ever signal durationchanged on metadata change in MSE case 780 // Do not ever signal durationchanged on metadata change in MSE case
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 UpdateNetworkState(WebMediaPlayer::NetworkStateFormatError); 852 UpdateNetworkState(WebMediaPlayer::NetworkStateFormatError);
848 break; 853 break;
849 case MediaPlayerAndroid::MEDIA_ERROR_INVALID_CODE: 854 case MediaPlayerAndroid::MEDIA_ERROR_INVALID_CODE:
850 break; 855 break;
851 } 856 }
852 client_->repaint(); 857 client_->repaint();
853 } 858 }
854 859
855 void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) { 860 void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) {
856 DCHECK(main_thread_checker_.CalledOnValidThread()); 861 DCHECK(main_thread_checker_.CalledOnValidThread());
862
863 // For HLS streams, a bogus empty size may be reported at first, followed by
864 // the actual size only once playback begins. See http://crbug.com/509972.
865 if (!has_size_info_ && width == 0 && height == 0 && IsHLSStream())
866 return;
867
857 has_size_info_ = true; 868 has_size_info_ = true;
858 if (natural_size_.width == width && natural_size_.height == height) 869 if (natural_size_.width == width && natural_size_.height == height)
859 return; 870 return;
860 871
861 #if defined(VIDEO_HOLE) 872 #if defined(VIDEO_HOLE)
862 // Use H/W surface for encrypted video. 873 // Use H/W surface for encrypted video.
863 // TODO(qinmin): Change this so that only EME needs the H/W surface 874 // TODO(qinmin): Change this so that only EME needs the H/W surface
864 if (force_use_overlay_embedded_video_ || 875 if (force_use_overlay_embedded_video_ ||
865 (media_source_delegate_ && media_source_delegate_->IsVideoEncrypted() && 876 (media_source_delegate_ && media_source_delegate_->IsVideoEncrypted() &&
866 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo())) { 877 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo())) {
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 1878
1868 bool WebMediaPlayerAndroid::IsHLSStream() const { 1879 bool WebMediaPlayerAndroid::IsHLSStream() const {
1869 std::string mime; 1880 std::string mime;
1870 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; 1881 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_;
1871 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) 1882 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime))
1872 return false; 1883 return false;
1873 return !mime.compare("application/x-mpegurl"); 1884 return !mime.compare("application/x-mpegurl");
1874 } 1885 }
1875 1886
1876 } // namespace content 1887 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698