Allow receiver to pick up frame size from incoming data

master
Mark Hills 2012-07-21 16:24:30 +01:00
parent 8c5bec31da
commit 2aa7a2da12
2 changed files with 7 additions and 15 deletions

View File

@ -6,7 +6,7 @@
#define DEFAULT_ADDR "0.0.0.0" #define DEFAULT_ADDR "0.0.0.0"
#define DEFAULT_PORT 1350 #define DEFAULT_PORT 1350
#define DEFAULT_FRAME 256 #define DEFAULT_FRAME 960
#define DEFAULT_JITTER 16 #define DEFAULT_JITTER 16
#define DEFAULT_RATE 48000 #define DEFAULT_RATE 48000

20
rx.c
View File

@ -40,12 +40,11 @@ static int play_one_frame(void *packet,
size_t len, size_t len,
OpusDecoder *decoder, OpusDecoder *decoder,
snd_pcm_t *snd, snd_pcm_t *snd,
const unsigned int channels, const unsigned int channels)
const snd_pcm_uframes_t samples)
{ {
int r; int r;
float *pcm; float *pcm;
snd_pcm_sframes_t f; snd_pcm_sframes_t f, samples = 1920;
pcm = alloca(sizeof(float) * samples * channels); pcm = alloca(sizeof(float) * samples * channels);
@ -73,8 +72,7 @@ static int play_one_frame(void *packet,
static int run_rx(RtpSession *session, static int run_rx(RtpSession *session,
OpusDecoder *decoder, OpusDecoder *decoder,
snd_pcm_t *snd, snd_pcm_t *snd,
const unsigned int channels, const unsigned int channels)
const snd_pcm_uframes_t frame)
{ {
int ts = 0; int ts = 0;
@ -97,7 +95,7 @@ static int run_rx(RtpSession *session,
fputc('.', stderr); fputc('.', stderr);
} }
r = play_one_frame(packet, r, decoder, snd, channels, frame); r = play_one_frame(packet, r, decoder, snd, channels);
if (r == -1) if (r == -1)
return -1; return -1;
@ -128,8 +126,6 @@ static void usage(FILE *fd)
DEFAULT_RATE); DEFAULT_RATE);
fprintf(fd, " -c <n> Number of channels (default %d)\n", fprintf(fd, " -c <n> Number of channels (default %d)\n",
DEFAULT_CHANNELS); DEFAULT_CHANNELS);
fprintf(fd, " -f <bytes> Frame size (default %d)\n",
DEFAULT_FRAME);
fprintf(fd, "\nDisplay parameters:\n"); fprintf(fd, "\nDisplay parameters:\n");
fprintf(fd, " -v <n> Verbosity level (default %d)\n", fprintf(fd, " -v <n> Verbosity level (default %d)\n",
@ -148,7 +144,6 @@ int main(int argc, char *argv[])
*addr = DEFAULT_ADDR; *addr = DEFAULT_ADDR;
unsigned int buffer = DEFAULT_BUFFER, unsigned int buffer = DEFAULT_BUFFER,
rate = DEFAULT_RATE, rate = DEFAULT_RATE,
frame = DEFAULT_FRAME,
jitter = DEFAULT_JITTER, jitter = DEFAULT_JITTER,
channels = DEFAULT_CHANNELS, channels = DEFAULT_CHANNELS,
port = DEFAULT_PORT; port = DEFAULT_PORT;
@ -158,7 +153,7 @@ int main(int argc, char *argv[])
for (;;) { for (;;) {
int c; int c;
c = getopt(argc, argv, "d:f:h:j:m:p:v:"); c = getopt(argc, argv, "d:h:j:m:p:v:");
if (c == -1) if (c == -1)
break; break;
@ -166,9 +161,6 @@ int main(int argc, char *argv[])
case 'd': case 'd':
device = optarg; device = optarg;
break; break;
case 'f':
frame = atoi(optarg);
break;
case 'h': case 'h':
addr = optarg; addr = optarg;
break; break;
@ -215,7 +207,7 @@ int main(int argc, char *argv[])
if (set_alsa_sw(snd) == -1) if (set_alsa_sw(snd) == -1)
return -1; return -1;
r = run_rx(session, decoder, snd, channels, frame); r = run_rx(session, decoder, snd, channels);
if (snd_pcm_close(snd) < 0) if (snd_pcm_close(snd) < 0)
abort(); abort();