/** * Returns a media description to run the streams with, based on the local capabilities and * and the received offer. * The returned media description is an answer and should be sent to the offerer. **/ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities, const SalMediaDescription *remote_offer, SalMediaDescription *result, bool_t one_matching_codec) { int i; const SalStreamDescription *ls,*rs; for(i=0; i<remote_offer->nstreams; ++i) { rs=&remote_offer->streams[i]; ms_message("Processing for stream %i",i); ls=sal_media_description_find_stream((SalMediaDescription*)local_capabilities,rs->proto,rs->type); if (ls) { initiate_incoming(ls,rs,&result->streams[i],one_matching_codec); } else { /* create an inactive stream for the answer, as there where no matching stream a local capability */ result->streams[i].dir=SalStreamInactive; result->streams[i].port=0; result->streams[i].type=rs->type; if (rs->type==SalOther) { strncpy(result->streams[i].typeother,rs->typeother,sizeof(rs->typeother)-1); } } } result->nstreams=i; strcpy(result->username, local_capabilities->username); strcpy(result->addr,local_capabilities->addr); result->bandwidth=local_capabilities->bandwidth; result->session_ver=local_capabilities->session_ver; result->session_id=local_capabilities->session_id; return 0; }
/** * Returns a media description to run the streams with, based on the local capabilities and * and the received offer. * The returned media description is an answer and should be sent to the offerer. **/ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities, const SalMediaDescription *remote_offer, SalMediaDescription *result, bool_t one_matching_codec){ int i; const SalStreamDescription *ls=NULL,*rs; for(i=0;i<remote_offer->nstreams;++i){ rs=&remote_offer->streams[i]; if (rs->proto!=SalProtoUnknown){ ls=sal_media_description_find_stream((SalMediaDescription*)local_capabilities,rs->proto,rs->type); /* if matching failed, and remote proposes Avp only, ask for local Savp streams */ if (!ls && rs->proto == SalProtoRtpAvp) { ls=sal_media_description_find_stream((SalMediaDescription*)local_capabilities,SalProtoRtpSavp,rs->type); } }else ms_warning("Unknown protocol for mline %i, declining",i); if (ls){ initiate_incoming(ls,rs,&result->streams[i],one_matching_codec); } else { /* create an inactive stream for the answer, as there where no matching stream a local capability */ result->streams[i].dir=SalStreamInactive; result->streams[i].port=0; result->streams[i].type=rs->type; result->streams[i].proto=rs->proto; if (rs->type==SalOther){ strncpy(result->streams[i].typeother,rs->typeother,sizeof(rs->typeother)-1); } } } result->nstreams=i; strcpy(result->username, local_capabilities->username); strcpy(result->addr,local_capabilities->addr); result->bandwidth=local_capabilities->bandwidth; result->session_ver=local_capabilities->session_ver; result->session_id=local_capabilities->session_id; return 0; }
/** * Returns a media description to run the streams with, based on the local capabilities and * and the received offer. * The returned media description is an answer and should be sent to the offerer. **/ int offer_answer_initiate_incoming(MSFactory *factory, const SalMediaDescription *local_capabilities, const SalMediaDescription *remote_offer, SalMediaDescription *result, bool_t one_matching_codec){ int i; const SalStreamDescription *ls=NULL,*rs; for(i=0;i<remote_offer->nb_streams;++i){ rs = &remote_offer->streams[i]; ls = &local_capabilities->streams[i]; if (ls && rs->type == ls->type && rs->proto == ls->proto){ initiate_incoming(factory, ls,rs,&result->streams[i],one_matching_codec); // Handle global RTCP FB attributes result->streams[i].rtcp_fb.generic_nack_enabled = rs->rtcp_fb.generic_nack_enabled; result->streams[i].rtcp_fb.tmmbr_enabled = rs->rtcp_fb.tmmbr_enabled; // Handle media RTCP XR attribute memset(&result->streams[i].rtcp_xr, 0, sizeof(result->streams[i].rtcp_xr)); if (rs->rtcp_xr.enabled == TRUE) { const OrtpRtcpXrConfiguration *rtcp_xr_conf = NULL; if (ls->rtcp_xr.enabled == TRUE) rtcp_xr_conf = &ls->rtcp_xr; else if (local_capabilities->rtcp_xr.enabled == TRUE) rtcp_xr_conf = &local_capabilities->rtcp_xr; if ((rtcp_xr_conf != NULL) && (ls->dir == SalStreamSendRecv)) { memcpy(&result->streams[i].rtcp_xr, rtcp_xr_conf, sizeof(result->streams[i].rtcp_xr)); } else { result->streams[i].rtcp_xr.enabled = TRUE; } } }else { ms_message("Declining mline %i, no corresponding stream in local capabilities description.",i); /* create an inactive stream for the answer, as there where no matching stream in local capabilities */ result->streams[i].dir=SalStreamInactive; result->streams[i].rtp_port=0; result->streams[i].type=rs->type; result->streams[i].proto=rs->proto; if (rs->type==SalOther){ strncpy(result->streams[i].typeother,rs->typeother,sizeof(rs->typeother)-1); } if (rs->proto==SalProtoOther){ strncpy(result->streams[i].proto_other,rs->proto_other,sizeof(rs->proto_other)-1); } } result->streams[i].custom_sdp_attributes = sal_custom_sdp_attribute_clone(ls->custom_sdp_attributes); } result->nb_streams=i; strcpy(result->username, local_capabilities->username); strcpy(result->addr,local_capabilities->addr); result->bandwidth=local_capabilities->bandwidth; result->session_ver=local_capabilities->session_ver; result->session_id=local_capabilities->session_id; strcpy(result->ice_pwd, local_capabilities->ice_pwd); strcpy(result->ice_ufrag, local_capabilities->ice_ufrag); result->ice_lite = local_capabilities->ice_lite; result->set_nortpproxy = local_capabilities->set_nortpproxy; result->custom_sdp_attributes = sal_custom_sdp_attribute_clone(local_capabilities->custom_sdp_attributes); strcpy(result->name,local_capabilities->name); // Handle session RTCP XR attribute memset(&result->rtcp_xr, 0, sizeof(result->rtcp_xr)); if (remote_offer->rtcp_xr.enabled == TRUE) { if ((local_capabilities->rtcp_xr.enabled == TRUE) && (local_capabilities->dir == SalStreamSendRecv)) { memcpy(&result->rtcp_xr, &local_capabilities->rtcp_xr, sizeof(result->rtcp_xr)); } else { result->rtcp_xr.enabled = TRUE; } } return 0; }
/** * Returns a media description to run the streams with, based on the local capabilities and * and the received offer. * The returned media description is an answer and should be sent to the offerer. **/ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities, const SalMediaDescription *remote_offer, SalMediaDescription *result, bool_t one_matching_codec) { int i; const SalStreamDescription *ls=NULL,*rs; for(i=0; i<remote_offer->nb_streams; ++i) { rs=&remote_offer->streams[i]; if (rs->proto!=SalProtoOther) { ls=find_local_matching_stream(result,local_capabilities,rs); } else ms_warning("Unknown protocol for mline %i, declining",i); if (ls) { initiate_incoming(ls,rs,&result->streams[i],one_matching_codec); // Handle media RTCP XR attribute memset(&result->streams[i].rtcp_xr, 0, sizeof(result->streams[i].rtcp_xr)); if (rs->rtcp_xr.enabled == TRUE) { const OrtpRtcpXrConfiguration *rtcp_xr_conf = NULL; if (ls->rtcp_xr.enabled == TRUE) rtcp_xr_conf = &ls->rtcp_xr; else if (local_capabilities->rtcp_xr.enabled == TRUE) rtcp_xr_conf = &local_capabilities->rtcp_xr; if ((rtcp_xr_conf != NULL) && (ls->dir == SalStreamSendRecv)) { memcpy(&result->streams[i].rtcp_xr, rtcp_xr_conf, sizeof(result->streams[i].rtcp_xr)); } else { result->streams[i].rtcp_xr.enabled = TRUE; } } } else { ms_message("Declining mline %i, no corresponding stream in local capabilities description.",i); /* create an inactive stream for the answer, as there where no matching stream in local capabilities */ result->streams[i].dir=SalStreamInactive; result->streams[i].rtp_port=0; result->streams[i].type=rs->type; result->streams[i].proto=rs->proto; if (rs->type==SalOther) { strncpy(result->streams[i].typeother,rs->typeother,sizeof(rs->typeother)-1); } if (rs->proto==SalProtoOther) { strncpy(result->streams[i].proto_other,rs->proto_other,sizeof(rs->proto_other)-1); } } } result->nb_streams=i; strcpy(result->username, local_capabilities->username); strcpy(result->addr,local_capabilities->addr); result->bandwidth=local_capabilities->bandwidth; result->session_ver=local_capabilities->session_ver; result->session_id=local_capabilities->session_id; strcpy(result->ice_pwd, local_capabilities->ice_pwd); strcpy(result->ice_ufrag, local_capabilities->ice_ufrag); result->ice_lite = local_capabilities->ice_lite; result->ice_completed = local_capabilities->ice_completed; strcpy(result->name,local_capabilities->name); // Handle session RTCP XR attribute memset(&result->rtcp_xr, 0, sizeof(result->rtcp_xr)); if (remote_offer->rtcp_xr.enabled == TRUE) { if ((local_capabilities->rtcp_xr.enabled == TRUE) && (local_capabilities->dir == SalStreamSendRecv)) { memcpy(&result->rtcp_xr, &local_capabilities->rtcp_xr, sizeof(result->rtcp_xr)); } else { result->rtcp_xr.enabled = TRUE; } } return 0; }