chromium/third_party/blink/renderer/platform/media/multi_buffer_data_source.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// Minimum preload buffer.
const int64_t kMinBufferPreload =;  // 2 Mb
// Maxmimum preload buffer.
const int64_t kMaxBufferPreload =;  // 50 Mb

// If preload_ == METADATA, preloading size will be
// shifted down this many bits. This shift turns
// one Mb into one 32k block.
// This seems to be the smallest amount of preload we can do without
// ending up repeatedly closing and re-opening the connection
// due to read calls after OnBufferingHaveEnough have been called.
const int64_t kMetadataShift =;

// Preload this much extra, then stop preloading until we fall below the
// preload_seconds_.value().
const int64_t kPreloadHighExtra =;  // 1 Mb

// Default pin region size.
// Note that we go over this if preload is calculated high enough.
const int64_t kDefaultPinSize =;  // 25 Mb

// If bitrate is not known, use this.
const int64_t kDefaultBitrate =;  // 200 Kbps.

// Maximum bitrate for buffer calculations.
const int64_t kMaxBitrate =;  // 20 Mbps.

// Maximum playback rate for buffer calculations.
const double kMaxPlaybackRate =;

// Extra buffer accumulation speed, in terms of download buffer.
const int kSlowPreloadPercentage =;

// Update buffer sizes every 32 progress updates.
const int kUpdateBufferSizeFrequency =;

// How long to we delay a seek after a read?
constexpr base::TimeDelta kSeekDelay =;

}  // namespace

class MultiBufferDataSource::ReadOperation {};

MultiBufferDataSource::ReadOperation::ReadOperation(
    int64_t position,
    int size,
    uint8_t* data,
    media::DataSource::ReadCB callback)
    :{}

MultiBufferDataSource::ReadOperation::~ReadOperation() {}

// static
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() {}

/////////////////////////////////////////////////////////////////////////////
// DataSource implementation.
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() {}

/////////////////////////////////////////////////////////////////////////////
// This method is the place where actual read happens,
void MultiBufferDataSource::ReadTask() {}

void MultiBufferDataSource::SeekTask() {}

void MultiBufferDataSource::SeekTask_Locked() {}

void MultiBufferDataSource::StopInternal_Locked() {}

void MultiBufferDataSource::StopLoader() {}

void MultiBufferDataSource::SetBitrateTask(int bitrate) {}

/////////////////////////////////////////////////////////////////////////////
// BufferedResourceLoader callback methods.
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() {}

}  // namespace blink