#include "media/filters/source_buffer_stream.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "media/base/data_buffer.h"
#include "media/base/decoder_buffer.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
#include "media/base/media_util.h"
#include "media/base/mock_media_log.h"
#include "media/base/test_helpers.h"
#include "media/base/timestamp_constants.h"
#include "media/base/webvtt_util.h"
#include "media/filters/source_buffer_range.h"
#include "testing/gtest/include/gtest/gtest.h"
HasSubstr;
InSequence;
StrictMock;
namespace {
enum class TimeGranularity { … };
}
namespace media {
BufferQueue;
static const int kDefaultFramesPerSecond = …;
static const int kDefaultKeyframesPerSecond = …;
static const uint8_t kDataA = …;
static const uint8_t kDataB = …;
static const size_t kDataSize = …;
MATCHER_P(ContainsTrackBufferExhaustionSkipLog, skip_milliseconds, "") { … }
#define EXPECT_STATUS_FOR_STREAM_OP(status_suffix, operation) …
class SourceBufferStreamTest : public testing::Test { … };
TEST_F(SourceBufferStreamTest, Append_SingleRange) { … }
TEST_F(SourceBufferStreamTest, Append_SingleRange_OneBufferAtATime) { … }
TEST_F(SourceBufferStreamTest, Append_DisjointRanges) { … }
TEST_F(SourceBufferStreamTest, Append_AdjacentRanges) { … }
TEST_F(SourceBufferStreamTest, Complete_Overlap) { … }
TEST_F(SourceBufferStreamTest,
Complete_Overlap_AfterGroupTimestampAndBeforeFirstBufferTimestamp) { … }
TEST_F(SourceBufferStreamTest, Complete_Overlap_EdgeCase) { … }
TEST_F(SourceBufferStreamTest, Start_Overlap) { … }
TEST_F(SourceBufferStreamTest, End_Overlap) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Several) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_SingleBuffer) { … }
TEST_F(SourceBufferStreamTest, Complete_Overlap_Several) { … }
TEST_F(SourceBufferStreamTest, Complete_Overlap_Several_Then_Merge) { … }
TEST_F(SourceBufferStreamTest, Complete_Overlap_Selected) { … }
TEST_F(SourceBufferStreamTest, Complete_Overlap_Selected_TrackBuffer) { … }
TEST_F(SourceBufferStreamTest, Complete_Overlap_Selected_EdgeCase) { … }
TEST_F(SourceBufferStreamTest, Complete_Overlap_Selected_Multiple) { … }
TEST_F(SourceBufferStreamTest, Start_Overlap_Selected) { … }
TEST_F(SourceBufferStreamTest, Start_Overlap_Selected_TrackBuffer) { … }
TEST_F(SourceBufferStreamTest, Start_Overlap_Selected_EdgeCase) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Selected) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Selected_AfterEndOfNew_1) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Selected_AfterEndOfNew_2) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Selected_AfterEndOfNew_3) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Selected_OverlappedByNew_1) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Selected_OverlappedByNew_2) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Selected_OverlappedByNew_3) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Selected_NoKeyframeAfterNew) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Selected_NoKeyframeAfterNew2) { … }
TEST_F(SourceBufferStreamTest, End_Overlap_Selected_NoKeyframeAfterNew3) { … }
TEST_F(SourceBufferStreamTest, Middle_Overlap_Selected_1) { … }
TEST_F(SourceBufferStreamTest, Middle_Overlap_Selected_2) { … }
TEST_F(SourceBufferStreamTest, Middle_Overlap_Selected_3) { … }
TEST_F(SourceBufferStreamTest, Middle_Overlap_Selected_4) { … }
TEST_F(SourceBufferStreamTest, Overlap_OneByOne) { … }
TEST_F(SourceBufferStreamTest, Overlap_OneByOne_DeleteGroup) { … }
TEST_F(SourceBufferStreamTest, Overlap_OneByOne_BetweenCodedFrameGroups) { … }
TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer) { … }
TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer2) { … }
TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer3) { … }
TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer4) { … }
TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer5) { … }
TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer6) { … }
TEST_F(SourceBufferStreamTest,
Overlap_That_Prunes_All_of_Previous_TrackBuffer) { … }
TEST_F(SourceBufferStreamTest, Seek_Keyframe) { … }
TEST_F(SourceBufferStreamTest, Seek_NonKeyframe) { … }
TEST_F(SourceBufferStreamTest, Seek_NotBuffered) { … }
TEST_F(SourceBufferStreamTest, Seek_InBetweenTimestamps) { … }
TEST_F(SourceBufferStreamTest, Seek_After_TrackBuffer_Filled) { … }
TEST_F(SourceBufferStreamTest, Seek_StartOfGroup) { … }
TEST_F(SourceBufferStreamTest, Seek_BeforeStartOfGroup) { … }
TEST_F(SourceBufferStreamTest, OldSeekPoint_CompleteOverlap) { … }
TEST_F(SourceBufferStreamTest, OldSeekPoint_CompleteOverlap_Pending) { … }
TEST_F(SourceBufferStreamTest, OldSeekPoint_MiddleOverlap) { … }
TEST_F(SourceBufferStreamTest, OldSeekPoint_MiddleOverlap_Pending) { … }
TEST_F(SourceBufferStreamTest, OldSeekPoint_StartOverlap) { … }
TEST_F(SourceBufferStreamTest, OldSeekPoint_StartOverlap_Pending) { … }
TEST_F(SourceBufferStreamTest, OldSeekPoint_EndOverlap) { … }
TEST_F(SourceBufferStreamTest, OldSeekPoint_EndOverlap_Pending) { … }
TEST_F(SourceBufferStreamTest, GetNextBuffer_AfterMerges) { … }
TEST_F(SourceBufferStreamTest, GetNextBuffer_ExhaustThenAppend) { … }
TEST_F(SourceBufferStreamTest, GetNextBuffer_ExhaustThenStartOverlap) { … }
TEST_F(SourceBufferStreamTest, GetNextBuffer_ExhaustThenStartOverlap2) { … }
TEST_F(SourceBufferStreamTest, GetNextBuffer_ExhaustThenCompleteOverlap) { … }
TEST_F(SourceBufferStreamTest, GetNextBuffer_ExhaustThenEndOverlap) { … }
TEST_F(SourceBufferStreamTest, GetNextBuffer_Overlap_Selected_Complete) { … }
TEST_F(SourceBufferStreamTest, PresentationTimestampIndependence) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_DeleteFront) { … }
TEST_F(SourceBufferStreamTest,
GarbageCollection_DeleteFront_PreserveSeekedGOP) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_DeleteFrontGOPsAtATime) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_DeleteBack) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_DeleteFrontAndBack) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_DeleteSeveralRanges) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_DeleteAfterLastAppend) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_DeleteAfterLastAppendMerged) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_NoSeek) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_PendingSeek) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_NeedsMoreData) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_TrackBuffer) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_SaveDataAtPlaybackPosition) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Middle) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Selected1) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Selected2) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Selected3) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_Performance) { … }
TEST_F(SourceBufferStreamTest, GarbageCollection_MediaTimeAfterLastAppendTime) { … }
TEST_F(SourceBufferStreamTest,
GarbageCollection_MediaTimeOutsideOfStreamBufferedRange) { … }
TEST_F(SourceBufferStreamTest, GetRemovalRange_BytesToFree) { … }
TEST_F(SourceBufferStreamTest, GetRemovalRange_Range) { … }
TEST_F(SourceBufferStreamTest, IsNextBufferConfigChanged) { … }
TEST_F(SourceBufferStreamTest, ConfigChange_Basic) { … }
TEST_F(SourceBufferStreamTest, ConfigChange_Seek) { … }
TEST_F(SourceBufferStreamTest, SetExplicitDuration) { … }
TEST_F(SourceBufferStreamTest, SetExplicitDuration_EdgeCase) { … }
TEST_F(SourceBufferStreamTest, SetExplicitDuration_EdgeCase2) { … }
TEST_F(SourceBufferStreamTest, RemoveWithinFudgeRoom) { … }
TEST_F(SourceBufferStreamTest, SetExplicitDuration_DeletePartialRange) { … }
TEST_F(SourceBufferStreamTest, SetExplicitDuration_DeleteSelectedRange) { … }
TEST_F(SourceBufferStreamTest, SetExplicitDuration_DeletePartialSelectedRange) { … }
TEST_F(SourceBufferStreamTest, SetExplicitDuration_UpdateSelectedRange) { … }
TEST_F(SourceBufferStreamTest,
SetExplicitDuration_AfterGroupTimestampAndBeforeFirstBufferTimestamp) { … }
TEST_F(SourceBufferStreamTest, SetExplicitDuration_MarkEOS) { … }
TEST_F(SourceBufferStreamTest, SetExplicitDuration_MarkEOS_IsSeekPending) { … }
TEST_F(SourceBufferStreamTest, OverlapWhileWaitingForMoreData) { … }
TEST_F(SourceBufferStreamTest, AfterRemove_SingleFrameRange_Unblocks_Read) { … }
TEST_F(SourceBufferStreamTest, AfterRemove_TinyFrames_Unblock_Read_1) { … }
TEST_F(SourceBufferStreamTest, AfterRemove_TinyFrames_Unblock_Read_2) { … }
TEST_F(SourceBufferStreamTest, AfterRemove_BeyondFudge_Stalled) { … }
TEST_F(SourceBufferStreamTest, SameTimestamp_Video_SingleAppend) { … }
TEST_F(SourceBufferStreamTest, SameTimestamp_Video_SingleAppend2) { … }
TEST_F(SourceBufferStreamTest, SameTimestamp_Video_TwoAppends) { … }
TEST_F(SourceBufferStreamTest, SameTimestamp_Video_TwoAppends2) { … }
TEST_F(SourceBufferStreamTest, SameTimestamp_VideoKeyFrame_TwoAppends) { … }
TEST_F(SourceBufferStreamTest, SameTimestamp_VideoKeyFrame_SingleAppend) { … }
TEST_F(SourceBufferStreamTest, SameTimestamp_Video_Overlap_1) { … }
TEST_F(SourceBufferStreamTest, SameTimestamp_Video_Overlap_2) { … }
TEST_F(SourceBufferStreamTest, SameTimestamp_Video_Overlap_3) { … }
TEST_F(SourceBufferStreamTest, SameTimestamp_Audio) { … }
TEST_F(SourceBufferStreamTest, EndSelected_During_PendingSeek) { … }
TEST_F(SourceBufferStreamTest, EndNotSelected_During_PendingSeek) { … }
TEST_F(SourceBufferStreamTest, Remove_WholeRange1) { … }
TEST_F(SourceBufferStreamTest, Remove_WholeRange2) { … }
TEST_F(SourceBufferStreamTest, Remove_WholeRange3) { … }
TEST_F(SourceBufferStreamTest, Remove_WholeRange4) { … }
TEST_F(SourceBufferStreamTest, Remove_WholeRange5) { … }
TEST_F(SourceBufferStreamTest, Remove_ZeroToInfinity) { … }
TEST_F(SourceBufferStreamTest, Remove_Partial1) { … }
TEST_F(SourceBufferStreamTest, Remove_Partial2) { … }
TEST_F(SourceBufferStreamTest, Remove_Partial3) { … }
TEST_F(SourceBufferStreamTest, Remove_Partial4) { … }
TEST_F(SourceBufferStreamTest, Remove_CurrentPosition) { … }
TEST_F(SourceBufferStreamTest, Remove_BeforeCurrentPosition) { … }
TEST_F(SourceBufferStreamTest, Remove_MidGroup) { … }
TEST_F(SourceBufferStreamTest, Remove_GOPBeingAppended) { … }
TEST_F(SourceBufferStreamTest, Remove_WholeGOPBeingAppended) { … }
TEST_F(SourceBufferStreamTest,
Remove_PreviousAppendDestroyedAndOverwriteExistingRange) { … }
TEST_F(SourceBufferStreamTest, Remove_GapAtBeginningOfGroup) { … }
TEST_F(SourceBufferStreamTest,
OverlappingAppendRangeMembership_OneMicrosecond_Video) { … }
TEST_F(SourceBufferStreamTest,
OverlappingAppendRangeMembership_TwoMicroseconds_Video) { … }
TEST_F(SourceBufferStreamTest, Audio_SpliceTrimmingForOverlap) { … }
TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoSplice) { … }
TEST_F(SourceBufferStreamTest, Audio_NoSpliceForBadOverlap) { … }
TEST_F(SourceBufferStreamTest, Audio_NoSpliceForEstimatedDuration) { … }
TEST_F(SourceBufferStreamTest, Audio_SpliceTrimming_ExistingTrimming) { … }
TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoMillisecondSplices) { … }
TEST_F(SourceBufferStreamTest, Audio_PrerollFrame) { … }
TEST_F(SourceBufferStreamTest, Audio_ConfigChangeWithPreroll) { … }
TEST_F(SourceBufferStreamTest, Audio_Opus_SeekToJustBeforeRangeStart) { … }
TEST_F(SourceBufferStreamTest, BFrames) { … }
TEST_F(SourceBufferStreamTest, RemoveShouldAlwaysExcludeEnd) { … }
TEST_F(SourceBufferStreamTest, RefinedDurationEstimates_BackOverlap) { … }
TEST_F(SourceBufferStreamTest, RefinedDurationEstimates_FrontOverlap) { … }
TEST_F(SourceBufferStreamTest, SeekToStartSatisfiedUpToThreshold) { … }
TEST_F(SourceBufferStreamTest, SeekToStartUnsatisfiedBeyondThreshold) { … }
TEST_F(SourceBufferStreamTest,
ReSeekToStartSatisfiedUpToThreshold_SameTimestamps) { … }
TEST_F(SourceBufferStreamTest,
ReSeekToStartSatisfiedUpToThreshold_EarlierTimestamps) { … }
TEST_F(SourceBufferStreamTest,
ReSeekToStartSatisfiedUpToThreshold_LaterTimestamps) { … }
TEST_F(SourceBufferStreamTest, ReSeekBeyondStartThreshold_SameTimestamps) { … }
TEST_F(SourceBufferStreamTest, ReSeekBeyondThreshold_EarlierTimestamps) { … }
TEST_F(SourceBufferStreamTest, ConfigChange_ReSeek) { … }
TEST_F(SourceBufferStreamTest, TrackBuffer_ExhaustionWithSkipForward) { … }
TEST_F(SourceBufferStreamTest,
TrackBuffer_ExhaustionAndImmediateNewTrackBuffer) { … }
TEST_F(
SourceBufferStreamTest,
AdjacentCodedFrameGroupContinuation_NoGapCreatedByTinyGapInGroupContinuation) { … }
TEST_F(SourceBufferStreamTest,
AdjacentCodedFrameGroupContinuation_NoGapCreatedPrefixRemoved) { … }
TEST_F(SourceBufferStreamTest,
AdjacentNewCodedFrameGroupContinuation_NoGapCreatedPrefixRemoved) { … }
TEST_F(SourceBufferStreamTest,
StartCodedFrameGroup_RemoveThenAppendMoreMuchLater) { … }
TEST_F(SourceBufferStreamTest,
StartCodedFrameGroup_InExisting_AppendMuchLater) { … }
TEST_F(SourceBufferStreamTest,
StartCodedFrameGroup_InExisting_RemoveGOP_ThenAppend_1) { … }
TEST_F(SourceBufferStreamTest,
StartCodedFrameGroup_InExisting_RemoveGOP_ThenAppend_2) { … }
TEST_F(SourceBufferStreamTest,
StartCodedFrameGroup_InExisting_RemoveMostRecentAppend_ThenAppend_1) { … }
TEST_F(SourceBufferStreamTest,
StartCodedFrameGroup_InExisting_RemoveMostRecentAppend_ThenAppend_2) { … }
TEST_F(SourceBufferStreamTest, GetLowestPresentationTimestamp_NonMuxed) { … }
TEST_F(SourceBufferStreamTest, GetLowestPresentationTimestamp_Muxed) { … }
TEST_F(SourceBufferStreamTest, GetHighestPresentationTimestamp) { … }
TEST_F(SourceBufferStreamTest, GarbageCollectionUnderMemoryPressure) { … }
TEST_F(SourceBufferStreamTest, InstantGarbageCollectionUnderMemoryPressure) { … }
TEST_F(SourceBufferStreamTest, GCFromFrontThenExplicitRemoveFromMiddleToEnd) { … }
TEST_F(SourceBufferStreamTest, BFrames_WithoutEditList) { … }
TEST_F(SourceBufferStreamTest, OverlapSameTimestampWithinSameGOP) { … }
struct VideoEndTimeCase { … };
TEST_F(SourceBufferStreamTest, VideoRangeEndTimeCases) { … }
struct AudioEndTimeCase { … };
TEST_F(SourceBufferStreamTest, AudioRangeEndTimeCases) { … }
TEST_F(SourceBufferStreamTest, SameTimestampEstimatedDurations_Video) { … }
TEST_F(SourceBufferStreamTest, RangeIsNextInPTS_Simple) { … }
TEST_F(SourceBufferStreamTest, RangeIsNextInPTS_OutOfOrder) { … }
TEST_F(SourceBufferStreamTest, RangeCoalescenceOnFudgeRoomIncrease_1) { … }
TEST_F(SourceBufferStreamTest, RangeCoalescenceOnFudgeRoomIncrease_2) { … }
TEST_F(SourceBufferStreamTest, NoRangeGapWhenIncrementallyOverlapped) { … }
TEST_F(SourceBufferStreamTest, AllowIncrementalAppendsToCoalesceRangeGap) { … }
TEST_F(SourceBufferStreamTest, PreciselyOverlapLastAudioFrameAppended_1) { … }
TEST_F(SourceBufferStreamTest, PreciselyOverlapLastAudioFrameAppended_2) { … }
TEST_F(SourceBufferStreamTest, ZeroDurationBuffersThenIncreasingFudgeRoom) { … }
TEST_F(SourceBufferStreamTest, NonZeroDurationBuffersThenIncreasingFudgeRoom) { … }
TEST_F(SourceBufferStreamTest, SapType2WithNonkeyframePtsInEarlierRange) { … }
TEST_F(SourceBufferStreamTest,
MergeAllowedIfRangeEndTimeWithEstimatedDurationMatchesNextRangeStart) { … }
}