#ifndef MEDIA_BASE_TEST_HELPERS_H_
#define MEDIA_BASE_TEST_HELPERS_H_
#include <stddef.h>
#include <memory>
#include "base/functional/callback.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "media/base/audio_parameters.h"
#include "media/base/channel_layout.h"
#include "media/base/decoder_status.h"
#include "media/base/demuxer_stream.h"
#include "media/base/media_log.h"
#include "media/base/pipeline_status.h"
#include "media/base/sample_format.h"
#include "media/base/status.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_frame.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/geometry/size.h"
namespace base {
class RunLoop;
class TimeDelta;
}
namespace media {
class AudioBuffer;
class AudioBus;
class DecoderBuffer;
class MockDemuxerStream;
base::OnceClosure NewExpectedClosure();
base::OnceCallback<void(bool)> NewExpectedBoolCB(bool success);
PipelineStatusCallback NewExpectedStatusCB(PipelineStatus status);
class WaitableMessageLoopEvent { … };
class TestVideoConfig { … };
class TestAudioConfig { … };
class TestAudioParameters { … };
template <class T>
scoped_refptr<AudioBuffer> MakeAudioBuffer(SampleFormat format,
ChannelLayout channel_layout,
size_t channel_count,
int sample_rate,
T start,
T increment,
size_t frames,
base::TimeDelta timestamp);
template <>
scoped_refptr<AudioBuffer> MakeAudioBuffer<float>(SampleFormat format,
ChannelLayout channel_layout,
size_t channel_count,
int sample_rate,
float start,
float increment,
size_t frames,
base::TimeDelta timestamp);
scoped_refptr<AudioBuffer> MakeBitstreamAudioBuffer(
SampleFormat format,
ChannelLayout channel_layout,
size_t channel_count,
int sample_rate,
uint8_t start,
uint8_t increment,
size_t frames,
size_t data_size,
base::TimeDelta timestamp);
void VerifyBitstreamAudioBus(AudioBus* bus,
size_t data_size,
uint8_t start,
uint8_t increment);
scoped_refptr<DecoderBuffer> CreateFakeVideoBufferForTest(
const VideoDecoderConfig& config,
base::TimeDelta timestamp,
base::TimeDelta duration);
scoped_refptr<DecoderBuffer> CreateMismatchedBufferForTest();
scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer();
scoped_refptr<DecoderBuffer> CreateClearBuffer();
bool VerifyFakeVideoBufferForTest(const DecoderBuffer& buffer,
const VideoDecoderConfig& config);
std::unique_ptr<::testing::StrictMock<MockDemuxerStream>>
CreateMockDemuxerStream(DemuxerStream::Type type, bool encrypted);
void FillFourColors(VideoFrame& dest_frame,
std::optional<uint32_t> xor_mask = std::nullopt);
std::tuple<uint8_t, uint8_t, uint8_t, uint8_t> RGBToYUV(uint32_t argb);
MATCHER_P(SameStatusCode, status, "") { … }
MATCHER_P(HasStatusCode, status_code, "") { … }
MATCHER(IsOkStatus, "") { … }
MATCHER(IsDecodeErrorStatus, "") { … }
MATCHER_P(DecoderConfigEq, config, "") { … }
MATCHER_P(ReadOneAndHasTimestamp, timestamp_in_ms, "") { … }
MATCHER(ReadOneAndIsEndOfStream, "") { … }
MATCHER(IsEmpty, "") { … }
MATCHER(EosBeforeHaveMetadata, "") { … }
MATCHER_P(SegmentMissingFrames, track_id, "") { … }
MATCHER(MuxedSequenceModeWarning, "") { … }
MATCHER_P2(KeyframeTimeGreaterThanDependant,
keyframe_time_string,
nonkeyframe_time_string,
"") { … }
MATCHER(StreamParsingFailed, "") { … }
MATCHER(ParsedBuffersNotInDTSSequence, "") { … }
MATCHER_P2(CodecUnsupportedInContainer, codec, container, "") { … }
MATCHER_P(FoundStream, stream_type_string, "") { … }
MATCHER_P2(CodecName, stream_type_string, codec_string, "") { … }
MATCHER_P2(FlacAudioSampleRateOverriddenByStreaminfo,
original_rate_string,
streaminfo_rate_string,
"") { … }
MATCHER_P2(InitSegmentMismatchesMimeType, stream_type, codec_name, "") { … }
MATCHER_P(InitSegmentMissesExpectedTrack, missing_codec, "") { … }
MATCHER_P2(UnexpectedTrack, track_type, id, "") { … }
MATCHER_P2(FrameTypeMismatchesTrackType, frame_type, track_type, "") { … }
MATCHER_P2(AudioNonKeyframe, pts_microseconds, dts_microseconds, "") { … }
MATCHER(AudioNonKeyframeOutOfOrder, "") { … }
MATCHER_P2(SkippingSpliceAtOrBefore,
new_microseconds,
existing_microseconds,
"") { … }
MATCHER_P(SkippingSpliceAlreadySpliced, time_microseconds, "") { … }
MATCHER_P2(SkippingSpliceTooLittleOverlap,
pts_microseconds,
overlap_microseconds,
"") { … }
MATCHER(WebMSimpleBlockDurationEstimatedAny, "") { … }
MATCHER_P(WebMSimpleBlockDurationEstimated, estimated_duration_ms, "") { … }
MATCHER(WebMOutOfOrderTimecode, "") { … }
MATCHER(WebMClusterBeforeFirstInfo, "") { … }
MATCHER_P3(TrimmedSpliceOverlap,
splice_time_us,
overlapped_start_us,
trim_duration_us,
"") { … }
MATCHER_P2(NoSpliceForBadMux, overlapped_buffer_count, splice_time_us, "") { … }
MATCHER(ChunkDemuxerCtor, "") { … }
MATCHER_P2(DiscardingEmptyFrame, pts_us, dts_us, "") { … }
MATCHER_P4(TruncatedFrame,
pts_us,
pts_end_us,
start_or_end,
append_window_us,
"") { … }
MATCHER_P2(DroppedFrame, frame_type, pts_us, "") { … }
MATCHER_P3(DroppedFrameCheckAppendWindow,
frame_type,
append_window_start_us,
append_window_end_us,
"") { … }
MATCHER_P3(DroppedAppendWindowUnusedPreroll,
pts_us,
delta_us,
next_pts_us,
"") { … }
MATCHER_P(PtsUnknown, frame_type, "") { … }
MATCHER_P2(FrameDurationUnknown, frame_type, pts_us, "") { … }
MATCHER_P3(FrameTimeOutOfRange, when, pts_or_dts, frame_type, "") { … }
MATCHER(SequenceOffsetUpdateOutOfRange, "") { … }
MATCHER(SequenceOffsetUpdatePreventedByOutOfRangeGroupStartTimestamp, "") { … }
MATCHER(OffsetOutOfRange, "") { … }
MATCHER_P(FrameEndTimestampOutOfRange, frame_type, "") { … }
MATCHER(HlsDemuxerCtor, "") { … }
}
#endif