Browse Source

change the sdp attribute lists/hashes around a bit

git.mgm/mediaproxy-ng/github/master
Richard Fuchs 13 years ago
parent
commit
e87787af11
1 changed files with 25 additions and 15 deletions
  1. +25
    -15
      daemon/sdp.c

+ 25
- 15
daemon/sdp.c View File

@ -34,8 +34,9 @@ struct sdp_connection {
struct sdp_attributes { struct sdp_attributes {
GQueue list; GQueue list;
GHashTable *name_hash;
GHashTable *lists_hash;
/* GHashTable *name_hash; */
/* GHashTable *name_lists_hash; */
GHashTable *id_lists_hash;
GHashTable *id_hash; GHashTable *id_hash;
}; };
@ -281,9 +282,11 @@ static int parse_media(char *start, char *end, struct sdp_media *output) {
static void attrs_init(struct sdp_attributes *a) { static void attrs_init(struct sdp_attributes *a) {
g_queue_init(&a->list); g_queue_init(&a->list);
a->name_hash = g_hash_table_new(str_hash, str_equal);
/* a->name_hash = g_hash_table_new(str_hash, str_equal); */
a->id_hash = g_hash_table_new(g_int_hash, g_int_equal); a->id_hash = g_hash_table_new(g_int_hash, g_int_equal);
a->lists_hash = g_hash_table_new_full(str_hash, str_equal,
/* a->name_lists_hash = g_hash_table_new_full(str_hash, str_equal,
NULL, (GDestroyNotify) g_queue_free); */
a->id_lists_hash = g_hash_table_new_full(g_int_hash, g_int_equal,
NULL, (GDestroyNotify) g_queue_free); NULL, (GDestroyNotify) g_queue_free);
} }
@ -641,14 +644,20 @@ int sdp_parse(str *body, GQueue *sessions) {
attrs = media ? &media->attributes : &session->attributes; attrs = media ? &media->attributes : &session->attributes;
g_queue_push_tail(&attrs->list, attr); g_queue_push_tail(&attrs->list, attr);
g_hash_table_insert(attrs->name_hash, &attr->name, attr);
g_hash_table_insert(attrs->id_hash, &attr->attr, attr);
if (attr->key.s)
g_hash_table_insert(attrs->name_hash, &attr->key, attr);
/* g_hash_table_insert(attrs->name_hash, &attr->name, attr); */
if (!g_hash_table_lookup(attrs->id_hash, &attr->attr))
g_hash_table_insert(attrs->id_hash, &attr->attr, attr);
/* if (attr->key.s)
g_hash_table_insert(attrs->name_hash, &attr->key, attr); */
attr_queue = g_hash_table_lookup(attrs->lists_hash, &attr->name);
/* attr_queue = g_hash_table_lookup(attrs->name_lists_hash, &attr->name);
if (!attr_queue) if (!attr_queue)
g_hash_table_insert(attrs->lists_hash, &attr->name,
g_hash_table_insert(attrs->name_lists_hash, &attr->name,
(attr_queue = g_queue_new()));
g_queue_push_tail(attr_queue, attr); */
attr_queue = g_hash_table_lookup(attrs->id_lists_hash, &attr->attr);
if (!attr_queue)
g_hash_table_insert(attrs->id_lists_hash, &attr->attr,
(attr_queue = g_queue_new())); (attr_queue = g_queue_new()));
g_queue_push_tail(attr_queue, attr); g_queue_push_tail(attr_queue, attr);
@ -703,9 +712,10 @@ error:
static void free_attributes(struct sdp_attributes *a) { static void free_attributes(struct sdp_attributes *a) {
struct sdp_attribute *attr; struct sdp_attribute *attr;
g_hash_table_destroy(a->name_hash);
/* g_hash_table_destroy(a->name_hash); */
g_hash_table_destroy(a->id_hash); g_hash_table_destroy(a->id_hash);
g_hash_table_destroy(a->lists_hash);
/* g_hash_table_destroy(a->name_lists_hash); */
g_hash_table_destroy(a->id_lists_hash);
while ((attr = g_queue_pop_head(&a->list))) { while ((attr = g_queue_pop_head(&a->list))) {
g_slice_free1(sizeof(*attr), attr); g_slice_free1(sizeof(*attr), attr);
} }
@ -1191,7 +1201,7 @@ static unsigned long prio_calc(unsigned int pref) {
} }
static unsigned long new_priority(struct sdp_media *media) { static unsigned long new_priority(struct sdp_media *media) {
str s;
int id;
GQueue *cands; GQueue *cands;
unsigned int pref; unsigned int pref;
unsigned long prio; unsigned long prio;
@ -1204,8 +1214,8 @@ static unsigned long new_priority(struct sdp_media *media) {
if (!media) if (!media)
goto out; goto out;
str_init(&s, "candidate");
cands = g_hash_table_lookup(media->attributes.lists_hash, &s);
id = ATTR_CANDIDATE;
cands = g_hash_table_lookup(media->attributes.id_lists_hash, &id);
if (!cands) if (!cands)
goto out; goto out;


Loading…
Cancel
Save