Ring Daemon 16.0.0
Loading...
Searching...
No Matches
audio_frame_resizer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 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
23#include <mutex>
24
25extern "C" {
26struct AVAudioFifo;
27}
28
29namespace jami {
30
39{
40public:
42 int frameSize,
43 std::function<void(std::shared_ptr<AudioFrame>&&)> cb = {});
45
49 int samples() const;
50
55 AudioFormat format() const;
56
57 void setFormat(const AudioFormat& format, int frameSize);
58 void setFrameSize(int frameSize);
59
63 int frameSize() const;
64
73 void enqueue(std::shared_ptr<AudioFrame>&& frame);
74
78 std::shared_ptr<AudioFrame> dequeue();
79
80private:
82
86 AudioFormat format_;
87
91 int frameSize_;
92
96 std::function<void(std::shared_ptr<AudioFrame>&&)> cb_;
97
101 AVAudioFifo* queue_;
102 int64_t nextOutputPts_ {0};
103 bool hasVoice_ {false};
104};
105
106} // 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 ring_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.