• 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 
17 #ifndef __DCF_COMM_H__
18 #define __DCF_COMM_H__
19 
20 #include <Drm2CommonTypes.h>
21 #include <arpa/inet.h>
22 #include <mistream.h>
23 #include <ustring.h>
24 
25 using namespace ustl;
26 
27 ////DCF box type list
28 const uint32_t DCF_CONTAINER_BOX = uint32_t('m' << 24 | 'r' << 16 | 'd' << 8 | 'o');
29 const uint32_t DCF_USER_TYPE = uint32_t('d' << 24 | 'i' << 16 | 'u' << 8 | 'u');
30 const uint32_t DCF_FILE_TYPE = uint32_t('p' << 24 | 'y' << 16 | 't' << 8 | 'f');
31 const uint32_t DCF_FILE_BRAND = uint32_t('f' << 24 | 'c' << 16 | 'd' << 8 | 'o');
32 
33 
34 /**
35  * The basic box class.
36  */
37 class Box
38 {
39 public:
40     /**
41      * constructor for Box, used to parse Box
42      * \param box  Box data
43      */
44     Box(const uint8_t* box);
45 
46     /**
47      * copy constructor for Box
48      * \param dcfBox  Box object used to init a new Box object
49      */
50     Box(const Box& dcfBox);
51 
52     /**
53      * assignment operator for Box
54      * \param other  Box object used to assign to a exist Box object
55      */
56     Box& operator=(const Box& other);
57 
58     /** Destructor for Box */
59     virtual ~Box();
60 
61     /**
62      * get the size of Box
63      * \param none
64      * \return
65      *   the size
66      */
67     uint64_t getSize(void) const;
68 
69     /**
70      * get the type of Box
71      * \param none
72      * \return
73      *   the type
74      */
75     uint32_t getType(void) const;
76 
77     /**
78      * get the user type of Box
79      * \param none
80      * \return
81      *   the user type
82      */
83     const uint8_t* getUsertype(void) const;
84 
85     /**
86      * get the length of Box
87      * \param none
88      * \return
89      *   the length
90      */
91     virtual uint32_t getLen(void) const;
92 PRIVATE:
93     static const uint32_t USER_TYPE_LEN = 16;
94 
95     uint32_t mSize;
96     uint32_t mType;
97     uint64_t mLargeSize;
98     uint8_t* mUserType;
99     uint32_t mBoxLength;
100 };
101 
102 /**
103  * The fullBox class.
104  */
105 class FullBox : public Box
106 {
107 public:
108     /**
109      * constructor for FullBox, used to parse FullBox
110      * \param fullBox  FullBox data
111      */
112     FullBox(const uint8_t* fullBox);
113 
114     /** Destructor for FullBox */
~FullBox()115     virtual ~FullBox(){}
116 
117     /**
118      * get the version of FullBox
119      * \param none
120      * \return
121      *   the version
122      */
123     uint8_t getVersion(void) const;
124 
125     /**
126      * get the flag of FullBox
127      * \param none
128      * \return
129      *   the flag
130      */
131     const uint8_t* getFlag(void) const;
132 
133     /**
134      * get the length of FullBox
135      * \param none
136      * \return
137      *   the length
138      */
139     virtual uint32_t getLen(void) const;
140 PRIVATE:
141     static const uint32_t FLAG_LEN = 3;
142 
143     uint8_t mVersion;
144     uint8_t mFlag[FLAG_LEN];
145     uint32_t mFullBoxLength;
146 };
147 
148 ////// textal header class
149 class TextualHeader
150 {
151 public:
152     /** default constructor of DrmInStream */
TextualHeader()153     TextualHeader(){};
154 
155     /**
156      * constructor for TextualHeader, used to parse textal header
157      * \param inData  textal header data
158      */
159     TextualHeader(const string& inData);
160 
161     /**
162      * get the name of textal header
163      * \param none
164      * \return
165      *   the name
166      */
167     string getName() const;
168 
169     /**
170      * get the value of textal header
171      * \param none
172      * \return
173      *   the value
174      */
175     string getValue() const;
176 
177     /**
178      * get the parameter of textal header
179      * \param none
180      * \return
181      *   the parameter
182      */
183     string getParam() const;
184 PRIVATE:
185     string name;
186     string value;
187     string param;
188 };
189 
190 extern int64_t ntoh_int64(int64_t in);
191 
192 #endif
193