Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • gstreamer-rs gstreamer-rs
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 36
    • Issues 36
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GStreamer
  • gstreamer-rsgstreamer-rs
  • Issues
  • #367

Closed
Open
Created Jan 17, 2022 by Jan Alexander Steffens@heftigDeveloper

event::Caps::caps does not use the EventRef's lifetime

event::Caps::caps no longer returns a CapsRef copying the EventRef's lifetime, making for worse code.

The following code compiles using 0.17, but not 0.18:

use gstreamer::{self as gst, prelude::*};

fn probe_func(_pad: &gst::Pad, info: &mut gst::PadProbeInfo) -> gst::PadProbeReturn {
    let caps = match &info.data {
        Some(gst::PadProbeData::Event(e)) => match e.view() {
            gst::EventView::Caps(c) => c.caps(),
            _ => return gst::PadProbeReturn::Ok,
        },
        _ => unreachable!(),
    };

    println!("{}", caps);

    gst::PadProbeReturn::Ok
}

fn main() {
    gst::init().unwrap();

    let pad = gst::Pad::new(None, gst::PadDirection::Src);
    pad.add_probe(gst::PadProbeType::EVENT_DOWNSTREAM, probe_func);
}

0.18 requires either taking a ref of the caps:

    let caps = match &info.data {
        Some(gst::PadProbeData::Event(e)) => match e.view() {
            gst::EventView::Caps(c) => c.caps_owned(), // 💡 Returns an owned Caps
            _ => return gst::PadProbeReturn::Ok,
        },
        _ => unreachable!(),
    };

    println!("{}", caps);

Or storing the event::Caps first:

    let caps = match &info.data {
        Some(gst::PadProbeData::Event(e)) => match e.view() {
            gst::EventView::Caps(c) => c, // 💡 Extract the event::Caps
            _ => return gst::PadProbeReturn::Ok,
        },
        _ => unreachable!(),
    };

    let caps = caps.caps(); // 💡 Extract the CapsRef

    println!("{}", caps);
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking