MistServer
2.5.3-Pro-19-gf5e75b1 ( Generic_64)
|
This class is used to hold, work with and get information about a single FLV tag. More...
#include <flv_tag.h>
Public Member Functions | |
Tag () | |
Constructor for a new, empty, tag. More... | |
Tag () | |
Constructor for a new, empty, tag. More... | |
Tag (const Tag &O) | |
Copy constructor, copies the contents of an existing tag. More... | |
Tag (const Tag &O) | |
Copy constructor, copies the contents of an existing tag. More... | |
Tag (const RTMPStream::Chunk &O) | |
Copy constructor from a RTMP chunk. More... | |
Tag (const RTMPStream::Chunk &O) | |
Copy constructor from a RTMP chunk. More... | |
~Tag () | |
Generic destructor. More... | |
~Tag () | |
Generic destructor. More... | |
bool | ChunkLoader (const RTMPStream::Chunk &O) |
bool | ChunkLoader (const RTMPStream::Chunk &O) |
FLV loader function from chunk. More... | |
bool | DTSCAudioInit (DTSC::Track &audio) |
FLV Audio init data loader function from JSON. More... | |
bool | DTSCAudioInit (DTSC::Track &audio) |
bool | DTSCLoader (DTSC::Packet &packData, DTSC::Track &track) |
bool | DTSCLoader (DTSC::Packet &packData, DTSC::Track &track) |
bool | DTSCMetaInit (DTSC::Meta &M, std::set< long unsigned int > &selTracks) |
bool | DTSCMetaInit (DTSC::Meta &M, std::set< long unsigned int > &selTracks) |
bool | DTSCVideoInit (DTSC::Track &video) |
FLV Video init data loader function from JSON. More... | |
bool | DTSCVideoInit (DTSC::Track &video) |
bool | FileLoader (FILE *f) |
Try to load a tag from a file. More... | |
bool | FileLoader (FILE *f) |
const char * | getAudioCodec () |
Returns a c-string with the audio codec name. More... | |
const char * | getAudioCodec () |
Returns a c-string with the audio codec name. More... | |
char * | getData () |
Returns a pointer to the raw media data for this packet. More... | |
char * | getData () |
unsigned int | getDataLen () |
Returns the length of the raw media data for this packet. More... | |
unsigned int | getDataLen () |
unsigned int | getTrackID () |
Returns 1 for video, 2 for audio, 3 for meta, 0 otherwise. More... | |
unsigned int | getTrackID () |
const char * | getVideoCodec () |
Returns a c-string with the video codec name. More... | |
const char * | getVideoCodec () |
Returns a c-string with the video codec name. More... | |
bool | isInitData () |
True if current tag is init data for this media type. More... | |
bool | isInitData () |
True if current tag is init data for this media type. More... | |
bool | MemLoader (char *D, unsigned int S, unsigned int &P) |
Try to load a tag from a data buffer in memory. More... | |
bool | MemLoader (char *D, unsigned int S, unsigned int &P) |
bool | needsInitData () |
True if this media type requires init data. More... | |
bool | needsInitData () |
True if this media type requires init data. More... | |
int | offset () |
Returns the 24-bit offset of this tag. More... | |
int | offset () |
void | offset (int o) |
void | offset (int o) |
Sets the 24-bit offset of this tag. More... | |
Tag & | operator= (const Tag &O) |
Assignment operator - works exactly like the copy constructor. More... | |
Tag & | operator= (const Tag &O) |
Assignment operator - works exactly like the copy constructor. More... | |
unsigned int | tagTime () |
unsigned int | tagTime () |
Returns the 32-bit timestamp of this tag. More... | |
void | tagTime (unsigned int T) |
Sets the 32-bit timestamp of this tag. More... | |
void | tagTime (unsigned int T) |
std::string | tagType () |
Returns a std::string describing the tag in detail. More... | |
std::string | tagType () |
Returns a std::string describing the tag in detail. More... | |
JSON::Value | toJSON (DTSC::Meta &metadata, AMF::Object &amf_storage, unsigned int reTrack=0) |
JSON::Value | toJSON (DTSC::Meta &metadata, AMF::Object &amf_storage, unsigned int reTrack=0) |
Data Fields | |
char * | data |
Pointer to tag buffer. More... | |
bool | isKeyframe |
True if current tag is a video keyframe. More... | |
int | len |
Actual length of tag. More... | |
Protected Member Functions | |
bool | checkBufferSize () |
Checks if buf is large enough to contain len. More... | |
bool | checkBufferSize () |
bool | FileReadUntil (char *buffer, unsigned int count, unsigned int &sofar, FILE *f) |
Helper function for FLV::FileLoader. More... | |
bool | FileReadUntil (char *buffer, unsigned int count, unsigned int &sofar, FILE *f) |
bool | MemReadUntil (char *buffer, unsigned int count, unsigned int &sofar, char *D, unsigned int S, unsigned int &P) |
bool | MemReadUntil (char *buffer, unsigned int count, unsigned int &sofar, char *D, unsigned int S, unsigned int &P) |
Helper function for FLV::MemLoader. More... | |
bool | Meta_Has (JSON::Value &meta, std::string cat, std::string elem) |
bool | Meta_Has (JSON::Value &meta, std::string cat, std::string elem) |
void | Meta_Put (JSON::Value &meta, std::string cat, std::string elem, std::string val) |
void | Meta_Put (JSON::Value &meta, std::string cat, std::string elem, std::string val) |
void | Meta_Put (JSON::Value &meta, std::string cat, std::string elem, uint64_t val) |
void | Meta_Put (JSON::Value &meta, std::string cat, std::string elem, uint64_t val) |
void | setLen () |
void | setLen () |
Helper function that properly sets the tag length from the internal len variable. More... | |
Protected Attributes | |
int | buf |
Maximum length of buffer space. More... | |
bool | done |
Body reading done? More... | |
unsigned int | sofar |
How many bytes are read sofar? More... | |
This class is used to hold, work with and get information about a single FLV tag.
FLV::Tag::Tag | ( | ) |
Constructor for a new, empty, tag.
The buffer length is initialized to 0, and later automatically increased if neccesary.
FLV::Tag::Tag | ( | const Tag & | O | ) |
Copy constructor, copies the contents of an existing tag.
The buffer length is initialized to the actual size of the tag that is being copied, and later automaticallt increased if neccesary.
FLV::Tag::Tag | ( | const RTMPStream::Chunk & | O | ) |
Copy constructor from a RTMP chunk.
Copies the contents of a RTMP chunk into a valid FLV tag. Exactly the same as making a chunk by through the default (empty) constructor and then calling FLV::Tag::ChunkLoader with the chunk as argument.
FLV::Tag::~Tag | ( | ) |
Generic destructor.
Generic destructor that frees the allocated memory in the internal data variable, if any.
FLV::Tag::Tag | ( | ) |
Constructor for a new, empty, tag.
FLV::Tag::Tag | ( | const Tag & | O | ) |
Copy constructor, copies the contents of an existing tag.
FLV::Tag::Tag | ( | const RTMPStream::Chunk & | O | ) |
Copy constructor from a RTMP chunk.
FLV::Tag::~Tag | ( | ) |
Generic destructor.
|
protected |
Checks if buf is large enough to contain len.
Attempts to resize data buffer if not/
|
protected |
bool FLV::Tag::ChunkLoader | ( | const RTMPStream::Chunk & | O | ) |
bool FLV::Tag::ChunkLoader | ( | const RTMPStream::Chunk & | O | ) |
bool FLV::Tag::DTSCAudioInit | ( | DTSC::Track & | audio | ) |
bool FLV::Tag::DTSCAudioInit | ( | DTSC::Track & | audio | ) |
bool FLV::Tag::DTSCLoader | ( | DTSC::Packet & | packData, |
DTSC::Track & | track | ||
) |
bool FLV::Tag::DTSCLoader | ( | DTSC::Packet & | packData, |
DTSC::Track & | track | ||
) |
bool FLV::Tag::DTSCMetaInit | ( | DTSC::Meta & | M, |
std::set< long unsigned int > & | selTracks | ||
) |
bool FLV::Tag::DTSCMetaInit | ( | DTSC::Meta & | M, |
std::set< long unsigned int > & | selTracks | ||
) |
bool FLV::Tag::DTSCVideoInit | ( | DTSC::Track & | video | ) |
bool FLV::Tag::DTSCVideoInit | ( | DTSC::Track & | video | ) |
bool FLV::Tag::FileLoader | ( | FILE * | f | ) |
Try to load a tag from a file.
This is a stateful function - if fed incorrect data, it will most likely never return true again! While this function returns false, the Tag might not contain valid data.
f | The file to read from. |
bool FLV::Tag::FileLoader | ( | FILE * | f | ) |
|
protected |
Helper function for FLV::FileLoader.
This function will try to read count bytes from file f into buffer. This function should be called repeatedly until true.
buffer | The target buffer. |
count | Amount of bytes to read. |
sofar | Current amount read. |
f | File to read from. |
|
protected |
const char * FLV::Tag::getAudioCodec | ( | ) |
Returns a c-string with the audio codec name.
const char* FLV::Tag::getAudioCodec | ( | ) |
Returns a c-string with the audio codec name.
char * FLV::Tag::getData | ( | ) |
Returns a pointer to the raw media data for this packet.
char* FLV::Tag::getData | ( | ) |
unsigned int FLV::Tag::getDataLen | ( | ) |
unsigned int FLV::Tag::getDataLen | ( | ) |
Returns the length of the raw media data for this packet.
unsigned int FLV::Tag::getTrackID | ( | ) |
Returns 1 for video, 2 for audio, 3 for meta, 0 otherwise.
unsigned int FLV::Tag::getTrackID | ( | ) |
const char* FLV::Tag::getVideoCodec | ( | ) |
Returns a c-string with the video codec name.
const char * FLV::Tag::getVideoCodec | ( | ) |
Returns a c-string with the video codec name.
bool FLV::Tag::isInitData | ( | ) |
True if current tag is init data for this media type.
bool FLV::Tag::isInitData | ( | ) |
True if current tag is init data for this media type.
bool FLV::Tag::MemLoader | ( | char * | D, |
unsigned int | S, | ||
unsigned int & | P | ||
) |
Try to load a tag from a data buffer in memory.
This is a stateful function - if fed incorrect data, it will most likely never return true again! While this function returns false, the Tag might not contain valid data.
D | The location of the data buffer. |
S | The size of the data buffer. |
P | The current position in the data buffer. Will be updated to reflect new position. |
bool FLV::Tag::MemLoader | ( | char * | D, |
unsigned int | S, | ||
unsigned int & | P | ||
) |
|
protected |
Helper function for FLV::MemLoader.
This function will try to read count bytes from data buffer D into buffer. This function should be called repeatedly until true. P and sofar are not the same value, because D may not start with the current tag.
buffer | The target buffer. |
count | Amount of bytes to read. |
sofar | Current amount read. |
D | The location of the data buffer. |
S | The size of the data buffer. |
P | The current position in the data buffer. Will be updated to reflect new position. |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
bool FLV::Tag::needsInitData | ( | ) |
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.
bool FLV::Tag::needsInitData | ( | ) |
True if this media type requires init data.
int FLV::Tag::offset | ( | ) |
Returns the 24-bit offset of this tag.
Returns 0 if the tag isn't H264
int FLV::Tag::offset | ( | ) |
void FLV::Tag::offset | ( | int | o | ) |
Sets the 24-bit offset of this tag.
Ignored if the tag isn't H264
void FLV::Tag::offset | ( | int | o | ) |
Assignment operator - works exactly like the copy constructor.
Assignment operator - works exactly like the copy constructor.
This operator checks for self-assignment.
|
protected |
|
protected |
Helper function that properly sets the tag length from the internal len variable.
unsigned int FLV::Tag::tagTime | ( | ) |
unsigned int FLV::Tag::tagTime | ( | ) |
Returns the 32-bit timestamp of this tag.
void FLV::Tag::tagTime | ( | unsigned int | T | ) |
void FLV::Tag::tagTime | ( | unsigned int | T | ) |
Sets the 32-bit timestamp of this tag.
std::string FLV::Tag::tagType | ( | ) |
Returns a std::string describing the tag in detail.
The string includes information about whether the tag is audio, video or metadata, what encoding is used, and the details of the encoding itself.
std::string FLV::Tag::tagType | ( | ) |
Returns a std::string describing the tag in detail.
JSON::Value FLV::Tag::toJSON | ( | DTSC::Meta & | metadata, |
AMF::Object & | amf_storage, | ||
unsigned int | reTrack = 0 |
||
) |
JSON::Value FLV::Tag::toJSON | ( | DTSC::Meta & | metadata, |
AMF::Object & | amf_storage, | ||
unsigned int | reTrack = 0 |
||
) |
|
protected |
Maximum length of buffer space.
char * FLV::Tag::data |
Pointer to tag buffer.
|
protected |
Body reading done?
bool FLV::Tag::isKeyframe |
True if current tag is a video keyframe.
int FLV::Tag::len |
Actual length of tag.
|
protected |
How many bytes are read sofar?