Skip to content

Commit

Permalink
Add tcptype to Candidate toString method
Browse files Browse the repository at this point in the history
Also, remove redundancy in generatig candidate SDP attribute strings.
  • Loading branch information
jalaziz committed Oct 19, 2017
1 parent c266797 commit 0a12d4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
17 changes: 16 additions & 1 deletion src/main/java/org/ice4j/ice/Candidate.java
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,18 @@ public TransportAddress getRelatedAddress()
@Override
public String toString()
{
StringBuilder buff = new StringBuilder("candidate:");
return "candidate:" + toAttributeValue();
}

/**
* Returns a <tt>String</tt> represnation of this <tt>Candidate</tt>
* suitable for use as an SDP attribute value.
*
* @return a <tt>String</tt> representing th SDP attribute value of this
* <tt>Candidate</tt>.
*/
public String toAttributeValue() {
StringBuilder buff = new StringBuilder();

buff.append(getFoundation());
buff.append(" ").append(getParentComponent().getComponentID());
Expand All @@ -776,6 +787,10 @@ public String toString()
buff.append(" rport ").append(relAddr.getPort());
}

if(getTcpType() != null) {
buff.append(" tcptype ").append(getTcpType());
}

return buff.toString();
}

Expand Down
24 changes: 1 addition & 23 deletions src/main/java/org/ice4j/ice/sdp/CandidateAttribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,29 +115,7 @@ public boolean hasValue()
*/
public String getValue()
{
StringBuffer buff = new StringBuffer();

buff.append(candidate.getFoundation());
buff.append(" ").append(
candidate.getParentComponent().getComponentID());
buff.append(" ").append(candidate.getTransport());
buff.append(" ").append(candidate.getPriority());
buff.append(" ").append(
candidate.getTransportAddress().getHostAddress());
buff.append(" ").append(
candidate.getTransportAddress().getPort());
buff.append(" typ ").append(
candidate.getType());

TransportAddress relAddr = candidate.getRelatedAddress();

if (relAddr != null)
{
buff.append(" raddr ").append(relAddr.getHostAddress());
buff.append(" rport ").append(relAddr.getPort());
}

return buff.toString();
return candidate.toAttributeValue();
}

/**
Expand Down

0 comments on commit 0a12d4d

Please sign in to comment.