chromium/media/formats/mp4/box_definitions.h

// 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.

#ifndef MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_
#define MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_

#include <stddef.h>
#include <stdint.h>

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

#include "base/compiler_specific.h"
#include "base/time/time.h"
#include "media/base/decrypt_config.h"
#include "media/base/media_export.h"
#include "media/base/media_log.h"
#include "media/base/video_codecs.h"
#include "media/formats/mp4/aac.h"
#include "media/formats/mp4/ac3.h"
#include "media/formats/mp4/ac4.h"
#include "media/formats/mp4/avc.h"
#include "media/formats/mp4/box_reader.h"
#include "media/formats/mp4/dts.h"
#include "media/formats/mp4/dtsx.h"
#include "media/formats/mp4/eac3.h"
#include "media/formats/mp4/fourccs.h"
#include "media/media_buildflags.h"

namespace media {
namespace mp4 {

// Size in bytes needed to store largest IV.
const int kInitializationVectorSize =;

enum TrackType {};

enum SampleFlags {};

#define DECLARE_BOX_METHODS(T)

struct MEDIA_EXPORT FileType : Box {};

// If only copying the 'pssh' boxes, use ProtectionSystemSpecificHeader.
// If access to the individual fields is needed, use
// FullProtectionSystemSpecificHeader.
struct MEDIA_EXPORT ProtectionSystemSpecificHeader : Box {};

struct MEDIA_EXPORT FullProtectionSystemSpecificHeader : Box {};

struct MEDIA_EXPORT SampleAuxiliaryInformationOffset : Box {};

struct MEDIA_EXPORT SampleAuxiliaryInformationSize : Box {};

// Represent an entry in SampleEncryption box or CENC auxiliary info.
struct MEDIA_EXPORT SampleEncryptionEntry {};

// ISO/IEC 23001-7:2015 8.1.1.
struct MEDIA_EXPORT SampleEncryption : Box {};

struct MEDIA_EXPORT OriginalFormat : Box {};

struct MEDIA_EXPORT SchemeType : Box {};

struct MEDIA_EXPORT TrackEncryption : Box {};

struct MEDIA_EXPORT SchemeInfo : Box {};

struct MEDIA_EXPORT ProtectionSchemeInfo : Box {};

struct MEDIA_EXPORT MovieHeader : Box {};

struct MEDIA_EXPORT TrackHeader : Box {};

struct MEDIA_EXPORT EditListEntry {};

struct MEDIA_EXPORT EditList : Box {};

struct MEDIA_EXPORT Edit : Box {};

struct MEDIA_EXPORT HandlerReference : Box {};

#if BUILDFLAG(USE_PROPRIETARY_CODECS)
struct MEDIA_EXPORT AVCDecoderConfigurationRecord : Box {
  DECLARE_BOX_METHODS(AVCDecoderConfigurationRecord);

  // Parses AVCDecoderConfigurationRecord data encoded in |data|.
  // Note: This method is intended to parse data outside the MP4StreamParser
  //       context and therefore the box header is not expected to be present
  //       in |data|.
  // Returns true if |data| was successfully parsed.
  bool Parse(const uint8_t* data, int data_size);
  bool Serialize(std::vector<uint8_t>& output) const;

  uint8_t version;
  uint8_t profile_indication;
  uint8_t profile_compatibility;
  uint8_t avc_level;
  uint8_t length_size;

  std::vector<std::vector<uint8_t>> sps_list;
  std::vector<std::vector<uint8_t>> pps_list;

  uint8_t chroma_format;
  uint8_t bit_depth_luma_minus8;
  uint8_t bit_depth_chroma_minus8;

  std::vector<std::vector<uint8_t>> sps_ext_list;

