RDK Documentation (Open Sourced RDK Components)
isobmffbuffer.cpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2019 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21 * @file isobmffbuffer.cpp
22 * @brief Source file for ISO Base Media File Format Buffer
23 */
24 
25 #include "isobmffbuffer.h"
26 #include "priv_aamp.h" //Required for AAMPLOG_WARN1
27 #include <string.h>
28 
29 
30 /**
31  * @brief IsoBmffBuffer destructor
32  */
34 {
35  for (unsigned int i=boxes.size(); i>0;)
36  {
37  --i;
38  SAFE_DELETE(boxes[i]);
39  boxes.pop_back();
40  }
41  boxes.clear();
42 }
43 
44 /**
45  * @brief Set buffer
46  */
47 void IsoBmffBuffer::setBuffer(uint8_t *buf, size_t sz)
48 {
49  buffer = buf;
50  bufSize = sz;
51 }
52 
53 /**
54  * @fn parseBuffer
55  * @param[in] correctBoxSize - flag to correct the box size
56  * @param[in] newTrackId - new track id to overwrite the existing track id, when value is -1, it will not override
57  * @brief Parse ISOBMFF boxes from buffer
58  */
59 bool IsoBmffBuffer::parseBuffer(bool correctBoxSize, int newTrackId)
60 {
61  size_t curOffset = 0;
62  while (curOffset < bufSize)
63  {
64  Box *box = Box::constructBox(buffer+curOffset, bufSize - curOffset, mLogObj, correctBoxSize, newTrackId);
65  if( ((bufSize - curOffset) < 4) || ( (bufSize - curOffset) < box->getSize()) )
66  {
67  chunkedBox = box;
68  }
69  box->setOffset(curOffset);
70  boxes.push_back(box);
71  curOffset += box->getSize();
72  }
73  return !!(boxes.size());
74 }
75 
76 /**
77  * @brief Get mdat buffer handle and size from parsed buffer
78  */
79 bool IsoBmffBuffer::parseMdatBox(uint8_t *buf, size_t &size)
80 {
81  return parseBoxInternal(&boxes, Box::MDAT, buf, size);
82 }
83 
84 #define BOX_HEADER_SIZE 8
85 
86 /**
87  * @brief parse ISOBMFF boxes of a type in a parsed buffer
88  */
89 bool IsoBmffBuffer::parseBoxInternal(const std::vector<Box*> *boxes, const char *name, uint8_t *buf, size_t &size)
90 {
91  for (size_t i = 0; i < boxes->size(); i++)
92  {
93  Box *box = boxes->at(i);
94  AAMPLOG_TRACE("Offset[%u] Type[%s] Size[%u]", box->getOffset(), box->getType(), box->getSize());
95  if (IS_TYPE(box->getType(), name))
96  {
97  size_t offset = box->getOffset() + BOX_HEADER_SIZE;
98  size = box->getSize() - BOX_HEADER_SIZE;
99  memcpy(buf, buffer + offset, size);
100  return true;
101  }
102  }
103  return false;
104 }
105 
106 /**
107  * @brief Get mdat buffer size
108  */
110 {
111  return getBoxSizeInternal(&boxes, Box::MDAT, size);
112 }
113 
114 /**
115  * @brief get ISOBMFF box size of a type
116  */
117 bool IsoBmffBuffer::getBoxSizeInternal(const std::vector<Box*> *boxes, const char *name, size_t &size)
118 {
119  for (size_t i = 0; i < boxes->size(); i++)
120  {
121  Box *box = boxes->at(i);
122  if (IS_TYPE(box->getType(), name))
123  {
124  size = box->getSize();
125  return true;
126  }
127  }
128  return false;
129 }
130 
131 /**
132  * @brief Restamp PTS in a buffer
133  */
134 void IsoBmffBuffer::restampPTS(uint64_t offset, uint64_t basePts, uint8_t *segment, uint32_t bufSz)
135 {
136  // TODO: Untest code, not required for now
137  uint32_t curOffset = 0;
138  while (curOffset < bufSz)
139  {
140  uint8_t *buf = segment + curOffset;
141  uint32_t size = READ_U32(buf);
142  uint8_t type[5];
143  READ_U8(type, buf, 4);
144  type[4] = '\0';
145 
146  if (IS_TYPE(type, Box::MOOF) || IS_TYPE(type, Box::TRAF))
147  {
148  restampPTS(offset, basePts, buf, size);
149  }
150  else if (IS_TYPE(type, Box::TFDT))
151  {
152  uint8_t version = READ_VERSION(buf);
153  uint32_t flags = READ_FLAGS(buf);
154 
155  if (1 == version)
156  {
157  uint64_t pts = ReadUint64(buf);
158  pts -= basePts;
159  pts += offset;
160  WriteUint64(buf, pts);
161  }
162  else
163  {
164  uint32_t pts = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
165  pts -= (uint32_t)basePts;
166  pts += (uint32_t)offset;
167  WRITE_U32(buf, pts);
168  }
169  }
170  curOffset += size;
171  }
172 }
173 
174 /**
175  * @brief Release ISOBMFF boxes parsed
176  */
178 {
179  for (unsigned int i=boxes.size(); i>0;)
180  {
181  --i;
182  SAFE_DELETE(boxes[i]);
183  boxes.pop_back();
184  }
185  boxes.clear();
186 }
187 
188 /**
189  * @brief Get first PTS of buffer
190  */
191 bool IsoBmffBuffer::getFirstPTSInternal(const std::vector<Box*> *boxes, uint64_t &pts)
192 {
193  bool ret = false;
194  for (size_t i = 0; (false == ret) && i < boxes->size(); i++)
195  {
196  Box *box = boxes->at(i);
197  if (IS_TYPE(box->getType(), Box::TFDT))
198  {
199  TfdtBox *tfdtBox = dynamic_cast<TfdtBox *>(box);
200  if(tfdtBox)
201  {
202  pts = tfdtBox->getBaseMDT();
203  ret = true;
204  break;
205  }
206  }
207  if (box->hasChildren())
208  {
209  ret = getFirstPTSInternal(box->getChildren(), pts);
210  }
211  }
212  return ret;
213 }
214 
215 /**
216  * @brief Get track id from trak box
217  */
218 bool IsoBmffBuffer::getTrackIdInternal(const std::vector<Box*> *boxes, uint32_t &track_id)
219 {
220  bool ret = false;
221  for (size_t i = 0; (false == ret) && i < boxes->size(); i++)
222  {
223  Box *box = boxes->at(i);
224  if (IS_TYPE(box->getType(), Box::TRAK))
225  {
226  try {
227  TrakBox *trakBox = dynamic_cast<TrakBox *>(box);
228  if(trakBox)
229  {
230  track_id = trakBox->getTrack_Id();
231  ret = true;
232  break;
233  }
234  } catch (std::bad_cast& bc){
235  //do nothing
236  }
237  }
238  if (box->hasChildren())
239  {
240  ret = getTrackIdInternal(box->getChildren(), track_id);
241  }
242  }
243  return ret;
244 }
245 
246 /**
247  * @brief Get first PTS of buffer
248  */
249 bool IsoBmffBuffer::getFirstPTS(uint64_t &pts)
250 {
251  return getFirstPTSInternal(&boxes, pts);
252 }
253 
254 /**
255  * @brief Print PTS of buffer
256  */
258 {
259  return printPTSInternal(&boxes);
260 }
261 
262 /**
263  * @brief Get track_id from the trak box
264  */
265 bool IsoBmffBuffer::getTrack_id(uint32_t &track_id)
266 {
267  return getTrackIdInternal(&boxes, track_id);
268 }
269 
270 /**
271  * @brief Get TimeScale value of buffer
272  */
273 bool IsoBmffBuffer::getTimeScaleInternal(const std::vector<Box*> *boxes, uint32_t &timeScale, bool &foundMdhd)
274 {
275  bool ret = false;
276  for (size_t i = 0; (false == foundMdhd) && i < boxes->size(); i++)
277  {
278  Box *box = boxes->at(i);
279  if (IS_TYPE(box->getType(), Box::MVHD))
280  {
281  MvhdBox *mvhdBox = dynamic_cast<MvhdBox *>(box);
282  if(mvhdBox){
283  timeScale = mvhdBox->getTimeScale();
284  ret = true;
285  }
286  }
287  else if (IS_TYPE(box->getType(), Box::MDHD))
288  {
289  MdhdBox *mdhdBox = dynamic_cast<MdhdBox *>(box);
290  if(mdhdBox) {
291  timeScale = mdhdBox->getTimeScale();
292  ret = true;
293  foundMdhd = true;
294  }
295  }
296  if (box->hasChildren())
297  {
298  ret = getTimeScaleInternal(box->getChildren(), timeScale, foundMdhd);
299  }
300  }
301  return ret;
302 }
303 
304 /**
305  * @brief Get TimeScale value of buffer
306  */
307 bool IsoBmffBuffer::getTimeScale(uint32_t &timeScale)
308 {
309  bool foundMdhd = false;
310  return getTimeScaleInternal(&boxes, timeScale, foundMdhd);
311 }
312 
313 /**
314  * @brief Print ISOBMFF boxes
315  */
316 void IsoBmffBuffer::printBoxesInternal(const std::vector<Box*> *boxes)
317 {
318  for (size_t i = 0; i < boxes->size(); i++)
319  {
320  Box *box = boxes->at(i);
321  AAMPLOG_WARN("Offset[%u] Type[%s] Size[%u]", box->getOffset(), box->getType(), box->getSize());
322  if (IS_TYPE(box->getType(), Box::TFDT))
323  {
324  if(dynamic_cast<TfdtBox *>(box)) {
325  AAMPLOG_WARN("****Base Media Decode Time: %lld", dynamic_cast<TfdtBox *>(box)->getBaseMDT());
326  }
327  }
328  else if (IS_TYPE(box->getType(), Box::MVHD))
329  {
330  if(dynamic_cast<MvhdBox *>(box)) {
331  AAMPLOG_WARN("**** TimeScale from MVHD: %u", dynamic_cast<MvhdBox *>(box)->getTimeScale());
332  }
333  }
334  else if (IS_TYPE(box->getType(), Box::MDHD))
335  {
336  if(dynamic_cast<MdhdBox *>(box)) {
337  AAMPLOG_WARN("**** TimeScale from MDHD: %u", dynamic_cast<MdhdBox *>(box)->getTimeScale());
338  }
339  }
340 
341  if (box->hasChildren())
342  {
344  }
345  }
346 }
347 
348 
349 /**
350  * @brief Print ISOBMFF boxes
351  */
353 {
354  printBoxesInternal(&boxes);
355 }
356 
357 /**
358  * @brief Check if buffer is an initialization segment
359  */
361 {
362  bool foundFtypBox = false;
363  for (size_t i = 0; i < boxes.size(); i++)
364  {
365  Box *box = boxes.at(i);
366  if (IS_TYPE(box->getType(), Box::FTYP))
367  {
368  foundFtypBox = true;
369  break;
370  }
371  }
372  return foundFtypBox;
373 }
374 
375 /**
376  * @brief Get emsg informations
377  */
378 bool IsoBmffBuffer::getEMSGInfoInternal(const std::vector<Box*> *boxes, uint8_t* &message, uint32_t &messageLen, uint8_t* &schemeIdUri, uint8_t* &value, uint64_t &presTime, uint32_t &timeScale, uint32_t &eventDuration, uint32_t &id, bool &foundEmsg)
379 {
380  bool ret = false;
381  for (size_t i = 0; (false == foundEmsg) && i < boxes->size(); i++)
382  {
383  Box *box = boxes->at(i);
384  if (IS_TYPE(box->getType(), Box::EMSG))
385  {
386  EmsgBox *emsgBox = dynamic_cast<EmsgBox *>(box);
387  if(emsgBox)
388  {
389  message = emsgBox->getMessage();
390  messageLen = emsgBox->getMessageLen();
391  presTime = emsgBox->getPresentationTime();
392  timeScale = emsgBox->getTimeScale();
393  eventDuration = emsgBox->getEventDuration();
394  id = emsgBox->getId();
395  schemeIdUri = emsgBox->getSchemeIdUri();
396  value = emsgBox->getValue();
397  ret = true;
398  foundEmsg = true;
399  }
400  }
401  }
402  return ret;
403 }
404 
405 /**
406  * @brief Get information from EMSG box
407  */
408 bool IsoBmffBuffer::getEMSGData(uint8_t* &message, uint32_t &messageLen, uint8_t* &schemeIdUri, uint8_t* &value, uint64_t &presTime, uint32_t &timeScale, uint32_t &eventDuration, uint32_t &id)
409 {
410  bool foundEmsg = false;
411  return getEMSGInfoInternal(&boxes, message, messageLen, schemeIdUri, value, presTime, timeScale, eventDuration, id, foundEmsg);
412 }
413 
414 /**
415  * @brief get ISOBMFF box list of a type in a parsed buffer
416  */
417 bool IsoBmffBuffer::getBoxesInternal(const std::vector<Box*> *boxes, const char *name, std::vector<Box*> *pBoxes)
418 {
419  size_t size =boxes->size();
420  //Adjust size when chunked box is available
421  if(chunkedBox)
422  {
423  size -= 1;
424  }
425  for (size_t i = 0; i < size; i++)
426  {
427  Box *box = boxes->at(i);
428 
429  if (IS_TYPE(box->getType(), name))
430  {
431  pBoxes->push_back(box);
432  }
433  }
434  return !!(pBoxes->size());
435 }
436 
437 /**
438  * @brief Check mdat buffer count in parsed buffer
439  */
441 {
442  std::vector<Box*> mdatBoxes;
443  bool bParse = false;
444  bParse = getBoxesInternal(&boxes ,Box::MDAT, &mdatBoxes);
445  count = mdatBoxes.size();
446  return bParse;
447 }
448 
449 /**
450  * @brief Print ISOBMFF mdat boxes in parsed buffer
451  */
453 {
454  std::vector<Box*> mdatBoxes;
455  bool bParse = false;
456  bParse = getBoxesInternal(&boxes ,Box::MDAT, &mdatBoxes);
457  printBoxesInternal(&mdatBoxes);
458 }
459 
460 /**
461  * @brief Get list of box handle in parsed bufferr using name
462  */
463 bool IsoBmffBuffer::getTypeOfBoxes(const char *name, std::vector<Box*> &stBoxes)
464 {
465  bool bParse = false;
466  bParse = getBoxesInternal(&boxes ,name, &stBoxes);
467  return bParse;
468 }
469 
470 /**
471  * @brief Get list of box handles in a parsed buffer
472  */
474 {
475  return this->chunkedBox;
476 }
477 
478 /**
479  * @brief Get list of box handles in a parsed buffer
480  */
481 std::vector<Box*> *IsoBmffBuffer::getParsedBoxes()
482 {
483  return &this->boxes;
484 }
485 
486 /**
487  * @brief Get box handle in parsed bufferr using name
488  */
489 Box* IsoBmffBuffer::getBox(const char *name, size_t &index)
490 {
491  Box *pBox = NULL;
492  index = -1;
493  for (size_t i = 0; i < boxes.size(); i++)
494  {
495  pBox = boxes.at(i);
496  if (IS_TYPE(pBox->getType(), name))
497  {
498  index = i;
499  break;
500  }
501  pBox = NULL;
502  }
503  return pBox;
504 }
505 
506 /**
507  * @brief Get box handle in parsed bufferr using index
508  */
510 {
511  if(index != -1)
512  return boxes.at(index);
513  else
514  return NULL;
515 }
516 
517 
518 /**
519  * @brief Print ISOBMFF box PTS
520  */
521 void IsoBmffBuffer::printPTSInternal(const std::vector<Box*> *boxes)
522 {
523  for (size_t i = 0; i < boxes->size(); i++)
524  {
525  Box *box = boxes->at(i);
526 
527  if (IS_TYPE(box->getType(), Box::TFDT))
528  {
529  AAMPLOG_WARN("****Base Media Decode Time: %lld", dynamic_cast<TfdtBox *>(box)->getBaseMDT());
530  }
531 
532  if (box->hasChildren())
533  {
535  }
536  }
537 }
538 
539 /**
540  * @brief Get ISOBMFF box Sample Duration
541  */
542 uint64_t IsoBmffBuffer::getSampleDurationInernal(const std::vector<Box*> *boxes)
543 {
544  if(!boxes) return 0;
545 
546  for (int i = boxes->size()-1; i >= 0; i--)
547  {
548  Box *box = boxes->at(i);
549  uint64_t duration = 0;
550  if (IS_TYPE(box->getType(), Box::TRUN))
551  {
552  TrunBox *trunBox = dynamic_cast<TrunBox *>(box);
553  if(trunBox)
554  {
555  //AAMPLOG_WARN("****TRUN BOX SIZE: %d \n", box->getSize());
556  duration = trunBox->getSampleDuration();
557  }
558  //AAMPLOG_WARN("****DURATION: %lld \n", duration);
559  if(duration) return duration;
560  }
561  else if (IS_TYPE(box->getType(), Box::TFHD))
562  {
563  TfhdBox *tfhdBox = dynamic_cast<TfhdBox *>(box);
564  if(tfhdBox)
565  {
566  //AAMPLOG_WARN("****TFHD BOX SIZE: %d \n", box->getSize());
567  duration = tfhdBox->getSampleDuration();
568  }
569  //AAMPLOG_WARN("****DURATION: %lld \n", duration);
570  if(duration) return duration;
571  }
572 
573  if (IS_TYPE(box->getType(), Box::TRAF) && box->hasChildren())
574  {
575  return getSampleDurationInernal(box->getChildren());
576  }
577  }
578  return 0;
579 }
580 
581 /**
582  * @brief Get ISOBMFF box Sample Duration
583  */
584 void IsoBmffBuffer::getSampleDuration(Box *box, uint64_t &fduration)
585 {
586  if (box->hasChildren())
587  {
588  fduration = getSampleDurationInernal(box->getChildren());
589  }
590 }
591 
592 /**
593  * @brief Get ISOBMFF box PTS
594  */
595 uint64_t IsoBmffBuffer::getPtsInternal(const std::vector<Box*> *boxes)
596 {
597  uint64_t retValue = 0;
598  for (size_t i = 0; i < boxes->size(); i++)
599  {
600  Box *box = boxes->at(i);
601 
602  if (IS_TYPE(box->getType(), Box::TFDT))
603  {
604  TfdtBox *tfdtBox = dynamic_cast<TfdtBox *>(box);
605  if(tfdtBox)
606  {
607  AAMPLOG_WARN("****Base Media Decode Time: %lld", tfdtBox->getBaseMDT());
608  retValue = tfdtBox->getBaseMDT();
609  }
610  break;
611  }
612 
613  if (box->hasChildren())
614  {
615  retValue = getPtsInternal(box->getChildren());
616  break;
617  }
618  }
619  return retValue;
620 }
621 
622 /**
623  * @brief Get ISOBMFF box PTS
624  */
625 void IsoBmffBuffer::getPts(Box *box, uint64_t &fpts)
626 {
627  if (box->hasChildren())
628  {
629  fpts = getPtsInternal(box->getChildren());
630  }
631 }
632 
IsoBmffBuffer::getEMSGInfoInternal
bool getEMSGInfoInternal(const std::vector< Box * > *boxes, uint8_t *&message, uint32_t &messageLen, uint8_t *&schemeIdUri, uint8_t *&value, uint64_t &presTime, uint32_t &timeScale, uint32_t &eventDuration, uint32_t &id, bool &foundEmsg)
Get emsg informations.
Definition: isobmffbuffer.cpp:378
TfdtBox::getBaseMDT
uint64_t getBaseMDT()
Get BaseMediaDecodeTime value.
Definition: isobmffbox.cpp:470
EmsgBox::getSchemeIdUri
uint8_t * getSchemeIdUri()
Get schemeIdUri.
Definition: isobmffbox.cpp:630
IsoBmffBuffer::getParsedBoxes
std::vector< Box * > * getParsedBoxes()
Get list of box handles in a parsed buffer.
Definition: isobmffbuffer.cpp:481
IsoBmffBuffer::PrintPTS
void PrintPTS(void)
Print PTS of buffer.
Definition: isobmffbuffer.cpp:257
EmsgBox
Class for ISO BMFF EMSG Box.
Definition: isobmffbox.h:472
IsoBmffBuffer::getSampleDuration
void getSampleDuration(Box *box, uint64_t &fduration)
Get ISOBMFF box Sample Duration.
Definition: isobmffbuffer.cpp:584
ReadUint64
uint64_t ReadUint64(uint8_t *buf)
Utility function to read 8 bytes from a buffer.
Definition: isobmffbox.cpp:54
MdhdBox
Class for ISO BMFF MDHD Box.
Definition: isobmffbox.h:369
IsoBmffBuffer::~IsoBmffBuffer
~IsoBmffBuffer()
IsoBmffBuffer destructor.
Definition: isobmffbuffer.cpp:33
IsoBmffBuffer::printBoxesInternal
void printBoxesInternal(const std::vector< Box * > *boxes)
Print ISOBMFF boxes.
Definition: isobmffbuffer.cpp:316
IsoBmffBuffer::printPTSInternal
void printPTSInternal(const std::vector< Box * > *boxes)
Print ISOBMFF box PTS.
Definition: isobmffbuffer.cpp:521
IsoBmffBuffer::getBoxAtIndex
Box * getBoxAtIndex(size_t index)
Get box handle in parsed bufferr using index.
Definition: isobmffbuffer.cpp:509
Box::constructBox
static Box * constructBox(uint8_t *hdr, uint32_t maxSz, AampLogManager *mLOgObj=NULL, bool correctBoxSize=false, int newTrackId=-1)
Definition: isobmffbox.cpp:161
TfdtBox
Class for ISO BMFF TFDT Box.
Definition: isobmffbox.h:421
Box::hasChildren
virtual bool hasChildren()
To check if box has any child boxes.
Definition: isobmffbox.cpp:98
IsoBmffBuffer::parseMdatBox
bool parseMdatBox(uint8_t *buf, size_t &size)
Get mdat buffer handle and size from parsed buffer.
Definition: isobmffbuffer.cpp:79
IsoBmffBuffer::getTimeScale
bool getTimeScale(uint32_t &timeScale)
Get TimeScale value of buffer.
Definition: isobmffbuffer.cpp:307
EmsgBox::getEventDuration
uint32_t getEventDuration()
Get eventDuration.
Definition: isobmffbox.cpp:566
IsoBmffBuffer::getChunkedfBox
Box * getChunkedfBox() const
Get list of box handles in a parsed buffer.
Definition: isobmffbuffer.cpp:473
EmsgBox::getMessageLen
uint32_t getMessageLen()
Get Message length.
Definition: isobmffbox.cpp:671
Box
Base Class for ISO BMFF Box.
Definition: isobmffbox.h:90
IsoBmffBuffer::destroyBoxes
void destroyBoxes()
Release ISOBMFF boxes parsed.
Definition: isobmffbuffer.cpp:177
EmsgBox::getId
uint32_t getId()
Get id.
Definition: isobmffbox.cpp:582
IsoBmffBuffer::getSampleDurationInernal
uint64_t getSampleDurationInernal(const std::vector< Box * > *boxes)
Get ISOBMFF box Sample Duration.
Definition: isobmffbuffer.cpp:542
Box::getOffset
uint32_t getOffset() const
Get box offset.
Definition: isobmffbox.cpp:90
IsoBmffBuffer::restampPTS
void restampPTS(uint64_t offset, uint64_t basePts, uint8_t *segment, uint32_t bufSz)
Restamp PTS in a buffer.
Definition: isobmffbuffer.cpp:134
EmsgBox::getTimeScale
uint32_t getTimeScale()
Get schemeIdUri.
Definition: isobmffbox.cpp:550
IsoBmffBuffer::parseBoxInternal
bool parseBoxInternal(const std::vector< Box * > *boxes, const char *name, uint8_t *buf, size_t &size)
parse ISOBMFF boxes of a type in a parsed buffer
Definition: isobmffbuffer.cpp:89
IsoBmffBuffer::getMdatBoxCount
bool getMdatBoxCount(size_t &count)
Check mdat buffer count in parsed buffer.
Definition: isobmffbuffer.cpp:440
Box::setOffset
void setOffset(uint32_t os)
Set box's offset from the beginning of the buffer.
Definition: isobmffbox.cpp:82
IsoBmffBuffer::getTypeOfBoxes
bool getTypeOfBoxes(const char *name, std::vector< Box * > &stBoxes)
Get list of box handle in parsed bufferr using name.
Definition: isobmffbuffer.cpp:463
IsoBmffBuffer::setBuffer
void setBuffer(uint8_t *buf, size_t sz)
Set buffer.
Definition: isobmffbuffer.cpp:47
Box::getSize
uint32_t getSize() const
Get box size.
Definition: isobmffbox.cpp:114
IsoBmffBuffer::printMdatBoxes
void printMdatBoxes()
Print ISOBMFF mdat boxes in parsed buffer.
Definition: isobmffbuffer.cpp:452
IsoBmffBuffer::getTrack_id
bool getTrack_id(uint32_t &track_id)
Get track_id from the trak box.
Definition: isobmffbuffer.cpp:265
IsoBmffBuffer::getFirstPTS
bool getFirstPTS(uint64_t &pts)
Get first PTS of buffer.
Definition: isobmffbuffer.cpp:249
IsoBmffBuffer::getPts
void getPts(Box *box, uint64_t &fpts)
Get ISOBMFF box PTS.
Definition: isobmffbuffer.cpp:625
TfhdBox
Class for ISO BMFF TFHD Box.
Definition: isobmffbox.h:725
IsoBmffBuffer::getTimeScaleInternal
bool getTimeScaleInternal(const std::vector< Box * > *boxes, uint32_t &timeScale, bool &foundMdhd)
Get TimeScale value of buffer.
Definition: isobmffbuffer.cpp:273
EmsgBox::getMessage
uint8_t * getMessage()
Get Message.
Definition: isobmffbox.cpp:663
priv_aamp.h
Private functions and types used internally by AAMP.
IsoBmffBuffer::getPtsInternal
uint64_t getPtsInternal(const std::vector< Box * > *boxes)
Get ISOBMFF box PTS.
Definition: isobmffbuffer.cpp:595
IsoBmffBuffer::parseBuffer
bool parseBuffer(bool correctBoxSize=false, int newTrackId=-1)
Parse ISOBMFF boxes from buffer.
Definition: isobmffbuffer.cpp:59
IsoBmffBuffer::getEMSGData
bool getEMSGData(uint8_t *&message, uint32_t &messageLen, uint8_t *&schemeIdUri, uint8_t *&value, uint64_t &presTime, uint32_t &timeScale, uint32_t &eventDuration, uint32_t &id)
Get information from EMSG box.
Definition: isobmffbuffer.cpp:408
AAMPLOG_TRACE
#define AAMPLOG_TRACE(FORMAT,...)
AAMP logging defines, this can be enabled through setLogLevel() as per the need.
Definition: AampLogManager.h:83
isobmffbuffer.h
Header file for ISO Base Media File Format Buffer.
IsoBmffBuffer::getBox
Box * getBox(const char *name, size_t &index)
Get box handle in parsed bufferr using name.
Definition: isobmffbuffer.cpp:489
Box::getChildren
virtual const std::vector< Box * > * getChildren()
Get children of this box.
Definition: isobmffbox.cpp:106
MvhdBox
Class for ISO BMFF MVHD Box.
Definition: isobmffbox.h:318
IsoBmffBuffer::isInitSegment
bool isInitSegment()
Check if buffer is an initialization segment.
Definition: isobmffbuffer.cpp:360
EmsgBox::getValue
uint8_t * getValue()
Get value.
Definition: isobmffbox.cpp:646
TrakBox
Class for ISO BMFF TRAK container.
Definition: isobmffbox.h:260
Box::getType
const char * getType()
Get box type.
Definition: isobmffbox.cpp:122
TrunBox::getSampleDuration
uint64_t getSampleDuration()
Get sampleDuration value.
Definition: isobmffbox.cpp:823
IsoBmffBuffer::printBoxes
void printBoxes()
Print ISOBMFF boxes.
Definition: isobmffbuffer.cpp:352
IsoBmffBuffer::getFirstPTSInternal
bool getFirstPTSInternal(const std::vector< Box * > *boxes, uint64_t &pts)
Get first PTS of buffer.
Definition: isobmffbuffer.cpp:191
IsoBmffBuffer::getBoxSizeInternal
bool getBoxSizeInternal(const std::vector< Box * > *boxes, const char *name, size_t &size)
get ISOBMFF box size of a type
Definition: isobmffbuffer.cpp:117
MvhdBox::getTimeScale
uint32_t getTimeScale()
Get TimeScale value.
Definition: isobmffbox.cpp:360
IsoBmffBuffer::getMdatBoxSize
bool getMdatBoxSize(size_t &size)
Get mdat buffer size.
Definition: isobmffbuffer.cpp:109
IsoBmffBuffer::getTrackIdInternal
bool getTrackIdInternal(const std::vector< Box * > *boxes, uint32_t &track_id)
Get track id from trak box.
Definition: isobmffbuffer.cpp:218
IsoBmffBuffer::getBoxesInternal
bool getBoxesInternal(const std::vector< Box * > *boxes, const char *name, std::vector< Box * > *pBoxes)
get ISOBMFF box list of a type in a parsed buffer
Definition: isobmffbuffer.cpp:417
WriteUint64
void WriteUint64(uint8_t *dst, uint64_t val)
Utility function to write 8 bytes to a buffer.
Definition: isobmffbox.cpp:64
EmsgBox::getPresentationTime
uint64_t getPresentationTime()
Get presentationTime.
Definition: isobmffbox.cpp:614
TrakBox::getTrack_Id
uint32_t getTrack_Id()
track_id getter
Definition: isobmffbox.h:288
TrunBox
Class for ISO BMFF TRUN Box.
Definition: isobmffbox.h:666
MdhdBox::getTimeScale
uint32_t getTimeScale()
Get TimeScale value.
Definition: isobmffbox.cpp:415
TfhdBox::getSampleDuration
uint64_t getSampleDuration()
Get SampleDuration value.
Definition: isobmffbox.cpp:914