34 Packet() : m_buffer(), m_counter(std::numeric_limits<std::uint32_t>::max()) {}
35 Packet(std::uint32_t counter) : m_buffer(), m_counter(counter) {}
37 const uint32_t getType()
41 if (getBuffer().size() >= 4)
43 std::vector<std::uint8_t> buffer = getBuffer();
44 for (
int i = 0; i < 4; i++)
46 type += (buffer[i] << (i*8)) & 0xFF;
52 const std::vector<uint8_t>& getBytes()
57 const std::uint32_t getCounter()
62 static std::string getTypeString(uint32_t type)
65 PacketType pktType =
static_cast<PacketType
>(type);
69 case PacketType::PES_DATA:
72 case PacketType::TIMESTAMP:
75 case PacketType::RESET_ALL:
78 case PacketType::RESET_CHANNEL:
79 ret =
"RESET_CHANNEL";
81 case PacketType::SUBTITLE_SELECTION:
82 ret =
"SUBTITLE_SELECTION";
84 case PacketType::TELETEXT_SELECTION:
85 ret =
"TELETEXT_SELECTION";
87 case PacketType::TTML_SELECTION:
88 ret =
"TTML_SELECTION";
90 case PacketType::TTML_DATA:
93 case PacketType::TTML_TIMESTAMP:
94 ret =
"TTML_TIMESTAMP";
96 case PacketType::WEBVTT_SELECTION:
97 ret =
"WEBVTT_SELECTION";
99 case PacketType::WEBVTT_DATA:
102 case PacketType::WEBVTT_TIMESTAMP:
103 ret =
"WEBVTT_TIMESTAMP";
105 case PacketType::CC_DATA :
108 case PacketType::PAUSE :
111 case PacketType::RESUME :
114 case PacketType::MUTE :
117 case PacketType::UNMUTE :
120 case PacketType::CC_SET_ATTRIBUTE:
121 ret =
"CC_SET_ATTRIBUTE";
123 case PacketType::INVALID:
136 std::vector<uint8_t>& getBuffer() {
return m_buffer; }
138 enum class PacketType : std::uint32_t
160 INVALID = 0xFFFFFFFF,
163 std::vector<uint8_t> m_buffer;
164 std::uint32_t m_counter;
166 void append32(std::uint32_t value)
168 m_buffer.push_back((
static_cast<std::uint8_t
>((value >> 0)) & 0xFF));
169 m_buffer.push_back((
static_cast<std::uint8_t
>((value >> 8)) & 0xFF));
170 m_buffer.push_back((
static_cast<std::uint8_t
>((value >> 16)) & 0xFF));
171 m_buffer.push_back((
static_cast<std::uint8_t
>((value >> 24)) & 0xFF));
174 void append64(std::int64_t value)
176 append32((
static_cast<std::int32_t
>((value >> 0)) & 0xFFFFFFFF));
177 append32((
static_cast<std::int32_t
>((value >> 32)) & 0xFFFFFFFF));
180 void appendType(PacketType type)
182 append32(
static_cast<std::underlying_type<PacketType>::type
>(type));
186 using PacketPtr = std::unique_ptr<Packet>;
208 std::uint32_t counter) :
Packet(counter)
210 appendType(PacketType::PAUSE);
231 std::uint32_t counter) :
Packet(counter)
233 appendType(PacketType::RESUME);
254 std::uint32_t counter) :
Packet(counter)
256 appendType(PacketType::MUTE);
277 std::uint32_t counter) :
Packet(counter)
279 appendType(PacketType::UNMUTE);
302 appendType(PacketType::RESET_ALL);
323 std::uint32_t counter) :
Packet(counter)
325 appendType(PacketType::RESET_CHANNEL);
377 std::uint32_t counter,
378 std::uint32_t ccType,
379 std::uint32_t attribType,
382 appendType(PacketType::CC_SET_ATTRIBUTE);
384 append32((NUMBER_OF_ATTRIBUTES+3)*4);
387 append32(attribType);
389 for(
const auto value : attributesValues)