From 12b0d9a93050c65d3eb994883351ff87ae728b20 Mon Sep 17 00:00:00 2001 From: wouter spruit Date: Thu, 5 Mar 2015 13:35:17 +0100 Subject: [PATCH] added setDiscontinuity function to ts_packet, added DEBUG MSG level shortcuts --- lib/defines.h | 6 ++++++ lib/ts_packet.cpp | 22 ++++++++++++++++++++++ lib/ts_packet.h | 1 + 3 files changed, 29 insertions(+) diff --git a/lib/defines.h b/lib/defines.h index 0939a968..cbf9bff7 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -47,6 +47,12 @@ static const char * DBG_LVL_LIST[] = {"NONE", "FAIL", "ERROR", "WARN", "INFO", " #define WARN_MSG(msg, ...) DEBUG_MSG(DLVL_WARN, msg, ##__VA_ARGS__) #define DEVEL_MSG(msg, ...) DEBUG_MSG(DLVL_DEVEL, msg, ##__VA_ARGS__) #define INFO_MSG(msg, ...) DEBUG_MSG(DLVL_DEVEL, msg, ##__VA_ARGS__) +#define MEDIUM_MSG(msg, ...) DEBUG_MSG(DLVL_MEDIUM, msg, ##__VA_ARGS__) +#define HIGH_MSG(msg, ...) DEBUG_MSG(DLVL_HIGH, msg, ##__VA_ARGS__) +#define VERYHIGH_MSG(msg, ...) DEBUG_MSG(DLVL_VERYHIGH, msg, ##__VA_ARGS__) +#define EXTREME_MSG(msg, ...) DEBUG_MSG(DLVL_EXTREME, msg, ##__VA_ARGS__) +#define INSANE_MSG(msg, ...) DEBUG_MSG(DLVL_INSANE, msg, ##__VA_ARGS__) +#define DONTEVEN_MSG(msg, ...) DEBUG_MSG(DLVL_DONTEVEN, msg, ##__VA_ARGS__) #endif diff --git a/lib/ts_packet.cpp b/lib/ts_packet.cpp index 9918530e..b943445b 100644 --- a/lib/ts_packet.cpp +++ b/lib/ts_packet.cpp @@ -329,6 +329,28 @@ namespace TS { bool Packet::hasDiscontinuity() const{ return strBuf[5] & 0x80; } + + void Packet::setDiscontinuity(bool newVal){ + updPos(6); + if (getAdaptationField() == 3) { + if (!strBuf[4]) { + strBuf[4] = 1; + } + if (newVal) { + strBuf[5] |= 0x80; + } else { + strBuf[5] &= 0x7F; + } + } else { + setAdaptationField(3); + strBuf[4] = 1; + if (newVal) { + strBuf[5] = 0x80; + } else { + strBuf[5] = 0x00; + } + } + } /// Gets whether this Packet can be accessed at random (indicates keyframe). /// \return Whether or not this Packet contains a keyframe. diff --git a/lib/ts_packet.h b/lib/ts_packet.h index fa30d6bf..7c0d370c 100644 --- a/lib/ts_packet.h +++ b/lib/ts_packet.h @@ -45,6 +45,7 @@ namespace TS { void setRandomAccess(bool newVal); bool getRandomAccess() const; + void setDiscontinuity(bool newVal); bool hasDiscontinuity() const; bool hasPCR() const; bool hasOPCR() const;