• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef I_CODEC_BUFFER_MGR_H
17 #define I_CODEC_BUFFER_MGR_H
18 
19 #include <gst/gst.h>
20 #include <vector>
21 #include "nocopyable.h"
22 #include "i_codec_common.h"
23 
24 namespace OHOS {
25 namespace Media {
26 class ICodecBufferMgr {
27 public:
28     virtual ~ICodecBufferMgr() = default;
29 
30     /**
31      * @brief Allocate input buffers.
32      *
33      * This inner memory of the kernel and should not be exposed to the outside.
34      *
35      * @return Returns GST_CODEC_OK successful;
36      * @since 1.0
37      * @version 1.0
38      */
39     virtual int32_t AllocateBuffers() = 0;
40 
41     /**
42      * @brief Use input buffer which can be null, and the real buffer in the push.
43      *
44      * Usebuffers of ashmem and bufferhandle.
45      *
46      * @return Returns GST_CODEC_OK successful;
47      * @since 1.0
48      * @version 1.0
49      */
50     virtual int32_t UseBuffers(std::vector<GstBuffer*> buffers) = 0;
51 
52     /**
53      * @brief Send the input buffer or ouput buffer.
54      *
55      * Codec will empty this buffer or fill this buffer.
56      *
57      * @return Returns GST_CODEC_OK successful;
58      * @since 1.0
59      * @version 1.0
60      */
61     virtual int32_t PushBuffer(GstBuffer *buffer) = 0;
62 
63     /**
64      * @brief Get the buffer.
65      *
66      * Get the buffer which is filled or empty.
67      *
68      * @return Returns GST_CODEC_OK successful;
69      * @since 1.0
70      * @version 1.0
71      */
72     virtual int32_t PullBuffer(GstBuffer **buffer) = 0;
73 
74     /**
75      * @brief Free Buffers free after stop.
76      *
77      * @return Returns GST_CODEC_OK successful;
78      * @since 1.0
79      * @version 1.0
80      */
81     virtual int32_t FreeBuffers() = 0;
82 
83     /**
84      * @brief Flush buffers.
85      *
86      * @return Returns GST_CODEC_OK successful;
87      * @since 1.0
88      * @version 1.0
89      */
90     virtual int32_t Flush(bool enable) = 0;
91 };
92 } // namespace Media
93 } // namespace OHOS
94 #endif // I_CODEC_BUFFER_MGR_H
95