Adds some extra abstraction to streams
This commit is contained in:
parent
58dcb7fd35
commit
2404d85468
@ -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;
|
||||
}
|
||||
}
|
@ -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 <p>The number of channels for the audio stream.</p>
|
||||
*/
|
||||
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;
|
||||
|
@ -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 <p>Codec type.</p>
|
||||
*/
|
||||
public String getCodecType() {
|
||||
return this.codecType;
|
||||
}
|
||||
public interface StreamObject {
|
||||
|
||||
/**
|
||||
* Gets the name of the stream codec
|
||||
*
|
||||
* @return <p>Codec name.</p>
|
||||
*/
|
||||
String getCodecName() {
|
||||
return this.codecName;
|
||||
}
|
||||
String getCodecName();
|
||||
|
||||
/**
|
||||
* Gets the absolute index of a stream object
|
||||
*
|
||||
* @return <p>Absolute index.</p>
|
||||
*/
|
||||
public int getAbsoluteIndex() {
|
||||
return this.absoluteIndex;
|
||||
}
|
||||
int getAbsoluteIndex();
|
||||
|
||||
/**
|
||||
* Gets the relative index of a stream object (kth element of codec type)
|
||||
*
|
||||
* @return <p>Relative index.</p>
|
||||
*/
|
||||
public int getRelativeIndex() {
|
||||
return this.relativeIndex;
|
||||
}
|
||||
}
|
||||
int getRelativeIndex();
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 <p>The height of the video stream.</p>
|
||||
*/
|
||||
public VideoStream(String codec, int absoluteIndex, int relativeIndex, int width, int height) {
|
||||
this.codecType = "video";
|
||||
this.codecName = codec;
|
||||
this.absoluteIndex = absoluteIndex;
|
||||
this.relativeIndex = relativeIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user