Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion AampStreamSinkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,15 @@ void AampStreamSinkManager::SetEncryptedHeaders(PrivateInstanceAAMP *aamp, std::
break;
case ePIPELINEMODE_SINGLE:
{
if (!mActiveGstPlayersMap.count(aamp))
if (!mActiveGstPlayersMap.count(aamp) && !mActiveGstPlayersMap.empty())
{
AAMPLOG_WARN("AampStreamSinkManager(%p) Ignoring SetEncryptedHeaders from non-active PLAYER[%d]", this, aamp->mPlayerId);
break;
}
if (mActiveGstPlayersMap.empty())
{
AAMPLOG_INFO("AampStreamSinkManager(%p) No active player, accepting SetEncryptedHeaders for PLAYER[%d]", this, aamp->mPlayerId);
}
if ((mGstPlayer != nullptr) && !mEncryptedHeaders.empty())
{
// If encryption info is already set, check that it has not been set from a different player
Expand Down
2 changes: 1 addition & 1 deletion StreamSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ class StreamSink
* @param[in] type - Media type
* @param[in] codecInfo - Codec information
*/
virtual void SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo) {};
virtual void SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo, const char* protectionSystem = nullptr) {};

};

Expand Down
4 changes: 2 additions & 2 deletions aampgstplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1383,9 +1383,9 @@ void AAMPGstPlayer::StopMonitorAvTimer()
* @param[in] type - Media type
* @param[in] codecInfo - Codec information
*/
void AAMPGstPlayer::SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo)
void AAMPGstPlayer::SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo, const char* protectionSystem)
{
playerInstance->SetStreamCaps(static_cast<GstMediaType>(type), std::move(codecInfo));
playerInstance->SetStreamCaps(static_cast<GstMediaType>(type), std::move(codecInfo), protectionSystem);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion aampgstplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ class AAMPGstPlayer : public StreamSink
* @param[in] type - Media type
* @param[in] codecInfo - Codec information
*/
void SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo) override;
void SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo, const char* protectionSystem = nullptr) override;

