RDK Documentation (Open Sourced RDK Components)
aampdrmsessionfactory.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 2018 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  * @file aampdrmsessionfactory.cpp
22  * @brief Source file for AampDrmSessionFactory
23  */
24 
25 #include "aampdrmsessionfactory.h"
26 #if defined(USE_OPENCDM_ADAPTER)
27 #include "AampOcdmBasicSessionAdapter.h"
29 #elif defined(USE_OPENCDM)
30 #include "opencdmsession.h"
31 #else
32 #if defined(USE_PLAYREADY)
33 #include "playreadydrmsession.h"
34 #endif
35 #endif
36 #include "ClearKeyDrmSession.h"
37 
38 /**
39  * @brief Creates an appropriate DRM session based on the given DrmHelper
40  */
41 AampDrmSession* AampDrmSessionFactory::GetDrmSession(AampLogManager *logObj, std::shared_ptr<AampDrmHelper> drmHelper, AampDrmCallbacks *drmCallbacks)
42 {
43  const std::string systemId = drmHelper->ocdmSystemId();
44 
45 #if defined (USE_OPENCDM_ADAPTER)
46  if (drmHelper->isClearDecrypt())
47  {
48 #if defined(USE_CLEARKEY)
49  if (systemId == CLEAR_KEY_SYSTEM_STRING)
50  {
51  return new ClearKeySession(logObj);
52  }
53  else
54 #endif
55  {
56  return new AAMPOCDMBasicSessionAdapter(logObj, drmHelper, drmCallbacks);
57  }
58  }
59  else
60  {
61  return new AAMPOCDMGSTSessionAdapter(logObj, drmHelper);
62  }
63 #elif defined (USE_OPENCDM)
64  return new AAMPOCDMSession(systemId);
65 #else // No form of OCDM support. Attempt to fallback to hardcoded session classes
66  if (systemId == PLAYREADY_KEY_SYSTEM_STRING)
67  {
68 #if defined(USE_PLAYREADY)
69  return new PlayReadyDRMSession(logObj);
70 #endif // USE_PLAYREADY
71  }
72  else if (systemId == CLEAR_KEY_SYSTEM_STRING)
73  {
74 #if defined(USE_CLEARKEY)
75  return new ClearKeySession(logObj);
76 #endif // USE_CLEARKEY
77  }
78 #endif // Not USE_OPENCDM
79  return NULL;
80 }
AampDrmSessionFactory::GetDrmSession
static AampDrmSession * GetDrmSession(AampLogManager *logObj, std::shared_ptr< AampDrmHelper > drmHelper, AampDrmCallbacks *drmCallbacks)
Creates an appropriate DRM session based on the given DrmHelper.
Definition: aampdrmsessionfactory.cpp:41
AampDrmCallbacks
DRM callback interface.
Definition: AampDrmCallbacks.h:34
ClearKeySession
Open CDM DRM session.
Definition: ClearKeyDrmSession.h:42
playreadydrmsession.h
Playready Session management.
AampOcdmGstSessionAdapter.h
File holds operations on OCDM gst sessions.
AAMPOCDMBasicSessionAdapter
OCDM session Adapter.
Definition: AampOcdmBasicSessionAdapter.h:14
AAMPOCDMSession
Open CDM DRM session.
Definition: opencdmsession.h:38
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
PlayReadyDRMSession
Class for PlayReady DRM operations.
Definition: playreadydrmsession.h:48
AAMPOCDMGSTSessionAdapter
OCDM Gstreamer session to decrypt.
Definition: AampOcdmGstSessionAdapter.h:18
aampdrmsessionfactory.h
Header file for AampDrmSessionFactory.
AampDrmSession
Base class for DRM sessions.
Definition: AampDrmSession.h:69
ClearKeyDrmSession.h
Header file for ClearKeySession.
opencdmsession.h
DRM Session management for Aamp.