Skip to content
Snippets Groups Projects
Commit 43436b7f authored by Lyubomir Marinov's avatar Lyubomir Marinov
Browse files

Commit work in progress of fixing the implementation of content mixing in Jitsi VideoBridge.

parent 54bf4958
No related branches found
No related tags found
No related merge requests found
......@@ -66,16 +66,59 @@ public void connect(DataSource captureDevice)
*/
protected abstract DataSource createOutputDataSource();
/**
* Initializes a new <tt>Processor</tt> instance which is to be used to play
* back media on this <tt>MediaDevice</tt>. Allows extenders to, for
* example, disable the playback on this <tt>MediaDevice</tt> by completely
* overriding and returning <tt>null</tt>.
*
* @param dataSource the <tt>DataSource</tt> which is to be played back by
* the new <tt>Processor</tt> instance
* @return a new <tt>Processor</tt> instance which is to be used to play
* back the media provided by the specified <tt>dataSource</tt> or
* <tt>null</tt> if the specified <tt>dataSource</tt> is to not be played
* back
* @throws Exception if an exception is thrown by
* {@link DataSource#connect()},
* {@link Manager#createProcessor(DataSource)}, or
* {@link DataSource#disconnect()}
*/
protected Processor createPlayer(DataSource dataSource)
throws Exception
{
Processor player = null;
// A Player is documented to be created on a connected DataSource.
dataSource.connect();
try
{
player = Manager.createProcessor(dataSource);
}
finally
{
if (player == null)
dataSource.disconnect();
}
return player;
}
/**
* Initializes a new <tt>Renderer</tt> instance which is to play back media
* on this <tt>MediaDevice</tt>.
* on this <tt>MediaDevice</tt>. Allows extenders to initialize a specific
* <tt>Renderer</tt> instance. The implementation of
* <tt>AbstractMediaDevice</tt> returns <tt>null</tt> which means that it is
* left to FMJ to choose a suitable <tt>Renderer</tt> irrespective of this
* <tt>MediaDevice</tt>.
*
* @return a new <tt>Renderer</tt> instance which is to play back media on
* this <tt>MediaDevice</tt> or <tt>null</tt> if a suitable
* <tt>Renderer</tt> is to be chosen irrespective of this
* <tt>MediaDevice</tt>
*/
public abstract Renderer createRenderer();
protected Renderer createRenderer()
{
return null;
}
/**
* Creates a new <tt>MediaDeviceSession</tt> instance which is to represent
......
......@@ -191,16 +191,18 @@ protected void connect(
}
/**
* Initializes a new <tt>Renderer</tt> instance which is to play back media
* on this <tt>MediaDevice</tt>.
* {@inheritDoc}
*
* @return a new <tt>Renderer</tt> instance which is to play back media on
* this <tt>MediaDevice</tt> or <tt>null</tt> if a suitable
* <tt>Renderer</tt> is to be chosen irrespective of this
* <tt>MediaDevice</tt>
* Tries to delegate the initialization of a new <tt>Renderer</tt> instance
* to the <tt>AudioSystem</tt> which provides the <tt>CaptureDevice</tt> of
* this instance. This way both the capture and the playback are given a
* chance to happen within the same <tt>AudioSystem</tt>. If the discovery
* of the delegate fails, the implementation of <tt>MediaDeviceImpl</tt> is
* executed and it currently leaves it to FMJ to choose a <tt>Renderer</tt>
* irrespective of this <tt>MediaDevice</tt>.
*/
@Override
public Renderer createRenderer()
protected Renderer createRenderer()
{
Renderer renderer = null;
......
......@@ -205,15 +205,28 @@ public AudioMixingPushBufferDataSource createOutputDataSource()
}
/**
* Initializes a new <tt>Renderer</tt> instance which is to play back media
* on this <tt>MediaDevice</tt>.
* {@inheritDoc}
*
* @return a new <tt>Renderer</tt> instance which is to play back media on
* this <tt>MediaDevice</tt> or <tt>null</tt> if a suitable
* <tt>Renderer</tt> is to be chosen irrespective of this
* <tt>MediaDevice</tt>
* Delegates to the {@link AbstractMediaDevice#createPlayer(DataSource)}
* implementation of the <tt>MediaDevice</tt> on which this instance enables
* mixing i.e. {@link #getWrappedDevice()}.
*/
public Renderer createRenderer()
@Override
protected Processor createPlayer(DataSource dataSource)
throws Exception
{
return device.createPlayer(dataSource);
}
/**
* {@inheritDoc}
*
* Delegates to the {@link AbstractMediaDevice#createRenderer()}
* implementation of the <tt>MediaDevice</tt> on which this instance enables
* mixing i.e. {@link #getWrappedDevice()}.
*/
@Override
protected Renderer createRenderer()
{
return device.createRenderer();
}
......@@ -650,6 +663,20 @@ protected DataSource createCaptureDevice()
return getAudioMixer().getLocalOutputDataSource();
}
/**
* {@inheritDoc}
*/
@Override
protected Player createPlayer(DataSource dataSource)
{
/*
* TODO AudioMixerMediaDevice wraps a MediaDevice so
* AudioMixerMediaDeviceSession should wrap a MediaDeviceSession of
* that same wrapped MediaDevice.
*/
return super.createPlayer(dataSource);
}
/**
* Sets <tt>listener</tt> as the list of listeners that will receive
* notifications of audio level event changes in the data arriving from
......
......@@ -167,20 +167,6 @@ protected DataSource createOutputDataSource()
: null;
}
/**
* Initializes a new <tt>Renderer</tt> instance which is to play back media
* on this <tt>MediaDevice</tt>.
*
* @return a new <tt>Renderer</tt> instance which is to play back media on
* this <tt>MediaDevice</tt> or <tt>null</tt> if a suitable
* <tt>Renderer</tt> is to be chosen irrespective of this
* <tt>MediaDevice</tt>
*/
public Renderer createRenderer()
{
return null;
}
/**
* Creates a new <tt>CaptureDevice</tt> which traces calls to a specific
* <tt>CaptureDevice</tt> for debugging purposes.
......
......@@ -430,36 +430,13 @@ protected Player createPlayer(DataSource dataSource)
Processor player = null;
Throwable exception = null;
// A Player is documented to be created on a connected DataSource.
try
{
dataSource.connect();
player = getDevice().createPlayer(dataSource);
}
catch (IOException ioex)
catch (Exception ex)
{
// TODO
exception = ioex;
}
if (exception != null)
{
logger.error(
"Failed to connect to "
+ MediaStreamImpl.toString(dataSource),
exception);
return player;
}
try
{
player = Manager.createProcessor(dataSource);
}
catch (IOException ioe)
{
exception = ioe;
}
catch (NoPlayerException npe)
{
exception = npe;
exception = ex;
}
if (exception != null)
{
......@@ -468,7 +445,7 @@ protected Player createPlayer(DataSource dataSource)
+ MediaStreamImpl.toString(dataSource),
exception);
}
else
else if (player != null)
{
/*
* We cannot wait for the Player to get configured (e.g. with
......@@ -477,6 +454,7 @@ protected Player createPlayer(DataSource dataSource)
* media (e.g. abnormally stopped), it will leave us blocked.
*/
if (playerControllerListener == null)
{
playerControllerListener = new ControllerListener()
{
......@@ -495,20 +473,20 @@ public void controllerUpdate(ControllerEvent event)
playerControllerUpdate(event);
}
};
}
player.addControllerListener(playerControllerListener);
player.configure();
if (logger.isTraceEnabled())
{
logger.trace(
"Created Player with hashCode "
+ player.hashCode()
+ " for "
+ MediaStreamImpl.toString(dataSource));
}
}
if (player == null)
dataSource.disconnect();
return player;
}
......@@ -939,12 +917,13 @@ public DataSource getOutputDataSource()
{
outputDataSource = processor.getDataOutput();
if (logger.isTraceEnabled() && (outputDataSource != null))
logger
.trace(
{
logger.trace(
"Processor with hashCode "
+ processor.hashCode()
+ " provided "
+ MediaStreamImpl.toString(outputDataSource));
}
/*
* Whoever wants the outputDataSource, they expect it to be started
......
......@@ -123,20 +123,6 @@ protected synchronized DataSource createOutputDataSource()
: deviceSession.getOutputDataSource();
}
/**
* Initializes a new <tt>Renderer</tt> instance which is to play back media
* on this <tt>MediaDevice</tt>.
*
* @return a new <tt>Renderer</tt> instance which is to play back media on
* this <tt>MediaDevice</tt> or <tt>null</tt> if a suitable
* <tt>Renderer</tt> is to be chosen irrespective of this
* <tt>MediaDevice</tt>
*/
public Renderer createRenderer()
{
return null;
}
/**
* Creates a new <tt>MediaDeviceSession</tt> instance which is to represent
* the use of this <tt>MediaDevice</tt> by a <tt>MediaStream</tt>.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment