Home | History | Annotate | Download | only in device3
      1 /*
      2  * Copyright (C) 2013 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 
     17 #ifndef ANDROID_SERVERS_CAMERA3_OUTPUT_STREAM_H
     18 #define ANDROID_SERVERS_CAMERA3_OUTPUT_STREAM_H
     19 
     20 #include <utils/RefBase.h>
     21 #include <gui/Surface.h>
     22 
     23 #include "Camera3Stream.h"
     24 #include "Camera3IOStreamBase.h"
     25 #include "Camera3OutputStreamInterface.h"
     26 
     27 namespace android {
     28 
     29 namespace camera3 {
     30 
     31 /**
     32  * A class for managing a single stream of output data from the camera device.
     33  */
     34 class Camera3OutputStream :
     35         public Camera3IOStreamBase,
     36         public Camera3OutputStreamInterface {
     37   public:
     38     /**
     39      * Set up a stream for formats that have 2 dimensions, such as RAW and YUV.
     40      */
     41     Camera3OutputStream(int id, sp<Surface> consumer,
     42             uint32_t width, uint32_t height, int format,
     43             android_dataspace dataSpace, camera3_stream_rotation_t rotation);
     44 
     45     /**
     46      * Set up a stream for formats that have a variable buffer size for the same
     47      * dimensions, such as compressed JPEG.
     48      */
     49     Camera3OutputStream(int id, sp<Surface> consumer,
     50             uint32_t width, uint32_t height, size_t maxSize, int format,
     51             android_dataspace dataSpace, camera3_stream_rotation_t rotation);
     52 
     53     virtual ~Camera3OutputStream();
     54 
     55     /**
     56      * Camera3Stream interface
     57      */
     58 
     59     virtual void     dump(int fd, const Vector<String16> &args) const;
     60 
     61     /**
     62      * Set the transform on the output stream; one of the
     63      * HAL_TRANSFORM_* / NATIVE_WINDOW_TRANSFORM_* constants.
     64      */
     65     status_t         setTransform(int transform);
     66 
     67   protected:
     68     Camera3OutputStream(int id, camera3_stream_type_t type,
     69             uint32_t width, uint32_t height, int format,
     70             android_dataspace dataSpace, camera3_stream_rotation_t rotation);
     71 
     72     /**
     73      * Note that we release the lock briefly in this function
     74      */
     75     virtual status_t returnBufferCheckedLocked(
     76             const camera3_stream_buffer &buffer,
     77             nsecs_t timestamp,
     78             bool output,
     79             /*out*/
     80             sp<Fence> *releaseFenceOut);
     81 
     82     virtual status_t disconnectLocked();
     83 
     84     sp<Surface> mConsumer;
     85   private:
     86     int               mTransform;
     87 
     88     virtual status_t  setTransformLocked(int transform);
     89 
     90     bool mTraceFirstBuffer;
     91 
     92     // Name of Surface consumer
     93     String8           mConsumerName;
     94 
     95     /**
     96      * Internal Camera3Stream interface
     97      */
     98     virtual status_t getBufferLocked(camera3_stream_buffer *buffer);
     99     virtual status_t returnBufferLocked(
    100             const camera3_stream_buffer &buffer,
    101             nsecs_t timestamp);
    102 
    103     virtual status_t configureQueueLocked();
    104 
    105     virtual status_t getEndpointUsage(uint32_t *usage) const;
    106 
    107 }; // class Camera3OutputStream
    108 
    109 } // namespace camera3
    110 
    111 } // namespace android
    112 
    113 #endif
    114