18be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala/* 28be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * Copyright (C) 2013 The Android Open Source Project 38be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * 48be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * Licensed under the Apache License, Version 2.0 (the "License"); 58be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * you may not use this file except in compliance with the License. 68be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * You may obtain a copy of the License at 78be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * 88be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * http://www.apache.org/licenses/LICENSE-2.0 98be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * 108be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * Unless required by applicable law or agreed to in writing, software 118be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * distributed under the License is distributed on an "AS IS" BASIS, 128be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * See the License for the specific language governing permissions and 148be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * limitations under the License. 158be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala */ 168be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 178be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala#ifndef ANDROID_SERVERS_CAMERA3_INPUT_STREAM_H 188be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala#define ANDROID_SERVERS_CAMERA3_INPUT_STREAM_H 198be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 208be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala#include <utils/RefBase.h> 218be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala#include <gui/Surface.h> 228be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala#include <gui/BufferItemConsumer.h> 238be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 24ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin#include "Camera3IOStreamBase.h" 258be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 268be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvalanamespace android { 278be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 288be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvalanamespace camera3 { 298be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 308be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala/** 318be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * A class for managing a single stream of input data to the camera device. 320776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin * 330776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin * This class serves as a consumer adapter for the HAL, and will consume the 340776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin * buffers by feeding them into the HAL, as well as releasing the buffers back 350776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin * the buffers once the HAL is done with them. 368be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala */ 37ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkinclass Camera3InputStream : public Camera3IOStreamBase { 388be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala public: 398be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala /** 408be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * Set up a stream for formats that have fixed size, such as RAW and YUV. 418be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala */ 428be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala Camera3InputStream(int id, uint32_t width, uint32_t height, int format); 430776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin ~Camera3InputStream(); 448be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 458be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala virtual void dump(int fd, const Vector<String16> &args) const; 468be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 47054aab3479a094b0a04d48db9cb8f325ea5be162Igor Murashkin // TODO: expose an interface to get the IGraphicBufferProducer 48054aab3479a094b0a04d48db9cb8f325ea5be162Igor Murashkin 498be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala private: 508be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 510776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin typedef BufferItemConsumer::BufferItem BufferItem; 520776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin 538be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala sp<BufferItemConsumer> mConsumer; 540776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin Vector<BufferItem> mBuffersInFlight; 550776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin 56ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin /** 57ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin * Camera3IOStreamBase 58ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin */ 59ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin virtual status_t returnBufferCheckedLocked( 60ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin const camera3_stream_buffer &buffer, 61ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin nsecs_t timestamp, 62ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin bool output, 63ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin /*out*/ 64ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin sp<Fence> *releaseFenceOut); 658be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 668be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala /** 678be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * Camera3Stream interface 688be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala */ 698be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 700776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin virtual status_t getInputBufferLocked(camera3_stream_buffer *buffer); 710776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin virtual status_t returnInputBufferLocked( 720776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin const camera3_stream_buffer &buffer); 738be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala virtual status_t disconnectLocked(); 748be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 750776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin virtual status_t configureQueueLocked(); 760776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin 77b2f5b19e5b6e1408a259add23dba91037756a943Eino-Ville Talvala virtual status_t getEndpointUsage(uint32_t *usage); 78b2f5b19e5b6e1408a259add23dba91037756a943Eino-Ville Talvala 798be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala}; // class Camera3InputStream 808be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 818be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala}; // namespace camera3 828be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 838be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala}; // namespace android 848be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 858be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala#endif 86