• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include "codec_buffer_wrapper.h"
16 #include <unistd.h>
17 
18 namespace OHOS::Codec::Omx {
19 
Convert(const CodecHDI::OmxCodecBuffer & src,bool isIpcMode)20 OmxCodecBuffer Convert(const CodecHDI::OmxCodecBuffer& src, bool isIpcMode)
21 {
22     return OmxCodecBuffer {
23         .bufferId = src.bufferId,
24         .bufferType = src.bufferType,
25         .bufferhandle = ReWrap(src.bufferhandle, isIpcMode),
26         .fd = UniqueFd::Create(src.fd, isIpcMode),
27         .allocLen = src.allocLen,
28         .filledLen = src.filledLen,
29         .offset = src.offset,
30         .fenceFd = UniqueFd::Create(src.fenceFd, isIpcMode),
31         .type = src.type,
32         .pts = src.pts,
33         .flag = src.flag,
34         .alongParam = std::move(src.alongParam),
35     };
36 }
37 
Convert(const OmxCodecBuffer & src,bool isIpcMode)38 CodecHDI::OmxCodecBuffer Convert(const OmxCodecBuffer& src, bool isIpcMode)
39 {
40     return CodecHDI::OmxCodecBuffer {
41         .bufferId = src.bufferId,
42         .bufferType = src.bufferType,
43         .bufferhandle = src.bufferhandle,
44         .fd = src.fd ? (isIpcMode ? src.fd->Get() : dup(src.fd->Get())) : -1,
45         .allocLen = src.allocLen,
46         .filledLen = src.filledLen,
47         .offset = src.offset,
48         .fenceFd = src.fenceFd ? (isIpcMode ? src.fenceFd->Get() : dup(src.fenceFd->Get())) : -1,
49         .type = src.type,
50         .pts = src.pts,
51         .flag = src.flag,
52         .alongParam = std::move(src.alongParam),
53     };
54 }
55 }