RTSP live timestamp syncing implemented, syncs with RTMP and/or JSON inputs

This commit is contained in:
Thulinma 2018-06-29 11:34:57 +02:00
parent ee195f0089
commit 75501c54f7
2 changed files with 23 additions and 1 deletions

View file

@ -18,11 +18,31 @@ namespace Mist{
void insertPacket(const DTSC::Packet &pkt){classPointer->incomingPacket(pkt);} void insertPacket(const DTSC::Packet &pkt){classPointer->incomingPacket(pkt);}
/// Takes incoming packets and buffers them. /// Takes incoming packets and buffers them.
void OutRTSP::incomingPacket(const DTSC::Packet &pkt){bufferLivePacket(pkt);} void OutRTSP::incomingPacket(const DTSC::Packet &pkt){
if (!bootMsOffset){
if (myMeta.bootMsOffset){
bootMsOffset = myMeta.bootMsOffset;
packetOffset = (Util::bootMS() - pkt.getTime()) - bootMsOffset;
}else{
bootMsOffset = Util::bootMS() - pkt.getTime();
packetOffset = 0;
}
}
/// \TODO Make this less inefficient. Seriously. Maybe use DTSC::RetimedPacket by extending with bmo functionality...?
static DTSC::Packet newPkt;
char * pktData;
unsigned int pktDataLen;
pkt.getString("data", pktData, pktDataLen);
newPkt.genericFill(pkt.getTime() + packetOffset, pkt.getInt("offset"), pkt.getTrackId(), pktData, pktDataLen, 0, pkt.getFlag("keyframe"), bootMsOffset);
bufferLivePacket(newPkt);
//bufferLivePacket(DTSC::RetimedPacket(pkt.getTime() + packetOffset, pkt));
}
OutRTSP::OutRTSP(Socket::Connection &myConn) : Output(myConn){ OutRTSP::OutRTSP(Socket::Connection &myConn) : Output(myConn){
connectedAt = Util::epoch() + 2208988800ll; connectedAt = Util::epoch() + 2208988800ll;
pausepoint = 0; pausepoint = 0;
bootMsOffset = 0;
packetOffset = 0;
setBlocking(false); setBlocking(false);
maxSkipAhead = 0; maxSkipAhead = 0;
expectTCP = false; expectTCP = false;

View file

@ -26,6 +26,8 @@ namespace Mist{
HTTP::Parser HTTP_R, HTTP_S; HTTP::Parser HTTP_R, HTTP_S;
std::string source; std::string source;
uint64_t lastTimeSync; uint64_t lastTimeSync;
int64_t bootMsOffset;
int64_t packetOffset;
bool expectTCP; bool expectTCP;
bool checkPort; bool checkPort;
bool handleTCP(); bool handleTCP();