Class AudioCdSrc

All Implemented Interfaces:
URIHandler, Proxy

@Generated("org.javagi.JavaGI") public class AudioCdSrc extends PushSrc implements URIHandler

Provides a base class for CD digital audio (CDDA) sources, which handles things like seeking, querying, discid calculation, tags, and buffer timestamping.

Using GstAudioCdSrc-based elements in applications

GstAudioCdSrc registers two GstFormats of its own, namely the "track" format and the "sector" format. Applications will usually only find the "track" format interesting. You can retrieve that GstFormat for use in seek events or queries with gst_format_get_by_nick("track").

In order to query the number of tracks, for example, an application would set the CDDA source element to READY or PAUSED state and then query the the number of tracks via gst_element_query_duration() using the track format acquired above. Applications can query the currently playing track in the same way.

Alternatively, applications may retrieve the currently playing track and the total number of tracks from the taglist that will posted on the bus whenever the CD is opened or the currently playing track changes. The taglist will contain GST_TAG_TRACK_NUMBER and GST_TAG_TRACK_COUNT tags.

Applications playing back CD audio using playbin and cdda://n URIs should issue a seek command in track format to change between tracks, rather than setting a new cdda://n+1 URI on playbin (as setting a new URI on playbin involves closing and re-opening the CD device, which is much much slower).

Tags and meta-information

CDDA sources will automatically emit a number of tags, details about which can be found in the libgsttag documentation. Those tags are: GST_TAG_CDDA_CDDB_DISCID, GST_TAG_CDDA_CDDB_DISCID_FULL, GST_TAG_CDDA_MUSICBRAINZ_DISCID, GST_TAG_CDDA_MUSICBRAINZ_DISCID_FULL, among others.

Tracks and Table of Contents (TOC)

Applications will be informed of the available tracks via a TOC message on the pipeline's GstBus. The GstToc will contain a GstTocEntry for each track, with information about each track. The duration for each track can be retrieved via the GST_TAG_DURATION tag from each entry's tag list, or calculated via gst_toc_entry_get_start_stop_times(). The track entries in the TOC will be sorted by track number.

  • Constructor Details

    • AudioCdSrc

      public AudioCdSrc(MemorySegment address)
      Create a AudioCdSrc instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • AudioCdSrc

      public AudioCdSrc()
      Create a new AudioCdSrc.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the AudioCdSrc class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected AudioCdSrc asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class PushSrc
      Returns:
      the instance as if it were its parent type
    • addTrack

      public boolean addTrack(AudioCdSrcTrack track)
      CDDA sources use this function from their start vfunc to announce the available data and audio tracks to the base source class. The caller should allocate track on the stack, the base source will do a shallow copy of the structure (and take ownership of the taglist if there is one).
      Parameters:
      track - address of GstAudioCdSrcTrack to add
      Returns:
      FALSE on error, otherwise TRUE.
    • close

      protected void close()
      closing the device
    • open

      protected boolean open(String device)
      opening the device
    • readSector

      protected Buffer readSector(int sector)
      reading a sector
    • builder

      public static AudioCdSrc.Builder<? extends AudioCdSrc.Builder> builder()
      A AudioCdSrc.Builder object constructs a AudioCdSrc with the specified properties. Use the various set...() methods to set properties, and finish construction with AudioCdSrc.Builder.build().
      Returns:
      the builder object