• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 #ifndef CPM_H_INCLUDED
19 #define CPM_H_INCLUDED
20 
21 #ifndef OSCL_TYPES_H_INCLUDED
22 #include "oscl_types.h"
23 #endif
24 #ifndef PVMF_EVENT_HANDLING_H_INCLUDED
25 #include "pvmf_event_handling.h"
26 #endif
27 #ifndef PVMI_KVP_INCLUDED
28 #include "pvmi_kvp.h"
29 #endif
30 #ifndef PVMF_FORMAT_TYPE_H_INCLUDED
31 #include "pvmf_format_type.h"
32 #endif
33 #ifndef CPM_TYPES_H_INCLUDED
34 #include "cpm_types.h"
35 #endif
36 #ifndef PVMF_CPMPLUGIN_ACCESS_INTERFACE_FACTORY_H_INCLUDED
37 #include "pvmf_cpmplugin_access_interface_factory.h"
38 #endif
39 #ifndef PVMF_CPMPLUGIN_ACCESS_INTERFACE_H_INCLUDED
40 #include "pvmf_cpmplugin_access_interface.h"
41 #endif
42 
43 typedef int32 PVMFCPMUsageID;
44 
45 /* Forward declarations */
46 class CPMPluginRegistry;
47 
48 /**
49  * PVMFCPMStatusObserver Class
50  *
51  * PVMFCPMStatusObserver is the PVMF CPM Plugin observer class for
52  * notifying the status of issued command messages. The API provides a mechanism
53  * for the status of each command to be passed back along with context specific
54  * information where applicable.
55  * Applications using the module must have a class derived from
56  * PVMFCPMStatusObserver and implement the pure virtual function in
57  * order to receive event notifications from the plugin.
58  **/
59 class PVMFCPMStatusObserver
60 {
61     public:
62         /**
63          * Handle an event that has been generated.
64          * @param "aResponse"   "The response to a previously issued command."
65          */
66         virtual void CPMCommandCompleted(const PVMFCmdResp& aResponse) = 0;
~PVMFCPMStatusObserver()67         virtual ~PVMFCPMStatusObserver() {}
68 };
69 
70 class PVMFCPM : public PVInterface
71 {
72     public:
73         /**
74          * Establishes usage thread context.
75          * CPM should do all thread-context-sensitive initialization in this
76          * call.
77          **/
78         virtual void ThreadLogon() = 0;
79         /**
80          * Exits usage thread context.
81          * CPM should do all thread-context-sensitive cleanup in this
82          * call.
83          **/
84         virtual void ThreadLogoff() = 0;
85 
86         /**
87          * Starts initialization of the content policy manager.  At the minimum,
88          * CPM should be ready to establish a session after initialization is complete
89          **/
90         virtual PVMFCommandId Init(const OsclAny* aContext = NULL) = 0;
91 
92         /**
93          * Creates a session based on interactions with all the
94          * registered plugins.
95          **/
96         virtual PVMFCommandId OpenSession(PVMFSessionId& aSessionId,
97                                           const OsclAny* aContext = NULL) = 0;
98 
99         virtual PVMFCommandId RegisterContent(PVMFSessionId aSessionId,
100                                               OSCL_wString& aSourceURL,
101                                               PVMFFormatType& aSourceFormat,
102                                               OsclAny* aSourceData,
103                                               const OsclAny* aContext = NULL) = 0;
104 
105         /**
106          * Retrieves the CPM content type for a passed in source. This could
107          * be types based on DRM version or content rating etc
108          **/
109         virtual PVMFCPMContentType GetCPMContentType(PVMFSessionId aSessionId) = 0;
110 
111 
112         /**
113          * Optional API to retrieve the original filename of a protected file.
114          **/
115         virtual PVMFStatus GetCPMContentFilename(PVMFSessionId aSessionId,
116                 OSCL_wString& aFileName) = 0;
117 
118         /**
119          * Retrieves the access interface factory to be used for all content
120          * access. The usage of the access factory could sometimes depend on
121          * a successful authorization.
122          **/
123         virtual PVMFStatus GetContentAccessFactory(PVMFSessionId aSessionId,
124                 PVMFCPMPluginAccessInterfaceFactory*& aContentAccessFactory) = 0;
125 
126         /**
127          * Approves the specified usage of the content, based on the
128          * interactions with all the authenticated plugins.
129          **/
130         virtual PVMFCommandId ApproveUsage(PVMFSessionId aSessionId,
131                                            PvmiKvp& aRequestedUsage,
132                                            PvmiKvp& aApprovedUsage,
133                                            PvmiKvp& aAuthorizationData,
134                                            PVMFCPMUsageID& aUsageID,
135                                            const OsclAny* aContext = NULL) = 0;
136 
137         /**
138          * Called by the user once the content usage is complete.
139          **/
140         virtual PVMFCommandId UsageComplete(PVMFSessionId aSessionId,
141                                             PVMFCPMUsageID& aUsageID,
142                                             OsclAny* aContext = NULL) = 0;
143 
144         virtual PVMFCommandId CloseSession(PVMFSessionId& aSessionId,
145                                            const OsclAny* aContext = NULL) = 0;
146 
147         /**
148          * Resets the content policy manager.  The CPM should relinquish all resources
149          * that is has acquired as part of the initialization process and should be
150          * ready to be deleted when this completes.
151          **/
152         virtual PVMFCommandId Reset(const OsclAny* aContext = NULL) = 0;
153 
154         /**
155          * Returns a pointer to the current plugin registry, for use in the
156          * rare case where code needs to access plugins directly.
157          **/
158         virtual CPMPluginRegistry* GetPluginRegistry() = 0;
159 
160         /**
161          * Provides a means to query extension interfaces either from the CPM
162          * directly or from underlying plugins.
163          * Example: Metadata, License Acquisition etc
164          **/
165         virtual PVMFCommandId QueryInterface(PVMFSessionId aSessionId,
166                                              const PVUuid& aUuid,
167                                              PVInterface*& aInterfacePtr,
168                                              const OsclAny* aContext = NULL) = 0;
169 
~PVMFCPM()170         virtual ~PVMFCPM() {}
171 };
172 
173 class PVMFCPMFactory
174 {
175     public:
176         /**
177          * Creates an instance of a PVMFCPM.
178          * If the creation fails, this function will leave.
179          *
180          * @param observer for PVMFCPM
181          *
182          * @returns A pointer to an instance of PVMFCPM
183          * leaves if instantiation fails
184          **/
185         OSCL_IMPORT_REF static PVMFCPM* CreateContentPolicyManager(PVMFCPMStatusObserver& aObserver);
186         /**
187          * Deletes an instance of PVMFCPM
188          * and reclaims all allocated resources.
189          *
190          * @param aNode The PVMFCPM instance to be deleted
191          * @returns None
192          **/
193         OSCL_IMPORT_REF static void DestroyContentPolicyManager(PVMFCPM*);
194 };
195 
196 #endif //CPM_H_INCLUDED
197 
198 
199