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

Commit 58160c8

Browse files
nudiya450pmaria904
authored and
pmaria904
committed
RDK-36975: RDK-36734-[HLS][AAMP][Development] Muxed hls-ts incompatibility
Reason for change: Audio track selection support for muxed HLS/TS tracks Risks: Low Test Procedure: Test with HLS/TS Muxed stream Signed-off-by: Nandakishor Udiyannur<[email protected]> Change-Id: If8d721987e3f287febecc9fe62adf84e72ac7450
1 parent 6a02d47 commit 58160c8

12 files changed

+500
-113
lines changed

AampConfig.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ static AampConfigLookupEntry ConfigLookUpTable[] =
269269
{"suppressDecode",eAAMPConfig_SuppressDecode,-1,-1},
270270
{"persistHighNetworkBandwidth",eAAMPConfig_PersistHighNetworkBandwidth,-1,-1},
271271
{"persistLowNetworkBandwidth",eAAMPConfig_PersistLowNetworkBandwidth,-1,-1},
272-
{"gstSubtecEnabled",eAAMPConfig_GstSubtecEnabled,-1,-1}
272+
{"gstSubtecEnabled",eAAMPConfig_GstSubtecEnabled,-1,-1},
273+
{"changeTrackWithoutRetune", eAAMPConfig_ChangeTrackWithoutRetune, -1,-1}
273274
};
274275
/////////////////// Public Functions /////////////////////////////////////
275276
/**
@@ -454,8 +455,9 @@ void AampConfig::Initialize()
454455
#else
455456
bAampCfgValue[eAAMPConfig_UseSecManager].value = false;
456457
#endif
457-
bAampCfgValue[eAAMPConfig_PersistHighNetworkBandwidth].value = false;
458-
bAampCfgValue[eAAMPConfig_PersistLowNetworkBandwidth].value = true;
458+
bAampCfgValue[eAAMPConfig_PersistHighNetworkBandwidth].value = false;
459+
bAampCfgValue[eAAMPConfig_PersistLowNetworkBandwidth].value = true;
460+
bAampCfgValue[eAAMPConfig_ChangeTrackWithoutRetune].value = false;
459461
///////////////// Following for Integer Data type configs ////////////////////////////
460462
iAampCfgValue[eAAMPConfig_HarvestCountLimit-eAAMPConfig_IntStartValue].value = 0;
461463
iAampCfgValue[eAAMPConfig_ABRCacheLife-eAAMPConfig_IntStartValue].value = DEFAULT_ABR_CACHE_LIFE;

AampConfig.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ typedef enum
194194
eAAMPConfig_GstSubtecEnabled, /**< Force Gstreamer subtec */
195195
eAAMPConfig_AllowPageHeaders, /**< Allow page http headers*/
196196
eAAMPConfig_SuppressDecode, /**< To Suppress Decode of segments for playback . Test only Downloader */
197-
eAAMPConfig_PersistHighNetworkBandwidth, /** Flag to enable Persist High Network Bandwidth across Tunes */
198-
eAAMPConfig_PersistLowNetworkBandwidth, /** Flag to enable Persist Low Network Bandwidth across Tunes */
197+
eAAMPConfig_PersistHighNetworkBandwidth, /** Flag to enable Persist High Network Bandwidth across Tunes */
198+
eAAMPConfig_PersistLowNetworkBandwidth, /** Flag to enable Persist Low Network Bandwidth across Tunes */
199+
eAAMPConfig_ChangeTrackWithoutRetune, /**< Flag to enable audio track change without disturbing video pipeline */
199200
eAAMPConfig_BoolMaxValue,
200201
/////////////////////////////////
201202
eAAMPConfig_IntStartValue,

AampUtils.cpp

+97
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,35 @@
5555
#define RAND_STRING_LEN (MAC_STRING_LEN + 2*URAND_STRING_LEN)
5656
#define MAX_BUFF_LENGTH 4096
5757

