From 5765b376971667d0d2f2e4f047b08ae5ec67e4d1 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Thu, 5 May 2016 09:34:26 -0500 Subject: [PATCH] Add packet delay attribute to Colibri Channel --- .../extensions/colibri/ColibriBuilder.java | 34 ++++++++++++++ .../colibri/ColibriConferenceIQ.java | 44 +++++++++++++++++++ .../extensions/colibri/ColibriIQProvider.java | 9 ++++ 3 files changed, 87 insertions(+) diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriBuilder.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriBuilder.java index 4c703a930..133b17cb1 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriBuilder.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriBuilder.java @@ -118,6 +118,13 @@ public class ColibriBuilder */ private SimulcastMode simulcastMode; + /** + * Specifies the audio packet delay that will be set on all created audio + * channels. When set to null the builder will clear the attribute + * which stands for 'undefined'. + **/ + private Integer audioPacketDelay; + /** * Creates new instance of {@link ColibriBuilder} for given * conferenceState. @@ -221,6 +228,11 @@ public boolean addAllocateChannelsReq( remoteRtpChannelRequest.setAdaptiveLastN(adaptiveLastN); remoteRtpChannelRequest.setAdaptiveSimulcast(adaptiveSimulcast); remoteRtpChannelRequest.setSimulcastMode(simulcastMode); + if (MediaType.AUDIO.equals(mediaType)) + { + // When audioPacketDelay is null it will clear the attribute + remoteRtpChannelRequest.setPacketDelay(audioPacketDelay); + } } // Copy transport @@ -959,6 +971,28 @@ public void setAdaptiveSimulcast(Boolean adaptiveSimulcast) this.adaptiveSimulcast = adaptiveSimulcast; } + /** + * Returns an Integer which stands for the audio packet delay + * that will be set on all created audio channels or null if + * the builder should leave not include the XML attribute at all. + */ + public Integer getAudioPacketDelay() + { + return audioPacketDelay; + } + + /** + * Configures audio channels packet delay. + * @param audioPacketDelay an Integer value which stands for + * the audio packet delay that will be set on all created audio channels or + * null if the builder should not set that channel property to any + * value. + */ + public void setAudioPacketDelay(Integer audioPacketDelay) + { + this.audioPacketDelay = audioPacketDelay; + } + /** * Sets channel 'simulcast-mode' option that will be added to the * request when channels are created. diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriConferenceIQ.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriConferenceIQ.java index 3fefc9f03..d5cf175c8 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriConferenceIQ.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriConferenceIQ.java @@ -542,6 +542,14 @@ public static class Channel public static final String RECEIVING_SIMULCAST_LAYER = "receive-simulcast-layer"; + /** + * The XML name of the packet-delay attribute of + * a channel of a content of a conference IQ + * which represents the value of the {@link #packetDelay} property of + * ColibriConferenceIQ.Channel. + */ + public static final String PACKET_DELAY_ATTR_NAME = "packet-delay"; + /** * The XML name of the rtcpport attribute of a channel * of a content of a conference IQ which represents @@ -612,6 +620,11 @@ public static class Channel */ private SimulcastMode simulcastMode; + /** + * The amount of delay added to the RTP stream in a number of packets. + */ + private Integer packetDelay; + /** * The payload-type elements defined by XEP-0167: Jingle RTP * Sessions associated with this channel. @@ -892,6 +905,18 @@ public SimulcastMode getSimulcastMode() return simulcastMode; } + /** + * Returns an Integer which stands for the amount of delay + * added to the RTP stream in a number of packets. + * + * @return Integer with the value or null if + * unspecified. + */ + public Integer getPacketDelay() + { + return packetDelay; + } + /** * Gets a list of payload-type elements defined by XEP-0167: * Jingle RTP Sessions added to this channel. @@ -1081,6 +1106,14 @@ protected void printAttributes(StringBuilder xml) .append("='").append(adaptiveSimulcast).append('\''); } + // packet-delay + Integer packetDelay = getPacketDelay(); + if (packetDelay != null) + { + xml.append(' ').append(PACKET_DELAY_ATTR_NAME).append("='") + .append(packetDelay).append('\''); + } + // simulcastMode SimulcastMode simulcastMode = getSimulcastMode(); @@ -1313,6 +1346,17 @@ public void setAdaptiveSimulcast(Boolean adaptiveSimulcast) this.adaptiveSimulcast = adaptiveSimulcast; } + /** + * Configures channel's packet delay which tells by how many packets + * the RTP streams will be delayed. + * @param packetDelay an Integer value which stands for + * the packet delay that will be set or null to leave undefined + */ + public void setPacketDelay(Integer packetDelay) + { + this.packetDelay = packetDelay; + } + /** * Sets the value of the 'simulcast-mode' flag. * @param simulcastMode the value to set. diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriIQProvider.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriIQProvider.java index a05f2130a..ce676efa4 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriIQProvider.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriIQProvider.java @@ -428,6 +428,15 @@ else if (ColibriConferenceIQ.GracefulShutdown.ELEMENT_NAME if ((expire != null) && (expire.length() != 0)) channel.setExpire(Integer.parseInt(expire)); + String packetDelay + = parser.getAttributeValue( + "", + ColibriConferenceIQ.Channel + .PACKET_DELAY_ATTR_NAME); + if (!StringUtils.isNullOrEmpty(packetDelay)) + channel.setPacketDelay( + Integer.parseInt(packetDelay)); + // host String host = parser.getAttributeValue(