/*
 * Kurento Android Media: Android Media Library based on FFmpeg.
 * Copyright (C) 2011  Tikal Technologies
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3
 * as published by the Free Software Foundation.
 *
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.kurento.kas.media.codecs;

import java.util.ArrayList;

import com.kurento.kas.media.exception.CodecNotSupportedException;

/**
 * 
 * @author mparis
 * 
 */
public enum VideoCodecType {
	H264(0, new String[]{ "H264", "h264" }),
	MPEG4(1, new String[]{ "MPEG4", "mpeg4", "MP4V-ES", "mp4v-es" }),
	H263(2, new String[]{ "H263", "h263", "H263-1998", "h263-1998", "H263-2000", "h263-2000" });
	
	private int codecID;
	private ArrayList<String> arrayCodecStrings;
	
	//private int[] supportedBitrates
	//private int[] supportedFramerates

	private VideoCodecType(int codecID, String[] codecStrings) {
		this.codecID = codecID;
		arrayCodecStrings = new ArrayList<String>();
		for (String s : codecStrings)
			arrayCodecStrings.add(s);
	}

	public int getCodecID() {
		return codecID;
	}

	public ArrayList<String> getArrayCodecStrings() {
		return arrayCodecStrings;
	}
	
	public static int getCodecIdFromName(String codecName) throws CodecNotSupportedException {
		if (H264.arrayCodecStrings.contains(codecName))
			return H264.codecID;
		else if (MPEG4.arrayCodecStrings.contains(codecName))
			return MPEG4.codecID;
		else if (H263.arrayCodecStrings.contains(codecName))
			return H263.codecID;

		throw new CodecNotSupportedException("Codec not supported");
	}
	
	public static VideoCodecType getCodecTypeFromName(String codecName) throws CodecNotSupportedException {
		if (H264.arrayCodecStrings.contains(codecName))
			return H264;
		else if (MPEG4.arrayCodecStrings.contains(codecName))
			return MPEG4;
		else if (H263.arrayCodecStrings.contains(codecName))
			return H263;

		throw new CodecNotSupportedException("Codec not supported");
	}
	
}

@@ -758,16 +758,45 @@
 rayList;
+%0Aimport java.util.Collection;
 %0A%0Aimport
@@ -953,16 +953,8 @@
 264%22
-, %22h264%22
  %7D),
@@ -992,35 +992,15 @@
 %22, %22
-mpeg4%22, %22MP4V-ES%22, %22mp4v-es
+MP4V-ES
 %22 %7D)
@@ -1035,16 +1035,8 @@
 63%22,
- %22h263%22,
  %22H2
@@ -1050,35 +1050,9 @@
 %22, %22
-h263-1998%22, %22H263-2000%22, %22h
+H
 263-
@@ -1098,31 +1098,37 @@
 ate 
-ArrayList%3CString%3E array
+Collection%3CString%3E collection
 Code
@@ -1302,21 +1302,26 @@
 ecID;%0A%09%09
-array
+collection
 CodecStr
@@ -1387,21 +1387,26 @@
 ngs)%0A%09%09%09
-array
+collection
 CodecStr
@@ -1479,25 +1479,26 @@
 %09public 
-ArrayList
+Collection
 %3CString%3E
@@ -1501,21 +1501,26 @@
 ing%3E get
-Array
+Collection
 CodecStr
@@ -1537,21 +1537,26 @@
 %09return 
-array
+collection
 CodecStr
@@ -1661,37 +1661,42 @@
 on %7B%0A%09%09if (H264.
-array
+collection
 CodecStrings.con
@@ -1702,32 +1702,46 @@
 ntains(codecName
+.toUpperCase()
 ))%0A%09%09%09return H26
@@ -1760,37 +1760,42 @@
 %09else if (MPEG4.
-array
+collection
 CodecStrings.con
@@ -1801,32 +1801,46 @@
 ntains(codecName
+.toUpperCase()
 ))%0A%09%09%09return MPE
@@ -1859,37 +1859,42 @@
 %09%09else if (H263.
-array
+collection
 CodecStrings.con
@@ -1900,32 +1900,46 @@
 ntains(codecName
+.toUpperCase()
 ))%0A%09%09%09return H26
@@ -2134,21 +2134,26 @@
 f (H264.
-array
+collection
 CodecStr
@@ -2167,32 +2167,46 @@
 ntains(codecName
+.toUpperCase()
 ))%0A%09%09%09return H26
@@ -2225,21 +2225,26 @@
  (MPEG4.
-array
+collection
 CodecStr
@@ -2258,32 +2258,46 @@
 ntains(codecName
+.toUpperCase()
 ))%0A%09%09%09return MPE
@@ -2320,13 +2320,18 @@
 263.
-array
+collection
 Code
@@ -2357,16 +2357,30 @@
 odecName
+.toUpperCase()
 ))%0A%09%09%09re

Improve VideoCodecType management.