[jitsi-dev] Streaming an audio file over RTP using Libjitsi


#1

Hi all,

I am trying to adapt the AVReceive2 and AVTransmit2 examples from Libjitsi
sources in order to be able to stream local media files over the network.
Unfortunately I do not see how I can reuse the higher level concepts like
MediaService and MediaStream for that purpose, as they seem to lack the
facilities for creating and operating on data streams apart from those,
coming from the real MediaDevice-s. The simplest approach I found when
using the pure JMF/FMJ in order to read a file and stream it over RTP was
to do something like this (details omitted):

File f = new File("samplemedia/gulp2.wav");
processor = Manager.createProcessor(f.toURI().toURL());
processor.setContentDescriptor(new
ContentDescriptor(ContentDescriptor.RAW_RTP));
DataSource ds = processor.getDataOutput();
String url = "rtp://127.0.0.1:8000/audio/1";
MediaLocator m = new MediaLocator(url);
DataSink d = Manager.createDataSink(ds, m);
d.open();
d.start();
processor.start();

I would be glad to reuse the high-level goodies that Libjitsi delivers
(like ICE and whole-punching utilities), but cannot figure out which
classes and at what level of abstraction should I extend in order to couple
that audio file into the MediaStream. Any hints?

Regards,
Alexander Fedulov


#2

A MediaDevice provides media data to a MediaStream to be streamed from the local user/peer to the remote peer(s). The libjitsi library implements MediaDevices which capture live audio. You'll likely want to extend AbstractMediaDevice and implement it to read the media data which it will provide to a MediaStream from a file.

···

On 23.10.2012, at 18:07, Alexander Fedulov <ijustwanttoregister@googlemail.com> wrote:

I would be glad to reuse the high-level goodies that Libjitsi delivers (like ICE and whole-punching utilities), but cannot figure out which classes and at what level of abstraction should I extend in order to couple that audio file into the MediaStream. Any hints?


#3

Hi Lyubomir,

thanks for the hint. It took some time to figure out the structure, but
thanks to your nicely designed classes' hierarchy the solution was really
simple. I currently need to stream only audio files, so I went for
extending the AudioMediaDeviceImpl directly. In my AudioFileMockMediaDevice
class I needed only to override the getDirection()
and createOutputDataSource() methods. createOutputDataSource() simply
returns a DataSource created by the Manager.createDataSource(locator)
method, where locator is a MediaLocator, pointing to a file.

PS: Libjitsi is as awesome as Jitsi. Thanks to all of the developers for
the effort!

Regards,
Alexander Fedulov

···

2012/10/24 Lyubomir Marinov <lyubomir.marinov@jitsi.org>

On 23.10.2012, at 18:07, Alexander Fedulov < > ijustwanttoregister@googlemail.com> wrote:
>
> I would be glad to reuse the high-level goodies that Libjitsi delivers
(like ICE and whole-punching utilities), but cannot figure out which
classes and at what level of abstraction should I extend in order to couple
that audio file into the MediaStream. Any hints?

A MediaDevice provides media data to a MediaStream to be streamed from the
local user/peer to the remote peer(s). The libjitsi library implements
MediaDevices which capture live audio. You'll likely want to extend
AbstractMediaDevice and implement it to read the media data which it will
provide to a MediaStream from a file.