1 /*
2  * Copyright (C) 2021 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 #ifndef FRAMEWORKS_KITS_JS_COMMON_INCLUDE_IMAGE_SOURCE_NATIVE_IMPL_H
16 #define FRAMEWORKS_KITS_JS_COMMON_INCLUDE_IMAGE_SOURCE_NATIVE_IMPL_H
17 #include <stdint.h>
18 #include "image_source.h"
19 #include "image_source_native.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 struct OH_ImageSourceNative {
26 public:
27     OH_ImageSourceNative(std::shared_ptr<OHOS::Media::ImageSource> imageSource);
28     OH_ImageSourceNative(char *uri, size_t size, OHOS::Media::SourceOptions ops);
29     OH_ImageSourceNative(int32_t fd, OHOS::Media::SourceOptions ops);
30     OH_ImageSourceNative(uint8_t *data, size_t dataSize, OHOS::Media::SourceOptions ops);
31     OH_ImageSourceNative(RawFileDescriptor rawFile, OHOS::Media::SourceOptions ops);
32     ~OH_ImageSourceNative();
33     std::shared_ptr<OHOS::Media::ImageSource> GetInnerImageSource();
34     std::string filePath_ = "";
35     int fileDescriptor_ = -1;
36     void *fileBuffer_ = nullptr;
37     size_t fileBufferSize_ = 0;
38 private:
39     std::string UrlToPath(const std::string &path);
40     std::shared_ptr<OHOS::Media::ImageSource> innerImageSource_;
41 };
42 
43 struct OH_DecodingOptionsForPicture {
44 public:
45     OH_DecodingOptionsForPicture(std::shared_ptr<OHOS::Media::DecodingOptionsForPicture> decodingOptionsForPicture);
46     ~OH_DecodingOptionsForPicture();
47     std::shared_ptr<OHOS::Media::DecodingOptionsForPicture> GetInnerDecodingOptForPicture();
48 
49 private:
50     std::shared_ptr<OHOS::Media::DecodingOptionsForPicture> decodingOptionsForPicture_;
51 };
52 
53 #ifdef __cplusplus
54 };
55 #endif
56 /** @} */
57 #endif // FRAMEWORKS_KITS_JS_COMMON_INCLUDE_IMAGE_SOURCE_NATIVE_IMPL_H