blob: cb65c4817e54eeccc310899dae2ab6e11c391bbd [file] [log] [blame]
Olga Sharonova09ceed22020-09-30 16:27:391/*
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
Artem Titov0e61fdd2021-07-25 19:50:1431 // processed frames by calling `sink_callback` if it was provided in SetSink()
32 // call. `sink_callback` can be called in the context of Process().
Olga Sharonova09ceed22020-09-30 16:27:3933 virtual void Process(std::unique_ptr<AudioFrame> frame) = 0;
34
35 // Atomically replaces the current sink with the new one. Before the
Artem Titov0e61fdd2021-07-25 19:50:1436 // first call to this function, or if the provided `sink_callback` is nullptr,
Olga Sharonova09ceed22020-09-30 16:27:3937 // 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_