Skip to content
This repository was archived by the owner on Jan 26, 2023. It is now read-only.
/ rdk-aamp Public archive

Commit c4a4fec

Browse files
anshephepmaria904
authored and
pmaria904
committed
RDK-37719 [UVE] support ability to override WebVTT caption styling
Reason for change: As a Video Engine supporting ability to render out of band WebVTT captions, I want to support ability to override font size from app side.More specifically: Small Subtitles: font-size 34px and top positioning 870px Medium/Default Subtitles: font-size 50px and top positioning 860px Large Subtitles: font-size 80px and top positioning 790px All the positioning above is relative to the top-left corner of the entire screen Test Procedure: Test with WebVTT subtitles, setting font sizes via setTextStyleOptions (JS) or ccStyle (CLI) Risks: Low Signed-off-by: Andrew Shepherd <[email protected]> Change-Id: Iffdd47e570463c6d8b6e4ebf17dead17882284cb
1 parent 025ef11 commit c4a4fec

38 files changed

+1559
-138
lines changed

CMakeLists.txt

+13-4
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,14 @@ if (CMAKE_RDK_CC_ENABLED)
511511
endif()
512512
endif()
513513

514-
set(AAMP_SUBTEC_CLASS_SOURCES subtec/subtecparser/WebVttSubtecParser.cpp subtec/subtecparser/TtmlSubtecParser.cpp subtec/subtecparser/WebvttSubtecDevParser.cpp)
514+
set(AAMP_SUBTEC_CLASS_SOURCES subtec/subtecparser/WebVttSubtecParser.cpp subtec/subtecparser/TtmlSubtecParser.cpp subtec/subtecparser/WebvttSubtecDevParser.cpp subtec/subtecparser/TextStyleAttributes.cpp)
515515
set(LIBAAMP_SOURCES ${LIBAAMP_SOURCES} ${AAMP_SUBTEC_CLASS_SOURCES})
516516
include_directories(subtec/subtecparser)
517517

