Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/main/java/net/bramp/ffmpeg/info/Codec.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -12,14 +13,6 @@
*/
@Immutable
public class Codec {

public enum Type {
VIDEO,
AUDIO,
SUBTITLE,
DATA
}

final String name;
final String longName;

Expand All @@ -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
Expand Down Expand Up @@ -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) + "'");
}
Expand Down Expand Up @@ -107,7 +102,7 @@ public boolean getCanEncode() {
return canEncode;
}

public Type getType() {
public CodecType getType() {
return type;
}
}
9 changes: 2 additions & 7 deletions src/main/java/net/bramp/ffmpeg/probe/FFmpegStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@

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(
value = {"UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"},
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;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/bramp/ffmpeg/shared/CodecType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.bramp.ffmpeg.shared;

public enum CodecType {
VIDEO,
AUDIO,
SUBTITLE,
DATA,
ATTACHMENT
}
13 changes: 5 additions & 8 deletions src/test/java/net/bramp/ffmpeg/FFprobeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")))
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down