58+
/*
59+
* Variable initialization for various audio formats
60+
*/
61+
const FormatMap mAudioFormatMap[] =
62+
{
63+
{ "mp4a.40.2", FORMAT_AUDIO_ES_AAC },
64+
{ "mp4a.40.5", FORMAT_AUDIO_ES_AAC },
65+
{ "ac-3", FORMAT_AUDIO_ES_AC3 },
66+
{ "mp4a.a5", FORMAT_AUDIO_ES_AC3 },
67+
{ "ac-4.02.01.01", FORMAT_AUDIO_ES_AC4 },
68+
{ "ac-4.02.01.02", FORMAT_AUDIO_ES_AC4 },
69+
{ "ec-3", FORMAT_AUDIO_ES_EC3 },
70+
{ "ec+3", FORMAT_AUDIO_ES_ATMOS },
71+
{ "eac3", FORMAT_AUDIO_ES_EC3 }
72+
};
73+
#define AAMP_AUDIO_FORMAT_MAP_LEN ARRAY_SIZE(mAudioFormatMap)
74+
75+
/*
76+
* Variable initialization for various video formats
77+
*/
78+
const FormatMap mVideoFormatMap[] =
79+
{
80+
{ "avc1.", FORMAT_VIDEO_ES_H264 },
81+
{ "hvc1.", FORMAT_VIDEO_ES_HEVC },
82+
{ "hev1.", FORMAT_VIDEO_ES_HEVC },
83+
{ "mpeg2v", FORMAT_VIDEO_ES_MPEG2 }//For testing.
84+
};
85+
#define AAMP_VIDEO_FORMAT_MAP_LEN ARRAY_SIZE(mVideoFormatMap)
86+
5887
/**
5988
* @brief Get current time from epoch is milliseconds
6089
*
@@ -975,6 +1004,74 @@ void mssleep(int milliseconds)
9751004
}
9761005
}
9771006

1007+
/*
1008+
* @fn GetAudioFormatStringForCodec
1009+
* @brief Function to get audio codec string from the map.
1010+
*
1011+
* @param[in] input Audio codec type
1012+
* @return Audio codec string
1013+
*/
1014+
const char * GetAudioFormatStringForCodec ( StreamOutputFormat input)
1015+
{
1016+
const char *codec = "UNKNOWN";
1017+
if(input < FORMAT_UNKNOWN)
1018+
{
1019+
for( int i=0; i<AAMP_AUDIO_FORMAT_MAP_LEN; i++ )
1020+
{
1021+
if(mAudioFormatMap[i].format == input )
1022+
{
1023+
codec = mAudioFormatMap[i].codec;
1024+
break;
1025+
}
1026+
}
1027+
}
1028+
return codec;
1029+
}
1030+
1031+
/*
1032+
* @fn GetAudioFormatForCodec
1033+
* @brief Function to get audio codec from the map.
1034+
*
1035+
* @param[in] Audio codec string
1036+
* @return Audio codec map
1037+
*/
1038+
const FormatMap * GetAudioFormatForCodec( const char *codecs )
1039+
{
1040+
if( codecs )
1041+
{
1042+
for( int i=0; i<AAMP_AUDIO_FORMAT_MAP_LEN; i++ )
1043+
{
1044+
if( strstr( codecs, mAudioFormatMap[i].codec) )
1045+
{
1046+
return &mAudioFormatMap[i];
1047+
}
1048+
}
1049+
}
1050+
return NULL;
1051+
}
1052+
1053+
/*
1054+
* @fn GetVideoFormatForCodec
1055+
* @brief Function to get video codec from the map.
1056+
*
1057+
* @param[in] Video codec string
1058+
* @return Video codec map
1059+
*/
1060+
const FormatMap * GetVideoFormatForCodec( const char *codecs )
1061+
{
1062+
if( codecs )
1063+
{
1064+
for( int i=0; i<AAMP_VIDEO_FORMAT_MAP_LEN; i++ )
1065+
{
1066+
if( strstr( codecs, mVideoFormatMap[i].codec) )
1067+
{
1068+
return &mVideoFormatMap[i];
1069+
}
1070+
}
1071+
}
1072+
return NULL;
1073+
}
1074+
9781075
/**
9791076
* EOF
9801077
*/

AampUtils.h

+37
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,43 @@
4444
//Delete Array object
4545
#define SAFE_DELETE_ARRAY(ptr) { delete [] ptr; ptr = NULL; }
4646

47+
/**
48+
* @struct FormatMap
49+
* @brief FormatMap structure for stream codec/format information
50+
*/
51+
struct FormatMap
52+
{
53+
const char* codec;
54+
StreamOutputFormat format;
55+
};
56+
57+
/*
58+
* @fn GetAudioFormatStringForCodec
59+
* @brief Function to get audio codec string from the map.
60+
*
61+
* @param[in] input Audio codec type
62+
* @return Audio codec string
63+
*/
64+
const char * GetAudioFormatStringForCodec ( StreamOutputFormat input);
65+
66+
/*
67+
* @fn GetAudioFormatForCodec
68+
* @brief Function to get audio codec from the map.
69+
*
70+
* @param[in] Audio codec string
71+
* @return Audio codec map
72+
*/
73+
const FormatMap * GetAudioFormatForCodec( const char *codecs );
74+
75+
/*
76+
* @fn GetVideoFormatForCodec
77+
* @brief Function to get video codec from the map.
78+
*
79+
* @param[in] Video codec string
80+
* @return Video codec map
81+
*/
82+
const FormatMap * GetVideoFormatForCodec( const char *codecs );
83+
4784
/**
4885
* @fn aamp_GetCurrentTimeMS
4986
*

StreamAbstractionAAMP.h

+24
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,30 @@ class StreamAbstractionAAMP
12891289
*/
12901290
void SetAudioFwdToAuxStatus(bool status) { mFwdAudioToAux = status; }
12911291

