Skip to content

Commit 0a12d4d

Browse files
committed
Add tcptype to Candidate toString method
Also, remove redundancy in generatig candidate SDP attribute strings.
1 parent c266797 commit 0a12d4d

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

src/main/java/org/ice4j/ice/Candidate.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,18 @@ public TransportAddress getRelatedAddress()
758758
@Override
759759
public String toString()
760760
{
761-
StringBuilder buff = new StringBuilder("candidate:");
761+
return "candidate:" + toAttributeValue();
762+
}
763+
764+
/**
765+
* Returns a <tt>String</tt> represnation of this <tt>Candidate</tt>
766+
* suitable for use as an SDP attribute value.
767+
*
768+
* @return a <tt>String</tt> representing th SDP attribute value of this
769+
* <tt>Candidate</tt>.
770+
*/
771+
public String toAttributeValue() {
772+
StringBuilder buff = new StringBuilder();
762773

763774
buff.append(getFoundation());
764775
buff.append(" ").append(getParentComponent().getComponentID());
@@ -776,6 +787,10 @@ public String toString()
776787
buff.append(" rport ").append(relAddr.getPort());
777788
}
778789

790+
if(getTcpType() != null) {
791+
buff.append(" tcptype ").append(getTcpType());
792+
}
793+
779794
return buff.toString();
780795
}
781796

src/main/java/org/ice4j/ice/sdp/CandidateAttribute.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -115,29 +115,7 @@ public boolean hasValue()
115115
*/
116116
public String getValue()
117117
{
118-
StringBuffer buff = new StringBuffer();
119-
120-
buff.append(candidate.getFoundation());
121-
buff.append(" ").append(
122-
candidate.getParentComponent().getComponentID());
123-
buff.append(" ").append(candidate.getTransport());
124-
buff.append(" ").append(candidate.getPriority());
125-
buff.append(" ").append(
126-
candidate.getTransportAddress().getHostAddress());
127-
buff.append(" ").append(
128-
candidate.getTransportAddress().getPort());
129-
buff.append(" typ ").append(
130-
candidate.getType());
131-
132-
TransportAddress relAddr = candidate.getRelatedAddress();
133-
134-
if (relAddr != null)
135-
{
136-
buff.append(" raddr ").append(relAddr.getHostAddress());
137-
buff.append(" rport ").append(relAddr.getPort());
138-
}
139-
140-
return buff.toString();
118+
return candidate.toAttributeValue();
141119
}
142120

143121
/**

0 commit comments

Comments
 (0)