Camera3InputStream.h revision b2f5b19e5b6e1408a259add23dba91037756a943
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 478be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala /** 488be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * Get the producer interface for this stream, to hand off to a producer. 498be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * The producer must be connected to the provided interface before 508be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * finishConfigure is called on this stream. 518be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala */ 528be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala sp<IGraphicBufferProducer> getProducerInterface() const; 538be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 548be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala private: 558be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 560776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin typedef BufferItemConsumer::BufferItem BufferItem; 570776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin 588be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala sp<BufferItemConsumer> mConsumer; 590776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin Vector<BufferItem> mBuffersInFlight; 600776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin 61ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin /** 62ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin * Camera3IOStreamBase 63ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin */ 64ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin virtual status_t returnBufferCheckedLocked( 65ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin const camera3_stream_buffer &buffer, 66ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin nsecs_t timestamp, 67ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin bool output, 68ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin /*out*/ 69ae3d0babb9c5d68b107b53d5a67193309020c556Igor Murashkin sp<Fence> *releaseFenceOut); 708be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 718be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala /** 728be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * Camera3Stream interface 738be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala */ 748be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 750776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin virtual status_t getInputBufferLocked(camera3_stream_buffer *buffer); 760776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin virtual status_t returnInputBufferLocked( 770776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin const camera3_stream_buffer &buffer); 788be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala virtual status_t disconnectLocked(); 798be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 800776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin virtual status_t configureQueueLocked(); 810776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin 82b2f5b19e5b6e1408a259add23dba91037756a943Eino-Ville Talvala virtual status_t getEndpointUsage(uint32_t *usage); 83b2f5b19e5b6e1408a259add23dba91037756a943Eino-Ville Talvala 848be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala}; // class Camera3InputStream 858be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 868be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala}; // namespace camera3 878be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 888be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala}; // namespace android 898be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 908be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala#endif 91