@ -348,34 +348,30 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply)
bool has_sdp = sdp_body & & sdp_body - > getLen ( ) ;
if ( ! has_sdp & & ! generate_sdp ) {
// let's see whether we should force SDP or not.
/* let's see whether we should force SDP or not. */
if ( reply . cseq_method = = SIP_METH_INVITE ) {
if ( ( reply . code = = 183 )
| | ( ( reply . code > = 200 ) & & ( reply . code < 300 ) ) ) {
// either offer received or no offer at all:
// -> force SDP
generate_sdp = ( state = = OA_OfferRecved )
| | ( state = = OA_None )
| | ( state = = OA_Completed ) ;
if ( reply . cseq_method = = SIP_METH_INVITE ) {
if ( ( reply . code = = 183 ) | | ( ( reply . code > = 200 ) & & ( reply . code < 300 ) ) ) {
/* either offer received or no offer at all:
* - > force SDP */
generate_sdp = ( state = = OA_OfferRecved )
| | ( state = = OA_None )
| | ( state = = OA_Completed ) ;
}
}
else if ( reply . cseq_method = = SIP_METH_UPDATE ) {
if ( ( reply . code > = 200 ) & &
( reply . code < 300 ) ) {
// offer received:
// -> force SDP
generate_sdp = ( state = = OA_OfferRecved ) ;
} else if ( reply . cseq_method = = SIP_METH_UPDATE ) {
if ( ( reply . code > = 200 ) & & ( reply . code < 300 ) ) {
/* offer received:
* - > force SDP */
generate_sdp = ( state = = OA_OfferRecved ) ;
}
}
}
if ( reply . cseq_method = = SIP_METH_INVITE & & reply . code < 300 ) {
// ignore SDP repeated in 1xx and 2xx replies (183, 180, ... 2xx)
/* ignore SDP repeated in 1xx and 2xx replies (183, 180, ... 2xx) */
if ( has_sdp & &
( state = = OA_Completed | | state = = OA_OfferSent ) & &
reply . cseq = = cseq )
@ -387,49 +383,43 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply)
saveState ( ) ;
if ( generate_sdp ) {
string sdp_buf ;
if ( getSdpBody ( sdp_buf ) ) {
if ( getSdpBody ( sdp_buf ) ) {
if ( reply . code = = 183 & & reply . cseq_method = = SIP_METH_INVITE ) {
// just ignore if no SDP is generated (required for B2B)
}
else if ( reply . code = = 200 & & reply . cseq_method = = SIP_METH_INVITE & & state = = OA_Completed ) {
// just ignore if no SDP is generated (required for B2B)
}
else if ( force_sdp ) return - 1 ;
}
else {
if ( ! sdp_body ) {
if ( ( sdp_body =
reply . body . addPart ( SIP_APPLICATION_SDP ) )
= = NULL ) {
/* just ignore if no SDP is generated (required for B2B) */
} else if ( reply . code = = 200 & & reply . cseq_method = = SIP_METH_INVITE & & state = = OA_Completed ) {
/* just ignore if no SDP is generated (required for B2B) */
} else if ( force_sdp )
return - 1 ;
} else {
if ( ! sdp_body ) {
if ( ( sdp_body = reply . body . addPart ( SIP_APPLICATION_SDP ) ) = = NULL ) {
DBG ( " AmMimeBody::addPart() failed \n " ) ;
return - 1 ;
}
}
sdp_body - > setPayload ( ( const unsigned char * ) sdp_buf . c_str ( ) ,
sdp_buf . length ( ) ) ;
sdp_body - > setPayload ( ( const unsigned char * ) sdp_buf . c_str ( ) , sdp_buf . length ( ) ) ;
has_sdp = true ;
}
} else if ( sdp_body & & has_sdp ) {
// update local SDP copy
/* update local SDP copy */
if ( sdp_local . parse ( ( const char * ) sdp_body - > getPayload ( ) ) ) {
ERROR ( " parser failed on Tx SDP: '%s' \n " , ( const char * ) sdp_body - > getPayload ( ) ) ;
}
}
if ( has_sdp & & ( onTxSdp ( reply . cseq , reply . body ) ! = 0 ) ) {
DBG ( " onTxSdp() failed \n " ) ;
return - 1 ;
}
if ( ( reply . code > = 300 ) & &
( reply . cseq = = cseq ) ) {
// final error reply -> cleanup OA state
DBG ( " after %u reply to %s: resetting OA state \n " ,
reply . code , reply . cseq_method . c_str ( ) ) ;
if ( ( reply . code > = 300 ) & & ( reply . cseq = = cseq ) ) {
/* final error reply -> cleanup OA state */
DBG ( " after %u reply to %s: resetting OA state \n " , reply . code , reply . cseq_method . c_str ( ) ) ;
clearTransitionalState ( ) ;
}