From 2404d85468fbcdd7257108c3518508a608ab0e18 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Mon, 11 May 2020 17:51:49 +0200 Subject: [PATCH] Adds some extra abstraction to streams --- .../streams/AbstractStream.java | 25 ++++++++++++++ .../ffmpegconverter/streams/AudioStream.java | 3 +- .../ffmpegconverter/streams/StreamObject.java | 33 ++++--------------- .../streams/SubtitleStream.java | 3 +- .../ffmpegconverter/streams/VideoStream.java | 3 +- 5 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 src/main/java/net/knarcraft/ffmpegconverter/streams/AbstractStream.java diff --git a/src/main/java/net/knarcraft/ffmpegconverter/streams/AbstractStream.java b/src/main/java/net/knarcraft/ffmpegconverter/streams/AbstractStream.java new file mode 100644 index 0000000..c1a0337 --- /dev/null +++ b/src/main/java/net/knarcraft/ffmpegconverter/streams/AbstractStream.java @@ -0,0 +1,25 @@ +package net.knarcraft.ffmpegconverter.streams; + +/** + * An object representation of a stream in a media file + */ +public abstract class AbstractStream implements StreamObject { + int absoluteIndex; + int relativeIndex; + String codecName; + + @Override + public String getCodecName() { + return this.codecName; + } + + @Override + public int getAbsoluteIndex() { + return this.absoluteIndex; + } + + @Override + public int getRelativeIndex() { + return this.relativeIndex; + } +} \ No newline at end of file diff --git a/src/main/java/net/knarcraft/ffmpegconverter/streams/AudioStream.java b/src/main/java/net/knarcraft/ffmpegconverter/streams/AudioStream.java index 9053701..00235c7 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/streams/AudioStream.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/streams/AudioStream.java @@ -3,7 +3,7 @@ package net.knarcraft.ffmpegconverter.streams; /** * This class represents an ffmpeg audio stream */ -public class AudioStream extends StreamObject { +public class AudioStream extends AbstractStream implements StreamObject { private final String language; private final int channels; private final String title; @@ -19,7 +19,6 @@ public class AudioStream extends StreamObject { * @param channels

The number of channels for the audio stream.

*/ public AudioStream(String codecName, int absoluteIndex, int relativeIndex, String language, String title, int channels) { - this.codecType = "audio"; this.codecName = codecName; this.absoluteIndex = absoluteIndex; this.language = language; diff --git a/src/main/java/net/knarcraft/ffmpegconverter/streams/StreamObject.java b/src/main/java/net/knarcraft/ffmpegconverter/streams/StreamObject.java index 77daf05..069d4cc 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/streams/StreamObject.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/streams/StreamObject.java @@ -1,47 +1,26 @@ package net.knarcraft.ffmpegconverter.streams; -/** - * An object representation of a stream in a media file - */ -public abstract class StreamObject { - int absoluteIndex; - int relativeIndex; - String codecName; - String codecType; - - /** - * Gets the type of the stream codec (video/audio/subtitle) - * - * @return

Codec type.

- */ - public String getCodecType() { - return this.codecType; - } +public interface StreamObject { /** * Gets the name of the stream codec * * @return

Codec name.

*/ - String getCodecName() { - return this.codecName; - } + String getCodecName(); /** * Gets the absolute index of a stream object * * @return

Absolute index.

*/ - public int getAbsoluteIndex() { - return this.absoluteIndex; - } + int getAbsoluteIndex(); /** * Gets the relative index of a stream object (kth element of codec type) * * @return

Relative index.

*/ - public int getRelativeIndex() { - return this.relativeIndex; - } -} \ No newline at end of file + int getRelativeIndex(); + +} diff --git a/src/main/java/net/knarcraft/ffmpegconverter/streams/SubtitleStream.java b/src/main/java/net/knarcraft/ffmpegconverter/streams/SubtitleStream.java index 3caf5ea..9e5ce6d 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/streams/SubtitleStream.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/streams/SubtitleStream.java @@ -3,7 +3,7 @@ package net.knarcraft.ffmpegconverter.streams; /** * An object representation of a subtitle stream in a media file */ -public class SubtitleStream extends StreamObject { +public class SubtitleStream extends AbstractStream implements StreamObject { final private String language; final private String title; final private String file; @@ -22,7 +22,6 @@ public class SubtitleStream extends StreamObject { */ public SubtitleStream(String codecName, int absoluteIndex, int relativeIndex, String language, String title, String file) { - this.codecType = "subtitle"; this.codecName = codecName; this.absoluteIndex = absoluteIndex; this.language = language; diff --git a/src/main/java/net/knarcraft/ffmpegconverter/streams/VideoStream.java b/src/main/java/net/knarcraft/ffmpegconverter/streams/VideoStream.java index 933a20a..8b7acff 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/streams/VideoStream.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/streams/VideoStream.java @@ -3,7 +3,7 @@ package net.knarcraft.ffmpegconverter.streams; /** * An object representation of a video stream in a media file */ -public class VideoStream extends StreamObject { +public class VideoStream extends AbstractStream implements StreamObject { private final int width; private final int height; @@ -17,7 +17,6 @@ public class VideoStream extends StreamObject { * @param height

The height of the video stream.

*/ public VideoStream(String codec, int absoluteIndex, int relativeIndex, int width, int height) { - this.codecType = "video"; this.codecName = codec; this.absoluteIndex = absoluteIndex; this.relativeIndex = relativeIndex;