1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*
This file is part of Subsonic.
Subsonic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Subsonic 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 Subsonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2009 (C) Sindre Mehus
*/
package net.sourceforge.subsonic.domain;
/**
* Enumeration of transcoding schemes. Transcoding is the process of
* converting an audio stream to a lower bit rate.
*
* @author Sindre Mehus
*/
public enum TranscodeScheme {
OFF(0),
MAX_32(32),
MAX_40(40),
MAX_48(48),
MAX_56(56),
MAX_64(64),
MAX_80(80),
MAX_96(96),
MAX_112(112),
MAX_128(128),
MAX_160(160),
MAX_192(192),
MAX_224(224),
MAX_256(256),
MAX_320(320);
private int maxBitRate;
TranscodeScheme(int maxBitRate) {
this.maxBitRate = maxBitRate;
}
/**
* Returns the maximum bit rate for this transcoding scheme.
*
* @return The maximum bit rate for this transcoding scheme.
*/
public int getMaxBitRate() {
return maxBitRate;
}
/**
* Returns the strictest transcode scheme (i.e., the scheme with the lowest max bitrate).
*
* @param other The other transcode scheme. May be <code>null</code>, in which case 'this' is returned.
* @return The strictest scheme.
*/
public TranscodeScheme strictest(TranscodeScheme other) {
if (other == null || other == TranscodeScheme.OFF) {
return this;
}
if (this == TranscodeScheme.OFF) {
return other;
}
return maxBitRate < other.maxBitRate ? this : other;
}
/**
* Returns a human-readable string representation of this object.
*
* @return A human-readable string representation of this object.
*/
public String toString() {
if (this == OFF) {
return "No limit";
}
return "" + getMaxBitRate() + " Kbps";
}
/**
* Returns the enum constant which corresponds to the given max bit rate.
*
* @param maxBitRate The max bit rate.
* @return The corresponding enum, or <code>null</code> if not found.
*/
public static TranscodeScheme valueOf(int maxBitRate) {
for (TranscodeScheme scheme : values()) {
if (scheme.getMaxBitRate() == maxBitRate) {
return scheme;
}
}
return null;
}
}
|