Exemplo n.º 1
0
  @Test
  public void testTransmission() throws Exception {
    channel.updateMode(ConnectionMode.SEND_RECV);
    audioMixer.start();
    oobMixer.start();
    detector.activate();

    new Thread(sender).start();

    Thread.sleep(5000);

    channel.updateMode(ConnectionMode.INACTIVE);
    audioMixer.stop();
    oobMixer.stop();
    detector.deactivate();

    assertEquals(4, count);
  }
Exemplo n.º 2
0
 @After
 public void tearDown() {
   channel.close();
   audioMixer.stop();
   oobMixer.stop();
   udpManager.stop();
   mediaScheduler.stop();
   scheduler.stop();
   sender.close();
 }
Exemplo n.º 3
0
  @Before
  public void setUp() throws Exception {
    // given
    DtlsSrtpServerProvider mockedDtlsServerProvider = mock(DtlsSrtpServerProvider.class);
    DtlsSrtpServer mockedDtlsSrtpServer = mock(DtlsSrtpServer.class);

    // when
    when(mockedDtlsServerProvider.provide()).thenReturn(mockedDtlsSrtpServer);
    when(mockedDtlsSrtpServer.getCipherSuites()).thenReturn(cipherSuites);

    // then
    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();

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

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

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

    detector = new DetectorImpl("dtmf", mediaScheduler);
    detector.setVolume(-35);
    detector.setDuration(40);
    detector.addListener(this);

    channel = channelsManager.getChannel();
    channel.bind(false);

    sender = new Sender(channel.getLocalPort());

    channel.setPeer(new InetSocketAddress("127.0.0.1", 9200));
    channel.setInputDsp(dsp11);
    channel.setFormatMap(AVProfile.audio);

    audioMixer = new AudioMixer(mediaScheduler);
    audioMixer.addComponent(channel.getAudioComponent());

    detectorComponent = new AudioComponent(1);
    detectorComponent.addOutput(detector.getAudioOutput());
    detectorComponent.updateMode(true, true);
    audioMixer.addComponent(detectorComponent);

    oobMixer = new OOBMixer(mediaScheduler);
    oobMixer.addComponent(channel.getOOBComponent());

    oobComponent = new OOBComponent(1);
    oobComponent.addOutput(detector.getOOBOutput());
    oobComponent.updateMode(true, true);
    oobMixer.addComponent(oobComponent);
  }