Fixed timing issues in ts
This commit is contained in:
parent
9587f3b708
commit
4811a7e065
1 changed files with 28 additions and 6 deletions
|
@ -387,7 +387,12 @@ namespace TS {
|
||||||
/// \param PTS The timestamp of the frame.
|
/// \param PTS The timestamp of the frame.
|
||||||
/// \param offset The timestamp of the frame.
|
/// \param offset The timestamp of the frame.
|
||||||
void Packet::PESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset) {
|
void Packet::PESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset) {
|
||||||
strBuf.append("\000\000\001\340\000\000\204", 7);
|
len += (offset ? 13 : 8);
|
||||||
|
len = 0;
|
||||||
|
strBuf.append("\000\000\001\340", 4);
|
||||||
|
strBuf += (char)((len >> 8) & 0xFF);
|
||||||
|
strBuf += (char)(len & 0xFF);
|
||||||
|
strBuf.append("\204", 1);
|
||||||
strBuf += (char)(offset ? 0xC0 : 0x80); //PTS/DTS + Flags
|
strBuf += (char)(offset ? 0xC0 : 0x80); //PTS/DTS + Flags
|
||||||
strBuf += (char)(offset ? 0x0A : 0x05); //PESHeaderDataLength
|
strBuf += (char)(offset ? 0x0A : 0x05); //PESHeaderDataLength
|
||||||
encodePESTimestamp(strBuf, (offset ? 0x30 : 0x20), PTS + offset);
|
encodePESTimestamp(strBuf, (offset ? 0x30 : 0x20), PTS + offset);
|
||||||
|
@ -401,9 +406,14 @@ namespace TS {
|
||||||
/// \param toSend Data that is to be send, will be modified.
|
/// \param toSend Data that is to be send, will be modified.
|
||||||
/// \param PTS The timestamp of the frame.
|
/// \param PTS The timestamp of the frame.
|
||||||
void Packet::PESVideoLeadIn(std::string & toSend, unsigned long long PTS, unsigned long long offset) {
|
void Packet::PESVideoLeadIn(std::string & toSend, unsigned long long PTS, unsigned long long offset) {
|
||||||
|
unsigned int len = toSend.size() + (offset ? 13 : 8);
|
||||||
|
len = 0;
|
||||||
std::string tmpStr;
|
std::string tmpStr;
|
||||||
tmpStr.reserve(25);
|
tmpStr.reserve(25);
|
||||||
tmpStr.append("\000\000\001\340\000\000\204", 7);
|
tmpStr.append("\000\000\001\340", 4);
|
||||||
|
tmpStr += (char)((len >> 8) & 0xFF);
|
||||||
|
tmpStr += (char)(len & 0xFF);
|
||||||
|
tmpStr.append("\204", 1);
|
||||||
tmpStr += (char)(offset ? 0xC0 : 0x80); //PTS/DTS + Flags
|
tmpStr += (char)(offset ? 0xC0 : 0x80); //PTS/DTS + Flags
|
||||||
tmpStr += (char)(offset ? 0x0A : 0x05); //PESHeaderDataLength
|
tmpStr += (char)(offset ? 0x0A : 0x05); //PESHeaderDataLength
|
||||||
encodePESTimestamp(tmpStr, (offset ? 0x30 : 0x20), PTS + offset);
|
encodePESTimestamp(tmpStr, (offset ? 0x30 : 0x20), PTS + offset);
|
||||||
|
@ -418,9 +428,21 @@ namespace TS {
|
||||||
/// \param len The length of this frame.
|
/// \param len The length of this frame.
|
||||||
/// \param PTS The timestamp of the frame.
|
/// \param PTS The timestamp of the frame.
|
||||||
std::string & Packet::getPESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset) {
|
std::string & Packet::getPESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset) {
|
||||||
|
len += (offset ? 13 : 8);
|
||||||
|
len = 0;
|
||||||
static std::string tmpStr;
|
static std::string tmpStr;
|
||||||
tmpStr.clear();
|
tmpStr.clear();
|
||||||
PESVideoLeadIn(tmpStr, PTS, offset);
|
tmpStr.reserve(25);
|
||||||
|
tmpStr.append("\000\000\001\340", 4);
|
||||||
|
tmpStr += (char)((len >> 8) & 0xFF);
|
||||||
|
tmpStr += (char)(len & 0xFF);
|
||||||
|
tmpStr.append("\204", 1);
|
||||||
|
tmpStr += (char)(offset ? 0xC0 : 0x80); //PTS/DTS + Flags
|
||||||
|
tmpStr += (char)(offset ? 0x0A : 0x05); //PESHeaderDataLength
|
||||||
|
encodePESTimestamp(tmpStr, (offset ? 0x30 : 0x20), PTS + offset);
|
||||||
|
if (offset){
|
||||||
|
encodePESTimestamp(tmpStr, 0x10, PTS);
|
||||||
|
}
|
||||||
return tmpStr;
|
return tmpStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +456,7 @@ namespace TS {
|
||||||
strBuf += (char)((len & 0xFF00) >> 8); //PES PacketLength
|
strBuf += (char)((len & 0xFF00) >> 8); //PES PacketLength
|
||||||
strBuf += (char)(len & 0x00FF); //PES PacketLength (Cont)
|
strBuf += (char)(len & 0x00FF); //PES PacketLength (Cont)
|
||||||
strBuf.append("\204\200\005", 3);
|
strBuf.append("\204\200\005", 3);
|
||||||
encodePESTimestamp(strBuf, 0x30, PTS);
|
encodePESTimestamp(strBuf, 0x20, PTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -450,7 +472,7 @@ namespace TS {
|
||||||
tmpStr += (char)((len & 0xFF00) >> 8); //PES PacketLength
|
tmpStr += (char)((len & 0xFF00) >> 8); //PES PacketLength
|
||||||
tmpStr += (char)(len & 0x00FF); //PES PacketLength (Cont)
|
tmpStr += (char)(len & 0x00FF); //PES PacketLength (Cont)
|
||||||
tmpStr.append("\204\200\005", 3);
|
tmpStr.append("\204\200\005", 3);
|
||||||
encodePESTimestamp(tmpStr, 0x30, PTS);
|
encodePESTimestamp(tmpStr, 0x20, PTS);
|
||||||
toSend.insert(0, tmpStr);
|
toSend.insert(0, tmpStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +489,7 @@ namespace TS {
|
||||||
tmpStr += (char)((len & 0xFF00) >> 8); //PES PacketLength
|
tmpStr += (char)((len & 0xFF00) >> 8); //PES PacketLength
|
||||||
tmpStr += (char)(len & 0x00FF); //PES PacketLength (Cont)
|
tmpStr += (char)(len & 0x00FF); //PES PacketLength (Cont)
|
||||||
tmpStr.append("\204\200\005", 3);
|
tmpStr.append("\204\200\005", 3);
|
||||||
encodePESTimestamp(tmpStr, 0x30, PTS);
|
encodePESTimestamp(tmpStr, 0x20, PTS);
|
||||||
return tmpStr;
|
return tmpStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue