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-DummyStream"
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 "Camera3DummyStream.h"
24 
25 namespace android {
26 
27 namespace camera3 {
28 
29 const String8 Camera3DummyStream::DUMMY_ID;
30 
Camera3DummyStream(int id)31 Camera3DummyStream::Camera3DummyStream(int id) :
32         Camera3IOStreamBase(id, CAMERA3_STREAM_OUTPUT, DUMMY_WIDTH, DUMMY_HEIGHT,
33                 /*maxSize*/0, DUMMY_FORMAT, DUMMY_DATASPACE, DUMMY_ROTATION,
34                 DUMMY_ID) {
35 
36 }
37 
~Camera3DummyStream()38 Camera3DummyStream::~Camera3DummyStream() {
39 
40 }
41 
getBufferLocked(camera3_stream_buffer *,const std::vector<size_t> &)42 status_t Camera3DummyStream::getBufferLocked(camera3_stream_buffer *,
43         const std::vector<size_t>&) {
44     ATRACE_CALL();
45     ALOGE("%s: Stream %d: Dummy stream cannot produce buffers!", __FUNCTION__, mId);
46     return INVALID_OPERATION;
47 }
48 
returnBufferLocked(const camera3_stream_buffer &,nsecs_t,const std::vector<size_t> &)49 status_t Camera3DummyStream::returnBufferLocked(
50         const camera3_stream_buffer &,
51         nsecs_t, const std::vector<size_t>&) {
52     ATRACE_CALL();
53     ALOGE("%s: Stream %d: Dummy stream cannot return buffers!", __FUNCTION__, mId);
54     return INVALID_OPERATION;
55 }
56 
returnBufferCheckedLocked(const camera3_stream_buffer &,nsecs_t,bool,const std::vector<size_t> &,sp<Fence> *)57 status_t Camera3DummyStream::returnBufferCheckedLocked(
58             const camera3_stream_buffer &,
59             nsecs_t,
60             bool,
61             const std::vector<size_t>&,
62             /*out*/
63             sp<Fence>*) {
64     ATRACE_CALL();
65     ALOGE("%s: Stream %d: Dummy stream cannot return buffers!", __FUNCTION__, mId);
66     return INVALID_OPERATION;
67 }
68 
dump(int fd,const Vector<String16> & args) const69 void Camera3DummyStream::dump(int fd, const Vector<String16> &args) const {
70     (void) args;
71     String8 lines;
72     lines.appendFormat("    Stream[%d]: Dummy\n", mId);
73     write(fd, lines.string(), lines.size());
74 
75     Camera3IOStreamBase::dump(fd, args);
76 }
77 
setTransform(int)78 status_t Camera3DummyStream::setTransform(int) {
79     ATRACE_CALL();
80     // Do nothing
81     return OK;
82 }
83 
detachBuffer(sp<GraphicBuffer> * buffer,int * fenceFd)84 status_t Camera3DummyStream::detachBuffer(sp<GraphicBuffer>* buffer, int* fenceFd) {
85     (void) buffer;
86     (void) fenceFd;
87     // Do nothing
88     return OK;
89 }
90 
configureQueueLocked()91 status_t Camera3DummyStream::configureQueueLocked() {
92     // Do nothing
93     return OK;
94 }
95 
disconnectLocked()96 status_t Camera3DummyStream::disconnectLocked() {
97     mState = (mState == STATE_IN_RECONFIG) ? STATE_IN_CONFIG
98                                            : STATE_CONSTRUCTED;
99     return OK;
100 }
101 
getEndpointUsage(uint64_t * usage) const102 status_t Camera3DummyStream::getEndpointUsage(uint64_t *usage) const {
103     *usage = DUMMY_USAGE;
104     return OK;
105 }
106 
isVideoStream() const107 bool Camera3DummyStream::isVideoStream() const {
108     return false;
109 }
110 
isConsumerConfigurationDeferred(size_t) const111 bool Camera3DummyStream::isConsumerConfigurationDeferred(size_t /*surface_id*/) const {
112     return false;
113 }
114 
dropBuffers(bool)115 status_t Camera3DummyStream::dropBuffers(bool /*dropping*/) {
116     return OK;
117 }
118 
getPhysicalCameraId() const119 const String8& Camera3DummyStream::getPhysicalCameraId() const {
120     return DUMMY_ID;
121 }
122 
setConsumers(const std::vector<sp<Surface>> &)123 status_t Camera3DummyStream::setConsumers(const std::vector<sp<Surface>>& /*consumers*/) {
124     ALOGE("%s: Stream %d: Dummy 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 Camera3DummyStream::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 
137 }; // namespace camera3
138 
139 }; // namespace android
140