All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mobicents.protocols.mgcp.parser.params.LocalOptionValueHandler Maven / Gradle / Ivy

/*
 * JBoss, Home of Professional Open Source
 * Copyright 2011, Red Hat, Inc. and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.mobicents.protocols.mgcp.parser.params;

import java.text.ParseException;

import org.mobicents.protocols.mgcp.parser.StringFunctions;
import org.mobicents.protocols.mgcp.parser.SplitDetails;

import jain.protocol.ip.mgcp.message.parms.LocalOptionValue;
import jain.protocol.ip.mgcp.message.parms.LocalOptionExtension;
import jain.protocol.ip.mgcp.message.parms.Bandwidth;
import jain.protocol.ip.mgcp.message.parms.CompressionAlgorithm;
import jain.protocol.ip.mgcp.message.parms.PacketizationPeriod;
import jain.protocol.ip.mgcp.message.parms.GainControl;
import jain.protocol.ip.mgcp.message.parms.EchoCancellation;
import jain.protocol.ip.mgcp.message.parms.EncryptionMethod;
import jain.protocol.ip.mgcp.message.parms.ResourceReservation;
import jain.protocol.ip.mgcp.message.parms.SilenceSuppression;
import jain.protocol.ip.mgcp.message.parms.TypeOfService;
import jain.protocol.ip.mgcp.message.parms.TypeOfNetwork;

public class LocalOptionValueHandler
{
	public static LocalOptionValue decode(byte[] value,int offset,int length) throws ParseException
	{		
		if(length>1 && value[offset+1]==StringFunctions.COLON_BYTE)
		{
			switch(value[offset])
			{
				case StringFunctions.LOW_A_BYTE:
				case StringFunctions.HIGH_A_BYTE:					
					return CompressionAlgorithmHandler.decode(value,offset+2,length-2); 
				case StringFunctions.LOW_B_BYTE:
				case StringFunctions.HIGH_B_BYTE:
					return BandwidthHandler.decode(value,offset+2,length-2);
				case StringFunctions.LOW_E_BYTE:
				case StringFunctions.HIGH_E_BYTE:
					return EchoCancellationHandler.decode(value,offset+2,length-2);
				case StringFunctions.LOW_K_BYTE:
				case StringFunctions.HIGH_K_BYTE:
					return EncryptionMethodHandler.decode(value,offset+2,length-2);
				case StringFunctions.LOW_P_BYTE:
				case StringFunctions.HIGH_P_BYTE:
					return PacketizationPeriodHandler.decode(value,offset+2,length-2);
				case StringFunctions.LOW_R_BYTE:
				case StringFunctions.HIGH_R_BYTE:
					return ResourceReservationHandler.decode(value,offset+2,length-2);
				case StringFunctions.LOW_S_BYTE:
				case StringFunctions.HIGH_S_BYTE:
					return SilenceSuppressionHandler.decode(value,offset+2,length-2);
				case StringFunctions.LOW_T_BYTE:
				case StringFunctions.HIGH_T_BYTE:
					return TypeOfServiceHandler.decode(value,offset+2,length-2);
			}
		}
		else if(length>2 && value[offset+2]==StringFunctions.COLON_BYTE)
		{
			switch(value[offset])
			{
				case StringFunctions.LOW_N_BYTE:
				case StringFunctions.HIGH_N_BYTE:
					if(value[offset+1]==StringFunctions.LOW_T_BYTE || value[offset+1]==StringFunctions.HIGH_T_BYTE)
						return TypeOfNetworkHandler.decode(value,offset+3,length-3); 
				case StringFunctions.LOW_G_BYTE:
				case StringFunctions.HIGH_G_BYTE:
					if(value[offset+1]==StringFunctions.LOW_C_BYTE || value[offset+1]==StringFunctions.HIGH_C_BYTE)
						return GainControlHandler.decode(value,offset+3,length-3);
			}
		}
		
		for(int i=3;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy