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 #ifndef CLIENT_BLOCK_HELPER_H 18 #define CLIENT_BLOCK_HELPER_H 19 20 #include <gui/IGraphicBufferProducer.h> 21 #include <codec2/hidl/1.0/types.h> 22 #include <C2Work.h> 23 24 namespace android { 25 namespace hardware { 26 namespace media { 27 namespace c2 { 28 namespace V1_0 { 29 namespace utils { 30 31 // BufferQueue-Based Block Operations 32 // ================================== 33 34 // Manage BufferQueue and graphic blocks for both component and codec. 35 // Manage graphic blocks ownership consistently during surface change. 36 struct OutputBufferQueue { 37 38 OutputBufferQueue(); 39 40 ~OutputBufferQueue(); 41 42 // Configure a new surface to render graphic blocks. 43 // Graphic blocks from older surface will be migrated to new surface. 44 bool configure(const sp<IGraphicBufferProducer>& igbp, 45 uint32_t generation, 46 uint64_t bqId); 47 48 // Render a graphic block to current surface. 49 status_t outputBuffer( 50 const C2ConstGraphicBlock& block, 51 const BnGraphicBufferProducer::QueueBufferInput& input, 52 BnGraphicBufferProducer::QueueBufferOutput* output); 53 54 // Call holdBufferQueueBlock() on output blocks in the given workList. 55 // The OutputBufferQueue will take the ownership of output blocks. 56 // 57 // Note: This function should be called after WorkBundle has been received 58 // from another process. 59 void holdBufferQueueBlocks( 60 const std::list<std::unique_ptr<C2Work>>& workList); 61 62 private: 63 64 class Impl; 65 std::unique_ptr<Impl> mImpl; 66 }; 67 68 } // namespace utils 69 } // namespace V1_0 70 } // namespace c2 71 } // namespace media 72 } // namespace hardware 73 } // namespace android 74 75 #endif // CLIENT_BLOCK_HELPER_H 76