• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014-2018 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 #define LOG_TAG "Camera3-FakeStream"
18 #define ATRACE_TAG ATRACE_TAG_CAMERA
19 //#define LOG_NDEBUG 0
20 
21 #include <utils/Log.h>
22 #include <utils/Trace.h>
23 #include <camera/StringUtils.h>
24 #include "Camera3FakeStream.h"
25 
26 namespace android {
27 
28 namespace camera3 {
29 
30 const std::string Camera3FakeStream::FAKE_ID;
31 
Camera3FakeStream(int id)32 Camera3FakeStream::Camera3FakeStream(int id) :
33         Camera3IOStreamBase(id, CAMERA_STREAM_OUTPUT, FAKE_WIDTH, FAKE_HEIGHT,
34                 /*maxSize*/0, FAKE_FORMAT, FAKE_DATASPACE, FAKE_ROTATION,
35                 FAKE_ID, std::unordered_set<int32_t>{ANDROID_SENSOR_PIXEL_MODE_DEFAULT}) {
36 
37 }
38 
~Camera3FakeStream()39 Camera3FakeStream::~Camera3FakeStream() {
40 
41 }
42 
getBufferLocked(camera_stream_buffer *,const std::vector<size_t> &)43 status_t Camera3FakeStream::getBufferLocked(camera_stream_buffer *,
44         const std::vector<size_t>&) {
45     ATRACE_CALL();
46     ALOGE("%s: Stream %d: Fake stream cannot produce buffers!", __FUNCTION__, mId);
47     return INVALID_OPERATION;
48 }
49 
returnBufferLocked(const camera_stream_buffer &,nsecs_t,nsecs_t,int32_t,const std::vector<size_t> &)50 status_t Camera3FakeStream::returnBufferLocked(
51         const camera_stream_buffer &,
52         nsecs_t, nsecs_t, int32_t, const std::vector<size_t>&) {
53     ATRACE_CALL();
54     ALOGE("%s: Stream %d: Fake stream cannot return buffers!", __FUNCTION__, mId);
55     return INVALID_OPERATION;
56 }
57 
returnBufferCheckedLocked(const camera_stream_buffer &,nsecs_t,nsecs_t,bool,int32_t,const std::vector<size_t> &,sp<Fence> *)58 status_t Camera3FakeStream::returnBufferCheckedLocked(
59             const camera_stream_buffer &,
60             nsecs_t, nsecs_t,
61             bool,
62             int32_t,
63             const std::vector<size_t>&,
64             /*out*/
65             sp<Fence>*) {
66     ATRACE_CALL();
67     ALOGE("%s: Stream %d: Fake stream cannot return buffers!", __FUNCTION__, mId);
68     return INVALID_OPERATION;
69 }
70 
dump(int fd,const Vector<String16> & args)71 void Camera3FakeStream::dump(int fd, [[maybe_unused]] const Vector<String16> &args) {
72     std::string lines;
73     lines += fmt::sprintf("    Stream[%d]: Fake\n", mId);
74     write(fd, lines.c_str(), lines.size());
75 
76     Camera3IOStreamBase::dump(fd, args);
77 }
78 
setTransform(int,bool)79 status_t Camera3FakeStream::setTransform(int, bool) {
80     ATRACE_CALL();
81     // Do nothing
82     return OK;
83 }
84 
detachBuffer(sp<GraphicBuffer> * buffer,int * fenceFd)85 status_t Camera3FakeStream::detachBuffer([[maybe_unused]] sp<GraphicBuffer>* buffer,
86                 [[maybe_unused]] int* fenceFd) {
87     // Do nothing
88     return OK;
89 }
90 
configureQueueLocked()91 status_t Camera3FakeStream::configureQueueLocked() {
92     // Do nothing
93     return OK;
94 }
95 
disconnectLocked()96 status_t Camera3FakeStream::disconnectLocked() {
97     mState = (mState == STATE_IN_RECONFIG) ? STATE_IN_CONFIG
98                                            : STATE_CONSTRUCTED;
99     return OK;
100 }
101 
getEndpointUsage(uint64_t * usage)102 status_t Camera3FakeStream::getEndpointUsage(uint64_t *usage) {
103     *usage = FAKE_USAGE;
104     return OK;
105 }
106 
isVideoStream()107 bool Camera3FakeStream::isVideoStream() {
108     return false;
109 }
110 
isConsumerConfigurationDeferred(size_t) const111 bool Camera3FakeStream::isConsumerConfigurationDeferred(size_t /*surface_id*/) const {
112     return false;
113 }
114 
dropBuffers(bool)115 status_t Camera3FakeStream::dropBuffers(bool /*dropping*/) {
116     return OK;
117 }
118 
getPhysicalCameraId() const119 const std::string& Camera3FakeStream::getPhysicalCameraId() const {
120     return FAKE_ID;
121 }
122 
setConsumers(const std::vector<sp<Surface>> &)123 status_t Camera3FakeStream::setConsumers(const std::vector<sp<Surface>>& /*consumers*/) {
124     ALOGE("%s: Stream %d: Fake stream doesn't support set consumer surface!",
125             __FUNCTION__, mId);
126     return INVALID_OPERATION;
127 }
128 
updateStream(const std::vector<sp<Surface>> &,const std::vector<OutputStreamInfo> &,const std::vector<size_t> &,KeyedVector<sp<Surface>,size_t> *)129 status_t Camera3FakeStream::updateStream(const std::vector<sp<Surface>> &/*outputSurfaces*/,
130             const std::vector<OutputStreamInfo> &/*outputInfo*/,
131             const std::vector<size_t> &/*removedSurfaceIds*/,
132             KeyedVector<sp<Surface>, size_t> * /*outputMap*/) {
133     ALOGE("%s: this method is not supported!", __FUNCTION__);
134     return INVALID_OPERATION;
135 }
136 
setBatchSize(size_t)137 status_t Camera3FakeStream::setBatchSize(size_t /*batchSize*/) {
138     ALOGE("%s: this method is not supported!", __FUNCTION__);
139     return INVALID_OPERATION;
140 }
141 
142 }; // namespace camera3
143 
144 }; // namespace android
145