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 "video_process_command.h"
17
18 #include "dps.h"
19
20 namespace OHOS {
21 namespace CameraStandard {
22 namespace DeferredProcessing {
VideoProcessCommand(const int32_t userId)23 VideoProcessCommand::VideoProcessCommand(const int32_t userId) : userId_(userId)
24 {
25 DP_DEBUG_LOG("entered. userId: %{public}d", userId_);
26 }
27
Initialize()28 int32_t VideoProcessCommand::Initialize()
29 {
30 DP_CHECK_RETURN_RET(initialized_.load(), DP_OK);
31 auto schedulerManager = DPS_GetSchedulerManager();
32 DP_CHECK_ERROR_RETURN_RET_LOG(schedulerManager == nullptr, DP_NULL_POINTER, "SchedulerManager is nullptr.");
33
34 videoPostProcess_ = schedulerManager->GetVideoPostProcessor(userId_);
35 DP_CHECK_ERROR_RETURN_RET_LOG(videoPostProcess_ == nullptr, DP_NULL_POINTER, "VideoPostProcessor is nullptr.");
36
37 initialized_.store(true);
38 return DP_OK;
39 }
40
Executing()41 int32_t VideoProcessSuccessCommand::Executing()
42 {
43 if (int32_t ret = Initialize() != DP_OK) {
44 return ret;
45 }
46
47 videoPostProcess_->OnProcessDone(videoId_, std::move(userInfo_));
48 return DP_OK;
49 }
50
Executing()51 int32_t VideoProcessFailedCommand::Executing()
52 {
53 if (int32_t ret = Initialize() != DP_OK) {
54 return ret;
55 }
56
57 videoPostProcess_->OnError(videoId_, error_);
58 return DP_OK;
59 }
60
Executing()61 int32_t VideoStateChangedCommand::Executing()
62 {
63 return DP_OK;
64 }
65 } // namespace DeferredProcessing
66 } // namespace CameraStandard
67 } // namespace OHOS