1292+
/**
1293+
* @brief Set AudioTrack info from Muxed stream
1294+
*
1295+
* @param[in] string index
1296+
* @return void
1297+
*/
1298+
virtual void SetAudioTrackInfoFromMuxedStream(std::vector<AudioTrackInfo>& vector);
1299+
1300+
/**
1301+
* @brief Set current audio track index
1302+
*
1303+
* @param[in] string index
1304+
* @return void
1305+
*/
1306+
void SetCurrentAudioTrackIndex(std::string& index) { mAudioTrackIndex = index; }
1307+
1308+
/**
1309+
* @brief Change muxed audio track index
1310+
*
1311+
* @param[in] string index
1312+
* @return void
1313+
*/
1314+
virtual void ChangeMuxedAudioTrackIndex(std::string& index){};
1315+
12921316
protected:
12931317
/**
12941318
* @brief Get stream information of a profile from subclass.

fragmentcollector_hls.cpp

+39-91
Original file line numberDiff line numberDiff line change
@@ -90,96 +90,6 @@ extern void ReleaseDRMLicenseAcquireThread(PrivateInstanceAAMP *aamp);
9090
#endif
9191

9292
#define UseProgramDateTimeIfAvailable() (ISCONFIGSET(eAAMPConfig_HLSAVTrackSyncUsingStartTime) || aamp->mIsVSS)
93-
/**
94-
* @struct FormatMap
95-
* @brief FormatMap structure for stream codec/format information
96-
*/
97-
struct FormatMap
98-
{
99-
const char* codec;
100-
StreamOutputFormat format;
101-
};
102-
103-
/// Variable initialization for various audio formats
104-
static const FormatMap mAudioFormatMap[] =
105-
{
106-
{ "mp4a.40.2", FORMAT_AUDIO_ES_AAC },
107-
{ "mp4a.40.5", FORMAT_AUDIO_ES_AAC },
108-
{ "ac-3", FORMAT_AUDIO_ES_AC3 },
109-
{ "mp4a.a5", FORMAT_AUDIO_ES_AC3 },
110-
{ "ac-4.02.01.01", FORMAT_AUDIO_ES_AC4 },
111-
{ "ac-4.02.01.02", FORMAT_AUDIO_ES_AC4 },
112-
{ "ec-3", FORMAT_AUDIO_ES_EC3 },
113-
{ "ec+3", FORMAT_AUDIO_ES_ATMOS },
114-
{ "eac3", FORMAT_AUDIO_ES_EC3 }
115-
};
116-
#define AAMP_AUDIO_FORMAT_MAP_LEN ARRAY_SIZE(mAudioFormatMap)
117-
118-
/// Variable initialization for various video formats
119-
static const FormatMap * GetAudioFormatForCodec( const char *codecs )
120-
{
121-
if( codecs )
122-
{
123-
for( int i=0; i<AAMP_AUDIO_FORMAT_MAP_LEN; i++ )
124-
{
125-
if( strstr( codecs, mAudioFormatMap[i].codec) )
126-
{
127-
return &mAudioFormatMap[i];
128-
}
129-
}
130-
}
131-
return NULL;
132-
}
133-
134-
/***************************************************************************
135-
* @fn GetAudioFormatStringForCodec
136-
* @brief Function to get audio codec string from the map.
137-
*
138-
* @param[in] input Audio codec type
139-
* @return Audio codec string
140-
***************************************************************************/
141-
static const char * GetAudioFormatStringForCodec ( StreamOutputFormat input)
142-
{
143-
const char *codec = "UNKNOWN";
144-
if(input < FORMAT_UNKNOWN)
145-
{
146-
for( int i=0; i<AAMP_AUDIO_FORMAT_MAP_LEN; i++ )
147-
{
148-
if(mAudioFormatMap[i].format == input )
149-
{
150-
codec = mAudioFormatMap[i].codec;
151-
break;
152-
}
153-
}
154-
}
155-
return codec;
156-
}
157-
158-
159-
/// Variable initialization for various video formats
160-
static const FormatMap mVideoFormatMap[] =
161-
{
162-
{ "avc1.", FORMAT_VIDEO_ES_H264 },
163-
{ "hvc1.", FORMAT_VIDEO_ES_HEVC },
164-
{ "hev1.", FORMAT_VIDEO_ES_HEVC },
165-
{ "mpeg2v", FORMAT_VIDEO_ES_MPEG2 }//For testing.
166-
};
167-
#define AAMP_VIDEO_FORMAT_MAP_LEN ARRAY_SIZE(mVideoFormatMap)
168-
169-
static const FormatMap * GetVideoFormatForCodec( const char *codecs )
170-
{
171-
if( codecs )
172-
{
173-
for( int i=0; i<AAMP_VIDEO_FORMAT_MAP_LEN; i++ )
174-
{
175-
if( strstr( codecs, mVideoFormatMap[i].codec) )
176-
{
177-
return &mVideoFormatMap[i];
178-
}
179-
}
180-
}
181-
return NULL;
182-
}
18393

