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/bind_to_current_loop.h" |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
11 #include "media/base/android/audio_decoder_job.h" | 12 #include "media/base/android/audio_decoder_job.h" |
12 #include "media/base/android/media_codec_bridge.h" | 13 #include "media/base/android/media_codec_bridge.h" |
13 #include "media/base/android/media_drm_bridge.h" | 14 #include "media/base/android/media_drm_bridge.h" |
14 #include "media/base/android/media_player_manager.h" | 15 #include "media/base/android/media_player_manager.h" |
15 #include "media/base/android/media_source_player.h" | 16 #include "media/base/android/media_source_player.h" |
16 #include "media/base/android/media_url_interceptor.h" | 17 #include "media/base/android/media_url_interceptor.h" |
17 #include "media/base/android/video_decoder_job.h" | 18 #include "media/base/android/video_decoder_job.h" |
18 #include "media/base/bind_to_current_loop.h" | |
19 #include "media/base/decoder_buffer.h" | 19 #include "media/base/decoder_buffer.h" |
20 #include "media/base/test_data_util.h" | 20 #include "media/base/test_data_util.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "ui/gl/android/surface_texture.h" | 22 #include "ui/gl/android/surface_texture.h" |
23 | 23 |
24 namespace media { | 24 namespace media { |
25 | 25 |
26 // Helper macro to skip the test if MediaCodecBridge isn't available. | 26 // Helper macro to skip the test if MediaCodecBridge isn't available. |
27 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ | 27 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ |
28 do { \ | 28 do { \ |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 EXPECT_FALSE(player_.IsPlaying()); | 239 EXPECT_FALSE(player_.IsPlaying()); |
240 } | 240 } |
241 | 241 |
242 // Upon the next successful decode callback, post a task to call Release() | 242 // Upon the next successful decode callback, post a task to call Release() |
243 // on the |player_|. TEST_F's do not have access to the private player | 243 // on the |player_|. TEST_F's do not have access to the private player |
244 // members, hence this helper method. | 244 // members, hence this helper method. |
245 // Prevent usage creep of MSP::set_decode_callback_for_testing() by | 245 // Prevent usage creep of MSP::set_decode_callback_for_testing() by |
246 // only using it for the ReleaseWithOnPrefetchDoneAlreadyPosted test. | 246 // only using it for the ReleaseWithOnPrefetchDoneAlreadyPosted test. |
247 void OnNextTestDecodeCallbackPostTaskToReleasePlayer() { | 247 void OnNextTestDecodeCallbackPostTaskToReleasePlayer() { |
248 DCHECK_EQ(&message_loop_, base::MessageLoop::current()); | 248 DCHECK_EQ(&message_loop_, base::MessageLoop::current()); |
249 player_.set_decode_callback_for_testing(media::BindToCurrentLoop( | 249 player_.set_decode_callback_for_testing(base::BindToCurrentLoop( |
250 base::Bind( | 250 base::Bind( |
251 &MediaSourcePlayerTest::ReleaseWithPendingPrefetchDoneVerification, | 251 &MediaSourcePlayerTest::ReleaseWithPendingPrefetchDoneVerification, |
252 base::Unretained(this)))); | 252 base::Unretained(this)))); |
253 } | 253 } |
254 | 254 |
255 // Asynch test callback posted upon decode completion to verify that a pending | 255 // Asynch test callback posted upon decode completion to verify that a pending |
256 // prefetch done event is not cleared across |player_|'s Release(). This helps | 256 // prefetch done event is not cleared across |player_|'s Release(). This helps |
257 // ensure the ReleaseWithOnPrefetchDoneAlreadyPosted test scenario is met. | 257 // ensure the ReleaseWithOnPrefetchDoneAlreadyPosted test scenario is met. |
258 void ReleaseWithPendingPrefetchDoneVerification() { | 258 void ReleaseWithPendingPrefetchDoneVerification() { |
259 EXPECT_TRUE(player_.IsEventPending(player_.PREFETCH_DONE_EVENT_PENDING)); | 259 EXPECT_TRUE(player_.IsEventPending(player_.PREFETCH_DONE_EVENT_PENDING)); |
(...skipping 2247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2507 // Wait for the metadata change. | 2507 // Wait for the metadata change. |
2508 while(manager_.num_metadata_changes() == 1) { | 2508 while(manager_.num_metadata_changes() == 1) { |
2509 player_.OnDemuxerDataAvailable(data); | 2509 player_.OnDemuxerDataAvailable(data); |
2510 WaitForVideoDecodeDone(); | 2510 WaitForVideoDecodeDone(); |
2511 } | 2511 } |
2512 EXPECT_EQ(2, manager_.num_metadata_changes()); | 2512 EXPECT_EQ(2, manager_.num_metadata_changes()); |
2513 WaitForVideoDecodeDone(); | 2513 WaitForVideoDecodeDone(); |
2514 } | 2514 } |
2515 | 2515 |
2516 } // namespace media | 2516 } // namespace media |
OLD | NEW |