|
Hi Vadim, I've made some changes on negotiation methods and I would like to know whether you agree with them. The point was to fix your appointments below: 1- "ptime attrirbute should be not per negotioation but per media"; and 2- "mode attribute should be defined per payload". Please let me know if you are confortable with this new implementation. Thanks, best regards and we talk again in 2009! Mauro. Vadim Lebedev escreveu: Mauro, --
|
/*
* @param attr_name Name of local and remote SDP's field that will be
compared.
* @param local_attr_value Value of local SDP field.
* @param remote_attr_value Value of remote SDP field.
* Return:
* -1 : indicates remote attrib don't need to be added to local SDP;
* 0 : indicates remote attrib must be added to local SDP;
* 1 : indicates remote attrib must replace the one on local SDP;
*/
static int
osip_negotiation_execute_attrib_negotiation(char *attr_name, char
*local_attr_value, char *remote_attr_value)
{
int max_cmp_size = 0;
if (strcmp(attr_name, "fmtp") == 0)
{
char* local_mode_str = NULL;
char* remote_mode_str = NULL;
if ( ((local_mode_str = strstr(local_attr_value, " mode=")) != NULL) &&
((remote_mode_str = strstr(remote_attr_value, " mode=")) != NULL) )
{
int local_mode = 0;
int remote_mode = 0;
sscanf(local_attr_value, " mode=\"%d\"", &local_mode);
sscanf(remote_attr_value, " mode=\"%d\"", &remote_mode);
if (remote_mode > local_mode)
{
return 1;
}
}
}
return -1;
}
static void
osip_negotiation_execute_media_negotiation(sdp_message_t *local,
sdp_media_t *local_media,
int local_media_index,
sdp_message_t *remote,
int bIsIncomingCall)
{
sdp_attribute_t *remote_attrib = NULL;
sdp_attribute_t *local_attrib = NULL;
int attrib_index = 0;
int remote_media_pos = -1;
int bAddAttrib = 0;
int bIncIndex = 1;
int iAttribRet;
char *payload_id = NULL;
remote_media_pos = sdp_message_get_media_pos(
remote, local_media->m_media, payload_id);
if (remote_media_pos != -1)
{
while ((remote_attrib = sdp_message_attribute_get(
remote, remote_media_pos, attrib_index)) != NULL)
{
// Negotiation involves only packetization attributes and
// parameters.
//
if (strcmp(remote_attrib->a_att_field, "ptime") == 0)
{
if ((local_attrib = sdp_message_att_find(local, local_media_index,
remote_attrib->a_att_field, NULL)) == NULL)
{
if (bIsIncomingCall)
{
sdp_message_a_attribute_add(local, local_media_index,
osip_strdup(remote_attrib->a_att_field),
osip_strdup(remote_attrib->a_att_value));
}
else
{
sdp_message_a_attribute_add(local, local_media_index,
osip_strdup(remote_attrib->a_att_field),
osip_strdup("20"));
}
}
else
{
sdp_message_a_attribute_add(local, local_media_index,
osip_strdup(remote_attrib->a_att_field),
osip_strdup(remote_attrib->a_att_value));
}
}
if (strcmp(remote_attrib->a_att_field, "fmtp") == 0)
{
// First we get the payload to compare with local existent paylods.
payload_id = osip_strdup(remote_attrib->a_att_value);
payload_id[(int)(strstr(payload_id, " ") - payload_id)] = '\0';
// Now we validate whether local SDP have the payload with which
// this attribute is associated.
if (sdp_message_att_find(local,
local_media_index, "rtpmap", payload_id) != NULL)
{
int bAddAttrib = 0;
if ((local_attrib = sdp_message_att_find(local,
local_media_index,
remote_attrib->a_att_field, payload_id)) == NULL)
{
if (strstr(remote_attrib->a_att_value, " mode=") != NULL)
{
bAddAttrib = 1;
}
}
else if ((iAttribRet = osip_negotiation_execute_attrib_negotiation(
remote_attrib->a_att_field, remote_attrib->a_att_value,
local_attrib->a_att_value)) >= 0)
{
bAddAttrib = 1;
if (iAttribRet == 1)
{
sdp_message_a_attribute_del(local,
local_media_index, local_attrib->a_att_field);
}
}
if (bAddAttrib == 1)
{
sdp_message_a_attribute_add(local, local_media_index,
osip_strdup(remote_attrib->a_att_field),
osip_strdup(remote_attrib->a_att_value));
}
}
osip_free(payload_id);
}
attrib_index++;
}
}
}
_______________________________________________ QuteCom-dev mailing list [email protected] http://lists.qutecom.org/mailman/listinfo/qutecom-dev
