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 std::enable_shared_from_this<DeferredVideoProcessor> { 28 public: 29 ~DeferredVideoProcessor(); 30 void Initialize(); 31 32 void AddVideo(const std::string& videoId, const sptr<IPCFileDescriptor>& srcFd, 33 const sptr<IPCFileDescriptor>& dstFd); 34 void RemoveVideo(const std::string& videoId, bool restorable); 35 void RestoreVideo(const std::string& videoId); 36 37 void OnProcessDone(const int32_t userId, const std::string& videoId, const sptr<IPCFileDescriptor>& ipcFd) override; 38 void OnError(const int32_t userId, const std::string& videoId, DpsError errorCode) override; 39 void OnStateChanged(const int32_t userId, DpsStatus statusCode) override; 40 41 void PostProcess(const DeferredVideoWorkPtr& work); 42 void PauseRequest(const ScheduleType& type); 43 void SetDefaultExecutionMode(); 44 bool GetPendingVideos(std::vector<std::string>& pendingVideos); 45 46 protected: 47 DeferredVideoProcessor(const std::shared_ptr<VideoJobRepository>& repository, 48 const std::shared_ptr<VideoPostProcessor>& postProcessor, 49 const std::shared_ptr<IVideoProcessCallbacks>& callback); 50 51 private: 52 bool IsFatalError(DpsError errorCode); 53 54 std::shared_ptr<VideoJobRepository> repository_; 55 std::shared_ptr<VideoPostProcessor> postProcessor_; 56 std::shared_ptr<IVideoProcessCallbacks> callback_; 57 }; 58 } // namespace DeferredProcessing 59 } // namespace CameraStandard 60 } // namespace OHOS 61 #endif // OHOS_CAMERA_DPS_DEFERRED_VIDEO_PROCESSOR_H