diff options
author | Boris Grozev <boris@jitsi.org> | 2014-06-20 12:55:48 +0200 |
---|---|---|
committer | Boris Grozev <boris@jitsi.org> | 2014-06-20 12:55:48 +0200 |
commit | 2d4cc999cc2b8a72a5656b6e910cc8a11f896a8e (patch) | |
tree | 1633b2b023ee19ed77b426941d2257862f57ef0e /src | |
parent | d0decfda96e0f94800b83a59517573d11e3652bf (diff) | |
download | jitsi-2d4cc999cc2b8a72a5656b6e910cc8a11f896a8e.zip jitsi-2d4cc999cc2b8a72a5656b6e910cc8a11f896a8e.tar.gz jitsi-2d4cc999cc2b8a72a5656b6e910cc8a11f896a8e.tar.bz2 |
Adds a 'recording' element to a Colibri IQ.
Diffstat (limited to 'src')
3 files changed, 201 insertions, 2 deletions
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 0f2704d..635de1e 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 @@ -59,6 +59,11 @@ public class ColibriConferenceIQ */ private String id; + /** + * Media recording. + */ + public Recording recording = null; + /** Initializes a new <tt>ColibriConferenceIQ</tt> instance. */ public ColibriConferenceIQ() { @@ -121,7 +126,11 @@ public class ColibriConferenceIQ List<Content> contents = getContents(); - if (contents.size() == 0) + int childrenCount = contents.size(); + if (recording != null) + childrenCount++; + + if (childrenCount == 0) { xml.append(" />"); } @@ -130,6 +139,8 @@ public class ColibriConferenceIQ xml.append('>'); for (Content content : contents) content.toXML(xml); + if (recording != null) + recording.toXML(xml); xml.append("</").append(ELEMENT_NAME).append('>'); } return xml.toString(); @@ -176,6 +187,24 @@ public class ColibriConferenceIQ } /** + * Gets the value of the recording field. + * @return the value of the recording field. + */ + public Recording getRecording() + { + return recording; + } + + /** + * Sets the recording field. + * @param recording the value to set. + */ + public void setRecording(Recording recording) + { + this.recording = recording; + } + + /** * Returns a <tt>Content</tt> from the list of <tt>Content</tt>s of this * <tt>conference</tt> IQ which has a specific name. If no such * <tt>Content</tt> exists at the time of the invocation of the method, @@ -1002,7 +1031,8 @@ public class ColibriConferenceIQ * section 2.3 "Mixers and Translators") used for this * <tt>Channel</tt>. * - * @param s the type of RTP-level relay used for this <tt>Channel</tt> + * @param rtpLevelRelayType the type of RTP-level relay used for + * this <tt>Channel</tt> */ public void setRTPLevelRelayType(RTPLevelRelayType rtpLevelRelayType) { @@ -1487,4 +1517,63 @@ public class ColibriConferenceIQ // No other content than the transport shared from ChannelCommon } } + + /** + * Represents a <tt>recording</tt> element. + */ + public static class Recording + { + /** + * The XML name of the <tt>recording</tt> element. + */ + public static final String ELEMENT_NAME = "recording"; + + /** + * The XML name of the <tt>state</tt> attribute. + */ + public static final String STATE_ATTR_NAME = "state"; + + /** + * The XML name of the <tt>token</tt> attribute. + */ + public static final String TOKEN_ATTR_NAME = "token"; + + private String token = null; + private boolean state; + + public Recording(boolean state) + { + this.state = state; + } + + public Recording(boolean state, String token) + { + this(state); + + this.token = token; + } + + public String getToken() + { + return token; + } + + public boolean getState() + { + return state; + } + + public void toXML(StringBuilder xml) + { + xml.append('<').append(ELEMENT_NAME); + xml.append(' ').append(STATE_ATTR_NAME).append("='") + .append(state).append('\''); + if (token != null) + { + xml.append(' ').append(TOKEN_ATTR_NAME).append("='") + .append(token).append('\''); + } + xml.append("/>"); + } + } } 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 06502a7..ec1c182 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 @@ -160,6 +160,7 @@ public class ColibriIQProvider ColibriConferenceIQ.Channel channel = null; ColibriConferenceIQ.SctpConnection sctpConnection = null; ColibriConferenceIQ.Content content = null; + ColibriConferenceIQ.Recording recording = null; StringBuilder ssrc = null; while (!done) @@ -214,6 +215,12 @@ public class ColibriIQProvider conference.addContent(content); content = null; } + else if (ColibriConferenceIQ.Recording.ELEMENT_NAME.equals( + name)) + { + conference.setRecording(recording); + recording = null; + } break; } @@ -348,6 +355,25 @@ public class ColibriIQProvider && (contentName.length() != 0)) content.setName(contentName); } + else if (ColibriConferenceIQ.Recording.ELEMENT_NAME.equals( + name)) + { + String stateStr + = parser.getAttributeValue( + "", + ColibriConferenceIQ.Recording.STATE_ATTR_NAME); + boolean state = Boolean.parseBoolean(stateStr); + + String token + = parser.getAttributeValue( + "", + ColibriConferenceIQ.Recording.TOKEN_ATTR_NAME); + + recording + = new ColibriConferenceIQ.Recording( + state, + token); + } else if (ColibriConferenceIQ.SctpConnection.ELEMENT_NAME .equals(name)) { diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/RecordingPacketExtension.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/RecordingPacketExtension.java new file mode 100644 index 0000000..5b91ba3 --- /dev/null +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/RecordingPacketExtension.java @@ -0,0 +1,84 @@ +/* + * 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.protocol.jabber.extensions.colibri; + +import net.java.sip.communicator.impl.protocol.jabber.extensions.*; + +/** + * Implements <tt>AbstractPacketExtension</tt> for a "recording" element. + * + * @author Boris Grozev + */ +public class RecordingPacketExtension + extends AbstractPacketExtension +{ + /** + * The XML name of the <tt>recording</tt> element. + */ + public static final String ELEMENT_NAME = "recording"; + + /** + * The XML name of the <tt>state</tt> attribute. + */ + private static final String STATE_ATTR_NAME = "state"; + + /** + * The XML name of the <tt>token</tt> attribute. + */ + private static final String TOKEN_ATTR_NAME = "token"; + + /** + * Initializes a new <tt>RecordingPacketExtension</tt> instance. + */ + public RecordingPacketExtension() + { + super(ColibriConferenceIQ.NAMESPACE, ELEMENT_NAME); + } + + public String getToken() + { + return getAttributeAsString(TOKEN_ATTR_NAME); + } + + public void setToken(String token) + { + setAttribute(TOKEN_ATTR_NAME, token); + } + + public State getState() + { + return State.parseString(getAttributeAsString(STATE_ATTR_NAME)); + } + + public void setState(State state) + { + setAttribute(STATE_ATTR_NAME, state.toString()); + } + + private enum State + { + ON("on"), + OFF("off"); + + private String name; + private State(String name) + { + this.name = name; + } + public String toString() + { + return name; + } + public static State parseString(String s) + { + if (ON.toString().equalsIgnoreCase(s)) + return ON; + return OFF; + } + } +} + |