Implemented ES_Rate in PES
This commit is contained in:
parent
1a4c62e763
commit
133a8f36da
3 changed files with 32 additions and 10 deletions
|
@ -487,8 +487,13 @@ namespace TS {
|
||||||
/// Prepends the lead-in to variable toSend, assumes toSend's length is all other data.
|
/// Prepends the lead-in to variable toSend, assumes toSend's length is all other data.
|
||||||
/// \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, bool isAligned) {
|
std::string & Packet::getPESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset, bool isAligned, uint64_t bps) {
|
||||||
len += (offset ? 13 : 8);
|
len += (offset ? 13 : 8);
|
||||||
|
if (bps >= 50){
|
||||||
|
len += 3;
|
||||||
|
}else{
|
||||||
|
bps = 0;
|
||||||
|
}
|
||||||
static std::string tmpStr;
|
static std::string tmpStr;
|
||||||
tmpStr.clear();
|
tmpStr.clear();
|
||||||
tmpStr.reserve(25);
|
tmpStr.reserve(25);
|
||||||
|
@ -500,12 +505,17 @@ namespace TS {
|
||||||
}else{
|
}else{
|
||||||
tmpStr.append("\200", 1);
|
tmpStr.append("\200", 1);
|
||||||
}
|
}
|
||||||
tmpStr += (char)(offset ? 0xC0 : 0x80) ; //PTS/DTS + Flags
|
tmpStr += (char)((offset ? 0xC0 : 0x80) | (bps?0x10:0)) ; //PTS/DTS + Flags
|
||||||
tmpStr += (char)(offset ? 0x0A : 0x05); //PESHeaderDataLength
|
tmpStr += (char)((offset ? 10 : 5) + (bps?3:0)); //PESHeaderDataLength
|
||||||
encodePESTimestamp(tmpStr, (offset ? 0x30 : 0x20), PTS + offset);
|
encodePESTimestamp(tmpStr, (offset ? 0x30 : 0x20), PTS + offset);
|
||||||
if (offset){
|
if (offset){
|
||||||
encodePESTimestamp(tmpStr, 0x10, PTS);
|
encodePESTimestamp(tmpStr, 0x10, PTS);
|
||||||
}
|
}
|
||||||
|
if (bps){
|
||||||
|
char rate_buf[3];
|
||||||
|
Bit::htob24(rate_buf, (bps/50) | 0x800001);
|
||||||
|
tmpStr.append(rate_buf, 3);
|
||||||
|
}
|
||||||
return tmpStr;
|
return tmpStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,16 +523,28 @@ namespace TS {
|
||||||
/// Prepends the lead-in to variable toSend, assumes toSend's length is all other data.
|
/// Prepends the lead-in to variable toSend, assumes toSend's length is all other data.
|
||||||
/// \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::getPESAudioLeadIn(unsigned int len, unsigned long long PTS) {
|
std::string & Packet::getPESAudioLeadIn(unsigned int len, unsigned long long PTS, uint64_t bps) {
|
||||||
|
if (bps >= 50){
|
||||||
|
len += 3;
|
||||||
|
}else{
|
||||||
|
bps = 0;
|
||||||
|
}
|
||||||
static std::string tmpStr;
|
static std::string tmpStr;
|
||||||
tmpStr.clear();
|
tmpStr.clear();
|
||||||
tmpStr.reserve(14);
|
tmpStr.reserve(20);
|
||||||
len += 8;
|
len += 8;
|
||||||
tmpStr.append("\000\000\001\300", 4);
|
tmpStr.append("\000\000\001\300", 4);
|
||||||
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 += (char)0x84;//isAligned
|
||||||
|
tmpStr += (char)(0x80 | (bps?0x10:0)) ; //PTS/DTS + Flags
|
||||||
|
tmpStr += (char)(5 + (bps?3:0)); //PESHeaderDataLength
|
||||||
encodePESTimestamp(tmpStr, 0x20, PTS);
|
encodePESTimestamp(tmpStr, 0x20, PTS);
|
||||||
|
if (bps){
|
||||||
|
char rate_buf[3];
|
||||||
|
Bit::htob24(rate_buf, (bps/50) | 0x800001);
|
||||||
|
tmpStr.append(rate_buf, 3);
|
||||||
|
}
|
||||||
return tmpStr;
|
return tmpStr;
|
||||||
}
|
}
|
||||||
//END PES FUNCTIONS
|
//END PES FUNCTIONS
|
||||||
|
|
|
@ -70,8 +70,8 @@ namespace TS {
|
||||||
void updPos(unsigned int newPos);
|
void updPos(unsigned int newPos);
|
||||||
|
|
||||||
//PES helpers
|
//PES helpers
|
||||||
static std::string & getPESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset, bool isAligned);
|
static std::string & getPESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset, bool isAligned, uint64_t bps=0);
|
||||||
static std::string & getPESAudioLeadIn(unsigned int len, unsigned long long PTS);
|
static std::string & getPESAudioLeadIn(unsigned int len, unsigned long long PTS, uint64_t bps=0);
|
||||||
|
|
||||||
//Printers and writers
|
//Printers and writers
|
||||||
std::string toPrettyString(size_t indent = 0, int detailLevel = 3) const;
|
std::string toPrettyString(size_t indent = 0, int detailLevel = 3) const;
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace Mist {
|
||||||
|
|
||||||
while (currPack <= splitCount){
|
while (currPack <= splitCount){
|
||||||
unsigned int alreadySent = 0;
|
unsigned int alreadySent = 0;
|
||||||
bs = TS::Packet::getPESVideoLeadIn((currPack != splitCount ? watKunnenWeIn1Ding : dataLen+extraSize - currPack*watKunnenWeIn1Ding), packTime, offset, !currPack);
|
bs = TS::Packet::getPESVideoLeadIn((currPack != splitCount ? watKunnenWeIn1Ding : dataLen+extraSize - currPack*watKunnenWeIn1Ding), packTime, offset, !currPack, Trk.bps);
|
||||||
fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg);
|
fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg);
|
||||||
if (!currPack){
|
if (!currPack){
|
||||||
if (Trk.codec == "H264" && (dataPointer[4] & 0x1f) != 0x09){
|
if (Trk.codec == "H264" && (dataPointer[4] & 0x1f) != 0x09){
|
||||||
|
@ -171,7 +171,7 @@ namespace Mist {
|
||||||
if (Trk.codec == "AAC"){
|
if (Trk.codec == "AAC"){
|
||||||
tempLen += 7;
|
tempLen += 7;
|
||||||
}
|
}
|
||||||
bs = TS::Packet::getPESAudioLeadIn(tempLen, packTime);// myMeta.tracks[thisPacket.getTrackId()].rate / 1000 );
|
bs = TS::Packet::getPESAudioLeadIn(tempLen, packTime, Trk.bps);// myMeta.tracks[thisPacket.getTrackId()].rate / 1000 );
|
||||||
fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg);
|
fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg);
|
||||||
if (Trk.codec == "AAC"){
|
if (Trk.codec == "AAC"){
|
||||||
bs = TS::getAudioHeader(dataLen, Trk.init);
|
bs = TS::getAudioHeader(dataLen, Trk.init);
|
||||||
|
|
Loading…
Add table
Reference in a new issue