mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-04-07 09:05:18 +00:00
aplay/mixer: print participant add/rm
This commit is contained in:
@@ -65,8 +65,12 @@
|
|||||||
#include "transmit.h"
|
#include "transmit.h"
|
||||||
#include "types.h" // for tx_media_type
|
#include "types.h" // for tx_media_type
|
||||||
#include "utils/audio_buffer.h"
|
#include "utils/audio_buffer.h"
|
||||||
|
#include "utils/macros.h" // for STR_LEN
|
||||||
|
#include "utils/net.h" // for get_sockaddr_addr_str
|
||||||
#include "utils/thread.h"
|
#include "utils/thread.h"
|
||||||
|
|
||||||
|
#define MOD_NAME "[audio mixer] "
|
||||||
|
|
||||||
#define SAMPLE_RATE 48000
|
#define SAMPLE_RATE 48000
|
||||||
#define BPS 2 /// @todo 4?
|
#define BPS 2 /// @todo 4?
|
||||||
#define CHANNELS 1
|
#define CHANNELS 1
|
||||||
@@ -122,7 +126,10 @@ static void mixer_dummy_rtp_callback(struct rtp *session [[gnu::unused]], rtp_ev
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct am_participant {
|
struct am_participant {
|
||||||
am_participant(struct socket_udp_local *l, struct sockaddr_storage *ss, string const & audio_codec) {
|
am_participant(struct socket_udp_local *l, struct sockaddr_storage *ss,
|
||||||
|
string const &audio_codec)
|
||||||
|
: remote_addr(*ss)
|
||||||
|
{
|
||||||
assert(l != nullptr && ss != nullptr);
|
assert(l != nullptr && ss != nullptr);
|
||||||
m_buffer = audio_buffer_init(SAMPLE_RATE, BPS, CHANNELS, get_commandline_param("low-latency-audio") ? 50 : 5);
|
m_buffer = audio_buffer_init(SAMPLE_RATE, BPS, CHANNELS, get_commandline_param("low-latency-audio") ? 50 : 5);
|
||||||
assert(m_buffer != NULL);
|
assert(m_buffer != NULL);
|
||||||
@@ -140,6 +147,12 @@ struct am_participant {
|
|||||||
LOG(LOG_LEVEL_ERROR) << "Audio coder init failed!\n";
|
LOG(LOG_LEVEL_ERROR) << "Audio coder init failed!\n";
|
||||||
throw 1;
|
throw 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char buf[STR_LEN];
|
||||||
|
MSG(NOTICE, "added participant: %s:%u\n",
|
||||||
|
get_sockaddr_addr_str((struct sockaddr *) &ss, buf,
|
||||||
|
sizeof buf),
|
||||||
|
get_sockaddr_addr_port((struct sockaddr *) &ss));
|
||||||
}
|
}
|
||||||
~am_participant() {
|
~am_participant() {
|
||||||
if (m_tx_session) {
|
if (m_tx_session) {
|
||||||
@@ -154,6 +167,11 @@ struct am_participant {
|
|||||||
if (m_audio_coder) {
|
if (m_audio_coder) {
|
||||||
audio_codec_done(m_audio_coder);
|
audio_codec_done(m_audio_coder);
|
||||||
}
|
}
|
||||||
|
char buf[STR_LEN];
|
||||||
|
MSG(NOTICE, "removed participant: %s:%u\n",
|
||||||
|
get_sockaddr_addr_str((struct sockaddr *) &remote_addr, buf,
|
||||||
|
sizeof buf),
|
||||||
|
get_sockaddr_addr_port((struct sockaddr *) &remote_addr));
|
||||||
}
|
}
|
||||||
am_participant& operator=(am_participant&& other) {
|
am_participant& operator=(am_participant&& other) {
|
||||||
m_audio_coder = std::move(other.m_audio_coder);
|
m_audio_coder = std::move(other.m_audio_coder);
|
||||||
@@ -170,6 +188,7 @@ struct am_participant {
|
|||||||
am_participant(am_participant && other) {
|
am_participant(am_participant && other) {
|
||||||
*this = std::move(other);
|
*this = std::move(other);
|
||||||
}
|
}
|
||||||
|
struct sockaddr_storage remote_addr;
|
||||||
struct audio_codec_state *m_audio_coder;
|
struct audio_codec_state *m_audio_coder;
|
||||||
struct audio_buffer *m_buffer;
|
struct audio_buffer *m_buffer;
|
||||||
struct rtp *m_network_device;
|
struct rtp *m_network_device;
|
||||||
|
|||||||
@@ -424,7 +424,12 @@ unsigned get_sockaddr_addr_port(struct sockaddr *sa){
|
|||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_sockaddr_addr_str(struct sockaddr *sa, char *buf, size_t n){
|
/**
|
||||||
|
* @returns the input buffer (buf)
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
get_sockaddr_addr_str(struct sockaddr *sa, char *buf, size_t n)
|
||||||
|
{
|
||||||
assert(n >= IN6_MAX_ASCII_LEN + 3 /* []: */ + 1 /* \0 */);
|
assert(n >= IN6_MAX_ASCII_LEN + 3 /* []: */ + 1 /* \0 */);
|
||||||
const void *src = NULL;
|
const void *src = NULL;
|
||||||
if (sa->sa_family == AF_INET6) {
|
if (sa->sa_family == AF_INET6) {
|
||||||
@@ -434,17 +439,18 @@ void get_sockaddr_addr_str(struct sockaddr *sa, char *buf, size_t n){
|
|||||||
src = &((struct sockaddr_in *)(void *) sa)->sin_addr;
|
src = &((struct sockaddr_in *)(void *) sa)->sin_addr;
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, n, "(unknown)");
|
snprintf(buf, n, "(unknown)");
|
||||||
return;
|
return buf;
|
||||||
}
|
}
|
||||||
if (inet_ntop(sa->sa_family, src, buf + strlen(buf), n - strlen(buf)) == NULL) {
|
if (inet_ntop(sa->sa_family, src, buf + strlen(buf), n - strlen(buf)) == NULL) {
|
||||||
perror("get_sockaddr_str");
|
perror("get_sockaddr_str");
|
||||||
snprintf(buf, n, "(error)");
|
snprintf(buf, n, "(error)");
|
||||||
return;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sa->sa_family == AF_INET6) {
|
if (sa->sa_family == AF_INET6) {
|
||||||
snprintf(buf + strlen(buf), n - strlen(buf), "]");
|
snprintf(buf + strlen(buf), n - strlen(buf), "]");
|
||||||
}
|
}
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *get_sockaddr_str(struct sockaddr *sa)
|
const char *get_sockaddr_str(struct sockaddr *sa)
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ bool is_host_private(const char *hostname);
|
|||||||
uint16_t socket_get_recv_port(int fd);
|
uint16_t socket_get_recv_port(int fd);
|
||||||
bool get_local_addresses(struct sockaddr_storage *addrs, size_t *len, int ip_version);
|
bool get_local_addresses(struct sockaddr_storage *addrs, size_t *len, int ip_version);
|
||||||
bool is_ipv6_supported(void);
|
bool is_ipv6_supported(void);
|
||||||
void get_sockaddr_addr_str(struct sockaddr *sa, char *buf, size_t n);
|
char *get_sockaddr_addr_str(struct sockaddr *sa, char *buf, size_t n);
|
||||||
unsigned get_sockaddr_addr_port(struct sockaddr *sa);
|
unsigned get_sockaddr_addr_port(struct sockaddr *sa);
|
||||||
const char *get_sockaddr_str(struct sockaddr *sa);
|
const char *get_sockaddr_str(struct sockaddr *sa);
|
||||||
const char *ug_gai_strerror(int errcode);
|
const char *ug_gai_strerror(int errcode);
|
||||||
|
|||||||
Reference in New Issue
Block a user