|
| 1 | +/** |
| 2 | +* If not stated otherwise in this file or this component's LICENSE |
| 3 | +* file the following copyright and licenses apply: |
| 4 | +* |
| 5 | +* Copyright 2019 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 | +#include "HdcpProfileClient.h" |
| 21 | + |
| 22 | +#include "UtilsJsonRpc.h" |
| 23 | + |
| 24 | +#include <glib.h> |
| 25 | +#include <glib/gstdio.h> |
| 26 | + |
| 27 | +#define API_VERSION_NUMBER_MAJOR 1 |
| 28 | +#define API_VERSION_NUMBER_MINOR 0 |
| 29 | +#define API_VERSION_NUMBER_PATCH 0 |
| 30 | + |
| 31 | +using namespace std; |
| 32 | + |
| 33 | +namespace WPEFramework { |
| 34 | + |
| 35 | + namespace { |
| 36 | + |
| 37 | + static Plugin::Metadata<Plugin::HdcpProfileClient> metadata( |
| 38 | + // Version (Major, Minor, Patch) |
| 39 | + API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, |
| 40 | + // Preconditions |
| 41 | + {}, |
| 42 | + // Terminations |
| 43 | + {}, |
| 44 | + // Controls |
| 45 | + {} |
| 46 | + ); |
| 47 | + } |
| 48 | + |
| 49 | + namespace Plugin { |
| 50 | + |
| 51 | + SERVICE_REGISTRATION(HdcpProfileClient, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); |
| 52 | + |
| 53 | + HdcpProfileClient* HdcpProfileClient::_instance = nullptr; |
| 54 | + |
| 55 | + HdcpProfileClient::HdcpProfileClient() |
| 56 | + { |
| 57 | + LOGINFO("ctor"); |
| 58 | + HdcpProfileClient::_instance = this; |
| 59 | + //Register("checkcomrpccomm", &HdcpProfileClient::checkcomrpccomm, this); |
| 60 | + } |
| 61 | + |
| 62 | + HdcpProfileClient::~HdcpProfileClient() |
| 63 | + { |
| 64 | + LOGINFO("dtor"); |
| 65 | + } |
| 66 | + |
| 67 | + const string HdcpProfileClient::Initialize(PluginHost::IShell* service) |
| 68 | + { |
| 69 | + Exchange::IHdcpProfile* _remotStoreObject = nullptr; |
| 70 | + ASSERT(service != nullptr); |
| 71 | + ASSERT(m_service == nullptr); |
| 72 | + |
| 73 | + m_service = service; |
| 74 | + m_service->AddRef(); |
| 75 | + _remotStoreObject = service->QueryInterfaceByCallsign<Exchange::IHdcpProfile>("org.rdk.HdcpProfile"); |
| 76 | + |
| 77 | + // HDCPStatus _hdcpstatus; |
| 78 | + Exchange::IHdcpProfile::HDCPStatus _hdcpstatus; |
| 79 | + bool _success = false; |
| 80 | + _remotStoreObject->GetHDCPStatus(_hdcpstatus, _success); |
| 81 | + if (_success == false) |
| 82 | + { |
| 83 | + LOGERR("getHDCPStatus failed"); |
| 84 | + return (string()); |
| 85 | + } |
| 86 | + LOGINFO("getHDCPStatus: isConnected: %d isHDCPCompliant: %d isHDCPEnabled: %d hdcpReason: %d supportedHDCPVersion: %s receiverHDCPVersion: %s currentHDCPVersion: %s", |
| 87 | + _hdcpstatus.isConnected, _hdcpstatus.isHDCPCompliant, _hdcpstatus.isHDCPEnabled, _hdcpstatus.hdcpReason, |
| 88 | + _hdcpstatus.supportedHDCPVersion.c_str(), _hdcpstatus.receiverHDCPVersion.c_str(), _hdcpstatus.currentHDCPVersion.c_str()); |
| 89 | + ASSERT (nullptr != _remotStoreObject); |
| 90 | + string supportedHDCPVersion; |
| 91 | + bool isHDCPSupported = false; |
| 92 | + bool success1 = false; |
| 93 | + _remotStoreObject->GetSettopHDCPSupport(supportedHDCPVersion, isHDCPSupported, success1); |
| 94 | + if (success1 == false) |
| 95 | + { |
| 96 | + LOGERR("getSettopHDCPSupport failed"); |
| 97 | + return (string()); |
| 98 | + } |
| 99 | + LOGINFO("getSettopHDCPSupport: supportedHDCPVersion: %s isHDCPSupported: %d", supportedHDCPVersion.c_str(), isHDCPSupported); |
| 100 | + //subscribe the events onDisplayConnectionChanged through com-rpc |
| 101 | + //register the notification |
| 102 | + Exchange::IHdcpProfile::INotification* notification = service->QueryInterfaceByCallsign<Exchange::IHdcpProfile::INotification>("org.rdk.HdcpProfile"); |
| 103 | + if (notification == nullptr) |
| 104 | + { |
| 105 | + LOGERR("Failed to get notification interface"); |
| 106 | + return (string()); |
| 107 | + } |
| 108 | + //register the notification |
| 109 | + _remotStoreObject->Register(notification); |
| 110 | + |
| 111 | + |
| 112 | + // if (notification != nullptr) |
| 113 | + // { |
| 114 | + // notification->Release(); |
| 115 | + // notification = nullptr; |
| 116 | + // } |
| 117 | + |
| 118 | + // On success return empty, to indicate there is no error text. |
| 119 | + return (string()); |
| 120 | + } |
| 121 | + |
| 122 | + |
| 123 | + //define the onDisplayConnectionChanged method |
| 124 | + void HdcpProfileClient::OnDisplayConnectionChanged(const Exchange::IHdcpProfile::HDCPStatus& hdcpstatus) |
| 125 | + { |
| 126 | + LOGINFO("OnDisplayConnectionChanged callback triggered: isConnected: %d isHDCPCompliant: %d isHDCPEnabled: %d hdcpReason: %d supportedHDCPVersion: %s receiverHDCPVersion: %s currentHDCPVersion: %s", |
| 127 | + hdcpstatus.isConnected, hdcpstatus.isHDCPCompliant, hdcpstatus.isHDCPEnabled, hdcpstatus.hdcpReason, |
| 128 | + hdcpstatus.supportedHDCPVersion.c_str(), hdcpstatus.receiverHDCPVersion.c_str(), hdcpstatus.currentHDCPVersion.c_str()); |
| 129 | + } |
| 130 | + |
| 131 | + |
| 132 | + void HdcpProfileClient::Deinitialize(PluginHost::IShell* service ) |
| 133 | + { |
| 134 | + ASSERT(service == m_service); |
| 135 | + |
| 136 | + m_service->Release(); |
| 137 | + m_service = nullptr; |
| 138 | + } |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | + } // namespace Plugin |
| 143 | +} // namespace WPEFramework |
0 commit comments