518518
message("CMAKE_GST_SUBTEC_ENABLED set")
519519
add_library(subtec SHARED subtec/libsubtec/PacketSender.cpp subtec/libsubtec/SubtecChannel.cpp)
520-
set_target_properties(subtec PROPERTIES PUBLIC_HEADER "subtec/libsubtec/SubtecChannel.hpp")
520+
set(AAMP_SUBTEC_PUBLIC_HEADERS subtec/libsubtec/SubtecChannel.hpp subtec/libsubtec/SubtecAttribute.hpp)
521+
set_target_properties(subtec PROPERTIES PUBLIC_HEADER "${AAMP_SUBTEC_PUBLIC_HEADERS}")
521522
set_target_properties(subtec PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -DSUBTEC_PACKET_DEBUG=1")
522523
include_directories(subtec/libsubtec)
523524
install (TARGETS subtec
@@ -536,7 +537,15 @@ if (CMAKE_SUBTEC_CC_ENABLED)
536537
set(LIBAAMP_DEFINES "${LIBAAMP_DEFINES} -DAAMP_SUBTEC_CC_ENABLED")
537538

538539
set(LIBSUBTECCONNECTOR_DEFINES "${LIBAAMP_DEFINES}")
539-
set(LIBSUBTECCONNECTOR_DEPENDS pthread rdkCCReader subtec)
540+
541+
if (CMAKE_USE_CC_MANAGER_MOCKS)
542+
find_path(STAGING_INCDIR closedcaption/ccDataReader.h)
543+
include_directories(${STAGING_INCDIR}/closedcaption)
544+
set(LIBAAMP_MOCK_SOURCES ${LIBAAMP_MOCK_SOURCES} test/fakes/ccManagerFakes.cpp)
545+
else()
546+
set(LIBSUBTECCONNECTOR_DEPENDS pthread rdkCCReader subtec)
547+
endif()
548+
540549
set(LIBSUBTECCONNECTOR_SOURCES ${AAMP_SUBTEC_SOURCES}
541550
closedcaptions/subtec/SubtecConnector.cpp
542551
closedcaptions/subtec/CCDataController.cpp
@@ -549,7 +558,7 @@ if (CMAKE_SUBTEC_CC_ENABLED)
549558
link_directories("${CMAKE_BINARY_DIR}")
550559

551560
set(LIBAAMP_SOURCES ${LIBAAMP_SOURCES} closedcaptions/subtec/AampSubtecCCManager.cpp)
552-
set(LIBAAMP_DEPENDS "${LIBAAMP_DEPENDS} -lsubtec_connector")
561+
set(LIBAAMP_DEPENDS "${LIBAAMP_DEPENDS}" subtec_connector)
553562
endif()
554563

555564

StreamAbstractionAAMP.h

+8
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,14 @@ class StreamAbstractionAAMP
13791379
*/
13801380
virtual void ResumeSubtitleAfterSeek(bool mute, char *data) { };
13811381

1382+
/**
1383+
* @fn SetTextStyle
1384+
* @brief Set the text style of the subtitle to the options passed
1385+
* @param[in] options - reference to the Json string that contains the information
1386+
* @return - true indicating successful operation in passing options to the parser
1387+
*/
1388+
virtual bool SetTextStyle(const std::string &options);
1389+
13821390
protected:
13831391
/**
13841392
* @brief Get stream information of a profile from subclass.

closedcaptions/AampCCManager.cpp

+95-89
Original file line numberDiff line numberDiff line change
@@ -427,117 +427,123 @@ try
427427
* FYI - bottomInset unsupported in RDK CC module
428428
*/
429429

430-
if (!options.empty())
430+
if(mEnabled)
431431
{
432-
AampJsonObject inputOptions(options);
432+
if (!options.empty())
433+
{
434+
AampJsonObject inputOptions(options);
433435

434-
std::string optionValue;
435-
ret = 0;
436-
mOptions = options;
436+
std::string optionValue;
437+
ret = 0;
438+
mOptions = options;
437439

438-
gsw_CcAttributes attribute;
439-
/** Get the current attributes */
440-
GetAttributes (&attribute, GSW_CC_TYPE_DIGITAL);
440+
gsw_CcAttributes attribute;
441+
/** Get the current attributes */
442+
GetAttributes (&attribute, GSW_CC_TYPE_DIGITAL);
441443

442-
short attribsMask = 0;
444+
short attribsMask = 0;
443445

444-
if (inputOptions.get("fontStyle", optionValue))
445-
{
446-
getFontStyle(optionValue, &(attribute.fontStyle));
447-
attribsMask |=GSW_CC_ATTRIB_FONT_STYLE;
448-
}
446+
if (inputOptions.get("fontStyle", optionValue))
447+
{
448+
getFontStyle(optionValue, &(attribute.fontStyle));
449+
attribsMask |=GSW_CC_ATTRIB_FONT_STYLE;
450+
}
449451

450-
if (inputOptions.get("textEdgeColor", optionValue))
451-
{
452-
getColor(GSW_CC_ATTRIB_EDGE_COLOR, GSW_CC_TYPE_DIGITAL, optionValue, &(attribute.edgeColor));
453-
attribsMask |=GSW_CC_ATTRIB_EDGE_COLOR;
454-
}
452+
if (inputOptions.get("textEdgeColor", optionValue))
453+
{
454+
getColor(GSW_CC_ATTRIB_EDGE_COLOR, GSW_CC_TYPE_DIGITAL, optionValue, &(attribute.edgeColor));
455+
attribsMask |=GSW_CC_ATTRIB_EDGE_COLOR;
456+
}
455457

456-
if (inputOptions.get("textEdgeStyle", optionValue))
457-
{
458-
getEdgeType(optionValue, &(attribute.edgeType));
459-
attribsMask |=GSW_CC_ATTRIB_EDGE_TYPE;
460-
}
458+
if (inputOptions.get("textEdgeStyle", optionValue))
459+
{
460+
getEdgeType(optionValue, &(attribute.edgeType));
461+
attribsMask |=GSW_CC_ATTRIB_EDGE_TYPE;
462+
}
461463

462-
if (inputOptions.get("textForegroundColor", optionValue))
463-
{
464-
getColor(GSW_CC_ATTRIB_FONT_COLOR, GSW_CC_TYPE_DIGITAL, optionValue, &(attribute.charFgColor));
465-
attribsMask |=GSW_CC_ATTRIB_FONT_COLOR;
466-
}
464+
if (inputOptions.get("textForegroundColor", optionValue))
465+
{
466+
getColor(GSW_CC_ATTRIB_FONT_COLOR, GSW_CC_TYPE_DIGITAL, optionValue, &(attribute.charFgColor));
467+
attribsMask |=GSW_CC_ATTRIB_FONT_COLOR;
468+
}
467469

468-
if (inputOptions.get("textForegroundOpacity", optionValue))
469-
{
470-
getOpacity(optionValue, &(attribute.charFgOpacity));
471-
attribsMask |=GSW_CC_ATTRIB_FONT_OPACITY;
472-
}
470+
if (inputOptions.get("textForegroundOpacity", optionValue))
471+
{
472+
getOpacity(optionValue, &(attribute.charFgOpacity));
473+
attribsMask |=GSW_CC_ATTRIB_FONT_OPACITY;
474+
}
473475

474-
if (inputOptions.get("textBackgroundColor", optionValue))
475-
{
476-
getColor(GSW_CC_ATTRIB_BACKGROUND_COLOR, GSW_CC_TYPE_DIGITAL, optionValue, &(attribute.charBgColor));
477-
attribsMask |=GSW_CC_ATTRIB_BACKGROUND_COLOR;
478-
}
476+
if (inputOptions.get("textBackgroundColor", optionValue))
477+
{
478+
getColor(GSW_CC_ATTRIB_BACKGROUND_COLOR, GSW_CC_TYPE_DIGITAL, optionValue, &(attribute.charBgColor));
479+
attribsMask |=GSW_CC_ATTRIB_BACKGROUND_COLOR;
480+
}
479481

480-
if (inputOptions.get("textBackgroundOpacity", optionValue))
481-
{
482-
getOpacity(optionValue, &(attribute.charBgOpacity));
483-
attribsMask |=GSW_CC_ATTRIB_BACKGROUND_OPACITY;
484-
}
482+
if (inputOptions.get("textBackgroundOpacity", optionValue))
483+
{
484+
getOpacity(optionValue, &(attribute.charBgOpacity));
485+
attribsMask |=GSW_CC_ATTRIB_BACKGROUND_OPACITY;
486+
}
485487

486-
if (inputOptions.get("penItalicized", optionValue))
487-
{
488-
getTextStyle(optionValue, &(attribute.fontItalic));
489-
attribsMask |=GSW_CC_ATTRIB_FONT_ITALIC;
490-
}
488+
if (inputOptions.get("penItalicized", optionValue))
489+
{
490+
getTextStyle(optionValue, &(attribute.fontItalic));
491+
attribsMask |=GSW_CC_ATTRIB_FONT_ITALIC;
492+
}
491493

492-
if (inputOptions.get("penSize", optionValue))
493-
{
494-
getFontSize(optionValue, &(attribute.fontSize));
495-
attribsMask |=GSW_CC_ATTRIB_FONT_SIZE;
496-
}
494+
if (inputOptions.get("penSize", optionValue))
495+
{
496+
getFontSize(optionValue, &(attribute.fontSize));
497+
attribsMask |=GSW_CC_ATTRIB_FONT_SIZE;
498+
}
497499

498-
if (inputOptions.get("penUnderline", optionValue))
499-
{
500-
getTextStyle(optionValue, &(attribute.fontUnderline));
501-
attribsMask |=GSW_CC_ATTRIB_FONT_UNDERLINE;
502-
}
500+
if (inputOptions.get("penUnderline", optionValue))
501+
{
502+
getTextStyle(optionValue, &(attribute.fontUnderline));
503+
attribsMask |=GSW_CC_ATTRIB_FONT_UNDERLINE;
504+
}
503505

504-
if (inputOptions.get("windowBorderEdgeColor", optionValue))
505-
{
506-
getColor(GSW_CC_ATTRIB_BORDER_COLOR, GSW_CC_TYPE_DIGITAL, optionValue, &(attribute.borderColor));
507-
attribsMask |=GSW_CC_ATTRIB_BORDER_COLOR;
508-
}
506+
if (inputOptions.get("windowBorderEdgeColor", optionValue))
507+
{
508+
getColor(GSW_CC_ATTRIB_BORDER_COLOR, GSW_CC_TYPE_DIGITAL, optionValue, &(attribute.borderColor));
509+
attribsMask |=GSW_CC_ATTRIB_BORDER_COLOR;
510+
}
509511

510-
if (inputOptions.get("windowBorderEdgeStyle", optionValue))
511-
{
512-
getEdgeType(optionValue, (gsw_CcEdgeType*) &(attribute.borderType));
513-
attribsMask |=GSW_CC_ATTRIB_BORDER_TYPE;
514-
}
512+
if (inputOptions.get("windowBorderEdgeStyle", optionValue))
513+
{
514+
getEdgeType(optionValue, (gsw_CcEdgeType*) &(attribute.borderType));
515+
attribsMask |=GSW_CC_ATTRIB_BORDER_TYPE;
516+
}
515517

516-
if (inputOptions.get("windowFillColor", optionValue))
517-
{
518-
getColor(GSW_CC_ATTRIB_WIN_COLOR, GSW_CC_TYPE_DIGITAL, optionValue, &(attribute.winColor));
519-
attribsMask |=GSW_CC_ATTRIB_WIN_COLOR;
520-
}
518+
if (inputOptions.get("windowFillColor", optionValue))
519+
{
520+
getColor(GSW_CC_ATTRIB_WIN_COLOR, GSW_CC_TYPE_DIGITAL, optionValue, &(attribute.winColor));
521+
attribsMask |=GSW_CC_ATTRIB_WIN_COLOR;
522+
}
521523

522-
if (inputOptions.get("windowFillOpacity", optionValue))
523-
{
524-
getOpacity(optionValue, &(attribute.winOpacity));
525-
attribsMask |=GSW_CC_ATTRIB_WIN_OPACITY;
526-
}
524+
if (inputOptions.get("windowFillOpacity", optionValue))
525+
{
526+
getOpacity(optionValue, &(attribute.winOpacity));
527+
attribsMask |=GSW_CC_ATTRIB_WIN_OPACITY;
528+
}
527529

528-
if(attribsMask != 0)
529-
{
530+
if(attribsMask != 0)
531+
{
530532

531-
SetAttributes(&attribute, attribsMask, GSW_CC_TYPE_DIGITAL);
532-
SetAttributes(&attribute, attribsMask, GSW_CC_TYPE_ANALOG);
533-
}
534-
else
535-
{
536-
AAMPLOG_WARN("AampCCManagerBase::received optionsJson but result attributeMask is 0");
537-
}
533+
SetAttributes(&attribute, attribsMask, GSW_CC_TYPE_DIGITAL);
534+
SetAttributes(&attribute, attribsMask, GSW_CC_TYPE_ANALOG);
535+
}
536+
else
537+
{
538+
AAMPLOG_WARN("AampCCManagerBase::received optionsJson but result attributeMask is 0");
539+
}
538540

541+
}
542+
}
543+
else
544+
{
545+
AAMPLOG_WARN("AampCCManagerBase::CC rendering not enabled");
539546
}
540-
541547
return ret;
542548
}
543549
catch(const AampJsonParseException& e)

fragmentcollector_mpd.cpp

+21-2
Original file line numberDiff line numberDiff line change
@@ -9784,8 +9784,9 @@ void StreamAbstractionAAMP_MPD::InitSubtitleParser(char *data)
97849784
mSubtitleParser = SubtecFactory::createSubtitleParser(mLogObj, aamp, eSUB_TYPE_WEBVTT);
97859785
if (mSubtitleParser)
97869786
{
9787-
AAMPLOG_WARN("sending init to webvtt parser %.3f", seekPosition);
9788-
mSubtitleParser->init(seekPosition,0);
9787+
double position = aamp->GetPositionSeconds();
9788+
AAMPLOG_WARN("sending init to webvtt parser %.3f", position);
9789+
mSubtitleParser->init(position,0);
97899790
mSubtitleParser->mute(false);
97909791
AAMPLOG_INFO("sending data");
97919792
if (data != NULL)
@@ -12634,3 +12635,21 @@ std::vector<StreamInfo*> StreamAbstractionAAMP_MPD::GetAvailableVideoTracks(void
1263412635
}
1263512636
return videoTracks;
1263612637
}
12638+
12639+
12640+
bool StreamAbstractionAAMP_MPD::SetTextStyle(const std::string &options)
12641+
{
12642+
bool retVal;
12643+
// If sidecar subtitles
12644+
if (mSubtitleParser)
12645+
{
12646+
AAMPLOG_INFO("Calling SubtitleParser::SetTextStyle(%s)", options.c_str());
12647+
mSubtitleParser->setTextStyle(options);
12648+
retVal = true;
12649+
}
12650+
else
12651+
{
12652+
retVal = StreamAbstractionAAMP::SetTextStyle(options);
12653+
}
12654+
return retVal;
12655+
}

fragmentcollector_mpd.h

+7
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,13 @@ class StreamAbstractionAAMP_MPD : public StreamAbstractionAAMP
436436
* @return void
437437
*/
438438
void ResumeSubtitleAfterSeek(bool mute, char *data) override;
439+
/**
440+
* @fn SetTextStyle
441+
* @brief Set the text style of the subtitle to the options passed
442+
* @param[in] options - reference to the Json string that contains the information
443+
* @return - true indicating successful operation in passing options to the parser
444+
*/
445+
bool SetTextStyle(const std::string &options) override;
439446
private:
440447
/**
441448
* @fn printSelectedTrack

priv_aamp.cpp

+27-11
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,7 @@ PrivateInstanceAAMP::PrivateInstanceAAMP(AampConfig *config) : mReportProgressPo
14591459
, mPipelineIsClear(false)
14601460
, mLLActualOffset(-1)
14611461
, mIsStream4K(false)
1462+
, mTextStyle()
14621463
{
14631464
for(int i=0; i<eMEDIATYPE_DEFAULT; i++)
14641465
{
@@ -5320,6 +5321,12 @@ void PrivateInstanceAAMP::TuneHelper(TuneType tuneType, bool seekWhilePaused)
53205321
if (mpStreamAbstractionAAMP)
53215322
mpStreamAbstractionAAMP->ResumeSubtitleAfterSeek(subtitles_muted, mData);
53225323
}
5324+
5325+
if ((mpStreamAbstractionAAMP) && (!mTextStyle.empty()))
5326+
{
5327+
// Restore the subtitle text style after a seek.
5328+
(void)mpStreamAbstractionAAMP->SetTextStyle(mTextStyle);
5329+
}
53235330
}
53245331

53255332
if (newTune && !mIsFakeTune)
@@ -10334,7 +10341,11 @@ void PrivateInstanceAAMP::SetTextTrack(int trackId, char *data)
1033410341
SetCCStatus(true);
1033510342

1033610343
mpStreamAbstractionAAMP->InitSubtitleParser(data);
10337-
10344+
if (!mTextStyle.empty())
10345+
{
10346+
// Restore the subtitle text style after a track change.
10347+
(void)mpStreamAbstractionAAMP->SetTextStyle(mTextStyle);
10348+
}
1033810349
}
1033910350
}
1034010351
}
@@ -10436,25 +10447,30 @@ void PrivateInstanceAAMP::NotifyTextTracksChanged()
1043610447
*/
1043710448
void PrivateInstanceAAMP::SetTextStyle(const std::string &options)
1043810449
{
10439-
//TODO: This can be later extended to subtitle rendering
10440-
// Right now, API is not available for subtitle
10450+
bool retVal = false;
10451+
10452+
mTextStyle = options;
10453+
10454+
if (mpStreamAbstractionAAMP)
10455+
{
10456+
AAMPLOG_WARN("Calling StreamAbstractionAAMP::SetTextStyle(%s)", options.c_str());
10457+
retVal = mpStreamAbstractionAAMP->SetTextStyle(options);
10458+
}
10459+
if (!retVal)
10460+
{
1044110461
#ifdef AAMP_CC_ENABLED
10442-
AampCCManager::GetInstance()->SetStyle(options);
10462+
AAMPLOG_WARN("Calling AampCCManager::SetTextStyle(%s)", options.c_str());
10463+
AampCCManager::GetInstance()->SetStyle(options);
1044310464
#endif
10465+
}
1044410466
}
1044510467

1044610468
/**
1044710469
* @brief Get style options for text track rendering
1044810470
*/
1044910471
std::string PrivateInstanceAAMP::GetTextStyle()
1045010472
{
10451-
//TODO: This can be later extended to subtitle rendering
10452-
// Right now, API is not available for subtitle
10453-
#ifdef AAMP_CC_ENABLED
10454-
return AampCCManager::GetInstance()->GetStyle();
10455-
#else
10456-
return std::string();
10457-
#endif
10473+
return mTextStyle;
1045810474
}
1045910475

1046010476
/**

0 commit comments

Comments
 (0)