blob: bc21d1485860709792ffaaf1c07c9a986b05c79e [file] [log] [blame]
Olga Sharonova09ceed22020-09-30 18:27:39 +02001/*
2 * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef API_AUDIO_AUDIO_FRAME_PROCESSOR_H_
12#define API_AUDIO_AUDIO_FRAME_PROCESSOR_H_
13
14#include <functional>
15#include <memory>
16
17namespace webrtc {
18
19class AudioFrame;
20
21// If passed into PeerConnectionFactory, will be used for additional
22// processing of captured audio frames, performed before encoding.
23// Implementations must be thread-safe.
24class AudioFrameProcessor {
25 public:
26 using OnAudioFrameCallback = std::function<void(std::unique_ptr<AudioFrame>)>;
27 virtual ~AudioFrameProcessor() = default;
28
29 // Processes the frame received from WebRTC, is called by WebRTC off the
30 // realtime audio capturing path. AudioFrameProcessor must reply with
31 // processed frames by calling |sink_callback| if it was provided in SetSink()
32 // call. |sink_callback| can be called in the context of Process().
33 virtual void Process(std::unique_ptr<AudioFrame> frame) = 0;
34
35 // Atomically replaces the current sink with the new one. Before the
36 // first call to this function, or if the provided |sink_callback| is nullptr,
37 // processed frames are simply discarded.
38 virtual void SetSink(OnAudioFrameCallback sink_callback) = 0;
39};
40
41} // namespace webrtc
42
43#endif // API_AUDIO_AUDIO_FRAME_PROCESSOR_H_