RDK Documentation (Open Sourced RDK Components)
getHDCPStatus.cpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 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 * @defgroup devicesettings
22 * @{
23 * @defgroup sample
24 * @{
25 **/
26 
27 
28  #include <stdint.h>
29 #include <iostream>
30 #include "host.hpp"
31 #include "videoOutputPort.hpp"
32 #include "videoOutputPortType.hpp"
33 #include "videoResolution.hpp"
34 #include "manager.hpp"
35 
36 #include "dsUtl.h"
37 #include "dsError.h"
38 #include "list.hpp"
39 #include <stdlib.h>
40 #include <unistd.h>
41 #include <string.h>
42 
43 #include "libIBus.h"
44 #include "dsMgr.h"
45 int iCallback = 0;
46 void _HDCPHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);
47 
48 int main(int argc, char *argv[])
49 {
50  int hdpcStatus = 0;
51 
52  IARM_Bus_Init("SampleDSClient");
54 
55 
56  IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,
58  _HDCPHandler);
59 
61 
62 
64 
65  if (vPort.isDisplayConnected()) {
66 
67  hdpcStatus = vPort.getHDCPStatus();
68  printf("\n >>>>>>>> hdpcStatus : %d\n",hdpcStatus);
69 
70  while(1)
71  {
72  printf("\n >>>>>>>> Perform a HDMI Hot Plug to get a HDCP status \r\n");
73  if(iCallback)
74  {
75  printf("\n >>>>>>>> Got a HDCP status .. \r\n");
76  break;
77  }
78  sleep(30);
79  }
80 
81  hdpcStatus = vPort.getHDCPStatus();
82  printf("\n >>>>>>>> hdpcStatus : %d\n",hdpcStatus);
83 
84  switch (hdpcStatus)
85  {
87  {
88  printf("\n >>>>>>>> HDCP Authenticated \r\n");
89  }
90  break;
92  {
93  printf("\n >>>>>>>> HDCP Failure \r\n");
94 
95  }
96  break;
97 
99  {
100  printf("\n >>>>>>>> HDCP Authentication not Initiated \r\n");
101  }
102  break;
103  }
104  printf("\n >>>>>>>> hdpcStatus : %d\n",hdpcStatus);
105  }
106  else
107  {
108  printf("\t Display [%s] connected\r\n", vPort.isDisplayConnected() ? "is" : "is NOT");
109  }
110 
113  IARM_Bus_Term();
114 
115  return 0;
116 }
117 
118 
119 void _HDCPHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
120 {
121  if (strcmp(owner,IARM_BUS_DSMGR_NAME) == 0)
122  {
123  printf("_HDCPHandler called %d ......... \r\n",eventId);
124  switch (eventId) {
126  {
127  iCallback = 1;
128  }
129  break;
130  default:
131  break;
132  }
133  }
134 }
135 
136 
137 /** @} */
138 /** @} */
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
dsHDCP_STATUS_AUTHENTICATED
@ dsHDCP_STATUS_AUTHENTICATED
Definition: dsTypes.h:416
device::VideoOutputPort::isDisplayConnected
bool isDisplayConnected() const
This API is used to Check if the port is currently connected to any display device.
Definition: videoOutputPort.cpp:381
device::VideoOutputPort
Class extending enumerable to implement the videoooutputport interface.
Definition: videoOutputPort.hpp:59
dsHDCP_STATUS_UNAUTHENTICATED
@ dsHDCP_STATUS_UNAUTHENTICATED
Definition: dsTypes.h:415
manager.hpp
It contains class referenced by manager.cpp file.
IARM_Bus_RegisterEventHandler
IARM_Result_t IARM_Bus_RegisterEventHandler(const char *ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler)
This API register to listen to event and provide the callback function for event notification....
Definition: iarmMgrMocks.cpp:43
dsError.h
Device Settings HAL error codes.
dsUtl.h
Device Settings HAL utilities.
IARM_BUS_DSMGR_EVENT_HDCP_STATUS
@ IARM_BUS_DSMGR_EVENT_HDCP_STATUS
Definition: dsMgr.h:52
IARM_Bus_Disconnect
IARM_Result_t IARM_Bus_Disconnect(void)
This API disconnect Application from IARM Bus so the application will not receive any IARM event or R...
videoOutputPortType.hpp
It contains structures and class referenced by the videoOutputportTypes.cpp file.
device::Manager::Initialize
static void Initialize()
This API is used to initialize the Device Setting module. Each API should be called by any client of ...
Definition: manager.cpp:97
videoResolution.hpp
It contains class and structure refrenced by the videoResolution.cpp file.
libIBus.h
RDK IARM-Bus API Declarations.
videoOutputPort.hpp
It contains class and structure refrenced by the videooutputport.cpp file.
device::Manager::DeInitialize
static void DeInitialize()
This API is used to deinitialize the device settings module. DeInitialize() must be called to release...
Definition: manager.cpp:138
device::Host::getVideoOutputPort
VideoOutputPort & getVideoOutputPort(const std::string &name)
This API is used to get the reference to the video output port by its name. The name of the port must...
Definition: host.cpp:350
device::Host::getInstance
static Host & getInstance(void)
This API is used to get a reference to the single instance of the Host object.
Definition: host.cpp:88
IARM_Bus_Connect
IARM_Result_t IARM_Bus_Connect(void)
This API is used to connect application to the IARM bus daemon. After connected, the application can ...
Definition: iarmMgrMocks.cpp:33
dsHDCP_STATUS_AUTHENTICATIONFAILURE
@ dsHDCP_STATUS_AUTHENTICATIONFAILURE
Definition: dsTypes.h:417
IARM_Bus_Init
IARM_Result_t IARM_Bus_Init(const char *name)
This API is used to initialize the IARM-Bus library.
Definition: iarmMgrMocks.cpp:38