blob: eab7eaddc81202f128db55eb75a2ed2139d9330e [file] [log] [blame]
Yin-Chia Yehc3603822016-01-18 22:11:19 -08001/*
2 * Copyright (C) 2016 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
Yin-Chia Yeh3e49be12016-04-12 16:00:33 -070017/**
18 * @addtogroup Media Camera
19 * @{
20 */
21
22/**
23 * @file NdkImage.h
24 */
25
Yin-Chia Yehc3603822016-01-18 22:11:19 -080026/*
27 * This file defines an NDK API.
28 * Do not remove methods.
29 * Do not change method signatures.
30 * Do not change the value of constants.
31 * Do not change the size of any of the classes defined in here.
32 * Do not reference types that are not part of the NDK.
33 * Do not #include files that aren't part of the NDK.
34 */
35
36#ifndef _NDK_IMAGE_H
37#define _NDK_IMAGE_H
38
39#include "NdkMediaError.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45typedef struct AImage AImage;
46
47// Formats not listed here will not be supported by AImageReader
48enum {
49 AIMAGE_FORMAT_YUV_420_888 = 0x23,
50 AIMAGE_FORMAT_JPEG = 0x100,
51 AIMAGE_FORMAT_RAW16 = 0x20,
52 AIMAGE_FORMAT_RAW_PRIVATE = 0x24,
53 AIMAGE_FORMAT_RAW10 = 0x25,
54 AIMAGE_FORMAT_RAW12 = 0x26,
55 AIMAGE_FORMAT_DEPTH16 = 0x44363159,
Yin-Chia Yeh3e49be12016-04-12 16:00:33 -070056 AIMAGE_FORMAT_DEPTH_POINT_CLOUD = 0x101,
57 AIMAGE_FORMAT_PRIVATE = 0x22 ///> Not supported by AImageReader yet
Yin-Chia Yehc3603822016-01-18 22:11:19 -080058};
59
60typedef struct AImageCropRect {
61 int32_t left;
62 int32_t top;
63 int32_t right;
64 int32_t bottom;
65} AImageCropRect;
66
67// Return the image back to system and delete the AImage from memory
68// Do NOT use `image` after this call
69void AImage_delete(AImage* image);
70
71// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
72media_status_t AImage_getWidth(const AImage* image, /*out*/int32_t* width);
73
74// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
75media_status_t AImage_getHeight(const AImage* image, /*out*/int32_t* height);
76
77// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
78media_status_t AImage_getFormat(const AImage* image, /*out*/int32_t* format);
79
80// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
81media_status_t AImage_getCropRect(const AImage* image, /*out*/AImageCropRect* rect);
82
83// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
84media_status_t AImage_getTimestamp(const AImage* image, /*out*/int64_t* timestampNs);
85
86// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
87media_status_t AImage_getNumberOfPlanes(const AImage* image, /*out*/int32_t* numPlanes);
88
89// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
90media_status_t AImage_getPlanePixelStride(
91 const AImage* image, int planeIdx, /*out*/int32_t* pixelStride);
92
93// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
94media_status_t AImage_getPlaneRowStride(
95 const AImage* image, int planeIdx, /*out*/int32_t* rowStride);
96
97// AMEDIA_ERROR_INVALID_OBJECT will be returned if the parent AImageReader is deleted
98// Note that once the AImage or the parent AImageReader is deleted, the `*data` returned from
99// previous AImage_getPlaneData call becomes dangling pointer. Do NOT use it after
100// AImage or AImageReader is deleted
101media_status_t AImage_getPlaneData(
102 const AImage* image, int planeIdx,
103 /*out*/uint8_t** data, /*out*/int* dataLength);
104
105#ifdef __cplusplus
106} // extern "C"
107#endif
108
109#endif //_NDK_IMAGE_H
Yin-Chia Yeh3e49be12016-04-12 16:00:33 -0700110
111/** @} */