Esempio n. 1
0
  @Test
  public void testHalfDuplex() throws Exception {
    channel1.updateMode(ConnectionMode.RECV_ONLY);
    channel2.updateMode(ConnectionMode.SEND_ONLY);
    source1.activate();
    source2.activate();
    analyzer1.activate();
    audioMixer1.start();
    audioMixer2.start();

    Thread.sleep(5000);

    source1.deactivate();
    source2.deactivate();
    analyzer1.deactivate();
    audioMixer1.stop();
    audioMixer2.stop();

    int s1[] = analyzer1.getSpectra();
    int s2[] = analyzer2.getSpectra();

    System.out.println("rx-channel1: " + channel1.getPacketsReceived());
    System.out.println("tx-channel1: " + channel1.getPacketsTransmitted());

    System.out.println("rx-channel2: " + channel2.getPacketsReceived());
    System.out.println("tx-channel2: " + channel2.getPacketsTransmitted());

    if (s2.length != 0 || s1.length != 1) {
      fcount++;
    } else {
      System.out.println("Passed");
    }

    assertEquals(0, fcount);
    assertEquals(50, s1[0], 5);
  }
Esempio n. 2
0
  @Test
  public void testTransmission() throws Exception {
    source1.activate();
    analyzer1.activate();
    audioMixer1.start();

    source2.start();
    analyzer2.activate();
    audioMixer2.start();

    Thread.sleep(5000);

    analyzer1.deactivate();
    analyzer2.deactivate();
    source1.deactivate();
    source2.deactivate();
    audioMixer1.stop();
    audioMixer2.stop();

    int s1[] = analyzer1.getSpectra();
    int s2[] = analyzer2.getSpectra();

    System.out.println("rx-channel1: " + channel1.getPacketsReceived());
    System.out.println("tx-channel1: " + channel1.getPacketsTransmitted());

    System.out.println("rx-channel2: " + channel2.getPacketsReceived());
    System.out.println("tx-channel2: " + channel2.getPacketsTransmitted());

    if (s1.length != 1 || s2.length != 1) {
      System.out.println("Failure ,s1:" + s1.length + ",s2:" + s2.length);
      fcount++;
    } else {
      System.out.println("Passed");
    }

    assertEquals(1, s1.length);
    assertEquals(1, s2.length);
    assertEquals(50, s1[0], 5);
    assertEquals(100, s2[0], 5);
  }
Esempio n. 3
0
  /** Test of setOtherParty method, of class LocalConnectionImpl. */
  @Test
  public void testTransmission() throws Exception {
    sine1.activate();
    sine2.activate();
    sine3.activate();
    sine4.activate();

    analyzer1.activate();
    analyzer2.activate();
    analyzer3.activate();
    analyzer4.activate();

    Connection connection1 = endpoint1.createConnection(ConnectionType.RTP, false);
    Connection connection3 = endpoint3.createConnection(ConnectionType.RTP, false);

    connection1.generateOffer(false);
    connection1.setMode(ConnectionMode.SEND_ONLY);

    connection3.setOtherParty(new Text(connection1.getLocalDescriptor()));
    connection1.setOtherParty(new Text(connection3.getLocalDescriptor()));

    // make inactive first

    connection3.setMode(ConnectionMode.CONFERENCE);
    connection1.setMode(ConnectionMode.CONFERENCE);

    Connection connection12 = endpoint1.createConnection(ConnectionType.LOCAL, false);
    Connection connection2 = endpoint2.createConnection(ConnectionType.LOCAL, false);

    connection12.setOtherParty(connection2);

    // initial mode
    connection12.setMode(ConnectionMode.SEND_RECV);

    // working mode
    connection12.setMode(ConnectionMode.CONFERENCE);
    connection2.setMode(ConnectionMode.SEND_RECV);

    Connection connection34 = endpoint3.createConnection(ConnectionType.LOCAL, false);
    Connection connection4 = endpoint4.createConnection(ConnectionType.LOCAL, false);

    connection34.setOtherParty(connection4);
    connection34.setMode(ConnectionMode.CONFERENCE);

    connection4.setMode(ConnectionMode.SEND_RECV);
    Thread.sleep(100);
    connection4.setMode(ConnectionMode.SEND_RECV);

    Thread.sleep(5000);

    sine1.deactivate();
    sine2.deactivate();
    sine3.deactivate();
    sine4.deactivate();

    analyzer1.deactivate();
    analyzer2.deactivate();
    analyzer3.deactivate();
    analyzer4.deactivate();

    SpectraAnalyzer a1 = (SpectraAnalyzer) analyzer1;
    SpectraAnalyzer a2 = (SpectraAnalyzer) analyzer2;
    SpectraAnalyzer a3 = (SpectraAnalyzer) analyzer3;
    SpectraAnalyzer a4 = (SpectraAnalyzer) analyzer4;

    int[] s1 = a1.getSpectra();
    int[] s2 = a2.getSpectra();
    int[] s3 = a3.getSpectra();
    int[] s4 = a4.getSpectra();

    endpoint1.deleteConnection(connection1);
    endpoint1.deleteConnection(connection12);

    endpoint2.deleteConnection(connection2);

    endpoint3.deleteConnection(connection3);
    endpoint3.deleteConnection(connection34);

    endpoint4.deleteConnection(connection4);

    printSpectra("E1", s1);
    printSpectra("E2", s2);
    printSpectra("E3", s3);
    printSpectra("E4", s4);
    System.out.println("===============");

    assertEquals(3, s2.length);
    assertEquals(3, s4.length);
  }
