Loading drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp +51 −2 Original line number Diff line number Diff line Loading @@ -45,10 +45,12 @@ namespace V1_1 { namespace clearkey { DrmPlugin::DrmPlugin(SessionLibrary* sessionLibrary) : mSessionLibrary(sessionLibrary) { : mSessionLibrary(sessionLibrary), mOpenSessionOkCount(0), mCloseSessionOkCount(0), mCloseSessionNotOpenedCount(0) { mPlayPolicy.clear(); initProperties(); } void DrmPlugin::initProperties() { Loading Loading @@ -77,6 +79,7 @@ Return<void> DrmPlugin::openSession(openSession_cb _hidl_cb) { setSecurityLevel(sessionId, SecurityLevel::SW_SECURE_CRYPTO); _hidl_cb(Status::OK, toHidlVec(sessionId)); mOpenSessionOkCount++; return Void(); } Loading @@ -87,9 +90,11 @@ Return<Status> DrmPlugin::closeSession(const hidl_vec<uint8_t>& sessionId) { sp<Session> session = mSessionLibrary->findSession(toVector(sessionId)); if (session.get()) { mCloseSessionOkCount++; mSessionLibrary->destroySession(session); return Status::OK; } mCloseSessionNotOpenedCount++; return Status::ERROR_DRM_SESSION_NOT_OPENED; } Loading Loading @@ -364,6 +369,50 @@ Return<Status> DrmPlugin::setSecurityLevel(const hidl_vec<uint8_t>& sessionId, return Status::OK; } Return<void> DrmPlugin::getMetrics(getMetrics_cb _hidl_cb) { // Set the open session count metric. DrmMetricGroup::Attribute openSessionOkAttribute = { "status", DrmMetricGroup::ValueType::INT64_TYPE, (int64_t) Status::OK, 0.0, "" }; DrmMetricGroup::Value openSessionMetricValue = { "count", DrmMetricGroup::ValueType::INT64_TYPE, mOpenSessionOkCount, 0.0, "" }; DrmMetricGroup::Metric openSessionMetric = { "open_session", { openSessionOkAttribute }, { openSessionMetricValue } }; // Set the close session count metric. DrmMetricGroup::Attribute closeSessionOkAttribute = { "status", DrmMetricGroup::ValueType::INT64_TYPE, (int64_t) Status::OK, 0.0, "" }; DrmMetricGroup::Value closeSessionMetricValue = { "count", DrmMetricGroup::ValueType::INT64_TYPE, mCloseSessionOkCount, 0.0, "" }; DrmMetricGroup::Metric closeSessionMetric = { "close_session", { closeSessionOkAttribute }, { closeSessionMetricValue } }; // Set the close session, not opened metric. DrmMetricGroup::Attribute closeSessionNotOpenedAttribute = { "status", DrmMetricGroup::ValueType::INT64_TYPE, (int64_t) Status::ERROR_DRM_SESSION_NOT_OPENED, 0.0, "" }; DrmMetricGroup::Value closeSessionNotOpenedMetricValue = { "count", DrmMetricGroup::ValueType::INT64_TYPE, mCloseSessionNotOpenedCount, 0.0, "" }; DrmMetricGroup::Metric closeSessionNotOpenedMetric = { "close_session", { closeSessionNotOpenedAttribute }, { closeSessionNotOpenedMetricValue } }; DrmMetricGroup metrics = { { openSessionMetric, closeSessionMetric, closeSessionNotOpenedMetric } }; _hidl_cb(Status::OK, hidl_vec<DrmMetricGroup>({metrics})); return Void(); } } // namespace clearkey } // namespace V1_1 } // namespace drm Loading drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h +7 −5 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ using ::android::hardware::drm::V1_0::KeyValue; using ::android::hardware::drm::V1_0::SecureStop; using ::android::hardware::drm::V1_0::SecureStopId; using ::android::hardware::drm::V1_0::Status; using ::android::hardware::drm::V1_1::DrmMetricGroup; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; Loading @@ -45,6 +46,7 @@ using ::android::hardware::Return; using ::android::hardware::Void; using ::android::sp; struct DrmPlugin : public IDrmPlugin { explicit DrmPlugin(SessionLibrary* sessionLibrary); Loading Loading @@ -163,6 +165,8 @@ struct DrmPlugin : public IDrmPlugin { Return<Status> setSecurityLevel(const hidl_vec<uint8_t>& sessionId, SecurityLevel level) override; Return<void> getMetrics(getMetrics_cb _hidl_cb) override; Return<void> getPropertyString( const hidl_string& name, getPropertyString_cb _hidl_cb) override; Loading Loading @@ -302,11 +306,6 @@ struct DrmPlugin : public IDrmPlugin { return Void(); } Return<void> getMetrics(getMetrics_cb _hidl_cb) { _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, hidl_vec<DrmMetricGroup>()); return Void(); } Return<void> getSecureStopIds(getSecureStopIds_cb _hidl_cb) { _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, hidl_vec<SecureStopId>()); return Void(); Loading Loading @@ -340,6 +339,9 @@ private: std::map<std::vector<uint8_t>, SecurityLevel> mSecurityLevel; sp<IDrmPluginListener> mListener; SessionLibrary *mSessionLibrary; int64_t mOpenSessionOkCount; int64_t mCloseSessionOkCount; int64_t mCloseSessionNotOpenedCount; CLEARKEY_DISALLOW_COPY_AND_ASSIGN_AND_NEW(DrmPlugin); }; Loading Loading
drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp +51 −2 Original line number Diff line number Diff line Loading @@ -45,10 +45,12 @@ namespace V1_1 { namespace clearkey { DrmPlugin::DrmPlugin(SessionLibrary* sessionLibrary) : mSessionLibrary(sessionLibrary) { : mSessionLibrary(sessionLibrary), mOpenSessionOkCount(0), mCloseSessionOkCount(0), mCloseSessionNotOpenedCount(0) { mPlayPolicy.clear(); initProperties(); } void DrmPlugin::initProperties() { Loading Loading @@ -77,6 +79,7 @@ Return<void> DrmPlugin::openSession(openSession_cb _hidl_cb) { setSecurityLevel(sessionId, SecurityLevel::SW_SECURE_CRYPTO); _hidl_cb(Status::OK, toHidlVec(sessionId)); mOpenSessionOkCount++; return Void(); } Loading @@ -87,9 +90,11 @@ Return<Status> DrmPlugin::closeSession(const hidl_vec<uint8_t>& sessionId) { sp<Session> session = mSessionLibrary->findSession(toVector(sessionId)); if (session.get()) { mCloseSessionOkCount++; mSessionLibrary->destroySession(session); return Status::OK; } mCloseSessionNotOpenedCount++; return Status::ERROR_DRM_SESSION_NOT_OPENED; } Loading Loading @@ -364,6 +369,50 @@ Return<Status> DrmPlugin::setSecurityLevel(const hidl_vec<uint8_t>& sessionId, return Status::OK; } Return<void> DrmPlugin::getMetrics(getMetrics_cb _hidl_cb) { // Set the open session count metric. DrmMetricGroup::Attribute openSessionOkAttribute = { "status", DrmMetricGroup::ValueType::INT64_TYPE, (int64_t) Status::OK, 0.0, "" }; DrmMetricGroup::Value openSessionMetricValue = { "count", DrmMetricGroup::ValueType::INT64_TYPE, mOpenSessionOkCount, 0.0, "" }; DrmMetricGroup::Metric openSessionMetric = { "open_session", { openSessionOkAttribute }, { openSessionMetricValue } }; // Set the close session count metric. DrmMetricGroup::Attribute closeSessionOkAttribute = { "status", DrmMetricGroup::ValueType::INT64_TYPE, (int64_t) Status::OK, 0.0, "" }; DrmMetricGroup::Value closeSessionMetricValue = { "count", DrmMetricGroup::ValueType::INT64_TYPE, mCloseSessionOkCount, 0.0, "" }; DrmMetricGroup::Metric closeSessionMetric = { "close_session", { closeSessionOkAttribute }, { closeSessionMetricValue } }; // Set the close session, not opened metric. DrmMetricGroup::Attribute closeSessionNotOpenedAttribute = { "status", DrmMetricGroup::ValueType::INT64_TYPE, (int64_t) Status::ERROR_DRM_SESSION_NOT_OPENED, 0.0, "" }; DrmMetricGroup::Value closeSessionNotOpenedMetricValue = { "count", DrmMetricGroup::ValueType::INT64_TYPE, mCloseSessionNotOpenedCount, 0.0, "" }; DrmMetricGroup::Metric closeSessionNotOpenedMetric = { "close_session", { closeSessionNotOpenedAttribute }, { closeSessionNotOpenedMetricValue } }; DrmMetricGroup metrics = { { openSessionMetric, closeSessionMetric, closeSessionNotOpenedMetric } }; _hidl_cb(Status::OK, hidl_vec<DrmMetricGroup>({metrics})); return Void(); } } // namespace clearkey } // namespace V1_1 } // namespace drm Loading
drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h +7 −5 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ using ::android::hardware::drm::V1_0::KeyValue; using ::android::hardware::drm::V1_0::SecureStop; using ::android::hardware::drm::V1_0::SecureStopId; using ::android::hardware::drm::V1_0::Status; using ::android::hardware::drm::V1_1::DrmMetricGroup; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; Loading @@ -45,6 +46,7 @@ using ::android::hardware::Return; using ::android::hardware::Void; using ::android::sp; struct DrmPlugin : public IDrmPlugin { explicit DrmPlugin(SessionLibrary* sessionLibrary); Loading Loading @@ -163,6 +165,8 @@ struct DrmPlugin : public IDrmPlugin { Return<Status> setSecurityLevel(const hidl_vec<uint8_t>& sessionId, SecurityLevel level) override; Return<void> getMetrics(getMetrics_cb _hidl_cb) override; Return<void> getPropertyString( const hidl_string& name, getPropertyString_cb _hidl_cb) override; Loading Loading @@ -302,11 +306,6 @@ struct DrmPlugin : public IDrmPlugin { return Void(); } Return<void> getMetrics(getMetrics_cb _hidl_cb) { _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, hidl_vec<DrmMetricGroup>()); return Void(); } Return<void> getSecureStopIds(getSecureStopIds_cb _hidl_cb) { _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, hidl_vec<SecureStopId>()); return Void(); Loading Loading @@ -340,6 +339,9 @@ private: std::map<std::vector<uint8_t>, SecurityLevel> mSecurityLevel; sp<IDrmPluginListener> mListener; SessionLibrary *mSessionLibrary; int64_t mOpenSessionOkCount; int64_t mCloseSessionOkCount; int64_t mCloseSessionNotOpenedCount; CLEARKEY_DISALLOW_COPY_AND_ASSIGN_AND_NEW(DrmPlugin); }; Loading