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 if (int32_t ret = Initialize() != DP_OK) {
42 return ret;
43 }
44
45 auto photoPost = schedulerManager_->GetPhotoPostProcessor(userId_);
46 DP_CHECK_ERROR_RETURN_RET_LOG(photoPost == nullptr, DP_NULL_POINTER, "PhotoPostProcessor is nullptr.");
47 photoPost->OnSessionDied();
48 return DP_OK;
49 }
50
Executing()51 int32_t VideoDiedCommand::Executing()
52 {
53 if (int32_t ret = Initialize() != DP_OK) {
54 return ret;
55 }
56
57 auto videoPost = schedulerManager_->GetVideoPostProcessor(userId_);
58 DP_CHECK_ERROR_RETURN_RET_LOG(videoPost == nullptr, DP_NULL_POINTER, "VideoPostProcessor is nullptr.");
59 videoPost->OnSessionDied();
60
61 auto controller = schedulerManager_->GetVideoController(userId_);
62 DP_CHECK_ERROR_RETURN_RET_LOG(controller == nullptr, DP_NULL_POINTER, "VideoController is nullptr.");
63
64 controller->HandleServiceDied();
65 return DP_OK;
66 }
67 } // namespace DeferredProcessing
68 } // namespace CameraStandard
69 } // namespace OHOS