Ring Daemon
Loading...
Searching...
No Matches
audio_frame_resizer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include "audio_format.h"
20#include "media/media_buffer.h"
21#include "noncopyable.h"
22
23extern "C" {
24struct AVAudioFifo;
25}
26
27namespace jami {
28
37{
38public:
40 int frameSize,
41 std::function<void(std::shared_ptr<AudioFrame>&&)> cb = {});
43
47 int samples() const;
48
53 AudioFormat format() const;
54
55 void setFormat(const AudioFormat& format, int frameSize);
56 void setFrameSize(int frameSize);
57
61 int frameSize() const;
62
71 void enqueue(std::shared_ptr<AudioFrame>&& frame);
72
76 std::shared_ptr<AudioFrame> dequeue();
77
78private:
80
84 AudioFormat format_;
85
89 int frameSize_;
90
94 std::function<void(std::shared_ptr<AudioFrame>&&)> cb_;
95
99 AVAudioFifo* queue_;
100 int64_t nextOutputPts_ {0};
101 bool hasVoice_ {false};
102};
103
104} // namespace jami
Buffers extra samples.
void setFrameSize(int frameSize)
void setFormat(const AudioFormat &format, int frameSize)
int frameSize() const
Gets the number of samples per output frame.
int samples() const
Gets the numbers of samples available for reading.
void enqueue(std::shared_ptr< AudioFrame > &&frame)
Write @frame's data to the queue.
std::shared_ptr< AudioFrame > dequeue()
Notifies owner of a new frame.
AudioFormat format() const
Gets the format used by @queue_, input frames must match this format or enqueuing will fail.
void emitSignal(Args... args)
Definition jami_signal.h:64
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30
Structure to hold sample rate and channel number associated with audio data.