• 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 "deferred_video_job.h"
17 
18 namespace OHOS {
19 namespace CameraStandard {
20 namespace DeferredProcessing {
21 
22 
DeferredVideoWork(const DeferredVideoJobPtr & jobPtr,ExecutionMode mode,bool isCharging)23 DeferredVideoWork::DeferredVideoWork(const DeferredVideoJobPtr& jobPtr, ExecutionMode mode, bool isCharging)
24     : jobPtr_(jobPtr),
25       executionMode_(mode),
26       startTime_(GetSteadyNow()),
27       isCharging_(isCharging)
28 {
29     DP_DEBUG_LOG("entered");
30 }
31 
~DeferredVideoWork()32 DeferredVideoWork::~DeferredVideoWork()
33 {
34     DP_DEBUG_LOG("entered");
35 }
36 
DeferredVideoJob(const std::string & videoId,const sptr<IPCFileDescriptor> & srcFd,const sptr<IPCFileDescriptor> & dstFd)37 DeferredVideoJob::DeferredVideoJob(const std::string& videoId, const sptr<IPCFileDescriptor>& srcFd,
38     const sptr<IPCFileDescriptor>& dstFd)
39     : videoId_(videoId),
40       srcFd_(srcFd),
41       dstFd_(dstFd),
42       createTime_(GetSteadyNow())
43 {
44     DP_DEBUG_LOG("videoId: %{public}s, srcFd: %{public}d, dstFd: %{public}d",
45         videoId_.c_str(), srcFd_->GetFd(), dstFd_->GetFd());
46 }
47 
~DeferredVideoJob()48 DeferredVideoJob::~DeferredVideoJob()
49 {
50     DP_DEBUG_LOG("entered");
51     if (srcFd_) {
52         fdsan_close_with_tag(srcFd_->GetFd(), LOG_DOMAIN);
53     }
54     if (dstFd_) {
55         fdsan_close_with_tag(dstFd_->GetFd(), LOG_DOMAIN);
56     }
57 }
58 
SetJobState(VideoJobState status)59 bool DeferredVideoJob::SetJobState(VideoJobState status)
60 {
61     DP_DEBUG_LOG("videoId: %{public}s, current status: %{public}d, previous status: %{public}d, "
62         "status to set: %{public}d", videoId_.c_str(), curStatus_, preStatus_, status);
63     DP_CHECK_RETURN_RET(curStatus_ == status, false);
64 
65     preStatus_ = curStatus_;
66     curStatus_ = status;
67     return true;
68 }
69 } // namespace DeferredProcessing
70 } // namespace CameraStandard
71 } // namespace OHOS