diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2017-08-31 17:22:56 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2017-12-31 12:20:59 +0100 |
commit | a8d46571cebb7f14501fa7bcf3c2eb86c473d8b2 (patch) | |
tree | 8e8dfb392f9a13026ff521e85f2b5babd1ce4c12 /src | |
parent | 9cba760ba2ca5fd73e34f91bf388fc255dbcd335 (diff) |
Add an 'osmo_gapk' prefix to the exposed symbols
To avoid a naming conflict between libosmogapk and other projects
during linkage, all the exposed symbols should have an unique
prefix. Let's use 'osmo_gapk' for that.
Diffstat (limited to 'src')
-rw-r--r-- | src/benchmark.c | 4 | ||||
-rw-r--r-- | src/codec_amr.c | 2 | ||||
-rw-r--r-- | src/codec_efr.c | 2 | ||||
-rw-r--r-- | src/codec_fr.c | 2 | ||||
-rw-r--r-- | src/codec_hr.c | 2 | ||||
-rw-r--r-- | src/codec_pcm.c | 2 | ||||
-rw-r--r-- | src/codecs.c | 14 | ||||
-rw-r--r-- | src/fmt_amr.c | 2 | ||||
-rw-r--r-- | src/fmt_amr_opencore.c | 2 | ||||
-rw-r--r-- | src/fmt_gsm.c | 2 | ||||
-rw-r--r-- | src/fmt_hr_ref.c | 4 | ||||
-rw-r--r-- | src/fmt_racal.c | 6 | ||||
-rw-r--r-- | src/fmt_rawpcm.c | 2 | ||||
-rw-r--r-- | src/fmt_rtp_amr.c | 2 | ||||
-rw-r--r-- | src/fmt_rtp_efr.c | 2 | ||||
-rw-r--r-- | src/fmt_rtp_hr_etsi.c | 2 | ||||
-rw-r--r-- | src/fmt_rtp_hr_ietf.c | 2 | ||||
-rw-r--r-- | src/fmt_ti.c | 6 | ||||
-rw-r--r-- | src/formats.c | 44 | ||||
-rw-r--r-- | src/main.c | 75 | ||||
-rw-r--r-- | src/pq_alsa.c | 10 | ||||
-rw-r--r-- | src/pq_codec.c | 16 | ||||
-rw-r--r-- | src/pq_file.c | 10 | ||||
-rw-r--r-- | src/pq_format.c | 11 | ||||
-rw-r--r-- | src/pq_rtp.c | 10 | ||||
-rw-r--r-- | src/procqueue.c | 26 |
26 files changed, 133 insertions, 129 deletions
diff --git a/src/benchmark.c b/src/benchmark.c index 6dfc33b..59f5965 100644 --- a/src/benchmark.c +++ b/src/benchmark.c @@ -21,14 +21,14 @@ #include <osmocom/gapk/benchmark.h> -struct benchmark_cycles codec_cycles[_CODEC_MAX]; +struct osmo_gapk_bench_cycles osmo_gapk_bench_codec[_CODEC_MAX]; void benchmark_dump(void) { int i; for (i = 0; i < _CODEC_MAX; i++) { - struct benchmark_cycles *bc = &codec_cycles[i]; + struct osmo_gapk_bench_cycles *bc = &osmo_gapk_bench_codec[i]; unsigned long long total; int j; diff --git a/src/codec_amr.c b/src/codec_amr.c index 4c4b3e6..9cbeba6 100644 --- a/src/codec_amr.c +++ b/src/codec_amr.c @@ -103,7 +103,7 @@ codec_amr_decode(void *state, uint8_t *pcm, const uint8_t *cod, unsigned int cod #endif /* HAVE_OPENCORE_AMRNB */ -const struct codec_desc codec_amr_desc = { +const struct osmo_gapk_codec_desc codec_amr_desc = { .type = CODEC_AMR, .name = "amr", .description = "GSM 26.071 Adaptive Multi Rate codec", diff --git a/src/codec_efr.c b/src/codec_efr.c index 84e5fc5..ba39f61 100644 --- a/src/codec_efr.c +++ b/src/codec_efr.c @@ -108,7 +108,7 @@ codec_efr_decode(void *state, uint8_t *pcm, const uint8_t *cod, unsigned int cod #endif /* HAVE_OPENCORE_AMRNB */ -const struct codec_desc codec_efr_desc = { +const struct osmo_gapk_codec_desc codec_efr_desc = { .type = CODEC_EFR, .name = "efr", .description = "GSM 06.60 Enhanced Full Rate codec", diff --git a/src/codec_fr.c b/src/codec_fr.c index 0cda1f4..6fc0af1 100644 --- a/src/codec_fr.c +++ b/src/codec_fr.c @@ -83,7 +83,7 @@ codec_fr_decode(void *state, uint8_t *pcm, const uint8_t *cod, unsigned int cod_ #endif /* HAVE_LIBGSM */ -const struct codec_desc codec_fr_desc = { +const struct osmo_gapk_codec_desc codec_fr_desc = { .type = CODEC_FR, .name = "fr", .description = "GSM 06.10 Full Rate codec (classic gsm codec)", diff --git a/src/codec_hr.c b/src/codec_hr.c index 6e5948a..7c1484e 100644 --- a/src/codec_hr.c +++ b/src/codec_hr.c @@ -73,7 +73,7 @@ codec_hr_decode(void *_state, uint8_t *pcm, const uint8_t *cod, unsigned int cod #endif /* HAVE_LIBGSMHR */ -const struct codec_desc codec_hr_desc = { +const struct osmo_gapk_codec_desc codec_hr_desc = { .type = CODEC_HR, .name = "hr", .description = "GSM 06.20 Half Rate codec", diff --git a/src/codec_pcm.c b/src/codec_pcm.c index 95e83ca..76cab34 100644 --- a/src/codec_pcm.c +++ b/src/codec_pcm.c @@ -19,7 +19,7 @@ #include <osmocom/gapk/codecs.h> -const struct codec_desc codec_pcm_desc = { +const struct osmo_gapk_codec_desc codec_pcm_desc = { .type = CODEC_PCM, .name = "pcm", .description = "Raw PCM signed 16 bits samples", diff --git a/src/codecs.c b/src/codecs.c index f7f86bd..be5a112 100644 --- a/src/codecs.c +++ b/src/codecs.c @@ -22,15 +22,15 @@ #include <osmocom/gapk/codecs.h> /* Extern codec descriptors */ -extern const struct codec_desc codec_pcm_desc; -extern const struct codec_desc codec_hr_desc; -extern const struct codec_desc codec_fr_desc; -extern const struct codec_desc codec_efr_desc; -extern const struct codec_desc codec_amr_desc; +extern const struct osmo_gapk_codec_desc codec_pcm_desc; +extern const struct osmo_gapk_codec_desc codec_hr_desc; +extern const struct osmo_gapk_codec_desc codec_fr_desc; +extern const struct osmo_gapk_codec_desc codec_efr_desc; +extern const struct osmo_gapk_codec_desc codec_amr_desc; -const struct codec_desc * -codec_get_from_type(enum codec_type type) +const struct osmo_gapk_codec_desc * +osmo_gapk_codec_get_from_type(enum osmo_gapk_codec_type type) { switch (type) { case CODEC_PCM: return &codec_pcm_desc; diff --git a/src/fmt_amr.c b/src/fmt_amr.c index 06f4158..3694f8a 100644 --- a/src/fmt_amr.c +++ b/src/fmt_amr.c @@ -70,7 +70,7 @@ amr_efr_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return EFR_CANON_LEN; } -const struct format_desc fmt_amr_efr = { +const struct osmo_gapk_format_desc fmt_amr_efr = { .type = FMT_AMR_EFR, .codec_type = CODEC_EFR, .name = "amr-efr", diff --git a/src/fmt_amr_opencore.c b/src/fmt_amr_opencore.c index 07281fd..640595e 100644 --- a/src/fmt_amr_opencore.c +++ b/src/fmt_amr_opencore.c @@ -39,7 +39,7 @@ amr_opencore_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return src_len; } -const struct format_desc fmt_amr_opencore = { +const struct osmo_gapk_format_desc fmt_amr_opencore = { .type = FMT_AMR_OPENCORE, .codec_type = CODEC_AMR, .name = "amr-opencore", diff --git a/src/fmt_gsm.c b/src/fmt_gsm.c index 1963692..e97ac9b 100644 --- a/src/fmt_gsm.c +++ b/src/fmt_gsm.c @@ -54,7 +54,7 @@ gsm_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return FR_CANON_LEN; } -const struct format_desc fmt_gsm = { +const struct osmo_gapk_format_desc fmt_gsm = { .type = FMT_GSM, .codec_type = CODEC_FR, .name = "gsm", diff --git a/src/fmt_hr_ref.c b/src/fmt_hr_ref.c index fb5b008..0394b76 100644 --- a/src/fmt_hr_ref.c +++ b/src/fmt_hr_ref.c @@ -191,7 +191,7 @@ hr_ref_enc_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) } -const struct format_desc fmt_hr_ref_dec = { +const struct osmo_gapk_format_desc fmt_hr_ref_dec = { .type = FMT_HR_REF_DEC, .codec_type = CODEC_HR, .name = "hr-ref-dec", @@ -202,7 +202,7 @@ const struct format_desc fmt_hr_ref_dec = { .conv_to_canon = hr_ref_dec_to_canon, }; -const struct format_desc fmt_hr_ref_enc = { +const struct osmo_gapk_format_desc fmt_hr_ref_enc = { .type = FMT_HR_REF_ENC, .codec_type = CODEC_HR, .name = "hr-ref-enc", diff --git a/src/fmt_racal.c b/src/fmt_racal.c index add202b..7bb53dd 100644 --- a/src/fmt_racal.c +++ b/src/fmt_racal.c @@ -76,7 +76,7 @@ racal_hr_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return RACAL_HR_LEN; } -const struct format_desc fmt_racal_hr = { +const struct osmo_gapk_format_desc fmt_racal_hr = { .type = FMT_RACAL_HR, .codec_type = CODEC_HR, .name = "racal-hr", @@ -124,7 +124,7 @@ racal_fr_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return FR_CANON_LEN; } -const struct format_desc fmt_racal_fr = { +const struct osmo_gapk_format_desc fmt_racal_fr = { .type = FMT_RACAL_FR, .codec_type = CODEC_FR, .name = "racal-fr", @@ -166,7 +166,7 @@ racal_efr_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return EFR_CANON_LEN; } -const struct format_desc fmt_racal_efr = { +const struct osmo_gapk_format_desc fmt_racal_efr = { .type = FMT_RACAL_EFR, .codec_type = CODEC_EFR, .name = "racal-efr", diff --git a/src/fmt_rawpcm.c b/src/fmt_rawpcm.c index c0c83c1..7b45060 100644 --- a/src/fmt_rawpcm.c +++ b/src/fmt_rawpcm.c @@ -53,7 +53,7 @@ rawpcm_s16le_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return PCM_CANON_LEN; } -const struct format_desc fmt_rawpcm_s16le = { +const struct osmo_gapk_format_desc fmt_rawpcm_s16le = { .type = FMT_RAWPCM_S16LE, .codec_type = CODEC_PCM, .name = "rawpcm-s16le", diff --git a/src/fmt_rtp_amr.c b/src/fmt_rtp_amr.c index 79dd37c..a6a3c9f 100644 --- a/src/fmt_rtp_amr.c +++ b/src/fmt_rtp_amr.c @@ -48,7 +48,7 @@ rtp_amr_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return src_len-1; } -const struct format_desc fmt_rtp_amr = { +const struct osmo_gapk_format_desc fmt_rtp_amr = { .type = FMT_RTP_AMR, .codec_type = CODEC_AMR, .name = "rtp-amr", diff --git a/src/fmt_rtp_efr.c b/src/fmt_rtp_efr.c index f900f75..accfd4f 100644 --- a/src/fmt_rtp_efr.c +++ b/src/fmt_rtp_efr.c @@ -61,7 +61,7 @@ rtp_efr_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return EFR_CANON_LEN; } -const struct format_desc fmt_rtp_efr = { +const struct osmo_gapk_format_desc fmt_rtp_efr = { .type = FMT_RTP_EFR, .codec_type = CODEC_EFR, .name = "rtp-efr", diff --git a/src/fmt_rtp_hr_etsi.c b/src/fmt_rtp_hr_etsi.c index 475f156..9ed9b22 100644 --- a/src/fmt_rtp_hr_etsi.c +++ b/src/fmt_rtp_hr_etsi.c @@ -48,7 +48,7 @@ rtp_hr_etsi_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return HR_CANON_LEN; } -const struct format_desc fmt_rtp_hr_etsi = { +const struct osmo_gapk_format_desc fmt_rtp_hr_etsi = { .type = FMT_RTP_HR_ETSI, .codec_type = CODEC_HR, .name = "rtp-hr-etsi", diff --git a/src/fmt_rtp_hr_ietf.c b/src/fmt_rtp_hr_ietf.c index cedf461..4ee548f 100644 --- a/src/fmt_rtp_hr_ietf.c +++ b/src/fmt_rtp_hr_ietf.c @@ -68,7 +68,7 @@ rtp_hr_ietf_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return HR_CANON_LEN; } -const struct format_desc fmt_rtp_hr_ietf = { +const struct osmo_gapk_format_desc fmt_rtp_hr_ietf = { .type = FMT_RTP_HR_IETF, .codec_type = CODEC_HR, .name = "rtp-hr-ietf", diff --git a/src/fmt_ti.c b/src/fmt_ti.c index 5f2da9f..d7a1ec7 100644 --- a/src/fmt_ti.c +++ b/src/fmt_ti.c @@ -84,7 +84,7 @@ ti_hr_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return HR_CANON_LEN; } -const struct format_desc fmt_ti_hr = { +const struct osmo_gapk_format_desc fmt_ti_hr = { .type = FMT_TI_HR, .codec_type = CODEC_HR, .name = "ti-hr", @@ -132,7 +132,7 @@ ti_fr_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return FR_CANON_LEN; } -const struct format_desc fmt_ti_fr = { +const struct osmo_gapk_format_desc fmt_ti_fr = { .type = FMT_TI_FR, .codec_type = CODEC_FR, .name = "ti-fr", @@ -224,7 +224,7 @@ ti_efr_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len) return EFR_CANON_LEN; } -const struct format_desc fmt_ti_efr = { +const struct osmo_gapk_format_desc fmt_ti_efr = { .type = FMT_TI_EFR, .codec_type = CODEC_EFR, .name = "ti-efr", diff --git a/src/formats.c b/src/formats.c index 8544186..835af6b 100644 --- a/src/formats.c +++ b/src/formats.c @@ -23,24 +23,24 @@ #include <osmocom/gapk/formats.h> /* Extern format descriptors */ -extern const struct format_desc fmt_amr_efr; -extern const struct format_desc fmt_gsm; -extern const struct format_desc fmt_hr_ref_dec; -extern const struct format_desc fmt_hr_ref_enc; -extern const struct format_desc fmt_racal_hr; -extern const struct format_desc fmt_racal_fr; -extern const struct format_desc fmt_racal_efr; -extern const struct format_desc fmt_rawpcm_s16le; -extern const struct format_desc fmt_ti_hr; -extern const struct format_desc fmt_ti_fr; -extern const struct format_desc fmt_ti_efr; -extern const struct format_desc fmt_amr_opencore; -extern const struct format_desc fmt_rtp_amr; -extern const struct format_desc fmt_rtp_efr; -extern const struct format_desc fmt_rtp_hr_etsi; -extern const struct format_desc fmt_rtp_hr_ietf; +extern const struct osmo_gapk_format_desc fmt_amr_efr; +extern const struct osmo_gapk_format_desc fmt_gsm; +extern const struct osmo_gapk_format_desc fmt_hr_ref_dec; +extern const struct osmo_gapk_format_desc fmt_hr_ref_enc; +extern const struct osmo_gapk_format_desc fmt_racal_hr; +extern const struct osmo_gapk_format_desc fmt_racal_fr; +extern const struct osmo_gapk_format_desc fmt_racal_efr; +extern const struct osmo_gapk_format_desc fmt_rawpcm_s16le; +extern const struct osmo_gapk_format_desc fmt_ti_hr; +extern const struct osmo_gapk_format_desc fmt_ti_fr; +extern const struct osmo_gapk_format_desc fmt_ti_efr; +extern const struct osmo_gapk_format_desc fmt_amr_opencore; +extern const struct osmo_gapk_format_desc fmt_rtp_amr; +extern const struct osmo_gapk_format_desc fmt_rtp_efr; +extern const struct osmo_gapk_format_desc fmt_rtp_hr_etsi; +extern const struct osmo_gapk_format_desc fmt_rtp_hr_ietf; -static const struct format_desc *supported_formats[_FMT_MAX] = { +static const struct osmo_gapk_format_desc *supported_formats[_FMT_MAX] = { [FMT_INVALID] = NULL, [FMT_AMR_EFR] = &fmt_amr_efr, [FMT_GSM] = &fmt_gsm, @@ -61,20 +61,20 @@ static const struct format_desc *supported_formats[_FMT_MAX] = { }; -const struct format_desc * -fmt_get_from_type(enum format_type type) +const struct osmo_gapk_format_desc * +osmo_gapk_fmt_get_from_type(enum osmo_gapk_format_type type) { if (type <= FMT_INVALID || type >= _FMT_MAX) return NULL; return supported_formats[type]; } -const struct format_desc * -fmt_get_from_name(const char *name) +const struct osmo_gapk_format_desc * +osmo_gapk_fmt_get_from_name(const char *name) { int i; for (i=FMT_INVALID+1; i<_FMT_MAX; i++) { - const struct format_desc *fmt = supported_formats[i]; + const struct osmo_gapk_format_desc *fmt = supported_formats[i]; if (!fmt) continue; if (!strcmp(fmt->name, name)) @@ -47,7 +47,7 @@ struct gapk_options uint16_t port; } rtp_in; const char *alsa_in; - const struct format_desc *fmt_in; + const struct osmo_gapk_format_desc *fmt_in; const char *fname_out; struct { @@ -55,14 +55,14 @@ struct gapk_options uint16_t port; } rtp_out; const char *alsa_out; - const struct format_desc *fmt_out; + const struct osmo_gapk_format_desc *fmt_out; }; struct gapk_state { struct gapk_options opts; - struct pq *pq; + struct osmo_gapk_pq *pq; struct { struct { @@ -87,6 +87,7 @@ struct gapk_state static void print_help(char *progname) { + const struct osmo_gapk_codec_desc *codec; int i; /* Header */ @@ -110,7 +111,7 @@ print_help(char *progname) fprintf(stdout, " name\tfmt enc dec\tdescription\n"); for (i=CODEC_INVALID+1; i<_CODEC_MAX; i++) { - const struct codec_desc *codec = codec_get_from_type(i); + codec = osmo_gapk_codec_get_from_type(i); fprintf(stdout, " %4s %c %c %c \t%s\n", codec->name, '*', @@ -126,7 +127,7 @@ print_help(char *progname) fprintf(stdout, "Supported formats:\n"); for (i=FMT_INVALID+1; i<_FMT_MAX; i++) { - const struct format_desc *fmt = fmt_get_from_type(i); + const struct osmo_gapk_format_desc *fmt = osmo_gapk_fmt_get_from_type(i); fprintf(stdout, " %-19s %s\n", fmt->name, fmt->description @@ -230,7 +231,7 @@ parse_options(struct gapk_state *state, int argc, char *argv[]) break; case 'f': - opt->fmt_in = fmt_get_from_name(optarg); + opt->fmt_in = osmo_gapk_fmt_get_from_name(optarg); if (!opt->fmt_in) { fprintf(stderr, "[!] Unsupported format: %s\n", optarg); return -EINVAL; @@ -238,7 +239,7 @@ parse_options(struct gapk_state *state, int argc, char *argv[]) break; case 'g': - opt->fmt_out = fmt_get_from_name(optarg); + opt->fmt_out = osmo_gapk_fmt_get_from_name(optarg); if (!opt->fmt_out) { fprintf(stderr, "[!] Unsupported format: %s\n", optarg); return -EINVAL; @@ -269,10 +270,10 @@ check_options(struct gapk_state *gs) /* Transcoding */ if (gs->opts.fmt_in->codec_type != gs->opts.fmt_out->codec_type) { - const struct codec_desc *codec; + const struct osmo_gapk_codec_desc *codec; /* Check source codec */ - codec = codec_get_from_type(gs->opts.fmt_in->codec_type); + codec = osmo_gapk_codec_get_from_type(gs->opts.fmt_in->codec_type); if (!codec) { fprintf(stderr, "[!] Internal error: bad codec reference\n"); return -EINVAL; @@ -283,7 +284,7 @@ check_options(struct gapk_state *gs) } /* Check destination codec */ - codec = codec_get_from_type(gs->opts.fmt_out->codec_type); + codec = osmo_gapk_codec_get_from_type(gs->opts.fmt_out->codec_type); if (!codec) { fprintf(stderr, "[!] Internal error: bad codec reference\n"); return -EINVAL; @@ -413,16 +414,16 @@ handle_headers(struct gapk_state *gs) static int make_processing_chain(struct gapk_state *gs) { - const struct format_desc *fmt_in, *fmt_out; - const struct codec_desc *codec_in, *codec_out; + const struct osmo_gapk_format_desc *fmt_in, *fmt_out; + const struct osmo_gapk_codec_desc *codec_in, *codec_out; int need_dec, need_enc; fmt_in = gs->opts.fmt_in; fmt_out = gs->opts.fmt_out; - codec_in = codec_get_from_type(fmt_in->codec_type); - codec_out = codec_get_from_type(fmt_out->codec_type); + codec_in = osmo_gapk_codec_get_from_type(fmt_in->codec_type); + codec_out = osmo_gapk_codec_get_from_type(fmt_out->codec_type); need_dec = (fmt_in->codec_type != CODEC_PCM) && (fmt_in->codec_type != fmt_out->codec_type); @@ -431,12 +432,12 @@ make_processing_chain(struct gapk_state *gs) /* File read */ if (gs->in.file.fh) - pq_queue_file_input(gs->pq, gs->in.file.fh, fmt_in->frame_len); + osmo_gapk_pq_queue_file_input(gs->pq, gs->in.file.fh, fmt_in->frame_len); else if (gs->in.rtp.fd != -1) - pq_queue_rtp_input(gs->pq, gs->in.rtp.fd, fmt_in->frame_len); + osmo_gapk_pq_queue_rtp_input(gs->pq, gs->in.rtp.fd, fmt_in->frame_len); #ifdef HAVE_ALSA else if (gs->opts.alsa_in) - pq_queue_alsa_input(gs->pq, gs->opts.alsa_in, fmt_in->frame_len); + osmo_gapk_pq_queue_alsa_input(gs->pq, gs->opts.alsa_in, fmt_in->frame_len); #endif else { fprintf(stderr, "Unknown/invalid input\n"); @@ -449,64 +450,64 @@ make_processing_chain(struct gapk_state *gs) /* Convert input to decoder input fmt */ if (fmt_in->type != codec_in->codec_dec_format_type) { - const struct format_desc *fmt_dec; + const struct osmo_gapk_format_desc *fmt_dec; - fmt_dec = fmt_get_from_type(codec_in->codec_dec_format_type); + fmt_dec = osmo_gapk_fmt_get_from_type(codec_in->codec_dec_format_type); if (!fmt_dec) { fprintf(stderr, "Cannot determine decoder input format for codec %s\n", codec_in->name); return -EINVAL; } - pq_queue_fmt_convert(gs->pq, fmt_in, 0); - pq_queue_fmt_convert(gs->pq, fmt_dec, 1); + osmo_gapk_pq_queue_fmt_convert(gs->pq, fmt_in, 0); + osmo_gapk_pq_queue_fmt_convert(gs->pq, fmt_dec, 1); } /* Do decoding */ - pq_queue_codec(gs->pq, codec_in, 0); + osmo_gapk_pq_queue_codec(gs->pq, codec_in, 0); } else if (fmt_in->type != fmt_out->type) { /* Convert input to canonical fmt */ - pq_queue_fmt_convert(gs->pq, fmt_in, 0); + osmo_gapk_pq_queue_fmt_convert(gs->pq, fmt_in, 0); } /* Encoding from PCM ? */ if (need_enc) { /* Do encoding */ - pq_queue_codec(gs->pq, codec_out, 1); + osmo_gapk_pq_queue_codec(gs->pq, codec_out, 1); /* Convert encoder output to output fmt */ if (fmt_out->type != codec_out->codec_enc_format_type) { - const struct format_desc *fmt_enc; + const struct osmo_gapk_format_desc *fmt_enc; - fmt_enc = fmt_get_from_type(codec_out->codec_enc_format_type); + fmt_enc = osmo_gapk_fmt_get_from_type(codec_out->codec_enc_format_type); if (!fmt_enc) { fprintf(stderr, "Cannot determine encoder output format for codec %s\n", codec_out->name); return -EINVAL; } - pq_queue_fmt_convert(gs->pq, fmt_enc, 0); - pq_queue_fmt_convert(gs->pq, fmt_out, 1); + osmo_gapk_pq_queue_fmt_convert(gs->pq, fmt_enc, 0); + osmo_gapk_pq_queue_fmt_convert(gs->pq, fmt_out, 1); } } else if (fmt_in->type != fmt_out->type) { /* Convert canonical to output fmt */ - pq_queue_fmt_convert(gs->pq, fmt_out, 1); + osmo_gapk_pq_queue_fmt_convert(gs->pq, fmt_out, 1); } /* File write */ if (gs->out.file.fh) - pq_queue_file_output(gs->pq, gs->out.file.fh, fmt_out->frame_len); + osmo_gapk_pq_queue_file_output(gs->pq, gs->out.file.fh, fmt_out->frame_len); else if (gs->out.rtp.fd != -1) - pq_queue_rtp_output(gs->pq, gs->out.rtp.fd, fmt_out->frame_len); + osmo_gapk_pq_queue_rtp_output(gs->pq, gs->out.rtp.fd, fmt_out->frame_len); #ifdef HAVE_ALSA else if (gs->opts.alsa_out) - pq_queue_alsa_output(gs->pq, gs->opts.alsa_out, fmt_out->frame_len); + osmo_gapk_pq_queue_alsa_output(gs->pq, gs->opts.alsa_out, fmt_out->frame_len); #endif else { fprintf(stderr, "Unknown/invalid output\n"); @@ -521,11 +522,11 @@ run(struct gapk_state *gs) { int rv, frames; - rv = pq_prepare(gs->pq); + rv = osmo_gapk_pq_prepare(gs->pq); if (rv) return rv; - for (frames=0; !(rv = pq_execute(gs->pq)); frames++); + for (frames=0; !(rv = osmo_gapk_pq_execute(gs->pq)); frames++); fprintf(stderr, "[+] Processed %d frames\n", frames); @@ -541,7 +542,7 @@ static void signal_handler(int signal) case SIGINT: fprintf(stderr, "catching sigint, closing files\n"); files_close(gs); - pq_destroy(gs->pq); + osmo_gapk_pq_destroy(gs->pq); exit(0); break; default: @@ -574,7 +575,7 @@ int main(int argc, char *argv[]) return rv; /* Create processing queue */ - gs->pq = pq_create(); + gs->pq = osmo_gapk_pq_create(); if (!gs->pq) { rv = -ENOMEM; fprintf(stderr, "Error creating processing queue\n"); @@ -612,7 +613,7 @@ error: files_close(gs); /* Release processing queue */ - pq_destroy(gs->pq); + osmo_gapk_pq_destroy(gs->pq); benchmark_dump(); diff --git a/src/pq_alsa.c b/src/pq_alsa.c index 1902d7b..d280de6 100644 --- a/src/pq_alsa.c +++ b/src/pq_alsa.c @@ -77,9 +77,9 @@ pq_cb_alsa_exit(void *_state) } static int -pq_queue_alsa_op(struct pq *pq, const char *alsa_dev, unsigned int blk_len, int in_out_n) +pq_queue_alsa_op(struct osmo_gapk_pq *pq, const char *alsa_dev, unsigned int blk_len, int in_out_n) { - struct pq_item *item; + struct osmo_gapk_pq_item *item; struct pq_state_alsa *state; snd_pcm_hw_params_t *hw_params; int rc = -1; @@ -127,7 +127,7 @@ pq_queue_alsa_op(struct pq *pq, const char *alsa_dev, unsigned int blk_len, int snd_pcm_hw_params_free(hw_params); - item = pq_add_item(pq); + item = osmo_gapk_pq_add_item(pq); if (!item) { rc = -ENOMEM; goto out_close; @@ -160,7 +160,7 @@ out_print: * \param[in] blk_len block length to be read from device * \returns 0 on sucess; negative on error */ int -pq_queue_alsa_input(struct pq *pq, const char *hwdev, unsigned int blk_len) +osmo_gapk_pq_queue_alsa_input(struct osmo_gapk_pq *pq, const char *hwdev, unsigned int 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); @@ -173,7 +173,7 @@ pq_queue_alsa_input(struct pq *pq, const char *hwdev, unsigned int blk_len) * \param[in] blk_len block length to be written to device * \returns 0 on sucess; negative on error */ int -pq_queue_alsa_output(struct pq *pq, const char *hwdev, unsigned int blk_len) +osmo_gapk_pq_queue_alsa_output(struct osmo_gapk_pq *pq, const char *hwdev, unsigned int 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); diff --git a/src/pq_codec.c b/src/pq_codec.c index 4b41e1d..37fa1c9 100644 --- a/src/pq_codec.c +++ b/src/pq_codec.c @@ -31,14 +31,14 @@ * \param[in] encode (1) or decode (0) * \returns 0 on success; negative on error */ int -pq_queue_codec(struct pq *pq, const struct codec_desc *codec, int enc_dec_n) +osmo_gapk_pq_queue_codec(struct osmo_gapk_pq *pq, const struct osmo_gapk_codec_desc *codec, int enc_dec_n) { - const struct codec_desc *codec_pcm = codec_get_from_type(CODEC_PCM); - const struct format_desc *fmt; - struct pq_item *item; + const struct osmo_gapk_codec_desc *codec_pcm; + const struct osmo_gapk_format_desc *fmt; + struct osmo_gapk_pq_item *item; /* allocate a new item to the processing queue */ - item = pq_add_item(pq); + item = osmo_gapk_pq_add_item(pq); if (!item) return -ENOMEM; @@ -50,7 +50,8 @@ pq_queue_codec(struct pq *pq, const struct codec_desc *codec, int enc_dec_n) } if (enc_dec_n) { - fmt = fmt_get_from_type(codec->codec_enc_format_type); + codec_pcm = osmo_gapk_codec_get_from_type(CODEC_PCM); + fmt = osmo_gapk_fmt_get_from_type(codec->codec_enc_format_type); if (!fmt) return -EINVAL; @@ -58,7 +59,8 @@ pq_queue_codec(struct pq *pq, const struct codec_desc *codec, int enc_dec_n) item->len_out = fmt->frame_len; item->proc = codec->codec_encode; } else { - fmt = fmt_get_from_type(codec->codec_dec_format_type); + codec_pcm = osmo_gapk_codec_get_from_type(CODEC_PCM); + fmt = osmo_gapk_fmt_get_from_type(codec->codec_dec_format_type); if (!fmt) return -EINVAL; diff --git a/src/pq_file.c b/src/pq_file.c index e20b52b..2d0a6b0 100644 --- a/src/pq_file.c +++ b/src/pq_file.c @@ -60,9 +60,9 @@ pq_cb_file_exit(void *_state) } static int -pq_queue_file_op(struct pq *pq, FILE *fh, unsigned int blk_len, int in_out_n) +pq_queue_file_op(struct osmo_gapk_pq *pq, FILE *fh, unsigned int blk_len, int in_out_n) { - struct pq_item *item; + struct osmo_gapk_pq_item *item; struct pq_state_file *state; state = calloc(1, sizeof(struct pq_state_file)); @@ -72,7 +72,7 @@ pq_queue_file_op(struct pq *pq, FILE *fh, unsigned int blk_len, int in_out_n) state->fh = fh; state->blk_len = blk_len; - item = pq_add_item(pq); + item = osmo_gapk_pq_add_item(pq); if (!item) { free(state); return -ENOMEM; @@ -95,7 +95,7 @@ pq_queue_file_op(struct pq *pq, FILE *fh, unsigned int blk_len, int in_out_n) * \param[in] blk_len block length to be read from file * \returns 0 on sucess; negative on error */ int -pq_queue_file_input(struct pq *pq, FILE *src, unsigned int blk_len) +osmo_gapk_pq_queue_file_input(struct osmo_gapk_pq *pq, FILE *src, unsigned int blk_len) { fprintf(stderr, "[+] PQ: Adding file input (blk_len=%u)\n", blk_len); return pq_queue_file_op(pq, src, blk_len, 1); @@ -108,7 +108,7 @@ pq_queue_file_input(struct pq *pq, FILE *src, unsigned int blk_len) * \param[in] blk_len block length to be written to file * \returns 0 on sucess; negative on error */ int -pq_queue_file_output(struct pq *pq, FILE *dst, unsigned int blk_len) +osmo_gapk_pq_queue_file_output(struct osmo_gapk_pq *pq, FILE *dst, unsigned int blk_len) { fprintf(stderr, "[+] PQ: Adding file output (blk_len=%u)\n", blk_len); return pq_queue_file_op(pq, dst, blk_len, 0); diff --git a/src/pq_format.c b/src/pq_format.c index ae98483..08860a3 100644 --- a/src/pq_format.c +++ b/src/pq_format.c @@ -28,7 +28,7 @@ static int pq_cb_fmt_convert(void *_state, uint8_t *out, const uint8_t *in, unsigned int in_len) { - fmt_conv_cb_t f = _state; + osmo_gapk_fmt_conv_cb_t f = _state; return f(out, in, in_len); } @@ -37,18 +37,19 @@ pq_cb_fmt_convert(void *_state, uint8_t *out, const uint8_t *in, unsigned int in * \param[in] fmt Format description for conversion * \param[in] to_from_n convert to (0) or from (1) specified format */ int -pq_queue_fmt_convert(struct pq *pq, const struct format_desc *fmt, int to_from_n) +osmo_gapk_pq_queue_fmt_convert(struct osmo_gapk_pq *pq, const struct osmo_gapk_format_desc *fmt, int to_from_n) { - struct pq_item *item; - const struct codec_desc *codec = codec_get_from_type(fmt->codec_type); + const struct osmo_gapk_codec_desc *codec; + struct osmo_gapk_pq_item *item; + codec = osmo_gapk_codec_get_from_type(fmt->codec_type); if (!codec) { fprintf(stderr, "[!] Cannot determine codec from format %s\n", fmt->name); return -EINVAL; } - item = pq_add_item(pq); + item = osmo_gapk_pq_add_item(pq); if (!item) return -ENOMEM; diff --git a/src/pq_rtp.c b/src/pq_rtp.c index d7d924e..b68e84a 100644 --- a/src/pq_rtp.c +++ b/src/pq_rtp.c @@ -192,9 +192,9 @@ pq_cb_rtp_exit(void *_state) } static int -pq_queue_rtp_op(struct pq *pq, int udp_fd, unsigned int blk_len, int in_out_n) +pq_queue_rtp_op(struct osmo_gapk_pq *pq, int udp_fd, unsigned int blk_len, int in_out_n) { - struct pq_item *item; + struct osmo_gapk_pq_item *item; struct pq_state_rtp *state; state = calloc(1, sizeof(struct pq_state_rtp)); @@ -217,7 +217,7 @@ pq_queue_rtp_op(struct pq *pq, int udp_fd, unsigned int blk_len, int in_out_n) state->payload_type = RTP_PT_GSM_FULL; } - item = pq_add_item(pq); + item = osmo_gapk_pq_add_item(pq); if (!item) { free(state); return -ENOMEM; @@ -239,7 +239,7 @@ pq_queue_rtp_op(struct pq *pq, int udp_fd, unsigned int blk_len, int in_out_n) * \param[in] udp_fd UDP file descriptor for the RTP input * \param[in] blk_len Block Length to read from RTP */ int -pq_queue_rtp_input(struct pq *pq, int udp_fd, unsigned int blk_len) +osmo_gapk_pq_queue_rtp_input(struct osmo_gapk_pq *pq, int udp_fd, unsigned int 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); @@ -251,7 +251,7 @@ pq_queue_rtp_input(struct pq *pq, int udp_fd, unsigned int blk_len) * \param[in] udp_fd UDP file descriptor for the RTP output * \param[in] blk_len Block Length to read from RTP */ int -pq_queue_rtp_output(struct pq *pq, int udp_fd, unsigned int blk_len) +osmo_gapk_pq_queue_rtp_output(struct osmo_gapk_pq *pq, int udp_fd, unsigned int 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); diff --git a/src/procqueue.c b/src/procqueue.c index cba6dbb..f377db1 100644 --- a/src/procqueue.c +++ b/src/procqueue.c @@ -24,16 +24,16 @@ #include <osmocom/gapk/procqueue.h> /* crate a new (empty) processing queue */ -struct pq * -pq_create(void) +struct osmo_gapk_pq * +osmo_gapk_pq_create(void) { - return (struct pq *) calloc(1, sizeof(struct pq)); + return (struct osmo_gapk_pq *) calloc(1, sizeof(struct osmo_gapk_pq)); } /*! destroy a processing queue, calls exit() callback of each item * \param[in] pq Processing Queue to be destroyed */ void -pq_destroy(struct pq *pq) +osmo_gapk_pq_destroy(struct osmo_gapk_pq *pq) { int i; @@ -57,10 +57,10 @@ pq_destroy(struct pq *pq) /*! allocate + add an item to a processing queue; return new item * \param[in] pq Processing Queue to which item is added * \returns new PQ item; NULL on error */ -struct pq_item * -pq_add_item(struct pq *pq) +struct osmo_gapk_pq_item * +osmo_gapk_pq_add_item(struct osmo_gapk_pq *pq) { - struct pq_item *item; + struct osmo_gapk_pq_item *item; if (pq->n_items == MAX_PQ_ITEMS) { fprintf(stderr, "[!] Processing Queue cannot handle more than %u items\n", @@ -68,7 +68,7 @@ pq_add_item(struct pq *pq) return NULL; } - item = calloc(1, sizeof(struct pq_item)); + item = calloc(1, sizeof(struct osmo_gapk_pq_item)); if (!item) return NULL; @@ -81,7 +81,7 @@ pq_add_item(struct pq *pq) * \param[in] pq Processing Queue to be prepared * \returns 0 on succcess; negative on error */ int -pq_prepare(struct pq *pq) +osmo_gapk_pq_prepare(struct osmo_gapk_pq *pq) { int i; unsigned int len_prev; @@ -89,7 +89,7 @@ pq_prepare(struct pq *pq) len_prev = 0; for (i=0; i<pq->n_items; i++) { - struct pq_item *item = pq->items[i]; + struct osmo_gapk_pq_item *item = pq->items[i]; if (item->len_in && item->len_in != len_prev) { fprintf(stderr, "[!] PQ item requires input size %u, but previous output is %u\n", @@ -121,7 +121,7 @@ pq_prepare(struct pq *pq) * \param[in] pq Processing Queue to be executed * \returns 0 on success; negative on error (if any item returns negative) */ int -pq_execute(struct pq *pq) +osmo_gapk_pq_execute(struct osmo_gapk_pq *pq) { int i; void *buf_prev, *buf; @@ -132,13 +132,13 @@ pq_execute(struct pq *pq) for (i=0; i<pq->n_items; i++) { int rv; - struct pq_item *item = pq->items[i]; + struct osmo_gapk_pq_item *item = pq->items[i]; buf = i < (pq->n_items-1) ? pq->buffers[i] : NULL; rv = item->proc(item->state, buf, buf_prev, len_prev); if (rv < 0) { - fprintf(stderr, "[!] pq_execute(): abort, item returned %d\n", rv); + fprintf(stderr, "[!] osmo_gapk_pq_execute(): abort, item returned %d\n", rv); return rv; } |