diff --git a/src/main/java/net/bramp/ffmpeg/info/Codec.java b/src/main/java/net/bramp/ffmpeg/info/Codec.java index 130bdbf5..4a0e11a0 100644 --- a/src/main/java/net/bramp/ffmpeg/info/Codec.java +++ b/src/main/java/net/bramp/ffmpeg/info/Codec.java @@ -2,6 +2,7 @@ import com.google.common.base.Preconditions; import com.google.errorprone.annotations.Immutable; +import net.bramp.ffmpeg.shared.CodecType; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; @@ -12,14 +13,6 @@ */ @Immutable public class Codec { - - public enum Type { - VIDEO, - AUDIO, - SUBTITLE, - DATA - } - final String name; final String longName; @@ -30,7 +23,7 @@ public enum Type { final boolean canEncode; /** What type of codec is this */ - final Type type; + final CodecType type; /** * @param name short codec name @@ -58,17 +51,19 @@ public Codec(String name, String longName, String flags) { switch (flags.charAt(2)) { case 'V': - this.type = Type.VIDEO; + this.type = CodecType.VIDEO; break; case 'A': - this.type = Type.AUDIO; + this.type = CodecType.AUDIO; break; case 'S': - this.type = Type.SUBTITLE; + this.type = CodecType.SUBTITLE; break; case 'D': - this.type = Type.DATA; + this.type = CodecType.DATA; break; + case 'T': + this.type = CodecType.ATTACHMENT; default: throw new IllegalArgumentException("Invalid codec type '" + flags.charAt(2) + "'"); } @@ -107,7 +102,7 @@ public boolean getCanEncode() { return canEncode; } - public Type getType() { + public CodecType getType() { return type; } } diff --git a/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java b/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java index bd517856..84891842 100644 --- a/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java +++ b/src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java @@ -2,6 +2,8 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Map; + +import net.bramp.ffmpeg.shared.CodecType; import org.apache.commons.lang3.math.Fraction; @SuppressFBWarnings( @@ -9,13 +11,6 @@ justification = "POJO objects where the fields are populated by gson") public class FFmpegStream { - public enum CodecType { - VIDEO, - AUDIO, - SUBTITLE, - DATA, - ATTACHMENT - } public int index; public String codec_name; diff --git a/src/main/java/net/bramp/ffmpeg/shared/CodecType.java b/src/main/java/net/bramp/ffmpeg/shared/CodecType.java new file mode 100644 index 00000000..3a29d6b6 --- /dev/null +++ b/src/main/java/net/bramp/ffmpeg/shared/CodecType.java @@ -0,0 +1,9 @@ +package net.bramp.ffmpeg.shared; + +public enum CodecType { + VIDEO, + AUDIO, + SUBTITLE, + DATA, + ATTACHMENT +} diff --git a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java index 7f039777..c53929b5 100644 --- a/src/test/java/net/bramp/ffmpeg/FFprobeTest.java +++ b/src/test/java/net/bramp/ffmpeg/FFprobeTest.java @@ -7,13 +7,12 @@ import static org.junit.Assert.*; import static org.mockito.Mockito.*; -import com.google.gson.Gson; import java.io.IOException; import net.bramp.ffmpeg.fixtures.Samples; import net.bramp.ffmpeg.lang.NewProcessAnswer; import net.bramp.ffmpeg.probe.FFmpegChapter; import net.bramp.ffmpeg.probe.FFmpegProbeResult; -import net.bramp.ffmpeg.probe.FFmpegStream; +import net.bramp.ffmpeg.shared.CodecType; import org.apache.commons.lang3.math.Fraction; import org.junit.Before; import org.junit.Test; @@ -28,8 +27,6 @@ public class FFprobeTest { FFprobe ffprobe; - static final Gson gson = FFmpegUtils.getGson(); - @Before public void before() throws IOException { when(runFunc.run(argThatHasItem("-version"))) @@ -73,8 +70,8 @@ public void testProbeVideo() throws IOException { // Only a quick sanity check until we do something better assertThat(info.getStreams(), hasSize(2)); - assertThat(info.getStreams().get(0).codec_type, is(FFmpegStream.CodecType.VIDEO)); - assertThat(info.getStreams().get(1).codec_type, is(FFmpegStream.CodecType.AUDIO)); + assertThat(info.getStreams().get(0).codec_type, is(CodecType.VIDEO)); + assertThat(info.getStreams().get(1).codec_type, is(CodecType.AUDIO)); assertThat(info.getStreams().get(1).channels, is(6)); assertThat(info.getStreams().get(1).sample_rate, is(48_000)); @@ -113,8 +110,8 @@ public void testProbeVideo2() throws IOException { // Only a quick sanity check until we do something better assertThat(info.getStreams(), hasSize(2)); - assertThat(info.getStreams().get(0).codec_type, is(FFmpegStream.CodecType.VIDEO)); - assertThat(info.getStreams().get(1).codec_type, is(FFmpegStream.CodecType.AUDIO)); + assertThat(info.getStreams().get(0).codec_type, is(CodecType.VIDEO)); + assertThat(info.getStreams().get(1).codec_type, is(CodecType.AUDIO)); assertThat(info.getStreams().get(1).channels, is(2)); assertThat(info.getStreams().get(1).sample_rate, is(48_000));