Added owner information
This commit is contained in:
parent
2dbc169a0f
commit
23090d2bd5
5 changed files with 79 additions and 32 deletions
|
|
@ -88,10 +88,10 @@ public class SDPParser {
|
|||
public List<SessionDescription> parse() throws IOException {
|
||||
List<SessionDescription> sessions = new ArrayList<>();
|
||||
|
||||
String line;
|
||||
SessionDescription currentSession = null;
|
||||
TimingDescription currentTiming = null;
|
||||
MediaDescription currentMedia = null;
|
||||
String line;
|
||||
String[] tmpArr;
|
||||
|
||||
while ((line=IOUtil.readLine(in)) != null) {
|
||||
|
|
@ -115,7 +115,20 @@ public class SDPParser {
|
|||
currentSession.protocolVersion = Integer.parseInt(getValue(line));
|
||||
break;
|
||||
|
||||
// TODO: o=<owner username> <session id> <session version> <network type> <address type> <address>
|
||||
// o=<owner username> <session id> <session version> <network type> <address type> <address>
|
||||
case 'o':
|
||||
if (currentSession == null) throw new RuntimeException("Received session owner before session definition: '" + line + "'");
|
||||
|
||||
tmpArr = getValueArray(line);
|
||||
if (tmpArr.length != 6) throw new RuntimeException("Incorrect owner definition found: '" + line + "'");
|
||||
|
||||
currentSession.sessionOwner = tmpArr[0];
|
||||
currentSession.sessionId = Long.parseLong(tmpArr[1]);
|
||||
currentSession.sessionAnnouncementVersion = Long.parseLong(tmpArr[2]);
|
||||
currentSession.ownerNetworkType = tmpArr[3];
|
||||
currentSession.ownerAddressType = tmpArr[4];
|
||||
currentSession.ownerAddress = tmpArr[5];
|
||||
break;
|
||||
|
||||
// s=<session title>
|
||||
case 's':
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ public class SessionDescription {
|
|||
protected int protocolVersion;
|
||||
|
||||
protected String sessionOwner;
|
||||
protected String sessionId;
|
||||
protected String sessionVersion;
|
||||
protected String networkType;
|
||||
protected String addressType;
|
||||
protected String address;
|
||||
protected long sessionId;
|
||||
protected long sessionAnnouncementVersion;
|
||||
protected String ownerNetworkType = "IN";
|
||||
protected String ownerAddressType = "IP4"; // IP4 or IP6
|
||||
protected String ownerAddress;
|
||||
|
||||
protected String sessionTitle;
|
||||
protected String sessionDescription;
|
||||
|
|
@ -40,24 +40,24 @@ public class SessionDescription {
|
|||
return sessionOwner;
|
||||
}
|
||||
|
||||
public String getSessionId() {
|
||||
public long getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public String getSessionVersion() {
|
||||
return sessionVersion;
|
||||
public long getAnnouncementVersion() {
|
||||
return sessionAnnouncementVersion;
|
||||
}
|
||||
|
||||
public String getNetworkType() {
|
||||
return networkType;
|
||||
public String getOwnerNetworkType() {
|
||||
return ownerNetworkType;
|
||||
}
|
||||
|
||||
public String getAddressType() {
|
||||
return addressType;
|
||||
public String getOwnerAddressType() {
|
||||
return ownerAddressType;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
public String getOwnerAddress() {
|
||||
return ownerAddress;
|
||||
}
|
||||
|
||||
public String getSessionTitle() {
|
||||
|
|
@ -93,8 +93,9 @@ public class SessionDescription {
|
|||
StringBuffer output = new StringBuffer();
|
||||
|
||||
output.append("v=").append(protocolVersion).append('\n');
|
||||
// TODO: o=<owner username> <session id> <session version> <network type> <address type> <address>
|
||||
output.append("s=").append(sessionTitle).append('\n');;
|
||||
output.append("o=").append(sessionOwner).append(' ').append(sessionId).append(' ').append(sessionAnnouncementVersion)
|
||||
.append(' ').append(ownerNetworkType).append(' ').append(ownerAddressType).append(' ').append(ownerAddress).append('\n');
|
||||
output.append("s=").append(sessionTitle).append('\n');
|
||||
|
||||
if (sessionDescription != null) output.append("i=").append(sessionDescription).append('\n');
|
||||
if (sessionURI != null) output.append("u=").append(sessionURI).append('\n');
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class URLDecoderTest {
|
|||
|
||||
@Test
|
||||
public void percentMultibyteTest() throws UnsupportedEncodingException {
|
||||
assertEquals("Ängen", java.net.URLDecoder.decode("%C3%84ngen", "UTF-8"));
|
||||
assertEquals("Ängen", URLDecoder.decode("%C3%84ngen"));
|
||||
assertEquals("Ängen", java.net.URLDecoder.decode("%C3%84ngen", "UTF-8"));
|
||||
assertEquals("Ängen", URLDecoder.decode("%C3%84ngen"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,10 +66,22 @@ public class SDPParserTest {
|
|||
assertEquals(1, sessions.size());
|
||||
|
||||
SessionDescription session = sessions.get(0);
|
||||
// v=
|
||||
assertEquals(0, session.getProtocolVersion());
|
||||
// o=
|
||||
assertEquals("mhandley", session.getSessionOwner());
|
||||
assertEquals(2890844526l, session.getSessionId());
|
||||
assertEquals(2890842807l, session.getAnnouncementVersion());
|
||||
assertEquals("IN", session.getOwnerNetworkType());
|
||||
assertEquals("IP4", session.getOwnerAddressType());
|
||||
assertEquals("126.16.64.4", session.getOwnerAddress());
|
||||
// s=
|
||||
assertEquals("SDP Seminar", session.getSessionTitle());
|
||||
// i=
|
||||
assertEquals("A Seminar on the session description protocol", session.getSessionDescription());
|
||||
// u=
|
||||
assertEquals("http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps", session.getSessionURI());
|
||||
// e=
|
||||
assertEquals("mjh@isi.edu (Mark Handley)", session.getOrganizerEmail());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ package zutil.parser.sdp;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SessionDescriptionTest {
|
||||
|
||||
|
|
@ -46,9 +46,7 @@ public class SessionDescriptionTest {
|
|||
// TODO: [optional] k=<method=clear|base64|uri|prompt>:<encryption key> // Encryption information
|
||||
// TODO: [optional] a=<session attribute>:<value>
|
||||
|
||||
// --------------------------------------
|
||||
// Media description
|
||||
// --------------------------------------
|
||||
|
||||
|
||||
@Test
|
||||
public void basicSession() {
|
||||
|
|
@ -56,8 +54,28 @@ public class SessionDescriptionTest {
|
|||
session.protocolVersion = 0;
|
||||
session.sessionTitle = "SDP Seminar";
|
||||
|
||||
assertEquals(session.toString(), "v=0\n" +
|
||||
"s=SDP Seminar"
|
||||
assertEquals("v=0\n" +
|
||||
"o=null 0 0 IN IP4 null\n" +
|
||||
"s=SDP Seminar",
|
||||
session.toString()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicOwner() {
|
||||
SessionDescription session = new SessionDescription();
|
||||
session.protocolVersion = 0;
|
||||
session.sessionTitle = "SDP Seminar";
|
||||
|
||||
session.sessionOwner = "mhandley";
|
||||
session.sessionId = 2890844526l;
|
||||
session.sessionAnnouncementVersion = 2890842807l;
|
||||
session.ownerAddress = "126.16.64.4";
|
||||
|
||||
assertEquals("v=0\n" +
|
||||
"o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4\n" +
|
||||
"s=SDP Seminar",
|
||||
session.toString()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -72,9 +90,11 @@ public class SessionDescriptionTest {
|
|||
session.sessionTitle = "SDP Seminar";
|
||||
session.timings.add(timing);
|
||||
|
||||
assertEquals(session.toString(), "v=0\n" +
|
||||
"s=SDP Seminar\n" +
|
||||
"t=2873397496 2873404696"
|
||||
assertEquals("v=0\n" +
|
||||
"o=null 0 0 IN IP4 null\n" +
|
||||
"s=SDP Seminar\n" +
|
||||
"t=2873397496 2873404696",
|
||||
session.toString()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -91,11 +111,12 @@ public class SessionDescriptionTest {
|
|||
session.sessionTitle = "SDP Seminar";
|
||||
session.media.add(media);
|
||||
|
||||
assertEquals(session.toString(), "v=0\n" +
|
||||
assertEquals("v=0\n" +
|
||||
"o=null 0 0 IN IP4 null\n" +
|
||||
"s=SDP Seminar\n" +
|
||||
"m=video 51372 RTP/AVP\n" +
|
||||
"i=main video feed"
|
||||
"i=main video feed",
|
||||
session.toString()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue