1 /* 2 * Copyright (c) 2022 Shenzhen Kaihong DID 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 CODEC_SHARE_BUFFER_H 17 #define CODEC_SHARE_BUFFER_H 18 #include <ashmem.h> 19 #include <memory> 20 #include "icodec_buffer.h" 21 22 namespace OHOS { 23 namespace Codec { 24 namespace Omx { 25 class CodecShareBuffer : public ICodecBuffer { 26 public: 27 ~CodecShareBuffer() = default; 28 static sptr<ICodecBuffer> UseBuffer(OMX_HANDLETYPE comp, uint32_t portIndex, 29 OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE *&header, bool doCopy); 30 static sptr<ICodecBuffer> AllocateBuffer(OMX_HANDLETYPE comp, uint32_t portIndex, 31 OmxCodecBuffer &codecBuffer, OMX_BUFFERHEADERTYPE *&header); 32 int32_t EmptyThisBuffer(OmxCodecBuffer &codecBuffer) override; 33 int32_t FillBufferDone(OMX_BUFFERHEADERTYPE &omxBuffer, OmxCodecBuffer& codecBuffer) override; 34 35 protected: CodecShareBuffer(const InitInfo & info,sptr<Ashmem> shMem,bool doCopy)36 CodecShareBuffer(const InitInfo& info, sptr<Ashmem> shMem, bool doCopy) 37 : ICodecBuffer(info), shMem_(shMem), doCopy_(doCopy) {} 38 39 private: 40 sptr<Ashmem> shMem_; 41 bool doCopy_ = false; 42 }; 43 } // namespace Omx 44 } // namespace Codec 45 } // namespace OHOS 46 #endif