Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2016 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_SHARED_OUTPUT_STREAM_H |
| 18 | #define ANDROID_SERVERS_CAMERA3_SHARED_OUTPUT_STREAM_H |
| 19 | |
| 20 | #include "Camera3StreamSplitter.h" |
| 21 | #include "Camera3OutputStream.h" |
| 22 | |
| 23 | namespace android { |
| 24 | |
| 25 | namespace camera3 { |
| 26 | |
| 27 | class Camera3SharedOutputStream : |
| 28 | public Camera3OutputStream { |
| 29 | public: |
| 30 | /** |
| 31 | * Set up a stream for formats that have 2 dimensions, with multiple |
| 32 | * surfaces. A valid stream set id needs to be set to support buffer |
| 33 | * sharing between multiple streams. |
| 34 | */ |
| 35 | Camera3SharedOutputStream(int id, const std::vector<sp<Surface>>& surfaces, |
| 36 | bool hasDeferredSurface, uint32_t width, uint32_t height, int format, |
| 37 | uint32_t consumerUsage, android_dataspace dataSpace, |
| 38 | camera3_stream_rotation_t rotation, nsecs_t timestampOffset, |
| 39 | int setId = CAMERA3_STREAM_SET_ID_INVALID); |
| 40 | |
| 41 | virtual ~Camera3SharedOutputStream(); |
| 42 | |
| 43 | virtual status_t notifyRequestedSurfaces(uint32_t frame_number, |
| 44 | const std::vector<size_t>& surface_ids); |
| 45 | |
| 46 | virtual bool isConsumerConfigurationDeferred(size_t surface_id) const; |
| 47 | |
| 48 | virtual status_t setConsumer(sp<Surface> consumer); |
| 49 | |
| 50 | private: |
| 51 | // Surfaces passed in constructor from app |
| 52 | std::vector<sp<Surface> > mSurfaces; |
| 53 | |
| 54 | /** |
| 55 | * The Camera3StreamSplitter object this stream uses for stream |
| 56 | * sharing. |
| 57 | */ |
| 58 | sp<Camera3StreamSplitter> mStreamSplitter; |
| 59 | |
| 60 | /** |
| 61 | * Initialize stream splitter. |
| 62 | */ |
| 63 | status_t connectStreamSplitterLocked(); |
| 64 | |
| 65 | virtual status_t configureQueueLocked(); |
| 66 | |
| 67 | virtual status_t disconnectLocked(); |
| 68 | |
| 69 | virtual status_t getEndpointUsage(uint32_t *usage) const; |
| 70 | |
| 71 | bool mDeferred; |
| 72 | |
| 73 | }; // class Camera3SharedOutputStream |
| 74 | |
| 75 | } // namespace camera3 |
| 76 | |
| 77 | } // namespace android |
| 78 | |
| 79 | #endif // ANDROID_SERVERS_CAMERA3_SHARED_OUTPUT_STREAM_H |