@@ -13,14 +13,6 @@ namespace CMAF{
13
13
return payloadSize;
14
14
}
15
15
16
- size_t simplifiedTrackId (const DTSC::Meta & M, size_t idx) {
17
- std::string type = M.getType (idx);
18
- if (type == " video" ) {return 1 ;}
19
- if (type == " audio" ) {return 2 ;}
20
- if (type == " meta" ) {return 3 ;}
21
- return idx;
22
- }
23
-
24
16
std::string trackHeader (const DTSC::Meta &M, size_t track, bool simplifyTrackIds){
25
17
std::string tType = M.getType (track);
26
18
@@ -43,9 +35,6 @@ namespace CMAF{
43
35
MP4::TRAK trakBox;
44
36
45
37
MP4::TKHD tkhdBox (M, track);
46
- if (simplifyTrackIds){
47
- tkhdBox.setTrackID (simplifiedTrackId (M, track));
48
- }
49
38
tkhdBox.setDuration (0 );
50
39
trakBox.setContent (tkhdBox, 0 );
51
40
@@ -87,7 +76,7 @@ namespace CMAF{
87
76
btrtBox.setAverageBitrate (M.getBps (track));
88
77
btrtBox.setMaxBitrate (M.getMaxBps (track));
89
78
90
- sampleEntry.setBoxEntry (sampleEntry.getBoxEntryCount (),btrtBox);
79
+ sampleEntry.setBoxEntry (sampleEntry.getBoxEntryCount (), btrtBox);
91
80
stsdBox.setEntry (sampleEntry, 0 );
92
81
}else if (tType == " audio" ){
93
82
MP4::AudioSampleEntry sampleEntry (M, track);
@@ -96,7 +85,7 @@ namespace CMAF{
96
85
btrtBox.setAverageBitrate (M.getBps (track));
97
86
btrtBox.setMaxBitrate (M.getMaxBps (track));
98
87
99
- sampleEntry.setBoxEntry (sampleEntry.getBoxEntryCount (),btrtBox);
88
+ sampleEntry.setBoxEntry (sampleEntry.getBoxEntryCount (), btrtBox);
100
89
stsdBox.setEntry (sampleEntry, 0 );
101
90
}else if (tType == " meta" ){
102
91
MP4::TextSampleEntry sampleEntry (M, track);
@@ -131,9 +120,6 @@ namespace CMAF{
131
120
}
132
121
133
122
MP4::TREX trexBox (track + 1 );
134
- if (simplifyTrackIds){
135
- trexBox.setTrackID (simplifiedTrackId (M, track));
136
- }
137
123
trexBox.setDefaultSampleDuration (1000 );
138
124
mvexBox.setContent (trexBox, M.getVod () ? 1 : 0 );
139
125
@@ -148,17 +134,21 @@ namespace CMAF{
148
134
MP4::SIDX sidxBox;
149
135
sidxBox.setReferenceID (track + 1 );
150
136
sidxBox.setTimescale (1000 );
151
- sidxBox.setEarliestPresentationTime (keys.getTime (0 ) + parts.getOffset (0 ) - M.getFirstms (track));
137
+ sidxBox.setEarliestPresentationTime (keys.getTime (0 ) + parts.getOffset (0 ) -
138
+ M.getFirstms (track));
152
139
153
140
for (size_t i = 0 ; i < fragments.getEndValid (); i++){
154
141
size_t firstKey = fragments.getFirstKey (i);
155
142
size_t endKey =
156
143
((i + 1 < fragments.getEndValid ()) ? fragments.getFirstKey (i + 1 ) : keys.getEndValid ());
157
144
158
145
MP4::sidxReference refItem;
159
- refItem.referencedSize = payloadSize (M, track, keys.getTime (firstKey), keys.getTime (endKey)) + keyHeaderSize (M, track, i) + 8 ;
146
+ refItem.referencedSize =
147
+ payloadSize (M, track, keys.getTime (firstKey), keys.getTime (endKey)) +
148
+ keyHeaderSize (M, track, i) + 8 ;
160
149
refItem.subSegmentDuration =
161
- (endKey == keys.getEndValid () ? M.getLastms (track) : keys.getTime (endKey)) - keys.getTime (firstKey);
150
+ (endKey == keys.getEndValid () ? M.getLastms (track) : keys.getTime (endKey)) -
151
+ keys.getTime (firstKey);
162
152
refItem.sapStart = true ;
163
153
refItem.sapType = 16 ;
164
154
refItem.sapDeltaTime = 0 ;
@@ -209,7 +199,8 @@ namespace CMAF{
209
199
}
210
200
211
201
// / Generates the 'moof' box for a DTSC::Key based CMAF fragment.
212
- std::string keyHeader (const DTSC::Meta &M, size_t track, uint64_t startTime, uint64_t endTime, uint64_t segmentNum, bool simplifyTrackIds, bool UTCTime){
202
+ std::string keyHeader (const DTSC::Meta &M, size_t track, uint64_t startTime, uint64_t endTime,
203
+ uint64_t segmentNum, bool simplifyTrackIds, bool UTCTime){
213
204
214
205
size_t firstPart = M.getPartIndex (startTime, track);
215
206
size_t endPart = M.getPartIndex (endTime, track);
@@ -218,10 +209,9 @@ namespace CMAF{
218
209
MP4::MFHD mfhdBox (segmentNum);
219
210
moofBox.setContent (mfhdBox, 0 );
220
211
221
-
222
212
std::set<sortPart> trunOrder;
223
213
224
- // We use keyHeaderSize here to determine the relative offsets of the data in the 'mdat' box.
214
+ // We use keyHeaderSize here to determine the relative offsets of the data in the 'mdat' box.
225
215
uint64_t relativeOffset = keyHeaderSize (M, track, startTime, endTime) + 8 ;
226
216
227
217
sortPart temp;
@@ -242,21 +232,20 @@ namespace CMAF{
242
232
243
233
tfhdBox.setFlags (MP4::tfhdSampleFlag | MP4::tfhdBaseIsMoof | MP4::tfhdSampleDesc);
244
234
tfhdBox.setTrackID (track + 1 );
245
- if (simplifyTrackIds){
246
- tfhdBox.setTrackID (simplifiedTrackId (M, track));
247
- }
248
235
tfhdBox.setDefaultSampleDuration (444 );
249
236
tfhdBox.setDefaultSampleSize (444 );
250
- tfhdBox.setDefaultSampleFlags ((M.getType (track) == " video" ) ? (MP4::noIPicture | MP4::noKeySample)
251
- : (MP4::isIPicture | MP4::isKeySample));
237
+ tfhdBox.setDefaultSampleFlags ((M.getType (track) == " video" )
238
+ ? (MP4::noIPicture | MP4::noKeySample)
239
+ : (MP4::isIPicture | MP4::isKeySample));
252
240
tfhdBox.setSampleDescriptionIndex (1 );
253
241
trafBox.setContent (tfhdBox, 0 );
254
242
255
243
MP4::TFDT tfdtBox;
256
244
if (M.getVod ()){
257
245
tfdtBox.setBaseMediaDecodeTime (startTime - M.getFirstms (track));
258
246
}else {
259
- tfdtBox.setBaseMediaDecodeTime ((UTCTime ? startTime + M.getBootMsOffset () + unixBootDiff : startTime));
247
+ tfdtBox.setBaseMediaDecodeTime (
248
+ (UTCTime ? startTime + M.getBootMsOffset () + unixBootDiff : startTime));
260
249
}
261
250
trafBox.setContent (tfdtBox, 1 );
262
251
@@ -277,15 +266,14 @@ namespace CMAF{
277
266
MP4::trunSampleInformation sampleInfo;
278
267
sampleInfo.sampleSize = parts.getSize (it->partIndex );
279
268
sampleInfo.sampleDuration = parts.getDuration (it->partIndex );
280
- if (it == lastOne){
281
- sampleInfo.sampleDuration = endTime - it->time ;
282
- }
269
+ if (it == lastOne){sampleInfo.sampleDuration = endTime - it->time ;}
283
270
sampleInfo.sampleOffset = parts.getOffset (it->partIndex );
284
271
trunBox.setSampleInformation (sampleInfo, trunOffset++);
285
272
}
286
273
}else {
287
- WARN_MSG (" Empty CMAF header for track %zu: %" PRIu64 " -%" PRIu64 " contains no packets (first: %" PRIu64
288
- " , last: %" PRIu64 " ), firstPart=%zu, lastPart=%zu" ,
274
+ WARN_MSG (" Empty CMAF header for track %zu: %" PRIu64 " -%" PRIu64
275
+ " contains no packets (first: %" PRIu64 " , last: %" PRIu64
276
+ " ), firstPart=%zu, lastPart=%zu" ,
289
277
track, startTime, endTime, M.getFirstms (track), M.getLastms (track), firstPart,
290
278
endPart);
291
279
}
0 commit comments