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 #ifndef OHOS_CAMERA_DPS_VIDEO_COMMAND_H
17 #define OHOS_CAMERA_DPS_VIDEO_COMMAND_H
18 
19 #include "command.h"
20 #include "ipc_file_descriptor.h"
21 #include "scheduler_manager.h"
22 
23 namespace OHOS {
24 namespace CameraStandard {
25 namespace DeferredProcessing {
26 class VideoCommand : public Command {
27 public:
28     VideoCommand(const int32_t userId, const std::string& videoId);
29     ~VideoCommand();
30 
31 protected:
32     int32_t Initialize();
33 
34     const int32_t userId_;
35     const std::string videoId_;
36     std::atomic<bool> initialized_ {false};
37     std::shared_ptr<SchedulerManager> schedulerManager_ {nullptr};
38     std::shared_ptr<DeferredVideoProcessor> processor_ {nullptr};
39 };
40 
41 class AddVideoCommand : public VideoCommand {
42     DECLARE_CMD_CLASS(AddVideoCommand)
43 public:
44     AddVideoCommand(const int32_t userId, const std::string& videoId,
45         const sptr<IPCFileDescriptor>& srcFd, const sptr<IPCFileDescriptor>& dstFd);
46 
47 protected:
48     int32_t Executing() override;
49 
50     sptr<IPCFileDescriptor> srcFd_;
51     sptr<IPCFileDescriptor> dstFd_;
52 };
53 
54 class RemoveVideoCommand : public VideoCommand {
55     DECLARE_CMD_CLASS(RemoveVideoCommand)
56 public:
57     RemoveVideoCommand(const int32_t userId, const std::string& videoId, const bool restorable);
58 
59 protected:
60     int32_t Executing() override;
61 
62     const bool restorable_;
63 };
64 
65 class RestoreCommand : public VideoCommand {
66     DECLARE_CMD_CLASS(RestoreCommand)
67 public:
68     using VideoCommand::VideoCommand;
69 
70 protected:
71     int32_t Executing() override;
72 };
73 
74 } // namespace DeferredProcessing
75 } // namespace CameraStandard
76 } // namespace OHOS
77 #endif // OHOS_CAMERA_DPS_VIDEO_COMMAND_H