RDK Documentation (Open Sourced RDK Components)
AampHlsDrmSessionManager.cpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2020 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 /**
22  * @file AampHlsDrmSessionManager.cpp
23  * @brief Operations for HLS DRM
24  */
25 
27 #include "AampDRMSessionManager.h"
28 #include "AampDrmHelper.h"
29 #include "AampHlsOcdmBridge.h"
30 
31 using namespace std;
32 
33 /**
34  * @brief getInstance Get DRM instance
35  * Get an instance of the Hls DRM Session Manager
36  */
38 {
39  static AampHlsDrmSessionManager instance;
40  return instance;
41 }
42 
43 /**
44  * @brief Check stream is DRM supported
45  */
46 bool AampHlsDrmSessionManager::isDrmSupported(const struct DrmInfo& drmInfo) const
47 {
48  return AampDrmHelperEngine::getInstance().hasDRM(drmInfo);
49 }
50 
51 /**
52  * @brief createSession create session for DRM
53  */
54 std::shared_ptr<HlsDrmBase> AampHlsDrmSessionManager::createSession(PrivateInstanceAAMP* aampInstance, const struct DrmInfo& drmInfo,MediaType streamType, AampLogManager *mLogObj)
55 {
56  std::shared_ptr<HlsDrmBase> bridge = nullptr;
57  std::shared_ptr<AampDrmHelper> drmHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo, mLogObj);
58  aampInstance->mDRMSessionManager->setSessionMgrState(SessionMgrState::eSESSIONMGR_ACTIVE);
59 
60  aampInstance->profiler.ProfileBegin(PROFILE_BUCKET_LA_TOTAL);
61  DrmMetaDataEventPtr event = std::make_shared<DrmMetaDataEvent>(AAMP_TUNE_FAILURE_UNKNOWN, "", 0, 0, false);
62  mDrmSession = aampInstance->mDRMSessionManager->createDrmSession(drmHelper, event, aampInstance, streamType);
63  if (!mDrmSession)
64  {
65  AAMPLOG_WARN("Failed to create Drm Session ");
66 
67  if (aampInstance->DownloadsAreEnabled())
68  {
69  AAMPTuneFailure failure = event->getFailure();
70 
71  aampInstance->DisableDownloads();
72  aampInstance->SendErrorEvent(failure);
73 
74  aampInstance->profiler.ProfileError(PROFILE_BUCKET_LA_TOTAL, (int) failure);
75  }
76  }
77  else
78  {
79  AAMPLOG_WARN("created Drm Session ");
80  bridge = std::make_shared<AampHlsOcdmBridge>(mLogObj, mDrmSession);
81  }
82  aampInstance->profiler.ProfileEnd(PROFILE_BUCKET_LA_TOTAL);
83  return bridge;
84 }
AampDRMSessionManager.h
Header file for DRM session manager.
AampDrmHelper.h
Implented DRM helper functionalities.
AampDrmHelperEngine::getInstance
static AampDrmHelperEngine & getInstance()
Get an instance of the DRM Helper Engine.
Definition: AampDrmHelperFactory.cpp:37
eSESSIONMGR_ACTIVE
@ eSESSIONMGR_ACTIVE
Definition: AampDRMSessionManager.h:138
AampHlsDrmSessionManager::createSession
std::shared_ptr< HlsDrmBase > createSession(PrivateInstanceAAMP *aampInstance, const struct DrmInfo &drmInfo, MediaType streamType, AampLogManager *logObj=NULL)
createSession create session for DRM
Definition: AampHlsDrmSessionManager.cpp:54
AampHlsDrmSessionManager
DRM Session manager for HLS stream operations.
Definition: AampHlsDrmSessionManager.h:38
AAMP_TUNE_FAILURE_UNKNOWN
@ AAMP_TUNE_FAILURE_UNKNOWN
Definition: AampEvent.h:147
AampHlsOcdmBridge.h
Handles OCDM bridge to validate DRM License.
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
ProfileEventAAMP::ProfileError
void ProfileError(ProfilerBucketType type, int result=-1)
Marking error while executing a bucket.
Definition: AampProfiler.cpp:311
DrmInfo
DRM information required to decrypt.
Definition: AampDrmInfo.h:47
MediaType
MediaType
Media types.
Definition: AampMediaType.h:37
AampHlsDrmSessionManager::getInstance
static AampHlsDrmSessionManager & getInstance()
getInstance Get DRM instance Get an instance of the Hls DRM Session Manager
Definition: AampHlsDrmSessionManager.cpp:37
AAMPTuneFailure
AAMPTuneFailure
AAMP playback error codes.
Definition: AampEvent.h:108
ProfileEventAAMP::ProfileBegin
void ProfileBegin(ProfilerBucketType type)
Marking the beginning of a bucket.
Definition: AampProfiler.cpp:297
PrivateInstanceAAMP
Class representing the AAMP player's private instance, which is not exposed to outside world.
Definition: priv_aamp.h:640
PrivateInstanceAAMP::SendErrorEvent
void SendErrorEvent(AAMPTuneFailure tuneFailure, const char *description=NULL, bool isRetryEnabled=true, int32_t secManagerClassCode=-1, int32_t secManagerReasonCode=-1, int32_t secClientBusinessStatus=-1)
Handles errors and sends events to application if required. For download failures,...
Definition: priv_aamp.cpp:2454
ProfileEventAAMP::ProfileEnd
void ProfileEnd(ProfilerBucketType type)
Marking the end of a bucket.
Definition: AampProfiler.cpp:325
AampDrmHelperEngine::hasDRM
bool hasDRM(const struct DrmInfo &drmInfo) const
Determines whether the helper engine has a DRM helper available for the specified DrmInfo.
Definition: AampDrmHelper.h:308
AampHlsDrmSessionManager::isDrmSupported
bool isDrmSupported(const struct DrmInfo &drmInfo) const
Check stream is DRM supported.
Definition: AampHlsDrmSessionManager.cpp:46
PrivateInstanceAAMP::DownloadsAreEnabled
bool DownloadsAreEnabled(void)
Check if downloads are enabled.
Definition: priv_aamp.cpp:6752
PrivateInstanceAAMP::DisableDownloads
void DisableDownloads(void)
abort ongoing downloads and returns error on future downloads called while stopping fragment collecto...
Definition: priv_aamp.cpp:6741
PROFILE_BUCKET_LA_TOTAL
@ PROFILE_BUCKET_LA_TOTAL
Definition: AampProfiler.h:67
AampHlsDrmSessionManager.h
Operations for HLS DRM.
AampDrmHelperEngine::createHelper
std::shared_ptr< AampDrmHelper > createHelper(const struct DrmInfo &drmInfo, AampLogManager *logObj=NULL) const
Build a helper class to support the identified DRM.
Definition: AampDrmHelperFactory.cpp:69