blob: 1dfcd80524f49b2d90715451ac68f2499fb52e0a [file] [log] [blame]
Zhijun He8486e412016-09-12 15:30:51 -07001/*
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
17package android.hardware.camera.device@1.0;
18
19interface ICameraDeviceCallback {
20
21 /**
22 * Notify the camera service of a particular event occurring
23 * The meaning of each parameter is defined by the value of msgType, and
24 * documented in the definition of NotifyCallbackMsg.
25 *
26 * @param msgType The type of the event.
27 * @param ext1 The first parameter for the event, if needed.
28 * @param ext2 The second parameter for the event, if needed.
29 */
30 notifyCallback(NotifyCallbackMsg msgType, int32_t ext1, int32_t ext2);
31
32 /**
33 * Define a memory buffer from the provided handle and size, and return a
34 * unique identifier for the HAL to use to reference it with.
35 *
36 * TODO(b/33269977): Ensure this aligns with design and performance goals.
37 *
38 * @param descriptor A native handle that must have exactly one file
39 * descriptor in it; the file descriptor must be memory mappable to
40 * bufferSize * bufferCount bytes.
41 * @param bufferSize The number of bytes a single buffer consists of.
42 * @param bufferCount The number of contiguous buffers that the descriptor
43 * contains.
44 *
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080045 * @return memId A positive integer identifier for this memory buffer, for
46 * use with data callbacks and unregistering memory. 0 must be returned
47 * in case of error, such as if the descriptor does not contain exactly
48 * one FD.
Zhijun He8486e412016-09-12 15:30:51 -070049 */
50 registerMemory(handle descriptor, uint32_t bufferSize, uint32_t bufferCount)
51 generates (MemoryId memId);
52
53 /**
54 * Unregister a previously registered memory buffer
55 */
56 unregisterMemory(MemoryId memId);
57
58 /**
59 * Send a buffer of image data to the camera service
60 *
61 * @param msgType The kind of image buffer data this call represents.
62 * @param data A memory handle to the buffer containing the data.
63 * @param bufferIndex The offset into the memory handle where the buffer
64 * starts.
65 *
66 */
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080067 dataCallback(DataCallbackMsg msgType, MemoryId data, uint32_t bufferIndex,
68 CameraFrameMetadata metadata);
Zhijun He8486e412016-09-12 15:30:51 -070069
70 /**
71 * Send a buffer of image data to the camera service, with a timestamp
72 *
73 * @param msgType The kind of image buffer data this call represents.
74 * @param data A memory handle to the buffer containing the data.
75 * @param bufferIndex The offset into the memory handle where the buffer
76 * starts.
77 * @param timestamp The time this buffer was captured by the camera, in
78 * nanoseconds.
79 *
80 */
81 dataCallbackTimestamp(DataCallbackMsg msgType, MemoryId data, uint32_t bufferIndex,
82 int64_t timestamp);
83
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080084 /**
85 * Send a buffer of image data to the camera service, with a timestamp
86 *
87 * @param msgType The kind of image buffer data this call represents.
88 * @param handle The handle of image buffer data this call represents.
89 * @param data A memory handle to the buffer containing the data.
90 * @param bufferIndex The offset into the memory handle where the buffer
91 * starts.
92 * @param timestamp The time this buffer was captured by the camera, in
93 * nanoseconds.
94 *
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080095 */
96 handleCallbackTimestamp(DataCallbackMsg msgType, handle frameData, MemoryId data,
97 uint32_t bufferIndex, int64_t timestamp);
98
Yin-Chia Yeh1ba83a92017-03-21 17:47:02 -070099 /**
100 * Send a batch of image data buffer to the camera service, with timestamps
101 *
102 * This callback can be used to send multiple frames to camera framework in one callback, which
103 * reduce number of callbacks in performance intensive use cases, such as high speed video
104 * recording. The HAL must not mix use of this method with handleCallbackTimestamp in one
105 * recording session (between startRecording and stopRecording)
106 *
107 * @param msgType The kind of image buffer data this call represents.
108 * @param batch a vector messages. Each message contains a image buffer and a timestamp. The
109 * messages must be ordered in time from lower index to higher index, so that timestamp of
110 * i-th message is always smaller than i+1-th message.
111 *
112 */
113 handleCallbackTimestampBatch(DataCallbackMsg msgType, vec<HandleTimestampMessage> batch);
114
Zhijun He8486e412016-09-12 15:30:51 -0700115};