diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Input/in_flv/FLVHeader.cpp | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Plugins/Input/in_flv/FLVHeader.cpp')
-rw-r--r-- | Src/Plugins/Input/in_flv/FLVHeader.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Src/Plugins/Input/in_flv/FLVHeader.cpp b/Src/Plugins/Input/in_flv/FLVHeader.cpp new file mode 100644 index 00000000..3b5bc1ee --- /dev/null +++ b/Src/Plugins/Input/in_flv/FLVHeader.cpp @@ -0,0 +1,41 @@ +#include "FLVHeader.h" +#include "FLVUtil.h" +/* +(c) 2006 Nullsoft, Inc. +Author: Ben Allison benski@nullsoft.com +*/ + +#define FLV_BITMASK_AUDIO 0x4 +#define FLV_BITMASK_VIDEO 0x1 + +/* +FLV Header spec + +Signature - uint8[3] - must equal "FLV" +Version - uint8 - only known version is 1 +Flags - uint8 - bitmask, 4 is audio, 1 is video +Offset - uint32 - total size of header (9), big endian +*/ + + + + +bool FLVHeader::Read(uint8_t *data, size_t size) +{ + if (size < 9) + return false; // too small to be an FLV header + + if (data[0] != 'F' || data[1] != 'L' || data[2] != 'V') + return false; // invalid signature + + version = data[3]; + + hasAudio = !!(data[4] & FLV_BITMASK_AUDIO); + hasVideo = data[4] & FLV_BITMASK_VIDEO; + + headerSize = FLV::Read32(&data[5]); + if (headerSize != 9) + return false; + + return true; +}
\ No newline at end of file |