xref: /aosp_15_r20/frameworks/av/media/codec2/hal/common/include/codec2/common/BufferPoolSender.h (revision ec779b8e0859a360c3d303172224686826e6e0e1)
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 CODEC2_COMMON_BUFFER_POOL_SENDER_H
18 #define CODEC2_COMMON_BUFFER_POOL_SENDER_H
19 
20 #include <memory>
21 
22 namespace android {
23 
24 // Template class to be used in
25 // objcpy(std::list<std::unique_ptr<C2Work>> -> WorkBundle).
26 template <typename BufferPoolTypes>
27 struct BufferPoolSender {
28     // BufferPoolTypes should define the following types:
29     typedef typename BufferPoolTypes::BufferPoolData        BufferPoolData;
30     typedef typename BufferPoolTypes::ResultStatus          ResultStatus;
31     typedef typename BufferPoolTypes::BufferPoolStatus      BufferPoolStatus;
32     typedef typename BufferPoolTypes::BufferStatusMessage   BufferStatusMessage;
33 
34     /**
35      * Send bpData and return BufferStatusMessage that can be supplied to
36      * IClientManager::receive() in the receiving process.
37      *
38      * This function will be called from within the function
39      * objcpy(std::list<std::unique_ptr<C2Work>> -> WorkBundle).
40      *
41      * \param[in] bpData BufferPoolData identifying the buffer to send.
42      * \param[out] bpMessage BufferStatusMessage of the transaction. Information
43      *    inside \p bpMessage should be passed to the receiving process by some
44      *    other means so it can call receive() properly.
45      * \return ResultStatus value that determines the success of the operation.
46      *    (See the possible values of ResultStatus in
47      *    hardware/interfaces/media/bufferpool/2.0/types.hal.)
48      */
49     virtual BufferPoolStatus send(
50             const std::shared_ptr<BufferPoolData>& bpData,
51             BufferStatusMessage* bpMessage) = 0;
52 
53     virtual ~BufferPoolSender() = default;
54 };
55 
56 }  // namespace android
57 
58 #endif  // CODEC2_COMMON_BUFFER_POOL_SENDER_H
59