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_DEFERRED_VIDEO_PROCESSOR_H 17 #define OHOS_CAMERA_DPS_DEFERRED_VIDEO_PROCESSOR_H 18 19 #include "ivideo_process_callbacks.h" 20 #include "video_post_processor.h" 21 #include "video_job_repository.h" 22 23 namespace OHOS { 24 namespace CameraStandard { 25 namespace DeferredProcessing { 26 class DeferredVideoProcessor : public IVideoProcessCallbacks { 27 public: 28 DeferredVideoProcessor(const int32_t userId, std::shared_ptr<VideoJobRepository> repository, 29 std::shared_ptr<IVideoProcessCallbacks> callbacks); 30 ~DeferredVideoProcessor(); 31 void Initialize(); 32 33 void AddVideo(const std::string& videoId, const sptr<IPCFileDescriptor>& srcFd, 34 const sptr<IPCFileDescriptor>& dstFd); 35 void RemoveVideo(const std::string& videoId, bool restorable); 36 void RestoreVideo(const std::string& videoId); 37 38 void OnProcessDone(const int32_t userId, const std::string& videoId, const sptr<IPCFileDescriptor>& ipcFd) override; 39 void OnError(const int32_t userId, const std::string& videoId, DpsError errorCode) override; 40 void OnStateChanged(const int32_t userId, DpsStatus statusCode) override; 41 42 void PostProcess(const DeferredVideoWorkPtr& work); 43 void PauseRequest(const ScheduleType& type); 44 void SetDefaultExecutionMode(); 45 bool GetPendingVideos(std::vector<std::string>& pendingVideos); 46 47 private: 48 bool IsFatalError(DpsError errorCode); 49 50 const int32_t userId_; 51 std::shared_ptr<VideoJobRepository> repository_; 52 std::shared_ptr<IVideoProcessCallbacks> callbacks_; 53 std::shared_ptr<VideoPostProcessor> postProcessor_; 54 }; 55 } // namespace DeferredProcessing 56 } // namespace CameraStandard 57 } // namespace OHOS 58 #endif // OHOS_CAMERA_DPS_DEFERRED_VIDEO_PROCESSOR_H