
org.restcomm.media.sdp.dtls.attributes.SetupAttribute Maven / Gradle / Ivy
/*
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2014, Telestax Inc and individual contributors
* by the @authors tag.
*
* This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see
*
*/
package org.restcomm.media.sdp.dtls.attributes;
import org.restcomm.media.sdp.fields.AttributeField;
/**
* a=setup:[active|passive|actpass|holdconn]
*
*
* The 'setup' attribute indicates which of the end points should initiate the
* connection establishment.
* It is charset-independent and can be a session-level or a media-level
* attribute.
*
*
*
* Possible Values:
*
*
* - active - The endpoint will initiate an outgoing connection.
* - passive - The endpoint will accept an incoming connection.
* - actpass - The endpoint is willing to accept an incoming connection
* or to initiate an outgoing connection.
* - holdconn - The endpoint does not want the connection to be
* established for the time being.
*
*
*
*
* This parameter was initialing defined in RFC4145, which has been updated by
* RFC4572.
*
*
* @author Henrique Rosa ([email protected])
*
* @see RFC4145, RFC4572
*/
public class SetupAttribute extends AttributeField {
public static final String ATTRIBUTE_TYPE = "setup";
public static final String ACTIVE = "active";
public static final String PASSIVE = "passive";
public static final String ACTPASS = "actpass";
public static final String HOLDCON = "holdconn";
public SetupAttribute(String value) {
super(ATTRIBUTE_TYPE);
setValue(value);
}
public void setValue(String value) {
if(!isSetupValid(value)) {
throw new IllegalArgumentException("Invalid setup: " + value);
}
super.value = value;
}
public static boolean isSetupValid(String value) {
if(value == null || value.isEmpty()) {
return false;
}
return ACTIVE.equals(value) ||
PASSIVE.equals(value) ||
ACTPASS.equals(value) ||
HOLDCON.equals(value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy