blob: 02b1c09621950861d57a6613610bd838fe0383e4 [file] [log] [blame]
Shuzhen Wang0129d522016-10-30 22:43:41 -07001/*
Shuzhen Wangc28189a2017-11-27 23:05:10 -08002 * Copyright (C) 2016-2018 The Android Open Source Project
Shuzhen Wang0129d522016-10-30 22:43:41 -07003 *
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
23namespace android {
24
25namespace camera3 {
26
27class Camera3SharedOutputStream :
28 public Camera3OutputStream {
29public:
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,
Shuzhen Wang758c2152017-01-10 18:26:18 -080036 uint32_t width, uint32_t height, int format,
Emilian Peev050f5dc2017-05-18 14:43:56 +010037 uint64_t consumerUsage, android_dataspace dataSpace,
Shuzhen Wang0129d522016-10-30 22:43:41 -070038 camera3_stream_rotation_t rotation, nsecs_t timestampOffset,
Shuzhen Wangc28189a2017-11-27 23:05:10 -080039 const String8& physicalCameraId,
Shuzhen Wang0129d522016-10-30 22:43:41 -070040 int setId = CAMERA3_STREAM_SET_ID_INVALID);
41
42 virtual ~Camera3SharedOutputStream();
43
Shuzhen Wangbee0f0a2017-01-24 14:51:37 -080044 virtual status_t notifyBufferReleased(ANativeWindowBuffer *buffer);
Shuzhen Wang0129d522016-10-30 22:43:41 -070045
46 virtual bool isConsumerConfigurationDeferred(size_t surface_id) const;
47
Shuzhen Wang758c2152017-01-10 18:26:18 -080048 virtual status_t setConsumers(const std::vector<sp<Surface>>& consumers);
Shuzhen Wang0129d522016-10-30 22:43:41 -070049
Emilian Peev40ead602017-09-26 15:46:36 +010050 virtual ssize_t getSurfaceId(const sp<Surface> &surface);
51
52 virtual status_t updateStream(const std::vector<sp<Surface>> &outputSurfaces,
53 const std::vector<OutputStreamInfo> &outputInfo,
54 const std::vector<size_t> &removedSurfaceIds,
55 KeyedVector<sp<Surface>, size_t> *outputMap/*out*/);
56
Shuzhen Wang0129d522016-10-30 22:43:41 -070057private:
Emilian Peev40ead602017-09-26 15:46:36 +010058
59 static const size_t kMaxOutputs = 4;
60
61 // Map surfaceId -> output surfaces
62 sp<Surface> mSurfaces[kMaxOutputs];
63
64 ssize_t getNextSurfaceIdLocked();
65
66 status_t revertPartialUpdateLocked(const KeyedVector<sp<Surface>, size_t> &removedSurfaces,
67 const KeyedVector<sp<Surface>, size_t> &attachedSurfaces);
Shuzhen Wang0129d522016-10-30 22:43:41 -070068
69 /**
70 * The Camera3StreamSplitter object this stream uses for stream
71 * sharing.
72 */
73 sp<Camera3StreamSplitter> mStreamSplitter;
74
75 /**
76 * Initialize stream splitter.
77 */
78 status_t connectStreamSplitterLocked();
79
Shuzhen Wangbee0f0a2017-01-24 14:51:37 -080080 /**
81 * Internal Camera3Stream interface
82 */
83 virtual status_t getBufferLocked(camera3_stream_buffer *buffer,
84 const std::vector<size_t>& surface_ids);
85
86 virtual status_t queueBufferToConsumer(sp<ANativeWindow>& consumer,
87 ANativeWindowBuffer* buffer, int anwReleaseFence);
88
Shuzhen Wang0129d522016-10-30 22:43:41 -070089 virtual status_t configureQueueLocked();
90
91 virtual status_t disconnectLocked();
92
Emilian Peev050f5dc2017-05-18 14:43:56 +010093 virtual status_t getEndpointUsage(uint64_t *usage) const;
Shuzhen Wang0129d522016-10-30 22:43:41 -070094
Shuzhen Wang0129d522016-10-30 22:43:41 -070095}; // class Camera3SharedOutputStream
96
97} // namespace camera3
98
99} // namespace android
100
101#endif // ANDROID_SERVERS_CAMERA3_SHARED_OUTPUT_STREAM_H