Esempio n. 4
0
  @Before
  public void setUp() throws Exception {
    AudioFormat pcma = FormatFactory.createAudioFormat("pcma", 8000, 8, 1);
    Formats fmts = new Formats();
    fmts.add(pcma);

    Formats dstFormats = new Formats();
    dstFormats.add(FormatFactory.createAudioFormat("LINEAR", 8000, 16, 1));

    dspFactory.addCodec("org.mobicents.media.server.impl.dsp.audio.g711.alaw.Encoder");
    dspFactory.addCodec("org.mobicents.media.server.impl.dsp.audio.g711.alaw.Decoder");

    dsp11 = dspFactory.newProcessor();
    dsp12 = dspFactory.newProcessor();

    dsp21 = dspFactory.newProcessor();
    dsp22 = dspFactory.newProcessor();

    // use default clock
    clock = new WallClock();
    rtpClock1 = new RtpClock(clock);
    rtpClock2 = new RtpClock(clock);
    oobClock1 = new RtpClock(clock);
    oobClock2 = new RtpClock(clock);

    // create single thread scheduler
    mediaScheduler = new PriorityQueueScheduler();
    mediaScheduler.setClock(clock);
    mediaScheduler.start();

    udpManager = new UdpManager(scheduler);
    scheduler.start();
    udpManager.start();

    channelsManager = new ChannelsManager(udpManager);
    channelsManager.setScheduler(mediaScheduler);

    source1 = new Sine(mediaScheduler);
    source1.setFrequency(100);

    source2 = new Sine(mediaScheduler);
    source2.setFrequency(50);

    analyzer1 = new SpectraAnalyzer("analyzer", mediaScheduler);
    analyzer2 = new SpectraAnalyzer("analyzer", mediaScheduler);

    this.statistics1 = new RtpStatistics(rtpClock1);
    this.statistics2 = new RtpStatistics(rtpClock2);

    channel1 = channelsManager.getRtpChannel(statistics1, rtpClock1, oobClock1);
    channel1.updateMode(ConnectionMode.SEND_RECV);
    channel1.setOutputDsp(dsp11);
    channel1.setOutputFormats(fmts);
    channel1.setInputDsp(dsp12);

    channel2 = channelsManager.getRtpChannel(statistics2, rtpClock2, oobClock2);
    channel2.updateMode(ConnectionMode.SEND_RECV);
    channel2.setOutputDsp(dsp21);
    channel2.setOutputFormats(fmts);
    channel2.setInputDsp(dsp22);

    channel1.bind(false);
    channel2.bind(false);

    channel1.setRemotePeer(new InetSocketAddress("127.0.0.1", channel2.getLocalPort()));
    channel2.setRemotePeer(new InetSocketAddress("127.0.0.1", channel1.getLocalPort()));

    channel1.setFormatMap(AVProfile.audio);
    channel2.setFormatMap(AVProfile.audio);

    audioMixer1 = new AudioMixer(mediaScheduler);
    audioMixer2 = new AudioMixer(mediaScheduler);

    component1 = new AudioComponent(1);
    component1.addInput(source1.getAudioInput());
    component1.addOutput(analyzer1.getAudioOutput());
    component1.updateMode(true, true);

    audioMixer1.addComponent(component1);
    audioMixer1.addComponent(channel1.getAudioComponent());

    component2 = new AudioComponent(2);
    component2.addInput(source2.getAudioInput());
    component2.addOutput(analyzer2.getAudioOutput());
    component2.updateMode(true, true);

    audioMixer2.addComponent(component2);
    audioMixer2.addComponent(channel2.getAudioComponent());
  }