@@ -18,6 +18,7 @@ import noop from "../../../../../../utils/noop.ts";
1818import type {
1919 IAdaptationSetAttributes ,
2020 IAdaptationSetChildren ,
21+ IRepresentationIntermediateRepresentation ,
2122 ISegmentListIntermediateRepresentation ,
2223} from "../../../node_parser_types.ts" ;
2324import type { IAttributeParser , IChildrenParser } from "../parsers_stack.ts" ;
@@ -28,6 +29,7 @@ import { generateBaseUrlAttrParser } from "./BaseURL.ts";
2829import { generateContentComponentAttrParser } from "./ContentComponent.ts" ;
2930import { generateContentProtectionAttrParser } from "./ContentProtection.ts" ;
3031import { generateLabelElementParser } from "./Label.ts" ;
32+ import { emptyChildArray , pushChild } from "./lazy_child_array.ts" ;
3133import {
3234 generateRepresentationAttrParser ,
3335 generateRepresentationChildrenParser ,
@@ -59,7 +61,7 @@ export function generateAdaptationSetChildrenParser(
5961 switch ( nodeId ) {
6062 case TagName . Accessibility : {
6163 const accessibility = { attributes : { } } ;
62- adaptationSetChildren . Accessibility . push ( accessibility ) ;
64+ pushChild ( adaptationSetChildren , " Accessibility" , accessibility ) ;
6365 const schemeAttrParser = generateSchemeAttrParser (
6466 accessibility . attributes ,
6567 linearMemory ,
@@ -70,15 +72,15 @@ export function generateAdaptationSetChildrenParser(
7072
7173 case TagName . BaseURL : {
7274 const baseUrl = { value : "" , attributes : { } } ;
73- adaptationSetChildren . BaseURL . push ( baseUrl ) ;
75+ pushChild ( adaptationSetChildren , " BaseURL" , baseUrl ) ;
7476 const attributeParser = generateBaseUrlAttrParser ( baseUrl , linearMemory ) ;
7577 parsersStack . pushParsers ( nodeId , noop , attributeParser ) ;
7678 break ;
7779 }
7880
7981 case TagName . ContentComponent : {
8082 const contentComponent = { attributes : { } } ;
81- adaptationSetChildren . ContentComponent . push ( contentComponent ) ;
83+ pushChild ( adaptationSetChildren , " ContentComponent" , contentComponent ) ;
8284 parsersStack . pushParsers (
8385 nodeId ,
8486 noop ,
@@ -92,7 +94,7 @@ export function generateAdaptationSetChildrenParser(
9294 children : { [ "cenc:pssh" ] : [ ] } ,
9395 attributes : { } ,
9496 } ;
95- adaptationSetChildren . ContentProtection . push ( contentProtection ) ;
97+ pushChild ( adaptationSetChildren , " ContentProtection" , contentProtection ) ;
9698 const contentProtAttrParser = generateContentProtectionAttrParser (
9799 contentProtection ,
98100 linearMemory ,
@@ -103,7 +105,7 @@ export function generateAdaptationSetChildrenParser(
103105
104106 case TagName . EssentialProperty : {
105107 const essentialProperty = { attributes : { } } ;
106- adaptationSetChildren . EssentialProperty . push ( essentialProperty ) ;
108+ pushChild ( adaptationSetChildren , " EssentialProperty" , essentialProperty ) ;
107109
108110 const childrenParser = noop ; // EssentialProperty have no sub-element
109111 const attributeParser = generateSchemeAttrParser (
@@ -116,7 +118,7 @@ export function generateAdaptationSetChildrenParser(
116118
117119 case TagName . InbandEventStream : {
118120 const inbandEvent = { attributes : { } } ;
119- adaptationSetChildren . InbandEventStream . push ( inbandEvent ) ;
121+ pushChild ( adaptationSetChildren , " InbandEventStream" , inbandEvent ) ;
120122
121123 const childrenParser = noop ; // InbandEventStream have no sub-element
122124 const attributeParser = generateSchemeAttrParser (
@@ -128,20 +130,20 @@ export function generateAdaptationSetChildrenParser(
128130 }
129131
130132 case TagName . Representation : {
131- const representationObj = {
133+ const representationObj : IRepresentationIntermediateRepresentation = {
132134 children : {
133- BaseURL : [ ] ,
134- ContentProtection : [ ] ,
135- InbandEventStream : [ ] ,
136- SegmentBase : [ ] ,
137- SegmentList : [ ] ,
138- SegmentTemplate : [ ] ,
139- SupplementalProperty : [ ] ,
140- EssentialProperty : [ ] ,
135+ BaseURL : emptyChildArray ( ) ,
136+ ContentProtection : emptyChildArray ( ) ,
137+ InbandEventStream : emptyChildArray ( ) ,
138+ SegmentBase : emptyChildArray ( ) ,
139+ SegmentList : emptyChildArray ( ) ,
140+ SegmentTemplate : emptyChildArray ( ) ,
141+ SupplementalProperty : emptyChildArray ( ) ,
142+ EssentialProperty : emptyChildArray ( ) ,
141143 } ,
142144 attributes : { } ,
143145 } ;
144- adaptationSetChildren . Representation . push ( representationObj ) ;
146+ pushChild ( adaptationSetChildren , " Representation" , representationObj ) ;
145147 const childrenParser = generateRepresentationChildrenParser (
146148 representationObj . children ,
147149 linearMemory ,
@@ -157,15 +159,15 @@ export function generateAdaptationSetChildrenParser(
157159
158160 case TagName . Role : {
159161 const role = { attributes : { } } ;
160- adaptationSetChildren . Role . push ( role ) ;
162+ pushChild ( adaptationSetChildren , " Role" , role ) ;
161163 const attributeParser = generateSchemeAttrParser ( role . attributes , linearMemory ) ;
162164 parsersStack . pushParsers ( nodeId , noop , attributeParser ) ;
163165 break ;
164166 }
165167
166168 case TagName . SupplementalProperty : {
167169 const supplementalProperty = { attributes : { } } ;
168- adaptationSetChildren . SupplementalProperty . push ( supplementalProperty ) ;
170+ pushChild ( adaptationSetChildren , " SupplementalProperty" , supplementalProperty ) ;
169171 const attributeParser = generateSchemeAttrParser (
170172 supplementalProperty . attributes ,
171173 linearMemory ,
@@ -176,7 +178,7 @@ export function generateAdaptationSetChildrenParser(
176178
177179 case TagName . SegmentBase : {
178180 const segmentBaseObj = { children : { Initialization : [ ] } , attributes : { } } ;
179- adaptationSetChildren . SegmentBase . push ( segmentBaseObj ) ;
181+ pushChild ( adaptationSetChildren , " SegmentBase" , segmentBaseObj ) ;
180182 const attributeParser = generateSegmentBaseAttrParser (
181183 segmentBaseObj ,
182184 linearMemory ,
@@ -198,7 +200,7 @@ export function generateAdaptationSetChildrenParser(
198200 } ,
199201 attributes : { } ,
200202 } ;
201- adaptationSetChildren . SegmentList . push ( segmentListObj ) ;
203+ pushChild ( adaptationSetChildren , " SegmentList" , segmentListObj ) ;
202204 const childrenParser = generateSegmentListChildrenParser (
203205 segmentListObj ,
204206 linearMemory ,
@@ -216,7 +218,7 @@ export function generateAdaptationSetChildrenParser(
216218
217219 case TagName . SegmentTemplate : {
218220 const stObj = { children : { Initialization : [ ] } , attributes : { } } ;
219- adaptationSetChildren . SegmentTemplate . push ( stObj ) ;
221+ pushChild ( adaptationSetChildren , " SegmentTemplate" , stObj ) ;
220222 parsersStack . pushParsers (
221223 nodeId ,
222224 generateSegmentTemplateChildrenParser (
0 commit comments