Browse Source

MT#55283 use typed GQueue for sdp_media

Change-Id: I0c6fd4ff3c2135817e79fce6ce34a6750bcf27e6
pull/1776/head
Richard Fuchs 2 years ago
parent
commit
a97a49189d
1 changed files with 12 additions and 12 deletions
  1. +12
    -12
      daemon/sdp.c

+ 12
- 12
daemon/sdp.c View File

@ -52,6 +52,8 @@ struct sdp_attributes {
GHashTable *id_hash; GHashTable *id_hash;
}; };
TYPED_GQUEUE(sdp_media, struct sdp_media)
struct sdp_session { struct sdp_session {
str s; str s;
struct sdp_origin origin; struct sdp_origin origin;
@ -59,7 +61,7 @@ struct sdp_session {
struct sdp_connection connection; struct sdp_connection connection;
int rr, rs; int rr, rs;
struct sdp_attributes attributes; struct sdp_attributes attributes;
GQueue media_streams;
sdp_media_q media_streams;
}; };
struct sdp_media { struct sdp_media {
@ -1267,7 +1269,7 @@ int sdp_parse(str *body, sdp_sessions_q *sessions, const sdp_ng_flags *flags) {
new_session: new_session:
session = g_slice_alloc0(sizeof(*session)); session = g_slice_alloc0(sizeof(*session));
g_queue_init(&session->media_streams);
t_queue_init(&session->media_streams);
attrs_init(&session->attributes); attrs_init(&session->attributes);
t_queue_push_tail(sessions, session); t_queue_push_tail(sessions, session);
media = NULL; media = NULL;
@ -1296,7 +1298,7 @@ new_session:
errstr = "Error parsing m= line"; errstr = "Error parsing m= line";
if (parse_media(&value_str, media)) if (parse_media(&value_str, media))
goto error; goto error;
g_queue_push_tail(&session->media_streams, media);
t_queue_push_tail(&session->media_streams, media);
media->s.s = b; media->s.s = b;
media->rr = media->rs = -1; media->rr = media->rs = -1;
@ -1401,14 +1403,13 @@ static void free_attributes(struct sdp_attributes *a) {
g_hash_table_destroy(a->id_lists_hash); g_hash_table_destroy(a->id_lists_hash);
g_queue_clear_full(&a->list, attr_free); g_queue_clear_full(&a->list, attr_free);
} }
static void media_free(void *p) {
struct sdp_media *media = p;
static void media_free(struct sdp_media *media) {
free_attributes(&media->attributes); free_attributes(&media->attributes);
g_queue_clear_full(&media->format_list, str_slice_free); g_queue_clear_full(&media->format_list, str_slice_free);
g_slice_free1(sizeof(*media), media); g_slice_free1(sizeof(*media), media);
} }
static void session_free(struct sdp_session *session) { static void session_free(struct sdp_session *session) {
g_queue_clear_full(&session->media_streams, media_free);
t_queue_clear_full(&session->media_streams, media_free);
free_attributes(&session->attributes); free_attributes(&session->attributes);
g_slice_free1(sizeof(*session), session); g_slice_free1(sizeof(*session), session);
} }
@ -1666,7 +1667,7 @@ static void sp_free(struct stream_params *s) {
// the indexing to be in order and instead of requiring all sections between monologue and sdp_media // the indexing to be in order and instead of requiring all sections between monologue and sdp_media
// lists to be matching. // lists to be matching.
// returns: discard this `sp` yes/no // returns: discard this `sp` yes/no
static bool legacy_osrtp_accept(struct stream_params *sp, sdp_streams_q *streams, GList *media_link,
static bool legacy_osrtp_accept(struct stream_params *sp, sdp_streams_q *streams, sdp_media_list *media_link,
sdp_ng_flags *flags, unsigned int *num) sdp_ng_flags *flags, unsigned int *num)
{ {
if (!streams->tail) if (!streams->tail)
@ -1740,7 +1741,6 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
struct sdp_session *session; struct sdp_session *session;
struct sdp_media *media; struct sdp_media *media;
struct stream_params *sp; struct stream_params *sp;
GList *k;
const char *errstr; const char *errstr;
unsigned int num = 0; unsigned int num = 0;
struct sdp_attribute *attr; struct sdp_attribute *attr;
@ -1749,7 +1749,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
for (__auto_type l = sessions->head; l; l = l->next) { for (__auto_type l = sessions->head; l; l = l->next) {
session = l->data; session = l->data;
for (k = session->media_streams.head; k; k = k->next) {
for (__auto_type k = session->media_streams.head; k; k = k->next) {
media = k->data; media = k->data;
sp = g_slice_alloc0(sizeof(*sp)); sp = g_slice_alloc0(sizeof(*sp));
@ -3206,7 +3206,7 @@ int sdp_replace(struct sdp_chopper *chop, sdp_sessions_q *sessions, struct call_
{ {
struct sdp_session *session; struct sdp_session *session;
struct sdp_media *sdp_media; struct sdp_media *sdp_media;
GList *k, *rtp_ps_link;
GList *rtp_ps_link;
int sess_conn; int sess_conn;
struct call_media *call_media; struct call_media *call_media;
struct packet_stream *ps; struct packet_stream *ps;
@ -3279,7 +3279,7 @@ int sdp_replace(struct sdp_chopper *chop, sdp_sessions_q *sessions, struct call_
if (flags->replace_sess_conn) if (flags->replace_sess_conn)
sess_conn = 1; sess_conn = 1;
else { else {
for (k = session->media_streams.head; k; k = k->next) {
for (__auto_type k = session->media_streams.head; k; k = k->next) {
sdp_media = k->data; sdp_media = k->data;
if (!sdp_media->connection.parsed) { if (!sdp_media->connection.parsed) {
sess_conn = 1; sess_conn = 1;
@ -3314,7 +3314,7 @@ int sdp_replace(struct sdp_chopper *chop, sdp_sessions_q *sessions, struct call_
struct sdp_manipulations *sdp_manipulations = sdp_manipulations_get_by_id(flags, MT_UNKNOWN); struct sdp_manipulations *sdp_manipulations = sdp_manipulations_get_by_id(flags, MT_UNKNOWN);
sdp_manipulations_add(chop, sdp_manipulations); sdp_manipulations_add(chop, sdp_manipulations);
for (k = session->media_streams.head; k; k = k->next) {
for (__auto_type k = session->media_streams.head; k; k = k->next) {
sdp_media = k->data; sdp_media = k->data;
// skip over received dummy SDP sections // skip over received dummy SDP sections


Loading…
Cancel
Save