Skip to content

Draft: PREVIEW: audio: take advantage of package name to avoid type and const name redundancy

This is a preview for how code would look like with gstreamer-rs#374 (closed). Only plugins under audio are affected in this preview. This is because I only changed gst_base & gst_audio so far. See this branch.

This is based on gir changes from this branch:

  • A "removable prefix" is determined based on each namespace specificities: if the first symbol prefix (e.g. gst, from the gir file namespace attribute c:symbol-prefixes) matches the first part of the crate name (e.g. gst_audio), then all functions starting with audio_, all types starting with Audio and all constants starting with AUDIO_ will get their prefix removed...

  • ... unless Gir.toml instructs otherwise (just to show how this could be fine-tuned):

    • Disabling for all types in a namespace

      [[object]]
      name = "GstApp.*"
      removable_prefix = "disabled"
    • Disabling for a specific type only

      [[object]]
      name = "GstBase.BaseSink"
      removable_prefix = "disabled"
    • Disabling for all constants

      [[object]]
      name = "GstGL.*"
      [..]
          [[object.constant]]
          pattern = "*"
          removable_prefix = "disabled"
    • Disabling for a specific constant only

      [[object]]
      name = "GstGL.*"
      [..]
          [[object.constant]]
          name = "GL_API_GLES1_NAME"
          removable_prefix = "disabled"
    • Forcing for all types in a namespace

      [[object]]
      name = "GstRtspServer.*"
      removable_prefix = "RTSP"
    • and so on...

  • I also removed the prefix from generated and manual source filenames. This leads to shorter paths and use clauses. E.g.:

    use gst_base::subclass::transform::GenerateOutputSuccess;

    See this FIXME for an unrelated proposal about this particular use clause, and this other FIXME for a similar proposal.

  • However, I kept the traits prefix to avoid conflicts when used with a prelude::* clause. So we still have BaseSinkExt and AudioBaseSinkExt for instance.

Edited by François Laignel

Merge request reports

Loading