1 /*
2  * Copyright 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 #include <gui/BufferHubConsumer.h>
18 
19 namespace android {
20 
21 using namespace dvr;
22 
23 /* static */
Create(const std::shared_ptr<ConsumerQueue> & queue)24 sp<BufferHubConsumer> BufferHubConsumer::Create(const std::shared_ptr<ConsumerQueue>& queue) {
25     sp<BufferHubConsumer> consumer = new BufferHubConsumer;
26     consumer->mQueue = queue;
27     return consumer;
28 }
29 
Create(ConsumerQueueParcelable parcelable)30 /* static */ sp<BufferHubConsumer> BufferHubConsumer::Create(ConsumerQueueParcelable parcelable) {
31     if (!parcelable.IsValid()) {
32         ALOGE("BufferHubConsumer::Create: Invalid consumer parcelable.");
33         return nullptr;
34     }
35 
36     sp<BufferHubConsumer> consumer = new BufferHubConsumer;
37     consumer->mQueue = ConsumerQueue::Import(parcelable.TakeChannelHandle());
38     return consumer;
39 }
40 
acquireBuffer(BufferItem *,nsecs_t,uint64_t)41 status_t BufferHubConsumer::acquireBuffer(BufferItem* /*buffer*/, nsecs_t /*presentWhen*/,
42                                           uint64_t /*maxFrameNumber*/) {
43     ALOGE("BufferHubConsumer::acquireBuffer: not implemented.");
44     return INVALID_OPERATION;
45 }
46 
detachBuffer(int)47 status_t BufferHubConsumer::detachBuffer(int /*slot*/) {
48     ALOGE("BufferHubConsumer::detachBuffer: not implemented.");
49     return INVALID_OPERATION;
50 }
51 
attachBuffer(int *,const sp<GraphicBuffer> &)52 status_t BufferHubConsumer::attachBuffer(int* /*outSlot*/, const sp<GraphicBuffer>& /*buffer*/) {
53     ALOGE("BufferHubConsumer::attachBuffer: not implemented.");
54     return INVALID_OPERATION;
55 }
56 
releaseBuffer(int,uint64_t,EGLDisplay,EGLSyncKHR,const sp<Fence> &)57 status_t BufferHubConsumer::releaseBuffer(int /*buf*/, uint64_t /*frameNumber*/,
58                                           EGLDisplay /*display*/, EGLSyncKHR /*fence*/,
59                                           const sp<Fence>& /*releaseFence*/) {
60     ALOGE("BufferHubConsumer::releaseBuffer: not implemented.");
61     return INVALID_OPERATION;
62 }
63 
consumerConnect(const sp<IConsumerListener> &,bool)64 status_t BufferHubConsumer::consumerConnect(const sp<IConsumerListener>& /*consumer*/,
65                                             bool /*controlledByApp*/) {
66     ALOGE("BufferHubConsumer::consumerConnect: not implemented.");
67 
68     // TODO(b/73267953): Make BufferHub honor producer and consumer connection. Returns NO_ERROR to
69     // make IGraphicBufferConsumer_test happy.
70     return NO_ERROR;
71 }
72 
consumerDisconnect()73 status_t BufferHubConsumer::consumerDisconnect() {
74     ALOGE("BufferHubConsumer::consumerDisconnect: not implemented.");
75 
76     // TODO(b/73267953): Make BufferHub honor producer and consumer connection. Returns NO_ERROR to
77     // make IGraphicBufferConsumer_test happy.
78     return NO_ERROR;
79 }
80 
getReleasedBuffers(uint64_t *)81 status_t BufferHubConsumer::getReleasedBuffers(uint64_t* /*slotMask*/) {
82     ALOGE("BufferHubConsumer::getReleasedBuffers: not implemented.");
83     return INVALID_OPERATION;
84 }
85 
setDefaultBufferSize(uint32_t,uint32_t)86 status_t BufferHubConsumer::setDefaultBufferSize(uint32_t /*w*/, uint32_t /*h*/) {
87     ALOGE("BufferHubConsumer::setDefaultBufferSize: not implemented.");
88     return INVALID_OPERATION;
89 }
90 
setMaxBufferCount(int)91 status_t BufferHubConsumer::setMaxBufferCount(int /*bufferCount*/) {
92     ALOGE("BufferHubConsumer::setMaxBufferCount: not implemented.");
93     return INVALID_OPERATION;
94 }
95 
setMaxAcquiredBufferCount(int)96 status_t BufferHubConsumer::setMaxAcquiredBufferCount(int /*maxAcquiredBuffers*/) {
97     ALOGE("BufferHubConsumer::setMaxAcquiredBufferCount: not implemented.");
98 
99     // TODO(b/73267953): Make BufferHub honor producer and consumer connection. Returns NO_ERROR to
100     // make IGraphicBufferConsumer_test happy.
101     return NO_ERROR;
102 }
103 
setConsumerName(const String8 &)104 status_t BufferHubConsumer::setConsumerName(const String8& /*name*/) {
105     ALOGE("BufferHubConsumer::setConsumerName: not implemented.");
106     return INVALID_OPERATION;
107 }
108 
setDefaultBufferFormat(PixelFormat)109 status_t BufferHubConsumer::setDefaultBufferFormat(PixelFormat /*defaultFormat*/) {
110     ALOGE("BufferHubConsumer::setDefaultBufferFormat: not implemented.");
111     return INVALID_OPERATION;
112 }
113 
setDefaultBufferDataSpace(android_dataspace)114 status_t BufferHubConsumer::setDefaultBufferDataSpace(android_dataspace /*defaultDataSpace*/) {
115     ALOGE("BufferHubConsumer::setDefaultBufferDataSpace: not implemented.");
116     return INVALID_OPERATION;
117 }
118 
setConsumerUsageBits(uint64_t)119 status_t BufferHubConsumer::setConsumerUsageBits(uint64_t /*usage*/) {
120     ALOGE("BufferHubConsumer::setConsumerUsageBits: not implemented.");
121     return INVALID_OPERATION;
122 }
123 
setConsumerIsProtected(bool)124 status_t BufferHubConsumer::setConsumerIsProtected(bool /*isProtected*/) {
125     ALOGE("BufferHubConsumer::setConsumerIsProtected: not implemented.");
126     return INVALID_OPERATION;
127 }
128 
setTransformHint(uint32_t)129 status_t BufferHubConsumer::setTransformHint(uint32_t /*hint*/) {
130     ALOGE("BufferHubConsumer::setTransformHint: not implemented.");
131     return INVALID_OPERATION;
132 }
133 
getSidebandStream(sp<NativeHandle> *) const134 status_t BufferHubConsumer::getSidebandStream(sp<NativeHandle>* /*outStream*/) const {
135     ALOGE("BufferHubConsumer::getSidebandStream: not implemented.");
136     return INVALID_OPERATION;
137 }
138 
getOccupancyHistory(bool,std::vector<OccupancyTracker::Segment> *)139 status_t BufferHubConsumer::getOccupancyHistory(
140         bool /*forceFlush*/, std::vector<OccupancyTracker::Segment>* /*outHistory*/) {
141     ALOGE("BufferHubConsumer::getOccupancyHistory: not implemented.");
142     return INVALID_OPERATION;
143 }
144 
discardFreeBuffers()145 status_t BufferHubConsumer::discardFreeBuffers() {
146     ALOGE("BufferHubConsumer::discardFreeBuffers: not implemented.");
147     return INVALID_OPERATION;
148 }
149 
dumpState(const String8 &,String8 *) const150 status_t BufferHubConsumer::dumpState(const String8& /*prefix*/, String8* /*outResult*/) const {
151     ALOGE("BufferHubConsumer::dumpState: not implemented.");
152     return INVALID_OPERATION;
153 }
154 
onAsBinder()155 IBinder* BufferHubConsumer::onAsBinder() {
156     ALOGE("BufferHubConsumer::onAsBinder: BufferHubConsumer should never be used as an Binder "
157           "object.");
158     return nullptr;
159 }
160 
161 } // namespace android
162