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 
16 #include "media_asset_data_handler_capi.h"
17 
18 #include "cstring"
19 #include "medialibrary_client_errno.h"
20 
21 namespace OHOS {
22 namespace Media {
23 static const std::string MEDIA_ASSET_DATA_HANDLER_CLASS = "MediaAssetDataHandler";
24 
CapiMediaAssetDataHandler(NativeOnDataPrepared dataHandler,ReturnDataType dataType,const std::string & uri,const std::string & destUri,NativeSourceMode sourceMode)25 CapiMediaAssetDataHandler::CapiMediaAssetDataHandler(NativeOnDataPrepared dataHandler, ReturnDataType dataType,
26     const std::string &uri, const std::string &destUri, NativeSourceMode sourceMode)
27 {
28     onDataPreparedHandler_ = dataHandler;
29     dataType_ = dataType;
30     requestUri_ = uri;
31     destUri_ = destUri;
32     sourceMode_ = sourceMode;
33 }
34 
CapiMediaAssetDataHandler(OH_MediaLibrary_OnImageDataPrepared imageDataHandler,ReturnDataType dataType,const std::string & uri,const std::string & destUri,NativeSourceMode sourceMode)35 CapiMediaAssetDataHandler::CapiMediaAssetDataHandler(OH_MediaLibrary_OnImageDataPrepared imageDataHandler,
36     ReturnDataType dataType, const std::string &uri, const std::string &destUri, NativeSourceMode sourceMode)
37 {
38     onRequestImageDataPreparedHandler_ = imageDataHandler;
39     dataType_ = dataType;
40     requestUri_ = uri;
41     destUri_ = destUri;
42     sourceMode_ = sourceMode;
43 }
44 
CapiMediaAssetDataHandler(OH_MediaLibrary_OnMovingPhotoDataPrepared photoDataHandler,ReturnDataType dataType,const std::string & uri,const std::string & destUri,NativeSourceMode sourceMode)45 CapiMediaAssetDataHandler::CapiMediaAssetDataHandler(OH_MediaLibrary_OnMovingPhotoDataPrepared photoDataHandler,
46     ReturnDataType dataType, const std::string &uri, const std::string &destUri, NativeSourceMode sourceMode)
47 {
48     onRequestMovingPhotoDataPreparedHandler_ = photoDataHandler;
49     dataType_ = dataType;
50     requestUri_ = uri;
51     destUri_ = destUri;
52     sourceMode_ = sourceMode;
53 }
54 
GetPhotoQuality()55 int32_t CapiMediaAssetDataHandler::GetPhotoQuality()
56 {
57     return photoQuality_;
58 }
59 
SetPhotoQuality(int32_t photoQuality)60 void CapiMediaAssetDataHandler::SetPhotoQuality(int32_t photoQuality)
61 {
62     photoQuality_ = photoQuality;
63 }
64 
GetReturnDataType()65 ReturnDataType CapiMediaAssetDataHandler::GetReturnDataType()
66 {
67     return dataType_;
68 }
69 
GetRequestUri()70 std::string CapiMediaAssetDataHandler::GetRequestUri()
71 {
72     return requestUri_;
73 }
74 
GetDestUri()75 std::string CapiMediaAssetDataHandler::GetDestUri()
76 {
77     return destUri_;
78 }
79 
GetSourceMode()80 NativeSourceMode CapiMediaAssetDataHandler::GetSourceMode()
81 {
82     return sourceMode_;
83 }
84 
SetNotifyMode(NativeNotifyMode notifyMode)85 void CapiMediaAssetDataHandler::SetNotifyMode(NativeNotifyMode notifyMode)
86 {
87     notifyMode_ = notifyMode;
88 }
89 
GetNotifyMode()90 NativeNotifyMode CapiMediaAssetDataHandler::GetNotifyMode()
91 {
92     return notifyMode_;
93 }
94 } // namespace Media
95 } // namespace OHOS
96