#include "media/filters/source_buffer_state.h"
#include <set>
#include <string_view>
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/functional/callback_helpers.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/types/cxx23_to_underlying.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "media/base/media_switches.h"
#include "media/base/media_track.h"
#include "media/base/media_tracks.h"
#include "media/base/mime_util.h"
#include "media/base/stream_parser.h"
#include "media/base/video_codec_string_parsers.h"
#include "media/filters/chunk_demuxer.h"
#include "media/filters/frame_processor.h"
#include "media/filters/source_buffer_stream.h"
#include "media/media_buildflags.h"
namespace media {
enum { … };
namespace {
base::TimeDelta EndTimestamp(const StreamParser::BufferQueue& queue) { … }
bool CheckBytestreamTrackIds(const MediaTracks& tracks) { … }
unsigned GetMSEBufferSizeLimitIfExists(std::string_view switch_string) { … }
}
Ranges<base::TimeDelta> SourceBufferState::ComputeRangesIntersection(
const RangesList& active_ranges,
bool ended) { … }
SourceBufferState::SourceBufferState(
std::unique_ptr<StreamParser> stream_parser,
std::unique_ptr<FrameProcessor> frame_processor,
CreateDemuxerStreamCB create_demuxer_stream_cb,
MediaLog* media_log)
: … { … }
SourceBufferState::~SourceBufferState() { … }
void SourceBufferState::Init(StreamParser::InitCB init_cb,
std::optional<std::string_view> expected_codecs,
const StreamParser::EncryptedMediaInitDataCB&
encrypted_media_init_data_cb) { … }
void SourceBufferState::ChangeType(
std::unique_ptr<StreamParser> new_stream_parser,
const std::string& new_expected_codecs) { … }
void SourceBufferState::SetSequenceMode(bool sequence_mode) { … }
void SourceBufferState::SetGroupStartTimestampIfInSequenceMode(
base::TimeDelta timestamp_offset) { … }
void SourceBufferState::SetTracksWatcher(
Demuxer::MediaTracksUpdatedCB tracks_updated_cb) { … }
void SourceBufferState::SetParseWarningCallback(
SourceBufferParseWarningCB parse_warning_cb) { … }
bool SourceBufferState::AppendToParseBuffer(base::span<const uint8_t> data) { … }
StreamParser::ParseStatus SourceBufferState::RunSegmentParserLoop(
base::TimeDelta append_window_start,
base::TimeDelta append_window_end,
base::TimeDelta* timestamp_offset) { … }
bool SourceBufferState::AppendChunks(
std::unique_ptr<StreamParser::BufferQueue> buffer_queue,
base::TimeDelta append_window_start,
base::TimeDelta append_window_end,
base::TimeDelta* timestamp_offset) { … }
void SourceBufferState::ResetParserState(base::TimeDelta append_window_start,
base::TimeDelta append_window_end,
base::TimeDelta* timestamp_offset) { … }
void SourceBufferState::Remove(base::TimeDelta start,
base::TimeDelta end,
base::TimeDelta duration) { … }
bool SourceBufferState::EvictCodedFrames(base::TimeDelta media_time,
size_t newDataSize) { … }
void SourceBufferState::OnMemoryPressure(
base::TimeDelta media_time,
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level,
bool force_instant_gc) { … }
Ranges<base::TimeDelta> SourceBufferState::GetBufferedRanges(
base::TimeDelta duration,
bool ended) const { … }
base::TimeDelta SourceBufferState::GetLowestPresentationTimestamp() const { … }
base::TimeDelta SourceBufferState::GetHighestPresentationTimestamp() const { … }
base::TimeDelta SourceBufferState::GetMaxBufferedDuration() const { … }
void SourceBufferState::StartReturningData() { … }
void SourceBufferState::AbortReads() { … }
void SourceBufferState::Seek(base::TimeDelta seek_time) { … }
void SourceBufferState::CompletePendingReadIfPossible() { … }
void SourceBufferState::OnSetDuration(base::TimeDelta duration) { … }
void SourceBufferState::MarkEndOfStream() { … }
void SourceBufferState::UnmarkEndOfStream() { … }
void SourceBufferState::Shutdown() { … }
void SourceBufferState::SetMemoryLimits(DemuxerStream::Type type,
size_t memory_limit) { … }
bool SourceBufferState::IsSeekWaitingForData() const { … }
void SourceBufferState::InitializeParser(
std::optional<std::string_view> expected_codecs) { … }
bool SourceBufferState::OnNewConfigs(std::unique_ptr<MediaTracks> tracks) { … }
void SourceBufferState::SetStreamMemoryLimits() { … }
void SourceBufferState::OnNewMediaSegment() { … }
void SourceBufferState::OnEndOfMediaSegment() { … }
bool SourceBufferState::OnNewBuffers(
const StreamParser::BufferQueueMap& buffer_queue_map) { … }
void SourceBufferState::OnEncryptedMediaInitData(
EmeInitDataType type,
const std::vector<uint8_t>& init_data) { … }
void SourceBufferState::OnSourceInitDone(
const StreamParser::InitParameters& params) { … }
}