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

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

Issue 257323003: Remove the IPC to request DemuxerConfigs when config changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | 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/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 DISALLOW_COPY_AND_ASSIGN(MockMediaPlayerManager); 129 DISALLOW_COPY_AND_ASSIGN(MockMediaPlayerManager);
130 }; 130 };
131 131
132 class MockDemuxerAndroid : public DemuxerAndroid { 132 class MockDemuxerAndroid : public DemuxerAndroid {
133 public: 133 public:
134 explicit MockDemuxerAndroid(base::MessageLoop* message_loop) 134 explicit MockDemuxerAndroid(base::MessageLoop* message_loop)
135 : message_loop_(message_loop), 135 : message_loop_(message_loop),
136 num_data_requests_(0), 136 num_data_requests_(0),
137 num_seek_requests_(0), 137 num_seek_requests_(0),
138 num_browser_seek_requests_(0), 138 num_browser_seek_requests_(0) {}
139 num_config_requests_(0) {}
140 virtual ~MockDemuxerAndroid() {} 139 virtual ~MockDemuxerAndroid() {}
141 140
142 virtual void Initialize(DemuxerAndroidClient* client) OVERRIDE {} 141 virtual void Initialize(DemuxerAndroidClient* client) OVERRIDE {}
143 virtual void RequestDemuxerConfigs() OVERRIDE {
144 num_config_requests_++;
145 }
146 virtual void RequestDemuxerData(DemuxerStream::Type type) OVERRIDE { 142 virtual void RequestDemuxerData(DemuxerStream::Type type) OVERRIDE {
147 num_data_requests_++; 143 num_data_requests_++;
148 if (message_loop_->is_running()) 144 if (message_loop_->is_running())
149 message_loop_->Quit(); 145 message_loop_->Quit();
150 } 146 }
151 virtual void RequestDemuxerSeek(const base::TimeDelta& time_to_seek, 147 virtual void RequestDemuxerSeek(const base::TimeDelta& time_to_seek,
152 bool is_browser_seek) OVERRIDE { 148 bool is_browser_seek) OVERRIDE {
153 num_seek_requests_++; 149 num_seek_requests_++;
154 if (is_browser_seek) 150 if (is_browser_seek)
155 num_browser_seek_requests_++; 151 num_browser_seek_requests_++;
156 } 152 }
157 153
158 int num_data_requests() const { return num_data_requests_; } 154 int num_data_requests() const { return num_data_requests_; }
159 int num_seek_requests() const { return num_seek_requests_; } 155 int num_seek_requests() const { return num_seek_requests_; }
160 int num_browser_seek_requests() const { return num_browser_seek_requests_; } 156 int num_browser_seek_requests() const { return num_browser_seek_requests_; }
161 int num_config_requests() const { return num_config_requests_; }
162 157
163 private: 158 private:
164 base::MessageLoop* message_loop_; 159 base::MessageLoop* message_loop_;
165 160
166 // The number of encoded data requests this object has seen. 161 // The number of encoded data requests this object has seen.
167 int num_data_requests_; 162 int num_data_requests_;
168 163
169 // The number of regular and browser seek requests this object has seen. 164 // The number of regular and browser seek requests this object has seen.
170 int num_seek_requests_; 165 int num_seek_requests_;
171 166
172 // The number of browser seek requests this object has seen. 167 // The number of browser seek requests this object has seen.
173 int num_browser_seek_requests_; 168 int num_browser_seek_requests_;
174 169
175 // The number of demuxer config requests this object has seen.
176 int num_config_requests_;
177
178 DISALLOW_COPY_AND_ASSIGN(MockDemuxerAndroid); 170 DISALLOW_COPY_AND_ASSIGN(MockDemuxerAndroid);
179 }; 171 };
180 172
181 class MediaSourcePlayerTest : public testing::Test { 173 class MediaSourcePlayerTest : public testing::Test {
182 public: 174 public:
183 MediaSourcePlayerTest() 175 MediaSourcePlayerTest()
184 : manager_(&message_loop_), 176 : manager_(&message_loop_),
185 demuxer_(new MockDemuxerAndroid(&message_loop_)), 177 demuxer_(new MockDemuxerAndroid(&message_loop_)),
186 player_(0, &manager_, 178 player_(0, &manager_,
187 base::Bind(&MockMediaPlayerManager::OnMediaResourcesRequested, 179 base::Bind(&MockMediaPlayerManager::OnMediaResourcesRequested,
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 DemuxerData CreateReadFromDemuxerAckWithConfigChanged(bool is_audio, 514 DemuxerData CreateReadFromDemuxerAckWithConfigChanged(bool is_audio,
523 int config_unit_index) { 515 int config_unit_index) {
524 DemuxerData data; 516 DemuxerData data;
525 data.type = is_audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO; 517 data.type = is_audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO;
526 data.access_units.resize(config_unit_index + 1); 518 data.access_units.resize(config_unit_index + 1);
527 519
528 for (int i = 0; i < config_unit_index; ++i) 520 for (int i = 0; i < config_unit_index; ++i)
529 data.access_units[i] = CreateAccessUnitWithData(is_audio, i); 521 data.access_units[i] = CreateAccessUnitWithData(is_audio, i);
530 522
531 data.access_units[config_unit_index].status = DemuxerStream::kConfigChanged; 523 data.access_units[config_unit_index].status = DemuxerStream::kConfigChanged;
524 data.demuxer_configs.resize(1);
525 data.demuxer_configs[0] = CreateDemuxerConfigs(is_audio, !is_audio);
532 return data; 526 return data;
533 } 527 }
534 528
535 // Valid only for video-only player tests. If |trigger_with_release_start| is 529 // Valid only for video-only player tests. If |trigger_with_release_start| is
536 // true, triggers the browser seek with a Release() + video data received + 530 // true, triggers the browser seek with a Release() + video data received +
537 // Start() with a new surface. If false, triggers the browser seek by 531 // Start() with a new surface. If false, triggers the browser seek by
538 // setting a new video surface after beginning decode of received video data. 532 // setting a new video surface after beginning decode of received video data.
539 // Such data receipt causes possibility that an I-frame is not next, and 533 // Such data receipt causes possibility that an I-frame is not next, and
540 // browser seek results once decode completes and surface change processing 534 // browser seek results once decode completes and surface change processing
541 // begins. 535 // begins.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 590
597 // Creates a new decoder job and feeds it data ending with a |kConfigChanged| 591 // Creates a new decoder job and feeds it data ending with a |kConfigChanged|
598 // access unit. If |config_unit_in_prefetch| is true, sends feeds the config 592 // access unit. If |config_unit_in_prefetch| is true, sends feeds the config
599 // change AU in response to the job's first read request (prefetch). If 593 // change AU in response to the job's first read request (prefetch). If
600 // false, regular data is fed and decoded prior to feeding the config change 594 // false, regular data is fed and decoded prior to feeding the config change
601 // AU in response to the second data request (after prefetch completed). 595 // AU in response to the second data request (after prefetch completed).
602 // |config_unit_index| controls which access unit is |kConfigChanged|. 596 // |config_unit_index| controls which access unit is |kConfigChanged|.
603 void StartConfigChange(bool is_audio, 597 void StartConfigChange(bool is_audio,
604 bool config_unit_in_prefetch, 598 bool config_unit_in_prefetch,
605 int config_unit_index) { 599 int config_unit_index) {
606 int expected_num_config_requests = demuxer_->num_config_requests();
607
608 EXPECT_FALSE(GetMediaDecoderJob(is_audio)); 600 EXPECT_FALSE(GetMediaDecoderJob(is_audio));
609 if (is_audio) { 601 if (is_audio) {
610 StartAudioDecoderJob(true); 602 StartAudioDecoderJob(true);
611 } else { 603 } else {
612 CreateNextTextureAndSetVideoSurface(); 604 CreateNextTextureAndSetVideoSurface();
613 StartVideoDecoderJob(true); 605 StartVideoDecoderJob(true);
614 } 606 }
615 607
616 int expected_num_data_requests = demuxer_->num_data_requests(); 608 int expected_num_data_requests = demuxer_->num_data_requests();
617 609
618 // Feed and decode a standalone access unit so the player exits prefetch. 610 // Feed and decode a standalone access unit so the player exits prefetch.
619 if (!config_unit_in_prefetch) { 611 if (!config_unit_in_prefetch) {
620 if (is_audio) 612 if (is_audio)
621 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); 613 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
622 else 614 else
623 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); 615 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo());
624 616
625 WaitForDecodeDone(is_audio, !is_audio); 617 WaitForDecodeDone(is_audio, !is_audio);
626 618
627 // We should have completed the prefetch phase at this point. 619 // We should have completed the prefetch phase at this point.
628 expected_num_data_requests++; 620 expected_num_data_requests++;
629 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests()); 621 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests());
630 } 622 }
631 623
632 EXPECT_EQ(expected_num_config_requests, demuxer_->num_config_requests());
633
634 // Feed and decode access units with data for any units prior to 624 // Feed and decode access units with data for any units prior to
635 // |config_unit_index|, and a |kConfigChanged| unit at that index. 625 // |config_unit_index|, and a |kConfigChanged| unit at that index.
636 // Player should prepare to reconfigure the decoder job, and should request 626 // Player should prepare to reconfigure the decoder job, and should request
637 // new demuxer configs. 627 // new demuxer configs.
638 player_.OnDemuxerDataAvailable( 628 player_.OnDemuxerDataAvailable(
639 CreateReadFromDemuxerAckWithConfigChanged(is_audio, config_unit_index)); 629 CreateReadFromDemuxerAckWithConfigChanged(is_audio, config_unit_index));
640 WaitForDecodeDone(is_audio, !is_audio); 630 // Run until decoder starts to request new data.
641 631 while (demuxer_->num_data_requests() == expected_num_data_requests)
642 expected_num_config_requests++; 632 message_loop_.RunUntilIdle();
643 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests());
644 EXPECT_EQ(expected_num_config_requests, demuxer_->num_config_requests());
645 } 633 }
646 634
647 void CreateNextTextureAndSetVideoSurface() { 635 void CreateNextTextureAndSetVideoSurface() {
648 gfx::SurfaceTexture* surface_texture; 636 gfx::SurfaceTexture* surface_texture;
649 if (surface_texture_a_is_next_) { 637 if (surface_texture_a_is_next_) {
650 surface_texture_a_ = gfx::SurfaceTexture::Create(next_texture_id_++); 638 surface_texture_a_ = gfx::SurfaceTexture::Create(next_texture_id_++);
651 surface_texture = surface_texture_a_.get(); 639 surface_texture = surface_texture_a_.get();
652 } else { 640 } else {
653 surface_texture_b_ = gfx::SurfaceTexture::Create(next_texture_id_++); 641 surface_texture_b_ = gfx::SurfaceTexture::Create(next_texture_id_++);
654 surface_texture = surface_texture_b_.get(); 642 surface_texture = surface_texture_b_.get();
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1180 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1193 1181
1194 // Test that if one stream (audio) has completed decode of EOS and the other 1182 // Test that if one stream (audio) has completed decode of EOS and the other
1195 // stream (video) processes config change, that subsequent video EOS completes 1183 // stream (video) processes config change, that subsequent video EOS completes
1196 // A/V playback. 1184 // A/V playback.
1197 // Also tests that seeking+Start() after completing playback resumes playback. 1185 // Also tests that seeking+Start() after completing playback resumes playback.
1198 CreateNextTextureAndSetVideoSurface(); 1186 CreateNextTextureAndSetVideoSurface();
1199 Start(CreateAudioVideoDemuxerConfigs(), true); 1187 Start(CreateAudioVideoDemuxerConfigs(), true);
1200 1188
1201 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS 1189 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS
1202 EXPECT_EQ(0, demuxer_->num_config_requests());
1203 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( 1190 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged(
1204 false, 0)); // Video |kConfigChanged| as first unit. 1191 false, 0)); // Video |kConfigChanged| as first unit.
1205 1192
1206 WaitForAudioVideoDecodeDone(); 1193 WaitForAudioVideoDecodeDone();
1207 1194
1208 EXPECT_EQ(1, demuxer_->num_config_requests());
1209 EXPECT_EQ(2, demuxer_->num_data_requests());
1210 player_.OnDemuxerConfigsAvailable(CreateAudioVideoDemuxerConfigs());
1211 EXPECT_EQ(3, demuxer_->num_data_requests()); 1195 EXPECT_EQ(3, demuxer_->num_data_requests());
1212 1196
1213 // At no time after completing audio EOS decode, above, should the 1197 // At no time after completing audio EOS decode, above, should the
1214 // audio decoder job resume decoding. Send and decode video EOS. 1198 // audio decoder job resume decoding. Send and decode video EOS.
1215 VerifyPlaybackCompletesOnEOSDecode(true, false); 1199 VerifyPlaybackCompletesOnEOSDecode(true, false);
1216 VerifyCompletedPlaybackResumesOnSeekPlusStart(true, true); 1200 VerifyCompletedPlaybackResumesOnSeekPlusStart(true, true);
1217 } 1201 }
1218 1202
1219 TEST_F(MediaSourcePlayerTest, VA_PlaybackCompletionAcrossConfigChange) { 1203 TEST_F(MediaSourcePlayerTest, VA_PlaybackCompletionAcrossConfigChange) {
1220 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1204 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1221 1205
1222 // Test that if one stream (video) has completed decode of EOS and the other 1206 // Test that if one stream (video) has completed decode of EOS and the other
1223 // stream (audio) processes config change, that subsequent audio EOS completes 1207 // stream (audio) processes config change, that subsequent audio EOS completes
1224 // A/V playback. 1208 // A/V playback.
1225 // Also tests that seeking+Start() after completing playback resumes playback. 1209 // Also tests that seeking+Start() after completing playback resumes playback.
1226 CreateNextTextureAndSetVideoSurface(); 1210 CreateNextTextureAndSetVideoSurface();
1227 Start(CreateAudioVideoDemuxerConfigs(), true); 1211 Start(CreateAudioVideoDemuxerConfigs(), true);
1228 1212
1229 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS 1213 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS
1230 EXPECT_EQ(0, demuxer_->num_config_requests());
1231 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( 1214 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged(
1232 true, 0)); // Audio |kConfigChanged| as first unit. 1215 true, 0)); // Audio |kConfigChanged| as first unit.
1233 1216
1234 WaitForAudioVideoDecodeDone(); 1217 WaitForAudioVideoDecodeDone();
1235 1218
1236 // TODO(wolenetz/qinmin): Prevent redundant demuxer config request and change
1237 // expectation to 1 here. See http://crbug.com/325528.
1238 EXPECT_EQ(2, demuxer_->num_config_requests());
1239 EXPECT_EQ(2, demuxer_->num_data_requests());
1240 player_.OnDemuxerConfigsAvailable(CreateAudioVideoDemuxerConfigs());
1241 EXPECT_EQ(3, demuxer_->num_data_requests()); 1219 EXPECT_EQ(3, demuxer_->num_data_requests());
1242 1220
1243 // At no time after completing video EOS decode, above, should the 1221 // At no time after completing video EOS decode, above, should the
1244 // video decoder job resume decoding. Send and decode audio EOS. 1222 // video decoder job resume decoding. Send and decode audio EOS.
1245 VerifyPlaybackCompletesOnEOSDecode(true, true); 1223 VerifyPlaybackCompletesOnEOSDecode(true, true);
1246 VerifyCompletedPlaybackResumesOnSeekPlusStart(true, true); 1224 VerifyCompletedPlaybackResumesOnSeekPlusStart(true, true);
1247 } 1225 }
1248 1226
1249 TEST_F(MediaSourcePlayerTest, AV_NoPrefetchForFinishedVideoOnAudioStarvation) { 1227 TEST_F(MediaSourcePlayerTest, AV_NoPrefetchForFinishedVideoOnAudioStarvation) {
1250 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1228 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 StartAudioDecoderJob(true); 1563 StartAudioDecoderJob(true);
1586 1564
1587 SeekPlayerWithAbort(true, base::TimeDelta::FromMilliseconds(100)); 1565 SeekPlayerWithAbort(true, base::TimeDelta::FromMilliseconds(100));
1588 EXPECT_TRUE(IsPrerolling(true)); 1566 EXPECT_TRUE(IsPrerolling(true));
1589 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); 1567 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF());
1590 1568
1591 // In response to data request, simulate that demuxer signals config change by 1569 // In response to data request, simulate that demuxer signals config change by
1592 // sending an AU with |kConfigChanged|. Player should prepare to reconfigure 1570 // sending an AU with |kConfigChanged|. Player should prepare to reconfigure
1593 // the audio decoder job, and should request new demuxer configs. 1571 // the audio decoder job, and should request new demuxer configs.
1594 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0); 1572 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0);
1595 EXPECT_EQ(0, demuxer_->num_config_requests());
1596 player_.OnDemuxerDataAvailable(data); 1573 player_.OnDemuxerDataAvailable(data);
1597 EXPECT_EQ(1, demuxer_->num_config_requests());
1598 1574
1599 // Simulate arrival of new configs. 1575 // Simulate arrival of new configs.
1600 player_.OnDemuxerConfigsAvailable(CreateAudioDemuxerConfigs(kCodecVorbis)); 1576 player_.OnDemuxerConfigsAvailable(CreateAudioDemuxerConfigs(kCodecVorbis));
1601 1577
1602 PrerollDecoderToTime( 1578 PrerollDecoderToTime(
1603 true, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100)); 1579 true, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100));
1604 } 1580 }
1605 1581
1606 TEST_F(MediaSourcePlayerTest, SimultaneousAudioVideoConfigChange) { 1582 TEST_F(MediaSourcePlayerTest, SimultaneousAudioVideoConfigChange) {
1607 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1583 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1608 1584
1609 // Test that the player allows simultaneous audio and video config change, 1585 // Test that the player allows simultaneous audio and video config change,
1610 // such as might occur during OnPrefetchDone() if next access unit for both 1586 // such as might occur during OnPrefetchDone() if next access unit for both
1611 // audio and video jobs is |kConfigChanged|. 1587 // audio and video jobs is |kConfigChanged|.
1612 CreateNextTextureAndSetVideoSurface(); 1588 CreateNextTextureAndSetVideoSurface();
1613 Start(CreateAudioVideoDemuxerConfigs(), true); 1589 Start(CreateAudioVideoDemuxerConfigs(), true);
1614 MediaDecoderJob* first_audio_job = GetMediaDecoderJob(true); 1590 MediaDecoderJob* first_audio_job = GetMediaDecoderJob(true);
1615 MediaDecoderJob* first_video_job = GetMediaDecoderJob(false); 1591 MediaDecoderJob* first_video_job = GetMediaDecoderJob(false);
1616 1592
1617 // Simulate audio |kConfigChanged| prefetched as standalone access unit. 1593 // Simulate audio |kConfigChanged| prefetched as standalone access unit.
1618 player_.OnDemuxerDataAvailable( 1594 player_.OnDemuxerDataAvailable(
1619 CreateReadFromDemuxerAckWithConfigChanged(true, 0)); 1595 CreateReadFromDemuxerAckWithConfigChanged(true, 0));
1620 EXPECT_EQ(0, demuxer_->num_config_requests()); // No OnPrefetchDone() yet.
1621 1596
1622 // Simulate video |kConfigChanged| prefetched as standalone access unit. 1597 // Simulate video |kConfigChanged| prefetched as standalone access unit.
1623 player_.OnDemuxerDataAvailable( 1598 player_.OnDemuxerDataAvailable(
1624 CreateReadFromDemuxerAckWithConfigChanged(false, 0)); 1599 CreateReadFromDemuxerAckWithConfigChanged(false, 0));
1625 EXPECT_EQ(1, demuxer_->num_config_requests()); // OnPrefetchDone() occurred. 1600 EXPECT_EQ(4, demuxer_->num_data_requests()); // No more data requested yet.
wolenetz 2014/05/02 22:25:30 nit: remove the incorrect(?) comment
qinmin 2014/05/05 20:52:19 Done.
1626 EXPECT_EQ(2, demuxer_->num_data_requests()); // No more data requested yet.
1627 1601
1628 // No job re-creation should occur until the requested configs arrive. 1602 // No job re-creation should occur until the requested configs arrive.
wolenetz 2014/05/02 22:25:30 nit: adjust the wording of comment: Both jobs shou
qinmin 2014/05/05 20:52:19 Done.
1629 EXPECT_EQ(first_audio_job, GetMediaDecoderJob(true)); 1603 EXPECT_NE(first_audio_job, GetMediaDecoderJob(true));
wolenetz 2014/05/02 22:25:30 nit: these pointer checks can be flaky. I think we
qinmin 2014/05/05 20:52:19 Done.
1630 EXPECT_EQ(first_video_job, GetMediaDecoderJob(false)); 1604 EXPECT_NE(first_video_job, GetMediaDecoderJob(false));
1631 1605 EXPECT_TRUE(GetMediaDecoderJob(true) && GetMediaDecoderJob(false));
1632 player_.OnDemuxerConfigsAvailable(CreateAudioVideoDemuxerConfigs());
1633 EXPECT_EQ(4, demuxer_->num_data_requests());
1634 MediaDecoderJob* second_audio_job = GetMediaDecoderJob(true);
1635 MediaDecoderJob* second_video_job = GetMediaDecoderJob(false);
1636 EXPECT_NE(first_audio_job, second_audio_job);
1637 EXPECT_NE(first_video_job, second_video_job);
1638 EXPECT_TRUE(second_audio_job && second_video_job);
1639
1640 // Confirm no further demuxer configs requested.
1641 EXPECT_EQ(1, demuxer_->num_config_requests());
1642 } 1606 }
1643 1607
1644 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit0) { 1608 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit0) {
1645 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1609 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1646 1610
1647 // Test that the player detects need for and requests demuxer configs if 1611 // Test that the player detects need for and requests demuxer configs if
1648 // the |kConfigChanged| unit is the very first unit in the set of units 1612 // the |kConfigChanged| unit is the very first unit in the set of units
1649 // received in OnDemuxerDataAvailable() ostensibly while 1613 // received in OnDemuxerDataAvailable() ostensibly while
1650 // |PREFETCH_DONE_EVENT_PENDING|. 1614 // |PREFETCH_DONE_EVENT_PENDING|.
1651 StartConfigChange(true, true, 0); 1615 StartConfigChange(true, true, 0);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); 1660 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF());
1697 EXPECT_EQ(3, demuxer_->num_data_requests()); 1661 EXPECT_EQ(3, demuxer_->num_data_requests());
1698 1662
1699 PrerollDecoderToTime( 1663 PrerollDecoderToTime(
1700 false, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100)); 1664 false, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100));
1701 } 1665 }
1702 1666
1703 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChange) { 1667 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChange) {
1704 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1668 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1705 1669
1706 // Test that video config change notification results in request for demuxer 1670 // Test that video config change notification results in creating a new
1707 // configuration, and that a video decoder job results without any browser 1671 // video decoder job results without any browser seek.
1708 // seek necessary once the new demuxer config arrives.
1709 StartConfigChange(false, true, 1); 1672 StartConfigChange(false, true, 1);
1710 MediaDecoderJob* first_job = GetMediaDecoderJob(false); 1673 EXPECT_TRUE(GetMediaDecoderJob(false));
1711 EXPECT_TRUE(first_job);
1712 EXPECT_EQ(1, demuxer_->num_data_requests());
1713 EXPECT_EQ(1, demuxer_->num_config_requests());
1714
1715 // Simulate arrival of new configs.
1716 player_.OnDemuxerConfigsAvailable(CreateVideoDemuxerConfigs());
1717
1718 // New video decoder job should have been created and configured, without any
1719 // browser seek.
1720 MediaDecoderJob* second_job = GetMediaDecoderJob(false);
1721 EXPECT_TRUE(second_job);
1722 EXPECT_NE(first_job, second_job);
1723 EXPECT_EQ(2, demuxer_->num_data_requests()); 1674 EXPECT_EQ(2, demuxer_->num_data_requests());
1724 EXPECT_EQ(1, demuxer_->num_config_requests());
1725 EXPECT_EQ(0, demuxer_->num_seek_requests()); 1675 EXPECT_EQ(0, demuxer_->num_seek_requests());
1726 } 1676 }
1727 1677
1728 TEST_F(MediaSourcePlayerTest, VideoConfigChangeContinuesAcrossSeek) { 1678 TEST_F(MediaSourcePlayerTest, NewSurfaceAfterChangingConfigs) {
1729 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1679 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1730 1680
1731 // Test if a demuxer config request is pending (due to previously receiving 1681 // Test that no seek results from a SetVideoSurface() that occurs after
1732 // |kConfigChanged|), and a seek request arrives prior to demuxer configs, 1682 // the player processes new demuxer configs. This test may be good to keep
1733 // then seek is processed first, followed by the decoder config change. 1683 // beyond browser seek hack.
1734 // This assumes the demuxer sends |kConfigChanged| read response prior to
1735 // canceling any reads pending seek; no |kAborted| is involved in this test.
1736 StartConfigChange(false, false, 1); 1684 StartConfigChange(false, false, 1);
1737 MediaDecoderJob* first_job = GetMediaDecoderJob(false); 1685 EXPECT_TRUE(GetMediaDecoderJob(false));
1738 EXPECT_TRUE(first_job);
1739 EXPECT_EQ(1, demuxer_->num_config_requests());
1740 EXPECT_EQ(2, demuxer_->num_data_requests());
1741 EXPECT_EQ(0, demuxer_->num_seek_requests());
1742
1743 player_.SeekTo(base::TimeDelta::FromMilliseconds(100));
1744
1745 // Verify that the seek is requested immediately.
1746 EXPECT_EQ(1, demuxer_->num_seek_requests());
1747
1748 // Simulate unlikely delayed arrival of the demuxer configs, completing the
1749 // config change.
1750 // TODO(wolenetz): Is it even possible for requested demuxer configs to be
1751 // delayed until after a SeekTo request arrives?
1752 player_.OnDemuxerConfigsAvailable(CreateVideoDemuxerConfigs());
1753
1754 MediaDecoderJob* second_job = GetMediaDecoderJob(false);
1755 EXPECT_NE(first_job, second_job);
1756 EXPECT_TRUE(second_job);
1757
1758 // Send back the seek done notification. This should finish the seek and
1759 // trigger the player to request more data.
1760 EXPECT_EQ(2, demuxer_->num_data_requests());
1761 player_.OnDemuxerSeekDone(kNoTimestamp());
1762 EXPECT_EQ(3, demuxer_->num_data_requests()); 1686 EXPECT_EQ(3, demuxer_->num_data_requests());
1763 }
1764
1765 TEST_F(MediaSourcePlayerTest, NewSurfaceWhileChangingConfigs) {
1766 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1767
1768 // Test that no seek or duplicated demuxer config request results from a
1769 // SetVideoSurface() that occurs while the player is expecting new demuxer
1770 // configs. This test may be good to keep beyond browser seek hack.
1771 StartConfigChange(false, false, 1);
1772 MediaDecoderJob* first_job = GetMediaDecoderJob(false);
1773 EXPECT_TRUE(first_job);
1774 EXPECT_EQ(1, demuxer_->num_config_requests());
1775 EXPECT_EQ(2, demuxer_->num_data_requests());
1776 1687
1777 CreateNextTextureAndSetVideoSurface(); 1688 CreateNextTextureAndSetVideoSurface();
1778 1689 EXPECT_TRUE(GetMediaDecoderJob(false));
1779 // Surface change processing (including decoder job re-creation) should
1780 // not occur until the pending video config change is completed.
1781 EXPECT_EQ(first_job, GetMediaDecoderJob(false));
1782
1783 player_.OnDemuxerConfigsAvailable(CreateVideoDemuxerConfigs());
1784 MediaDecoderJob* second_job = GetMediaDecoderJob(false);
1785 EXPECT_NE(first_job, second_job);
1786 EXPECT_TRUE(second_job);
1787
1788 EXPECT_EQ(3, demuxer_->num_data_requests()); 1690 EXPECT_EQ(3, demuxer_->num_data_requests());
1789 EXPECT_EQ(1, demuxer_->num_config_requests());
1790 EXPECT_EQ(0, demuxer_->num_seek_requests()); 1691 EXPECT_EQ(0, demuxer_->num_seek_requests());
1791 } 1692 }
1792 1693
1793 TEST_F(MediaSourcePlayerTest, 1694 TEST_F(MediaSourcePlayerTest,
1794 BrowserSeek_DecoderStarvationWhilePendingSurfaceChange) { 1695 BrowserSeek_DecoderStarvationWhilePendingSurfaceChange) {
1795 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1696 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1796 1697
1797 // Test video decoder starvation while handling a pending surface change 1698 // Test video decoder starvation while handling a pending surface change
1798 // should not cause any crashes. 1699 // should not cause any crashes.
1799 CreateNextTextureAndSetVideoSurface(); 1700 CreateNextTextureAndSetVideoSurface();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 player_.OnDemuxerSeekDone(kNoTimestamp()); 1859 player_.OnDemuxerSeekDone(kNoTimestamp());
1959 EXPECT_TRUE(GetMediaDecoderJob(true)); 1860 EXPECT_TRUE(GetMediaDecoderJob(true));
1960 EXPECT_TRUE(IsPrerolling(true)); 1861 EXPECT_TRUE(IsPrerolling(true));
1961 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); 1862 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF());
1962 EXPECT_EQ(3, demuxer_->num_data_requests()); 1863 EXPECT_EQ(3, demuxer_->num_data_requests());
1963 1864
1964 // No further seek should have been requested since before Release(), above. 1865 // No further seek should have been requested since before Release(), above.
1965 EXPECT_EQ(1, demuxer_->num_seek_requests()); 1866 EXPECT_EQ(1, demuxer_->num_seek_requests());
1966 } 1867 }
1967 1868
1968 TEST_F(MediaSourcePlayerTest, ConfigChangedThenReleaseThenConfigsAvailable) { 1869 TEST_F(MediaSourcePlayerTest, ConfigChangedThenReleaseThenConfigsAvailable) {
wolenetz 2014/05/02 22:25:30 Test needs renaming (no separation of configchange
qinmin 2014/05/05 20:52:19 Merged this test with the next test. Added a DCHEC
1969 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1870 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1970 1871
1971 // Test if Release() occurs after |kConfigChanged| detected, new configs 1872 // Test if Release() occurs after |kConfigChanged| detected, new configs
wolenetz 2014/05/02 22:25:30 nit: comment needs rewording (no configs requested
qinmin 2014/05/05 20:52:19 Done.
1972 // requested of demuxer, and the requested configs arrive before the next 1873 // requested of demuxer, and the requested configs arrive before the next
1973 // Start(), then the player completes the pending config change processing on 1874 // Start(), then the player completes the pending config change processing on
1974 // their receipt. 1875 // their receipt.
1975 StartConfigChange(true, true, 0); 1876 StartConfigChange(true, true, 0);
1976 ReleasePlayer(); 1877 ReleasePlayer();
1977 1878
1978 player_.OnDemuxerConfigsAvailable(CreateAudioDemuxerConfigs(kCodecVorbis));
1979 EXPECT_FALSE(GetMediaDecoderJob(true)); 1879 EXPECT_FALSE(GetMediaDecoderJob(true));
1980 EXPECT_FALSE(player_.IsPlaying()); 1880 EXPECT_FALSE(player_.IsPlaying());
1981 EXPECT_EQ(1, demuxer_->num_data_requests()); 1881 EXPECT_EQ(2, demuxer_->num_data_requests());
1982 1882
1983 // Player should resume upon Start(), even without further configs supplied. 1883 // Player should resume upon Start(), even without further configs supplied.
1984 player_.Start(); 1884 player_.Start();
1985 EXPECT_TRUE(GetMediaDecoderJob(true)); 1885 EXPECT_TRUE(GetMediaDecoderJob(true));
1986 EXPECT_TRUE(player_.IsPlaying()); 1886 EXPECT_TRUE(player_.IsPlaying());
1987 EXPECT_EQ(2, demuxer_->num_data_requests()); 1887 EXPECT_EQ(2, demuxer_->num_data_requests());
1988
1989 // No further config request should have occurred since StartConfigChange().
1990 EXPECT_EQ(1, demuxer_->num_config_requests());
1991 } 1888 }
1992 1889
1993 TEST_F(MediaSourcePlayerTest, ConfigChangedThenReleaseThenStart) { 1890 TEST_F(MediaSourcePlayerTest, ConfigChangedThenReleaseThenStart) {
wolenetz 2014/05/02 22:25:30 This test is now entirely a subset of the previous
qinmin 2014/05/05 20:52:19 merged with the above one On 2014/05/02 22:25:30,
1994 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1891 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1995 1892
1996 // Test if Release() occurs after |kConfigChanged| detected, new configs 1893 // Test if Release() occurs after |kConfigChanged| detected, new configs
1997 // requested of demuxer, and the requested configs arrive after the next 1894 // requested of demuxer, and the requested configs arrive after the next
1998 // Start(), then the player pends job creation until the new configs arrive. 1895 // Start(), then the player pends job creation until the new configs arrive.
1999 StartConfigChange(true, true, 0); 1896 StartConfigChange(true, true, 0);
2000 ReleasePlayer(); 1897 ReleasePlayer();
2001 1898
2002 player_.Start(); 1899 player_.Start();
2003 EXPECT_TRUE(player_.IsPlaying()); 1900 EXPECT_TRUE(player_.IsPlaying());
2004 EXPECT_FALSE(GetMediaDecoderJob(true));
2005 EXPECT_EQ(1, demuxer_->num_data_requests());
2006
2007 player_.OnDemuxerConfigsAvailable(CreateAudioDemuxerConfigs(kCodecVorbis));
2008 EXPECT_TRUE(GetMediaDecoderJob(true)); 1901 EXPECT_TRUE(GetMediaDecoderJob(true));
2009 EXPECT_EQ(2, demuxer_->num_data_requests()); 1902 EXPECT_EQ(2, demuxer_->num_data_requests());
2010
2011 // No further config request should have occurred since StartConfigChange().
2012 EXPECT_EQ(1, demuxer_->num_config_requests());
2013 } 1903 }
2014 1904
2015 TEST_F(MediaSourcePlayerTest, BrowserSeek_ThenReleaseThenDemuxerSeekDone) { 1905 TEST_F(MediaSourcePlayerTest, BrowserSeek_ThenReleaseThenDemuxerSeekDone) {
2016 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1906 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
2017 1907
2018 // Test that Release() after a browser seek's DemuxerSeek IPC request has been 1908 // Test that Release() after a browser seek's DemuxerSeek IPC request has been
2019 // sent behaves similar to a regular seek: if OnDemuxerSeekDone() occurs 1909 // sent behaves similar to a regular seek: if OnDemuxerSeekDone() occurs
2020 // before the next Start()+SetVideoSurface(), then the player will resume 1910 // before the next Start()+SetVideoSurface(), then the player will resume
2021 // correct post-seek preroll upon Start()+SetVideoSurface(). 1911 // correct post-seek preroll upon Start()+SetVideoSurface().
2022 BrowserSeekPlayer(false); 1912 BrowserSeekPlayer(false);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 1999
2110 // Test current time keep on increasing after audio config change. 2000 // Test current time keep on increasing after audio config change.
2111 // Test that current time is updated while decoder is starved. 2001 // Test that current time is updated while decoder is starved.
2112 StartAudioDecoderJob(true); 2002 StartAudioDecoderJob(true);
2113 2003
2114 DecodeAudioDataUntilOutputBecomesAvailable(); 2004 DecodeAudioDataUntilOutputBecomesAvailable();
2115 2005
2116 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0); 2006 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0);
2117 player_.OnDemuxerDataAvailable(data); 2007 player_.OnDemuxerDataAvailable(data);
2118 WaitForAudioDecodeDone(); 2008 WaitForAudioDecodeDone();
2119
2120 // Simulate arrival of new configs.
2121 player_.OnDemuxerConfigsAvailable(CreateAudioDemuxerConfigs(kCodecVorbis));
2122 DecodeAudioDataUntilOutputBecomesAvailable(); 2009 DecodeAudioDataUntilOutputBecomesAvailable();
2123 } 2010 }
2124 2011
2125 } // namespace media 2012 } // namespace media
OLDNEW
« media/base/android/media_decoder_job.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