MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
input_mp4.h
Go to the documentation of this file.
1 #include "input.h"
2 #include <mist/dtsc.h>
3 #include <mist/mp4.h>
4 #include <mist/mp4_generic.h>
5 namespace Mist {
6  class mp4PartTime{
7  public:
8  mp4PartTime() : time(0), offset(0), trackID(0), bpos(0), size(0), index(0) {}
9  bool operator < (const mp4PartTime & rhs) const {
10  if (time < rhs.time){
11  return true;
12  }else{
13  if (time == rhs.time){
14  if (trackID < rhs.trackID){
15  return true;
16  }else{
17  if (trackID == rhs.trackID && bpos < rhs.bpos){
18  return true;
19  }
20  }
21  }
22  }
23  return false;
24  }
25  long long unsigned int time;
26  long long unsigned int offset;
27  unsigned int trackID;
28  long long unsigned int bpos;
29  unsigned int size;
30  long unsigned int index;
31  };
32 
33  struct mp4PartBpos{
34  bool operator < (const mp4PartBpos & rhs) const {
35  if (time < rhs.time){
36  return true;
37  }else{
38  if (time == rhs.time){
39  if (trackID < rhs.trackID){
40  return true;
41  }else{
42  if (trackID == rhs.trackID && bpos < rhs.bpos){
43  return true;
44  }
45  }
46  }
47  }
48  return false;
49  }
50  long long unsigned int time;
51  long long unsigned int trackID;
52  long long unsigned int bpos;
53  long long unsigned int size;
54  long long unsigned int stcoNr;
55  long unsigned int timeOffset;
56  bool keyframe;
57  };
58 
60  public:
62  void read(MP4::TRAK & trakBox);
66  bool hasCTTS;
69  long unsigned int timeScale;
70  void getPart(long unsigned int index, long long unsigned int & offset,unsigned int& size, long long unsigned int & timestamp, long long unsigned int & timeOffset);
71  long unsigned int size();
72  private:
74  //next variables are needed for the stsc/stco loop
75  long long unsigned int stscStart;
76  long long unsigned int sampleIndex;
77  //next variables are needed for the stts loop
78  long long unsigned deltaIndex;
79  long long unsigned deltaPos;
80  long long unsigned deltaTotal;
81  //for CTTS box loop
82  long long unsigned offsetIndex;
83  long long unsigned offsetPos;
84  };
85 
86  class inputMP4 : public Input {
87  public:
88  inputMP4(Util::Config * cfg);
89  ~inputMP4();
90  protected:
91  //Private Functions
92  bool setup();
93  bool readHeader();
94  void getNext(bool smart = true);
95  void seek(int seekTime);
96  void trackSelect(std::string trackSpec);
97 
98  FILE * inFile;
99 
100  std::map<unsigned int, mp4TrackHeader> headerData;
101  std::set<mp4PartTime> curPositions;
102 
103  //remember last seeked keyframe;
104  std::map <unsigned int, unsigned int> nextKeyframe;
105 
106  //these next two variables keep a buffer for reading from filepointer inFile;
107  unsigned long long int malSize;
108  char* data;
109  };
110 }
111 
long long unsigned int sampleIndex
Definition: input_mp4.h:76
long long unsigned int bpos
Definition: input_mp4.h:28
std::set< mp4PartTime > curPositions
Definition: input_mp4.h:101
MP4::STSZ stszBox
Definition: input_mp4.h:64
long long unsigned int size
Definition: input_mp4.h:53
Mist::inputMP4 mistIn
Definition: input_mp4.h:112
long long unsigned offsetIndex
Index in CTTS box.
Definition: input_mp4.h:82
MP4::STTS sttsBox
Definition: input_mp4.h:65
long long unsigned offsetPos
Sample counter for CTTS box.
Definition: input_mp4.h:83
Definition: mp4_generic.h:529
Definition: input_mp4.h:6
long long unsigned int offset
Definition: input_mp4.h:26
bool operator<(const mp4PartTime &rhs) const
Definition: input_mp4.h:9
MP4::CTTS cttsBox
Definition: input_mp4.h:67
MP4::STCO stcoBox
Definition: input_mp4.h:63
long long unsigned deltaTotal
Total timestamp for STTS box.
Definition: input_mp4.h:80
Definition: input_mp4.h:59
Definition: mp4_generic.h:592
std::map< unsigned int, mp4TrackHeader > headerData
Definition: input_mp4.h:100
Definition: input.h:19
Recording to file.
Definition: input.cpp:13
Definition: mp4_generic.h:572
unsigned long long int malSize
Definition: input_mp4.h:107
Definition: input_mp4.h:86
long long unsigned int stscStart
Definition: input_mp4.h:75
long long unsigned int bpos
Definition: input_mp4.h:52
long long unsigned deltaIndex
Index in STTS box.
Definition: input_mp4.h:78
unsigned int size
Definition: input_mp4.h:29
long unsigned int index
Definition: input_mp4.h:30
Definition: input_mp4.h:33
long unsigned int timeOffset
Definition: input_mp4.h:55
Deals with parsing configuration from commandline options.
Definition: config.h:18
long unsigned int timeScale
Definition: input_mp4.h:69
MP4::STSC stscBox
Definition: input_mp4.h:68
Definition: mp4_generic.h:544
mp4PartTime()
Definition: input_mp4.h:8
long long unsigned int time
Definition: input_mp4.h:50
long long unsigned int stcoNr
Definition: input_mp4.h:54
std::map< unsigned int, unsigned int > nextKeyframe
Definition: input_mp4.h:104
Definition: mp4_generic.h:562
bool keyframe
Definition: input_mp4.h:56
bool hasCTTS
Definition: input_mp4.h:66
FILE * inFile
Definition: input_mp4.h:98
long long unsigned int time
Definition: input_mp4.h:25
Definition: mp4_generic.h:306
long long unsigned int trackID
Definition: input_mp4.h:51
char * data
Definition: input_mp4.h:108
long long unsigned deltaPos
Sample counter for STTS box.
Definition: input_mp4.h:79
unsigned int trackID
Definition: input_mp4.h:27
bool initialised
Definition: input_mp4.h:73