chromium/media/formats/mp4/track_run_iterator.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "media/formats/mp4/track_run_iterator.h"

#include <algorithm>
#include <iomanip>
#include <limits>
#include <memory>

#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "build/chromecast_buildflags.h"
#include "media/base/decrypt_config.h"
#include "media/base/demuxer.h"
#include "media/base/demuxer_memory_limit.h"
#include "media/base/encryption_pattern.h"
#include "media/base/encryption_scheme.h"
#include "media/base/media_util.h"
#include "media/base/timestamp_constants.h"
#include "media/formats/mp4/rcheck.h"
#include "media/formats/mp4/sample_to_group_iterator.h"
#include "media/media_buildflags.h"

namespace media {
namespace mp4 {

struct SampleInfo {};

struct TrackRunInfo {};

TrackRunInfo::TrackRunInfo()
    :{}
TrackRunInfo::~TrackRunInfo() = default;

base::TimeDelta TimeDeltaFromRational(int64_t numer, int64_t denom) {}

DecodeTimestamp DecodeTimestampFromRational(int64_t numer, int64_t denom) {}

TrackRunIterator::TrackRunIterator(const Movie* moov, MediaLog* media_log)
    :{}

TrackRunIterator::~TrackRunIterator() = default;

static std::string HexFlags(uint32_t flags) {}

static bool PopulateSampleInfo(const TrackExtends& trex,
                               const TrackFragmentHeader& tfhd,
                               const TrackFragmentRun& trun,
                               const int64_t edit_list_offset,
                               const uint32_t i,
                               SampleInfo* sample_info,
                               const SampleDependsOn sdtp_sample_depends_on,
                               bool is_audio,
                               MediaLog* media_log) {}

static const CencSampleEncryptionInfoEntry* GetSampleEncryptionInfoEntry(
    const TrackRunInfo& run_info,
    uint32_t group_description_index) {}

// In well-structured encrypted media, each track run will be immediately
// preceded by its auxiliary information; this is the only optimal storage
// pattern in terms of minimum number of bytes from a serial stream needed to
// begin playback. It also allows us to optimize caching on memory-constrained
// architectures, because we can cache the relatively small auxiliary
// information for an entire run and then discard data from the input stream,
// instead of retaining the entire 'mdat' box.
//
// We optimize for this situation (with no loss of generality) by sorting track
// runs during iteration in order of their first data offset (either sample data
// or auxiliary data).
class CompareMinTrackRunDataOffset {};

bool TrackRunIterator::Init(const MovieFragment& moof) {}

bool TrackRunIterator::UpdateCts() {}

bool TrackRunIterator::AdvanceRun() {}

bool TrackRunIterator::ResetRun() {}

bool TrackRunIterator::AdvanceSample() {}

// This implementation only indicates a need for caching if CENC auxiliary
// info is available in the stream.
bool TrackRunIterator::AuxInfoNeedsToBeCached() {}

// This implementation currently only caches CENC auxiliary info.
bool TrackRunIterator::CacheAuxInfo(const uint8_t* buf, int buf_size) {}

bool TrackRunIterator::IsRunValid() const {}

bool TrackRunIterator::IsSampleValid() const {}

// Because tracks are in sorted order and auxiliary information is cached when
// returning samples, it is guaranteed that no data will be required before the
// lesser of the minimum data offset of this track and the next in sequence.
// (The stronger condition - that no data is required before the minimum data
// offset of this track alone - is not guaranteed, because the BMFF spec does
// not have any inter-run ordering restrictions.)
int64_t TrackRunIterator::GetMaxClearOffset() {}

uint32_t TrackRunIterator::track_id() const {}

bool TrackRunIterator::is_encrypted() const {}

int64_t TrackRunIterator::aux_info_offset() const {}

int TrackRunIterator::aux_info_size() const {}

bool TrackRunIterator::is_audio() const {}

const AudioSampleEntry& TrackRunIterator::audio_description() const {}

const VideoSampleEntry& TrackRunIterator::video_description() const {}

int64_t TrackRunIterator::sample_offset() const {}

uint32_t TrackRunIterator::sample_size() const {}

DecodeTimestamp TrackRunIterator::dts() const {}

base::TimeDelta TrackRunIterator::cts() const {}

base::TimeDelta TrackRunIterator::duration() const {}

bool TrackRunIterator::is_keyframe() const {}

const ProtectionSchemeInfo& TrackRunIterator::protection_scheme_info() const {}

const TrackEncryption& TrackRunIterator::track_encryption() const {}

std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() {}

uint32_t TrackRunIterator::GetGroupDescriptionIndex(
    uint32_t sample_index) const {}

bool TrackRunIterator::IsSampleEncrypted(size_t sample_index) const {}

const std::vector<uint8_t>& TrackRunIterator::GetKeyId(
    size_t sample_index) const {}

uint8_t TrackRunIterator::GetIvSize(size_t sample_index) const {}

bool TrackRunIterator::ApplyConstantIv(size_t sample_index,
                                       SampleEncryptionEntry* entry) const {}

}  // namespace mp4
}  // namespace media