MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
flv_tag.h
Go to the documentation of this file.
1 
4 #pragma once
5 #include "socket.h"
6 #include "dtsc.h"
7 #include "json.h"
8 #include "amf.h"
9 #include <string>
10 
11 
12 //forward declaration of RTMPStream::Chunk to avoid circular dependencies.
13 namespace RTMPStream {
14  class Chunk;
15 }
16 
18 namespace FLV {
19  //variables
20  extern char Header[13];
21  extern bool Parse_Error;
22  extern std::string Error_Str;
23 
24  //functions
25  bool check_header(char * header);
26  bool is_header(char * header);
27 
29  class Tag {
30  public:
31  int len;
32  bool isKeyframe;
33  char * data;
34  bool needsInitData();
35  bool isInitData();
36  const char * getAudioCodec();
37  const char * getVideoCodec();
38  std::string tagType();
39  unsigned int tagTime();
40  void tagTime(unsigned int T);
41  int offset();
42  void offset(int o);
43  Tag();
44  Tag(const Tag & O);
45  Tag & operator=(const Tag & O);
46  Tag(const RTMPStream::Chunk & O);
47  ~Tag();
48  //loader functions
49  bool ChunkLoader(const RTMPStream::Chunk & O);
50  bool DTSCLoader(DTSC::Packet & packData, DTSC::Track & track);
51  bool DTSCVideoInit(DTSC::Track & video);
52  bool DTSCAudioInit(DTSC::Track & audio);
53  bool DTSCMetaInit(DTSC::Meta & M, std::set<long unsigned int> & selTracks);
54  JSON::Value toJSON(DTSC::Meta & metadata, AMF::Object & amf_storage, unsigned int reTrack = 0);
55  bool MemLoader(char * D, unsigned int S, unsigned int & P);
56  bool FileLoader(FILE * f);
57  unsigned int getTrackID();
58  char * getData();
59  unsigned int getDataLen();
60  protected:
61  int buf;
62  bool done;
63  unsigned int sofar;
64  void setLen();
65  bool checkBufferSize();
66  //loader helper functions
67  bool MemReadUntil(char * buffer, unsigned int count, unsigned int & sofar, char * D, unsigned int S, unsigned int & P);
68  bool FileReadUntil(char * buffer, unsigned int count, unsigned int & sofar, FILE * f);
69  //JSON writer helpers
70  void Meta_Put(JSON::Value & meta, std::string cat, std::string elem, std::string val);
71  void Meta_Put(JSON::Value & meta, std::string cat, std::string elem, uint64_t val);
72  bool Meta_Has(JSON::Value & meta, std::string cat, std::string elem);
73  };
74 //Tag
75 
76 }//FLV namespace
Class for storage of meta data.
Definition: dtsc.h:337
Class for storage of track data.
Definition: dtsc.h:285
bool Parse_Error
This variable is set to true if a problem is encountered while parsing the FLV.
Definition: flv_tag.h:21
This class is used to hold, work with and get information about a single FLV tag. ...
Definition: flv_tag.h:29
A JSON::Value is either a string or an integer, but may also be an object, array or null...
Definition: json.h:21
bool done
Body reading done?
Definition: flv_tag.h:62
std::string Error_Str
This variable is set if a problem is encountered while parsing the FLV.
Definition: flv_tag.h:22
bool check_header(char *header)
Checks a FLV Header for validness.
Definition: flv_tag.cpp:28
int buf
Maximum length of buffer space.
Definition: flv_tag.h:61
bool isKeyframe
True if current tag is a video keyframe.
Definition: flv_tag.h:32
char * data
Pointer to tag buffer.
Definition: flv_tag.h:33
bool is_header(char *header)
Checks the first 3 bytes for the string "FLV".
Definition: flv_tag.cpp:45
Recursive class that holds AMF0 objects.
Definition: amf.h:55
int len
Actual length of tag.
Definition: flv_tag.h:31
This namespace holds all FLV-parsing related functionality.
Definition: flv_tag.h:18
Holds a single RTMP chunk, either send or receive direction.
Definition: rtmpchunks.h:33
char Header[13]
Holds the last FLV header parsed.
Definition: flv_tag.h:20
unsigned int sofar
How many bytes are read sofar?
Definition: flv_tag.h:63
Contains all functions and classes needed for RTMP connections.
Definition: flv_tag.h:13
DTSC::Packets can currently be three types: DTSC_HEAD packets are the "DTSC" header string...
Definition: dtsc.h:100