#include "third_party/blink/renderer/platform/media/multi_buffer_data_source.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "base/containers/adapters.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "media/base/media_log.h"
#include "net/base/net_errors.h"
#include "third_party/blink/renderer/platform/media/buffered_data_source_host_impl.h"
#include "third_party/blink/renderer/platform/media/multi_buffer_reader.h"
#include "url/gurl.h"
namespace blink {
namespace {
const int64_t kMinBufferPreload = …;
const int64_t kMaxBufferPreload = …;
const int64_t kMetadataShift = …;
const int64_t kPreloadHighExtra = …;
const int64_t kDefaultPinSize = …;
const int64_t kDefaultBitrate = …;
const int64_t kMaxBitrate = …;
const double kMaxPlaybackRate = …;
const int kSlowPreloadPercentage = …;
const int kUpdateBufferSizeFrequency = …;
constexpr base::TimeDelta kSeekDelay = …;
}
class MultiBufferDataSource::ReadOperation { … };
MultiBufferDataSource::ReadOperation::ReadOperation(
int64_t position,
int size,
uint8_t* data,
media::DataSource::ReadCB callback)
: … { … }
MultiBufferDataSource::ReadOperation::~ReadOperation() { … }
void MultiBufferDataSource::ReadOperation::Run(
std::unique_ptr<ReadOperation> read_op,
int result) { … }
MultiBufferDataSource::MultiBufferDataSource(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
scoped_refptr<UrlData> url_data_arg,
media::MediaLog* media_log,
BufferedDataSourceHost* host,
DownloadingCB downloading_cb)
: … { … }
MultiBufferDataSource::~MultiBufferDataSource() { … }
bool MultiBufferDataSource::media_has_played() const { … }
bool MultiBufferDataSource::AssumeFullyBuffered() const { … }
void MultiBufferDataSource::SetReader(
std::unique_ptr<MultiBufferReader> reader) { … }
void MultiBufferDataSource::CreateResourceLoader(int64_t first_byte_position,
int64_t last_byte_position) { … }
void MultiBufferDataSource::CreateResourceLoader_Locked(
int64_t first_byte_position,
int64_t last_byte_position) { … }
void MultiBufferDataSource::Initialize(InitializeCB init_cb) { … }
void MultiBufferDataSource::OnRedirected(
const scoped_refptr<UrlData>& new_destination) { … }
void MultiBufferDataSource::SetPreload(media::DataSource::Preload preload) { … }
bool MultiBufferDataSource::HasSingleOrigin() { … }
bool MultiBufferDataSource::IsCorsCrossOrigin() const { … }
void MultiBufferDataSource::OnRedirect(RedirectCB callback) { … }
bool MultiBufferDataSource::HasAccessControl() const { … }
bool MultiBufferDataSource::PassedTimingAllowOriginCheck() { … }
bool MultiBufferDataSource::WouldTaintOrigin() { … }
UrlData::CorsMode MultiBufferDataSource::cors_mode() const { … }
void MultiBufferDataSource::OnMediaPlaybackRateChanged(double playback_rate) { … }
void MultiBufferDataSource::OnMediaIsPlaying() { … }
void MultiBufferDataSource::Stop() { … }
void MultiBufferDataSource::Abort() { … }
void MultiBufferDataSource::SetBitrate(int bitrate) { … }
void MultiBufferDataSource::OnBufferingHaveEnough(bool always_cancel) { … }
int64_t MultiBufferDataSource::GetMemoryUsage() { … }
GURL MultiBufferDataSource::GetUrlAfterRedirects() const { … }
void MultiBufferDataSource::Read(int64_t position,
int size,
uint8_t* data,
media::DataSource::ReadCB read_cb) { … }
bool MultiBufferDataSource::GetSize(int64_t* size_out) { … }
bool MultiBufferDataSource::IsStreaming() { … }
void MultiBufferDataSource::ReadTask() { … }
void MultiBufferDataSource::SeekTask() { … }
void MultiBufferDataSource::SeekTask_Locked() { … }
void MultiBufferDataSource::StopInternal_Locked() { … }
void MultiBufferDataSource::StopLoader() { … }
void MultiBufferDataSource::SetBitrateTask(int bitrate) { … }
void MultiBufferDataSource::StartCallback() { … }
void MultiBufferDataSource::ProgressCallback(int64_t begin, int64_t end) { … }
void MultiBufferDataSource::UpdateLoadingState_Locked(bool force_loading) { … }
void MultiBufferDataSource::UpdateProgress() { … }
void MultiBufferDataSource::UpdateBufferSizes() { … }
}