001package net.bramp.ffmpeg.job;
002
003import static com.google.common.base.Preconditions.checkNotNull;
004
005import javax.annotation.Nullable;
006import net.bramp.ffmpeg.FFmpeg;
007import net.bramp.ffmpeg.progress.ProgressListener;
008
009/**
010 * A FFmpegJob is a single job that can be run by FFmpeg. It can be a single pass, or a two pass
011 * job.
012 *
013 * @author bramp
014 */
015public abstract class FFmpegJob implements Runnable {
016
017  /** Enum representing the execution state of an FFmpeg job. */
018  public enum State {
019    WAITING,
020    RUNNING,
021    FINISHED,
022    FAILED,
023  }
024
025  final FFmpeg ffmpeg;
026  final ProgressListener listener;
027
028  State state = State.WAITING;
029
030  /** Constructs a new FFmpeg job with the given FFmpeg instance. */
031  public FFmpegJob(FFmpeg ffmpeg) {
032    this(ffmpeg, null);
033  }
034
035  /** Constructs a new FFmpeg job with the given FFmpeg instance and progress listener. */
036  public FFmpegJob(FFmpeg ffmpeg, @Nullable ProgressListener listener) {
037    this.ffmpeg = checkNotNull(ffmpeg);
038    this.listener = listener;
039  }
040
041  public State getState() {
042    return state;
043  }
044}