 private:
  bool ParseInternal(BufferReader* reader, MediaLog* media_log);
  bool ParseREXT(BufferReader* reader, MediaLog* media_log);
};
#endif  // BUILDFLAG(USE_PROPRIETARY_CODECS)

struct MEDIA_EXPORT VPCodecConfigurationRecord : Box {};

#if BUILDFLAG(ENABLE_AV1_DECODER)
struct MEDIA_EXPORT AV1CodecConfigurationRecord : Box {};
#endif

struct MEDIA_EXPORT PixelAspectRatioBox : Box {};

struct MEDIA_EXPORT ColorParameterInformation : Box {};

struct MEDIA_EXPORT MasteringDisplayColorVolume : Box {};

// Mostly the same as MasteringDisplayColorVolume, but with a different fourcc
// and slightly different layout and format of encoded values.
struct MEDIA_EXPORT SMPTE2086MasteringDisplayMetadataBox
    : MasteringDisplayColorVolume {};

struct MEDIA_EXPORT ContentLightLevelInformation : Box {};

// Same as ContentLightLevelInformation, but with a different fourcc.
struct MEDIA_EXPORT ContentLightLevel : ContentLightLevelInformation {};

struct MEDIA_EXPORT VideoSampleEntry : Box {};

struct MEDIA_EXPORT ElementaryStreamDescriptor : Box {};

struct MEDIA_EXPORT FlacSpecificBox : Box {};

struct MEDIA_EXPORT OpusSpecificBox : Box {};

#if BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
struct MEDIA_EXPORT DtsSpecificBox : Box {
  DECLARE_BOX_METHODS(DtsSpecificBox);
  DTS dts;
};

struct MEDIA_EXPORT DtsUhdSpecificBox : Box {
  DECLARE_BOX_METHODS(DtsUhdSpecificBox);
  DTSX dtsx;
};
#endif  // BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)

#if BUILDFLAG(ENABLE_PLATFORM_AC3_EAC3_AUDIO)
struct MEDIA_EXPORT AC3SpecificBox : Box {
  DECLARE_BOX_METHODS(AC3SpecificBox);
  AC3 dac3;
};

struct MEDIA_EXPORT EC3SpecificBox : Box {
  DECLARE_BOX_METHODS(EC3SpecificBox);
  EAC3 dec3;
};
#endif  // BUILDFLAG(ENABLE_PLATFORM_AC3_EAC3_AUDIO)

#if BUILDFLAG(ENABLE_PLATFORM_AC4_AUDIO)
struct MEDIA_EXPORT AC4SpecificBox : Box {
  DECLARE_BOX_METHODS(AC4SpecificBox);
  AC4 dac4;
};
#endif  // BUILDFLAG(ENABLE_PLATFORM_AC4_AUDIO)

#if BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
struct MEDIA_EXPORT IamfSpecificBox : Box {
  DECLARE_BOX_METHODS(IamfSpecificBox);
  bool ReadOBU(BufferReader* reader);
  bool ReadOBUHeader(BufferReader* reader,
                     uint8_t* obu_type,
                     uint32_t* obu_size);
  bool ReadLeb128Value(BufferReader* reader, uint32_t* value) const;

  uint8_t profile;
  bool redundant_copy = false;

  std::vector<uint8_t> ia_descriptors;
};
#endif  // BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)

struct MEDIA_EXPORT AudioSampleEntry : Box {};

struct MEDIA_EXPORT SampleDescription : Box {};

struct MEDIA_EXPORT CencSampleEncryptionInfoEntry {};

struct MEDIA_EXPORT SampleGroupDescription : Box {};

struct MEDIA_EXPORT SampleTable : Box {};

struct MEDIA_EXPORT MediaHeader : Box {};

struct MEDIA_EXPORT MediaInformation : Box {};

struct MEDIA_EXPORT Media : Box {};

struct MEDIA_EXPORT Track : Box {};

struct MEDIA_EXPORT MovieExtendsHeader : Box {};

struct MEDIA_EXPORT TrackExtends : Box {};

struct MEDIA_EXPORT MovieExtends : Box {};

struct MEDIA_EXPORT Movie : Box {};

struct MEDIA_EXPORT TrackFragmentDecodeTime : Box {};

struct MEDIA_EXPORT MovieFragmentHeader : Box {};

struct MEDIA_EXPORT TrackFragmentHeader : Box {};

struct MEDIA_EXPORT TrackFragmentRun : Box {};

// sample_depends_on values in ISO/IEC 14496-12 Section 8.40.2.3.
enum SampleDependsOn {};

class MEDIA_EXPORT IndependentAndDisposableSamples : public Box {};

struct MEDIA_EXPORT SampleToGroupEntry {};

struct MEDIA_EXPORT SampleToGroup : Box {};

struct MEDIA_EXPORT TrackFragment : Box {};

struct MEDIA_EXPORT MovieFragment : Box {};

#undef DECLARE_BOX

}  // namespace mp4
}  // namespace media

#endif  // MEDIA_FORMATS_MP4_BOX_DEFINITIONS_H_