TT#91151 add local codec-accept function

Change-Id: Id718a0c90af9cb952a03c6a961c4904933c02cad
pull/1307/head
Richard Fuchs 5 years ago
parent 7b59f55457
commit 66eff2dbc3

@ -3495,6 +3495,71 @@ void codec_store_accept(struct codec_store *cs, GQueue *accept, struct codec_sto
}
}
int codec_store_accept_one(struct codec_store *cs, GQueue *accept) {
// local codec-accept routine: accept first supported codec, or first from "accept" list
// if given
bool accept_any = false; // also accept unsupported codecs?
struct rtp_payload_type *accept_pt = NULL;
for (GList *l = accept ? accept->head : NULL; l; l = l->next) {
// iterate through list and look for the first supported codec
str *codec = l->data;
if (!str_cmp(codec, "any")) {
accept_any = true;
continue;
}
GQueue *pts = g_hash_table_lookup(cs->codec_names, codec);
if (!pts)
continue;
for (GList *k = pts->head; k; k = k->next) {
int pt_num = GPOINTER_TO_INT(k->data);
struct rtp_payload_type *pt = g_hash_table_lookup(cs->codecs, GINT_TO_POINTER(pt_num));
if (!pt) {
ilogs(codec, LOG_DEBUG, "PT %i missing for accepting " STR_FORMAT, pt_num,
STR_FMT(codec));
continue;
}
accept_pt = pt;
break;
}
if (accept_pt)
break;
}
if (!accept_pt) {
// none found yet - pick the first one
for (GList *l = cs->codec_prefs.head; l; l = l->next) {
struct rtp_payload_type *pt = l->data;
if (!accept_any) {
ensure_codec_def(pt, cs->media);
if (!pt->codec_def)
continue;
}
accept_pt = pt;
break;
}
}
if (!accept_pt) {
ilogs(codec, LOG_WARN, "No acceptable codecs found from publisher");
return -1;
}
// delete all codecs except the accepted one
GList *link = cs->codec_prefs.head;
while (link) {
struct rtp_payload_type *pt = link->data;
if (pt == accept_pt) {
link = link->next;
continue;
}
link = __codec_store_delete_link(link, cs);
}
return 0;
}
void codec_store_track(struct codec_store *cs, GQueue *q) {
#ifdef WITH_TRANSCODING
// just track all codecs from the list as "touched"

@ -92,6 +92,7 @@ void codec_store_add_raw(struct codec_store *cs, struct rtp_payload_type *pt);
void codec_store_strip(struct codec_store *, GQueue *strip, GHashTable *except);
void codec_store_offer(struct codec_store *, GQueue *, struct codec_store *);
void codec_store_accept(struct codec_store *, GQueue *, struct codec_store *);
int codec_store_accept_one(struct codec_store *, GQueue *);
void codec_store_track(struct codec_store *, GQueue *);
void codec_store_transcode(struct codec_store *, GQueue *, struct codec_store *);
void codec_store_answer(struct codec_store *dst, struct codec_store *src, struct sdp_ng_flags *flags);

Loading…
Cancel
Save