Ring Daemon 16.0.0
Loading...
Searching...
No Matches
audio_sender.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 "media_buffer.h"
20#include "media_codec.h"
21#include "noncopyable.h"
22#include "observer.h"
23#include "socket_pair.h"
24
25namespace jami {
26
27class AudioInput;
28class MediaEncoder;
29class MediaIOHandle;
30class Resampler;
31
32class AudioSender : public Observer<std::shared_ptr<MediaFrame>>
33{
34public:
35 AudioSender(const std::string& dest,
38 const uint16_t seqVal,
39 const uint16_t mtu);
41
44
45 void setVoiceCallback(std::function<void(bool)> cb);
46
47 void update(Observable<std::shared_ptr<jami::MediaFrame>>*,
48 const std::shared_ptr<jami::MediaFrame>&) override;
49
50private:
52
53 bool setup(SocketPair& socketPair);
54
55 std::string dest_;
56 MediaDescription args_;
57 std::unique_ptr<MediaEncoder> audioEncoder_;
58 std::unique_ptr<MediaIOHandle> muxContext_;
59
60 uint64_t sent_samples = 0;
61
62 const uint16_t seqVal_;
63 uint16_t mtu_;
64
65 // last voice activity state
66 bool voice_ {false};
67 std::function<void(bool)> voiceCallback_;
68};
69
70} // namespace jami
void setVoiceCallback(std::function< void(bool)> cb)
int setPacketLoss(uint64_t pl)
uint16_t getLastSeqValue()
void update(Observable< std::shared_ptr< jami::MediaFrame > > *, const std::shared_ptr< jami::MediaFrame > &) override
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
MediaDescription Negotiated RTP media slot.