Libjitsi - stream.setConnector(connector) always fails

Hello,

I recently started working with SIP and RTP and successfully establish a connection via SIP to an Asterisk server with JAIN-Sip. Now I want to transfer audio data via libjitsi with the following code:

MediaService mediaService = LibJitsi.getMediaService();
ArrayList mediaStreams = new ArrayList<AudioMediaStream>();
MediaDevice device = mediaService.getDefaultDevice(MediaType.AUDIO, MediaUseCase.CALL);

if (device != null) {
	DefaultStreamConnector mainConnector = new DefaultStreamConnector(
		new DatagramSocket(localRtpPort),
		new DatagramSocket(localRtpPort + 1)
	);
	AudioMediaStream stream = (AudioMediaStream) mediaService.createMediaStream(
		device
	);

	stream.setConnector(mainConnector);

	stream.setFormat(mediaService.getFormatFactory().createMediaFormat(
		"PCMU", 8000));

	stream.setTarget(new MediaStreamTarget(
		new InetSocketAddress(remoteIp, remoteRtpPort), 
		new InetSocketAddress(remoteIp, remoteRtpPort + 1)
	));
	stream.setDirection(MediaDirection.SENDRECV);
	mediaStreams.add(stream);

	stream.start();
} 

But “stream.setConnector(mainConnector);” always fails (without exception). Regardless of how I initiate the connector (via InetAdress or DatagramSockets).

Do I have any wrong assumptions?

My system:
Ubuntu 18.04.2 LTS
JMF 2.1.1e
libjitsi 1096

Many thanks in advance!

Many greetings,
Tobias

You should not use jmf, but fmj. For that kind of code, you better look at the desktop client and make sure you use the dependencies used there, also it has a working example of using jain-sip and libjitsi.

Thank you very much for the clarification! I now use FMJ and in my opinion I can also successfully determine CaptureDevices with it. However, I am not able to generate an AudioMediaSteam based on a CaptureDeviceInfo object or a MediaDevice.

Am I wrong again here?

// add capture devices
net.sf.fmj.media.cdp.GlobalCaptureDevicePlugger.addCaptureDevices();

//Get the media source (microphone)
AudioFormat captureFormat = new AudioFormat( AudioFormat.LINEAR, 8000, 8, 1 );
CaptureDeviceInfo di = ( CaptureDeviceInfo ) CaptureDeviceManager
        .getDeviceList( captureFormat ).firstElement();
// di.getLocator() > javasound://
// di.getFormats()[0] > LINEAR, 44100.0 Hz, 32-bit, 32-channel, LittleEndian, Signed, 1411200.0 frame rate, FrameSize=1024 bits

MediaService mediaService = LibJitsi.getMediaService();
MediaDevice device = new MediaDeviceImpl(di, MediaType.AUDIO);

// device.getMediaType() > audio
// device.getFormat() > rtpmap:-1 LINEAR/44100/32
// device.getDirection() > sendrecv

// device.getSupportedFormats() < Fails / Not working ?
// Fails:
AudioMediaStream stream = (AudioMediaStream) mediaService.createMediaStream(device);