• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ENGINE_GST_IMPL_H
17 #define RECORDER_ENGINE_GST_IMPL_H
18 
19 #include <map>
20 #include <vector>
21 #include <mutex>
22 
23 #include "nocopyable.h"
24 #include "i_recorder_engine.h"
25 #include "recorder_pipeline.h"
26 #include "recorder_pipeline_ctrler.h"
27 #include "recorder_pipeline_builder.h"
28 #include "recorder_inner_defines.h"
29 
30 namespace OHOS {
31 namespace Media {
32 class RecorderEngineGstImpl : public IRecorderEngine, public NoCopyable {
33 public:
34     RecorderEngineGstImpl(int32_t appUid, int32_t appPid, uint32_t appTokenId);
35     ~RecorderEngineGstImpl();
36 
37     int32_t Init();
38     int32_t SetVideoSource(VideoSourceType source, int32_t &sourceId) override;
39     int32_t SetAudioSource(AudioSourceType source, int32_t &sourceId) override;
40     int32_t SetOutputFormat(OutputFormatType format) override;
41     int32_t SetObs(const std::weak_ptr<IRecorderEngineObs> &obs) override;
42     int32_t Configure(int32_t sourceId, const RecorderParam &recParam) override;
43     int32_t Prepare() override;
44     int32_t Start() override;
45     int32_t Pause() override;
46     int32_t Resume() override;
47     int32_t Stop(bool isDrainAll) override;
48     int32_t Reset() override;
49     int32_t SetParameter(int32_t sourceId, const RecorderParam &recParam) override;
50     sptr<Surface> GetSurface(int32_t sourceId) override;
51 
52 private:
53     int32_t BuildPipeline();
54     bool CheckParamType(int32_t sourceId, const RecorderParam &recParam) const;
55 
56     std::unique_ptr<RecorderPipelineBuilder> builder_ = nullptr;
57     std::shared_ptr<RecorderPipelineCtrler> ctrler_ = nullptr;
58     std::shared_ptr<RecorderPipeline> pipeline_ = nullptr;
59     std::map<int32_t, RecorderSourceDesc> allSources_;
60     std::vector<int32_t> sourceCount_;
61     std::mutex mutex_;
62     int32_t appUid_;
63     int32_t appPid_;
64     uint32_t appTokenId_;
65 };
66 } // namespace Media
67 } // namespace OHOS
68 #endif
69