[jitsi-dev] LibJitsi Realtime Audio Streaming Help


#1

Hello,

I was hoping if I could receive some help for using the libjitsi library as
I am frankly new to the API. As of right now, I am trying to implement VoIP
with the AudioMediaStreams provided by the API.

However, after implementing all the streams similarly to the examples
available from the library, it appears that the receiving end is not
playing back any of the data. I've set the directions on both streams to be
receivable and sendable.

SERVER SIDE (the mixer) -

Initializing the Stream, and providing a mixer:

private boolean initialize() throws Exception {
MediaService mediaService = LibJitsi.getMediaService();

mediaStreams = new ArrayList<AudioMediaStream>();
MediaDevice device = mediaService.getDefaultDevice(MediaType.AUDIO,
MediaUseCase.CALL);
if (device == null) {
    return false;
}
mediaDevice = mediaService.createMixer(device);
mainConnector = new DefaultStreamConnector();

return true;
    }

On connection of an user in the conference, connect to user's stream and
start the stream:

public void addVoice(String clientAddress, int remotePort) {
MediaService mediaService = LibJitsi.getMediaService();
AudioMediaStream stream = (AudioMediaStream)
mediaService.createMediaStream(mainConnector,
mediaDevice);
stream.setFormat(mediaService.getFormatFactory().createMediaFormat(
"PCMU", 8000));
stream.setTarget(new MediaStreamTarget(new InetSocketAddress(
externalAddress, remotePort), new InetSocketAddress(
externalAddress, remotePort + 1)));
stream.setDirection(MediaDirection.SENDRECV);
mediaStreams.add(stream);
stream.start();
    }

CLIENT SIDE -

Initialize the stream and connect to the server:

private boolean initialize() throws Exception {
MediaService mediaService = LibJitsi.getMediaService();

mediaStreams = new ArrayList<AudioMediaStream>();
MediaDevice device = mediaService.getDefaultDevice(MediaType.AUDIO,
MediaUseCase.CALL);
if (device == null) {
    return false;
}
mainConnector = new DefaultStreamConnector();

AudioMediaStream stream = (AudioMediaStream)
mediaService.createMediaStream(mainConnector,
device);
stream.setFormat(mediaService.getFormatFactory().createMediaFormat(
"PCMU", 8000));
stream.setTarget(new MediaStreamTarget(new InetSocketAddress(
externalAddress, port), new InetSocketAddress(externalAddress,
port + 1)));
stream.setDirection(MediaDirection.SENDRECV);
mediaStreams.add(stream);

stream.start();

return true;
    }

There are no exceptions being called in any of the methods whatsoever, and
I was wondering if I had gotten the whole networking infrastructure wrong
when it comes to realtime streaming.

If there is anything wrong with the way I am implementing it, please do
reply.

Sincerely,
Dranithix Games


#2

Hello,

Hello,

I was hoping if I could receive some help for using the libjitsi library
as I am frankly new to the API. As of right now, I am trying to
implement VoIP with the AudioMediaStreams provided by the API.

However, after implementing all the streams similarly to the examples
available from the library, it appears that the receiving end is not
playing back any of the data. I've set the directions on both streams to
be receivable and sendable.

SERVER SIDE (the mixer) -

Initializing the Stream, and providing a mixer:

private boolean initialize() throws Exception {
MediaService mediaService = LibJitsi.getMediaService();

mediaStreams = new ArrayList<AudioMediaStream>();
MediaDevice device = mediaService.getDefaultDevice(MediaType.AUDIO,
MediaUseCase.CALL);
if (device == null) {
   return false;
}
mediaDevice = mediaService.createMixer(device);
mainConnector = new DefaultStreamConnector();

A StreamConnector initialized like this will not have DatagramSockets
which to use for RTP/RTCP (see the javadoc for the constructor). It's
unusable.

If you want to use DefaultStreamConnector, you need to use one of the
other constructors and provide either your own DatagramSockets, or
provide an InetAddress and let it bind on it's own (again, see the
javadoc for the constructors and createDatagramSocket).

I don't know if you can share a StreamConnector between multiple
MediaStream-s like this, someone else will have to answer.

return true;
    }

On connection of an user in the conference, connect to user's stream and
start the stream:

public void addVoice(String clientAddress, int remotePort) {
MediaService mediaService = LibJitsi.getMediaService();
AudioMediaStream stream = (AudioMediaStream)
mediaService.createMediaStream(mainConnector,
mediaDevice);
stream.setFormat(mediaService.getFormatFactory().createMediaFormat(
"PCMU", 8000));
stream.setTarget(new MediaStreamTarget(new InetSocketAddress(
externalAddress, remotePort), new InetSocketAddress(
externalAddress, remotePort + 1)));

Where do externalAddress and remotePort come from? They should match the
ones used in the StreamConnector on the other end of the MediaStream.

stream.setDirection(MediaDirection.SENDRECV);
mediaStreams.add(stream);
stream.start();
    }

CLIENT SIDE -

Initialize the stream and connect to the server:

private boolean initialize() throws Exception {
MediaService mediaService = LibJitsi.getMediaService();

mediaStreams = new ArrayList<AudioMediaStream>();
MediaDevice device = mediaService.getDefaultDevice(MediaType.AUDIO,
MediaUseCase.CALL);
if (device == null) {
   return false;
}
mainConnector = new DefaultStreamConnector();

AudioMediaStream stream = (AudioMediaStream)
mediaService.createMediaStream(mainConnector,
device);
stream.setFormat(mediaService.getFormatFactory().createMediaFormat(
"PCMU", 8000));
stream.setTarget(new MediaStreamTarget(new InetSocketAddress(
externalAddress, port), new InetSocketAddress(externalAddress,
port + 1)));
stream.setDirection(MediaDirection.SENDRECV);
mediaStreams.add(stream);

stream.start();

return true;
    }

The same two comments as above apply here.

Hope that helps,
Boris

···

On 8/16/13 10:23 PM, Kenta Iwasaki wrote: