| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "media/base/android/media_codec_bridge.h" | 10 #include "media/base/android/media_codec_bridge.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); | 358 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); |
| 359 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | 359 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); |
| 360 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | 360 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
| 361 player_.SeekTo(seek_time); | 361 player_.SeekTo(seek_time); |
| 362 EXPECT_EQ(0.0, GetPrerollTimestamp().InMillisecondsF()); | 362 EXPECT_EQ(0.0, GetPrerollTimestamp().InMillisecondsF()); |
| 363 EXPECT_EQ(1, demuxer_->num_data_requests()); | 363 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 364 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 364 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
| 365 } | 365 } |
| 366 | 366 |
| 367 // Seek, including simulated receipt of |kAborted| read between SeekTo() | 367 // Seek, including simulated receipt of |kAborted| read between SeekTo() |
| 368 // and OnDemuxerSeekDone(). Use this helper method only when the player | 368 // and OnDemuxerSeekDone() if |abort| is true. Use this helper method only |
| 369 // already has created the decoder job. | 369 // when the player already has created the decoder job. If |abort| is false, |
| 370 void SeekPlayer(bool is_audio, const base::TimeDelta& seek_time) { | 370 // |is_audio| is ignored. |expected_new_data_requests| is compared to the |
| 371 // actual increase in data request count due to the seek. |
| 372 void SeekPlayer(bool is_audio, const base::TimeDelta& seek_time, bool abort, |
| 373 int expected_new_data_requests) { |
| 371 EXPECT_TRUE(GetMediaDecoderJob(is_audio)); | 374 EXPECT_TRUE(GetMediaDecoderJob(is_audio)); |
| 372 | 375 |
| 373 int original_num_seeks = demuxer_->num_seek_requests(); | 376 int original_num_seeks = demuxer_->num_seek_requests(); |
| 374 int original_num_data_requests = demuxer_->num_data_requests(); | 377 int original_num_data_requests = demuxer_->num_data_requests(); |
| 375 | 378 |
| 376 // Initiate a seek. Skip the round-trip of requesting seek from renderer. | 379 // Initiate a seek. Skip the round-trip of requesting seek from renderer. |
| 377 // Instead behave as if the renderer has asked us to seek. | 380 // Instead behave as if the renderer has asked us to seek. |
| 378 player_.SeekTo(seek_time); | 381 player_.SeekTo(seek_time); |
| 379 | 382 |
| 380 // Verify that the seek does not occur until previously outstanding data | 383 if (abort) { |
| 381 // request is satisfied. | 384 // Verify that the seek does not occur until previously outstanding data |
| 382 EXPECT_EQ(original_num_seeks, demuxer_->num_seek_requests()); | 385 // request is satisfied. |
| 386 EXPECT_EQ(original_num_seeks, demuxer_->num_seek_requests()); |
| 383 | 387 |
| 384 // Simulate seeking causes the demuxer to abort the outstanding read caused | 388 // Simulate seeking causes the demuxer to abort the outstanding read |
| 385 // by the seek. | 389 // caused by the seek. |
| 386 player_.OnDemuxerDataAvailable(CreateAbortedAck(is_audio)); | 390 player_.OnDemuxerDataAvailable(CreateAbortedAck(is_audio)); |
| 391 } |
| 387 | 392 |
| 388 // Verify that the seek is requested now that the outstanding read is | 393 // Verify that the seek is requested. |
| 389 // completed by aborted access unit. | |
| 390 EXPECT_EQ(original_num_seeks + 1, demuxer_->num_seek_requests()); | 394 EXPECT_EQ(original_num_seeks + 1, demuxer_->num_seek_requests()); |
| 391 | 395 |
| 392 // Send back the seek done notification. This should trigger the player to | 396 // Send back the seek done notification. This should trigger the player to |
| 393 // call OnReadFromDemuxer() again. | 397 // call OnReadFromDemuxer() again. |
| 394 EXPECT_EQ(original_num_data_requests, demuxer_->num_data_requests()); | 398 EXPECT_EQ(original_num_data_requests, demuxer_->num_data_requests()); |
| 395 player_.OnDemuxerSeekDone(kNoTimestamp()); | 399 player_.OnDemuxerSeekDone(kNoTimestamp()); |
| 396 EXPECT_EQ(original_num_data_requests + 1, demuxer_->num_data_requests()); | 400 EXPECT_EQ(original_num_data_requests + expected_new_data_requests, |
| 401 demuxer_->num_data_requests()); |
| 397 | 402 |
| 398 // No other seek should have been requested. | 403 // No other seek should have been requested. |
| 399 EXPECT_EQ(original_num_seeks + 1, demuxer_->num_seek_requests()); | 404 EXPECT_EQ(original_num_seeks + 1, demuxer_->num_seek_requests()); |
| 400 } | 405 } |
| 401 | 406 |
| 402 DemuxerData CreateReadFromDemuxerAckWithConfigChanged(bool is_audio, | 407 DemuxerData CreateReadFromDemuxerAckWithConfigChanged(bool is_audio, |
| 403 int config_unit_index) { | 408 int config_unit_index) { |
| 404 DemuxerData data; | 409 DemuxerData data; |
| 405 data.type = is_audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO; | 410 data.type = is_audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO; |
| 406 data.access_units.resize(config_unit_index + 1); | 411 data.access_units.resize(config_unit_index + 1); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 EXPECT_EQ(0, demuxer_->num_data_requests()); | 671 EXPECT_EQ(0, demuxer_->num_data_requests()); |
| 667 } | 672 } |
| 668 | 673 |
| 669 TEST_F(MediaSourcePlayerTest, ReadFromDemuxerAfterSeek) { | 674 TEST_F(MediaSourcePlayerTest, ReadFromDemuxerAfterSeek) { |
| 670 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 675 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 671 | 676 |
| 672 // Test decoder job will resend a ReadFromDemuxer request after seek. | 677 // Test decoder job will resend a ReadFromDemuxer request after seek. |
| 673 StartAudioDecoderJob(); | 678 StartAudioDecoderJob(); |
| 674 EXPECT_TRUE(GetMediaDecoderJob(true)); | 679 EXPECT_TRUE(GetMediaDecoderJob(true)); |
| 675 EXPECT_EQ(1, demuxer_->num_data_requests()); | 680 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 676 SeekPlayer(true, base::TimeDelta()); | 681 SeekPlayer(true, base::TimeDelta(), true, 1); |
| 677 EXPECT_EQ(2, demuxer_->num_data_requests()); | 682 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 678 } | 683 } |
| 679 | 684 |
| 680 TEST_F(MediaSourcePlayerTest, SetSurfaceWhileSeeking) { | 685 TEST_F(MediaSourcePlayerTest, SetSurfaceWhileSeeking) { |
| 681 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 686 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 682 | 687 |
| 683 // Test SetVideoSurface() will not cause an extra seek while the player is | 688 // Test SetVideoSurface() will not cause an extra seek while the player is |
| 684 // waiting for demuxer to indicate seek is done. | 689 // waiting for demuxer to indicate seek is done. |
| 685 StartVideoDecoderJob(); | 690 StartVideoDecoderJob(); |
| 686 // Player is still waiting for SetVideoSurface(), so no request is sent. | 691 // Player is still waiting for SetVideoSurface(), so no request is sent. |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 | 915 |
| 911 // Send new data to the decoder so it can finish prefetching. This should | 916 // Send new data to the decoder so it can finish prefetching. This should |
| 912 // reset the start time ticks. | 917 // reset the start time ticks. |
| 913 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3)); | 918 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3)); |
| 914 EXPECT_TRUE(StartTimeTicks() != base::TimeTicks()); | 919 EXPECT_TRUE(StartTimeTicks() != base::TimeTicks()); |
| 915 | 920 |
| 916 base::TimeTicks current = StartTimeTicks(); | 921 base::TimeTicks current = StartTimeTicks(); |
| 917 EXPECT_LE(100.0, (current - previous).InMillisecondsF()); | 922 EXPECT_LE(100.0, (current - previous).InMillisecondsF()); |
| 918 } | 923 } |
| 919 | 924 |
| 920 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterInputEOS) { | 925 TEST_F(MediaSourcePlayerTest, SecondVideoDataIsEOSAndSeekPlusStartResumesPlay) { |
| 921 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 926 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 922 | 927 |
| 923 // Test MediaSourcePlayer will not request for new data after input EOS is | 928 // Test MediaSourcePlayer can replay video after input EOS is reached. |
| 924 // reached. | |
| 925 CreateNextTextureAndSetVideoSurface(); | 929 CreateNextTextureAndSetVideoSurface(); |
| 926 StartVideoDecoderJob(); | 930 StartVideoDecoderJob(); |
| 931 |
| 927 // Player should not seek the demuxer on setting initial surface. | 932 // Player should not seek the demuxer on setting initial surface. |
| 928 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 933 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
| 929 | 934 |
| 930 EXPECT_EQ(1, demuxer_->num_data_requests()); | 935 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 931 // Send the first input chunk. | 936 // Send the first input chunk. |
| 932 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); | 937 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); |
| 933 message_loop_.Run(); | 938 message_loop_.Run(); |
| 934 EXPECT_EQ(2, demuxer_->num_data_requests()); | 939 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 935 | 940 |
| 936 // Send EOS. | 941 // Send EOS. |
| 937 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); | 942 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); |
| 938 message_loop_.Run(); | 943 EXPECT_FALSE(manager_.playback_completed()); |
| 939 // No more request for data should be made. | 944 message_loop_.Run(); |
| 940 EXPECT_EQ(2, demuxer_->num_data_requests()); | 945 EXPECT_TRUE(manager_.playback_completed()); |
| 941 | 946 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 942 // Reconfirm no seek request has occurred. | 947 |
| 943 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 948 // Playback should resume with further data request following seek and start. |
| 944 } | 949 SeekPlayer(false, base::TimeDelta(), false, 0); |
| 945 | |
| 946 TEST_F(MediaSourcePlayerTest, ReplayAfterInputEOS) { | |
| 947 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
| 948 | |
| 949 // Test MediaSourcePlayer can replay after input EOS is | |
| 950 // reached. | |
| 951 CreateNextTextureAndSetVideoSurface(); | |
| 952 StartVideoDecoderJob(); | 950 StartVideoDecoderJob(); |
| 953 | 951 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 954 // Player should not seek the demuxer on setting initial surface. | 952 } |
| 955 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 953 |
| 956 | 954 TEST_F(MediaSourcePlayerTest, FirstAudioDataIsEOSAndSeekPlusStartResumesPlay) { |
| 957 EXPECT_EQ(1, demuxer_->num_data_requests()); | 955 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 958 // Send the first input chunk. | 956 |
| 959 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); | 957 // Test decode of audio EOS buffer without any prior decode. See also |
| 960 message_loop_.Run(); | |
| 961 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
| 962 | |
| 963 // Send EOS. | |
| 964 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); | |
| 965 message_loop_.Run(); | |
| 966 // No more request for data should be made. | |
| 967 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
| 968 | |
| 969 // Initiate a seek. Skip requesting element seek of renderer. | |
| 970 // Instead behave as if the renderer has asked us to seek. | |
| 971 player_.SeekTo(base::TimeDelta()); | |
| 972 StartVideoDecoderJob(); | |
| 973 EXPECT_EQ(1, demuxer_->num_seek_requests()); | |
| 974 player_.OnDemuxerSeekDone(kNoTimestamp()); | |
| 975 // Seek/Play after EOS should request more data. | |
| 976 EXPECT_EQ(3, demuxer_->num_data_requests()); | |
| 977 | |
| 978 // Reconfirm only 1 seek request has occurred. | |
| 979 EXPECT_EQ(1, demuxer_->num_seek_requests()); | |
| 980 } | |
| 981 | |
| 982 TEST_F(MediaSourcePlayerTest, FirstDataIsEOS) { | |
| 983 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
| 984 | |
| 985 // Test decode of EOS buffer without any prior decode. See also | |
| 986 // http://b/11696552. | 958 // http://b/11696552. |
| 959 // Also tests that seeking+Start() after completing audio playback resumes |
| 960 // playback. |
| 987 Start(CreateAudioDemuxerConfigs(kCodecAAC)); | 961 Start(CreateAudioDemuxerConfigs(kCodecAAC)); |
| 988 EXPECT_TRUE(GetMediaDecoderJob(true)); | 962 EXPECT_TRUE(GetMediaDecoderJob(true)); |
| 989 | 963 |
| 990 EXPECT_EQ(1, demuxer_->num_data_requests()); | 964 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 991 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); | 965 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); |
| 992 EXPECT_FALSE(manager_.playback_completed()); | 966 EXPECT_FALSE(manager_.playback_completed()); |
| 993 | |
| 994 message_loop_.Run(); | 967 message_loop_.Run(); |
| 995 EXPECT_TRUE(manager_.playback_completed()); | 968 EXPECT_TRUE(manager_.playback_completed()); |
| 996 EXPECT_EQ(1, demuxer_->num_data_requests()); | 969 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 997 } | 970 |
| 998 | 971 // Playback should resume with further data request following seek and start. |
| 999 TEST_F(MediaSourcePlayerTest, FirstDataAfterSeekIsEOS) { | 972 SeekPlayer(true, base::TimeDelta(), false, 0); |
| 1000 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 973 Start(CreateAudioDemuxerConfigs(kCodecAAC)); |
| 1001 | 974 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1002 // Test decode of EOS buffer, just after seeking, without any prior decode | 975 } |
| 1003 // (other than the simulated |kAborted| resulting from the seek process.) | 976 |
| 1004 // See also http://b/11696552. | 977 TEST_F(MediaSourcePlayerTest, FirstVideoDataAfterSeekIsEOS) { |
| 978 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 979 |
| 980 // Test decode of video EOS buffer, just after seeking, without any prior |
| 981 // decode (other than the simulated |kAborted| resulting from the seek |
| 982 // process.) |
| 983 CreateNextTextureAndSetVideoSurface(); |
| 984 StartVideoDecoderJob(); |
| 985 EXPECT_TRUE(GetMediaDecoderJob(false)); |
| 986 |
| 987 SeekPlayer(false, base::TimeDelta(), true, 1); |
| 988 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 989 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); |
| 990 EXPECT_FALSE(manager_.playback_completed()); |
| 991 message_loop_.Run(); |
| 992 EXPECT_TRUE(manager_.playback_completed()); |
| 993 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 994 } |
| 995 |
| 996 TEST_F(MediaSourcePlayerTest, FirstAudioDataAfterSeekIsEOS) { |
| 997 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 998 |
| 999 // Test decode of audio EOS buffer, just after seeking, without any prior |
| 1000 // decode (other than the simulated |kAborted| resulting from the seek |
| 1001 // process.) See also http://b/11696552. |
| 1005 Start(CreateAudioDemuxerConfigs(kCodecAAC)); | 1002 Start(CreateAudioDemuxerConfigs(kCodecAAC)); |
| 1006 EXPECT_TRUE(GetMediaDecoderJob(true)); | 1003 EXPECT_TRUE(GetMediaDecoderJob(true)); |
| 1007 | 1004 |
| 1008 SeekPlayer(true, base::TimeDelta()); | 1005 SeekPlayer(true, base::TimeDelta(), true, 1); |
| 1009 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1006 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1010 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); | 1007 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); |
| 1011 EXPECT_FALSE(manager_.playback_completed()); | 1008 EXPECT_FALSE(manager_.playback_completed()); |
| 1012 | 1009 message_loop_.Run(); |
| 1013 message_loop_.Run(); | 1010 EXPECT_TRUE(manager_.playback_completed()); |
| 1014 EXPECT_TRUE(manager_.playback_completed()); | 1011 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1015 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1012 } |
| 1013 |
| 1014 TEST_F(MediaSourcePlayerTest, AV_PlaybackCompletionAcrossConfigChange) { |
| 1015 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1016 |
| 1017 // Test that if one stream (audio) has completed decode of EOS and the other |
| 1018 // stream (video) processes config change, that subsequent video EOS completes |
| 1019 // A/V playback. |
| 1020 // Also tests that seeking+Start() after completing playback resumes playback. |
| 1021 Start(CreateAudioVideoDemuxerConfigs()); |
| 1022 CreateNextTextureAndSetVideoSurface(); |
| 1023 EXPECT_TRUE(GetMediaDecoderJob(true) && GetMediaDecoderJob(false)); |
| 1024 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1025 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS |
| 1026 EXPECT_EQ(0, demuxer_->num_config_requests()); |
| 1027 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( |
| 1028 false, 0)); // Video |kConfigChanged| as first unit. |
| 1029 |
| 1030 while (GetMediaDecoderJob(true)->is_decoding() || |
| 1031 GetMediaDecoderJob(false)->is_decoding()) { |
| 1032 message_loop_.RunUntilIdle(); |
| 1033 } |
| 1034 |
| 1035 EXPECT_EQ(1, demuxer_->num_config_requests()); |
| 1036 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1037 player_.OnDemuxerConfigsAvailable(CreateAudioVideoDemuxerConfigs()); |
| 1038 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1039 |
| 1040 // At no time after completing audio EOS decode, above, should the |
| 1041 // audio decoder job resume decoding. |
| 1042 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); |
| 1043 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS |
| 1044 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); |
| 1045 |
| 1046 // Decode the video EOS. Spot-check that audio decode doesn't resume. |
| 1047 EXPECT_FALSE(manager_.playback_completed()); |
| 1048 do { |
| 1049 message_loop_.RunUntilIdle(); |
| 1050 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); |
| 1051 } while (GetMediaDecoderJob(false)->is_decoding()); |
| 1052 |
| 1053 EXPECT_TRUE(manager_.playback_completed()); |
| 1054 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1055 |
| 1056 // Playback should resume with further data requests following seek and start. |
| 1057 SeekPlayer(true /* ignored */, base::TimeDelta(), false, 0); |
| 1058 Start(CreateAudioVideoDemuxerConfigs()); |
| 1059 EXPECT_EQ(5, demuxer_->num_data_requests()); |
| 1060 } |
| 1061 |
| 1062 TEST_F(MediaSourcePlayerTest, VA_PlaybackCompletionAcrossConfigChange) { |
| 1063 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1064 |
| 1065 // Test that if one stream (video) has completed decode of EOS and the other |
| 1066 // stream (audio) processes config change, that subsequent audio EOS completes |
| 1067 // A/V playback. |
| 1068 // Also tests that seeking+Start() after completing playback resumes playback. |
| 1069 Start(CreateAudioVideoDemuxerConfigs()); |
| 1070 CreateNextTextureAndSetVideoSurface(); |
| 1071 EXPECT_TRUE(GetMediaDecoderJob(true) && GetMediaDecoderJob(false)); |
| 1072 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1073 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS |
| 1074 EXPECT_EQ(0, demuxer_->num_config_requests()); |
| 1075 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( |
| 1076 true, 0)); // Audio |kConfigChanged| as first unit. |
| 1077 |
| 1078 while (GetMediaDecoderJob(true)->is_decoding() || |
| 1079 GetMediaDecoderJob(false)->is_decoding()) { |
| 1080 message_loop_.RunUntilIdle(); |
| 1081 } |
| 1082 |
| 1083 // TODO(wolenetz/qinmin): Prevent redundant demuxer config request and change |
| 1084 // expectation to 1 here. See http://crbug.com/325528. |
| 1085 EXPECT_EQ(2, demuxer_->num_config_requests()); |
| 1086 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1087 player_.OnDemuxerConfigsAvailable(CreateAudioVideoDemuxerConfigs()); |
| 1088 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1089 |
| 1090 // At no time after completing video EOS decode, above, should the |
| 1091 // video decoder job resume decoding. |
| 1092 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); |
| 1093 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS |
| 1094 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); |
| 1095 |
| 1096 // Decode the audio EOS. Spot-check that video decode doesn't resume. |
| 1097 EXPECT_FALSE(manager_.playback_completed()); |
| 1098 do { |
| 1099 message_loop_.RunUntilIdle(); |
| 1100 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); |
| 1101 } while (GetMediaDecoderJob(true)->is_decoding()); |
| 1102 |
| 1103 EXPECT_TRUE(manager_.playback_completed()); |
| 1104 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1105 |
| 1106 // Playback should resume with further data requests following seek and start. |
| 1107 SeekPlayer(true /* ignored */, base::TimeDelta(), false, 0); |
| 1108 Start(CreateAudioVideoDemuxerConfigs()); |
| 1109 EXPECT_EQ(5, demuxer_->num_data_requests()); |
| 1110 } |
| 1111 |
| 1112 TEST_F(MediaSourcePlayerTest, AV_NoPrefetchForFinishedVideoOnAudioStarvation) { |
| 1113 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1114 |
| 1115 // Test that if one stream (video) has completed decode of EOS, prefetch |
| 1116 // resulting from player starvation occurs only for the other stream (audio), |
| 1117 // and responding to that prefetch with EOS completes A/V playback, even if |
| 1118 // another starvation occurs during the latter EOS's decode. |
| 1119 Start(CreateAudioVideoDemuxerConfigs()); |
| 1120 CreateNextTextureAndSetVideoSurface(); |
| 1121 EXPECT_TRUE(GetMediaDecoderJob(true) && GetMediaDecoderJob(false)); |
| 1122 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1123 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); |
| 1124 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS |
| 1125 |
| 1126 // Wait until video EOS is processed and more data (assumed to be audio) is |
| 1127 // requested. |
| 1128 while (demuxer_->num_data_requests() < 3 || |
| 1129 GetMediaDecoderJob(false)->is_decoding()) { |
| 1130 message_loop_.RunUntilIdle(); |
| 1131 } |
| 1132 |
| 1133 // Simulate decoder underrun to trigger prefetch while still decoding audio. |
| 1134 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1135 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(1)); |
| 1136 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding() && |
| 1137 !GetMediaDecoderJob(false)->is_decoding()); |
| 1138 TriggerPlayerStarvation(); |
| 1139 |
| 1140 // Complete the audio decode that was in progress when simulated player |
| 1141 // starvation was triggered. At no time after completing video EOS decode, |
| 1142 // above, should the video decoder job resume decoding. |
| 1143 while (GetMediaDecoderJob(true)->is_decoding()) { |
| 1144 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); |
| 1145 message_loop_.RunUntilIdle(); |
| 1146 } |
| 1147 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); |
| 1148 EXPECT_EQ(4, demuxer_->num_data_requests()); |
| 1149 |
| 1150 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS |
| 1151 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); |
| 1152 |
| 1153 // Simulate another decoder underrun to trigger prefetch while decoding EOS. |
| 1154 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
| 1155 TriggerPlayerStarvation(); |
| 1156 |
| 1157 EXPECT_FALSE(manager_.playback_completed()); |
| 1158 message_loop_.Run(); |
| 1159 EXPECT_TRUE(manager_.playback_completed()); |
| 1160 EXPECT_EQ(4, demuxer_->num_data_requests()); |
| 1161 } |
| 1162 |
| 1163 TEST_F(MediaSourcePlayerTest, StarvationDuringVideoEOSDecode) { |
| 1164 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1165 |
| 1166 // Test that video-only playback completes without further data requested when |
| 1167 // starvation occurs during EOS decode. |
| 1168 CreateNextTextureAndSetVideoSurface(); |
| 1169 StartVideoDecoderJob(); |
| 1170 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); |
| 1171 message_loop_.Run(); |
| 1172 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1173 |
| 1174 // Simulate decoder underrun to trigger prefetch while decoding EOS. |
| 1175 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS |
| 1176 EXPECT_TRUE(GetMediaDecoderJob(false)->is_decoding()); |
| 1177 TriggerPlayerStarvation(); |
| 1178 EXPECT_FALSE(manager_.playback_completed()); |
| 1179 message_loop_.Run(); |
| 1180 EXPECT_TRUE(manager_.playback_completed()); |
| 1181 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1182 } |
| 1183 |
| 1184 TEST_F(MediaSourcePlayerTest, StarvationDuringAudioEOSDecode) { |
| 1185 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1186 |
| 1187 // Test that audio-only playback completes without further data requested when |
| 1188 // starvation occurs during EOS decode. |
| 1189 StartAudioDecoderJob(); |
| 1190 EXPECT_TRUE(GetMediaDecoderJob(true)); |
| 1191 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); |
| 1192 message_loop_.Run(); |
| 1193 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1194 |
| 1195 // Simulate decoder underrun to trigger prefetch while decoding EOS. |
| 1196 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS |
| 1197 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
| 1198 TriggerPlayerStarvation(); |
| 1199 EXPECT_FALSE(manager_.playback_completed()); |
| 1200 message_loop_.Run(); |
| 1201 EXPECT_TRUE(manager_.playback_completed()); |
| 1202 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1016 } | 1203 } |
| 1017 | 1204 |
| 1018 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterAbort) { | 1205 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterAbort) { |
| 1019 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1206 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1020 | 1207 |
| 1021 // Test that the decoder will not request new data after receiving an aborted | 1208 // Test that the decoder will not request new data after receiving an aborted |
| 1022 // access unit. | 1209 // access unit. |
| 1023 StartAudioDecoderJob(); | 1210 StartAudioDecoderJob(); |
| 1024 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1211 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 1025 | 1212 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 } | 1317 } |
| 1131 | 1318 |
| 1132 TEST_F(MediaSourcePlayerTest, PrerollAudioAfterSeek) { | 1319 TEST_F(MediaSourcePlayerTest, PrerollAudioAfterSeek) { |
| 1133 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1320 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1134 | 1321 |
| 1135 // Test decoder job will preroll the media to the seek position. | 1322 // Test decoder job will preroll the media to the seek position. |
| 1136 StartAudioDecoderJob(); | 1323 StartAudioDecoderJob(); |
| 1137 EXPECT_TRUE(GetMediaDecoderJob(true)); | 1324 EXPECT_TRUE(GetMediaDecoderJob(true)); |
| 1138 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1325 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 1139 | 1326 |
| 1140 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100)); | 1327 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100), true, 1); |
| 1141 EXPECT_TRUE(IsPrerolling(true)); | 1328 EXPECT_TRUE(IsPrerolling(true)); |
| 1142 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); | 1329 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); |
| 1143 | 1330 |
| 1144 // Send some data before the seek position. | 1331 // Send some data before the seek position. |
| 1145 for (int i = 1; i < 4; ++i) { | 1332 for (int i = 1; i < 4; ++i) { |
| 1146 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); | 1333 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); |
| 1147 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | 1334 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
| 1148 message_loop_.Run(); | 1335 message_loop_.Run(); |
| 1149 } | 1336 } |
| 1150 EXPECT_EQ(100.0, player_.GetCurrentTime().InMillisecondsF()); | 1337 EXPECT_EQ(100.0, player_.GetCurrentTime().InMillisecondsF()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1161 | 1348 |
| 1162 TEST_F(MediaSourcePlayerTest, PrerollVideoAfterSeek) { | 1349 TEST_F(MediaSourcePlayerTest, PrerollVideoAfterSeek) { |
| 1163 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1350 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1164 | 1351 |
| 1165 // Test decoder job will preroll the media to the seek position. | 1352 // Test decoder job will preroll the media to the seek position. |
| 1166 CreateNextTextureAndSetVideoSurface(); | 1353 CreateNextTextureAndSetVideoSurface(); |
| 1167 StartVideoDecoderJob(); | 1354 StartVideoDecoderJob(); |
| 1168 EXPECT_TRUE(GetMediaDecoderJob(false)); | 1355 EXPECT_TRUE(GetMediaDecoderJob(false)); |
| 1169 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1356 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 1170 | 1357 |
| 1171 SeekPlayer(false, base::TimeDelta::FromMilliseconds(100)); | 1358 SeekPlayer(false, base::TimeDelta::FromMilliseconds(100), true, 1); |
| 1172 EXPECT_TRUE(IsPrerolling(false)); | 1359 EXPECT_TRUE(IsPrerolling(false)); |
| 1173 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); | 1360 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); |
| 1174 | 1361 |
| 1175 // Send some data before the seek position. | 1362 // Send some data before the seek position. |
| 1176 DemuxerData data; | 1363 DemuxerData data; |
| 1177 for (int i = 1; i < 4; ++i) { | 1364 for (int i = 1; i < 4; ++i) { |
| 1178 data = CreateReadFromDemuxerAckForVideo(); | 1365 data = CreateReadFromDemuxerAckForVideo(); |
| 1179 data.access_units[0].timestamp = base::TimeDelta::FromMilliseconds(i * 30); | 1366 data.access_units[0].timestamp = base::TimeDelta::FromMilliseconds(i * 30); |
| 1180 player_.OnDemuxerDataAvailable(data); | 1367 player_.OnDemuxerDataAvailable(data); |
| 1181 EXPECT_TRUE(GetMediaDecoderJob(false)->is_decoding()); | 1368 EXPECT_TRUE(GetMediaDecoderJob(false)->is_decoding()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1210 | 1397 |
| 1211 // Complete the initial preroll by feeding data to the decoder. | 1398 // Complete the initial preroll by feeding data to the decoder. |
| 1212 for (int i = 0; i < 4; ++i) { | 1399 for (int i = 0; i < 4; ++i) { |
| 1213 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); | 1400 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); |
| 1214 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | 1401 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
| 1215 message_loop_.Run(); | 1402 message_loop_.Run(); |
| 1216 } | 1403 } |
| 1217 EXPECT_LT(0.0, player_.GetCurrentTime().InMillisecondsF()); | 1404 EXPECT_LT(0.0, player_.GetCurrentTime().InMillisecondsF()); |
| 1218 EXPECT_FALSE(IsPrerolling(true)); | 1405 EXPECT_FALSE(IsPrerolling(true)); |
| 1219 | 1406 |
| 1220 SeekPlayer(true, base::TimeDelta::FromMilliseconds(500)); | 1407 SeekPlayer(true, base::TimeDelta::FromMilliseconds(500), true, 1); |
| 1221 | 1408 |
| 1222 // Prerolling should have begun again. | 1409 // Prerolling should have begun again. |
| 1223 EXPECT_TRUE(IsPrerolling(true)); | 1410 EXPECT_TRUE(IsPrerolling(true)); |
| 1224 EXPECT_EQ(500.0, GetPrerollTimestamp().InMillisecondsF()); | 1411 EXPECT_EQ(500.0, GetPrerollTimestamp().InMillisecondsF()); |
| 1225 | 1412 |
| 1226 // Send data at and after the seek position. Prerolling should complete. | 1413 // Send data at and after the seek position. Prerolling should complete. |
| 1227 for (int i = 0; i < 4; ++i) { | 1414 for (int i = 0; i < 4; ++i) { |
| 1228 DemuxerData data = CreateReadFromDemuxerAckForAudio(i); | 1415 DemuxerData data = CreateReadFromDemuxerAckForAudio(i); |
| 1229 data.access_units[0].timestamp = base::TimeDelta::FromMilliseconds( | 1416 data.access_units[0].timestamp = base::TimeDelta::FromMilliseconds( |
| 1230 500 + 30 * (i - 1)); | 1417 500 + 30 * (i - 1)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1243 | 1430 |
| 1244 TEST_F(MediaSourcePlayerTest, PrerollContinuesAcrossReleaseAndStart) { | 1431 TEST_F(MediaSourcePlayerTest, PrerollContinuesAcrossReleaseAndStart) { |
| 1245 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1432 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1246 | 1433 |
| 1247 // Test decoder job will resume media prerolling if interrupted by Release() | 1434 // Test decoder job will resume media prerolling if interrupted by Release() |
| 1248 // and Start(). | 1435 // and Start(). |
| 1249 StartAudioDecoderJob(); | 1436 StartAudioDecoderJob(); |
| 1250 EXPECT_TRUE(GetMediaDecoderJob(true)); | 1437 EXPECT_TRUE(GetMediaDecoderJob(true)); |
| 1251 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1438 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 1252 | 1439 |
| 1253 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100)); | 1440 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100), true, 1); |
| 1254 EXPECT_TRUE(IsPrerolling(true)); | 1441 EXPECT_TRUE(IsPrerolling(true)); |
| 1255 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); | 1442 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); |
| 1256 | 1443 |
| 1257 // Send some data before the seek position. | 1444 // Send some data before the seek position. |
| 1258 // Test uses 'large' number of iterations because decoder job may not get | 1445 // Test uses 'large' number of iterations because decoder job may not get |
| 1259 // MEDIA_CODEC_OK output status until after a few dequeue output attempts. | 1446 // MEDIA_CODEC_OK output status until after a few dequeue output attempts. |
| 1260 // This allows decoder status to stabilize prior to AU timestamp reaching | 1447 // This allows decoder status to stabilize prior to AU timestamp reaching |
| 1261 // the preroll target. | 1448 // the preroll target. |
| 1262 DemuxerData data; | 1449 DemuxerData data; |
| 1263 for (int i = 0; i < 10; ++i) { | 1450 for (int i = 0; i < 10; ++i) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 | 1487 |
| 1301 TEST_F(MediaSourcePlayerTest, PrerollContinuesAcrossConfigChange) { | 1488 TEST_F(MediaSourcePlayerTest, PrerollContinuesAcrossConfigChange) { |
| 1302 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1489 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1303 | 1490 |
| 1304 // Test decoder job will resume media prerolling if interrupted by | 1491 // Test decoder job will resume media prerolling if interrupted by |
| 1305 // |kConfigChanged| and OnDemuxerConfigsAvailable(). | 1492 // |kConfigChanged| and OnDemuxerConfigsAvailable(). |
| 1306 StartAudioDecoderJob(); | 1493 StartAudioDecoderJob(); |
| 1307 EXPECT_TRUE(GetMediaDecoderJob(true)); | 1494 EXPECT_TRUE(GetMediaDecoderJob(true)); |
| 1308 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1495 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 1309 | 1496 |
| 1310 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100)); | 1497 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100), true, 1); |
| 1311 EXPECT_TRUE(IsPrerolling(true)); | 1498 EXPECT_TRUE(IsPrerolling(true)); |
| 1312 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); | 1499 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); |
| 1313 | 1500 |
| 1314 // In response to data request, simulate that demuxer signals config change by | 1501 // In response to data request, simulate that demuxer signals config change by |
| 1315 // sending an AU with |kConfigChanged|. Player should prepare to reconfigure | 1502 // sending an AU with |kConfigChanged|. Player should prepare to reconfigure |
| 1316 // the audio decoder job, and should request new demuxer configs. | 1503 // the audio decoder job, and should request new demuxer configs. |
| 1317 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0); | 1504 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0); |
| 1318 EXPECT_EQ(0, demuxer_->num_config_requests()); | 1505 EXPECT_EQ(0, demuxer_->num_config_requests()); |
| 1319 player_.OnDemuxerDataAvailable(data); | 1506 player_.OnDemuxerDataAvailable(data); |
| 1320 EXPECT_EQ(1, demuxer_->num_config_requests()); | 1507 EXPECT_EQ(1, demuxer_->num_config_requests()); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 | 2089 |
| 1903 std::vector<std::string> codec_avc(1, "avc1"); | 2090 std::vector<std::string> codec_avc(1, "avc1"); |
| 1904 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); | 2091 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); |
| 1905 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); | 2092 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); |
| 1906 } | 2093 } |
| 1907 | 2094 |
| 1908 // TODO(xhwang): Are these IsTypeSupported tests device specific? | 2095 // TODO(xhwang): Are these IsTypeSupported tests device specific? |
| 1909 // TODO(xhwang): Add more IsTypeSupported tests. | 2096 // TODO(xhwang): Add more IsTypeSupported tests. |
| 1910 | 2097 |
| 1911 } // namespace media | 2098 } // namespace media |
| OLD | NEW |