From a73f97e0656ef5cbbfff0f8b30a79f5e0411b690 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 18 Jul 2016 10:08:28 +0200 Subject: [PATCH] Implemented ES priority flag in accordance with HBBTV spec --- lib/ts_packet.cpp | 44 +++++++++++++++++++++++++++++------ lib/ts_packet.h | 3 ++- src/output/output_ts_base.cpp | 3 ++- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/lib/ts_packet.cpp b/lib/ts_packet.cpp index 40ca8d33..85c8e4e5 100644 --- a/lib/ts_packet.cpp +++ b/lib/ts_packet.cpp @@ -258,6 +258,9 @@ namespace TS { if (getRandomAccess()){ output << " [RandomXS]"; } + if (getESPriority()){ + output << " [ESPriority]"; + } if (hasPCR()) { output << " [PCR " << (double)getPCR() / 27000000 << "s]"; } @@ -286,7 +289,7 @@ namespace TS { return output.str(); } - if (detailLevel >= 3){ + if (detailLevel >= 10){ output << std::string(indent+2, ' ') << "Raw data bytes:"; unsigned int size = getDataSize(); @@ -325,12 +328,6 @@ namespace TS { } } -/// Gets the elementary stream priority indicator of a Packet -/// \return The elementary stream priority indicator of a Packet - bool Packet::hasESpriority() const{ - return strBuf[5] & 0x20; - } - bool Packet::hasDiscontinuity() const{ return strBuf[5] & 0x80; } @@ -366,6 +363,15 @@ namespace TS { return strBuf[5] & 0x40; } +/// Gets whether this Packet has the priority bit set +/// \return Whether or not this Packet has the priority bit set + bool Packet::getESPriority() const{ + if (getAdaptationField() < 2) { + return false; + } + return strBuf[5] & 0x20; + } + ///Gets the value of the PCR flag ///\return true if there is a PCR, false otherwise bool Packet::hasPCR() const{ @@ -408,6 +414,30 @@ namespace TS { } } +///Gets the value of the ES priority flag +///\return the value of the ES priority flag + void Packet::setESPriority(bool NewVal) { + updPos(6); + if (getAdaptationField() == 3) { + if (!strBuf[4]) { + strBuf[4] = 1; + } + if (NewVal) { + strBuf[5] |= 0x20; + } else { + strBuf[5] &= 0xDF; + } + } else { + setAdaptationField(3); + strBuf[4] = 1; + if (NewVal) { + strBuf[5] = 0x20; + } else { + strBuf[5] = 0x00; + } + } + } + /// Transforms the Packet into a standard Program Association Table void Packet::setDefaultPAT() { static int MyCntr = 0; diff --git a/lib/ts_packet.h b/lib/ts_packet.h index 3cdfce36..74937859 100644 --- a/lib/ts_packet.h +++ b/lib/ts_packet.h @@ -45,6 +45,8 @@ namespace TS { bool getUnitStart() const; void setRandomAccess(bool newVal); bool getRandomAccess() const; + void setESPriority(bool newVal); + bool getESPriority() const; void setDiscontinuity(bool newVal); bool hasDiscontinuity() const; @@ -53,7 +55,6 @@ namespace TS { bool hasSplicingPoint() const; bool hasTransportError() const; bool hasPriority() const; - bool hasESpriority() const; //Helper functions operator bool() const; diff --git a/src/output/output_ts_base.cpp b/src/output/output_ts_base.cpp index ee771c35..ca7a2a67 100644 --- a/src/output/output_ts_base.cpp +++ b/src/output/output_ts_base.cpp @@ -39,7 +39,8 @@ namespace Mist { packData.setDiscontinuity(true); if (myMeta.tracks[thisPacket.getTrackId()].type == "video"){ if (thisPacket.getInt("keyframe")){ - packData.setRandomAccess(1); + packData.setRandomAccess(true); + packData.setESPriority(true); } packData.setPCR(thisPacket.getTime() * 27000); }