• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef ANDROID_V4L2_CODEC2_PLUGIN_STORE_H2B_GRAPHIC_BUFFER_PRODUCER_H
6 #define ANDROID_V4L2_CODEC2_PLUGIN_STORE_H2B_GRAPHIC_BUFFER_PRODUCER_H
7 
8 #include <C2Buffer.h>
9 #include <android/hardware/graphics/bufferqueue/2.0/IGraphicBufferProducer.h>
10 #include <android/hardware/graphics/bufferqueue/2.0/IProducerListener.h>
11 #include <ui/Fence.h>
12 #include <ui/GraphicBuffer.h>
13 #include <utils/StrongPointer.h>
14 
15 namespace android {
16 
17 class H2BGraphicBufferProducer {
18 public:
19     using HGraphicBufferProducer =
20             ::android::hardware::graphics::bufferqueue::V2_0::IGraphicBufferProducer;
21     using HProducerListener = ::android::hardware::graphics::bufferqueue::V2_0::IProducerListener;
22 
23     explicit H2BGraphicBufferProducer(sp<HGraphicBufferProducer> base);
24     ~H2BGraphicBufferProducer() = default;
25 
26     // Convert HIDL interface of IGraphicBufferProducer.
27     status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
28     status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers);
29     status_t dequeueBuffer(uint32_t width, uint32_t height, uint32_t pixelFormat,
30                            C2AndroidMemoryUsage androidUsage, int* slot, sp<Fence>* fence);
31     status_t detachBuffer(int slot);
32     status_t attachBuffer(const sp<GraphicBuffer>& buffer, int* outSlot);
33     status_t cancelBuffer(int slot, const sp<Fence>& fence);
34     int query(int what, int* value);
35     status_t allowAllocation(bool allow);
36     status_t getUniqueId(uint64_t* outId) const;
37     status_t connect(sp<HProducerListener> const& hListener, int32_t api,
38                      bool producerControlledByApp);
39     status_t setDequeueTimeout(nsecs_t timeout);
40 
getBase()41     sp<HGraphicBufferProducer> getBase() { return mBase; }
42 
43 private:
44     const sp<HGraphicBufferProducer> mBase;
45 };
46 
47 }  // namespace android
48 #endif  // ANDROID_V4L2_CODEC2_PLUGIN_STORE_H2B_GRAPHIC_BUFFER_PRODUCER_H
49