diff --git a/src/zutil/parser/sdp/MediaDescription.java b/src/zutil/parser/sdp/MediaDescription.java index d373a97..8909e7e 100644 --- a/src/zutil/parser/sdp/MediaDescription.java +++ b/src/zutil/parser/sdp/MediaDescription.java @@ -55,4 +55,21 @@ public class MediaDescription { public String getLabel() { return label; } + + + public String toString() { + StringBuffer output = new StringBuffer(); + + output.append("m=").append(type).append(' ').append(transportPort).append(' ').append(transport).append('\n'); // TODO: media formats + + if (label != null) output.append("i=").append(label).append('\n'); + // TODO: [optional] c=
// Media specific connection information + // TODO: [optional] b=(bandwidth information) + // TODO: [optional] k=(encryption key) + + // TODO: [optional] a=: + // TODO: [optional] a=rtpmap:: + + return output.toString().trim(); + } } \ No newline at end of file diff --git a/src/zutil/parser/sdp/SDPParser.java b/src/zutil/parser/sdp/SDPParser.java index 684f0b7..51b022a 100644 --- a/src/zutil/parser/sdp/SDPParser.java +++ b/src/zutil/parser/sdp/SDPParser.java @@ -162,7 +162,7 @@ public class SDPParser { if (currentSession == null) throw new RuntimeException("Time description received before a session has been defined: '" + line + "'"); currentTiming = new TimingDescription(); - currentSession.timing.add(currentTiming); + currentSession.timings.add(currentTiming); tmpArr = getValueArray(line); if (tmpArr.length != 2) throw new RuntimeException("Incorrect time definition found: '" + line + "'"); diff --git a/src/zutil/parser/sdp/SessionDescription.java b/src/zutil/parser/sdp/SessionDescription.java index db43ec3..c092397 100644 --- a/src/zutil/parser/sdp/SessionDescription.java +++ b/src/zutil/parser/sdp/SessionDescription.java @@ -25,7 +25,7 @@ public class SessionDescription { protected String organizerEmail; protected String organizerPhoneNumber; - protected List timing = new ArrayList<>(); + protected List timings = new ArrayList<>(); protected List media = new ArrayList<>(); @@ -80,13 +80,41 @@ public class SessionDescription { return organizerPhoneNumber; } - public List getTiming() { - return timing; + public List getTimings() { + return timings; } public List getMedia() { return media; } + + + public String toString() { + StringBuffer output = new StringBuffer(); + + output.append("v=").append(protocolVersion).append('\n'); + // TODO: o=
+ 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'); + if (organizerEmail != null) output.append("e=").append(organizerEmail).append('\n'); + if (organizerPhoneNumber != null) output.append("p=").append(organizerPhoneNumber).append('\n'); + // TODO: [optional] c=
// Session overall connection information + + // Time description + for (TimingDescription t : timings) output.append(t.toString()).append('\n'); + + // TODO: [optional] b=: + // TODO: [optional] z= .... // Time zone adjustments + // TODO: [optional] k=: // Encryption information + // TODO: [optional] a=: + + // Media description + for (MediaDescription m : media) output.append(m.toString()).append('\n'); + + return output.toString().trim(); + } } diff --git a/src/zutil/parser/sdp/TimingDescription.java b/src/zutil/parser/sdp/TimingDescription.java index 97c7486..a0a06af 100644 --- a/src/zutil/parser/sdp/TimingDescription.java +++ b/src/zutil/parser/sdp/TimingDescription.java @@ -41,4 +41,15 @@ public class TimingDescription { public long getEndTime() { return endTime; } + + + public String toString() { + StringBuffer output = new StringBuffer(); + + output.append("t=").append(startTime).append(' ').append(endTime).append('\n'); + + // TODO: [optional] r= // Repeat information + + return output.toString().trim(); + } } \ No newline at end of file