001package net.bramp.ffmpeg.info; 002 003import com.google.common.base.Preconditions; 004import com.google.errorprone.annotations.Immutable; 005import org.apache.commons.lang3.builder.EqualsBuilder; 006import org.apache.commons.lang3.builder.HashCodeBuilder; 007 008/** 009 * Information about supported Format 010 * 011 * @author bramp 012 */ 013@Immutable 014public class Format { 015 final String name; 016 final String longName; 017 018 final boolean canDemux; 019 final boolean canMux; 020 021 /** 022 * @param name short format name 023 * @param longName long format name 024 * @param flags is expected to be in the following format: 025 * <pre> 026 * D. = Demuxing supported 027 * .E = Muxing supported 028 * </pre> 029 */ 030 public Format(String name, String longName, String flags) { 031 this.name = Preconditions.checkNotNull(name).trim(); 032 this.longName = Preconditions.checkNotNull(longName).trim(); 033 034 Preconditions.checkNotNull(flags); 035 Preconditions.checkArgument(flags.length() == 2, "Format flags is invalid '{}'", flags); 036 canDemux = flags.charAt(0) == 'D'; 037 canMux = flags.charAt(1) == 'E'; 038 } 039 040 @Override 041 public String toString() { 042 return name + " " + longName; 043 } 044 045 @Override 046 public boolean equals(Object obj) { 047 return EqualsBuilder.reflectionEquals(this, obj); 048 } 049 050 @Override 051 public int hashCode() { 052 return HashCodeBuilder.reflectionHashCode(this); 053 } 054 055 public String getName() { 056 return name; 057 } 058 059 public String getLongName() { 060 return longName; 061 } 062 063 public boolean getCanDemux() { 064 return canDemux; 065 } 066 067 public boolean getCanMux() { 068 return canMux; 069 } 070}