NdkCameraMetadata.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2015 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. //#define LOG_NDEBUG 0
  17. #define LOG_TAG "NdkCameraMetadata"
  18. #define ATRACE_TAG ATRACE_TAG_CAMERA
  19. #include <utils/Log.h>
  20. #include <utils/Trace.h>
  21. #include <camera/NdkCameraMetadata.h>
  22. #include "impl/ACameraMetadata.h"
  23. using namespace android;
  24. EXPORT
  25. camera_status_t ACameraMetadata_getConstEntry(
  26. const ACameraMetadata* acm, uint32_t tag, ACameraMetadata_const_entry* entry) {
  27. ATRACE_CALL();
  28. if (acm == nullptr || entry == nullptr) {
  29. ALOGE("%s: invalid argument! metadata %p, tag 0x%x, entry %p",
  30. __FUNCTION__, acm, tag, entry);
  31. return ACAMERA_ERROR_INVALID_PARAMETER;
  32. }
  33. return acm->getConstEntry(tag, entry);
  34. }
  35. EXPORT
  36. camera_status_t ACameraMetadata_getAllTags(
  37. const ACameraMetadata* acm, /*out*/int32_t* numTags, /*out*/const uint32_t** tags) {
  38. ATRACE_CALL();
  39. if (acm == nullptr || numTags == nullptr || tags == nullptr) {
  40. ALOGE("%s: invalid argument! metadata %p, numTags %p, tags %p",
  41. __FUNCTION__, acm, numTags, tags);
  42. return ACAMERA_ERROR_INVALID_PARAMETER;
  43. }
  44. return acm->getTags(numTags, tags);
  45. }
  46. EXPORT
  47. ACameraMetadata* ACameraMetadata_copy(const ACameraMetadata* src) {
  48. ATRACE_CALL();
  49. if (src == nullptr) {
  50. ALOGE("%s: src is null!", __FUNCTION__);
  51. return nullptr;
  52. }
  53. ACameraMetadata* copy = new ACameraMetadata(*src);
  54. copy->incStrong((void*) ACameraMetadata_copy);
  55. return copy;
  56. }
  57. EXPORT
  58. void ACameraMetadata_free(ACameraMetadata* metadata) {
  59. ATRACE_CALL();
  60. if (metadata != nullptr) {
  61. metadata->decStrong((void*) ACameraMetadata_free);
  62. }
  63. }
  64. EXPORT
  65. bool ACameraMetadata_isLogicalMultiCamera(const ACameraMetadata* staticMetadata,
  66. /*out*/size_t* numPhysicalCameras, /*out*/const char*const** physicalCameraIds) {
  67. ATRACE_CALL();
  68. if (numPhysicalCameras == nullptr || physicalCameraIds == nullptr) {
  69. ALOGE("%s: Invalid input: numPhysicalCameras %p, physicalCameraIds %p",
  70. __FUNCTION__, numPhysicalCameras, physicalCameraIds);
  71. return false;
  72. }
  73. if (staticMetadata == nullptr) {
  74. ALOGE("%s: Invalid input: staticMetadata is null.", __FUNCTION__);
  75. return false;
  76. }
  77. return staticMetadata->isLogicalMultiCamera(numPhysicalCameras, physicalCameraIds);
  78. }