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

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

Issue 2158923004: Convert media constants to constexpr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 // Marks negative timestamp buffers for discard or transfers FFmpeg's built in 103 // Marks negative timestamp buffers for discard or transfers FFmpeg's built in
104 // discard metadata in favor of setting DiscardPadding on the DecoderBuffer. 104 // discard metadata in favor of setting DiscardPadding on the DecoderBuffer.
105 // Allows better testing of AudioDiscardHelper usage. 105 // Allows better testing of AudioDiscardHelper usage.
106 static void SetDiscardPadding(AVPacket* packet, 106 static void SetDiscardPadding(AVPacket* packet,
107 const scoped_refptr<DecoderBuffer> buffer, 107 const scoped_refptr<DecoderBuffer> buffer,
108 double samples_per_second) { 108 double samples_per_second) {
109 // Discard negative timestamps. 109 // Discard negative timestamps.
110 if (buffer->timestamp() + buffer->duration() < base::TimeDelta()) { 110 if (buffer->timestamp() + buffer->duration() < base::TimeDelta()) {
111 buffer->set_discard_padding( 111 buffer->set_discard_padding(
112 std::make_pair(kInfiniteDuration(), base::TimeDelta())); 112 std::make_pair(kInfiniteDuration, base::TimeDelta()));
113 return; 113 return;
114 } 114 }
115 if (buffer->timestamp() < base::TimeDelta()) { 115 if (buffer->timestamp() < base::TimeDelta()) {
116 buffer->set_discard_padding( 116 buffer->set_discard_padding(
117 std::make_pair(-buffer->timestamp(), base::TimeDelta())); 117 std::make_pair(-buffer->timestamp(), base::TimeDelta()));
118 return; 118 return;
119 } 119 }
120 120
121 // If the timestamp is positive, try to use FFmpeg's discard data. 121 // If the timestamp is positive, try to use FFmpeg's discard data.
122 int skip_samples_size = 0; 122 int skip_samples_size = 0;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 TEST_P(AudioDecoderTest, Reset) { 445 TEST_P(AudioDecoderTest, Reset) {
446 SKIP_TEST_IF_NO_MEDIA_CODEC(); 446 SKIP_TEST_IF_NO_MEDIA_CODEC();
447 ASSERT_NO_FATAL_FAILURE(Initialize()); 447 ASSERT_NO_FATAL_FAILURE(Initialize());
448 Reset(); 448 Reset();
449 } 449 }
450 450
451 TEST_P(AudioDecoderTest, NoTimestamp) { 451 TEST_P(AudioDecoderTest, NoTimestamp) {
452 SKIP_TEST_IF_NO_MEDIA_CODEC(); 452 SKIP_TEST_IF_NO_MEDIA_CODEC();
453 ASSERT_NO_FATAL_FAILURE(Initialize()); 453 ASSERT_NO_FATAL_FAILURE(Initialize());
454 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(0)); 454 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(0));
455 buffer->set_timestamp(kNoTimestamp()); 455 buffer->set_timestamp(kNoTimestamp);
456 DecodeBuffer(buffer); 456 DecodeBuffer(buffer);
457 EXPECT_EQ(DecodeStatus::DECODE_ERROR, last_decode_status()); 457 EXPECT_EQ(DecodeStatus::DECODE_ERROR, last_decode_status());
458 } 458 }
459 459
460 TEST_P(OpusAudioDecoderBehavioralTest, InitializeWithNoCodecDelay) { 460 TEST_P(OpusAudioDecoderBehavioralTest, InitializeWithNoCodecDelay) {
461 ASSERT_EQ(GetParam().decoder_type, OPUS); 461 ASSERT_EQ(GetParam().decoder_type, OPUS);
462 std::vector<uint8_t> extra_data( 462 std::vector<uint8_t> extra_data(
463 kOpusExtraData, 463 kOpusExtraData,
464 kOpusExtraData + arraysize(kOpusExtraData)); 464 kOpusExtraData + arraysize(kOpusExtraData));
465 AudioDecoderConfig decoder_config; 465 AudioDecoderConfig decoder_config;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 }; 620 };
621 621
622 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest, 622 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest,
623 AudioDecoderTest, 623 AudioDecoderTest,
624 testing::ValuesIn(kFFmpegTests)); 624 testing::ValuesIn(kFFmpegTests));
625 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest, 625 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest,
626 FFmpegAudioDecoderBehavioralTest, 626 FFmpegAudioDecoderBehavioralTest,
627 testing::ValuesIn(kFFmpegBehavioralTest)); 627 testing::ValuesIn(kFFmpegBehavioralTest));
628 628
629 } // namespace media 629 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698