Beispiel #1
0
  public void testDatachannelSdp() throws InvalidDescriptionException {
    JSONObject json = SdpProcessor.sdpToJson(sDcSdp);
    assertNotNull(SdpProcessor.jsonToSdp(json));
    assertEquals("0", json.optString("version"));
    assertEquals("0", json.optString("startTime"));
    assertEquals("-", json.optString("sessionName"));
    assertEquals("0", json.optString("stopTime"));

    assertOriginator(json, 2, "128254989039880302", "-", "IN", "IP4", "127.0.0.1");

    JSONArray mediaDescriptions = json.optJSONArray("mediaDescriptions");
    assertNotNull(mediaDescriptions);
    assertEquals(1, mediaDescriptions.length());

    {
      JSONObject dataDescription = mediaDescriptions.optJSONObject(0);
      assertNotNull(dataDescription);
      assertEquals("application", dataDescription.optString("type"));
      assertEquals("57049", dataDescription.optString("port"));
      assertEquals("DTLS/SCTP", dataDescription.optString("protocol"));

      assertNetAttrs(dataDescription, "IN", "IP4", "192.168.1.86");
      assertSctp(dataDescription, 5000, "webrtc-datachannel", 1024);
      assertIce(
          dataDescription,
          "9I+z5/4mb+Y00teq",
          "2gMDyNA8fu2WOCnIyyU1gkur",
          new IceCandidate("3681649477", 1, "UDP", 2122260223, "192.168.1.86", 57049, "host"));
      assertDtlsObject(
          dataDescription,
          "actpass",
          "sha-256",
          "1A:3C:A9:43:47:14:D1:12:E3:6E:C0:D5:19:14:EE:57:F6:FC:F9:1F:18:64:65:79:8B:AA:88:EB:3E:1A:B6:69");
    }
  }
Beispiel #2
0
 public void testSimple() throws InvalidDescriptionException {
   JSONObject json = SdpProcessor.sdpToJson(sSimpleSdp);
   JSONArray mediaDescriptions = json.optJSONArray("mediaDescriptions");
   assertNotNull(mediaDescriptions);
   assertEquals(1, mediaDescriptions.length());
   assertEquals("application", mediaDescriptions.optJSONObject(0).optString("type"));
   assertEquals("0", mediaDescriptions.optJSONObject(0).optString("port"));
   assertEquals("NONE", mediaDescriptions.optJSONObject(0).optString("protocol"));
   String sdp = SdpProcessor.jsonToSdp(json);
   assertNotNull(sdp);
   assertEquals(sSimpleSdp, sdp);
 }
Beispiel #3
0
 public void testInvalidSdp() throws InvalidDescriptionException {
   JSONObject json = SdpProcessor.sdpToJson(sInvalidSdp);
   assertNotNull(json);
   JSONArray mediaDescriptions = json.optJSONArray("mediaDescriptions");
   assertNotNull(mediaDescriptions);
   assertEquals(0, mediaDescriptions.length());
 }
