1 /* 2 * Copyright (c) 2023-2023 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 #if defined(VIDEO_SUPPORT) 17 18 #ifndef HISTREAMER_PLUGIN_CODEC_BUFFER_H 19 #define HISTREAMER_PLUGIN_CODEC_BUFFER_H 20 21 #include "v4_0/icodec_component.h" 22 #include "v4_0/codec_types.h" 23 #include "codec_omx_ext.h" 24 #include "plugin/common/plugin_buffer.h" 25 #include "plugin/common/share_memory.h" 26 27 namespace OHOS { 28 namespace Media { 29 namespace Plugin { 30 namespace CodecAdapter { 31 32 namespace CodecHDI = OHOS::HDI::Codec::V4_0; 33 34 class CodecBuffer { 35 public: 36 CodecBuffer(std::shared_ptr<Buffer>& buffer, CodecHDI::CompVerInfo& verInfo, 37 bool isInput, uint32_t bufferSize, MemoryType bufMemType); 38 39 ~CodecBuffer() = default; 40 41 std::shared_ptr<CodecHDI::OmxCodecBuffer> GetOmxBuffer(); 42 43 uint32_t GetBufferId() const; 44 45 Status Copy(const std::shared_ptr<Plugin::Buffer>& pluginBuffer); 46 47 Status Rebind(const std::shared_ptr<Plugin::Buffer>& pluginBuffer); // 重新申请内存时, CodecBuffer都要重新创建 48 49 Status Unbind(std::shared_ptr<Plugin::Buffer>& buffer, const CodecHDI::OmxCodecBuffer& omxBuffer); 50 51 private: 52 void Init(bool isInput, uint32_t bufferSize, MemoryType bufMemType); 53 54 std::shared_ptr<Buffer> buffer_; 55 CodecHDI::CompVerInfo verInfo_ {}; 56 std::shared_ptr<Memory> memory_; 57 std::shared_ptr<CodecHDI::OmxCodecBuffer> omxBuffer_; 58 }; 59 } // namespace CodecAdapter 60 } // namespace Plugin 61 } // namespace Media 62 } // namespace OHOS 63 #endif // HISTREAMER_PLUGIN_CODEC_BUFFER_H 64 #endif