• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 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 HOS_CAMERA_BUFFER_ADAPTER_H
17 #define HOS_CAMERA_BUFFER_ADAPTER_H
18 
19 #include <surface_buffer.h>
20 #include <memory>
21 #include "display_type.h"
22 #include "ibuffer.h"
23 #include "surface.h"
24 
25 namespace OHOS::Camera {
26 class BufferAdapter {
27 public:
28     // convert surfae buffer to camera ibuffer, only for external buffer.
29     static RetCode SurfaceBufferToCameraBuffer(const OHOS::SurfaceBuffer* surfaceBuffer,
30                                                const std::shared_ptr<OHOS::Surface>& surface,
31                                                const std::shared_ptr<IBuffer>& buffer);
32 
33     static RetCode SetExtInfoToSurfaceBuffer(const std::shared_ptr<IBuffer>& buffer,
34                                                const std::shared_ptr<OHOS::SurfaceBuffer>& surfaceBuffer);
35 
36     // convert camera format to pixel format.
37     static uint32_t CameraFormatToPixelFormat(const uint32_t cameraFormat);
38     // convert pixel format to camera format.
39     static uint32_t PixelFormatToCameraFormat(const uint32_t format);
40 
41     // convert camera usage to gralloc usage.
42     static uint64_t CameraUsageToGrallocUsage(const uint64_t cameraUsage);
43 
44     // convert gralloc usage to camera usage.
45     static uint64_t GrallocUsageToCameraUsage(const uint64_t usage);
46 };
47 } // namespace OHOS::Camera
48 #endif
49