Beispiel #4
0
  public void testFirefoxSdp() throws InvalidDescriptionException {
    JSONObject json = SdpProcessor.sdpToJson(sFfSdp);
    assertNotNull(SdpProcessor.jsonToSdp(json));
    assertEquals("0", json.optString("version"));
    assertEquals("0", json.optString("startTime"));
    assertEquals("SIP Call", json.optString("sessionName"));
    assertEquals("0", json.optString("stopTime"));

    assertOriginator(json, 0, "1021", "Mozilla-SIPUA-35.0.1", "IN", "IP4", "0.0.0.0");

    JSONArray mediaDescriptions = json.optJSONArray("mediaDescriptions");
    assertNotNull(mediaDescriptions);
    assertEquals(3, mediaDescriptions.length());

    {
      JSONObject audioDescription = mediaDescriptions.optJSONObject(0);
      assertNotNull(audioDescription);
      assertMediaAttrs(audioDescription, "audio", "9", "RTP/SAVPF");
      assertRtcpMux(audioDescription, true);
      assertEquals("sendrecv", audioDescription.optString("mode"));

      assertNetAttrs(audioDescription, "IN", "IP4", "0.0.0.0");
      assertDtlsObject(
          audioDescription,
          "actpass",
          "sha-256",
          "6C:B4:AB:6C:86:7E:6C:C8:69:68:CE:53:A1:3E:36:D2:1D:5B:4E:CC:39:2E:C7:4D:3F:A8:04:B5:0E:EB:74:9D");
      assertIce(
          audioDescription,
          "90293b3d",
          "ab4334b9f3efb523ba45c11ec3152350",
          new IceCandidate("0", 2, "UDP", 2130379006, "172.20.10.2", 59310, "host"),
          new IceCandidate("0", 1, "UDP", 2130379007, "172.20.10.2", 51830, "host"),
          new IceCandidate(
              "1", 1, "UDP", 1694236671, "90.237.24.157", 41535, "srflx", "172.20.10.2", 51830),
          new IceCandidate("0", 1, "UDP", 2130379007, "172.20.10.2", 51830, "host"),
          new IceCandidate("0", 2, "UDP", 2130379006, "172.20.10.2", 59310, "host"),
          new IceCandidate(
              "1", 1, "UDP", 1694236671, "90.237.24.157", 41535, "srflx", "172.20.10.2", 51830),
          new IceCandidate(
              "1", 2, "UDP", 1694236670, "90.237.24.157", 48703, "srflx", "172.20.10.2", 59310),
          new IceCandidate(
              "3", 1, "UDP", 100401151, "192.36.158.14", 64686, "relay", "192.36.158.14", 64686),
          new IceCandidate(
              "3", 2, "UDP", 100401150, "192.36.158.14", 59208, "relay", "192.36.158.14", 59208));
      assertPayloads(
          audioDescription,
          new MediaPayload(0, 8000, "PCMU", 1, null),
          new MediaPayload(8, 8000, "PCMA", 1, null),
          new MediaPayload(9, 8000, "G722", 1, null),
          new MediaPayload(101, 8000, "telephone-event", 1, null),
          new MediaPayload(109, 48000, "opus", 2, null));
    }

    {
      JSONObject videoDescription = mediaDescriptions.optJSONObject(1);
      assertNotNull(videoDescription);
      assertMediaAttrs(videoDescription, "video", "9", "RTP/SAVPF");
      assertRtcpMux(videoDescription, true);
      assertEquals("sendrecv", videoDescription.optString("mode"));

      assertNetAttrs(videoDescription, "IN", "IP4", "0.0.0.0");
      assertDtlsObject(
          videoDescription,
          "actpass",
          "sha-256",
          "6C:B4:AB:6C:86:7E:6C:C8:69:68:CE:53:A1:3E:36:D2:1D:5B:4E:CC:39:2E:C7:4D:3F:A8:04:B5:0E:EB:74:9D");
      assertIce(
          videoDescription,
          "90293b3d",
          "ab4334b9f3efb523ba45c11ec3152350",
          new IceCandidate("0", 1, "UDP", 2130379007, "172.20.10.2", 63183, "host"),
          new IceCandidate("0", 2, "UDP", 2130379006, "172.20.10.2", 62121, "host"),
          new IceCandidate("0", 1, "UDP", 2130379007, "172.20.10.2", 63183, "host"),
          new IceCandidate("0", 2, "UDP", 2130379006, "172.20.10.2", 62121, "host"),
          new IceCandidate(
              "1", 1, "UDP", 1694236671, "90.237.24.157", 43849, "srflx", "172.20.10.2", 63183),
          new IceCandidate(
              "1", 2, "UDP", 1694236670, "90.237.24.157", 39502, "srflx", "172.20.10.2", 62121),
          new IceCandidate(
              "3", 1, "UDP", 100401151, "192.36.158.14", 56914, "relay", "192.36.158.14", 56914),
          new IceCandidate(
              "3", 2, "UDP", 100401150, "192.36.158.14", 54995, "relay", "192.36.158.14", 54995));
      assertPayloads(
          videoDescription,
          new MediaPayload(
              97,
              90000,
              "H264",
              true,
              true,
              true,
              new HashMap<String, Object>() {
                {
                  put("packetizationMode", 0);
                  put("levelAsymmetryAllowed", 1);
                  put("PROFILE", 0);
                  put("cbr", 0);
                  put("useinbandfec", 0);
                  put("profileLevelId", "42e01f");
                  put("stereo", 0);
                  put("LEVEL", 0);
                  put("usedtx", 0);
                  put("parameterAdd", 1);
                }
              }),
          new MediaPayload(
              126,
              90000,
              "H264",
              true,
              true,
              true,
              new HashMap<String, Object>() {
                {
                  put("packetizationMode", 1);
                  put("levelAsymmetryAllowed", 1);
                  put("PROFILE", 0);
                  put("cbr", 0);
                  put("useinbandfec", 0);
                  put("profileLevelId", "42e01f");
                  put("stereo", 0);
                  put("LEVEL", 0);
                  put("usedtx", 0);
                  put("parameterAdd", 1);
                }
              }),
          new MediaPayload(120, 90000, "VP8", true, true, true, null));
    }

    {
      JSONObject dataDescription = mediaDescriptions.optJSONObject(2);
      assertNotNull(dataDescription);
      assertMediaAttrs(dataDescription, "application", "9", "DTLS/SCTP");

      assertSctp(dataDescription, 5000, "webrtc-datachannel", 256);
      assertNetAttrs(dataDescription, "IN", "IP4", "0.0.0.0");
      assertDtlsObject(
          dataDescription,
          "actpass",
          "sha-256",
          "6C:B4:AB:6C:86:7E:6C:C8:69:68:CE:53:A1:3E:36:D2:1D:5B:4E:CC:39:2E:C7:4D:3F:A8:04:B5:0E:EB:74:9D");
      assertIce(
          dataDescription,
          "90293b3d",
          "ab4334b9f3efb523ba45c11ec3152350",
          new IceCandidate("0", 1, "UDP", 2130379007, "172.20.10.2", 51850, "host"),
          new IceCandidate("0", 2, "UDP", 2130379006, "172.20.10.2", 61466, "host"),
          new IceCandidate("0", 1, "UDP", 2130379007, "172.20.10.2", 51850, "host"),
          new IceCandidate("0", 2, "UDP", 2130379006, "172.20.10.2", 61466, "host"),
          new IceCandidate(
              "1", 1, "UDP", 1694236671, "90.237.24.157", 35856, "srflx", "172.20.10.2", 51850),
          new IceCandidate(
              "1", 2, "UDP", 1694236670, "90.237.24.157", 32790, "srflx", "172.20.10.2", 61466),
          new IceCandidate(
              "3", 1, "UDP", 100401151, "192.36.158.14", 55300, "relay", "192.36.158.14", 55300),
          new IceCandidate(
              "3", 2, "UDP", 100401150, "192.36.158.14", 61720, "relay", "192.36.158.14", 61720));
    }
  }
Beispiel #5
0
 public void testSimpleGen() throws InvalidDescriptionException, JSONException {
   String sdp =
       SdpProcessor.jsonToSdp(new JSONObject("{\"originator\":{\"sessionId\":123456789}}"));
   assertNotNull(sdp);
   assertEquals("v=0\r\no=- 123456789 1 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n", sdp);
 }