1 /* 2 * Copyright (C) 2021 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 RECORDER_PIPELINE_CTRLER_H 17 #define RECORDER_PIPELINE_CTRLER_H 18 19 #include <memory> 20 #include "nocopyable.h" 21 #include "i_recorder_engine.h" 22 #include "recorder_pipeline.h" 23 #include "task_queue.h" 24 25 namespace OHOS { 26 namespace Media { 27 class RecorderPipelineCtrler : public NoCopyable { 28 public: 29 RecorderPipelineCtrler(); 30 ~RecorderPipelineCtrler(); 31 32 void SetObs(const std::weak_ptr<IRecorderEngineObs> &obs); 33 void SetPipeline(std::shared_ptr<RecorderPipeline> pipeline); 34 35 int32_t Init(); 36 int32_t Prepare(); 37 int32_t Start(); 38 int32_t Pause(); 39 int32_t Resume(); 40 int32_t Stop(bool isDrainAll); 41 int32_t Reset(); 42 43 private: 44 void Notify(const RecorderMessage &msg); 45 int32_t ExecuteInCmdQ(const std::shared_ptr<TaskHandler<int32_t>> &task, const bool &cancelNotExecuted); 46 47 std::weak_ptr<IRecorderEngineObs> obs_; 48 std::shared_ptr<RecorderPipeline> pipeline_; 49 50 std::unique_ptr<TaskQueue> cmdQ_; 51 std::unique_ptr<TaskQueue> msgQ_; 52 }; 53 } // namespace Media 54 } // namespace OHOS 55 #endif 56