summaryrefslogtreecommitdiff
path: root/dom/media/encoder/fmp4_muxer/MP4ESDS.h
blob: ee91312c1f10b5b651a6ed5c39bd3cd11b1e79a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef MP4ESDS_h_
#define MP4ESDS_h_

#include "nsTArray.h"
#include "MuxerOperation.h"

namespace mozilla {

class ISOControl;

/**
 * ESDS tag
 */
#define ESDescrTag        0x03

/**
 * 14496-1 '8.3.3 ES_Descriptor'.
 * It will get DecoderConfigDescriptor and SLConfigDescriptor from
 * AAC CSD data.
 */
class ES_Descriptor : public MuxerOperation {
public:
  // ISO BMFF members
  uint8_t tag;      // ESDescrTag
  uint8_t length;
  uint16_t ES_ID;
  std::bitset<1> streamDependenceFlag;
  std::bitset<1> URL_Flag;
  std::bitset<1> reserved;
  std::bitset<5> streamPriority;

  nsTArray<uint8_t> DecodeSpecificInfo;

  // MuxerOperation methods
  nsresult Generate(uint32_t* aBoxSize) override;
  nsresult Write() override;
  nsresult Find(const nsACString& aType,
                nsTArray<RefPtr<MuxerOperation>>& aOperations) override;

  // ES_Descriptor methods
  ES_Descriptor(ISOControl* aControl);
  ~ES_Descriptor();

protected:
  ISOControl* mControl;
};

// 14496-14 5.6 'Sample Description Boxes'
// Box type: 'esds'
class ESDBox : public FullBox {
public:
  // ISO BMFF members
  RefPtr<ES_Descriptor> es_descriptor;

  // MuxerOperation methods
  nsresult Generate(uint32_t* aBoxSize) override;
  nsresult Write() override;

  // ESDBox methods
  ESDBox(ISOControl* aControl);
  ~ESDBox();
};

// 14496-14 5.6 'Sample Description Boxes'
// Box type: 'mp4a'
class MP4AudioSampleEntry : public AudioSampleEntry {
public:
  // ISO BMFF members
  RefPtr<ESDBox> es;

  // MuxerOperation methods
  nsresult Generate(uint32_t* aBoxSize) override;
  nsresult Write() override;

  // MP4AudioSampleEntry methods
  MP4AudioSampleEntry(ISOControl* aControl);
  ~MP4AudioSampleEntry();
};

}

#endif // MP4ESDS_h_