• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2023 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 "deferred_processing_service.h"
17 
18 #include "events_info.h"
19 #include "events_monitor.h"
20 #include "dp_log.h"
21 #include "dps.h"
22 #include "picture_interface.h"
23 namespace OHOS {
24 namespace CameraStandard {
25 namespace DeferredProcessing {
DeferredProcessingService()26 DeferredProcessingService::DeferredProcessingService()
27 {
28     DP_DEBUG_LOG("entered.");
29 }
30 
~DeferredProcessingService()31 DeferredProcessingService::~DeferredProcessingService()
32 {
33     DP_DEBUG_LOG("entered.");
34     DP_CHECK_RETURN(!initialized_.load());
35 
36     DPS_Destroy();
37 }
38 
Initialize()39 void DeferredProcessingService::Initialize()
40 {
41     DP_DEBUG_LOG("entered.");
42     DP_CHECK_RETURN(initialized_.load());
43 
44     DPS_Initialize();
45     EventsMonitor::GetInstance().Initialize();
46     EventsInfo::GetInstance().Initialize();
47     initialized_.store(true);
48 }
49 
Start()50 void DeferredProcessingService::Start()
51 {
52     DP_DEBUG_LOG("entered.");
53 }
54 
Stop()55 void DeferredProcessingService::Stop()
56 {
57     DP_DEBUG_LOG("entered.");
58 }
59 
NotifyLowQualityImage(const int32_t userId,const std::string & imageId,std::shared_ptr<PictureIntf> picture)60 void DeferredProcessingService::NotifyLowQualityImage(const int32_t userId, const std::string& imageId,
61     std::shared_ptr<PictureIntf> picture)
62 {
63     DP_INFO_LOG("entered.");
64     auto sessionManager = DPS_GetSessionManager();
65     if (sessionManager != nullptr && sessionManager->GetCallback(userId) != nullptr) {
66         sessionManager->GetCallback(userId)->OnDeliveryLowQualityImage(imageId, picture);
67     } else {
68         DP_INFO_LOG("DeferredPhotoProcessingSessionCallback::NotifyLowQualityImage not set!, Discarding callback");
69     }
70 }
71 
CreateDeferredPhotoProcessingSession(const int32_t userId,const sptr<IDeferredPhotoProcessingSessionCallback> & callbacks)72 sptr<IDeferredPhotoProcessingSession> DeferredProcessingService::CreateDeferredPhotoProcessingSession(
73     const int32_t userId, const sptr<IDeferredPhotoProcessingSessionCallback>& callbacks)
74 {
75     DP_INFO_LOG("create photo session, userId: %{public}d", userId);
76     auto sessionManager = DPS_GetSessionManager();
77     DP_CHECK_ERROR_RETURN_RET_LOG(sessionManager == nullptr, nullptr,
78         "SessionManager is null, userId: %{public}d", userId);
79     return sessionManager->CreateDeferredPhotoProcessingSession(userId, callbacks);
80 }
81 
CreateDeferredVideoProcessingSession(const int32_t userId,const sptr<IDeferredVideoProcessingSessionCallback> & callbacks)82 sptr<IDeferredVideoProcessingSession> DeferredProcessingService::CreateDeferredVideoProcessingSession(
83     const int32_t userId, const sptr<IDeferredVideoProcessingSessionCallback>& callbacks)
84 {
85     DP_INFO_LOG("create video session, userId: %{public}d", userId);
86     auto sessionManager = DPS_GetSessionManager();
87     DP_CHECK_ERROR_RETURN_RET_LOG(sessionManager == nullptr, nullptr,
88         "SessionManager is null, userId: %{public}d", userId);
89     return sessionManager->CreateDeferredVideoProcessingSession(userId, callbacks);
90 }
91 
NotifyCameraSessionStatus(const int32_t userId,const std::string & cameraId,bool running,bool isSystemCamera)92 void DeferredProcessingService::NotifyCameraSessionStatus(const int32_t userId, const std::string& cameraId,
93     bool running, bool isSystemCamera)
94 {
95     DP_INFO_LOG("entered, userId: %{public}d, cameraId: %s, running: %{public}d, isSystemCamera: %{public}d: ",
96         userId, cameraId.c_str(), running, isSystemCamera);
97     EventsMonitor::GetInstance().NotifyCameraSessionStatus(userId, cameraId, running, isSystemCamera);
98 }
99 } // namespace DeferredProcessing
100 } // namespace CameraStandard
101 } // namespace OHOS