Camera3InputStream.h revision 0776a14513300f04dc5c1d2f89c4156576b8b8ed
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 248be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala#include "Camera3Stream.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 */ 378be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvalaclass Camera3InputStream : public Camera3Stream { 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 status_t waitUntilIdle(nsecs_t timeout); 468be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala virtual void dump(int fd, const Vector<String16> &args) const; 478be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 488be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala /** 498be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * Get the producer interface for this stream, to hand off to a producer. 508be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * The producer must be connected to the provided interface before 518be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * finishConfigure is called on this stream. 528be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala */ 538be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala sp<IGraphicBufferProducer> getProducerInterface() const; 548be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 558be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala private: 568be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 570776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin typedef BufferItemConsumer::BufferItem BufferItem; 580776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin 598be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala sp<BufferItemConsumer> mConsumer; 600776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin Vector<BufferItem> mBuffersInFlight; 610776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin size_t mTotalBufferCount; 620776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin size_t mDequeuedBufferCount; 630776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin Condition mBufferReturnedSignal; 640776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin uint32_t mFrameCount; 650776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin nsecs_t mLastTimestamp; 660776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin 670776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin // The merged release fence for all returned buffers 680776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin sp<Fence> mCombinedFence; 698be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 708be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala /** 718be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala * Camera3Stream interface 728be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala */ 738be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 740776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin virtual status_t getInputBufferLocked(camera3_stream_buffer *buffer); 750776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin virtual status_t returnInputBufferLocked( 760776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin const camera3_stream_buffer &buffer); 778be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala virtual bool hasOutstandingBuffersLocked() const; 788be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala virtual status_t disconnectLocked(); 798be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 800776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin virtual status_t configureQueueLocked(); 810776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin virtual size_t getBufferCountLocked(); 820776a14513300f04dc5c1d2f89c4156576b8b8edIgor Murashkin 838be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala}; // class Camera3InputStream 848be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 858be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala}; // namespace camera3 868be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 878be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala}; // namespace android 888be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala 898be20f50711a94426f1394ec113672e41c1224e8Eino-Ville Talvala#endif 90