• 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 "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     int32_t ret = Initialize();
44     if (ret != DP_OK) {
45         return ret;
46     }
47 
48     videoPostProcess_->OnProcessDone(videoId_, std::move(userInfo_));
49     return DP_OK;
50 }
51 
Executing()52 int32_t VideoProcessFailedCommand::Executing()
53 {
54     int32_t ret = Initialize();
55     if (ret != DP_OK) {
56         return ret;
57     }
58 
59     videoPostProcess_->OnError(videoId_, error_);
60     return DP_OK;
61 }
62 
Executing()63 int32_t VideoStateChangedCommand::Executing()
64 {
65     return DP_OK;
66 }
67 } // namespace DeferredProcessing
68 } // namespace CameraStandard
69 } // namespace OHOS