mirror of https://gerrit.osmocom.org/gapk
direct all log statements to stderr to avoid breaking stdout data out
The tool has the capability to be used in a pipe, so stdout should recevie nothing else but actual codec/pcm data.
This commit is contained in:
parent
7bdf34cc09
commit
0c655bce25
|
@ -148,7 +148,7 @@ out_close:
|
||||||
int
|
int
|
||||||
pq_queue_alsa_input(struct pq *pq, const char *hwdev, unsigned int blk_len)
|
pq_queue_alsa_input(struct pq *pq, const char *hwdev, unsigned int blk_len)
|
||||||
{
|
{
|
||||||
printf("PQ: Adding ALSA input (dev='%s', blk_len=%u)\n", hwdev, blk_len);
|
fprintf(stderr, "[+] PQ: Adding ALSA input (dev='%s', blk_len=%u)\n", hwdev, blk_len);
|
||||||
return pq_queue_alsa_op(pq, hwdev, blk_len, 1);
|
return pq_queue_alsa_op(pq, hwdev, blk_len, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ pq_queue_alsa_input(struct pq *pq, const char *hwdev, unsigned int blk_len)
|
||||||
int
|
int
|
||||||
pq_queue_alsa_output(struct pq *pq, const char *hwdev, unsigned int blk_len)
|
pq_queue_alsa_output(struct pq *pq, const char *hwdev, unsigned int blk_len)
|
||||||
{
|
{
|
||||||
printf("PQ: Adding ALSA output (dev='%s', blk_len=%u)\n", hwdev, blk_len);
|
fprintf(stderr, "[+] PQ: Adding ALSA output (dev='%s', blk_len=%u)\n", hwdev, blk_len);
|
||||||
return pq_queue_alsa_op(pq, hwdev, blk_len, 0);
|
return pq_queue_alsa_op(pq, hwdev, blk_len, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ pq_queue_codec(struct pq *pq, const struct codec_desc *codec, int enc_dec_n)
|
||||||
|
|
||||||
item->exit = codec->codec_exit;
|
item->exit = codec->codec_exit;
|
||||||
|
|
||||||
printf("PQ: Adding Codec %s, %s format %s\n", codec->name,
|
fprintf(stderr, "[+] PQ: Adding Codec %s, %s format %s\n", codec->name,
|
||||||
enc_dec_n ? "encoding to" : "decoding from", fmt->name);
|
enc_dec_n ? "encoding to" : "decoding from", fmt->name);
|
||||||
|
|
||||||
if (!item->proc)
|
if (!item->proc)
|
||||||
|
|
|
@ -97,7 +97,7 @@ pq_queue_file_op(struct pq *pq, FILE *fh, unsigned int blk_len, int in_out_n)
|
||||||
int
|
int
|
||||||
pq_queue_file_input(struct pq *pq, FILE *src, unsigned int blk_len)
|
pq_queue_file_input(struct pq *pq, FILE *src, unsigned int blk_len)
|
||||||
{
|
{
|
||||||
printf("PQ: Adding file input (blk_len=%u)\n", blk_len);
|
fprintf(stderr, "[+] PQ: Adding file input (blk_len=%u)\n", blk_len);
|
||||||
return pq_queue_file_op(pq, src, blk_len, 1);
|
return pq_queue_file_op(pq, src, blk_len, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +110,6 @@ pq_queue_file_input(struct pq *pq, FILE *src, unsigned int blk_len)
|
||||||
int
|
int
|
||||||
pq_queue_file_output(struct pq *pq, FILE *dst, unsigned int blk_len)
|
pq_queue_file_output(struct pq *pq, FILE *dst, unsigned int blk_len)
|
||||||
{
|
{
|
||||||
printf("PQ: Adding file output (blk_len=%u)\n", blk_len);
|
fprintf(stderr, "[+] PQ: Adding file output (blk_len=%u)\n", blk_len);
|
||||||
return pq_queue_file_op(pq, dst, blk_len, 0);
|
return pq_queue_file_op(pq, dst, blk_len, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ pq_queue_fmt_convert(struct pq *pq, const struct format_desc *fmt, int to_from_n
|
||||||
const struct codec_desc *codec = codec_get_from_type(fmt->codec_type);
|
const struct codec_desc *codec = codec_get_from_type(fmt->codec_type);
|
||||||
|
|
||||||
if (!codec) {
|
if (!codec) {
|
||||||
fprintf(stderr, "Cannot determine codec from format %s\n", fmt->name);
|
fprintf(stderr, "[!] Cannot determine codec from format %s\n", fmt->name);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,12 +53,14 @@ pq_queue_fmt_convert(struct pq *pq, const struct format_desc *fmt, int to_from_n
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (to_from_n) {
|
if (to_from_n) {
|
||||||
printf("PQ: Adding conversion from canon to %s (for codec %s)\n", fmt->name, codec->name);
|
fprintf(stderr, "[+] PQ: Adding conversion from canon to %s (for codec %s)\n",
|
||||||
|
fmt->name, codec->name);
|
||||||
item->len_in = codec->canon_frame_len;
|
item->len_in = codec->canon_frame_len;
|
||||||
item->len_out = fmt->frame_len;
|
item->len_out = fmt->frame_len;
|
||||||
item->state = fmt->conv_from_canon;
|
item->state = fmt->conv_from_canon;
|
||||||
} else {
|
} else {
|
||||||
printf("PQ: Adding conversion from %s to canon (for codec %s)\n", fmt->name, codec->name);
|
fprintf(stderr, "[+] PQ: Adding conversion from %s to canon (for codec %s)\n",
|
||||||
|
fmt->name, codec->name);
|
||||||
item->len_in = fmt->frame_len;
|
item->len_in = fmt->frame_len;
|
||||||
item->len_out = codec->canon_frame_len;
|
item->len_out = codec->canon_frame_len;
|
||||||
item->state = fmt->conv_to_canon;
|
item->state = fmt->conv_to_canon;
|
||||||
|
|
21
src/pq_rtp.c
21
src/pq_rtp.c
|
@ -86,6 +86,7 @@ struct pq_state_rtp {
|
||||||
uint32_t ssrc;
|
uint32_t ssrc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define rtp_err(x, args...) fprintf(stderr, "[!] %s():" x, __func__, ## args)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pq_cb_rtp_input(void *_state, uint8_t *out, const uint8_t *in, unsigned int in_len)
|
pq_cb_rtp_input(void *_state, uint8_t *out, const uint8_t *in, unsigned int in_len)
|
||||||
|
@ -99,30 +100,30 @@ pq_cb_rtp_input(void *_state, uint8_t *out, const uint8_t *in, unsigned int in_l
|
||||||
|
|
||||||
rv = read(state->fd, buf, sizeof(buf));
|
rv = read(state->fd, buf, sizeof(buf));
|
||||||
if (rv <= 0) {
|
if (rv <= 0) {
|
||||||
perror("RTP read");
|
rtp_err("error during read\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rv < sizeof(struct rtp_hdr)) {
|
if (rv < sizeof(struct rtp_hdr)) {
|
||||||
fprintf(stderr, "%d smaller than rtp header\n", rv);
|
rtp_err("%d smaller than rtp header\n", rv);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtph->version != RTP_VERSION) {
|
if (rtph->version != RTP_VERSION) {
|
||||||
fprintf(stderr, "unknown RTP version %u\n", rtph->version);
|
rtp_err("unknown RTP version %u\n", rtph->version);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
payload = buf + sizeof(struct rtp_hdr) + (rtph->csrc_count << 2);
|
payload = buf + sizeof(struct rtp_hdr) + (rtph->csrc_count << 2);
|
||||||
payload_len = rv - sizeof(struct rtp_hdr) - (rtph->csrc_count << 2);
|
payload_len = rv - sizeof(struct rtp_hdr) - (rtph->csrc_count << 2);
|
||||||
if (payload_len < 0) {
|
if (payload_len < 0) {
|
||||||
fprintf(stderr, "non-existant RTP payload length %d\n", payload_len);
|
rtp_err("non-existant RTP payload length %d\n", payload_len);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtph->extension) {
|
if (rtph->extension) {
|
||||||
if (payload_len < sizeof(struct rtp_x_hdr)) {
|
if (payload_len < sizeof(struct rtp_x_hdr)) {
|
||||||
fprintf(stderr, "short extension header: %d\n", payload_len);
|
rtp_err("short extension header: %d\n", payload_len);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
rtpxh = (struct rtp_x_hdr *)payload;
|
rtpxh = (struct rtp_x_hdr *)payload;
|
||||||
|
@ -130,18 +131,18 @@ pq_cb_rtp_input(void *_state, uint8_t *out, const uint8_t *in, unsigned int in_l
|
||||||
payload += x_len;
|
payload += x_len;
|
||||||
payload_len -= x_len;
|
payload_len -= x_len;
|
||||||
if (payload_len < 0) {
|
if (payload_len < 0) {
|
||||||
fprintf(stderr, "short RTP payload length %d\n", payload_len);
|
rtp_err("short RTP payload length %d\n", payload_len);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rtph->padding) {
|
if (rtph->padding) {
|
||||||
if (payload_len < 0) {
|
if (payload_len < 0) {
|
||||||
fprintf(stderr, "padding but no payload length %d\n", payload_len);
|
rtp_err("padding but no payload length %d\n", payload_len);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
payload_len -= payload[payload_len -1];
|
payload_len -= payload[payload_len -1];
|
||||||
if (payload_len < 0) {
|
if (payload_len < 0) {
|
||||||
fprintf(stderr, "no payload left after padding %d\n", payload_len);
|
rtp_err("no payload left after padding %d\n", payload_len);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +241,7 @@ pq_queue_rtp_op(struct pq *pq, int udp_fd, unsigned int blk_len, int in_out_n)
|
||||||
int
|
int
|
||||||
pq_queue_rtp_input(struct pq *pq, int udp_fd, unsigned int blk_len)
|
pq_queue_rtp_input(struct pq *pq, int udp_fd, unsigned int blk_len)
|
||||||
{
|
{
|
||||||
printf("PQ: Adding RTP input (blk_len=%u)\n", blk_len);
|
fprintf(stderr, "[+] PQ: Adding RTP input (blk_len=%u)\n", blk_len);
|
||||||
return pq_queue_rtp_op(pq, udp_fd, blk_len, 1);
|
return pq_queue_rtp_op(pq, udp_fd, blk_len, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,6 +253,6 @@ pq_queue_rtp_input(struct pq *pq, int udp_fd, unsigned int blk_len)
|
||||||
int
|
int
|
||||||
pq_queue_rtp_output(struct pq *pq, int udp_fd, unsigned int blk_len)
|
pq_queue_rtp_output(struct pq *pq, int udp_fd, unsigned int blk_len)
|
||||||
{
|
{
|
||||||
printf("PQ: Adding RTP output (blk_len=%u)\n", blk_len);
|
fprintf(stderr, "[+] PQ: Adding RTP output (blk_len=%u)\n", blk_len);
|
||||||
return pq_queue_rtp_op(pq, udp_fd, blk_len, 0);
|
return pq_queue_rtp_op(pq, udp_fd, blk_len, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue