Wasabi ExpressPlay SDK for Embedded Systems  1.23.0
EmbStorage.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | EMBB Object Storage
4 |
5 | $Id: EmbStorage.h 2017-10-03
6 | Original author: Kiran Kumar G
7 |
8 | This software is provided to you pursuant to your agreement
9 | with Intertrust Technologies Corporation ("Intertrust").
10 | This software may be used only in accordance with the terms
11 | of the agreement.
12 |
13 | Copyright (c) 2017-2018 by Intertrust. All rights reserved.
14 |
15 ****************************************************************/
21 #ifndef _EMB_STORAGE_H_
22 #define _EMB_STORAGE_H_
23 
24 /*----------------------------------------------------------------------
25 | includes
26 +---------------------------------------------------------------------*/
27 #include "EmbProcessor.h"
28 #include "EmbItem.h"
29 
30 /*----------------------------------------------------------------------
31 | types
32 +---------------------------------------------------------------------*/
33 
42 typedef struct EMB_Storage EMB_Storage;
43 
44 /*----------------------------------------------------------------------
45 | functions
46 +---------------------------------------------------------------------*/
47 #if defined(__cplusplus)
48 extern "C" {
49 #endif
50 
61 EMB_Storage_Open(EMB_Storage** storage);
62 
119  EMB_ItemType item_type,
120  EMB_UInt32 id_count,
121  EMB_ByteArray** ids,
122  EMB_Bool hash_content_ids,
123  SHI_Data** items);
124 /*
125  * Finds the epl items (both expired and non-expired) targeted to a given group id.
126  *
127  * This method returns EMB_ERROR_STORAGE_NO_ITEM if no match was found, or
128  * EMB_ERROR_STORAGE_LOOKUP if an error occurred during lookup.
129  *
130  * @param storage An EMBB Storage
131  * @param item_type Supported item type is EMB_IT_EPL.
132  * @param group_id The EPL items targeted to a group id.
133  * @param items Address of a SHI_Data pointer that will, upon successful return,
134  * be set to point to a SHI_Data object representing an array of
135  * one or more items.
136  * This SHI_Data object will have a value of type
137  * SHI_DATA_TYPE_ARRAY, where each element in the array will be of
138  * type SHI_DATA_TYPE_POINTER, so its value is a SHI_TypedPointer.
139  * Each SHI_TypedPointer structure in the array will have its
140  * type_id field set to EMB_TYPE_ID_EMBB_OBJ and its pointer field
141  * pointing to an EMB_Item.
142  * The caller is responsible for calling SHI_Data_Release to
143  * release the SHI_Data object containing the array when it is no
144  * longer needed. The EMB_Object pointed to by the array are no
145  * longer valid and should not be accessed after the caller has
146  * called SHI_Data_Release.
147  */
150  EMB_ItemType item_type,
151  EMB_ByteArray group_id,
152  SHI_Data** items);
153 
188  EMB_ItemType item_type,
189  EMB_UInt32 item_id,
190  SHI_Data** item);
191 
201  EMB_ItemType item_type,
202  EMB_UInt32 id_count,
203  EMB_ByteArray** ids);
204 
214 EMB_Storage_RemoveItem(EMB_Storage* storage, EMB_ItemType item_type, EMB_UInt32 item_id);
215 
227 
236 
245 
249 #include <time.h>
250 
254 typedef void *EPD_Storage;
255 
259 #define INVALID_EPD_STORAGE (void *)NULL
260 
274 EMB_Storage_GetEntitlementStorage(EMB_Storage *storage, EPD_Storage *epds);
275 
287 EMB_Storage_ReleaseEntitlementStorage(EMB_Storage *storage, EPD_Storage epds);
288 
300 EMB_Storage_CleanupEntitlementStorage(EMB_Storage *storage, time_t expirationDate);
301 
302 
303 /*
304  * EPD_Storage
305  *
306  * The EPD_Storage is part of the EMBB storage.
307  * An handle to the EPD_Storage is obtained by calling \e EMB_Storage_GetEntitlementStorage
308  * and released by calling \e EMB_Storage_ReleaseEntitlementStorage. More than one handle can be
309  * created and used at any point in time.
310  * The EPD_Storage contains information about Entitlement Package Descriptions (EPDs)
311  * and can be queried according the criteria defined by the following functions:
312  * - \e EPD_Storage_GetPackageById
313  * - \e EPD_Storage_GetPackagesForContent
314  * - \e EPD_Storage_GetPackages
315  * - \e EPD_Storage_GetContentForPackage
316  *
317  * The above functions allocates memory to return a result set. Such result set must be released by calling the corresponding function
318  * when no longer needed.
319  *
320  */
321 
322 #include <stdint.h>
323 
329 typedef int XPCA_package_type_t;
330 #define MIN_XPCA_PACKAGE_TYPE 1
331 #define MAX_XPCA_PACKAGE_TYPE 15
332 #define ANY_XPCA_PACKAGE_TYPE 0
333 
341 #define MIN_XPCA_PACKAGE_ACCESS 1
342 #define MAX_XPCA_PACKAGE_ACCESS 15
343 #define ANY_XPCA_PACKAGE_ACCESS 0
344 
348 typedef struct {
349  uint32_t id;
350  char name[20];
351  time_t startDate;
352  time_t endDate;
353  XPCA_package_type_t type;
354  XPCA_package_access_t access;
355  int lcidSize;
356  uint32_t lcid[1];
357 } XPCA_Package;
358 
359 
368 #define XPCA_CONTENT_STATUS_IS_IN_EPD(status) (((status) & 0x01) == 0x01)
369 #define XPCA_CONTENT_STATUS_IS_IN_EPL(status) (((status) & 0x02) == 0x02)
370 #define XPCA_CONTENT_STATUS_CHECK_ERROR(status) (((status) & 0x80) == 0x80)
371 
391 typedef struct {
392  uint8_t contentId[EMB_CONTENT_ID_HASH_LENGTH];
393  uint32_t status;
394  int32_t eplGroupId;
397 } XPCA_Content;
398 
402 typedef struct {
403  int32_t pkgGroupId;
406  uint32_t size;
407  XPCA_Content content[1];
409 
414 typedef struct {
415  uint32_t size;
416  uint32_t value[1];
418 
422 #define EPD_INFINITE_TIME ((time_t)(-1))
423 
441 EPD_Storage_GetPackageById(EPD_Storage epds, uint32_t id, XPCA_Package **package);
442 
463 EPD_Storage_GetPackagesForContent(EPD_Storage epds, uint32_t lcid, XPCA_package_type_t type, XPCA_package_access_t access, XPCA_UintArray **array);
464 
483 EPD_Storage_GetPackages(EPD_Storage epds, XPCA_package_type_t type, XPCA_package_access_t access, XPCA_UintArray **array);
484 
507 EPD_Storage_GetContentForPackage(EPD_Storage epds, uint32_t id, XPCA_PackageContentArray **array);
508 
521 EPD_Storage_ReleasePackage(EPD_Storage epds, XPCA_Package *package);
522 
536 EPD_Storage_ReleaseUintArray(EPD_Storage epds, XPCA_UintArray *array);
537 
551 
554 #if defined(__cplusplus)
555 }
556 #endif /* __cplusplus */
557 
558 #endif /* _EMB_STORAGE_H_ */
EMB_EXPORT EMB_Result EMB_Storage_Wipe()
Wipes the EMBB and license storage by deleting the underlying database.
EMB_EXPORT EMB_Result EPD_Storage_GetContentForPackage(EPD_Storage epds, uint32_t id, XPCA_PackageContentArray **array)
This API searches the EPD_Storage and the EMB_Storage for the content access definition XPCA_ContentA...
time_t startDate
UTC time, always valid.
Definition: EmbStorage.h:351
int lcidSize
Size of the variable-length array.
Definition: EmbStorage.h:355
This is a variable-size array of XPCA_Content data.
Definition: EmbStorage.h:402
#define EMB_CONTENT_ID_HASH_LENGTH
Definition: EmbProcessor.h:38
uint32_t id
Package id.
Definition: EmbStorage.h:349
int32_t eplGroupId
Group id from the EPL, -1 if contentID is missing in the EPL or it is not associated with a group...
Definition: EmbStorage.h:394
uint32_t size
Size of the variable-length array.
Definition: EmbStorage.h:415
EMB_EXPORT EMB_Result EMB_Storage_ReleaseEntitlementStorage(EMB_Storage *storage, EPD_Storage epds)
Release the handle to the EPD_storage database.
EMB (Extended Marlin Broadcast) Processor API.
EMB_EXPORT EMB_Result EMB_Storage_CleanupEntitlementStorage(EMB_Storage *storage, time_t expirationDate)
Remove from the EMBB storage EPD entries that have expired.
XPCA_package_type_t type
Type of package.
Definition: EmbStorage.h:353
EMB_EXPORT EMB_Result EMB_Storage_RemoveItemsByIds(EMB_Storage *storage, EMB_ItemType item_type, EMB_UInt32 id_count, EMB_ByteArray **ids)
Removes the list of the items specified in the EMB_ByteArray from the EMBB Storage.
void * EPD_Storage
Entitlement Package Description (EPD) specific operations.
Definition: EmbStorage.h:254
EMB_EXPORT EMB_Result EMB_Storage_FindItemsByIds(EMB_Storage *storage, EMB_ItemType item_type, EMB_UInt32 id_count, EMB_ByteArray **ids, EMB_Bool hash_content_ids, SHI_Data **items)
Finds in the EMBB Storage the items that contain the specified id(s).
EMB_EXPORT EMB_Result EPD_Storage_ReleaseUintArray(EPD_Storage epds, XPCA_UintArray *array)
Release a XPCA_UintArray result set returned by a successful call to EPD_Storage_GetPackages or EPD_S...
EMB_EXPORT EMB_Result EPD_Storage_GetPackages(EPD_Storage epds, XPCA_package_type_t type, XPCA_package_access_t access, XPCA_UintArray **array)
This API searches the EPD_Storage for packages whose access and type match the input criteria access ...
uint32_t status
Bitmask, use XPCA_CONTENT_STATUS_IS_IN_xxx to access the bitmask.
Definition: EmbStorage.h:393
EMB_EXPORT EMB_Result EMB_Storage_ExpungeExpiredItems(EMB_Storage *storage, EMB_ItemType item_type)
Expunges all expired items of item type from the EMBB storage.
The following structure defines the characteristics of a package.
Definition: EmbStorage.h:348
int EMB_Result
Signed integer value representing a function or method result (return value).
Definition: EmbTypes.h:38
EMB_EXPORT EMB_Result EPD_Storage_ReleasePackageContentArray(EPD_Storage epds, XPCA_PackageContentArray *array)
Release a XPCA_PackageContentArray result set returned by a successful call to EPD_Storage_GetContent...
An XPCA_Content type describes the status of a protected content with regard to the license associate...
Definition: EmbStorage.h:391
int XPCA_package_access_t
Accessibility of a package.
Definition: EmbStorage.h:340
int32_t pkgGroupId
Group id from the package, -1 if contentID is missing in the EPL or it is not associated with a group...
Definition: EmbStorage.h:403
bool EMB_Bool
A boolean value which can be either true or false.
Definition: EmbTypes.h:79
EMB_EXPORT EMB_Result EPD_Storage_GetPackagesForContent(EPD_Storage epds, uint32_t lcid, XPCA_package_type_t type, XPCA_package_access_t access, XPCA_UintArray **array)
This API searches the EPD_Storage for packages including the entitlement item (logical content id) lc...
EMB_EXPORT EMB_Result EMB_Storage_GetEntitlementStorage(EMB_Storage *storage, EPD_Storage *epds)
Factory function to create an handle to access the EPD_Storage database.
XPCA_package_access_t access
Accessibility of the package.
Definition: EmbStorage.h:354
EMB_EXPORT EMB_Result EMB_Storage_Open(EMB_Storage **storage)
Opens the EMBB storage and creates a new EMB_Storage object to refer to it.
EMB_ItemType
EMBB item type.
Definition: EmbItem.h:53
EMB_EXPORT EMB_Result EMB_Storage_FindItemsTargetAtGroup(EMB_Storage *storage, EMB_ItemType item_type, EMB_ByteArray group_id, SHI_Data **items)
time_t endDate
UTC time, (-1) if unlimited.
Definition: EmbStorage.h:352
EMB_EXPORT EMB_Result EMB_Storage_Close(EMB_Storage *storage)
Closes the EMBB storage and releases the specified EMB_Storage object referring to it...
struct EMB_Storage EMB_Storage
An EMB_Storage object represents information about EMB object storage.
Definition: EmbStorage.h:42
uint32_t size
Size of the variable-length array.
Definition: EmbStorage.h:406
EMB_EXPORT EMB_Result EMB_Storage_GetItemByItemId(EMB_Storage *storage, EMB_ItemType item_type, EMB_UInt32 item_id, SHI_Data **item)
Finds the item in the EMBB Storage that contain the specified item_id.
int XPCA_package_type_t
Type of package.
Definition: EmbStorage.h:329
EMB_EXPORT EMB_Result EPD_Storage_GetPackageById(EPD_Storage epds, uint32_t id, XPCA_Package **package)
This API searches the EPD_Storage for a single package definition corresponding to the given package ...
This is a variable-size array of uint32_t data which are package ids returned by relevant EPD storage...
Definition: EmbStorage.h:414
struct SHI_Data SHI_Data
A SHI_Data object represents a typed data object.
Definition: EmbProcessor.h:231
unsigned int EMB_UInt32
An unsigned 32-bit integer.
Definition: EmbTypes.h:53
An array of bytes.
Definition: EmbProcessor.h:53
EMBB Item API.
EMB_EXPORT EMB_Result EMB_Storage_RemoveItem(EMB_Storage *storage, EMB_ItemType item_type, EMB_UInt32 item_id)
Removes from the EMBB Storage the item with a specified item ID.
EMB_EXPORT EMB_Result EPD_Storage_ReleasePackage(EPD_Storage epds, XPCA_Package *package)
Release a XPCA_Package result set returned by a successful call to EPD_Storage_GetPackageById.
#define EMB_EXPORT
Definition: EmbConfig.h:25