22 #include "SubtecPacket.hpp"
23 #include "SubtecChannel.hpp"
24 #include "PacketSender.hpp"
31 ClosedCaptionsPacket(uint32_t channelId, uint32_t counter, uint32_t ptsValue, uint8_t* data,
size_t dataLen)
33 appendType(Packet::PacketType::CC_DATA);
35 append32(CC_DATA_HEADER_LEN+dataLen);
37 append32(CC_CHANNEL_TYPE);
40 for(
int i = 0; i<dataLen; ++i)
41 getBuffer().push_back(data[i]);
46 appendType(Packet::PacketType::CC_DATA);
48 append32(CC_DATA_HEADER_LEN+dataLen);
50 append32(CC_CHANNEL_TYPE);
53 for(
int i = 0; i<dataLen; ++i)
54 getBuffer().push_back(data[i]);
58 static constexpr std::uint8_t CC_DATA_HEADER_LEN = 16;
59 static constexpr std::uint8_t CC_CHANNEL_TYPE = 3;
65 enum class CEA : uint32_t
73 auto to_integral = [](CEA e) -> uint32_t
75 return static_cast<uint32_t
>(e);
78 appendType(Packet::PacketType::SUBTITLE_SELECTION);
80 append32(CC_SELECTION_LEN);
82 append32(CC_USERDATA_SUBTITLE_TYPE);
83 append32(to_integral(type));
91 static constexpr std::uint8_t CC_SELECTION_LEN = 16;
92 static constexpr std::uint8_t CC_USERDATA_SUBTITLE_TYPE = 3;
100 void SendDataPacketWithPTS(uint32_t ptsValue, uint8_t* data,
size_t dataLen)
102 std::unique_lock<std::mutex> lock(mChannelMtx);
103 PacketSender::Instance()->SendPacket(std::unique_ptr<ClosedCaptionsPacket>(
new ClosedCaptionsPacket(m_channelId, m_counter++, ptsValue, data, dataLen)));
106 void SendDataPacketNoPTS(uint8_t* data,
size_t dataLen)
108 std::unique_lock<std::mutex> lock(mChannelMtx);
109 PacketSender::Instance()->SendPacket(std::unique_ptr<ClosedCaptionsPacket>(
new ClosedCaptionsPacket(m_channelId, m_counter++, data, dataLen)));
112 void SendActiveTypePacket(ClosedCaptionsActiveTypePacket::CEA type,
unsigned int channel)
114 std::unique_lock<std::mutex> lock(mChannelMtx);
115 PacketSender::Instance()->SendPacket(std::unique_ptr<ClosedCaptionsActiveTypePacket>(
new ClosedCaptionsActiveTypePacket(m_channelId, m_counter++, type, channel)));