private:
std::mutex mBufferingLock;
Expand Down
24 changes: 15 additions & 9 deletions fragmentcollector_mpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4063,6 +4063,7 @@ AAMPStatusType StreamAbstractionAAMP_MPD::Init(TuneType tuneType)
// Check if a period in a multi-period asset has an encrypted content
if(GetEncryptedHeaders(headers))
{
AAMPLOG_WARN("Getting Non Empty manifest EncryptedHeaders");
PushEncryptedHeaders(headers);
aamp->mPipelineIsClear = false;
aamp->mEncryptedPeriodFound = false;
Expand All @@ -4071,9 +4072,11 @@ AAMPStatusType StreamAbstractionAAMP_MPD::Init(TuneType tuneType)
{
// Check if single pipeline has a main asset that has
// encrypted content whose init header urls have been saved
AampStreamSinkManager::GetInstance().ReinjectEncryptedHeaders();
AampStreamSinkManager::GetInstance().GetEncryptedHeaders(headers);
if (!headers.empty())
{
AAMPLOG_WARN("Getting Non Empty sinkmanager EncryptedHeaders");
PushEncryptedHeaders(headers);
aamp->mPipelineIsClear = false;
aamp->mEncryptedPeriodFound = false;
Expand Down Expand Up @@ -8697,13 +8700,14 @@ bool StreamAbstractionAAMP_MPD::CheckForInitalClearPeriod()
*/
void StreamAbstractionAAMP_MPD::PushEncryptedHeaders(std::map<int, std::string>& mappedHeaders)
{
AAMPLOG_WARN("Entering PushEncryptedHeaders");
std::vector<std::shared_future<void>> futures;
for (std::map<int, std::string>::iterator it = mappedHeaders.begin(); it != mappedHeaders.end(); ++it)
{
if (ISCONFIGSET(eAAMPConfig_DashParallelFragDownload))
{
// Download the video, audio & subtitle fragments in a separate parallel thread.
AAMPLOG_DEBUG("Submitting job for init encrypted header track %d", it->first);
AAMPLOG_WARN("Submitting job for init encrypted header track %d", it->first);
auto track = it->first;
auto header = it->second;
auto dashWorkerJob = std::make_shared<AampDashWorkerJob>([this, track, header]() { CacheEncryptedHeader(track, header); });
Expand All @@ -8712,7 +8716,7 @@ void StreamAbstractionAAMP_MPD::PushEncryptedHeaders(std::map<int, std::string>&
}
else
{
AAMPLOG_INFO("Track %d worker not available, caching init encrypted header sequentially", it->first);
AAMPLOG_WARN("Track %d worker not available, caching init encrypted header sequentially", it->first);
CacheEncryptedHeader(it->first, it->second);
}
}
Expand Down Expand Up @@ -8741,13 +8745,15 @@ void StreamAbstractionAAMP_MPD::CacheEncryptedHeader(int trackIdx, std::string h
bool temp = false;
try
{
DownloadInfoPtr info = std::make_shared<DownloadInfo>();
info->absolutePosition = 0;
info->ptsOffset = 0;
info->isInitSegment = true;
info->mediaType = (AampMediaType)trackIdx;
mMediaStreamContext[trackIdx]->mActiveDownloadInfo = std::move(info);
temp = mMediaStreamContext[trackIdx]->CacheFragment(headerUrl, (eCURLINSTANCE_VIDEO + mMediaStreamContext[trackIdx]->mediaType), mMediaStreamContext[trackIdx]->fragmentTime, 0.0, NULL, true, false, false, 0);
DownloadInfoPtr downloadInfo = std::make_shared<DownloadInfo>();
downloadInfo->absolutePosition = 0;
downloadInfo->isInitSegment = true;
downloadInfo->mediaType = static_cast<AampMediaType>(trackIdx);
downloadInfo->curlInstance = static_cast<AampCurlInstance>(eCURLINSTANCE_VIDEO + mMediaStreamContext[trackIdx]->mediaType);
downloadInfo->uriList[0] = URIInfo(headerUrl);
AAMPLOG_WARN("Inside the condition--> RESHMA");
temp = mMediaStreamContext[trackIdx]->DownloadFragment(downloadInfo);
this->OnFragmentDownloadComplete(temp, downloadInfo);
}
catch(const std::regex_error& e)
{
Expand Down
10 changes: 8 additions & 2 deletions middleware/InterfacePlayerRDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5390,7 +5390,7 @@ void AddBufferFieldToStructure(GstStructure *structure, const char *fieldName, c
* @param[in] type The media type.
* @param[in] codecInfo The codec information.
*/
void InterfacePlayerRDK::SetStreamCaps(GstMediaType type, MediaCodecInfo&& codecInfo)
void InterfacePlayerRDK::SetStreamCaps(GstMediaType type, MediaCodecInfo&& codecInfo, const char* protectionSystem)
{
GstCaps *caps = GetCaps(codecInfo.mCodecFormat);
gst_media_stream *stream = &interfacePlayerPriv->gstPrivateContext->stream[type];
Expand Down Expand Up @@ -5452,7 +5452,13 @@ void InterfacePlayerRDK::SetStreamCaps(GstMediaType type, MediaCodecInfo&& codec
gst_structure_set (s,
"original-media-type", G_TYPE_STRING, gst_structure_get_name (s),
NULL);
if (mDrmSystem != NULL)
if (protectionSystem && protectionSystem[0] != '\0')
{
gst_structure_set (s,
GST_PROTECTION_SYSTEM_ID_CAPS_FIELD, G_TYPE_STRING, protectionSystem,
NULL);
}
else if (mDrmSystem != NULL)
{
gst_structure_set (s,
GST_PROTECTION_SYSTEM_ID_CAPS_FIELD, G_TYPE_STRING, mDrmSystem,
Expand Down
2 changes: 1 addition & 1 deletion middleware/InterfacePlayerRDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ class InterfacePlayerRDK
* @param[in] type The media type.
* @param[in] codecInfo The codec information.
*/
void SetStreamCaps(GstMediaType type, MediaCodecInfo&& codecInfo);
void SetStreamCaps(GstMediaType type, MediaCodecInfo&& codecInfo, const char* protectionSystem = nullptr);

private:
InterfacePlayerPriv *interfacePlayerPriv;
Expand Down
15 changes: 14 additions & 1 deletion mp4demux/AampMp4Demuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,20 @@ bool AampMp4Demuxer::sendSegment(std::vector<uint8_t>&& buffer, double position,
{
// Invoke SetStreamCaps for proper codec info
AAMPLOG_INFO("Updating codecInfo with format:%d", codecInfo.mCodecFormat);
mAamp->SetStreamCaps(mMediaType, std::move(codecInfo));
// Extract protection system if present
std::string protectionSystem;
auto protectionEvents = mMp4Demux->GetProtectionEvents();
if (!protectionEvents.empty()) {
static const std::string kWidevineUUID{"edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};
static const std::string kPlayReadyUUID{"9a04f079-9840-4286-ab92-e65be0885f95"};
for (const auto& event : protectionEvents) {
if (event.systemID == kWidevineUUID || event.systemID == kPlayReadyUUID) {
protectionSystem = event.systemID;
break;
}
}
}
mAamp->SetStreamCaps(mMediaType, std::move(codecInfo), protectionSystem.empty() ? nullptr : protectionSystem.c_str());
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions priv_aamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15045,7 +15045,7 @@ void PrivateInstanceAAMP::GetStreamFormat(StreamOutputFormat &primaryOutputForma
* @param[in] type - Media type
* @param[in] codecInfo - Codec information
*/
void PrivateInstanceAAMP::SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo)
void PrivateInstanceAAMP::SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo, const char* protectionSystem)
{
StreamSink *sink = AampStreamSinkManager::GetInstance().GetStreamSink(this);
switch (type)
Expand All @@ -15062,7 +15062,7 @@ void PrivateInstanceAAMP::SetStreamCaps(AampMediaType type, MediaCodecInfo&& cod
AAMPLOG_INFO("Updated format mVideoFormat=%d mAudioFormat=%d", mVideoFormat, mAudioFormat);
if (sink)
{
sink->SetStreamCaps(type, std::move(codecInfo));
sink->SetStreamCaps(type, std::move(codecInfo), protectionSystem);
}
}

Expand Down
2 changes: 1 addition & 1 deletion priv_aamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -4036,7 +4036,7 @@ class PrivateInstanceAAMP : public DrmCallbacks, public std::enable_shared_from_
* @param[in] type - Media type
* @param[in] codecInfo - Codec information
*/
void SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo);
void SetStreamCaps(AampMediaType type, MediaCodecInfo&& codecInfo, const char* protectionSystem = nullptr);

/**
* @fn GetBufferedDurationSecs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,3 +716,27 @@ TEST_F(AampStreamSinkManagerTests, CheckEncryptedHeaders_PlayerNotDeactivated)
AampStreamSinkManager::GetInstance().DeactivatePlayer(mPrivateInstanceAAMP2, true);
}

/* @brief : - Allows encrypted headers to be set before activation when the
single pipeline sink has no active player.
*/
TEST_F(AampStreamSinkManagerTests, SetEncryptedHeaders_NoActivePlayerInSinglePipeline)
{
std::map<int, std::string> setHeaders;
std::map<int, std::string> getHeaders;
setHeaders.insert({1, "Test String1"});

AampStreamSinkManager::GetInstance().CreateStreamSink(mPrivateInstanceAAMP1, mId3HandlerCallback1);
AampStreamSinkManager::GetInstance().SetSinglePipelineMode(mPrivateInstanceAAMP1);
AampStreamSinkManager::GetInstance().CreateStreamSink(mPrivateInstanceAAMP2, mId3HandlerCallback2);

AampStreamSinkManager::GetInstance().ActivatePlayer(mPrivateInstanceAAMP1);
AampStreamSinkManager::GetInstance().DeactivatePlayer(mPrivateInstanceAAMP1, false);
AampStreamSinkManager::GetInstance().UpdateTuningPlayer(mPrivateInstanceAAMP2);

EXPECT_CALL(*g_mockAampGstPlayer, SetEncryptedAamp(mPrivateInstanceAAMP2)).Times(1);
AampStreamSinkManager::GetInstance().SetEncryptedHeaders(mPrivateInstanceAAMP2, setHeaders);
AampStreamSinkManager::GetInstance().GetEncryptedHeaders(getHeaders);

EXPECT_EQ(getHeaders, setHeaders);
}

Loading