• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 and
13  * limitations under the License.
14  */
15 
16 #include "service_died_command.h"
17 
18 #include "dps.h"
19 
20 namespace OHOS {
21 namespace CameraStandard {
22 namespace DeferredProcessing {
23 
ServiceDiedCommand(const int32_t userId)24 ServiceDiedCommand::ServiceDiedCommand(const int32_t userId) : userId_(userId)
25 {
26     DP_DEBUG_LOG("entered.");
27 }
28 
Initialize()29 int32_t ServiceDiedCommand::Initialize()
30 {
31     DP_CHECK_RETURN_RET(initialized_.load(), DP_OK);
32     schedulerManager_ = DPS_GetSchedulerManager();
33     DP_CHECK_ERROR_RETURN_RET_LOG(schedulerManager_ == nullptr, DP_NULL_POINTER, "SchedulerManager is nullptr.");
34 
35     initialized_.store(true);
36     return DP_OK;
37 }
38 
Executing()39 int32_t PhotoDiedCommand::Executing()
40 {
41     int32_t ret = Initialize();
42     if (ret != DP_OK) {
43         return ret;
44     }
45 
46     auto photoPost = schedulerManager_->GetPhotoPostProcessor(userId_);
47     DP_CHECK_ERROR_RETURN_RET_LOG(photoPost == nullptr, DP_NULL_POINTER, "PhotoPostProcessor is nullptr.");
48     photoPost->OnSessionDied();
49     return DP_OK;
50 }
51 
Executing()52 int32_t VideoDiedCommand::Executing()
53 {
54     int32_t ret = Initialize();
55     if (ret != DP_OK) {
56         return ret;
57     }
58 
59     auto videoPost = schedulerManager_->GetVideoPostProcessor(userId_);
60     DP_CHECK_ERROR_RETURN_RET_LOG(videoPost == nullptr, DP_NULL_POINTER, "VideoPostProcessor is nullptr.");
61     videoPost->OnSessionDied();
62 
63     auto controller = schedulerManager_->GetVideoController(userId_);
64     DP_CHECK_ERROR_RETURN_RET_LOG(controller == nullptr, DP_NULL_POINTER, "VideoController is nullptr.");
65 
66     controller->HandleServiceDied();
67     return DP_OK;
68 }
69 } // namespace DeferredProcessing
70 } // namespace CameraStandard
71 } // namespace OHOS