1
0

FLVStreamHeader.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include "FLVStreamHeader.h"
  2. #include "FLVUtil.h"
  3. /*
  4. (c) 2006 Nullsoft, Inc.
  5. Author: Ben Allison [email protected]
  6. */
  7. /*
  8. PreviousTagSize - uint32 - total size of previous tag, presumably for stream continuity checking. big endian
  9. Type - uint8 - what does this frame contain? 0x12=meta, 0x8=audio, 0x9=video
  10. BodyLength - uint24 - size of the data following this header. big endian
  11. Timestamp - uint24 - timestamp (milliseconds). big endian
  12. Timestamp High - uint8 - high 8 bits of timestamp (to form 32bit timestamp)
  13. Stream ID - uint24 - always zero
  14. */
  15. bool FLVStreamHeader::Read(uint8_t *data, size_t size)
  16. {
  17. if (size < 15)
  18. return false; // header size too small
  19. previousSize = FLV::Read32(&data[0]);
  20. type = data[4];
  21. dataSize = FLV::Read24(&data[5]);
  22. timestamp = FLV::Read24(&data[8]);
  23. uint8_t timestampHigh = FLV::Read8(&data[11]);
  24. timestamp |= (timestampHigh << 24);
  25. streamID = FLV::Read24(&data[12]);
  26. if (streamID != 0)
  27. return false;
  28. return true;
  29. }