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

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 15927003: Fix MediaPlayerDelegate error handling so it passes the webkitmediasource-errors.html LayoutTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 6 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 | « webkit/media/android/webmediaplayer_android.cc ('k') | webkit/media/webmediaplayer_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "webkit/media/webmediaplayer_impl.h" 5 #include "webkit/media/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 GetClient()->timeChanged(); 866 GetClient()->timeChanged();
867 } 867 }
868 868
869 void WebMediaPlayerImpl::OnPipelineEnded() { 869 void WebMediaPlayerImpl::OnPipelineEnded() {
870 DCHECK(main_loop_->BelongsToCurrentThread()); 870 DCHECK(main_loop_->BelongsToCurrentThread());
871 GetClient()->timeChanged(); 871 GetClient()->timeChanged();
872 } 872 }
873 873
874 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { 874 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) {
875 DCHECK(main_loop_->BelongsToCurrentThread()); 875 DCHECK(main_loop_->BelongsToCurrentThread());
876 DCHECK_NE(error, media::PIPELINE_OK);
876 877
877 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { 878 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) {
878 // Any error that occurs before reaching ReadyStateHaveMetadata should 879 // Any error that occurs before reaching ReadyStateHaveMetadata should
879 // be considered a format error. 880 // be considered a format error.
880 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); 881 SetNetworkState(WebMediaPlayer::NetworkStateFormatError);
881 Repaint(); 882 Repaint();
882 return; 883 return;
883 } 884 }
884 885
885 switch (error) { 886 SetNetworkState(PipelineErrorToNetworkState(error));
886 case media::PIPELINE_OK:
887 NOTREACHED() << "PIPELINE_OK isn't an error!";
888 break;
889 887
890 case media::PIPELINE_ERROR_NETWORK: 888 if (error == media::PIPELINE_ERROR_DECRYPT)
891 case media::PIPELINE_ERROR_READ: 889 EmeUMAHistogramCounts(current_key_system_.utf8(), "DecryptError", 1);
892 SetNetworkState(WebMediaPlayer::NetworkStateNetworkError);
893 break;
894
895 // TODO(vrk): Because OnPipelineInitialize() directly reports the
896 // NetworkStateFormatError instead of calling OnPipelineError(), I believe
897 // this block can be deleted. Should look into it! (crbug.com/126070)
898 case media::PIPELINE_ERROR_INITIALIZATION_FAILED:
899 case media::PIPELINE_ERROR_COULD_NOT_RENDER:
900 case media::PIPELINE_ERROR_URL_NOT_FOUND:
901 case media::DEMUXER_ERROR_COULD_NOT_OPEN:
902 case media::DEMUXER_ERROR_COULD_NOT_PARSE:
903 case media::DEMUXER_ERROR_NO_SUPPORTED_STREAMS:
904 case media::DECODER_ERROR_NOT_SUPPORTED:
905 SetNetworkState(WebMediaPlayer::NetworkStateFormatError);
906 break;
907
908 case media::PIPELINE_ERROR_DECODE:
909 case media::PIPELINE_ERROR_ABORT:
910 case media::PIPELINE_ERROR_OPERATION_PENDING:
911 case media::PIPELINE_ERROR_INVALID_STATE:
912 SetNetworkState(WebMediaPlayer::NetworkStateDecodeError);
913 break;
914
915 case media::PIPELINE_ERROR_DECRYPT:
916 // Decrypt error.
917 EmeUMAHistogramCounts(current_key_system_.utf8(), "DecryptError", 1);
918
919 // TODO(xhwang): Change to use NetworkStateDecryptError once it's added in
920 // Webkit (see http://crbug.com/124486).
921 SetNetworkState(WebMediaPlayer::NetworkStateDecodeError);
922 break;
923
924 case media::PIPELINE_STATUS_MAX:
925 NOTREACHED() << "PIPELINE_STATUS_MAX isn't a real error!";
926 break;
927 }
928 890
929 // Repaint to trigger UI update. 891 // Repaint to trigger UI update.
930 Repaint(); 892 Repaint();
931 } 893 }
932 894
933 void WebMediaPlayerImpl::OnPipelineBufferingState( 895 void WebMediaPlayerImpl::OnPipelineBufferingState(
934 media::Pipeline::BufferingState buffering_state) { 896 media::Pipeline::BufferingState buffering_state) {
935 DVLOG(1) << "OnPipelineBufferingState(" << buffering_state << ")"; 897 DVLOG(1) << "OnPipelineBufferingState(" << buffering_state << ")";
936 898
937 switch (buffering_state) { 899 switch (buffering_state) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 1251
1290 if (pending_repaint_) 1252 if (pending_repaint_)
1291 return; 1253 return;
1292 1254
1293 pending_repaint_ = true; 1255 pending_repaint_ = true;
1294 main_loop_->PostTask(FROM_HERE, base::Bind( 1256 main_loop_->PostTask(FROM_HERE, base::Bind(
1295 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); 1257 &WebMediaPlayerImpl::Repaint, AsWeakPtr()));
1296 } 1258 }
1297 1259
1298 } // namespace webkit_media 1260 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/android/webmediaplayer_android.cc ('k') | webkit/media/webmediaplayer_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698