Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 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" |
Igor Murashkin | e3a9f96 | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 24 | #include "Camera3IOStreamBase.h" |
Igor Murashkin | 2fba584 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 25 | #include "Camera3OutputStreamInterface.h" |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 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 | */ |
Igor Murashkin | 2fba584 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 34 | class Camera3OutputStream : |
Igor Murashkin | e3a9f96 | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 35 | public Camera3IOStreamBase, |
Igor Murashkin | 2fba584 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 36 | public Camera3OutputStreamInterface { |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 37 | public: |
| 38 | /** |
| 39 | * Set up a stream for formats that have 2 dimensions, such as RAW and YUV. |
| 40 | */ |
Eino-Ville Talvala | 727d172 | 2015-06-09 13:44:19 -0700 | [diff] [blame] | 41 | Camera3OutputStream(int id, sp<Surface> consumer, |
Eino-Ville Talvala | 3d82c0d | 2015-02-23 15:19:19 -0800 | [diff] [blame] | 42 | uint32_t width, uint32_t height, int format, |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 43 | android_dataspace dataSpace, camera3_stream_rotation_t rotation); |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 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 | */ |
Eino-Ville Talvala | 727d172 | 2015-06-09 13:44:19 -0700 | [diff] [blame] | 49 | Camera3OutputStream(int id, sp<Surface> consumer, |
Eino-Ville Talvala | 3d82c0d | 2015-02-23 15:19:19 -0800 | [diff] [blame] | 50 | uint32_t width, uint32_t height, size_t maxSize, int format, |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 51 | android_dataspace dataSpace, camera3_stream_rotation_t rotation); |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 52 | |
| 53 | virtual ~Camera3OutputStream(); |
| 54 | |
| 55 | /** |
| 56 | * Camera3Stream interface |
| 57 | */ |
| 58 | |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 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 | |
Chien-Yu Chen | 85a6455 | 2015-08-28 15:46:12 -0700 | [diff] [blame^] | 67 | /** |
| 68 | * Return if this output stream is for video encoding. |
| 69 | */ |
| 70 | bool isVideoStream() const; |
| 71 | |
Igor Murashkin | e3a9f96 | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 72 | protected: |
| 73 | Camera3OutputStream(int id, camera3_stream_type_t type, |
Eino-Ville Talvala | 3d82c0d | 2015-02-23 15:19:19 -0800 | [diff] [blame] | 74 | uint32_t width, uint32_t height, int format, |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 75 | android_dataspace dataSpace, camera3_stream_rotation_t rotation); |
Igor Murashkin | e3a9f96 | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 76 | |
Zhijun He | 124ccf4 | 2013-05-22 14:01:30 -0700 | [diff] [blame] | 77 | /** |
| 78 | * Note that we release the lock briefly in this function |
| 79 | */ |
Igor Murashkin | e3a9f96 | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 80 | virtual status_t returnBufferCheckedLocked( |
| 81 | const camera3_stream_buffer &buffer, |
| 82 | nsecs_t timestamp, |
| 83 | bool output, |
| 84 | /*out*/ |
| 85 | sp<Fence> *releaseFenceOut); |
| 86 | |
Zhijun He | 0a21051 | 2014-07-24 13:45:15 -0700 | [diff] [blame] | 87 | virtual status_t disconnectLocked(); |
| 88 | |
Eino-Ville Talvala | 727d172 | 2015-06-09 13:44:19 -0700 | [diff] [blame] | 89 | sp<Surface> mConsumer; |
Igor Murashkin | e3a9f96 | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 90 | private: |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 91 | int mTransform; |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 92 | |
Igor Murashkin | e3a9f96 | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 93 | virtual status_t setTransformLocked(int transform); |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 94 | |
Ruchit Sharma | e0711f2 | 2014-08-18 13:48:24 -0400 | [diff] [blame] | 95 | bool mTraceFirstBuffer; |
| 96 | |
Eino-Ville Talvala | 727d172 | 2015-06-09 13:44:19 -0700 | [diff] [blame] | 97 | // Name of Surface consumer |
| 98 | String8 mConsumerName; |
| 99 | |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 100 | /** |
| 101 | * Internal Camera3Stream interface |
| 102 | */ |
| 103 | virtual status_t getBufferLocked(camera3_stream_buffer *buffer); |
| 104 | virtual status_t returnBufferLocked( |
| 105 | const camera3_stream_buffer &buffer, |
| 106 | nsecs_t timestamp); |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 107 | |
| 108 | virtual status_t configureQueueLocked(); |
Eino-Ville Talvala | b2f5b19 | 2013-07-30 14:36:03 -0700 | [diff] [blame] | 109 | |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 110 | virtual status_t getEndpointUsage(uint32_t *usage) const; |
Eino-Ville Talvala | b2f5b19 | 2013-07-30 14:36:03 -0700 | [diff] [blame] | 111 | |
Eino-Ville Talvala | fd58f1a | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 112 | }; // class Camera3OutputStream |
| 113 | |
| 114 | } // namespace camera3 |
| 115 | |
| 116 | } // namespace android |
| 117 | |
| 118 | #endif |