diff --git a/daemon/audio_player.c b/daemon/audio_player.c index 988c13a68..1ae48e118 100644 --- a/daemon/audio_player.c +++ b/daemon/audio_player.c @@ -116,7 +116,7 @@ bool audio_player_setup(struct call_media *m, const rtp_payload_type *dst_pt, // set everything up - src_pt.codec_def = codec_find_by_av(AV_CODEC_ID_PCM_S16LE), // XXX shortcut this? + src_pt.codec_def = codec_get_pcm16(); mp->run_func = audio_player_run; diff --git a/lib/codeclib.c b/lib/codeclib.c index 83fd05c10..fbbefe949 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -881,6 +881,7 @@ static struct codec_def_s __codec_defs[] = { static GQueue __supplemental_codecs = G_QUEUE_INIT; const GQueue * const codec_supplemental_codecs = &__supplemental_codecs; static codec_def_t *codec_def_cn; +static codec_def_t *codec_def_pcm16; void (*codeclib_thread_init)(void); void (*codeclib_thread_cleanup)(void); @@ -888,11 +889,9 @@ void (*codeclib_thread_loop)(void); TYPED_GHASHTABLE(codecs_by_name, str, struct codec_def_s, str_case_hash, str_case_equal, NULL, NULL) -TYPED_GHASHTABLE(codecs_by_id, void, struct codec_def_s, g_direct_hash, g_direct_equal, NULL, NULL) TYPED_GHASHTABLE(codecs_by_id_alloc, void, struct codec_def_s, g_direct_hash, g_direct_equal, NULL, g_free) static codecs_by_name codecs_ht; -static codecs_by_id codecs_ht_by_av; static rwlock_t generic_ffmpeg_codecs_lock = RWLOCK_STATIC_INIT; static codecs_by_id_alloc generic_ffmpeg_codecs; @@ -908,8 +907,8 @@ codec_def_t *codec_find(const str *name, enum media_type type) { return ret; } -codec_def_t *codec_find_by_av(enum AVCodecID id) { - return t_hash_table_lookup(codecs_ht_by_av, GINT_TO_POINTER(id)); +codec_def_t *codec_get_pcm16(void) { + return codec_def_pcm16; } @@ -1368,7 +1367,6 @@ static void cc_cleanup(void); void codeclib_free(void) { t_hash_table_destroy(codecs_ht); - t_hash_table_destroy(codecs_ht_by_av); t_hash_table_destroy(generic_ffmpeg_codecs); avformat_network_deinit(); cc_cleanup(); @@ -1584,7 +1582,6 @@ void codeclib_init(int print) { av_log_set_callback(avlog_ilog); codecs_ht = codecs_by_name_new(); - codecs_ht_by_av = codecs_by_id_new(); generic_ffmpeg_codecs = codecs_by_id_alloc_new(); cc_init(); @@ -1596,11 +1593,6 @@ void codeclib_init(int print) { assert(t_hash_table_lookup(codecs_ht, &def->rtpname_str) == NULL); t_hash_table_insert(codecs_ht, &def->rtpname_str, def); - if (def->avcodec_id >= 0) { - if (t_hash_table_lookup(codecs_ht_by_av, GINT_TO_POINTER(def->avcodec_id)) == NULL) - t_hash_table_insert(codecs_ht_by_av, GINT_TO_POINTER(def->avcodec_id), def); - } - // init undefined member vars if (!def->default_clockrate_fact.mult) def->default_clockrate_fact.mult = 1; @@ -1630,6 +1622,8 @@ void codeclib_init(int print) { if (!strcmp(def->rtpname, "CN")) codec_def_cn = def; + if (def->avcodec_id == AV_CODEC_ID_PCM_S16LE) + codec_def_pcm16 = def; if (print) { if (def->support_encoding && def->support_decoding) { diff --git a/lib/codeclib.h b/lib/codeclib.h index 0c786b1a5..bd33bcd6a 100644 --- a/lib/codeclib.h +++ b/lib/codeclib.h @@ -398,7 +398,7 @@ void codeclib_free(void); bool rtpe_has_cpu_flag(enum rtpe_cpu_flag flag); codec_def_t *codec_find(const str *name, enum media_type); -codec_def_t *codec_find_by_av(enum AVCodecID); +codec_def_t *codec_get_pcm16(void); bool codec_parse_fmtp(codec_def_t *def, struct rtp_codec_format *fmtp, const str *fmtp_string, union codec_format_options *copy);