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

Side by Side Diff: media/filters/source_buffer_stream_unittest.cc

Issue 1490613005: media config: expand is_encrypted to a struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missed a couple comments Created 4 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/source_buffer_stream.h" 5 #include "media/filters/source_buffer_stream.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 void SetTextStream() { 89 void SetTextStream() {
90 video_config_ = TestVideoConfig::Invalid(); 90 video_config_ = TestVideoConfig::Invalid();
91 TextTrackConfig config(kTextSubtitles, "", "", ""); 91 TextTrackConfig config(kTextSubtitles, "", "", "");
92 stream_.reset(new SourceBufferStream(config, media_log_, true)); 92 stream_.reset(new SourceBufferStream(config, media_log_, true));
93 SetStreamInfo(2, 2); 93 SetStreamInfo(2, 2);
94 } 94 }
95 95
96 void SetAudioStream() { 96 void SetAudioStream() {
97 video_config_ = TestVideoConfig::Invalid(); 97 video_config_ = TestVideoConfig::Invalid();
98 audio_config_.Initialize(kCodecVorbis, 98 audio_config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32,
99 kSampleFormatPlanarF32, 99 CHANNEL_LAYOUT_STEREO, 1000, EmptyExtraData(),
100 CHANNEL_LAYOUT_STEREO, 100 Unencrypted(), base::TimeDelta(), 0);
101 1000,
102 EmptyExtraData(),
103 false,
104 base::TimeDelta(),
105 0);
106 stream_.reset(new SourceBufferStream(audio_config_, media_log_, true)); 101 stream_.reset(new SourceBufferStream(audio_config_, media_log_, true));
107 102
108 // Equivalent to 2ms per frame. 103 // Equivalent to 2ms per frame.
109 SetStreamInfo(500, 500); 104 SetStreamInfo(500, 500);
110 } 105 }
111 106
112 void NewCodedFrameGroupAppend(int starting_position, int number_of_buffers) { 107 void NewCodedFrameGroupAppend(int starting_position, int number_of_buffers) {
113 AppendBuffers(starting_position, number_of_buffers, true, 108 AppendBuffers(starting_position, number_of_buffers, true,
114 base::TimeDelta(), true, &kDataA, kDataSize); 109 base::TimeDelta(), true, &kDataA, kDataSize);
115 } 110 }
(...skipping 3530 matching lines...) Expand 10 before | Expand all | Expand 10 after
3646 AppendBuffers("90 110K 150"); 3641 AppendBuffers("90 110K 150");
3647 Seek(0); 3642 Seek(0);
3648 CheckExpectedBuffers("0K 20 40 60 80 90 90 110K 150"); 3643 CheckExpectedBuffers("0K 20 40 60 80 90 90 110K 150");
3649 CheckNoNextBuffer(); 3644 CheckNoNextBuffer();
3650 CheckExpectedRangesByTimestamp("{ [0,190) }"); 3645 CheckExpectedRangesByTimestamp("{ [0,190) }");
3651 } 3646 }
3652 3647
3653 // Test all the valid same timestamp cases for audio. 3648 // Test all the valid same timestamp cases for audio.
3654 TEST_F(SourceBufferStreamTest, SameTimestamp_Audio) { 3649 TEST_F(SourceBufferStreamTest, SameTimestamp_Audio) {
3655 AudioDecoderConfig config(kCodecMP3, kSampleFormatF32, CHANNEL_LAYOUT_STEREO, 3650 AudioDecoderConfig config(kCodecMP3, kSampleFormatF32, CHANNEL_LAYOUT_STEREO,
3656 44100, EmptyExtraData(), false); 3651 44100, EmptyExtraData(), Unencrypted());
3657 stream_.reset(new SourceBufferStream(config, media_log_, true)); 3652 stream_.reset(new SourceBufferStream(config, media_log_, true));
3658 Seek(0); 3653 Seek(0);
3659 NewCodedFrameGroupAppend("0K 0K 30K 30 60 60"); 3654 NewCodedFrameGroupAppend("0K 0K 30K 30 60 60");
3660 CheckExpectedBuffers("0K 0K 30K 30 60 60"); 3655 CheckExpectedBuffers("0K 0K 30K 30 60 60");
3661 } 3656 }
3662 3657
3663 TEST_F(SourceBufferStreamTest, SameTimestamp_Audio_SingleAppend_Warning) { 3658 TEST_F(SourceBufferStreamTest, SameTimestamp_Audio_SingleAppend_Warning) {
3664 EXPECT_MEDIA_LOG(ContainsSameTimestampAt30MillisecondsLog()); 3659 EXPECT_MEDIA_LOG(ContainsSameTimestampAt30MillisecondsLog());
3665 3660
3666 AudioDecoderConfig config(kCodecMP3, kSampleFormatF32, CHANNEL_LAYOUT_STEREO, 3661 AudioDecoderConfig config(kCodecMP3, kSampleFormatF32, CHANNEL_LAYOUT_STEREO,
3667 44100, EmptyExtraData(), false); 3662 44100, EmptyExtraData(), Unencrypted());
3668 stream_.reset(new SourceBufferStream(config, media_log_, true)); 3663 stream_.reset(new SourceBufferStream(config, media_log_, true));
3669 Seek(0); 3664 Seek(0);
3670 3665
3671 // Note, in reality, a non-keyframe audio frame is rare or perhaps not 3666 // Note, in reality, a non-keyframe audio frame is rare or perhaps not
3672 // possible. 3667 // possible.
3673 NewCodedFrameGroupAppend("0K 30 30K 60"); 3668 NewCodedFrameGroupAppend("0K 30 30K 60");
3674 CheckExpectedBuffers("0K 30 30K 60"); 3669 CheckExpectedBuffers("0K 30 30K 60");
3675 } 3670 }
3676 3671
3677 // If seeking past any existing range and the seek is pending 3672 // If seeking past any existing range and the seek is pending
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
4222 CheckNoNextBuffer(); 4217 CheckNoNextBuffer();
4223 } 4218 }
4224 4219
4225 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_ConfigChange) { 4220 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_ConfigChange) {
4226 EXPECT_MEDIA_LOG(ContainsGeneratedSpliceLog(3000, 5000)); 4221 EXPECT_MEDIA_LOG(ContainsGeneratedSpliceLog(3000, 5000));
4227 4222
4228 SetAudioStream(); 4223 SetAudioStream();
4229 4224
4230 AudioDecoderConfig new_config(kCodecVorbis, kSampleFormatPlanarF32, 4225 AudioDecoderConfig new_config(kCodecVorbis, kSampleFormatPlanarF32,
4231 CHANNEL_LAYOUT_MONO, 1000, EmptyExtraData(), 4226 CHANNEL_LAYOUT_MONO, 1000, EmptyExtraData(),
4232 false); 4227 Unencrypted());
4233 ASSERT_NE(new_config.channel_layout(), audio_config_.channel_layout()); 4228 ASSERT_NE(new_config.channel_layout(), audio_config_.channel_layout());
4234 4229
4235 Seek(0); 4230 Seek(0);
4236 CheckAudioConfig(audio_config_); 4231 CheckAudioConfig(audio_config_);
4237 NewCodedFrameGroupAppend("0K 2K 4K 6K"); 4232 NewCodedFrameGroupAppend("0K 2K 4K 6K");
4238 stream_->UpdateAudioConfig(new_config); 4233 stream_->UpdateAudioConfig(new_config);
4239 NewCodedFrameGroupAppend("5K 8K 12K"); 4234 NewCodedFrameGroupAppend("5K 8K 12K");
4240 CheckExpectedBuffers("0K 2K 4K 6K C 5K 8K 12K"); 4235 CheckExpectedBuffers("0K 2K 4K 6K C 5K 8K 12K");
4241 CheckAudioConfig(new_config); 4236 CheckAudioConfig(new_config);
4242 CheckNoNextBuffer(); 4237 CheckNoNextBuffer();
(...skipping 20 matching lines...) Expand all
4263 CheckNoNextBuffer(); 4258 CheckNoNextBuffer();
4264 } 4259 }
4265 4260
4266 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoMillisecondSplices) { 4261 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoMillisecondSplices) {
4267 EXPECT_MEDIA_LOG( 4262 EXPECT_MEDIA_LOG(
4268 HasSubstr("Skipping splice frame generation: not enough samples for " 4263 HasSubstr("Skipping splice frame generation: not enough samples for "
4269 "splicing new buffer at 1250us. Have 750us, but need 1000us.")); 4264 "splicing new buffer at 1250us. Have 750us, but need 1000us."));
4270 4265
4271 video_config_ = TestVideoConfig::Invalid(); 4266 video_config_ = TestVideoConfig::Invalid();
4272 audio_config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32, 4267 audio_config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32,
4273 CHANNEL_LAYOUT_STEREO, 4000, EmptyExtraData(), false, 4268 CHANNEL_LAYOUT_STEREO, 4000, EmptyExtraData(),
4274 base::TimeDelta(), 0); 4269 Unencrypted(), base::TimeDelta(), 0);
4275 stream_.reset(new SourceBufferStream(audio_config_, media_log_, true)); 4270 stream_.reset(new SourceBufferStream(audio_config_, media_log_, true));
4276 // Equivalent to 0.5ms per frame. 4271 // Equivalent to 0.5ms per frame.
4277 SetStreamInfo(2000, 2000); 4272 SetStreamInfo(2000, 2000);
4278 Seek(0); 4273 Seek(0);
4279 4274
4280 // Append four buffers with a 0.5ms duration each. 4275 // Append four buffers with a 0.5ms duration each.
4281 NewCodedFrameGroupAppend(0, 4); 4276 NewCodedFrameGroupAppend(0, 4);
4282 CheckExpectedRangesByTimestamp("{ [0,2) }"); 4277 CheckExpectedRangesByTimestamp("{ [0,2) }");
4283 4278
4284 // Overlap the range [0, 2) with [1.25, 2); this results in an overlap of 4279 // Overlap the range [0, 2) with [1.25, 2); this results in an overlap of
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
4763 CheckNoNextBuffer(); 4758 CheckNoNextBuffer();
4764 } 4759 }
4765 4760
4766 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. 4761 // TODO(vrk): Add unit tests where keyframes are unaligned between streams.
4767 // (crbug.com/133557) 4762 // (crbug.com/133557)
4768 4763
4769 // TODO(vrk): Add unit tests with end of stream being called at interesting 4764 // TODO(vrk): Add unit tests with end of stream being called at interesting
4770 // times. 4765 // times.
4771 4766
4772 } // namespace media 4767 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698