1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 00:59:39 +02:00

Merge branch '4.2'

This commit is contained in:
Florian Schmaus 2017-05-25 10:39:59 +02:00
commit 7a5f9e6a03
187 changed files with 2284 additions and 588 deletions

View file

@ -213,7 +213,7 @@ public class AudioChannel {
// Wait for it to configure
boolean result = waitForState(processor, Processor.Configured);
if (!result){
if (!result) {
return "Couldn't configure processor";
}
@ -221,7 +221,7 @@ public class AudioChannel {
TrackControl[] tracks = processor.getTrackControls();
// Do we have atleast one track?
if (tracks == null || tracks.length < 1){
if (tracks == null || tracks.length < 1) {
return "Couldn't find tracks in processor";
}

View file

@ -54,7 +54,7 @@ public class AudioMediaSession extends JingleMediaSession {
*/
public AudioMediaSession(final PayloadType payloadType, final TransportCandidate remote,
final TransportCandidate local, String locator, JingleSession jingleSession) {
super(payloadType, remote, local, locator==null?"dsound://":locator,jingleSession);
super(payloadType, remote, local, locator == null ? "dsound://" : locator,jingleSession);
initialize();
}

View file

@ -79,18 +79,18 @@ public class AudioMediaSession extends JingleMediaSession implements MediaSessio
/**
* The master key. Hardcoded for now.
*/
byte[] masterKey = new byte[]{(byte) 0xE1, (byte) 0xF9, 0x7A, 0x0D, 0x3E, 0x01, (byte) 0x8B, (byte) 0xE0, (byte) 0xD6, 0x4F, (byte) 0xA3, 0x2C, 0x06, (byte) 0xDE, 0x41, 0x39};
byte[] masterKey = new byte[] {(byte) 0xE1, (byte) 0xF9, 0x7A, 0x0D, 0x3E, 0x01, (byte) 0x8B, (byte) 0xE0, (byte) 0xD6, 0x4F, (byte) 0xA3, 0x2C, 0x06, (byte) 0xDE, 0x41, 0x39};
/**
* The master salt. Hardcoded for now.
*/
byte[] masterSalt = new byte[]{0x0E, (byte) 0xC6, 0x75, (byte) 0xAD, 0x49, (byte) 0x8A, (byte) 0xFE, (byte) 0xEB, (byte) 0xB6, (byte) 0x96, 0x0B, 0x3A, (byte) 0xAB, (byte) 0xE6};
byte[] masterSalt = new byte[] {0x0E, (byte) 0xC6, 0x75, (byte) 0xAD, 0x49, (byte) 0x8A, (byte) 0xFE, (byte) 0xEB, (byte) 0xB6, (byte) 0x96, 0x0B, 0x3A, (byte) 0xAB, (byte) 0xE6};
DatagramSocket[] localPorts = MediaSession.getLocalPorts(InetAddress.getByName(localhost), localPort);
MediaSession session = MediaSession.createInstance(remoteHost, remotePort, localPorts, quality, secure, masterKey, masterSalt);
session.setListener(eventHandler);
session.setSourceDescription(new SourceDescription[]{new SourceDescription(SourceDescription.SOURCE_DESC_NAME, "Superman", 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_EMAIL, "cdcie.tester@je.jfcom.mil", 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_LOC, InetAddress.getByName(localhost) + " Port " + session.getLocalDataPort(), 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_TOOL, "JFCOM CDCIE Audio Chat", 1, false)});
session.setSourceDescription(new SourceDescription[] {new SourceDescription(SourceDescription.SOURCE_DESC_NAME, "Superman", 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_EMAIL, "cdcie.tester@je.jfcom.mil", 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_LOC, InetAddress.getByName(localhost) + " Port " + session.getLocalDataPort(), 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_TOOL, "JFCOM CDCIE Audio Chat", 1, false)});
return session;
}

View file

@ -69,7 +69,7 @@ public abstract class AbstractBufferedImageOp implements BufferedImageOp, Clonea
public int[] getRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) {
int type = image.getType();
if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB)
return (int [])image.getRaster().getDataElements(x, y, width, height, pixels);
return (int[]) image.getRaster().getDataElements(x, y, width, height, pixels);
return image.getRGB(x, y, width, height, pixels, 0, width);
}

View file

@ -167,8 +167,8 @@ public class ImageReceiver extends Canvas {
this.decoder = decoder;
}
public void stop(){
this.on=false;
public void stop() {
this.on = false;
socket.close();
}
}

View file

@ -61,10 +61,10 @@ public class OctTreeQuantizer implements Quantizer {
if (count == 0)
LOGGER.fine(indentStr + index + ": count=" + count);
else
LOGGER.fine(indentStr + index + ": count=" + count + " red=" + (totalRed/count) + " green=" + (totalGreen / count) + " blue=" + (totalBlue / count));
LOGGER.fine(indentStr + index + ": count=" + count + " red=" + (totalRed / count) + " green=" + (totalGreen / count) + " blue=" + (totalBlue / count));
for (int i = 0; i < 8; i++)
if (leaf[i] != null)
leaf[i].list(s, level+2);
leaf[i].list(s, level + 2);
}
}
@ -77,8 +77,8 @@ public class OctTreeQuantizer implements Quantizer {
public OctTreeQuantizer() {
setup(256);
colorList = new ArrayList<>(MAX_LEVEL+1);
for (int i = 0; i < MAX_LEVEL+1; i++)
colorList = new ArrayList<>(MAX_LEVEL + 1);
for (int i = 0; i < MAX_LEVEL + 1; i++)
colorList.add(i, new Vector<OctTreeNode>());
root = new OctTreeNode();
}
@ -102,7 +102,7 @@ public class OctTreeQuantizer implements Quantizer {
@Override
public void addPixels(int[] pixels, int offset, int count) {
for (int i = 0; i < count; i++) {
insertColor(pixels[i+offset]);
insertColor(pixels[i + offset]);
if (colors > reduceColors)
reduceTree(reduceColors);
}
@ -203,7 +203,7 @@ public class OctTreeQuantizer implements Quantizer {
}
private void reduceTree(int numColors) {
for (int level = MAX_LEVEL-1; level >= 0; level--) {
for (int level = MAX_LEVEL - 1; level >= 0; level--) {
Vector<OctTreeNode> v = colorList.get(level);
if (v != null && v.size() > 0) {
for (int j = 0; j < v.size(); j++) {
@ -222,7 +222,7 @@ public class OctTreeQuantizer implements Quantizer {
node.children--;
colors--;
nodes--;
colorList.get(level+1).removeElement(child);
colorList.get(level + 1).removeElement(child);
}
}
node.isLeaf = true;
@ -273,9 +273,9 @@ public class OctTreeQuantizer implements Quantizer {
if (node.isLeaf) {
int count = node.count;
table[index] = 0xff000000 |
((node.totalRed/count) << 16) |
((node.totalGreen/count) << 8) |
node.totalBlue/count;
((node.totalRed / count) << 16) |
((node.totalGreen / count) << 8) |
node.totalBlue / count;
node.index = index++;
} else {
for (int i = 0; i < 8; i++) {

View file

@ -62,14 +62,14 @@ public class PixelUtils {
}
public static int interpolate(int v1, int v2, float f) {
return clamp((int)(v1+f*(v2-v1)));
return clamp((int) (v1 + f * (v2 - v1)));
}
public static int brightness(int rgb) {
int r = (rgb >> 16) & 0xff;
int g = (rgb >> 8) & 0xff;
int b = rgb & 0xff;
return (r+g+b)/3;
return (r + g + b) / 3;
}
public static boolean nearColors(int rgb1, int rgb2, int tolerance) {
@ -79,7 +79,7 @@ public class PixelUtils {
int r2 = (rgb2 >> 16) & 0xff;
int g2 = (rgb2 >> 8) & 0xff;
int b2 = rgb2 & 0xff;
return Math.abs(r1-r2) <= tolerance && Math.abs(g1-g2) <= tolerance && Math.abs(b1-b2) <= tolerance;
return Math.abs(r1 - r2) <= tolerance && Math.abs(g1 - g2) <= tolerance && Math.abs(b1 - b2) <= tolerance;
}
private final static float[] hsb1 = new float[3];//FIXME-not thread safe
@ -120,24 +120,24 @@ public class PixelUtils {
b1 = Math.max(b1, b2);
break;
case ADD:
r1 = clamp(r1+r2);
g1 = clamp(g1+g2);
b1 = clamp(b1+b2);
r1 = clamp(r1 + r2);
g1 = clamp(g1 + g2);
b1 = clamp(b1 + b2);
break;
case SUBTRACT:
r1 = clamp(r2-r1);
g1 = clamp(g2-g1);
b1 = clamp(b2-b1);
r1 = clamp(r2 - r1);
g1 = clamp(g2 - g1);
b1 = clamp(b2 - b1);
break;
case DIFFERENCE:
r1 = clamp(Math.abs(r1-r2));
g1 = clamp(Math.abs(g1-g2));
b1 = clamp(Math.abs(b1-b2));
r1 = clamp(Math.abs(r1 - r2));
g1 = clamp(Math.abs(g1 - g2));
b1 = clamp(Math.abs(b1 - b2));
break;
case MULTIPLY:
r1 = clamp(r1*r2/255);
g1 = clamp(g1*g2/255);
b1 = clamp(b1*b2/255);
r1 = clamp(r1 * r2 / 255);
g1 = clamp(g1 * g2 / 255);
b1 = clamp(b1 * b2 / 255);
break;
case DISSOLVE:
if ((randomGenerator.nextInt() & 0xff) <= a1) {
@ -147,9 +147,9 @@ public class PixelUtils {
}
break;
case AVERAGE:
r1 = (r1+r2)/2;
g1 = (g1+g2)/2;
b1 = (b1+b2)/2;
r1 = (r1 + r2) / 2;
g1 = (g1 + g2) / 2;
b1 = (b1 + b2) / 2;
break;
case HUE:
case SATURATION:
@ -198,25 +198,25 @@ public class PixelUtils {
r1 = g1 = b1 = 0xff;
break;
case DST_IN:
r1 = clamp((r2*a1)/255);
g1 = clamp((g2*a1)/255);
b1 = clamp((b2*a1)/255);
a1 = clamp((a2*a1)/255);
r1 = clamp((r2 * a1) / 255);
g1 = clamp((g2 * a1) / 255);
b1 = clamp((b2 * a1) / 255);
a1 = clamp((a2 * a1) / 255);
return (a1 << 24) | (r1 << 16) | (g1 << 8) | b1;
case ALPHA:
a1 = a1*a2/255;
a1 = a1 * a2 / 255;
return (a1 << 24) | (r2 << 16) | (g2 << 8) | b2;
case ALPHA_TO_GRAY:
int na = 255-a1;
int na = 255 - a1;
return (a1 << 24) | (na << 16) | (na << 8) | na;
}
if (extraAlpha != 0xff || a1 != 0xff) {
a1 = a1*extraAlpha/255;
int a3 = (255-a1)*a2/255;
r1 = clamp((r1*a1+r2*a3)/255);
g1 = clamp((g1*a1+g2*a3)/255);
b1 = clamp((b1*a1+b2*a3)/255);
a1 = clamp(a1+a3);
a1 = a1 * extraAlpha / 255;
int a3 = (255 - a1) * a2 / 255;
r1 = clamp((r1 * a1 + r2 * a3) / 255);
g1 = clamp((g1 * a1 + g2 * a3) / 255);
b1 = clamp((b1 * a1 + b2 * a3) / 255);
a1 = clamp(a1 + a3);
}
return (a1 << 24) | (r1 << 16) | (g1 << 8) | b1;
}

View file

@ -37,7 +37,7 @@ public class QuantizeFilter extends WholeImageFilter {
0, 0, 7,
3, 5, 1,
};
private int sum = 3+5+7+1;
private int sum = 3 + 5 + 7 + 1;
private boolean dither;
private int numColors = 256;
@ -92,7 +92,7 @@ public class QuantizeFilter extends WholeImageFilter {
}
public void quantize(int[] inPixels, int[] outPixels, int width, int height, int numColors, boolean dither, boolean serpentine) {
int count = width*height;
int count = width * height;
Quantizer quantizer = new OctTreeQuantizer();
quantizer.setup(numColors);
quantizer.addPixels(inPixels, 0, count);
@ -107,10 +107,10 @@ public class QuantizeFilter extends WholeImageFilter {
boolean reverse = serpentine && (y & 1) == 1;
int direction;
if (reverse) {
index = y*width+width-1;
index = y * width + width - 1;
direction = -1;
} else {
index = y*width;
index = y * width;
direction = 1;
}
for (int x = 0; x < width; x++) {
@ -127,30 +127,30 @@ public class QuantizeFilter extends WholeImageFilter {
int g2 = (rgb2 >> 8) & 0xff;
int b2 = rgb2 & 0xff;
int er = r1-r2;
int eg = g1-g2;
int eb = b1-b2;
int er = r1 - r2;
int eg = g1 - g2;
int eb = b1 - b2;
for (int i = -1; i <= 1; i++) {
int iy = i+y;
int iy = i + y;
if (0 <= iy && iy < height) {
for (int j = -1; j <= 1; j++) {
int jx = j+x;
int jx = j + x;
if (0 <= jx && jx < width) {
int w;
if (reverse)
w = matrix[(i+1)*3-j+1];
w = matrix[(i + 1) * 3 - j + 1];
else
w = matrix[(i+1)*3+j+1];
w = matrix[(i + 1) * 3 + j + 1];
if (w != 0) {
int k = reverse ? index - j : index + j;
rgb1 = inPixels[k];
r1 = (rgb1 >> 16) & 0xff;
g1 = (rgb1 >> 8) & 0xff;
b1 = rgb1 & 0xff;
r1 += er * w/sum;
g1 += eg * w/sum;
b1 += eb * w/sum;
r1 += er * w / sum;
g1 += eg * w / sum;
b1 += eb * w / sum;
inPixels[k] = (PixelUtils.clamp(r1) << 16) | (PixelUtils.clamp(g1) << 8) | PixelUtils.clamp(b1);
}
}
@ -165,7 +165,7 @@ public class QuantizeFilter extends WholeImageFilter {
@Override
protected int[] filterPixels(int width, int height, int[] inPixels, Rectangle transformedSpace) {
int[] outPixels = new int[width*height];
int[] outPixels = new int[width * height];
quantize(inPixels, outPixels, width, height, numColors, dither, serpentine);

View file

@ -245,7 +245,7 @@ public class ICECandidate extends TransportCandidate implements Comparable<ICECa
public void testFinished(TestResult testResult, TransportCandidate candidate) {
if (testResult.isReachable() && checkingCandidate.equals(candidate)) {
result.setResult(true);
LOGGER.fine("Candidate reachable: " + candidate.getIp() + ":" + candidate.getPort() + " from " + getIp() +":" + getPort());
LOGGER.fine("Candidate reachable: " + candidate.getIp() + ":" + candidate.getPort() + " from " + getIp() + ":" + getPort());
}
}
};

View file

@ -132,7 +132,7 @@ public class ICEResolver extends TransportResolver {
Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();
short i = 0;
NetworkInterface nic = NetworkInterface.getByInetAddress(candidate.getAddress().getInetAddress());
while(nics.hasMoreElements()) {
while (nics.hasMoreElements()) {
NetworkInterface checkNIC = nics.nextElement();
if (checkNIC.equals(nic)) {
nicNum = i;

View file

@ -518,7 +518,7 @@ public class RTPBridge extends IQ {
// Cancel the collector.
collector.cancel();
if(response == null) return null;
if (response == null) return null;
if (response.getIp() == null || response.getIp().equals("")) return null;
@ -529,7 +529,7 @@ public class RTPBridge extends IQ {
catch (SocketException e) {
LOGGER.log(Level.WARNING, "exception", e);
}
while (ifaces!=null&&ifaces.hasMoreElements()) {
while (ifaces != null && ifaces.hasMoreElements()) {
NetworkInterface iface = ifaces.nextElement();
Enumeration<InetAddress> iaddresses = iface.getInetAddresses();

View file

@ -294,7 +294,7 @@ public class STUNResolver extends TransportResolver {
@Override
public void initialize() throws XMPPException {
LOGGER.fine("Initialized");
if (!isResolving()&&!isResolved()) {
if (!isResolving() && !isResolved()) {
// Get the best STUN server available
if (currentServer.isNull()) {
loadSTUNServers();

View file

@ -80,7 +80,7 @@ public class TcpUdpBridgeClient {
localUdpSocket.receive(p);
if (p.getLength() == 0) continue;
LOGGER.fine("UDP Client Received and Sending to TCP Server:"+new String(p.getData(),0,p.getLength(),"UTF-8"));
LOGGER.fine("UDP Client Received and Sending to TCP Server:" + new String(p.getData(), 0, p.getLength(), "UTF-8"));
out.write(p.getData(), 0, p.getLength());
out.flush();
@ -112,7 +112,7 @@ public class TcpUdpBridgeClient {
int s = in.read(b);
//if (s == -1) continue;
LOGGER.fine("TCP Client:" +new String(b,0,s,"UTF-8"));
LOGGER.fine("TCP Client:" + new String(b, 0, s, "UTF-8"));
DatagramPacket udpPacket = new DatagramPacket(b, s);

View file

@ -123,7 +123,7 @@ public abstract class JingleContentDescription implements ExtensionElement {
JinglePayloadType jpt = jinglePtsIter.next();
if (jpt instanceof JinglePayloadType.Audio) {
JinglePayloadType.Audio jpta = (JinglePayloadType.Audio) jpt;
result.add((PayloadType.Audio)jpta.getPayloadType());
result.add((PayloadType.Audio) jpta.getPayloadType());
}
}

View file

@ -325,7 +325,7 @@ public class JingleTransport implements ExtensionElement {
protected String getChildElements() {
StringBuilder buf = new StringBuilder();
if (transportCandidate != null) {// && transportCandidate instanceof ICECandidate) {
if (transportCandidate != null) { // && transportCandidate instanceof ICECandidate) {
ICECandidate tci = (ICECandidate) transportCandidate;
// We convert the transportElement candidate to XML here...