Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Map;
- /**
- * Represents a single video encoding.
- * @author Ryan Greene
- *
- */
- public enum Encoding {
- FLV_240p(5, "FLV", "240p", "Sorenson H.263", "N/A", 0.25, "MP3", 64),
- FLV_270p(6, "FLV", "270p", "Sorenson H.263", "N/A", 0.8, "MP3", 64),
- GP3_NA(13, "3GP", "N/A", "MPEG-4 Visual", "N/A", 0.5, "AAC", -1),
- GP3_144p(17, "3GP", "144p", "MPEG-4 Visual", "Simple", 0.05, "AAC", 24),
- MP4_360p(18, "MP4", "360p", "H.264", "Baseline", 0.5, "AAC", 96),
- MP4_720p(22, "MP4", "720p", "H.264", "High", 2.45, "AAC", 192),
- FLV_360p(34, "FLV", "360p", "H.264", "Main", 0.5, "AAC", 128),
- FLV_480p(35, "FLV", "480p", "H.264", "Main", 0.4, "AAC", 128),
- GP3_240p(36, "3GP", "240p", "MPEG-4 Visual", "Simple", 0.17, "AAC", 38),
- MP4_1080p(37, "MP4", "1080p", "H.264", "High", 3.65, "AAC", 192),
- MP4_3072p(38, "MP4", "3072p", "H.264", "High", 3.25, "AAC", 192),
- WEBM_360p(43, "WebM", "360p", "VP8", "N/A", 0.5, "Vorbis", 128),
- WEBM_480p(44, "WebM", "480p", "VP8", "N/A", 1.0, "Vorbis", 128),
- WEBM_720p(45, "WebM", "720p", "VP8", "N/A", 2.0, "Vorbis", 192),
- WEBM_1080p(46, "FLV", "1080p", "VP8", "N/A", -1, "Vorbis", 192),
- MP4_360p_3D(82, "MP4", "360p", "H.264", "3D", 0.5, "AC", 96),
- MP4_240p_3D(83, "MP4", "240p", "H.264", "3D", 0.5, "AC", 96),
- MP4_720p_3D(84, "MP4", "720p", "H.264", "3D", 2.45, "AAC", 152),
- MP4_520p_3D(85, "MP4", "520p", "H.264", "3D", 2.45, "AAC", 152),
- WEBM_360p_3D_128kbs(100, "360p", "240p", "3D", "N/A", -1, "Vorbis", 128),
- WEBM_360p_3D_192kbs(101, "360p", "240p", "3D", "N/A", -1, "Vorbis", 192),
- WEBM_720p_3D(102, "WebM", "720p", "VP8", "3D", -1, "Vorbis", 192),
- FLV_720p(120, "FLV", "720p", "AVC", "Main@L3.1", 2, "AAC", 128);
- /**
- * The itag value.
- */
- private final int itagValue;
- /**
- * The default container.
- */
- private final String defaultContainer;
- /**
- * The video resolution.
- */
- private final String videoResolution;
- /**
- * The video encoding.
- */
- private final String videoEncoding;
- /**
- * The video profile.
- */
- private final String videoProfile;
- /**
- * The video bitrate (MBit/s).
- */
- private final double videoBitrate;
- /**
- * The audio encoding.
- */
- private final String audioEncoding;
- /**
- * The audio bitrate (kbit/s).
- */
- private final int audioBitrate;
- /**
- * A map of itag values to encodings.
- */
- private static Map<Integer, Encoding> encodings = new HashMap<Integer, Encoding>();
- /**
- * Gets a encoding by a itag value.
- *
- * @param itagValue
- * The itag value.
- * @return The encoding, or <code>null</code> if the itag value is not an encoding.
- */
- public static Encoding forItagValue(int itagValue) {
- return encodings.get(itagValue);
- }
- /**
- * Populates the encodings map.
- */
- static {
- for (Encoding encoding : Encoding.values()) {
- encodings.put(encoding.itagValue, encoding);
- }
- }
- /**
- * Constructs the encoding.
- * @param itagValue The itag value.
- * @param defaultContainer The default container.
- * @param videoResolution The video resolution.
- * @param videoEncoding The video encoding.
- * @param videoProfile The video profile.
- * @param videoBitrate The video bitrate (MBit/s).
- * @param audioEncoding The audio encoding.
- * @param audioBitrate The audio bitrate (kbit/s).
- */
- private Encoding(int itagValue, String defaultContainer, String videoResolution, String videoEncoding,
- String videoProfile, double videoBitrate, String audioEncoding, int audioBitrate) {
- this.itagValue = itagValue;
- this.defaultContainer = defaultContainer;
- this.videoResolution = videoResolution;
- this.videoEncoding = videoEncoding;
- this.videoProfile = videoProfile;
- this.videoBitrate = videoBitrate;
- this.audioEncoding = audioEncoding;
- this.audioBitrate = audioBitrate;
- }
- /**
- * Gets the itag value.
- * @return The itag value.
- */
- public int getItagValue() {
- return itagValue;
- }
- /**
- * Gets the default container.
- * @return The default container.
- */
- public String getDefaultContainer() {
- return defaultContainer;
- }
- /**
- * Gets the video resolution.
- * @return The video resolution.
- */
- public String getVideoResolution() {
- return videoResolution;
- }
- /**
- * Gets the video encoding.
- * @return The video encoding.
- */
- public String getVideoEncoding() {
- return videoEncoding;
- }
- /**
- * Gets the video profile.
- * @return The video profile.
- */
- public String getVideoProfile() {
- return videoProfile;
- }
- /**
- * Gets the video bitrate (MBit/s).
- * @return The video bitrate (MBit/s).
- */
- public double getVideoBitrate() {
- return videoBitrate;
- }
- /**
- * Gets the audio encoding.
- * @return The audio encoding.
- */
- public String getAudioEncoding() {
- return audioEncoding;
- }
- /**
- * Gets the audio bitrate (kbit/s).
- * @return The audio bitrate (kbit/s).
- */
- public int getAudioBitrate() {
- return audioBitrate;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement