support for copy codec for avconv
[meviz.git] / src / main / java / eu / svjatoslav / meviz / encoder / BitrateParameter.java
1 /*
2  * Meviz - Various tools collection to work with multimedia.
3  * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 2 of the GNU General Public License
7  * as published by the Free Software Foundation.
8  */
9
10 package eu.svjatoslav.meviz.encoder;
11
12 import eu.svjatoslav.commons.commandline.parameterparser.ArgumentCount;
13 import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
14
15 public class BitrateParameter extends Parameter {
16
17         static public enum bitrate {
18                 LOW, MEDIUM, HIGH, COPY
19         }
20
21         public BitrateParameter(final String description) {
22                 super(description, ArgumentCount.SINGLE);
23         }
24
25         @Override
26         public BitrateParameter addAliases(final String... aliasArray) {
27                 addAliasesProtected(aliasArray);
28                 return this;
29         }
30
31         @Override
32         public String describeFormat() {
33                 return "Target bitrate [LOW / MEDIUM / HIGH / COPY]";
34         };
35
36         @Override
37         public bitrate getValue() {
38                 return bitrate.valueOf(arguments.get(0).toUpperCase());
39         }
40
41         @Override
42         public BitrateParameter setMandatory() {
43                 setMandatoryProtected();
44                 return this;
45         }
46
47         @Override
48         public boolean validate(final String value) {
49                 try {
50                         bitrate.valueOf(value.toUpperCase());
51                 } catch (final IllegalArgumentException exception) {
52                         return false;
53                 }
54
55                 return true;
56         }
57 }