diff --git a/daemon/codec.c b/daemon/codec.c index a65d9a4cd..ad3c98737 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -2171,7 +2171,7 @@ struct rtp_payload_type *codec_make_payload_type(const str *codec_str, enum medi void codec_init_payload_type(struct rtp_payload_type *pt, enum media_type type) { #ifdef WITH_TRANSCODING ensure_codec_def_type(pt, type); - const codec_def_t *def = pt->codec_def; + codec_def_t *def = pt->codec_def; if (def) { if (!pt->clock_rate) diff --git a/lib/codeclib.c b/lib/codeclib.c index 2fe88e7ad..ba0c4eb2f 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -57,7 +57,7 @@ static set_enc_options_f amr_set_enc_options; static set_dec_options_f amr_set_dec_options; static format_cmp_f amr_format_cmp; -static void avc_def_init(codec_def_t *); +static void avc_def_init(struct codec_def_s *); static const char *avc_decoder_init(decoder_t *, const str *); static int avc_decoder_input(decoder_t *dec, const str *data, GQueue *out); static void avc_decoder_close(decoder_t *); @@ -110,7 +110,7 @@ static void (*evs_amr_dec_out)(void *, void *); static void (*evs_syn_output)(float *in, const uint16_t len, uint16_t *out); static void (*evs_reset_enc_ind)(void *); -static void evs_def_init(codec_def_t *); +static void evs_def_init(struct codec_def_s *); static const char *evs_decoder_init(decoder_t *, const str *); static int evs_decoder_input(decoder_t *dec, const str *data, GQueue *out); static void evs_decoder_close(decoder_t *); @@ -137,7 +137,6 @@ static const codec_type_t codec_type_avcodec = { .encoder_close = avc_encoder_close, }; static const codec_type_t codec_type_libopus = { - //.def_init = avc_def_init, .decoder_init = libopus_decoder_init, .decoder_input = libopus_decoder_input, .decoder_close = libopus_decoder_close, @@ -207,7 +206,7 @@ static const dtx_method_t dtx_method_evs = { #ifdef HAVE_BCG729 static packetizer_f packetizer_g729; // aggregate some frames into packets -static void bcg729_def_init(codec_def_t *); +static void bcg729_def_init(struct codec_def_s *); static const char *bcg729_decoder_init(decoder_t *, const str *); static int bcg729_decoder_input(decoder_t *dec, const str *data, GQueue *out); static void bcg729_decoder_close(decoder_t *); @@ -228,7 +227,7 @@ static const codec_type_t codec_type_bcg729 = { -static codec_def_t __codec_defs[] = { +static struct codec_def_s __codec_defs[] = { { .rtpname = "PCMA", .avcodec_id = AV_CODEC_ID_PCM_ALAW, @@ -672,7 +671,7 @@ static GHashTable *codecs_ht_by_av; -const codec_def_t *codec_find(const str *name, enum media_type type) { +codec_def_t *codec_find(const str *name, enum media_type type) { codec_def_t *ret = g_hash_table_lookup(codecs_ht, name); if (!ret) return NULL; @@ -681,7 +680,7 @@ const codec_def_t *codec_find(const str *name, enum media_type type) { return ret; } -const codec_def_t *codec_find_by_av(enum AVCodecID id) { +codec_def_t *codec_find_by_av(enum AVCodecID id) { return g_hash_table_lookup(codecs_ht_by_av, GINT_TO_POINTER(id)); } @@ -720,13 +719,13 @@ static const char *avc_decoder_init(decoder_t *dec, const str *extra_opts) { -decoder_t *decoder_new_fmt(const codec_def_t *def, int clockrate, int channels, int ptime, +decoder_t *decoder_new_fmt(codec_def_t *def, int clockrate, int channels, int ptime, const format_t *resample_fmt) { return decoder_new_fmtp(def, clockrate, channels, ptime, resample_fmt, NULL, NULL, NULL); } -int codec_parse_fmtp(const codec_def_t *def, struct rtp_codec_format *fmtp, const str *fmtp_string, +int codec_parse_fmtp(codec_def_t *def, struct rtp_codec_format *fmtp, const str *fmtp_string, union codec_format_options *copy) { struct rtp_codec_format fmtp_store; @@ -758,7 +757,7 @@ int codec_parse_fmtp(const codec_def_t *def, struct rtp_codec_format *fmtp, cons return ret; } -decoder_t *decoder_new_fmtp(const codec_def_t *def, int clockrate, int channels, int ptime, +decoder_t *decoder_new_fmtp(codec_def_t *def, int clockrate, int channels, int ptime, const format_t *resample_fmt, struct rtp_codec_format *fmtp, const str *fmtp_string, const str *extra_opts) @@ -1101,7 +1100,7 @@ static void avlog_ilog(void *ptr, int loglevel, const char *fmt, va_list ap) { } -static void avc_def_init(codec_def_t *def) { +static void avc_def_init(struct codec_def_s *def) { // look up AVCodec structs if (def->avcodec_name_enc) def->encoder = avcodec_find_encoder_by_name(def->avcodec_name_enc); @@ -1146,7 +1145,7 @@ void codeclib_init(int print) { for (int i = 0; i < G_N_ELEMENTS(__codec_defs); i++) { // add to hash table - codec_def_t *def = &__codec_defs[i]; + struct codec_def_s *def = &__codec_defs[i]; str_init(&def->rtpname_str, (char *) def->rtpname); assert(g_hash_table_lookup(codecs_ht, &def->rtpname_str) == NULL); g_hash_table_insert(codecs_ht, &def->rtpname_str, def); @@ -1430,14 +1429,14 @@ static const char *avc_encoder_init(encoder_t *enc, const str *extra_opts) { return NULL; } -int encoder_config(encoder_t *enc, const codec_def_t *def, int bitrate, int ptime, +int encoder_config(encoder_t *enc, codec_def_t *def, int bitrate, int ptime, const format_t *requested_format, format_t *actual_format) { return encoder_config_fmtp(enc, def, bitrate, ptime, NULL, requested_format, actual_format, NULL, NULL, NULL); } -int encoder_config_fmtp(encoder_t *enc, const codec_def_t *def, int bitrate, int ptime, +int encoder_config_fmtp(encoder_t *enc, codec_def_t *def, int bitrate, int ptime, const format_t *input_format, const format_t *requested_format_p, format_t *actual_format, struct rtp_codec_format *fmtp, const str *fmtp_string, @@ -2280,7 +2279,7 @@ static int amr_format_parse(struct rtp_codec_format *f, const str *fmtp) { codeclib_key_value_parse(fmtp, true, amr_parse_format_cb, f); return 0; } -static void amr_set_encdec_options(codec_options_t *opts, const codec_def_t *def) { +static void amr_set_encdec_options(codec_options_t *opts, codec_def_t *def) { if (!strcmp(def->rtpname, "AMR")) { opts->amr.bits_per_frame = amr_bits_per_frame; opts->amr.bitrates = amr_bitrates; @@ -2839,7 +2838,7 @@ static void generic_cn_dtx_cleanup(decoder_t *dec) { #ifdef HAVE_BCG729 -static void bcg729_def_init(codec_def_t *def) { +static void bcg729_def_init(struct codec_def_s *def) { // test init bcg729EncoderChannelContextStruct *e = initBcg729EncoderChannel(0); bcg729DecoderChannelContextStruct *d = initBcg729DecoderChannel(); @@ -4313,7 +4312,7 @@ err: evs_lib_handle = NULL; } -static void evs_def_init(codec_def_t *def) { +static void evs_def_init(struct codec_def_s *def) { evs_load_so(rtpe_common_config_ptr->evs_lib_path); if (evs_lib_handle) { diff --git a/lib/codeclib.h b/lib/codeclib.h index 363315931..f540ce4b1 100644 --- a/lib/codeclib.h +++ b/lib/codeclib.h @@ -4,7 +4,7 @@ struct codec_def_s; struct packet_sequencer_s; -typedef struct codec_def_s codec_def_t; +typedef const struct codec_def_s codec_def_t; typedef struct packet_sequencer_s packet_sequencer_t; struct rtp_payload_type; @@ -95,7 +95,7 @@ typedef void format_answer_f(struct rtp_payload_type *); struct codec_type_s { - void (*def_init)(codec_def_t *); + void (*def_init)(struct codec_def_s *); const char *(*decoder_init)(decoder_t *, const str *); int (*decoder_input)(decoder_t *, const str *data, GQueue *); @@ -238,7 +238,7 @@ struct dtx_method_s { }; struct decoder_s { - const codec_def_t *def; + codec_def_t *def; struct fraction clockrate_fact; codec_options_t codec_options; union codec_format_options format_options; @@ -288,7 +288,7 @@ struct encoder_s { input_format, actual_format; - const codec_def_t *def; + codec_def_t *def; struct fraction clockrate_fact; codec_options_t codec_options; encoder_callback_t callback; @@ -350,15 +350,15 @@ void codeclib_init(int); void codeclib_free(void); -const codec_def_t *codec_find(const str *name, enum media_type); -const codec_def_t *codec_find_by_av(enum AVCodecID); +codec_def_t *codec_find(const str *name, enum media_type); +codec_def_t *codec_find_by_av(enum AVCodecID); -int codec_parse_fmtp(const codec_def_t *def, struct rtp_codec_format *fmtp, const str *fmtp_string, +int codec_parse_fmtp(codec_def_t *def, struct rtp_codec_format *fmtp, const str *fmtp_string, union codec_format_options *copy); -decoder_t *decoder_new_fmt(const codec_def_t *def, int clockrate, int channels, int ptime, +decoder_t *decoder_new_fmt(codec_def_t *def, int clockrate, int channels, int ptime, const format_t *resample_fmt); -decoder_t *decoder_new_fmtp(const codec_def_t *def, int clockrate, int channels, int ptime, +decoder_t *decoder_new_fmtp(codec_def_t *def, int clockrate, int channels, int ptime, const format_t *resample_fmt, struct rtp_codec_format *fmtp, const str *fmtp_string, const str *codec_opts); void decoder_close(decoder_t *dec); @@ -374,9 +374,9 @@ int decoder_dtx(decoder_t *dec, unsigned long ts, int ptime, encoder_t *encoder_new(void); -int encoder_config(encoder_t *enc, const codec_def_t *def, int bitrate, int ptime, +int encoder_config(encoder_t *enc, codec_def_t *def, int bitrate, int ptime, const format_t *requested_format, format_t *actual_format); -int encoder_config_fmtp(encoder_t *enc, const codec_def_t *def, int bitrate, int ptime, +int encoder_config_fmtp(encoder_t *enc, codec_def_t *def, int bitrate, int ptime, const format_t *input_format, const format_t *requested_format, format_t *actual_format, struct rtp_codec_format *fmtp, const str *fmtp_string, const str *codec_opts); @@ -462,7 +462,7 @@ INLINE void codeclib_free(void) { ; } -INLINE const codec_def_t *codec_find(const str *name, enum media_type type) { +INLINE codec_def_t *codec_find(const str *name, enum media_type type) { return NULL; } INLINE void packet_sequencer_destroy(packet_sequencer_t *p) { diff --git a/lib/rtplib.h b/lib/rtplib.h index 582c1b686..898409015 100644 --- a/lib/rtplib.h +++ b/lib/rtplib.h @@ -7,8 +7,7 @@ -struct codec_def_s; -typedef struct codec_def_s codec_def_t; +typedef const struct codec_def_s codec_def_t; struct rtp_header { @@ -89,7 +88,7 @@ struct rtp_payload_type { int ptime; // default from RFC int bitrate; - const codec_def_t *codec_def; + codec_def_t *codec_def; GList *prefs_link; // link in `codec_prefs` list struct rtp_codec_format format; // parsed out fmtp diff --git a/recording-daemon/decoder.c b/recording-daemon/decoder.c index 1ac027f31..55c3ee572 100644 --- a/recording-daemon/decoder.c +++ b/recording-daemon/decoder.c @@ -49,7 +49,7 @@ decode_t *decoder_new(const char *payload_str, const char *format, int ptime, ou channels = 1; } - const codec_def_t *def = codec_find(&name, MT_AUDIO); + codec_def_t *def = codec_find(&name, MT_AUDIO); if (!def) { ilog(LOG_WARN, "No decoder for payload %s", payload_str); return NULL; diff --git a/recording-daemon/output.c b/recording-daemon/output.c index 82133d488..a171a41fb 100644 --- a/recording-daemon/output.c +++ b/recording-daemon/output.c @@ -13,7 +13,7 @@ //static int output_codec_id; -static const codec_def_t *output_codec; +static codec_def_t *output_codec; static const char *output_file_format; int mp3_bitrate; diff --git a/t/test-amr-decode.c b/t/test-amr-decode.c index 9e5319641..bd58f9770 100644 --- a/t/test-amr-decode.c +++ b/t/test-amr-decode.c @@ -39,7 +39,7 @@ static void do_test_amr_xx(const char *file, int line, printf("running test %s:%i\n", file, line); str codec_name; str_init(&codec_name, codec); - const codec_def_t *def = codec_find(&codec_name, MT_AUDIO); + codec_def_t *def = codec_find(&codec_name, MT_AUDIO); assert(def); if (!def->support_encoding || !def->support_decoding) { printf("AMR not fully supported - skipping test\n"); diff --git a/t/test-amr-encode.c b/t/test-amr-encode.c index 44d081c8c..75ff2a6f3 100644 --- a/t/test-amr-encode.c +++ b/t/test-amr-encode.c @@ -49,7 +49,7 @@ static void do_test_amr_xx(const char *file, int line, printf("running test %s:%i\n", file, line); str codec_name; str_init(&codec_name, codec); - const codec_def_t *def = codec_find(&codec_name, MT_AUDIO); + codec_def_t *def = codec_find(&codec_name, MT_AUDIO); assert(def); if (!def->support_encoding || !def->support_decoding) { printf("AMR not fully supported - skipping test\n"); diff --git a/t/test-transcode.c b/t/test-transcode.c index 6bc23dfa8..9ccf8193d 100644 --- a/t/test-transcode.c +++ b/t/test-transcode.c @@ -522,7 +522,7 @@ int main(void) { #ifdef WITH_AMR_TESTS { str codec_name = STR_CONST_INIT("AMR-WB"); - const codec_def_t *def = codec_find(&codec_name, MT_AUDIO); + codec_def_t *def = codec_find(&codec_name, MT_AUDIO); assert(def); if (def->support_encoding && def->support_decoding) { // forward AMR-WB @@ -592,7 +592,7 @@ int main(void) { { str codec_name = STR_CONST_INIT("AMR"); - const codec_def_t *def = codec_find(&codec_name, MT_AUDIO); + codec_def_t *def = codec_find(&codec_name, MT_AUDIO); assert(def); if (def->support_encoding && def->support_decoding) { // default bitrate