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

Side by Side Diff: media/base/android/media_source_player_unittest.cc

Issue 50433007: Allow simultaneous audio and video config change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Allow simultaneous config change only in OnPrefetchDone(), add unit test Created 7 years, 1 month 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 | Annotate | Revision Log
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 <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 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 1200
1201 // Send data after the seek position. 1201 // Send data after the seek position.
1202 data = CreateReadFromDemuxerAckForAudio(3); 1202 data = CreateReadFromDemuxerAckForAudio(3);
1203 data.access_units[0].timestamp = base::TimeDelta::FromMilliseconds(100); 1203 data.access_units[0].timestamp = base::TimeDelta::FromMilliseconds(100);
1204 player_.OnDemuxerDataAvailable(data); 1204 player_.OnDemuxerDataAvailable(data);
1205 message_loop_.Run(); 1205 message_loop_.Run();
1206 EXPECT_LT(100.0, player_.GetCurrentTime().InMillisecondsF()); 1206 EXPECT_LT(100.0, player_.GetCurrentTime().InMillisecondsF());
1207 EXPECT_FALSE(IsPrerolling(true)); 1207 EXPECT_FALSE(IsPrerolling(true));
1208 } 1208 }
1209 1209
1210 TEST_F(MediaSourcePlayerTest, SimultaneousAudioVideoConfigChange) {
1211 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1212
1213 // Test that the player allows simultaneous audio and video config change,
1214 // such as might occur during OnPrefetchDone() if next access unit for both
1215 // audio and video jobs is |kConfigChanged|.
1216 Start(CreateAudioVideoDemuxerConfigs());
1217 CreateNextTextureAndSetVideoSurface();
1218 MediaDecoderJob* first_audio_job = GetMediaDecoderJob(true);
1219 MediaDecoderJob* first_video_job = GetMediaDecoderJob(false);
1220 EXPECT_TRUE(first_audio_job && first_video_job);
1221
1222 // Simulate audio |kConfigChanged| prefetched as standalone access unit.
1223 player_.OnDemuxerDataAvailable(
1224 CreateReadFromDemuxerAckWithConfigChanged(true, 0));
1225 EXPECT_EQ(0, demuxer_->num_config_requests()); // No OnPrefetchDone() yet.
1226
1227 // Simulate video |kConfigChanged| prefetched as standalone access unit.
1228 player_.OnDemuxerDataAvailable(
1229 CreateReadFromDemuxerAckWithConfigChanged(false, 0));
1230 EXPECT_EQ(1, demuxer_->num_config_requests()); // OnPrefetchDone() occurred.
1231 EXPECT_EQ(2, demuxer_->num_data_requests());
1232
1233 // No job re-creation should occur until the requested configs arrive.
1234 EXPECT_EQ(first_audio_job, GetMediaDecoderJob(true));
1235 EXPECT_EQ(first_video_job, GetMediaDecoderJob(false));
1236
1237 player_.OnDemuxerConfigsAvailable(CreateAudioVideoDemuxerConfigs());
1238 EXPECT_EQ(4, demuxer_->num_data_requests());
1239 MediaDecoderJob* second_audio_job = GetMediaDecoderJob(true);
1240 MediaDecoderJob* second_video_job = GetMediaDecoderJob(false);
1241 EXPECT_NE(first_audio_job, second_audio_job);
1242 EXPECT_NE(first_video_job, second_video_job);
1243 EXPECT_TRUE(second_audio_job && second_video_job);
1244
1245 // Confirm no further demuxer configs requested.
1246 EXPECT_EQ(1, demuxer_->num_config_requests());
1247 }
1248
1210 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit0) { 1249 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit0) {
1211 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1250 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1212 1251
1213 // Test that the player detects need for and requests demuxer configs if 1252 // Test that the player detects need for and requests demuxer configs if
1214 // the |kConfigChanged| unit is the very first unit in the set of units 1253 // the |kConfigChanged| unit is the very first unit in the set of units
1215 // received in OnDemuxerDataAvailable() ostensibly while 1254 // received in OnDemuxerDataAvailable() ostensibly while
1216 // |PREFETCH_DONE_EVENT_PENDING|. 1255 // |PREFETCH_DONE_EVENT_PENDING|.
1217 StartConfigChange(true, true, 0); 1256 StartConfigChange(true, true, 0);
1218 } 1257 }
1219 1258
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 1485
1447 std::vector<std::string> codec_avc(1, "avc1"); 1486 std::vector<std::string> codec_avc(1, "avc1");
1448 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); 1487 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc));
1449 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); 1488 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc));
1450 } 1489 }
1451 1490
1452 // TODO(xhwang): Are these IsTypeSupported tests device specific? 1491 // TODO(xhwang): Are these IsTypeSupported tests device specific?
1453 // TODO(xhwang): Add more IsTypeSupported tests. 1492 // TODO(xhwang): Add more IsTypeSupported tests.
1454 1493
1455 } // namespace media 1494 } // namespace media
OLDNEW
« media/base/android/media_source_player.cc ('K') | « media/base/android/media_source_player.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698