Record Class SyntheticSpec

java.lang.Object
java.lang.Record
limn.video.decode.SyntheticSpec
Record Components:
pattern - what the pictures draw
width - picture width in pixels, in [1..PixelFormat.MAX_DIMENSION]
height - picture height in pixels, in the same range
format - the plane layout every picture uses
color - how every picture's samples are to be interpreted
frameRateNum - numerator of the nominal frame rate, at least 1 (kept rational so that 30000/1001 is exact rather than a drifting decimal)
frameRateDen - denominator of the nominal frame rate, at least 1
frameCount - pictures before the stream ends, or 0 for a stream that never ends; the endless one is the default because a demo surface wants something to show for as long as it is on screen, and a finite one is what a test asserts an end on
slots - pictures in flight at once, in [1..FramePool.MAX_SLOTS]

public record SyntheticSpec(SyntheticPattern pattern, int width, int height, PixelFormat format, VideoColor color, int frameRateNum, int frameRateDen, int frameCount, int slots) extends Record
The whole description of a synthetic stream: what it draws, how big, in which layout, under which colour interpretation, how fast, for how long, and how many pictures it keeps in flight.

It has a text form, and the text form is a file name: pattern=counter,size=640x360, format=I420,color=BT709_LIMITED,rate=30-1,frames=0,slots=3.synth. That is what lets a stream that has no file behind it be opened through the same facade a real file is, with the same canOpen/open pair and the same install order, instead of through a side door only this decoder has. Every field appears, so the text round-trips exactly and two specs that print the same are the same.

Immutable. The with… methods return a new spec, so a caller starts from of(int, int) and changes the axis it cares about.

  • Field Details

    • EXTENSION

      public static final String EXTENSION
      What a synthetic stream's file name ends with; nothing else claims it.
      See Also:
  • Constructor Details

    • SyntheticSpec

      public SyntheticSpec(SyntheticPattern pattern, int width, int height, PixelFormat format, VideoColor color, int frameRateNum, int frameRateDen, int frameCount, int slots)
      Creates an instance of a SyntheticSpec record class.
      Parameters:
      pattern - the value for the pattern record component
      width - the value for the width record component
      height - the value for the height record component
      format - the value for the format record component
      color - the value for the color record component
      frameRateNum - the value for the frameRateNum record component
      frameRateDen - the value for the frameRateDen record component
      frameCount - the value for the frameCount record component
      slots - the value for the slots record component
  • Method Details

    • of

      public static SyntheticSpec of(int width, int height)
      Colour bars at width × height, I420, BT.709 studio range, 30 per second, endless, three pictures in flight.
      Throws:
      IllegalArgumentException - if a dimension is outside [1..MAX_DIMENSION]
    • withPattern

      public SyntheticSpec withPattern(SyntheticPattern newPattern)
      Returns:
      the same spec drawing newPattern
    • withSize

      public SyntheticSpec withSize(int newWidth, int newHeight)
      Returns:
      the same spec at newWidth × newHeight
    • withFormat

      public SyntheticSpec withFormat(PixelFormat newFormat)
      Returns:
      the same spec in newFormat
    • withColor

      public SyntheticSpec withColor(VideoColor newColor)
      Returns:
      the same spec interpreted as newColor
    • withRate

      public SyntheticSpec withRate(int num, int den)
      Returns:
      the same spec at num/den pictures a second
    • withFrameCount

      public SyntheticSpec withFrameCount(int count)
      Returns:
      the same spec ending after count pictures, or endless when 0
    • withSlots

      public SyntheticSpec withSlots(int count)
      Returns:
      the same spec keeping count pictures in flight
    • durationMicros

      public long durationMicros()
      Returns:
      total length in microseconds, or VideoStreamSource.DURATION_UNKNOWN for an endless stream
    • ptsMicrosOf

      public long ptsMicrosOf(int frameIndex)
      The presentation time of picture frameIndex, in microseconds from the start of the stream. Computed from the rational rate rather than accumulated from an interval, so picture 100000 of a 30000/1001 stream is exact rather than a hundred milliseconds adrift.
      Throws:
      IllegalArgumentException - if frameIndex is negative
    • fileName

      public String fileName()
      Returns:
      the file name this spec is opened under: toString() plus EXTENSION. The file need not exist and is never read; it is the description that is being passed, not a location.
    • path

      public Path path()
      Returns:
      fileName() as a path, ready for Videos.open(java.nio.file.Path). Relative and bare, so nothing resolves it against a directory that would have to exist.
    • parse

      public static SyntheticSpec parse(String text)
      Reads back what toString() wrote. Keys may appear in any order and any of them may be left out, in which case of(int, int) supplies it; the value of an unrecognised key is a failure rather than something skipped, because a misspelled key that was silently ignored would leave a stream quietly running at the wrong size.
      Parameters:
      text - a comma-separated list of key=value, with or without the EXTENSION suffix
      Throws:
      IllegalArgumentException - if a key is unknown, a value cannot be read, or a value is outside the range its component allows; the message names the offending key
      NullPointerException - if text is null
    • toString

      public String toString()
      The text form: every field, in a fixed order, readable back by parse(java.lang.String).
      Specified by:
      toString in class Record
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • pattern

      public SyntheticPattern pattern()
      Returns the value of the pattern record component.
      Returns:
      the value of the pattern record component
    • width

      public int width()
      Returns the value of the width record component.
      Returns:
      the value of the width record component
    • height

      public int height()
      Returns the value of the height record component.
      Returns:
      the value of the height record component
    • format

      public PixelFormat format()
      Returns the value of the format record component.
      Returns:
      the value of the format record component
    • color

      public VideoColor color()
      Returns the value of the color record component.
      Returns:
      the value of the color record component
    • frameRateNum

      public int frameRateNum()
      Returns the value of the frameRateNum record component.
      Returns:
      the value of the frameRateNum record component
    • frameRateDen

      public int frameRateDen()
      Returns the value of the frameRateDen record component.
      Returns:
      the value of the frameRateDen record component
    • frameCount

      public int frameCount()
      Returns the value of the frameCount record component.
      Returns:
      the value of the frameCount record component
    • slots

      public int slots()
      Returns the value of the slots record component.
      Returns:
      the value of the slots record component