mirror of http://www.pogo.org.uk/~mark/trx.git
Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
Mark Hills | 5c844e6996 | |
Mark Hills | 69b6537303 | |
Mark Hills | 85fe843d61 | |
Mark Hills | 66b4707a24 | |
Mark Hills | e375ceef5a | |
Mark Hills | 0b53299941 | |
Mark Hills | f35eb4efe2 |
2
README
2
README
|
@ -1,6 +1,6 @@
|
|||
trx: Realtime audio over IP
|
||||
|
||||
(C) Copyright 2012 Mark Hills <mark@xwax.org>
|
||||
(C) Copyright 2020 Mark Hills <mark@xwax.org>
|
||||
|
||||
See the COPYING file for licensing terms.
|
||||
|
||||
|
|
4
device.c
4
device.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Mark Hills <mark@xwax.org>
|
||||
* Copyright (C) 2020 Mark Hills <mark@xwax.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -53,7 +53,7 @@ int set_alsa_hw(snd_pcm_t *pcm,
|
|||
r = snd_pcm_hw_params_set_access(pcm, hw, SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
CHK("snd_pcm_hw_params_set_access", r);
|
||||
|
||||
r = snd_pcm_hw_params_set_format(pcm, hw, SND_PCM_FORMAT_FLOAT);
|
||||
r = snd_pcm_hw_params_set_format(pcm, hw, SND_PCM_FORMAT_S16);
|
||||
CHK("snd_pcm_hw_params_set_format", r);
|
||||
|
||||
r = snd_pcm_hw_params_set_rate(pcm, hw, rate, 0);
|
||||
|
|
2
device.h
2
device.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Mark Hills <mark@xwax.org>
|
||||
* Copyright (C) 2020 Mark Hills <mark@xwax.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
2
notice.h
2
notice.h
|
@ -1,6 +1,6 @@
|
|||
#ifndef NOTICE_H
|
||||
#define NOTICE_H
|
||||
|
||||
#define COPYRIGHT "trx (C) Copyright 2014 Mark Hills <mark@xwax.org>"
|
||||
#define COPYRIGHT "trx (C) Copyright 2020 Mark Hills <mark@xwax.org>"
|
||||
|
||||
#endif
|
||||
|
|
21
rx.c
21
rx.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Mark Hills <mark@xwax.org>
|
||||
* Copyright (C) 2020 Mark Hills <mark@xwax.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -32,7 +32,7 @@
|
|||
|
||||
static unsigned int verbose = DEFAULT_VERBOSE;
|
||||
|
||||
static void timestamp_jump(RtpSession *session, ...)
|
||||
static void timestamp_jump(RtpSession *session, void *a, void *b, void *c)
|
||||
{
|
||||
if (verbose > 1)
|
||||
fputc('|', stderr);
|
||||
|
@ -60,6 +60,15 @@ static RtpSession* create_rtp_recv(const char *addr_desc, const int port,
|
|||
abort();
|
||||
}
|
||||
|
||||
/*
|
||||
* oRTP in RECVONLY mode attempts to send RTCP packets and
|
||||
* segfaults (v4.3.0 tested)
|
||||
*
|
||||
* https://stackoverflow.com/questions/43591690/receiving-rtcp-issues-within-ortp-library
|
||||
*/
|
||||
|
||||
rtp_session_enable_rtcp(session, FALSE);
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
|
@ -70,15 +79,15 @@ static int play_one_frame(void *packet,
|
|||
const unsigned int channels)
|
||||
{
|
||||
int r;
|
||||
float *pcm;
|
||||
int16_t *pcm;
|
||||
snd_pcm_sframes_t f, samples = 1920;
|
||||
|
||||
pcm = alloca(sizeof(float) * samples * channels);
|
||||
pcm = alloca(sizeof(*pcm) * samples * channels);
|
||||
|
||||
if (packet == NULL) {
|
||||
r = opus_decode_float(decoder, NULL, 0, pcm, samples, 1);
|
||||
r = opus_decode(decoder, NULL, 0, pcm, samples, 1);
|
||||
} else {
|
||||
r = opus_decode_float(decoder, packet, len, pcm, samples, 0);
|
||||
r = opus_decode(decoder, packet, len, pcm, samples, 0);
|
||||
}
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "opus_decode: %s\n", opus_strerror(r));
|
||||
|
|
2
sched.c
2
sched.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Mark Hills <mark@xwax.org>
|
||||
* Copyright (C) 2020 Mark Hills <mark@xwax.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
2
sched.h
2
sched.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Mark Hills <mark@xwax.org>
|
||||
* Copyright (C) 2020 Mark Hills <mark@xwax.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
14
tx.c
14
tx.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Mark Hills <mark@xwax.org>
|
||||
* Copyright (C) 2020 Mark Hills <mark@xwax.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -48,6 +48,8 @@ static RtpSession* create_rtp_send(const char *addr_desc, const int port)
|
|||
abort();
|
||||
if (rtp_session_set_multicast_ttl(session, 16) != 0)
|
||||
abort();
|
||||
if (rtp_session_set_dscp(session, 40) != 0)
|
||||
abort();
|
||||
|
||||
return session;
|
||||
}
|
||||
|
@ -60,17 +62,20 @@ static int send_one_frame(snd_pcm_t *snd,
|
|||
const unsigned int ts_per_frame,
|
||||
RtpSession *session)
|
||||
{
|
||||
float *pcm;
|
||||
int16_t *pcm;
|
||||
void *packet;
|
||||
ssize_t z;
|
||||
snd_pcm_sframes_t f;
|
||||
static unsigned int ts = 0;
|
||||
|
||||
pcm = alloca(sizeof(float) * samples * channels);
|
||||
pcm = alloca(sizeof(*pcm) * samples * channels);
|
||||
packet = alloca(bytes_per_frame);
|
||||
|
||||
f = snd_pcm_readi(snd, pcm, samples);
|
||||
if (f < 0) {
|
||||
if (f == -ESTRPIPE)
|
||||
ts = 0;
|
||||
|
||||
f = snd_pcm_recover(snd, f, 0);
|
||||
if (f < 0) {
|
||||
aerror("snd_pcm_readi", f);
|
||||
|
@ -88,7 +93,7 @@ static int send_one_frame(snd_pcm_t *snd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
z = opus_encode_float(encoder, pcm, samples, packet, bytes_per_frame);
|
||||
z = opus_encode(encoder, pcm, samples, packet, bytes_per_frame);
|
||||
if (z < 0) {
|
||||
fprintf(stderr, "opus_encode_float: %s\n", opus_strerror(z));
|
||||
return -1;
|
||||
|
@ -240,7 +245,6 @@ int main(int argc, char *argv[])
|
|||
|
||||
ortp_init();
|
||||
ortp_scheduler_init();
|
||||
ortp_set_log_level_mask(ORTP_WARNING|ORTP_ERROR);
|
||||
session = create_rtp_send(addr, port);
|
||||
assert(session != NULL);
|
||||
|
||||
|
|
Loading…
Reference in New Issue