20 #include "WebVttSubtecParser.hpp"
25 m_channel = SubtecChannel::SubtecChannelFactory(SubtecChannel::ChannelType::WEBVTT);
26 if (!m_channel->InitComms())
28 AAMPLOG_INFO(
"Init failed - subtitle parsing disabled");
29 throw std::runtime_error(
"PacketSender init failed");
31 AAMPLOG_INFO(
"Sending RESET ALL");
32 m_channel->SendResetAllPacket();
33 int width = 1920, height = 1080;
34 m_channel->SendMutePacket();
36 m_channel->SendSelectionPacket(width, height);
39 void WebVTTSubtecParser::updateTimestamp(
unsigned long long positionMs)
41 AAMPLOG_INFO(
"positionMs %lld", positionMs);
42 m_channel->SendTimestampPacket(positionMs);
45 void WebVTTSubtecParser::reset()
47 m_channel->SendMutePacket();
48 m_channel->SendResetChannelPacket();
51 bool WebVTTSubtecParser::init(
double startPosSeconds,
unsigned long long basePTS)
53 AAMPLOG_INFO(
"startPos %f basePTS %lld", startPosSeconds, basePTS);
55 m_channel->SendTimestampPacket(
static_cast<uint64_t
>(startPosSeconds*1000.0));
62 bool WebVTTSubtecParser::processData(
char* buffer,
size_t bufferLen,
double position,
double duration)
64 std::string str(
const_cast<const char*
>(buffer), bufferLen);
65 std::vector<uint8_t> data(str.begin(), str.end());
67 m_channel->SendDataPacket(std::move(data), 0);
72 void WebVTTSubtecParser::mute(
bool mute)
75 m_channel->SendMutePacket();
77 m_channel->SendUnmutePacket();
80 void WebVTTSubtecParser::pause(
bool pause)
83 m_channel->SendPausePacket();
85 m_channel->SendResumePacket();
89 void WebVTTSubtecParser::setTextStyle(
const std::string &options)
92 uint32_t attributesMask = 0;
97 if (!textStyleAttributes.getAttributes(options, attributesValues, attributesMask))
101 m_channel->SendCCSetAttributePacket(ccType, attributesMask, attributesValues);