Browse Source

TT#30901 use hash table to look up RFC specified codecs

Change-Id: I471dc77d0c4bdbdf66dc4b021d77202ec0ddbb39
changes/68/18768/5
Richard Fuchs 8 years ago
parent
commit
71b3762f13
4 changed files with 19 additions and 8 deletions
  1. +9
    -7
      daemon/codec.c
  2. +7
    -0
      lib/codeclib.c
  3. +2
    -0
      lib/codeclib.h
  4. +1
    -1
      lib/rtplib.c

+ 9
- 7
daemon/codec.c View File

@ -622,14 +622,16 @@ static struct rtp_payload_type *codec_make_payload_type(const str *codec, struct
const codec_def_t *dec = codec_find(codec);
if (!dec)
return NULL;
const struct rtp_payload_type *rfc_pt = rtp_get_rfc_codec(codec);
if (!rfc_pt)
return codec_make_dynamic_payload_type(dec, call);
struct rtp_payload_type *ret = __rtp_payload_type_copy(rfc_pt);
ret->codec_def = dec;
if (dec->rfc_payload_type >= 0) {
const struct rtp_payload_type *rfc_pt = rtp_get_rfc_payload_type(dec->rfc_payload_type);
if (rfc_pt) {
struct rtp_payload_type *ret = __rtp_payload_type_copy(rfc_pt);
ret->codec_def = dec;
return ret;
}
}
return codec_make_dynamic_payload_type(dec, call);
return ret;
}


+ 7
- 0
lib/codeclib.c View File

@ -7,6 +7,7 @@
#include "log.h"
#include "loglib.h"
#include "resample.h"
#include "rtplib.h"
@ -556,6 +557,12 @@ void codeclib_init() {
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);
const struct rtp_payload_type *pt = rtp_get_rfc_codec(&def->rtpname_str);
if (pt)
def->rfc_payload_type = pt->payload_type;
else
def->rfc_payload_type = -1;
}
}


+ 2
- 0
lib/codeclib.h View File

@ -40,7 +40,9 @@ struct codec_def_s {
const int default_ptime;
packetizer_f * const packetizer;
const int bits_per_sample;
str rtpname_str;
int rfc_payload_type;
};
struct format_s {


+ 1
- 1
lib/rtplib.c View File

@ -130,7 +130,7 @@ const struct rtp_payload_type *rtp_get_rfc_payload_type(unsigned int type) {
return rtp_pt;
}
// XXX use hash table
// for one-time init only - better use rtp_get_rfc_payload_type(codec_def->rfc_payload_type)
const struct rtp_payload_type *rtp_get_rfc_codec(const str *codec) {
for (int i = 0; i < num_rfc_rtp_payload_types; i++) {
if (!rfc_rtp_payload_types[i].encoding.s)


Loading…
Cancel
Save