001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.util;
006
007/**
008 * Options for where the timestamp an {@link RawFrame} was captured at can be measured relative to.
009 */
010public enum TimestampSource {
011  /** unknown. */
012  kUnknown(0),
013  /**
014   * wpi::Now when the new frame was dequeued by CSCore. Does not account for camera exposure time
015   * or V4L latency.
016   */
017  kFrameDequeue(1),
018  /** End of Frame. Same as V4L2_BUF_FLAG_TSTAMP_SRC_EOF, translated into wpi::Now's timebase. */
019  kV4LEOF(2),
020  /**
021   * Start of Exposure. Same as V4L2_BUF_FLAG_TSTAMP_SRC_SOE, translated into wpi::Now's timebase.
022   */
023  kV4LSOE(3);
024
025  private final int value;
026
027  TimestampSource(int value) {
028    this.value = value;
029  }
030
031  /**
032   * Gets the integer value of the pixel format.
033   *
034   * @return Integer value
035   */
036  public int getValue() {
037    return value;
038  }
039
040  private static final TimestampSource[] s_values = values();
041
042  /**
043   * Gets a TimestampSource enum value from its integer value.
044   *
045   * @param timestampSource integer value
046   * @return Enum value
047   */
048  public static TimestampSource getFromInt(int timestampSource) {
049    return s_values[timestampSource];
050  }
051}