22 #include "PacketSender.hpp"
23 #include "SubtecChannel.hpp"
24 #include "SubtecPacket.hpp"
25 #include "TtmlPacket.hpp"
26 #include "WebVttPacket.hpp"
27 #include "ClosedCaptionsPacket.hpp"
31 template<
typename T,
typename ...Args>
32 std::unique_ptr<T> make_unique(Args&& ...args)
34 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
38 std::unique_ptr<SubtecChannel> SubtecChannel::SubtecChannelFactory(ChannelType type)
40 std::unique_ptr<SubtecChannel> subtecChannel;
44 case ChannelType::TTML:
45 subtecChannel = make_unique<TtmlChannel>();
47 case ChannelType::WEBVTT:
48 subtecChannel = make_unique<WebVttChannel>();
59 bool SubtecChannel::InitComms()
61 const char *socket_path = ::getenv(
"AAMP_SUBTITLE_SOCKET");
64 return InitComms(socket_path);
66 return InitComms(SOCKET_PATH);
69 bool SubtecChannel::InitComms(
const char* socket_path)
71 return PacketSender::Instance()->Init(socket_path);
75 template<
typename PacketType,
typename ...Args>
76 void SubtecChannel::sendPacket(Args && ...args)
78 std::unique_lock<std::mutex> lock(mChannelMtx);
79 PacketSender::Instance()->SendPacket(make_unique<PacketType>(m_channelId, m_counter++, std::forward<Args>(args)...));
82 void SubtecChannel::SendResetAllPacket()
84 std::unique_lock<std::mutex> lock(mChannelMtx);
86 PacketSender::Instance()->SendPacket(make_unique<ResetAllPacket>());
89 void SubtecChannel::SendResetChannelPacket() {
90 sendPacket<ResetChannelPacket>();
92 void SubtecChannel::SendPausePacket() {
93 sendPacket<PausePacket>();
95 void SubtecChannel::SendResumePacket() {
96 sendPacket<ResumePacket>();
98 void SubtecChannel::SendMutePacket() {
99 sendPacket<MutePacket>();
101 void SubtecChannel::SendUnmutePacket() {
102 sendPacket<UnmutePacket>();
104 void SubtecChannel::SendCCSetAttributePacket(std::uint32_t ccType, std::uint32_t attribType,
const attributesType &attributesValues) {
105 AAMPLOG_INFO(
"SendCCSetAttributePacket, the bit mask is 0x%X", attribType);
106 sendPacket<CCSetAttributePacket>(ccType, attribType, attributesValues);
109 SubtecChannel::~SubtecChannel() {}