1 /*
2  * Copyright (c) 2024 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 "image_packer_impl.h"
16 
17 namespace OHOS {
18 namespace Media {
19 extern "C" {
ImagePackerImpl()20 ImagePackerImpl::ImagePackerImpl()
21 {
22     real_ = std::make_unique<ImagePacker>();
23 }
24 
GetImagePacker()25 std::shared_ptr<ImagePacker> ImagePackerImpl::GetImagePacker()
26 {
27     if (real_ == nullptr) {
28         return nullptr;
29     }
30     std::shared_ptr<ImagePacker> res = real_;
31     return res;
32 }
33 
Packing(PixelMap & source,const PackOption & option,uint64_t bufferSize)34 std::tuple<int32_t, uint8_t*, int64_t> ImagePackerImpl::Packing(PixelMap& source, const PackOption& option,
35     uint64_t bufferSize)
36 {
37     return CommonPacking<PixelMap>(source, option, bufferSize);
38 }
39 
Packing(ImageSource & source,const PackOption & option,uint64_t bufferSize)40 std::tuple<int32_t, uint8_t*, int64_t> ImagePackerImpl::Packing(ImageSource& source, const PackOption& option,
41     uint64_t bufferSize)
42 {
43     return CommonPacking<ImageSource>(source, option, bufferSize);
44 }
45 
PackToFile(PixelMap & source,int fd,const PackOption & option)46 uint32_t ImagePackerImpl::PackToFile(PixelMap& source, int fd, const PackOption& option)
47 {
48     return CommonPackToFile<PixelMap>(source, fd, option);
49 }
50 
PackToFile(ImageSource & source,int fd,const PackOption & option)51 uint32_t ImagePackerImpl::PackToFile(ImageSource& source, int fd, const PackOption& option)
52 {
53     return CommonPackToFile<ImageSource>(source, fd, option);
54 }
55 }
56 } // namespace Media
57 } // namespace OHOS
58