*/
+#include "ortp/port.h"
#include "ortp/b64.h"
#include "ortp/ortp_srtp.h"
#include "sal.h"
#include <eXosip2/eXosip.h>
-#define keywordcmp(key,b) strncmp(key,b,sizeof(key))
+#define keywordcmp(key,b) strcmp(key,b)
#ifdef FOR_LATER
rtcp_addr=desc->rtcp_addr;
rtp_port=desc->rtp_port;
rtcp_port=desc->rtcp_port;
- if (desc->candidates[0].addr[0]!='\0'){
- rtp_addr=desc->candidates[0].addr;
- rtp_port=desc->candidates[0].port;
- }
if (desc->proto == SalProtoRtpSavp) {
int i;
if (desc->ice_mismatch == TRUE) {
sdp_message_a_attribute_add(msg, lineno, osip_strdup("ice-mismatch"), NULL);
} else {
- if (desc->ice_pwd[0] != '\0') sdp_message_a_attribute_add(msg, lineno, osip_strdup("ice-pwd"), osip_strdup(desc->ice_pwd));
- if (desc->ice_ufrag[0] != '\0') sdp_message_a_attribute_add(msg, lineno, osip_strdup("ice-ufrag"), osip_strdup(desc->ice_ufrag));
- add_ice_candidates(msg, lineno, desc);
- add_ice_remote_candidates(msg, lineno, desc);
+ if (desc->rtp_port != 0) {
+ if (desc->ice_pwd[0] != '\0') sdp_message_a_attribute_add(msg, lineno, osip_strdup("ice-pwd"), osip_strdup(desc->ice_pwd));
+ if (desc->ice_ufrag[0] != '\0') sdp_message_a_attribute_add(msg, lineno, osip_strdup("ice-ufrag"), osip_strdup(desc->ice_ufrag));
+ add_ice_candidates(msg, lineno, desc);
+ add_ice_remote_candidates(msg, lineno, desc);
+ }
}
}
sdp_message_t *media_description_to_sdp(const SalMediaDescription *desc){
int i;
sdp_message_t *msg=create_generic_sdp(desc);
- for(i=0;i<desc->nstreams;++i){
+ for(i=0;i<desc->n_total_streams;++i){
add_line(msg,i,&desc->streams[i]);
}
return msg;
int sdp_to_media_description(sdp_message_t *msg, SalMediaDescription *desc){
int i,j;
const char *mtype,*proto,*rtp_port,*rtp_addr,*number;
+ const char *sess;
sdp_bandwidth_t *sbw=NULL;
sdp_attribute_t *attr;
int nb_ice_candidates;
+ /* Get session information. */
+ sess = sdp_message_o_sess_id_get(msg);
+ if (sess) desc->session_id = strtoul(sess, NULL, 10);
+ sess = sdp_message_o_sess_version_get(msg);
+ if (sess) desc->session_ver = strtoul(sess, NULL, 10);
+
rtp_addr=sdp_message_c_addr_get (msg, -1, 0);
if (rtp_addr)
strncpy(desc->addr,rtp_addr,sizeof(desc->addr));
}
}
+ desc->n_active_streams = 0;
+
/* for each m= line */
for (i=0; !sdp_message_endof_media (msg, i) && i<SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++)
{
strncpy(stream->rtp_addr,rtp_addr,sizeof(stream->rtp_addr));
if (rtp_port)
stream->rtp_port=atoi(rtp_port);
+ if (stream->rtp_port > 0)
+ desc->n_active_streams++;
stream->ptime=_sdp_message_get_a_ptime(msg,i);
if (strcasecmp("audio", mtype) == 0){
/* Get media specific RTCP attribute */
stream->rtcp_port = stream->rtp_port + 1;
- snprintf(stream->rtcp_addr, sizeof(stream->rtcp_addr), stream->rtp_addr);
+ snprintf(stream->rtcp_addr, sizeof(stream->rtcp_addr), "%s", stream->rtp_addr);
for (j = 0; ((attr = sdp_message_attribute_get(msg, i, j)) != NULL); j++) {
if ((keywordcmp("rtcp", attr->a_att_field) == 0) && (attr->a_att_value != NULL)) {
char tmp[256];
for (k=0;valid_count < SAL_CRYPTO_ALGO_MAX && (attr=sdp_message_attribute_get(msg,i,k))!=NULL;k++){
char tmp[256], tmp2[256];
if (keywordcmp("crypto",attr->a_att_field)==0 && attr->a_att_value!=NULL){
- int nb = sscanf(attr->a_att_value, "%d %256s inline:%256s",
+ int nb = sscanf(attr->a_att_value, "%d %255s inline:%255s",
&stream->crypto[valid_count].tag,
tmp,
tmp2);
}
}
}
- desc->nstreams=i;
+ desc->n_total_streams=i;
return 0;
}