diff --git a/util/flv_tag.cpp b/util/flv_tag.cpp index f595bbff..3be1f4e1 100644 --- a/util/flv_tag.cpp +++ b/util/flv_tag.cpp @@ -43,6 +43,31 @@ bool FLV::is_header(char * header){ return true; }//FLV::is_header +/// True if this media type requires init data. +/// Will always return false if the tag type is not 0x08 or 0x09. +/// Returns true for H263, AVC (H264), AAC. +/// \todo Check if MP3 does or does not require init data... +bool FLV::Tag::needsInitData(){ + switch (data[0]){ + case 0x09: + switch (data[11] & 0x0F){ + case 2: return true; break;//H263 requires init data + case 7: return true; break;//AVC requires init data + default: return false; break;//other formats do not + } + break; + case 0x08: + switch (data[11] & 0xF0){ + case 0x20: return false; break;//MP3 does not...? Unsure. + case 0xA0: return true; break;//AAC requires init data + case 0xE0: return false; break;//MP38kHz does not...? + default: return false; break;//other formats do not + } + break; + } + return false;//only audio/video can require init data +} + /// True if current tag is init data for this media type. bool FLV::Tag::isInitData(){ switch (data[0]){ diff --git a/util/flv_tag.h b/util/flv_tag.h index 2ad39673..1d7bbc41 100644 --- a/util/flv_tag.h +++ b/util/flv_tag.h @@ -22,6 +22,7 @@ namespace FLV { int len; ///< Actual length of tag. bool isKeyframe; ///< True if current tag is a video keyframe. char * data; ///< Pointer to tag buffer. + bool needsInitData(); ///< True if this media type requires init data. bool isInitData(); ///< True if current tag is init data for this media type. std::string tagType(); ///< Returns a std::string describing the tag in detail. unsigned int tagTime(); ///< Returns the 32-bit timestamp of this tag.