OSDN Git Service

Merge branch いんきゅばすv2開発ブランチマージ
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / config / ConfigFfmpegProfile.java
1 package yukihane.inqubus.config;
2
3 import java.io.File;
4 import java.io.IOException;
5 import org.apache.commons.lang.builder.ToStringBuilder;
6 import saccubus.FfmpegOption;
7 import saccubus.worker.profile.FfmpegProfile;
8
9 /**
10  * コンフィグに設定された値を基にしたFfmpegProfile実装.
11  * @author yuki
12  */
13 public class ConfigFfmpegProfile implements FfmpegProfile {
14
15     private final String extOption;
16     private final String inOption;
17     private final String mainOption;
18     private final String outOption;
19     private final String avOption;
20     private final boolean resize;
21     private final int resizeWidth;
22     private final int resizeHeight;
23     private final boolean adjustRatio;
24
25     public ConfigFfmpegProfile() throws IOException {
26         final Config p = Config.INSTANCE;
27
28         if (p.getFfmpegOptionFile() != null) {
29             final File file = new File(p.getFfmpegOptionFile());
30             final FfmpegOption ffop = FfmpegOption.load(file);
31             this.extOption = ffop.getExtOption();
32             this.inOption = ffop.getInOption();
33             this.mainOption = ffop.getMainOption();
34             this.outOption = ffop.getMainOption();
35             this.avOption = ffop.getAvfilterOption();
36             this.resize = ffop.isResize();
37             this.resizeWidth = ffop.getResizeWidth();
38             this.resizeHeight = ffop.getResizeHeight();
39             this.adjustRatio = ffop.isAdjustRatio();
40         } else {
41             this.extOption = p.getFfmpegExtension();
42             this.inOption = p.getFfmpegInOption();
43             this.mainOption = p.getFfmpegMainOption();
44             this.outOption = p.getFfmpegOutOption();
45             this.avOption = p.getFfmpegAvOption();
46             this.resize = p.getFfmpegResizeEnable();
47             this.resizeWidth = Integer.parseInt(p.getFfmpegResizeWidth());
48             this.resizeHeight = Integer.parseInt(p.getFfmpegResizeHeight());
49             this.adjustRatio = p.getFfmpegKeepAspect();
50         }
51     }
52
53     @Override
54     public String getExtOption() {
55         if (this.extOption.startsWith(".")) {
56             return this.extOption;
57         }
58         return "." + this.extOption;
59     }
60
61     @Override
62     public String getInOption() {
63         return this.inOption;
64     }
65
66     @Override
67     public String getMainOption() {
68         return this.mainOption;
69     }
70
71     @Override
72     public String getOutOption() {
73         return this.outOption;
74     }
75
76     @Override
77     public String getAvfilterOption() {
78         return this.avOption;
79     }
80
81     @Override
82     public boolean isResize() {
83         return this.resize;
84     }
85
86     @Override
87     public int getResizeWidth() {
88         return this.resizeWidth;
89     }
90
91     @Override
92     public int getResizeHeight() {
93         return this.resizeHeight;
94     }
95
96     @Override
97     public boolean isAdjustRatio() {
98         return this.adjustRatio;
99     }
100
101     @Override
102     public String toString() {
103         return ToStringBuilder.reflectionToString(this);
104     }
105 }