18486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He/*
28486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He * Copyright (C) 2016 The Android Open Source Project
38486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He *
48486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He * Licensed under the Apache License, Version 2.0 (the "License");
58486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He * you may not use this file except in compliance with the License.
68486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He * You may obtain a copy of the License at
78486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He *
88486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He *      http://www.apache.org/licenses/LICENSE-2.0
98486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He *
108486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He * Unless required by applicable law or agreed to in writing, software
118486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He * distributed under the License is distributed on an "AS IS" BASIS,
128486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He * See the License for the specific language governing permissions and
148486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He * limitations under the License.
158486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He */
168486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He
178486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun Hepackage android.hardware.camera.device@1.0;
188486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He
198486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun Heinterface ICameraDeviceCallback {
208486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He
218486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He    /**
228486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * Notify the camera service of a particular event occurring
238486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * The meaning of each parameter is defined by the value of msgType, and
248486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * documented in the definition of NotifyCallbackMsg.
258486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *
268486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param msgType The type of the event.
278486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param ext1 The first parameter for the event, if needed.
288486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param ext2 The second parameter for the event, if needed.
298486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     */
308486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He    notifyCallback(NotifyCallbackMsg msgType, int32_t ext1, int32_t ext2);
318486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He
328486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He    /**
338486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * Define a memory buffer from the provided handle and size, and return a
348486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * unique identifier for the HAL to use to reference it with.
358486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *
368486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param descriptor A native handle that must have exactly one file
378486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *     descriptor in it; the file descriptor must be memory mappable to
388486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *     bufferSize * bufferCount bytes.
398486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param bufferSize The number of bytes a single buffer consists of.
408486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param bufferCount The number of contiguous buffers that the descriptor
418486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *     contains.
428486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *
43248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     * @return memId A positive integer identifier for this memory buffer, for
44248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     *     use with data callbacks and unregistering memory. 0 must be returned
45248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     *     in case of error, such as if the descriptor does not contain exactly
46248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     *     one FD.
478486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     */
488486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He    registerMemory(handle descriptor, uint32_t bufferSize, uint32_t bufferCount)
498486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He            generates (MemoryId memId);
508486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He
518486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He    /**
528486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * Unregister a previously registered memory buffer
538486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     */
548486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He    unregisterMemory(MemoryId memId);
558486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He
568486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He    /**
578486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * Send a buffer of image data to the camera service
588486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *
598486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param msgType The kind of image buffer data this call represents.
608486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param data A memory handle to the buffer containing the data.
618486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param bufferIndex The offset into the memory handle where the buffer
628486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *     starts.
638486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *
648486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     */
65248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh    dataCallback(DataCallbackMsg msgType, MemoryId data, uint32_t bufferIndex,
66248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh            CameraFrameMetadata metadata);
678486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He
688486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He    /**
698486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * Send a buffer of image data to the camera service, with a timestamp
708486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *
718486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param msgType The kind of image buffer data this call represents.
728486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param data A memory handle to the buffer containing the data.
738486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param bufferIndex The offset into the memory handle where the buffer
748486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *     starts.
758486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     * @param timestamp The time this buffer was captured by the camera, in
768486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *     nanoseconds.
778486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     *
788486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He     */
798486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He    dataCallbackTimestamp(DataCallbackMsg msgType, MemoryId data, uint32_t bufferIndex,
808486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He            int64_t timestamp);
818486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He
82248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh    /**
83248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     * Send a buffer of image data to the camera service, with a timestamp
84248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     *
85248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     * @param msgType The kind of image buffer data this call represents.
86248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     * @param handle The handle of image buffer data this call represents.
87248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     * @param data A memory handle to the buffer containing the data.
88248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     * @param bufferIndex The offset into the memory handle where the buffer
89248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     *     starts.
90248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     * @param timestamp The time this buffer was captured by the camera, in
91248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     *     nanoseconds.
92248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     *
93248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh     */
94248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh    handleCallbackTimestamp(DataCallbackMsg msgType, handle frameData, MemoryId data,
95248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh            uint32_t bufferIndex, int64_t timestamp);
96248ed700fed7e682eddf3d0607592eb5f3a3fb1aYin-Chia Yeh
971ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh    /**
981ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     * Send a batch of image data buffer to the camera service, with timestamps
991ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     *
1001ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     * This callback can be used to send multiple frames to camera framework in one callback, which
1011ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     * reduce number of callbacks in performance intensive use cases, such as high speed video
1021ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     * recording. The HAL must not mix use of this method with handleCallbackTimestamp in one
1031ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     * recording session (between startRecording and stopRecording)
1041ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     *
1051ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     * @param msgType The kind of image buffer data this call represents.
1061ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     * @param batch a vector messages. Each message contains a image buffer and a timestamp. The
1071ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     *     messages must be ordered in time from lower index to higher index, so that timestamp of
1081ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     *     i-th message is always smaller than i+1-th message.
1091ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     *
1101ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh     */
1111ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh    handleCallbackTimestampBatch(DataCallbackMsg msgType, vec<HandleTimestampMessage> batch);
1121ba83a9a282afa086ac2431942a4814633438ffcYin-Chia Yeh
1138486e4179cc493e3e64a22f830b307f9a5d2b095Zhijun He};
114