Skip to content

Commit

Permalink
clone label attr
Browse files Browse the repository at this point in the history
  • Loading branch information
sorooshm78 committed Dec 22, 2024
1 parent 1bede37 commit e3248f4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
12 changes: 12 additions & 0 deletions pjmedia/include/pjmedia/sdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,18 @@ PJ_DECL(pjmedia_sdp_media*) pjmedia_sdp_media_clone_deactivate(
const pjmedia_sdp_media *rhs);


/**
* Create a=label attribute.
*
* @param pool Pool to create the attribute.
* @param sdp_media The SDP media.
*
* @return SDP label attribute.
*/
PJ_DECL(pjmedia_sdp_attr*) pjmedia_sdp_attr_create_label( pj_pool_t *pool,
pjmedia_sdp_media *sdp_media);


/* **************************************************************************
* SDP SESSION DESCRIPTION
****************************************************************************
Expand Down
20 changes: 20 additions & 0 deletions pjmedia/src/pjmedia/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,26 @@ PJ_DEF(pj_status_t) pjmedia_sdp_attr_get_ssrc(const pjmedia_sdp_attr *attr,
}


PJ_DEF(pjmedia_sdp_attr*) pjmedia_sdp_attr_create_label( pj_pool_t *pool,
pjmedia_sdp_media *sdp_media)
{
pjmedia_sdp_attr *attr;
pjmedia_sdp_attr *cloned_attr;
const pj_str_t STR_LABEL_ATTR = {"label", 5};

attr = pjmedia_sdp_media_find_attr(
sdp_media, &STR_LABEL_ATTR, NULL);

cloned_attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
cloned_attr->name = STR_LABEL_ATTR;
cloned_attr->value.ptr = (char *)pj_pool_alloc(pool, attr->value.slen);
pj_memcpy(cloned_attr->value.ptr, attr->value.ptr, attr->value.slen);
cloned_attr->value.slen = attr->value.slen;

return cloned_attr;
}


PJ_DEF(pjmedia_sdp_attr*) pjmedia_sdp_attr_create_ssrc( pj_pool_t *pool,
pj_uint32_t ssrc,
const pj_str_t *cname)
Expand Down
17 changes: 8 additions & 9 deletions pjsip/src/pjsua-lib/pjsua_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -1953,12 +1953,12 @@ static pj_status_t call_media_init_cb(pjsua_call_media *call_med,
goto on_return;
}

/* Check if media is deinitializing */
if (call_med->call->async_call.med_ch_deinit || !call_med->tp) {
status = PJ_ECANCELLED;
goto on_return;
}

/* Check if media is deinitializing */
if (call_med->call->async_call.med_ch_deinit || !call_med->tp) {
status = PJ_ECANCELLED;
goto on_return;
}

pjmedia_transport_simulate_lost(call_med->tp, PJMEDIA_DIR_ENCODING,
pjsua_var.media_cfg.tx_drop_pct);

Expand Down Expand Up @@ -3007,9 +3007,8 @@ pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
* Get label attribute in SDP offer and add label attribute to SDP answer
*/
if (call->inv && (call->inv->options & PJSIP_INV_REQUIRE_SIPREC)) {
const pj_str_t STR_LABEL_ATTR = {"label", 5};
m->attr[m->attr_count++] = pjmedia_sdp_media_find_attr(
rem_sdp->media[mi], &STR_LABEL_ATTR, NULL);
m->attr[m->attr_count++] = pjmedia_sdp_attr_create_label(pool,
rem_sdp->media[mi]);
}

/* Add ssrc and cname attribute */
Expand Down

0 comments on commit e3248f4

Please sign in to comment.