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

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

Issue 1551103002: Convert Pass()→std::move() in //media (Android Cast edition) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | media/base/android/sdk_media_codec_bridge.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/base/android/media_source_player.h"
6
5 #include <stdint.h> 7 #include <stdint.h>
6
7 #include <string> 8 #include <string>
9 #include <utility>
8 10
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
13 #include "build/build_config.h" 15 #include "build/build_config.h"
14 #include "media/base/android/audio_decoder_job.h" 16 #include "media/base/android/audio_decoder_job.h"
15 #include "media/base/android/media_codec_util.h" 17 #include "media/base/android/media_codec_util.h"
16 #include "media/base/android/media_drm_bridge.h" 18 #include "media/base/android/media_drm_bridge.h"
17 #include "media/base/android/media_player_manager.h" 19 #include "media/base/android/media_player_manager.h"
18 #include "media/base/android/media_source_player.h"
19 #include "media/base/android/media_url_interceptor.h" 20 #include "media/base/android/media_url_interceptor.h"
20 #include "media/base/android/sdk_media_codec_bridge.h" 21 #include "media/base/android/sdk_media_codec_bridge.h"
21 #include "media/base/android/video_decoder_job.h" 22 #include "media/base/android/video_decoder_job.h"
22 #include "media/base/bind_to_current_loop.h" 23 #include "media/base/bind_to_current_loop.h"
23 #include "media/base/decoder_buffer.h" 24 #include "media/base/decoder_buffer.h"
24 #include "media/base/test_data_util.h" 25 #include "media/base/test_data_util.h"
25 #include "media/base/timestamp_constants.h" 26 #include "media/base/timestamp_constants.h"
26 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
27 #include "ui/gl/android/surface_texture.h" 28 #include "ui/gl/android/surface_texture.h"
28 29
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 if (surface_texture_a_is_next_) { 704 if (surface_texture_a_is_next_) {
704 surface_texture_a_ = gfx::SurfaceTexture::Create(next_texture_id_++); 705 surface_texture_a_ = gfx::SurfaceTexture::Create(next_texture_id_++);
705 surface_texture = surface_texture_a_.get(); 706 surface_texture = surface_texture_a_.get();
706 } else { 707 } else {
707 surface_texture_b_ = gfx::SurfaceTexture::Create(next_texture_id_++); 708 surface_texture_b_ = gfx::SurfaceTexture::Create(next_texture_id_++);
708 surface_texture = surface_texture_b_.get(); 709 surface_texture = surface_texture_b_.get();
709 } 710 }
710 711
711 surface_texture_a_is_next_ = !surface_texture_a_is_next_; 712 surface_texture_a_is_next_ = !surface_texture_a_is_next_;
712 gfx::ScopedJavaSurface surface = gfx::ScopedJavaSurface(surface_texture); 713 gfx::ScopedJavaSurface surface = gfx::ScopedJavaSurface(surface_texture);
713 player_.SetVideoSurface(surface.Pass()); 714 player_.SetVideoSurface(std::move(surface));
714 } 715 }
715 716
716 // Wait for one or both of the jobs to complete decoding. Media codec bridges 717 // Wait for one or both of the jobs to complete decoding. Media codec bridges
717 // are assumed to exist for any stream whose decode completion is awaited. 718 // are assumed to exist for any stream whose decode completion is awaited.
718 void WaitForDecodeDone(bool wait_for_audio, bool wait_for_video) { 719 void WaitForDecodeDone(bool wait_for_audio, bool wait_for_video) {
719 DCHECK(wait_for_audio || wait_for_video); 720 DCHECK(wait_for_audio || wait_for_video);
720 while ((wait_for_audio && GetMediaCodecBridge(true) && 721 while ((wait_for_audio && GetMediaCodecBridge(true) &&
721 GetMediaDecoderJob(true)->HasData() && 722 GetMediaDecoderJob(true)->HasData() &&
722 GetMediaDecoderJob(true)->is_decoding()) || 723 GetMediaDecoderJob(true)->is_decoding()) ||
723 (wait_for_video && GetMediaCodecBridge(false) && 724 (wait_for_video && GetMediaCodecBridge(false) &&
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 911 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
911 912
912 // Test video codec will not be created when surface is invalid. 913 // Test video codec will not be created when surface is invalid.
913 scoped_refptr<gfx::SurfaceTexture> surface_texture( 914 scoped_refptr<gfx::SurfaceTexture> surface_texture(
914 gfx::SurfaceTexture::Create(0)); 915 gfx::SurfaceTexture::Create(0));
915 gfx::ScopedJavaSurface surface(surface_texture.get()); 916 gfx::ScopedJavaSurface surface(surface_texture.get());
916 StartVideoDecoderJob(); 917 StartVideoDecoderJob();
917 918
918 // Release the surface texture. 919 // Release the surface texture.
919 surface_texture = NULL; 920 surface_texture = NULL;
920 player_.SetVideoSurface(surface.Pass()); 921 player_.SetVideoSurface(std::move(surface));
921 922
922 // Player should not seek the demuxer on setting initial surface. 923 // Player should not seek the demuxer on setting initial surface.
923 EXPECT_EQ(0, demuxer_->num_seek_requests()); 924 EXPECT_EQ(0, demuxer_->num_seek_requests());
924 EXPECT_EQ(1, demuxer_->num_data_requests()); 925 EXPECT_EQ(1, demuxer_->num_data_requests());
925 926
926 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); 927 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false));
927 EXPECT_FALSE(GetMediaCodecBridge(false)); 928 EXPECT_FALSE(GetMediaCodecBridge(false));
928 } 929 }
929 930
930 TEST_F(MediaSourcePlayerTest, ReadFromDemuxerAfterSeek) { 931 TEST_F(MediaSourcePlayerTest, ReadFromDemuxerAfterSeek) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 CreateNextTextureAndSetVideoSurface(); 974 CreateNextTextureAndSetVideoSurface();
974 StartVideoDecoderJob(); 975 StartVideoDecoderJob();
975 EXPECT_EQ(0, demuxer_->num_seek_requests()); 976 EXPECT_EQ(0, demuxer_->num_seek_requests());
976 977
977 // Send the first input chunk. 978 // Send the first input chunk.
978 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); 979 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false));
979 980
980 // While the decoder is decoding, change multiple surfaces. Pass an empty 981 // While the decoder is decoding, change multiple surfaces. Pass an empty
981 // surface first. 982 // surface first.
982 gfx::ScopedJavaSurface empty_surface; 983 gfx::ScopedJavaSurface empty_surface;
983 player_.SetVideoSurface(empty_surface.Pass()); 984 player_.SetVideoSurface(std::move(empty_surface));
984 // Next, pass a new non-empty surface. 985 // Next, pass a new non-empty surface.
985 CreateNextTextureAndSetVideoSurface(); 986 CreateNextTextureAndSetVideoSurface();
986 987
987 // Wait for the media codec bridge to finish decoding and be reset pending a 988 // Wait for the media codec bridge to finish decoding and be reset pending a
988 // browser seek. 989 // browser seek.
989 WaitForVideoDecodeDone(); 990 WaitForVideoDecodeDone();
990 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); 991 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false));
991 992
992 // Only one browser seek should have been initiated. No further data request 993 // Only one browser seek should have been initiated. No further data request
993 // should have been processed on |message_loop_| before surface change event 994 // should have been processed on |message_loop_| before surface change event
(...skipping 19 matching lines...) Expand all
1013 // Test player pauses if an empty surface is passed. 1014 // Test player pauses if an empty surface is passed.
1014 CreateNextTextureAndSetVideoSurface(); 1015 CreateNextTextureAndSetVideoSurface();
1015 StartVideoDecoderJob(); 1016 StartVideoDecoderJob();
1016 EXPECT_EQ(1, demuxer_->num_data_requests()); 1017 EXPECT_EQ(1, demuxer_->num_data_requests());
1017 1018
1018 // Send the first input chunk. 1019 // Send the first input chunk.
1019 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); 1020 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false));
1020 1021
1021 // While the decoder is decoding, pass an empty surface. 1022 // While the decoder is decoding, pass an empty surface.
1022 gfx::ScopedJavaSurface empty_surface; 1023 gfx::ScopedJavaSurface empty_surface;
1023 player_.SetVideoSurface(empty_surface.Pass()); 1024 player_.SetVideoSurface(std::move(empty_surface));
1024 // Let the player starve. However, it should not issue any new data request in 1025 // Let the player starve. However, it should not issue any new data request in
1025 // this case. 1026 // this case.
1026 TriggerPlayerStarvation(); 1027 TriggerPlayerStarvation();
1027 // Wait for the media codec bridge to finish decoding and be reset. 1028 // Wait for the media codec bridge to finish decoding and be reset.
1028 while (GetMediaDecoderJob(false)->is_decoding()) 1029 while (GetMediaDecoderJob(false)->is_decoding())
1029 message_loop_.RunUntilIdle(); 1030 message_loop_.RunUntilIdle();
1030 1031
1031 // No further seek or data requests should have been received since the 1032 // No further seek or data requests should have been received since the
1032 // surface is empty. 1033 // surface is empty.
1033 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); 1034 EXPECT_EQ(0, demuxer_->num_browser_seek_requests());
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after
2379 2380
2380 EXPECT_EQ(demuxer_->num_data_requests(), 0); 2381 EXPECT_EQ(demuxer_->num_data_requests(), 0);
2381 player_.OnDemuxerConfigsAvailable(CreateDemuxerConfigs(true, true)); 2382 player_.OnDemuxerConfigsAvailable(CreateDemuxerConfigs(true, true));
2382 2383
2383 manager_.set_allow_play(true); 2384 manager_.set_allow_play(true);
2384 player_.Start(); 2385 player_.Start();
2385 EXPECT_TRUE(player_.IsPlaying()); 2386 EXPECT_TRUE(player_.IsPlaying());
2386 } 2387 }
2387 2388
2388 } // namespace media 2389 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | media/base/android/sdk_media_codec_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698