1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4  * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef MP4ESDS_h_
7 #define MP4ESDS_h_
8 
9 #include "nsTArray.h"
10 #include "MuxerOperation.h"
11 
12 namespace mozilla {
13 
14 class ISOControl;
15 
16 /**
17  * ESDS tag
18  */
19 #define ESDescrTag        0x03
20 
21 /**
22  * 14496-1 '8.3.3 ES_Descriptor'.
23  * It will get DecoderConfigDescriptor and SLConfigDescriptor from
24  * AAC CSD data.
25  */
26 class ES_Descriptor : public MuxerOperation {
27 public:
28   // ISO BMFF members
29   uint8_t tag;      // ESDescrTag
30   uint8_t length;
31   uint16_t ES_ID;
32   std::bitset<1> streamDependenceFlag;
33   std::bitset<1> URL_Flag;
34   std::bitset<1> reserved;
35   std::bitset<5> streamPriority;
36 
37   nsTArray<uint8_t> DecodeSpecificInfo;
38 
39   // MuxerOperation methods
40   nsresult Generate(uint32_t* aBoxSize) override;
41   nsresult Write() override;
42   nsresult Find(const nsACString& aType,
43                 nsTArray<RefPtr<MuxerOperation>>& aOperations) override;
44 
45   // ES_Descriptor methods
46   ES_Descriptor(ISOControl* aControl);
47   ~ES_Descriptor();
48 
49 protected:
50   ISOControl* mControl;
51 };
52 
53 // 14496-14 5.6 'Sample Description Boxes'
54 // Box type: 'esds'
55 class ESDBox : public FullBox {
56 public:
57   // ISO BMFF members
58   RefPtr<ES_Descriptor> es_descriptor;
59 
60   // MuxerOperation methods
61   nsresult Generate(uint32_t* aBoxSize) override;
62   nsresult Write() override;
63 
64   // ESDBox methods
65   ESDBox(ISOControl* aControl);
66   ~ESDBox();
67 };
68 
69 // 14496-14 5.6 'Sample Description Boxes'
70 // Box type: 'mp4a'
71 class MP4AudioSampleEntry : public AudioSampleEntry {
72 public:
73   // ISO BMFF members
74   RefPtr<ESDBox> es;
75 
76   // MuxerOperation methods
77   nsresult Generate(uint32_t* aBoxSize) override;
78   nsresult Write() override;
79 
80   // MP4AudioSampleEntry methods
81   MP4AudioSampleEntry(ISOControl* aControl);
82   ~MP4AudioSampleEntry();
83 };
84 
85 }
86 
87 #endif // MP4ESDS_h_
88