Well... Adds AudioMixer-related functionality for the sake of completeness, nothing that currently seems to change anything it its behavior. Fixes a few javadocs.

cusax-fix
Lyubomir Marinov 16 years ago
parent b78890b23b
commit 78db66c3df

@ -17,7 +17,8 @@
* @author Ken Larson
* @author Lubomir Marinov
*/
public class ProcessorUtility implements ControllerListener
public class ProcessorUtility
implements ControllerListener
{
/**
@ -126,7 +127,7 @@ else if (state == Processor.Realized)
// Wait until we get an event that confirms the
// success of the method, or a failure event.
// See StateListener inner class
while ((processor.getState() < state) &&!failed)
while ((processor.getState() < state) && !failed)
{
Object stateLock = getStateLock();

@ -11,6 +11,7 @@
import java.util.*;
import javax.media.*;
import javax.media.Controls; // disambiguation
import javax.media.control.*;
import javax.media.format.*;
import javax.media.protocol.*;
@ -408,6 +409,49 @@ private InputStreamDesc getExistingInputStreamDesc(
return null;
}
/**
* Gets the control of a specific <tt>Controls</tt> implementation of a
* specific type if such a control is made available through
* {@link Controls#getControls()}; otherwise, returns <tt>null</tt>.
*
* @param controlsImpl the implementation of <tt>Controls</tt> which is to
* be queried for its list of controls so that the control of the specified
* type can be looked for
* @param controlType a <tt>String</tt> value which names the type of the
* control to be retrieved
* @return an <tt>Object</tt> which represents the control of
* <tt>controlsImpl</tt> of the specified <tt>controlType</tt> if such a
* control is made available through <tt>Controls#getControls()</tt>;
* otherwise, <tt>null</tt>
*/
public static Object getControl(Controls controlsImpl, String controlType)
{
Object[] controls = controlsImpl.getControls();
if ((controls != null) && (controls.length > 0))
{
Class<?> controlClass;
try
{
controlClass = Class.forName(controlType);
}
catch (ClassNotFoundException cnfe)
{
controlClass = null;
logger
.warn(
"Failed to find control class " + controlType,
cnfe);
}
if (controlClass != null)
for (Object control : controls)
if (controlClass.isInstance(control))
return control;
}
return null;
}
/**
* Gets the duration of each one of the output streams produced by this
* <tt>AudioMixer</tt>.
@ -1143,30 +1187,7 @@ public long getContentLength()
*/
public Object getControl(String controlType)
{
Object[] controls = getControls();
if ((controls != null) && (controls.length > 0))
{
Class<?> controlClass;
try
{
controlClass = Class.forName(controlType);
}
catch (ClassNotFoundException cnfe)
{
controlClass = null;
logger
.warn(
"Failed to find control class " + controlType,
cnfe);
}
if (controlClass != null)
for (Object control : controls)
if (controlClass.isInstance(control))
return control;
}
return null;
return AudioMixer.getControl(this, controlType);
}
/*

@ -140,13 +140,18 @@ public String getContentType()
return audioMixer.getContentType();
}
/*
* Implements DataSource#getControl(String). Does nothing.
/**
* Implements DataSource#getControl(String).
*
* @param controlType a <tt>String</tt> value which names the type of the
* control of this instance to be retrieved
* @return an <tt>Object</tt> which represents the control of this instance
* with the specified type if such a control is available; otherwise,
* <tt>null</tt>
*/
public Object getControl(String controlType)
{
// TODO Auto-generated method stub
return null;
return AudioMixer.getControl(this, controlType);
}
/*

@ -0,0 +1,96 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.neomedia.control;
import javax.media.*;
import javax.media.control.*;
/**
* Provides an abstract implementation of <tt>FormatControl</tt> which
* facilitates implementers by requiring them to implement just
* {@link FormatControl#getSupportedFormats()} and
* {@link FormatControl#getFormat()}.
*
* @author Lubomir Marinov
*/
public abstract class AbstractFormatControl
implements FormatControl
{
/**
* The indicator which determines whether this track is enabled.
*/
private boolean enabled;
/**
* Implements {@link Controls#getControlComponent()}. Returns <tt>null</tt>.
*
* @return a <tt>Component</tt> which represents UI associated with this
* instance if any; otherwise, <tt>null</tt>
*/
public java.awt.Component getControlComponent()
{
// No Component is exported by this instance.
return null;
}
/**
* Implements {@link FormatControl#isEnabled()}.
*
* @return <tt>true</tt> if this track is enabled; otherwise, <tt>false</tt>
*/
public boolean isEnabled()
{
return enabled;
}
/**
* Implements {@link FormatControl#setEnabled(boolean)}.
*
* @param enabled <tt>true</tt> if this track is to be enabled; otherwise,
* <tt>false</tt>
*/
public void setEnabled(boolean enabled)
{
this.enabled = enabled;
}
/**
* Implements {@link FormatControl#setFormat(Format)}. Not supported and
* just returns the currently set format if the specified <tt>Format</tt> is
* supported and <tt>null</tt> if it is not supported.
*
* @param format the <tt>Format</tt> to be set on this instance
* @return the currently set <tt>Format</tt> after the attempt to set it on
* this instance if <tt>format</tt> is supported by this instance and
* regardless of whether it was actually set; <tt>null</tt> if
* <tt>format</tt> is not supported by this instance
*/
public Format setFormat(Format format)
{
/*
* Determine whether the specified format is supported by this instance
* because we have to return null if it is not supported. Or at least
* that is what I gather from the respective javadoc.
*/
boolean formatIsSupported = false;
if (format != null)
for (Format supportedFormat : getSupportedFormats())
if (supportedFormat.matches(format))
{
formatIsSupported = true;
break;
}
/*
* We do not actually support setFormat so we have to return the
* currently set format if the specified format is supported.
*/
return (formatIsSupported) ? getFormat() : null;
}
}
Loading…
Cancel
Save