1 /*
2 * Copyright (c) 2024-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 andPhotoProcessResult
13 * limitations under the License.
14 */
15
16 #include "photo_process_result.h"
17
18 #include "dp_log.h"
19 #include "dps.h"
20 #include "events_monitor.h"
21 #include "photo_process_command.h"
22 #include "service_died_command.h"
23
24 namespace OHOS {
25 namespace CameraStandard {
26 namespace DeferredProcessing {
PhotoProcessResult(const int32_t userId)27 PhotoProcessResult::PhotoProcessResult(const int32_t userId) : userId_(userId)
28 {
29 DP_DEBUG_LOG("entered.");
30 }
31
~PhotoProcessResult()32 PhotoProcessResult::~PhotoProcessResult()
33 {
34 DP_DEBUG_LOG("entered.");
35 }
36
OnProcessDone(const std::string & imageId,const std::shared_ptr<BufferInfo> & bufferInfo)37 void PhotoProcessResult::OnProcessDone(const std::string& imageId, const std::shared_ptr<BufferInfo>& bufferInfo)
38 {
39 DP_DEBUG_LOG("DPS_PHOTO: OnProcessDone imageId: %{public}s", imageId.c_str());
40 auto ret = DPS_SendCommand<PhotoProcessSuccessCommand>(userId_, imageId, bufferInfo);
41 DP_CHECK_ERROR_RETURN_LOG(ret != DP_OK,
42 "process success imageId: %{public}s failed. ret: %{public}d", imageId.c_str(), ret);
43 }
44
OnProcessDoneExt(const std::string & imageId,const std::shared_ptr<BufferInfoExt> & bufferInfo)45 void PhotoProcessResult::OnProcessDoneExt(const std::string& imageId, const std::shared_ptr<BufferInfoExt>& bufferInfo)
46 {
47 DP_DEBUG_LOG("DPS_PHOTO: OnProcessDoneExt imageId: %{public}s", imageId.c_str());
48 auto ret = DPS_SendCommand<PhotoProcessSuccessExtCommand>(userId_, imageId, bufferInfo);
49 DP_CHECK_ERROR_RETURN_LOG(ret != DP_OK,
50 "processExt success imageId: %{public}s failed. ret: %{public}d", imageId.c_str(), ret);
51 }
52
OnError(const std::string & imageId,DpsError errorCode)53 void PhotoProcessResult::OnError(const std::string& imageId, DpsError errorCode)
54 {
55 DP_DEBUG_LOG("DPS_PHOTO: OnError imageId: %{public}s, error: %{public}d", imageId.c_str(), errorCode);
56 auto ret = DPS_SendCommand<PhotoProcessFailedCommand>(userId_, imageId, errorCode);
57 DP_CHECK_ERROR_RETURN_LOG(ret != DP_OK,
58 "processExt success imageId: %{public}s failed. ret: %{public}d", imageId.c_str(), ret);
59 }
60
OnStateChanged(HdiStatus hdiStatus)61 void PhotoProcessResult::OnStateChanged(HdiStatus hdiStatus)
62 {
63 DP_DEBUG_LOG("DPS_PHOTO: OnStateChanged hdiStatus: %{public}d", hdiStatus);
64 EventsMonitor::GetInstance().NotifyImageEnhanceStatus(hdiStatus);
65 }
66
OnPhotoSessionDied()67 void PhotoProcessResult::OnPhotoSessionDied()
68 {
69 DP_ERR_LOG("DPS_PHOTO: OnPhotoSessionDied");
70 auto ret = DPS_SendCommand<PhotoDiedCommand>(userId_);
71 DP_CHECK_ERROR_RETURN_LOG(ret != DP_OK, "process photoSessionDied. ret: %{public}d", ret);
72 }
73 } // namespace DeferredProcessing
74 } // namespace CameraStandard
75 } // namespace OHOS