• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
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 express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef _DRMMANAGER_
17 #define _DRMMANAGER_
18 
19 #include <Drm2CommonTypes.h>
20 #include <ofstream.h>
21 #include <sostream.h>
22 #include <ustring.h>
23 #include <sistream.h>
24 #include <uvector.h>
25 
26 using namespace ustl;
27 
28 /** It should be removed after real DcfContainer is ready */
29 #define DcfContainer string
30 static const int16_t DRM_OK = 1;
31 
32 class DrmManager
33 {
34 public:
35     /**
36      * Error definition
37      */
38      static const int16_t DRM_MANAGER_BASE = 100;
39      static const int16_t ERR_DCFSTREAM_NOT_INITIALIZED = DRM_MANAGER_BASE+1;
40      static const int16_t ERR_WRONG_DCFDATA = DRM_MANAGER_BASE+2;
41      static const int16_t ERR_WRONG_RIGHTS = DRM_MANAGER_BASE+3;
42 
43     /**
44      * Constructor for DrmManager,used to open local dcf file.
45      * @param inRawData input stream of raw data.
46      */
47     DrmManager(istream *inRawData);
48 
49     /**
50      * Constructor for DrmManager,used to separate dcf file and trig message when upper
51      * application downloading one multipart message from CI.
52      * @param inRawData input stream of raw data.
53      */
54     DrmManager(istream * inRawData, string mimeType);
55 
56     /** Destructor for DomExpatAgent. */
57     ~DrmManager();
58     /**
59      * Config DRM engine
60      * Fix me later
61      */
62      bool config();
63 
64     /**
65      * Consume rights according to specified operation, DrmManager will check.
66      * @param operationType the type of operation.
67      * @return the operation result.
68      */
69     int16_t consumeRights(int16_t operationType);
70 
71     /**
72      * Get the list of all dcf containers object reference in the dcf file.
73      * @param the vector of the dcf objects list returned.
74      * @return the operation result.
75      */
76      int16_t getListOfDcfObjects(vector<DcfContainer*> **outDcfList);
77 
78     /**
79      * Open one Dcf container to read the decrypted data according to specified
80      * operation.
81      * @param oneDcfObject the reference of the DcfContainer.
82      * @param operationType the type of operation.
83      * @param decrypted data returned.
84      * @return the operation result.
85      */
86     int16_t openDecryptedContent(DcfContainer *oneDcfObject,
87                                 int16_t operationType,
88                                 istream *outDecryptedData);
89 
90     /**
91      * Get the separated Dcf raw data from multipart message.
92      * @return the ifstream of the dcf raw data which should be stored by upper
93      * application.
94      */
95     ifstream* getOriginalMediaData(void);
96 
97     /**
98      * Handle DRM2.0 push message
99      */
100     bool handlePushMsg(uint8_t* data, string mimeType);
101 
102 PRIVATE:
103     istream *mDcfStream; /**< the handler of dcf stream. */
104     vector<DcfContainer*> mDcfs; /**< all the dcf containers included in one dcf file. */
105 };
106 
107 #endif //_DRMMANAGER_
108