Added tests for SDP
This commit is contained in:
parent
e8f055971e
commit
fa0bb8aa54
3 changed files with 212 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,7 +1,8 @@
|
|||
/build/
|
||||
/bin/
|
||||
/target/
|
||||
/target/
|
||||
/gradle/
|
||||
/.gradle/
|
||||
|
||||
/.repository/
|
||||
/.flattened-pom.xml
|
||||
|
|
|
|||
109
test/zutil/parser/sdp/SDPParserTest.java
Normal file
109
test/zutil/parser/sdp/SDPParserTest.java
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Ziver Koc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package zutil.parser.sdp;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SDPParserTest {
|
||||
|
||||
/*
|
||||
"v=0\n" +
|
||||
"o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4\n" +
|
||||
"s=SDP Seminar\n" +
|
||||
"i=A Seminar on the session description protocol\n" +
|
||||
"u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps\n" +
|
||||
"e=mjh@isi.edu (Mark Handley)\n" +
|
||||
"c=IN IP4 224.2.17.12/127" +
|
||||
"t=2873397496 2873404696\n" +
|
||||
"a=recvonly\n" +
|
||||
"m=audio 49170 RTP/AVP 0\n" +
|
||||
"m=video 51372 RTP/AVP 31\n" +
|
||||
"m=application 32416 udp wb\n" +
|
||||
"a=orient:portrait";
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void basicSessionInfo() throws IOException {
|
||||
String description =
|
||||
"v=0\n" +
|
||||
"o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4\n" +
|
||||
"s=SDP Seminar\n" +
|
||||
"i=A Seminar on the session description protocol\n" +
|
||||
"u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps\n" +
|
||||
"e=mjh@isi.edu (Mark Handley)\n" +
|
||||
"c=IN IP4 224.2.17.12/127";
|
||||
|
||||
SDPParser parser = new SDPParser(description);
|
||||
List<SessionDescription> sessions = parser.parse();
|
||||
|
||||
assertEquals(1, sessions.size());
|
||||
|
||||
SessionDescription session = sessions.get(0);
|
||||
assertEquals(0, session.getProtocolVersion());
|
||||
assertEquals("SDP Seminar", session.getSessionTitle());
|
||||
assertEquals("A Seminar on the session description protocol", session.getSessionDescription());
|
||||
assertEquals("http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps", session.getSessionURI());
|
||||
assertEquals("mjh@isi.edu (Mark Handley)", session.getOrganizerEmail());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicTimingInfo() throws IOException {
|
||||
String description = "v=0\n" +
|
||||
"s=SDP Seminar\n" +
|
||||
"t=2873397496 2873404696";
|
||||
|
||||
SDPParser parser = new SDPParser(description);
|
||||
List<SessionDescription> sessions = parser.parse();
|
||||
|
||||
assertEquals(1, sessions.get(0).getTimings().size());
|
||||
TimingDescription timing = sessions.get(0).getTimings().get(0);
|
||||
|
||||
assertEquals(timing.getStartTime(), 2873397496l);
|
||||
assertEquals(timing.getEndTime(), 2873404696l);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicMediaInfo() throws IOException {
|
||||
String description = "v=0\n" +
|
||||
"s=SDP Seminar\n" +
|
||||
"m=video 51372 RTP/AVP 31\n" +
|
||||
"i=main video feed";
|
||||
|
||||
SDPParser parser = new SDPParser(description);
|
||||
List<SessionDescription> sessions = parser.parse();
|
||||
|
||||
assertEquals(1, sessions.get(0).getMedia().size());
|
||||
MediaDescription media = sessions.get(0).getMedia().get(0);
|
||||
|
||||
assertEquals(media.getType(), "video");
|
||||
assertEquals(media.getTransportPort(), 51372);
|
||||
assertEquals(media.getTransport(), "RTP/AVP");
|
||||
}
|
||||
}
|
||||
101
test/zutil/parser/sdp/SessionDescriptionTest.java
Normal file
101
test/zutil/parser/sdp/SessionDescriptionTest.java
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Ziver Koc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package zutil.parser.sdp;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SessionDescriptionTest {
|
||||
|
||||
// TODO: o=<owner username> <session id> <session version> <network type> <address type> <address>
|
||||
// TODO: [optional] i=<session description>
|
||||
// TODO: [optional] u=<Session description URI>
|
||||
// TODO: [optional] e=<email address>
|
||||
// TODO: [optional] p=<phone number>
|
||||
// TODO: [optional] c=<network type> <address type> <connection address> // Session overall connection information
|
||||
|
||||
// --------------------------------------
|
||||
// Time description
|
||||
// --------------------------------------
|
||||
|
||||
// TODO: [optional] b=<modifier>:<bandwidth kilobits per second>
|
||||
// TODO: [optional] z=<adjustment time> <offset> <adjustment time> <offset> .... // Time zone adjustments
|
||||
// TODO: [optional] k=<method=clear|base64|uri|prompt>:<encryption key> // Encryption information
|
||||
// TODO: [optional] a=<session attribute>:<value>
|
||||
|
||||
// --------------------------------------
|
||||
// Media description
|
||||
// --------------------------------------
|
||||
|
||||
@Test
|
||||
public void basicSession() {
|
||||
SessionDescription session = new SessionDescription();
|
||||
session.protocolVersion = 0;
|
||||
session.sessionTitle = "SDP Seminar";
|
||||
|
||||
assertEquals(session.toString(), "v=0\n" +
|
||||
"s=SDP Seminar"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicTiming() {
|
||||
TimingDescription timing = new TimingDescription();
|
||||
timing.startTime = 2873397496l;
|
||||
timing.endTime = 2873404696l;
|
||||
|
||||
SessionDescription session = new SessionDescription();
|
||||
session.protocolVersion = 0;
|
||||
session.sessionTitle = "SDP Seminar";
|
||||
session.timings.add(timing);
|
||||
|
||||
assertEquals(session.toString(), "v=0\n" +
|
||||
"s=SDP Seminar\n" +
|
||||
"t=2873397496 2873404696"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicMedia() {
|
||||
MediaDescription media = new MediaDescription();
|
||||
media.type = "video";
|
||||
media.transportPort = 51372;
|
||||
media.transport = "RTP/AVP";
|
||||
media.label = "main video feed";
|
||||
|
||||
SessionDescription session = new SessionDescription();
|
||||
session.protocolVersion = 0;
|
||||
session.sessionTitle = "SDP Seminar";
|
||||
session.media.add(media);
|
||||
|
||||
assertEquals(session.toString(), "v=0\n" +
|
||||
"s=SDP Seminar\n" +
|
||||
"m=video 51372 RTP/AVP\n" +
|
||||
"i=main video feed"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue