public static String toSdpAttribute(RtcCandidate candidate){
  final StringBuilder sb=new StringBuilder("candidate:");
  sb.append(candidate.getFoundation());
  sb.append(" ");
switch (candidate.getComponentType()) {
case RTP:
    sb.append(1);
  break;
case RTCP:
sb.append(2);
break;
}
sb.append(" ");
if (candidate.getTransportType() == RtcCandidate.TransportType.UDP) {
sb.append("UDP");
}
 else {
sb.append("TCP");
}
sb.append(" ");
sb.append(candidate.getPriority());
sb.append(" ");
sb.append(candidate.getAddress());
sb.append(" ");
sb.append(candidate.getPort());
sb.append(" typ ");
switch (candidate.getType()) {
case HOST:
sb.append("host");
break;
case SERVER_REFLEXIVE:
sb.append("srflx");
break;
case PEER_REFLEXIVE:
sb.append("prflx");
break;
case RELAY:
sb.append("relay");
break;
}
if (candidate.getRelatedAddress() != null) {
sb.append(" raddr ");
sb.append(candidate.getRelatedAddress());
sb.append(" rport ");
sb.append(candidate.getRelatedPort());
}
if (candidate.getTransportType() != RtcCandidate.TransportType.UDP) {
sb.append(" tcptype ");
switch (candidate.getTransportType()) {
case TCP_ACTIVE:
sb.append("active");
break;
case TCP_PASSIVE:
sb.append("passive");
break;
case TCP_SO:
sb.append("so");
break;
}
}
return sb.toString();
}

public static String toSdpAttribute ( RtcCandidate candidate ) { final StringBuilder sb = new StringBuilder ( "candidate:" ) ; sb . append ( candidate . getFoundation ( ) ) ; sb . append ( " " ) ; switch ( candidate . getComponentType ( ) ) { case RTP : sb . append ( 1 ) ; break ; case RTCP : sb . append ( 2 ) ; break ; } sb . append ( " " ) ; if ( candidate . getTransportType ( ) == RtcCandidate . TransportType . UDP ) { sb . append ( "UDP" ) ; } else { sb . append ( "TCP" ) ; } sb . append ( " " ) ; sb . append ( candidate . getPriority ( ) ) ; sb . append ( " " ) ; sb . append ( candidate . getAddress ( ) ) ; sb . append ( " " ) ; sb . append ( candidate . getPort ( ) ) ; sb . append ( " typ " ) ; switch ( candidate . getType ( ) ) { case HOST : sb . append ( "host" ) ; break ; case SERVER_REFLEXIVE : sb . append ( "srflx" ) ; break ; case PEER_REFLEXIVE : sb . append ( "prflx" ) ; break ; case RELAY : sb . append ( "relay" ) ; break ; } if ( candidate . getRelatedAddress ( ) != null ) { sb . append ( " raddr " ) ; sb . append ( candidate . getRelatedAddress ( ) ) ; sb . append ( " rport " ) ; sb . append ( candidate . getRelatedPort ( ) ) ; } if ( candidate . getTransportType ( ) != RtcCandidate . TransportType . UDP ) { sb . append ( " tcptype " ) ; switch ( candidate . getTransportType ( ) ) { case TCP_ACTIVE : sb . append ( "active" ) ; break ; case TCP_PASSIVE : sb . append ( "passive" ) ; break ; case TCP_SO : sb . append ( "so" ) ; break ; } } return sb . toString ( ) ; }
converts a candidate to a candidate attribute string with the format " candidate : . . . "
