wav to flac conversion
[meviz.git] / src / main / java / eu / svjatoslav / meviz / encoder / FormatsRegistry.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 java.util.ArrayList;
13 import java.util.List;
14
15 import eu.svjatoslav.meviz.encoder.converters.Avi2Ogv;
16 import eu.svjatoslav.meviz.encoder.converters.Converter;
17 import eu.svjatoslav.meviz.encoder.converters.Jpeg2Png;
18 import eu.svjatoslav.meviz.encoder.converters.Mkv2Mp4;
19 import eu.svjatoslav.meviz.encoder.converters.Mp42Ogv;
20 import eu.svjatoslav.meviz.encoder.converters.Mts2Mkv;
21 import eu.svjatoslav.meviz.encoder.converters.Mts2Mp4;
22 import eu.svjatoslav.meviz.encoder.converters.Ogg2Mp3;
23 import eu.svjatoslav.meviz.encoder.converters.Ogg2Wav;
24 import eu.svjatoslav.meviz.encoder.converters.Png2Tiff;
25 import eu.svjatoslav.meviz.encoder.converters.Tiff2Png;
26 import eu.svjatoslav.meviz.encoder.converters.Wav2flac;
27 import eu.svjatoslav.meviz.encoder.converters.Wav2mp3;
28
29 public class FormatsRegistry {
30
31         public ArrayList<Converter> encoders = new ArrayList<Converter>();
32
33         public FormatsRegistry() {
34                 // video conversion
35                 registerEncoder(new Avi2Ogv());
36                 registerEncoder(new Mp42Ogv());
37                 registerEncoder(new Mts2Mp4());
38                 registerEncoder(new Mts2Mkv());
39                 registerEncoder(new Mkv2Mp4());
40
41                 // image conversion
42                 registerEncoder(new Jpeg2Png());
43                 registerEncoder(new Png2Tiff());
44                 registerEncoder(new Tiff2Png());
45
46                 // audio conversion
47                 registerEncoder(new Ogg2Wav());
48                 registerEncoder(new Wav2mp3());
49                 registerEncoder(new Wav2flac());
50                 registerEncoder(new Ogg2Mp3());
51         }
52
53         public List<Converter> getEncoders(final String sourceFormat,
54                         final String targetFormat) {
55
56                 final String sourceFormatLowerCase = sourceFormat.toLowerCase();
57                 final String targetFormatLowerCase = targetFormat.toLowerCase();
58
59                 final ArrayList<Converter> encoders = new ArrayList<Converter>();
60
61                 for (final Converter encoder : this.encoders)
62                         if (encoder.getSourceFileExtension().equals(sourceFormatLowerCase))
63                                 if (encoder.getTargetFileExtension().equals(
64                                                 targetFormatLowerCase)) {
65                                         encoders.add(encoder);
66                                         return encoders;
67                                 }
68
69                 return encoders;
70         }
71
72         public void registerEncoder(final Converter encoder) {
73                 encoders.add(encoder);
74         }
75
76 }