/include/drm/DrmMetadata.h

http://github.com/CyanogenMod/android_frameworks_base · C++ Header · 111 lines · 65 code · 19 blank · 27 comment · 3 complexity · 8feabb7a204a8d7cfb93351d0e7b6204 MD5 · raw file

  1. /*
  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. #ifndef __DRM_METADATA_H__
  17. #define __DRM_METADATA_H__
  18. #include "drm_framework_common.h"
  19. namespace android {
  20. /**
  21. * This is an utility class which contains the constraints information.
  22. *
  23. * As a result of DrmManagerClient::getMetadata(const String8*)
  24. * an instance of DrmMetadata would be returned.
  25. */
  26. class DrmMetadata {
  27. public:
  28. /**
  29. * Iterator for key
  30. */
  31. class KeyIterator {
  32. friend class DrmMetadata;
  33. private:
  34. KeyIterator(DrmMetadata* drmMetadata) : mDrmMetadata(drmMetadata), mIndex(0) {}
  35. public:
  36. KeyIterator(const KeyIterator& keyIterator);
  37. KeyIterator& operator=(const KeyIterator& keyIterator);
  38. virtual ~KeyIterator() {}
  39. public:
  40. bool hasNext();
  41. const String8& next();
  42. private:
  43. DrmMetadata* mDrmMetadata;
  44. unsigned int mIndex;
  45. };
  46. /**
  47. * Iterator for constraints
  48. */
  49. class Iterator {
  50. friend class DrmMetadata;
  51. private:
  52. Iterator(DrmMetadata* drmMetadata) : mDrmMetadata(drmMetadata), mIndex(0) {}
  53. public:
  54. Iterator(const Iterator& iterator);
  55. Iterator& operator=(const Iterator& iterator);
  56. virtual ~Iterator() {}
  57. public:
  58. bool hasNext();
  59. String8 next();
  60. private:
  61. DrmMetadata* mDrmMetadata;
  62. unsigned int mIndex;
  63. };
  64. public:
  65. DrmMetadata() {}
  66. virtual ~DrmMetadata() {
  67. DrmMetadata::KeyIterator keyIt = this->keyIterator();
  68. while (keyIt.hasNext()) {
  69. String8 key = keyIt.next();
  70. const char* value = this->getAsByteArray(&key);
  71. if (NULL != value) {
  72. delete[] value;
  73. value = NULL;
  74. }
  75. }
  76. mMetadataMap.clear();
  77. }
  78. public:
  79. int getCount(void) const;
  80. status_t put(const String8* key, const char* value);
  81. String8 get(const String8& key) const;
  82. const char* getAsByteArray(const String8* key) const;
  83. KeyIterator keyIterator();
  84. Iterator iterator();
  85. private:
  86. const char* getValue(const String8* key) const;
  87. private:
  88. typedef KeyedVector<String8, const char*> DrmMetadataMap;
  89. DrmMetadataMap mMetadataMap;
  90. };
  91. };
  92. #endif /* __DRM_METADATA_H__ */