• 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 
16 #ifndef FRAMEWORKS_SERVICES_THUMBNAIL_SERVICE_INCLUDE_THUMBNAIL_IMAGE_FRAMEWORK_UTILS_H_
17 #define FRAMEWORKS_SERVICES_THUMBNAIL_SERVICE_INCLUDE_THUMBNAIL_IMAGE_FRAMEWORK_UTILS_H_
18 
19 #include "picture.h"
20 #include "surface_buffer.h"
21 
22 namespace OHOS {
23 namespace Media {
24 #define EXPORT __attribute__ ((visibility ("default")))
25 class ThumbnailImageFrameWorkUtils {
26 public:
27     EXPORT ThumbnailImageFrameWorkUtils() = delete;
28     EXPORT virtual ~ThumbnailImageFrameWorkUtils() = delete;
29 
30     EXPORT static bool IsYuvPixelMap(std::shared_ptr<PixelMap> pixelMap);
31     EXPORT static bool IsSupportCopyPixelMap(std::shared_ptr<PixelMap> pixelMap);
32     EXPORT static std::shared_ptr<Picture> CopyPictureSource(std::shared_ptr<Picture> picture);
33     EXPORT static std::shared_ptr<PixelMap> CopyPixelMapSource(std::shared_ptr<PixelMap> pixelMap);
34     EXPORT static int32_t GetPictureOrientation(std::shared_ptr<Picture> picture, int32_t &orientation);
35 
36 private:
37     EXPORT static std::shared_ptr<PixelMap> CopyNormalPixelmap(std::shared_ptr<PixelMap> pixelMap);
38     EXPORT static std::shared_ptr<PixelMap> CopyYuvPixelmap(std::shared_ptr<PixelMap> pixelMap);
39     EXPORT static std::shared_ptr<PixelMap> CopyYuvPixelmapWithSurfaceBuffer(std::shared_ptr<PixelMap> pixelMap);
40     EXPORT static std::shared_ptr<PixelMap> CopyNoSurfaceBufferYuvPixelmap(std::shared_ptr<PixelMap> pixelMap);
41     EXPORT static bool SetPixelMapYuvInfo(sptr<SurfaceBuffer> &surfaceBuffer,
42         std::shared_ptr<PixelMap> pixelMap, bool isHdr);
43     EXPORT static void CopySurfaceBufferInfo(sptr<SurfaceBuffer> &source, sptr<SurfaceBuffer> &dst);
44     EXPORT static bool GetSbStaticMetadata(const sptr<SurfaceBuffer> &buffer, std::vector<uint8_t> &staticMetadata);
45     EXPORT static bool GetSbDynamicMetadata(const sptr<SurfaceBuffer> &buffer, std::vector<uint8_t> &dynamicMetadata);
46     EXPORT static bool SetSbStaticMetadata(sptr<SurfaceBuffer> &buffer, const std::vector<uint8_t> &staticMetadata);
47     EXPORT static bool SetSbDynamicMetadata(sptr<SurfaceBuffer> &buffer, const std::vector<uint8_t> &dynamicMetadata);
48 };
49 } // namespace Media
50 } // namespace OHOS
51 
52 #endif  // FRAMEWORKS_SERVICES_THUMBNAIL_SERVICE_INCLUDE_THUMBNAIL_IMAGE_FRAMEWORK_UTILS_H_
53