I’m developing a plugin using the MIP SDK, and I would like to check whether the Bookmark feature is available before enabling bookmark-related UI/actions.
What is the recommended way in a MIP SDK plugin to determine:
Whether bookmarks are supported at the product/license level
for example, depending on the XProtect product edition.
Whether you can use bookmarks is a part of the permissions on the camera.
Using the Configuration API a administrator user can check the permissions for the camera for a certain role.
Given the scenario that this is a plugin this is impractical for two reason. There is no easy way to find out which role the user belongs to, and even more relevant, the plugin will always be operating in the context of the logged in user, so no admin rights to allow the look up using Configuration API.
What you can do.
You can use the CheckPermission method.
This snippet of code shows how.
private bool CheckBookmark(Item cameraItem)
{
try
{
// checking permission "READ_BOOKMARKS" for the camera item,
// other options are "DELETE_BOOKMARKS", "CREATE_BOOKMARKS", "EDIT_BOOKMARKS"
VideoOS.Platform.Util.SecurityAccess.CheckPermission(cameraItem,
"READ_BOOKMARKS"
);
}
catch (NotAuthorizedMIPException)
{
return false;
}
catch (Exception ex)
{
EnvironmentManager.Instance.Log(
true,
"MyTest CheckPermission",
ex.ToString()
);
return false;
}
return true;
}
Please note that this will work even if the XProtect VMS is a product version not supporting bookmarking.
If you are investigating further into which permissions are possible you can do so using the Config API Client sample.