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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 EXPECT_EQ(1, demuxer_->num_data_requests()); | 879 EXPECT_EQ(1, demuxer_->num_data_requests()); |
880 | 880 |
881 // Simulate browser seek is done and confirm player requests more data for new | 881 // Simulate browser seek is done and confirm player requests more data for new |
882 // video decoder job. | 882 // video decoder job. |
883 player_.OnDemuxerSeekDone(player_.GetCurrentTime()); | 883 player_.OnDemuxerSeekDone(player_.GetCurrentTime()); |
884 EXPECT_TRUE(GetMediaDecoderJob(false)); | 884 EXPECT_TRUE(GetMediaDecoderJob(false)); |
885 EXPECT_EQ(2, demuxer_->num_data_requests()); | 885 EXPECT_EQ(2, demuxer_->num_data_requests()); |
886 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 886 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
887 } | 887 } |
888 | 888 |
| 889 TEST_F(MediaSourcePlayerTest, SetEmptySurfaceAndStarveWhileDecoding) { |
| 890 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 891 |
| 892 // Test player pauses if an empty surface is passed. |
| 893 CreateNextTextureAndSetVideoSurface(); |
| 894 StartVideoDecoderJob(true); |
| 895 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 896 |
| 897 // Send the first input chunk. |
| 898 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); |
| 899 |
| 900 // While the decoder is decoding, pass an empty surface. |
| 901 gfx::ScopedJavaSurface empty_surface; |
| 902 player_.SetVideoSurface(empty_surface.Pass()); |
| 903 |
| 904 // Let the player starve. However, it should not issue any new data request in |
| 905 // this case. |
| 906 TriggerPlayerStarvation(); |
| 907 // Wait for the decoder job to finish decoding and be reset. |
| 908 while (GetMediaDecoderJob(false)) |
| 909 message_loop_.RunUntilIdle(); |
| 910 |
| 911 // No further seek or data requests should have been received since the |
| 912 // surface is empty. |
| 913 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); |
| 914 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 915 |
| 916 // Playback resumes once a non-empty surface is passed. |
| 917 CreateNextTextureAndSetVideoSurface(); |
| 918 EXPECT_EQ(1, demuxer_->num_browser_seek_requests()); |
| 919 } |
| 920 |
889 TEST_F(MediaSourcePlayerTest, AudioOnlyStartAfterSeekFinish) { | 921 TEST_F(MediaSourcePlayerTest, AudioOnlyStartAfterSeekFinish) { |
890 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 922 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
891 | 923 |
892 // Test audio decoder job will not start until pending seek event is handled. | 924 // Test audio decoder job will not start until pending seek event is handled. |
893 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis); | 925 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis); |
894 player_.OnDemuxerConfigsAvailable(configs); | 926 player_.OnDemuxerConfigsAvailable(configs); |
895 EXPECT_FALSE(GetMediaDecoderJob(true)); | 927 EXPECT_FALSE(GetMediaDecoderJob(true)); |
896 | 928 |
897 // Initiate a seek. Skip requesting element seek of renderer. | 929 // Initiate a seek. Skip requesting element seek of renderer. |
898 // Instead behave as if the renderer has asked us to seek. | 930 // Instead behave as if the renderer has asked us to seek. |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2063 | 2095 |
2064 std::vector<std::string> codec_avc(1, "avc1"); | 2096 std::vector<std::string> codec_avc(1, "avc1"); |
2065 EXPECT_FALSE(IsTypeSupported(invalid_uuid, kL3, kVideoMp4, codec_avc)); | 2097 EXPECT_FALSE(IsTypeSupported(invalid_uuid, kL3, kVideoMp4, codec_avc)); |
2066 EXPECT_FALSE(IsTypeSupported(invalid_uuid, kL1, kVideoMp4, codec_avc)); | 2098 EXPECT_FALSE(IsTypeSupported(invalid_uuid, kL1, kVideoMp4, codec_avc)); |
2067 } | 2099 } |
2068 | 2100 |
2069 // TODO(xhwang): Are these IsTypeSupported tests device specific? | 2101 // TODO(xhwang): Are these IsTypeSupported tests device specific? |
2070 // TODO(xhwang): Add more IsTypeSupported tests. | 2102 // TODO(xhwang): Add more IsTypeSupported tests. |
2071 | 2103 |
2072 } // namespace media | 2104 } // namespace media |
OLD | NEW |