• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 HPAE_SOURCE_OUTPUT_NODE_H
17 #define HPAE_SOURCE_OUTPUT_NODE_H
18 #include <memory>
19 #include "hpae_node.h"
20 #include "hpae_pcm_buffer.h"
21 #include "audio_info.h"
22 #include "i_capturer_stream.h"
23 
24 namespace OHOS {
25 namespace AudioStandard {
26 namespace HPAE {
27 
28 class HpaeSourceOutputNode : public InputNode<HpaePcmBuffer *> {
29 public:
30     HpaeSourceOutputNode(HpaeNodeInfo &nodeInfo);
31     virtual ~HpaeSourceOutputNode();
32     virtual void DoProcess() final;
33     virtual bool Reset() final;
34     bool ResetAll() final;
35     void Connect(const std::shared_ptr<OutputNode<HpaePcmBuffer *>> &preNode) override;
36     void ConnectWithInfo(const std::shared_ptr<OutputNode<HpaePcmBuffer *>> &preNode, HpaeNodeInfo &nodeInfo) override;
37     void DisConnect(const std::shared_ptr<OutputNode<HpaePcmBuffer *>> &preNode) override;
38     void DisConnectWithInfo(
39         const std::shared_ptr<OutputNode<HpaePcmBuffer *>> &preNode, HpaeNodeInfo &nodeInfo) override;
40     bool RegisterReadCallback(const std::weak_ptr<ICapturerStreamCallback> &callback);
41     int32_t SetState(HpaeSessionState captureState);
42     HpaeSessionState GetState();
43     void SetAppUid(int32_t appUid);
44     int32_t GetAppUid();
45     void SetMute(bool isMute);
46 private:
47     uint64_t GetTimestamp();
48 private:
49     InputPort<HpaePcmBuffer *> inputStream_;
50     std::weak_ptr<ICapturerStreamCallback> readCallback_;
51     AudioCallBackCapturerStreamInfo streamInfo_;
52     std::vector<char> sourceOutputData_;
53     std::vector<float> interleveData_;
54     std::atomic<uint64_t> framesRead_;
55     HpaeSessionState state_ = HPAE_SESSION_NEW;
56     uint64_t totalFrames_;
57     int32_t appUid_ = -1;
58     bool isMute_;
59 };
60 
61 }  // namespace HPAE
62 }  // namespace AudioStandard
63 }  // namespace OHOS
64 
65 #endif