MT#61368 change media_ids to typed hash table

Change-Id: I53e40d80d813eeee3edaebe557b3aa5c9e5b5733
pull/1884/head
Richard Fuchs 5 months ago
parent 67141a517b
commit 2a46eb2cdc

@ -682,7 +682,7 @@ static struct call_media *__get_media(struct call_monologue *ml, const struct st
if (sp->media_id.len) { if (sp->media_id.len) {
// in this case, the media sections can be out of order and the media ID // in this case, the media sections can be out of order and the media ID
// string is used to determine which media section to operate on. // string is used to determine which media section to operate on.
med = g_hash_table_lookup(ml->media_ids, &sp->media_id); med = t_hash_table_lookup(ml->media_ids, &sp->media_id);
if (med) { if (med) {
if (med->type_id == sp->type_id) if (med->type_id == sp->type_id)
return med; return med;
@ -2253,7 +2253,7 @@ static void __update_media_id(struct call_media *media, struct call_media *other
if (sp->media_id.s) if (sp->media_id.s)
other_media->media_id = call_str_cpy(&sp->media_id); other_media->media_id = call_str_cpy(&sp->media_id);
if (other_media->media_id.s) if (other_media->media_id.s)
g_hash_table_insert(other_ml->media_ids, &other_media->media_id, t_hash_table_insert(other_ml->media_ids, &other_media->media_id,
other_media); other_media);
} }
else { else {
@ -2262,9 +2262,9 @@ static void __update_media_id(struct call_media *media, struct call_media *other
if (sp->media_id.s) { if (sp->media_id.s) {
if (str_cmp_str(&other_media->media_id, &sp->media_id)) { if (str_cmp_str(&other_media->media_id, &sp->media_id)) {
// mismatch - update // mismatch - update
g_hash_table_remove(other_ml->media_ids, &other_media->media_id); t_hash_table_remove(other_ml->media_ids, &other_media->media_id);
other_media->media_id = call_str_cpy(&sp->media_id); other_media->media_id = call_str_cpy(&sp->media_id);
g_hash_table_insert(other_ml->media_ids, &other_media->media_id, t_hash_table_insert(other_ml->media_ids, &other_media->media_id,
other_media); other_media);
} }
} }
@ -2285,7 +2285,7 @@ static void __update_media_id(struct call_media *media, struct call_media *other
media->media_id = call_str_cpy_c(buf); media->media_id = call_str_cpy_c(buf);
} }
if (media->media_id.s) if (media->media_id.s)
g_hash_table_insert(ml->media_ids, &media->media_id, media); t_hash_table_insert(ml->media_ids, &media->media_id, media);
} }
else { else {
// we already have a media ID. keep what we have and ignore what's // we already have a media ID. keep what we have and ignore what's
@ -4113,7 +4113,7 @@ void call_media_free(struct call_media **mdp) {
void __monologue_free(struct call_monologue *m) { void __monologue_free(struct call_monologue *m) {
t_ptr_array_free(m->medias, true); t_ptr_array_free(m->medias, true);
g_hash_table_destroy(m->associated_tags); g_hash_table_destroy(m->associated_tags);
g_hash_table_destroy(m->media_ids); t_hash_table_destroy(m->media_ids);
free_ssrc_hash(&m->ssrc_hash); free_ssrc_hash(&m->ssrc_hash);
if (m->last_out_sdp) if (m->last_out_sdp)
g_string_free(m->last_out_sdp, TRUE); g_string_free(m->last_out_sdp, TRUE);
@ -4335,7 +4335,7 @@ struct call_monologue *__monologue_create(call_t *call) {
ret->created = rtpe_now.tv_sec; ret->created = rtpe_now.tv_sec;
ret->associated_tags = g_hash_table_new(g_direct_hash, g_direct_equal); ret->associated_tags = g_hash_table_new(g_direct_hash, g_direct_equal);
ret->medias = medias_arr_new(); ret->medias = medias_arr_new();
ret->media_ids = g_hash_table_new((GHashFunc) str_hash, (GEqualFunc) str_equal); ret->media_ids = media_id_ht_new();
ret->ssrc_hash = create_ssrc_hash_call(); ret->ssrc_hash = create_ssrc_hash_call();
ret->sdp_attr_print = sdp_insert_monologue_attributes; ret->sdp_attr_print = sdp_insert_monologue_attributes;
/* explicitely set b=RR/b=RS to -1 so it's not considered as 0 inadvertently */ /* explicitely set b=RR/b=RS to -1 so it's not considered as 0 inadvertently */

@ -95,7 +95,7 @@ static void ice_update_media_streams(struct call_monologue *ml, sdp_streams_q *s
struct call_media *media = NULL; struct call_media *media = NULL;
if (sp->media_id.len) if (sp->media_id.len)
media = g_hash_table_lookup(ml->media_ids, &sp->media_id); media = t_hash_table_lookup(ml->media_ids, &sp->media_id);
else if (sp->index > 0) { else if (sp->index > 0) {
unsigned int arr_idx = sp->index - 1; unsigned int arr_idx = sp->index - 1;
if (arr_idx < ml->medias->len) if (arr_idx < ml->medias->len)

@ -1916,7 +1916,7 @@ static int json_link_medias(call_t *c, struct redis_list *medias,
return -1; return -1;
if (med->media_id.s) if (med->media_id.s)
g_hash_table_insert(med->monologue->media_ids, &med->media_id, med); t_hash_table_insert(med->monologue->media_ids, &med->media_id, med);
/* find the pair media to subscribe */ /* find the pair media to subscribe */
if (!json_build_list_cb(NULL, c, "media-subscriptions", med->unique_id, if (!json_build_list_cb(NULL, c, "media-subscriptions", med->unique_id,

@ -328,6 +328,7 @@ TYPED_GQUEUE(subscription, struct media_subscription)
TYPED_DIRECT_FUNCS(media_direct_hash, media_direct_eq, struct call_media) TYPED_DIRECT_FUNCS(media_direct_hash, media_direct_eq, struct call_media)
TYPED_GHASHTABLE(subscription_ht, struct call_media, subscription_list, media_direct_hash, media_direct_eq, TYPED_GHASHTABLE(subscription_ht, struct call_media, subscription_list, media_direct_hash, media_direct_eq,
NULL, NULL) NULL, NULL)
TYPED_GHASHTABLE(media_id_ht, str, struct call_media, str_hash, str_equal, NULL, NULL)
struct session_bandwidth { struct session_bandwidth {
long as, rr, rs, ct, tias; long as, rr, rs, ct, tias;
@ -587,7 +588,7 @@ struct call_monologue {
GHashTable *associated_tags; GHashTable *associated_tags;
GHashTable *subscribers_ht; /* for quick lookup */ GHashTable *subscribers_ht; /* for quick lookup */
medias_arr *medias; medias_arr *medias;
GHashTable *media_ids; media_id_ht media_ids;
struct media_player *player; struct media_player *player;
struct media_player *rec_player; struct media_player *rec_player;
struct session_bandwidth sdp_session_bandwidth; struct session_bandwidth sdp_session_bandwidth;

Loading…
Cancel
Save