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 private final String name; 016 private final String longName; 017 018 private final boolean canDemux; 019 private final boolean canMux; 020 021 /** 022 * Creates a new Format. 023 * 024 * @param name short format name 025 * @param longName long format name 026 * @param flags is expected to be in the following format: 027 * <pre> 028 * D. = Demuxing supported 029 * .E = Muxing supported 030 * </pre> 031 */ 032 public Format(String name, String longName, String flags) { 033 this.name = Preconditions.checkNotNull(name).trim(); 034 this.longName = Preconditions.checkNotNull(longName).trim(); 035 036 Preconditions.checkNotNull(flags); 037 Preconditions.checkArgument(flags.length() == 2, "Format flags is invalid '%s'", flags); 038 canDemux = flags.charAt(0) == 'D'; 039 canMux = flags.charAt(1) == 'E'; 040 } 041 042 @Override 043 public String toString() { 044 return name + " " + longName; 045 } 046 047 @Override 048 public boolean equals(Object obj) { 049 return EqualsBuilder.reflectionEquals(this, obj); 050 } 051 052 @Override 053 public int hashCode() { 054 return HashCodeBuilder.reflectionHashCode(this); 055 } 056 057 public String getName() { 058 return name; 059 } 060 061 public String getLongName() { 062 return longName; 063 } 064 065 public boolean getCanDemux() { 066 return canDemux; 067 } 068 069 public boolean getCanMux() { 070 return canMux; 071 } 072}