All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scodec.protocols.mpeg.transport.ContinuityCounter.scala Maven / Gradle / Ivy

The newest version!
package scodec.protocols.mpeg
package transport

import scodec.Codec
import scodec.codecs.uint

case class ContinuityCounter(value: Int) {
  require(value >= ContinuityCounter.MinValue && value <= ContinuityCounter.MaxValue)

  def next: ContinuityCounter = ContinuityCounter((value + 1) % 16)
}

object ContinuityCounter {
  val MinValue = 0
  val MaxValue = 15

  implicit val codec: Codec[ContinuityCounter] = uint(4).xmap(ContinuityCounter.apply, _.value)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy