Introduces AbstractRenderer to aid the implementations of the Renderer FMJ/JMF interface.

cusax-fix
Lyubomir Marinov 15 years ago
parent 90ec573a4c
commit e237a844f4

@ -370,10 +370,10 @@ else if (inputLength < this.frameSize)
}
/**
* Get the matching output formats for a specific format.
* Get the output formats matching a specific input format.
*
* @param inputFormat input format
* @return array for formats matching input format
* @param inputFormat the input format to get the matching output formats of
* @return the output formats matching the specified input format
* @see AbstractCodecExt#getMatchingOutputFormats(Format)
*/
@Override

@ -764,8 +764,7 @@ public synchronized void start()
if (!started)
{
if (!connected)
throw new IOException(
getClass().getSimpleName() + " not connected");
throw new IOException(getClass().getName() + " not connected");
doStart();
started = true;

@ -0,0 +1,69 @@
/*
* Jitsi, 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.jmfext.media.renderer;
import javax.media.*;
import net.java.sip.communicator.impl.neomedia.control.*;
/**
* Provides an abstract base implementation of <tt>Renderer</tt> in order to
* facilitate extenders
*
* @author Lyubomir Marinov
*
* @param <InputFormatT> the type of <tt>Format</tt> of the media data processed
* as input by <tt>AbstractRenderer</tt>
*/
public abstract class AbstractRenderer<InputFormatT extends Format>
extends ControlsAdapter
implements Renderer
{
/**
* The <tt>Format</tt> of the media data processed as input by this
* <tt>Renderer</tt>.
*/
protected InputFormatT inputFormat;
/**
* Resets the state of this <tt>PlugIn</tt>.
*/
public void reset()
{
// TODO Auto-generated method stub
}
/**
* Sets the <tt>Format</tt> of the media data to be rendered by this
* <tt>Renderer</tt>.
*
* @param format the <tt>Format</tt> of the media data to be rendered by
* this <tt>Renderer</tt>
* @return <tt>null</tt> if the specified <tt>format</tt> is not compatible
* with this <tt>Renderer</tt>; otherwise, the <tt>Format</tt> which has
* been successfully set
*/
@SuppressWarnings("unchecked")
public Format setInputFormat(Format format)
{
Format matchingFormat = null;
for (Format supportedInputFormat : getSupportedInputFormats())
{
if (supportedInputFormat.matches(format))
{
matchingFormat = supportedInputFormat.intersects(format);
break;
}
}
if (matchingFormat == null)
return null;
inputFormat = (InputFormatT) matchingFormat;
return inputFormat;
}
}

@ -12,8 +12,8 @@
import javax.media.format.*;
import net.java.sip.communicator.impl.neomedia.*;
import net.java.sip.communicator.impl.neomedia.control.*;
import net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.portaudio.*;
import net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.*;
import net.java.sip.communicator.impl.neomedia.portaudio.*;
import net.java.sip.communicator.util.*;
@ -24,8 +24,7 @@
* @author Lyubomir Marinov
*/
public class PortAudioRenderer
extends ControlsAdapter
implements Renderer
extends AbstractRenderer<AudioFormat>
{
/**
* The <tt>Logger</tt> used by the <tt>PortAudioRenderer</tt> class and its
@ -116,12 +115,6 @@ public class PortAudioRenderer
*/
private int framesPerBuffer;
/**
* The JMF <tt>Format</tt> in which this <tt>PortAudioRenderer</tt> is
* currently configured to read the audio data to be rendered.
*/
private AudioFormat inputFormat;
/**
* The <tt>MediaLocator</tt> which specifies the device index of the
* PortAudio device used by this instance for rendering.
@ -167,13 +160,18 @@ public PortAudioRenderer()
/**
* Initializes a new <tt>PortAudioRenderer</tt> instance.
* @param enableVolumeControl whether we enable volume control or not.
*
* @param enableVolumeControl <tt>true</tt> to enable volume control;
* <tt>false</tt>, otherwise
*/
public PortAudioRenderer(boolean enableVolumeControl)
{
if(enableVolumeControl)
this.gainControl = (GainControl)NeomediaActivator
.getMediaServiceImpl().getOutputVolumeControl();
this.gainControl
= (GainControl)
NeomediaActivator
.getMediaServiceImpl()
.getOutputVolumeControl();
}
/**
@ -207,6 +205,19 @@ public synchronized void close()
}
}
/**
* Implements {@link javax.media.Controls#getControls()}. Gets the controls
* available for the owner of this instance. The current implementation
* returns an empty array because it has no available controls.
*
* @return an array of <tt>Object</tt>s which represent the controls
* available for the owner of this instance
*/
public Object[] getControls()
{
return new Object[] { gainControl };
}
/**
* Gets the <tt>MediaLocator</tt> which specifies the device index of the
* PortAudio device used by this instance for rendering.
@ -533,13 +544,6 @@ private void process(byte[] buffer, int offset, int length)
}
}
/**
* Resets this <tt>PlugIn</tt>.
*/
public void reset()
{
}
/**
* Sets the <tt>MediaLocator</tt> which specifies the device index of the
* PortAudio device to be used by <tt>PortAudioRenderer</tt> instances which
@ -564,35 +568,6 @@ else if (PortAudioRenderer.defaultLocator.equals(defaultLocator))
PortAudioRenderer.defaultLocator = defaultLocator;
}
/**
* Sets the JMF <tt>Format</tt> of the audio data to be rendered by this
* <tt>Renderer</tt>.
*
* @param format the JMF <tt>Format</tt> of the audio data to be redered by
* this instance
* @return <tt>null</tt> if the specified <tt>format</tt> is not compatible
* with this <tt>Renderer</tt>; otherwise, the JMF <tt>Format</tt> which has
* been successfully set
*/
public Format setInputFormat(Format format)
{
Format matchingFormat = null;
for (Format supportedInputFormat : getSupportedInputFormats())
{
if (supportedInputFormat.matches(format))
{
matchingFormat = supportedInputFormat.intersects(format);
break;
}
}
if (matchingFormat == null)
return null;
inputFormat = (AudioFormat) matchingFormat;
return inputFormat;
}
/**
* Sets the <tt>MediaLocator</tt> which specifies the device index of the
* PortAudio device to be used by this instance for rendering.
@ -671,17 +646,4 @@ public synchronized void stop()
}
}
}
/**
* Implements {@link javax.media.Controls#getControls()}. Gets the controls
* available for the owner of this instance. The current implementation
* returns an empty array because it has no available controls.
*
* @return an array of <tt>Object</tt>s which represent the controls
* available for the owner of this instance
*/
public Object[] getControls()
{
return new Object[]{gainControl};
}
}

@ -14,7 +14,7 @@
import javax.media.renderer.*;
import javax.swing.*;
import net.java.sip.communicator.impl.neomedia.control.*;
import net.java.sip.communicator.impl.neomedia.jmfext.media.renderer.*;
import net.java.sip.communicator.util.*;
/**
@ -24,7 +24,7 @@
* @author Lyubomir Marinov
*/
public class JAWTRenderer
extends ControlsAdapter
extends AbstractRenderer<VideoFormat>
implements VideoRenderer
{
/**
@ -110,12 +110,6 @@ public class JAWTRenderer
*/
private long handle = 0;
/**
* The <tt>VideoFormat</tt> of the input processed by this
* <tt>Renderer</tt>.
*/
private VideoFormat inputFormat;
/**
* The last known height of the input processed by this
* <tt>JAWTRenderer</tt>.
@ -497,14 +491,6 @@ static native void processLightweightComponentEvent(
static native void removeNotifyLightweightComponent(
long handle, Component component);
/**
* Resets the state of this <tt>PlugIn</tt>.
*/
public void reset()
{
// TODO Auto-generated method stub
}
/**
* Sets the region in the component of this <tt>VideoRenderer</tt> where the
* video is to be rendered.
@ -547,22 +533,10 @@ public boolean setComponent(Component component)
* <tt>Renderer</tt>. Typically, it is the supported input <tt>Format</tt>
* which most closely matches the specified <tt>Format</tt>.
*/
@Override
public Format setInputFormat(Format format)
{
Format matchingFormat = null;
for (Format supportedInputFormat : getSupportedInputFormats())
{
if (supportedInputFormat.matches(format))
{
matchingFormat = supportedInputFormat.intersects(format);
break;
}
}
if (matchingFormat == null)
return null;
inputFormat = (VideoFormat) format;
super.setInputFormat(format);
/*
* Know the width and height of the input because we'll be depicting it

Loading…
Cancel
Save