18494
/// Variable initialization for media profiler buckets
18595
static const ProfilerBucketType mediaTrackBucketTypes[AAMP_TRACK_COUNT] =
@@ -4719,6 +4629,14 @@ AAMPStatusType StreamAbstractionAAMP_HLS::Init(TuneType tuneType)
47194629
{
47204630
AAMPLOG_WARN("StreamAbstractionAAMP_HLS: Configure audio TS track demuxing");
47214631
ts->playContext = new TSProcessor(mLogObj, aamp, eStreamOp_DEMUX_AUDIO);
4632+
if(ts->playContext)
4633+
{
4634+
if (currentAudioProfileIndex >= 0 )
4635+
{
4636+
std::string groupId = mediaInfo[currentAudioProfileIndex].group_id;
4637+
ts->playContext->SetAudioGroupId(groupId);
4638+
}
4639+
}
47224640
}
47234641
else
47244642
{
@@ -4802,7 +4720,15 @@ AAMPStatusType StreamAbstractionAAMP_HLS::Init(TuneType tuneType)
48024720
}
48034721
AAMPLOG_WARN("StreamAbstractionAAMP_HLS::Init : Configure video TS track demuxing demuxOp %d", demuxOp);
48044722
ts->playContext = new TSProcessor(mLogObj, aamp, demuxOp, eMEDIATYPE_VIDEO, static_cast<TSProcessor*> (trackState[eMEDIATYPE_AUDIO]->playContext), static_cast<TSProcessor*> (trackState[eMEDIATYPE_AUX_AUDIO]->playContext));
4805-
ts->playContext->setThrottleEnable(this->enableThrottle);
4723+
if(ts->playContext)
4724+
{
4725+
ts->playContext->setThrottleEnable(this->enableThrottle);
4726+
if (currentAudioProfileIndex >= 0 )
4727+
{
4728+
std::string groupId = mediaInfo[currentAudioProfileIndex].group_id;
4729+
ts->playContext->SetAudioGroupId(groupId);
4730+
}
4731+
}
48064732
if (this->rate == AAMP_NORMAL_PLAY_RATE)
48074733
{
48084734
ts->playContext->setRate(this->rate, PlayMode_normal);
@@ -7956,6 +7882,28 @@ StreamInfo * StreamAbstractionAAMP_HLS::GetStreamInfo(int idx)
79567882
return &streamInfo[userData];
79577883
}
79587884

7885+
7886+
/****************************************************************************
7887+
* @brief Change muxed audio track index
7888+
*
7889+
* @param[in] string index
7890+
* @return void
7891+
****************************************************************************/
7892+
void StreamAbstractionAAMP_HLS::ChangeMuxedAudioTrackIndex(std::string& index)
7893+
{
7894+
std::string muxPrefix = "mux-";
7895+
std::string trackIndex = index.substr(muxPrefix.size());
7896+
unsigned char indexNum = (unsigned char) stoi(trackIndex);
7897+
if(trackState[eMEDIATYPE_AUDIO] && trackState[eMEDIATYPE_AUDIO]->playContext)
7898+
{
7899+
trackState[eMEDIATYPE_AUDIO]->playContext->ChangeMuxedAudioTrack(indexNum);
7900+
}
7901+
else if(trackState[eMEDIATYPE_VIDEO] && trackState[eMEDIATYPE_VIDEO]->playContext && IsMuxedStream())
7902+
{
7903+
trackState[eMEDIATYPE_VIDEO]->playContext->ChangeMuxedAudioTrack(indexNum);
7904+
}
7905+
}
7906+
79597907
/**
79607908
* @}
79617909
*/

fragmentcollector_hls.h

+7
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,13 @@ class StreamAbstractionAAMP_HLS : public StreamAbstractionAAMP
853853
*
854854
*************************************************************************/
855855
StreamOutputFormat GetStreamOutputFormatForAudio(void);
856+
/****************************************************************************
857+
* @brief Change muxed audio track index
858+
*
859+
* @param[in] string index
860+
* @return void
861+
****************************************************************************/
862+
void ChangeMuxedAudioTrackIndex(std::string& index);
856863

857864
protected:
858865
/***************************************************************************

0 commit comments

Comments
 (0)