chromium/media/formats/mp4/writable_box_definitions.h

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

#ifndef MEDIA_FORMATS_MP4_WRITABLE_BOX_DEFINITIONS_H_
#define MEDIA_FORMATS_MP4_WRITABLE_BOX_DEFINITIONS_H_

#include <optional>
#include <string>
#include <vector>

#include "base/containers/span.h"
#include "base/time/time.h"
#include "media/base/audio_codecs.h"
#include "media/base/media_export.h"
#include "media/base/video_codecs.h"
#include "media/formats/mp4/box_definitions.h"
#include "media/formats/mp4/fourccs.h"
#include "media/media_buildflags.h"
#include "ui/gfx/geometry/size.h"

namespace media::mp4::writable_boxes {

enum class TrackHeaderFlags : uint16_t {};

enum class TrackFragmentHeaderFlags : uint32_t {};

enum class TrackFragmentRunFlags : uint16_t {};

enum class FragmentSampleFlags : uint32_t {};

// Box header without version.
struct MEDIA_EXPORT Box {};

// Box header with version and flags.
struct MEDIA_EXPORT FullBox : Box {};

// Pixel Aspect Ratio Box (`pasp`) box.
struct MEDIA_EXPORT PixelAspectRatioBox : Box {};

// Bit Rate Box (`btrt`) box.
struct MEDIA_EXPORT BitRate : Box {};

#if BUILDFLAG(USE_PROPRIETARY_CODECS)
// Elementary Stream Descriptor (`esds`) box.
struct MEDIA_EXPORT ElementaryStreamDescriptor : FullBox {
  ElementaryStreamDescriptor();
  ~ElementaryStreamDescriptor();
  ElementaryStreamDescriptor(const ElementaryStreamDescriptor&);
  ElementaryStreamDescriptor& operator=(const ElementaryStreamDescriptor&);

  // ES descriptor 14496-1
  // DecoderConfigDescriptor (14496-1).
  // AAC AudioSpecificConfig (14496-3).
  std::vector<uint8_t> aac_codec_description;
};

// AVC DecoderConfiguration Record (`avcC`) box.
struct MEDIA_EXPORT AVCDecoderConfiguration : Box {
  // Refer AVCDecoderConfigurationRecord of box_definitions.h
  // because it provides Serialize method and the format
  // is hard to be correct.
  AVCDecoderConfigurationRecord avc_config_record;
};
#endif  // BUILDFLAG(USE_PROPRIETARY_CODECS)

// VP9 DecoderConfiguration Record (`vpcC`) box.
struct MEDIA_EXPORT VPCodecConfiguration : FullBox {};

// AV1 DecoderConfiguration Record (`av1C`) box.
struct MEDIA_EXPORT AV1CodecConfiguration : FullBox {};

// VisualSampleEntry (`avc1`, 'vp09', 'av01') box.
struct MEDIA_EXPORT VisualSampleEntry : Box {};

// Opus media data ('dOps') box.
// Spec is https://opus-codec.org/docs/opus_in_isobmff.html.
struct MEDIA_EXPORT OpusSpecificBox : Box {};

// Audio Sample Entry (`mp4a` or 'Opus') box.
struct MEDIA_EXPORT AudioSampleEntry : Box {};

// Media sample table (`stsd`) box.
struct MEDIA_EXPORT SampleDescription : FullBox {};

// `stco`, `stsz`, `stts`, `stsc`' are mandatory boxes.
// They have 0 child entries in the fragment MP4.

// Media sample table (`stco`) box.
struct MEDIA_EXPORT SampleChunkOffset : FullBox {};

// Media sample table (`stsz`) box.
struct MEDIA_EXPORT SampleSize : FullBox {};

// Decoding Time to Sample (`stts`) box.
struct MEDIA_EXPORT DecodingTimeToSample : FullBox {};

// Media sample table (`stsc`) box.
struct MEDIA_EXPORT SampleToChunk : FullBox {};

// Media sample table (`stbl`) box.
struct MEDIA_EXPORT SampleTable : Box {};

// Data Url Entry (`url`) box.
struct MEDIA_EXPORT DataUrlEntry : FullBox {};

// Data Reference (`dref`) box.
struct MEDIA_EXPORT DataReference : FullBox {};

// Data Information (`dinf`) box.
struct MEDIA_EXPORT DataInformation : Box {};

// Sound Media Information Header (`smdh`) box.
struct MEDIA_EXPORT SoundMediaHeader : FullBox {};

// Video Media Information Header (`vmhd`) box.
struct MEDIA_EXPORT VideoMediaHeader : FullBox {};

// Media information (`minf`) box.
struct MEDIA_EXPORT MediaInformation : Box {};

// Media Handler (`hdlr`) box.
struct MEDIA_EXPORT MediaHandler : FullBox {};

// Media header (`mdhd`) box.
struct MEDIA_EXPORT MediaHeader : FullBox {};

// Media (`mdia`) box.
struct MEDIA_EXPORT Media : Box {};

// Track header (`tkhd`) box.
struct MEDIA_EXPORT TrackHeader : FullBox {};

// Track (`trak`) box.
struct MEDIA_EXPORT Track : Box {};

// Track Extends (`trex`) box.
struct MEDIA_EXPORT TrackExtends : FullBox {};

// Movie Extends (`mvex`) box.
struct MEDIA_EXPORT MovieExtends : Box {};

// Movie Header (`mvhd`) box.
struct MEDIA_EXPORT MovieHeader : FullBox {};

// Movie (`moov`) box.
struct MEDIA_EXPORT Movie : Box {};

// Track Fragment Run (`trun`) box.
struct MEDIA_EXPORT TrackFragmentRun : FullBox {};

// Track Fragment Decode Time (`tfdt`) box.
struct MEDIA_EXPORT TrackFragmentDecodeTime : Box {};

// Track Fragment Header(`tfhd`) box.
struct MEDIA_EXPORT TrackFragmentHeader : FullBox {};

// Track Fragment Header(`traf`) box.
struct MEDIA_EXPORT TrackFragment : Box {};

// Movie Fragment Header(`mfhd`) box.
struct MEDIA_EXPORT MovieFragmentHeader : FullBox {};

// Movie Fragment (`moof`) box.
struct MEDIA_EXPORT MovieFragment : Box {};

// Media Data (`mdat`) box.
struct MEDIA_EXPORT MediaData : Box {};

// File Type (`ftyp`) box.
struct MEDIA_EXPORT FileType : Box {};

// Movie Track Fragment Random Access Box Entry.
struct TrackFragmentRandomAccessEntry {};

// Movie Track Fragment Random Access Box (`tfra`) box.
struct MEDIA_EXPORT TrackFragmentRandomAccess : FullBox {};

// Movie Fragment Random Access Offset Box (`mfro`) box.
struct MEDIA_EXPORT FragmentRandomAccessOffset : Box {};

// Movie Fragment Random Access Box (`mfra`) box.
struct MEDIA_EXPORT FragmentRandomAccess : Box {};

}  // namespace media::mp4::writable_boxes

#endif  // MEDIA_FORMATS_MP4_WRITABLE_BOX_DEFINITIONS_H_