mirror of https://github.com/sipwise/jitsi.git
Hide resize button if we can detect that its not supported, and limit the resolutions we have for setting according the remote party settings. Fix changing resolution several times. Fix duplicate field for keeping framerate.cusax-fix
parent
754f0397d2
commit
6064f8d33c
@ -0,0 +1,180 @@
|
||||
/*
|
||||
* 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.protocol.sip;
|
||||
|
||||
import net.java.sip.communicator.service.neomedia.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* A wrapper of media quality control.
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class QualityControlsWrapper
|
||||
implements QualityControls
|
||||
{
|
||||
/**
|
||||
* Our class logger.
|
||||
*/
|
||||
private static final Logger logger
|
||||
= Logger.getLogger(QualityControlsWrapper.class);
|
||||
|
||||
/**
|
||||
* The peer we are controlling.
|
||||
*/
|
||||
private CallPeerSipImpl peer;
|
||||
|
||||
/**
|
||||
* The media quality control.
|
||||
*/
|
||||
private QualityControls qualityControls;
|
||||
|
||||
/**
|
||||
* The currently used video quality preset.
|
||||
*/
|
||||
protected QualityPresets remoteSendMaxPreset = null;
|
||||
|
||||
/**
|
||||
* The frame rate.
|
||||
*/
|
||||
private float maxFrameRate = -1;
|
||||
|
||||
/**
|
||||
* Creates quality control for peer.
|
||||
* @param peer
|
||||
*/
|
||||
QualityControlsWrapper(CallPeerSipImpl peer)
|
||||
{
|
||||
this.peer = peer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and obtains quality control from media stream.
|
||||
* @return
|
||||
*/
|
||||
private QualityControls getMediaQualityControls()
|
||||
{
|
||||
if(qualityControls != null)
|
||||
return qualityControls;
|
||||
|
||||
MediaStream stream = peer.getMediaHandler().getStream(MediaType.VIDEO);
|
||||
|
||||
if(stream != null && stream instanceof VideoMediaStream)
|
||||
qualityControls = ((VideoMediaStream)stream).getQualityControls();
|
||||
|
||||
return qualityControls;
|
||||
}
|
||||
|
||||
/**
|
||||
* The currently used quality preset announced as receive by remote party.
|
||||
* @return the current quality preset.
|
||||
*/
|
||||
public QualityPresets getRemoteReceivePreset()
|
||||
{
|
||||
QualityControls qControls = getMediaQualityControls();
|
||||
|
||||
if(qControls == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return qControls.getRemoteReceivePreset();
|
||||
}
|
||||
|
||||
/**
|
||||
* The minimum preset that the remote party is sending and we are receiving.
|
||||
* Not Used.
|
||||
* @return the minimum remote preset.
|
||||
*/
|
||||
public QualityPresets getRemoteSendMinPreset()
|
||||
{
|
||||
QualityControls qControls = getMediaQualityControls();
|
||||
|
||||
if(qControls == null)
|
||||
return null;
|
||||
|
||||
return qControls.getRemoteSendMinPreset();
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum preset that the remote party is sending and we are receiving.
|
||||
* @return the maximum preset announced from remote party as send.
|
||||
*/
|
||||
public QualityPresets getRemoteSendMaxPreset()
|
||||
{
|
||||
QualityControls qControls = getMediaQualityControls();
|
||||
|
||||
if(qControls == null)
|
||||
return remoteSendMaxPreset;
|
||||
|
||||
QualityPresets qp = qControls.getRemoteSendMaxPreset();
|
||||
|
||||
// there is info about max frame rate
|
||||
if(qp != null && maxFrameRate > 0)
|
||||
qp = new QualityPresets(qp.getResolution(), (int)maxFrameRate);
|
||||
|
||||
return qp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes local value of frame rate, the one we have received from
|
||||
* remote party.
|
||||
* @param f new frame rate.
|
||||
*/
|
||||
public void setMaxFrameRate(float f)
|
||||
{
|
||||
this.maxFrameRate = f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes remote send preset. This doesn't have impact of current stream.
|
||||
* But will have on next media changes.
|
||||
* With this we can try to change the resolution that the remote part
|
||||
* is sending.
|
||||
* @param preset the new preset value.
|
||||
*/
|
||||
public void setRemoteSendMaxPreset(QualityPresets preset)
|
||||
{
|
||||
QualityControls qControls = getMediaQualityControls();
|
||||
|
||||
if(qControls != null)
|
||||
qControls.setRemoteSendMaxPreset(preset);
|
||||
else
|
||||
remoteSendMaxPreset = preset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the current video settings for the peer with the desired
|
||||
* quality settings and inform the peer to stream the video
|
||||
* with those settings.
|
||||
*
|
||||
* @param preset the desired video settings
|
||||
* @throws OperationFailedException
|
||||
*/
|
||||
public void setPreferredRemoteSendMaxPreset(QualityPresets preset)
|
||||
throws OperationFailedException
|
||||
{
|
||||
QualityControls qControls = getMediaQualityControls();
|
||||
|
||||
if(qControls != null)
|
||||
{
|
||||
qControls.setRemoteSendMaxPreset(preset);
|
||||
|
||||
try
|
||||
{
|
||||
// re-invites the peer with the new settings
|
||||
peer.sendReInvite();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
ProtocolProviderServiceSipImpl.throwOperationFailedException(
|
||||
"Failed to re-invite for video quality change.",
|
||||
OperationFailedException.INTERNAL_ERROR, ex, logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.service.neomedia;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* The quality controls we use to control other party video presets.
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public interface QualityControls
|
||||
{
|
||||
/**
|
||||
* The currently used quality preset announced as receive by remote party.
|
||||
* @return the current quality preset.
|
||||
*/
|
||||
public QualityPresets getRemoteReceivePreset();
|
||||
|
||||
/**
|
||||
* The minimum preset that the remote party is sending and we are receiving.
|
||||
* @return the minimum remote preset.
|
||||
*/
|
||||
public QualityPresets getRemoteSendMinPreset();
|
||||
|
||||
/**
|
||||
* The maximum preset that the remote party is sending and we are receiving.
|
||||
* @return the maximum preset announced from remote party as send.
|
||||
*/
|
||||
public QualityPresets getRemoteSendMaxPreset();
|
||||
|
||||
/**
|
||||
* Changes remote send preset. This doesn't have impact of current stream.
|
||||
* But will have on next media changes.
|
||||
* With this we can try to change the resolution that the remote part
|
||||
* is sending.
|
||||
* @param preset the new preset value.
|
||||
*/
|
||||
public void setRemoteSendMaxPreset(QualityPresets preset);
|
||||
|
||||
/**
|
||||
* Changes remote send preset and protocols who can handle the changes
|
||||
* will implement this for re-inviting the other party or just sending that
|
||||
* media has changed.
|
||||
* @param preset the new preset.
|
||||
* @throws OperationFailedException
|
||||
*/
|
||||
public void setPreferredRemoteSendMaxPreset(QualityPresets preset)
|
||||
throws OperationFailedException;
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* 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.service.neomedia;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Predefined Quality presets used to specify some video settings during
|
||||
* call or when starting call.
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class QualityPreset
|
||||
{
|
||||
/**
|
||||
* 720p HD
|
||||
*/
|
||||
public final static QualityPreset HD_QUALITY =
|
||||
new QualityPreset(new Dimension(1280, 720), 30);
|
||||
|
||||
/**
|
||||
* SD
|
||||
*/
|
||||
public final static QualityPreset SD_QUALITY =
|
||||
new QualityPreset(new Dimension(640, 480), 20);
|
||||
|
||||
/**
|
||||
* Low
|
||||
*/
|
||||
public final static QualityPreset LO_QUALITY =
|
||||
new QualityPreset(new Dimension(320, 240), 15);
|
||||
|
||||
/**
|
||||
* The frame rate to use.
|
||||
*/
|
||||
private int frameRate;
|
||||
|
||||
/**
|
||||
* The resolution to use.
|
||||
*/
|
||||
private Dimension resolution;
|
||||
|
||||
/**
|
||||
* Creates preset with <tt>resolution</tt> and <tt>frameRate</tt>.
|
||||
* Predefined presets can be created only here.
|
||||
*
|
||||
* @param resolution the resolution.
|
||||
* @param frameRate the frame rate.
|
||||
*/
|
||||
private QualityPreset(Dimension resolution, int frameRate)
|
||||
{
|
||||
this.frameRate = frameRate;
|
||||
this.resolution = resolution;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this preset frame rate.
|
||||
* @return the frame rate.
|
||||
*/
|
||||
public int getFameRate()
|
||||
{
|
||||
return this.frameRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this preset resolution.
|
||||
* @return the resolution.
|
||||
*/
|
||||
public Dimension getResolution()
|
||||
{
|
||||
return this.resolution;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.service.neomedia;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Predefined Quality presets used to specify some video settings during
|
||||
* call or when starting call.
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class QualityPresets
|
||||
implements Comparable<QualityPresets>
|
||||
{
|
||||
/**
|
||||
* 720p HD
|
||||
*/
|
||||
public final static QualityPresets HD_QUALITY =
|
||||
new QualityPresets(new Dimension(1280, 720), 30);
|
||||
|
||||
/**
|
||||
* SD
|
||||
*/
|
||||
public final static QualityPresets SD_QUALITY =
|
||||
new QualityPresets(new Dimension(640, 480), 20);
|
||||
|
||||
/**
|
||||
* Low
|
||||
*/
|
||||
public final static QualityPresets LO_QUALITY =
|
||||
new QualityPresets(new Dimension(320, 240), 15);
|
||||
|
||||
/**
|
||||
* The frame rate to use.
|
||||
*/
|
||||
private float frameRate;
|
||||
|
||||
/**
|
||||
* The resolution to use.
|
||||
*/
|
||||
private Dimension resolution;
|
||||
|
||||
/**
|
||||
* Creates preset with <tt>resolution</tt> and <tt>frameRate</tt>.
|
||||
* Predefined presets can be created only here.
|
||||
*
|
||||
* @param resolution the resolution.
|
||||
* @param frameRate the frame rate.
|
||||
*/
|
||||
public QualityPresets(Dimension resolution, float frameRate)
|
||||
{
|
||||
this.frameRate = frameRate;
|
||||
this.resolution = resolution;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates preset with <tt>resolution</tt> and <tt>frameRate</tt>.
|
||||
* Predefined presets can be created only here.
|
||||
*
|
||||
* @param resolution the resolution.
|
||||
*/
|
||||
public QualityPresets(Dimension resolution)
|
||||
{
|
||||
// unspecified frame rate
|
||||
this(resolution, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this preset frame rate.
|
||||
* @return the frame rate.
|
||||
*/
|
||||
public float getFameRate()
|
||||
{
|
||||
return this.frameRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this preset resolution.
|
||||
* @return the resolution.
|
||||
*/
|
||||
public Dimension getResolution()
|
||||
{
|
||||
return this.resolution;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares to presets and its dimensions.
|
||||
* @param o object to compare to.
|
||||
* @return a negative integer, zero, or a positive integer as this object is
|
||||
* less than, equal to, or greater than the specified object.
|
||||
*/
|
||||
public int compareTo(QualityPresets o)
|
||||
{
|
||||
if(this.resolution.equals(o.resolution))
|
||||
return 0;
|
||||
else if(this.resolution.height < o.resolution.height &&
|
||||
this.resolution.width < o.resolution.width)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue