1 | /* |
2 | Copyright 2018 Google Inc. All Rights Reserved. |
3 | |
4 | Licensed under the Apache License, Version 2.0 (the "License"); |
5 | you may not use this file except in compliance with the License. |
6 | You may obtain a copy of the License at |
7 | |
8 | http://www.apache.org/licenses/LICENSE-2.0 |
9 | |
10 | Unless required by applicable law or agreed to in writing, software |
11 | distributed under the License is distributed on an "AS-IS" BASIS, |
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | See the License for the specific language governing permissions and |
14 | limitations under the License. |
15 | */ |
16 | |
17 | #ifndef RESONANCE_AUDIO_NODE_SINK_NODE_H_ |
18 | #define RESONANCE_AUDIO_NODE_SINK_NODE_H_ |
19 | |
20 | #include <memory> |
21 | #include <vector> |
22 | |
23 | #include "base/audio_buffer.h" |
24 | #include "node/publisher_node.h" |
25 | #include "node/subscriber_node.h" |
26 | |
27 | namespace vraudio { |
28 | |
29 | // Audio sink node that reads from multiple inputs. |
30 | class SinkNode : public Node, public SubscriberNode<const AudioBuffer*> { |
31 | public: |
32 | typedef PublisherNode<const AudioBuffer*> PublisherNodeType; |
33 | |
34 | SinkNode(); |
35 | |
36 | // Polls for data on all inputs of the sink node. |
37 | // |
38 | // @return A vector of input data. |
39 | const std::vector<const AudioBuffer*>& ReadInputs(); |
40 | |
41 | // SubscriberNode<AudioBuffer> implementation. |
42 | void Connect( |
43 | const std::shared_ptr<PublisherNodeType>& publisher_node) override; |
44 | |
45 | // Node implementation. |
46 | void Process() final; |
47 | bool CleanUp() final; |
48 | |
49 | // Disable copy constructor. |
50 | SinkNode(const SinkNode& that) = delete; |
51 | |
52 | private: |
53 | // Input stream to poll for incoming data. |
54 | Node::Input<const AudioBuffer*> input_stream_; |
55 | }; |
56 | |
57 | } // namespace vraudio |
58 | |
59 | #endif // RESONANCE_AUDIO_NODE_SINK_NODE_H_ |
60 | |