blob: bf12b0b37e9dc3bce73bd896e93e1535a1bce8ee [file] [log] [blame]
aimitakeshi27ed8ad2010-07-29 10:12:27 +09001/*
2 * Copyright (C) 2010 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 __DRM_SUPPORT_INFO_H__
18#define __DRM_SUPPORT_INFO_H__
19
20#include "drm_framework_common.h"
21
22namespace android {
23
24/**
25 * This is an utility class which wraps the capability of each plug-in,
26 * such as mimetype's and file suffixes it could handle.
27 *
28 * Plug-in developer could return the capability of the plugin by passing
29 * DrmSupportInfo instance.
30 *
31 */
32class DrmSupportInfo {
33public:
34 /**
35 * Iterator for mMimeTypeVector
36 */
37 class MimeTypeIterator {
38 friend class DrmSupportInfo;
39 private:
40 MimeTypeIterator(DrmSupportInfo* drmSupportInfo)
41 : mDrmSupportInfo(drmSupportInfo), mIndex(0) {}
42 public:
43 MimeTypeIterator(const MimeTypeIterator& iterator);
44 MimeTypeIterator& operator=(const MimeTypeIterator& iterator);
45 virtual ~MimeTypeIterator() {}
46
47 public:
48 bool hasNext();
49 String8& next();
50
51 private:
52 DrmSupportInfo* mDrmSupportInfo;
53 unsigned int mIndex;
54 };
55
56 /**
57 * Iterator for mFileSuffixVector
58 */
59 class FileSuffixIterator {
60 friend class DrmSupportInfo;
61
62 private:
63 FileSuffixIterator(DrmSupportInfo* drmSupportInfo)
64 : mDrmSupportInfo(drmSupportInfo), mIndex(0) {}
65 public:
66 FileSuffixIterator(const FileSuffixIterator& iterator);
67 FileSuffixIterator& operator=(const FileSuffixIterator& iterator);
68 virtual ~FileSuffixIterator() {}
69
70 public:
71 bool hasNext();
72 String8& next();
73
74 private:
75 DrmSupportInfo* mDrmSupportInfo;
76 unsigned int mIndex;
77 };
78
79public:
80 /**
81 * Constructor for DrmSupportInfo
82 */
83 DrmSupportInfo();
84
85 /**
86 * Copy constructor for DrmSupportInfo
87 */
88 DrmSupportInfo(const DrmSupportInfo& drmSupportInfo);
89
90 /**
91 * Destructor for DrmSupportInfo
92 */
93 virtual ~DrmSupportInfo() {}
94
95 DrmSupportInfo& operator=(const DrmSupportInfo& drmSupportInfo);
96 bool operator<(const DrmSupportInfo& drmSupportInfo) const;
97 bool operator==(const DrmSupportInfo& drmSupportInfo) const;
98
99 /**
100 * Returns FileSuffixIterator object to walk through file suffix values
101 * associated with this instance
102 *
103 * @return FileSuffixIterator object
104 */
105 FileSuffixIterator getFileSuffixIterator();
106
107 /**
108 * Returns MimeTypeIterator object to walk through mimetype values
109 * associated with this instance
110 *
111 * @return MimeTypeIterator object
112 */
113 MimeTypeIterator getMimeTypeIterator();
114
115public:
116 /**
117 * Returns the number of mimetypes supported.
118 *
119 * @return Number of mimetypes supported
120 */
121 int getMimeTypeCount(void) const;
122
123 /**
124 * Returns the number of file types supported.
125 *
126 * @return Number of file types supported
127 */
128 int getFileSuffixCount(void) const;
129
130 /**
131 * Adds the mimetype to the list of supported mimetypes
132 *
133 * @param[in] mimeType mimetype to be added
134 * @return Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
135 */
136 status_t addMimeType(const String8& mimeType);
137
138 /**
139 * Adds the filesuffix to the list of supported file types
140 *
141 * @param[in] filesuffix file suffix to be added
142 * @return Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
143 */
144 status_t addFileSuffix(const String8& fileSuffix);
145
146 /**
147 * Set the unique description about the plugin
148 *
149 * @param[in] description Unique description
150 * @return Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
151 */
152 status_t setDescription(const String8& description);
153
154 /**
155 * Returns the unique description associated with the plugin
156 *
157 * @return Unique description
158 */
159 String8 getDescription() const;
160
161 /**
162 * Returns whether given mimetype is supported or not
163 *
164 * @param[in] mimeType MIME type
165 * @return
166 * true - if mime-type is supported
167 * false - if mime-type is not supported
168 */
169 bool isSupportedMimeType(const String8& mimeType) const;
170
171 /**
172 * Returns whether given file type is supported or not
173 *
174 * @param[in] fileType File type
175 * @return
176 * true if file type is supported
177 * false if file type is not supported
178 */
179 bool isSupportedFileSuffix(const String8& fileType) const;
180
181private:
182 Vector<String8> mMimeTypeVector;
183 Vector<String8> mFileSuffixVector;
184
185 String8 mDescription;
186};
187
188};
189
190#endif /* __DRM_SUPPORT_INFO_H__ */
191