MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
output_progressive_mp4.h
Go to the documentation of this file.
1 #include "output_http.h"
2 #include <mist/http_parser.h>
3 #include <list>
4 
5 namespace Mist {
6  struct keyPart{
7  public:
8  bool operator < (const keyPart& rhs) const {
9  if (time < rhs.time){
10  return true;
11  }
12  if (time == rhs.time){
13  if (trackID < rhs.trackID){
14  return true;
15  }
16  if (trackID == rhs.trackID){
17  return index < rhs.index;
18  }
19  }
20  return false;
21  }
22  long unsigned int trackID;
23  long unsigned int size;
24  long long unsigned int time;
25  long long unsigned int endTime;
26  long long unsigned int byteOffset;//added for MP4 fragmented
27  long int timeOffset;//added for MP4 fragmented
28  long unsigned int duration;//added for MP4 fragmented
29  long unsigned int index;
30  };
31 
32  struct fragSet{
33  long unsigned int firstPart;
34  long unsigned int lastPart;
35  long long unsigned int firstTime;
36  long long unsigned int lastTime;
37  };
38  class OutProgressiveMP4 : public HTTPOutput {
39  public:
42  static void init(Util::Config * cfg);
43  void parseRange(std::string header, long long & byteStart, long long & byteEnd, long long & seekPoint, unsigned int headerSize);
44  std::string DTSCMeta2MP4Header(long long & size, int fragmented = 0);
45  //int fragmented values: 0 = non fragmented stream, 1 = frag stream main header
46  void buildFragment(int fragNum);//this builds the structure of the fragment header for fragment number fragNum, and stores it in a member variable
47  void sendFragmentHeader(int fragNum);//this builds the moof box for fragmented MP4
48  void findSeekPoint(long long byteStart, long long & seekPoint, unsigned int headerSize);
49  void onHTTP();
50  void sendNext();
51  void sendHeader();
52  protected:
53  long long fileSize;
54  long long byteStart;
55  long long byteEnd;
56  long long leftOver;
57  long long currPos;
58  long long seekPoint;
59 
60  //variables for standard MP4
61  std::set <keyPart> sortSet;//needed for unfragmented MP4, remembers the order of keyparts
62 
63  //functions for fragmented MP4
64  void buildTrafPart();
65  void setvidTrack();//searching for the current vid track
66 
67  //variables for fragmented
68  int fragSeqNum;//the sequence number of the next keyframe/fragment when producing fragmented MP4's
69  long unsigned int vidTrack;//the video track we use as fragmenting base
70  long long unsigned int realBaseOffset;//base offset for every moof packet
71  //from sendnext
72  long unsigned int partListSent;//parts of current fragSet sent
73  long unsigned int partListLength;//amount of packets in current fragment
74  long int fragKeyNumberShift;//the difference between the first fragment Number and the first keyframe number
75 
76 
77  bool sending3GP;
78  long long unsigned estimateFileSize();
79 
80  //This is a dirty solution... but it prevents copying and copying and copying again
81  std::map<long unsigned int, fragSet> currentPartSet;
82  };
83 }
84 
long unsigned int firstPart
Definition: output_progressive_mp4.h:33
long unsigned int index
Definition: output_progressive_mp4.h:29
long long unsigned int endTime
Definition: output_progressive_mp4.h:25
long unsigned int lastPart
Definition: output_progressive_mp4.h:34
long long currPos
Definition: output_progressive_mp4.h:57
Definition: output_progressive_mp4.h:38
long unsigned int trackID
Definition: output_progressive_mp4.h:22
long long leftOver
Definition: output_progressive_mp4.h:56
long long unsigned int firstTime
Definition: output_progressive_mp4.h:35
std::map< long unsigned int, fragSet > currentPartSet
Definition: output_progressive_mp4.h:81
long long fileSize
Definition: output_progressive_mp4.h:53
long long unsigned int lastTime
Definition: output_progressive_mp4.h:36
Recording to file.
Definition: input.cpp:13
long long unsigned int realBaseOffset
Definition: output_progressive_mp4.h:70
Definition: output_progressive_mp4.h:32
bool sending3GP
Definition: output_progressive_mp4.h:77
long unsigned int vidTrack
Definition: output_progressive_mp4.h:69
std::set< keyPart > sortSet
Definition: output_progressive_mp4.h:61
long int fragKeyNumberShift
Definition: output_progressive_mp4.h:74
long long unsigned int time
Definition: output_progressive_mp4.h:24
long unsigned int size
Definition: output_progressive_mp4.h:23
Deals with parsing configuration from commandline options.
Definition: config.h:18
long long unsigned int byteOffset
Definition: output_progressive_mp4.h:26
int fragSeqNum
Definition: output_progressive_mp4.h:68
Definition: output_progressive_mp4.h:6
long unsigned int partListLength
Definition: output_progressive_mp4.h:73
function init(plot)
Definition: jquery.flot.time.min.js:1
Definition: output_http.h:8
long unsigned int duration
Definition: output_progressive_mp4.h:28
long int timeOffset
Definition: output_progressive_mp4.h:27
Mist::OutProgressiveMP4 mistOut
Definition: output_progressive_mp4.h:85
long unsigned int partListSent
Definition: output_progressive_mp4.h:72
long long byteEnd
Definition: output_progressive_mp4.h:55
long long seekPoint
Definition: output_progressive_mp4.h:58
bool operator<(const keyPart &rhs) const
Definition: output_progressive_mp4.h:8
This class is for easy communicating through sockets, either TCP or Unix.
Definition: socket.h:47
long long byteStart
Definition: output_progressive_mp4.h:54