Browse Source

MT#55283 simpler lookup for PCM16

Change-Id: Id473485bbd9ce82f18ef03436ae6edb604e139d0
pull/2035/head
Richard Fuchs 1 week ago
parent
commit
11061b483e
3 changed files with 7 additions and 13 deletions
  1. +1
    -1
      daemon/audio_player.c
  2. +5
    -11
      lib/codeclib.c
  3. +1
    -1
      lib/codeclib.h

+ 1
- 1
daemon/audio_player.c View File

@ -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;


+ 5
- 11
lib/codeclib.c View File

@ -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) {


+ 1
- 1
lib/codeclib.h View File

@ -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);


Loading…
Cancel
Save