Home | History | Annotate | Download | only in usbcamera
      1 /*
      2  * Copyright (C) 2015 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 STREAM_H_
     18 #define STREAM_H_
     19 
     20 #include <hardware/camera3.h>
     21 #include <hardware/gralloc.h>
     22 #include <system/graphics.h>
     23 #include <utils/Mutex.h>
     24 #include <utils/Vector.h>
     25 
     26 namespace usb_camera_hal {
     27 // Stream represents a single input or output stream for a camera device.
     28 class Stream {
     29     public:
     30         Stream(int id, camera3_stream_t *s);
     31         ~Stream();
     32 
     33         // validate that a stream's parameters match this stream's parameters
     34         bool isValidReuseStream(int id, camera3_stream_t *s);
     35 
     36         void setUsage(uint32_t usage);
     37         void setMaxBuffers(uint32_t max_buffers);
     38 
     39         int getType();
     40         bool isInputType();
     41         bool isOutputType();
     42         const char* typeToString(int type);
     43         const char* formatToString(int format);
     44         void dump(int fd);
     45 
     46         // This stream is being reused. Used in stream configuration passes
     47         bool mReuse;
     48 
     49     private:
     50         // The camera device id this stream belongs to
     51         const int mId;
     52         // Handle to framework's stream, used as a cookie for buffers
     53         camera3_stream_t *mStream;
     54         // Array of handles to buffers currently in use by the stream
     55         android::Vector<buffer_handle_t *> mBuffers;
     56         // Lock protecting the Stream object for modifications
     57         android::Mutex mLock;
     58 };
     59 } // namespace usb_camera_hal
     60 
     61 #endif // STREAM_H_
     62