diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java
index 7d5a2bc..af11d19 100644
--- a/src/org/ice4j/ice/Agent.java
+++ b/src/org/ice4j/ice/Agent.java
@@ -2199,31 +2199,22 @@ public class Agent
}
/**
- * Returns the selected pair for this Agent.
+ * Returns the selected pair for the RTP component for the ICE media stream
+ * with name streamName of this Agent, or null.
*
- * @param streamName The stream name (AUDIO, VIDEO);
+ * @param streamName The stream name.
*
- * @return The selected pair for this Agent. Null if no pair is selected.
+ * @return the selected pair for the RTP component for the ICE media stream
+ * with name streamName of this Agent, or null.
*/
private CandidatePair getSelectedPair(String streamName)
{
- List iceMediaStreams = this.getStreams();
- for(int i = 0; i < iceMediaStreams.size(); ++i)
+ IceMediaStream stream = getStream(streamName);
+ if (stream != null)
{
- if(iceMediaStreams.get(i).getName().equals(streamName))
- {
- List components =
- iceMediaStreams.get(i).getComponents();
- for(int j = 0; j < components.size(); ++j)
- {
- Component component = components.get(i);
- if(component.getComponentID()
- == org.ice4j.ice.Component.RTP)
- {
- return component.getSelectedPair();
- }
- }
- }
+ Component component = stream.getComponent(Component.RTP);
+ if (component != null)
+ return component.getSelectedPair();
}
return null;
}