Update for caps/structure-related string API changes

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1048>
This commit is contained in:
Sebastian Dröge 2023-01-15 22:57:14 +02:00
parent 0c954135a3
commit 6132788b02
16 changed files with 89 additions and 84 deletions

View file

@ -1331,16 +1331,14 @@ impl AudioFormat {
if self.rate != 0 { if self.rate != 0 {
if let Some(ref mut caps) = caps.as_mut() { if let Some(ref mut caps) = caps.as_mut() {
caps.get_mut() caps.get_mut().unwrap().set("rate", self.rate as i32)
.unwrap()
.set_simple(&[("rate", &(self.rate as i32))])
} }
} }
if self.channels != 0 { if self.channels != 0 {
if let Some(ref mut caps) = caps.as_mut() { if let Some(ref mut caps) = caps.as_mut() {
caps.get_mut() caps.get_mut()
.unwrap() .unwrap()
.set_simple(&[("channels", &(self.channels as i32))]) .set("channels", self.channels as i32)
} }
} }
@ -1441,19 +1439,19 @@ impl VideoFormat {
if let (Some(width), Some(height)) = (self.width, self.height) { if let (Some(width), Some(height)) = (self.width, self.height) {
if let Some(ref mut caps) = caps.as_mut() { if let Some(ref mut caps) = caps.as_mut() {
caps.get_mut() let caps = caps.get_mut().unwrap();
.unwrap() caps.set("width", width as i32);
.set_simple(&[("width", &(width as i32)), ("height", &(height as i32))]) caps.set("height", height as i32);
} }
} }
if let Some(par) = self.pixel_aspect_ratio { if let Some(par) = self.pixel_aspect_ratio {
if *par.numer() != 0 && par.numer() != par.denom() { if *par.numer() != 0 && par.numer() != par.denom() {
if let Some(ref mut caps) = caps.as_mut() { if let Some(ref mut caps) = caps.as_mut() {
caps.get_mut().unwrap().set_simple(&[( caps.get_mut().unwrap().set(
"pixel-aspect-ratio", "pixel-aspect-ratio",
&gst::Fraction::new(*par.numer(), *par.denom()), gst::Fraction::new(*par.numer(), *par.denom()),
)]) );
} }
} }
} }
@ -1461,10 +1459,9 @@ impl VideoFormat {
if let Some(fps) = self.framerate { if let Some(fps) = self.framerate {
if *fps.numer() != 0 { if *fps.numer() != 0 {
if let Some(ref mut caps) = caps.as_mut() { if let Some(ref mut caps) = caps.as_mut() {
caps.get_mut().unwrap().set_simple(&[( caps.get_mut()
"framerate", .unwrap()
&gst::Fraction::new(*fps.numer(), *fps.denom()), .set("framerate", gst::Fraction::new(*fps.numer(), *fps.denom()));
)])
} }
} }
} }

View file

@ -57,7 +57,7 @@ fn write_full_box<T, F: FnOnce(&mut Vec<u8>) -> Result<T, Error>>(
fn cmaf_brands_from_caps(caps: &gst::CapsRef, compatible_brands: &mut Vec<&'static [u8; 4]>) { fn cmaf_brands_from_caps(caps: &gst::CapsRef, compatible_brands: &mut Vec<&'static [u8; 4]>) {
let s = caps.structure(0).unwrap(); let s = caps.structure(0).unwrap();
match s.name() { match s.name().as_str() {
"video/x-h264" => { "video/x-h264" => {
let width = s.get::<i32>("width").ok(); let width = s.get::<i32>("width").ok();
let height = s.get::<i32>("height").ok(); let height = s.get::<i32>("height").ok();
@ -411,7 +411,10 @@ fn write_moov(v: &mut Vec<u8>, cfg: &super::HeaderConfiguration) -> Result<(), E
for (idx, other_stream) in cfg.streams.iter().enumerate() { for (idx, other_stream) in cfg.streams.iter().enumerate() {
let s = other_stream.caps.structure(0).unwrap(); let s = other_stream.caps.structure(0).unwrap();
if matches!(s.name(), "video/x-h264" | "video/x-h265" | "image/jpeg") { if matches!(
s.name().as_str(),
"video/x-h264" | "video/x-h265" | "image/jpeg"
) {
references.push(TrackReference { references.push(TrackReference {
reference_type: *b"cdsc", reference_type: *b"cdsc",
track_ids: vec![idx as u32 + 1], track_ids: vec![idx as u32 + 1],
@ -600,7 +603,7 @@ fn write_tkhd(
// Volume // Volume
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
match s.name() { match s.name().as_str() {
"audio/mpeg" | "audio/x-opus" | "audio/x-alaw" | "audio/x-mulaw" | "audio/x-adpcm" => { "audio/mpeg" | "audio/x-opus" | "audio/x-alaw" | "audio/x-mulaw" | "audio/x-adpcm" => {
v.extend((1u16 << 8).to_be_bytes()) v.extend((1u16 << 8).to_be_bytes())
} }
@ -628,7 +631,7 @@ fn write_tkhd(
); );
// Width/height // Width/height
match s.name() { match s.name().as_str() {
"video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => {
let width = s.get::<i32>("width").context("video caps without width")? as u32; let width = s.get::<i32>("width").context("video caps without width")? as u32;
let height = s let height = s
@ -738,7 +741,7 @@ fn write_hdlr(
v.extend([0u8; 4]); v.extend([0u8; 4]);
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
let (handler_type, name) = match s.name() { let (handler_type, name) = match s.name().as_str() {
"video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => {
(b"vide", b"VideoHandler\0".as_slice()) (b"vide", b"VideoHandler\0".as_slice())
} }
@ -768,7 +771,7 @@ fn write_minf(
) -> Result<(), Error> { ) -> Result<(), Error> {
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
match s.name() { match s.name().as_str() {
"video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => {
// Flags are always 1 for unspecified reasons // Flags are always 1 for unspecified reasons
write_full_box(v, b"vmhd", FULL_BOX_VERSION_0, 1, |v| write_vmhd(v, cfg))? write_full_box(v, b"vmhd", FULL_BOX_VERSION_0, 1, |v| write_vmhd(v, cfg))?
@ -879,7 +882,7 @@ fn write_stsd(
v.extend(1u32.to_be_bytes()); v.extend(1u32.to_be_bytes());
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
match s.name() { match s.name().as_str() {
"video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => {
write_visual_sample_entry(v, cfg, stream)? write_visual_sample_entry(v, cfg, stream)?
} }
@ -915,7 +918,7 @@ fn write_visual_sample_entry(
stream: &super::HeaderStream, stream: &super::HeaderStream,
) -> Result<(), Error> { ) -> Result<(), Error> {
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
let fourcc = match s.name() { let fourcc = match s.name().as_str() {
"video/x-h264" => { "video/x-h264" => {
let stream_format = s.get::<&str>("stream-format").context("no stream-format")?; let stream_format = s.get::<&str>("stream-format").context("no stream-format")?;
match stream_format { match stream_format {
@ -977,7 +980,7 @@ fn write_visual_sample_entry(
v.extend((-1i16).to_be_bytes()); v.extend((-1i16).to_be_bytes());
// Codec specific boxes // Codec specific boxes
match s.name() { match s.name().as_str() {
"video/x-h264" => { "video/x-h264" => {
let codec_data = s let codec_data = s
.get::<&gst::BufferRef>("codec_data") .get::<&gst::BufferRef>("codec_data")
@ -1132,7 +1135,7 @@ fn write_visual_sample_entry(
} }
// Write fiel box for codecs that require it // Write fiel box for codecs that require it
if ["image/jpeg"].contains(&s.name()) { if ["image/jpeg"].contains(&s.name().as_str()) {
let interlace_mode = s let interlace_mode = s
.get::<&str>("interlace-mode") .get::<&str>("interlace-mode")
.ok() .ok()
@ -1176,7 +1179,7 @@ fn write_audio_sample_entry(
stream: &super::HeaderStream, stream: &super::HeaderStream,
) -> Result<(), Error> { ) -> Result<(), Error> {
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
let fourcc = match s.name() { let fourcc = match s.name().as_str() {
"audio/mpeg" => b"mp4a", "audio/mpeg" => b"mp4a",
"audio/x-opus" => b"Opus", "audio/x-opus" => b"Opus",
"audio/x-alaw" => b"alaw", "audio/x-alaw" => b"alaw",
@ -1192,7 +1195,7 @@ fn write_audio_sample_entry(
_ => unreachable!(), _ => unreachable!(),
}; };
let sample_size = match s.name() { let sample_size = match s.name().as_str() {
"audio/x-adpcm" => { "audio/x-adpcm" => {
let bitrate = s.get::<i32>("bitrate").context("no ADPCM bitrate field")?; let bitrate = s.get::<i32>("bitrate").context("no ADPCM bitrate field")?;
(bitrate / 8000) as u16 (bitrate / 8000) as u16
@ -1223,7 +1226,7 @@ fn write_audio_sample_entry(
v.extend((u32::from(rate) << 16).to_be_bytes()); v.extend((u32::from(rate) << 16).to_be_bytes());
// Codec specific boxes // Codec specific boxes
match s.name() { match s.name().as_str() {
"audio/mpeg" => { "audio/mpeg" => {
let codec_data = s let codec_data = s
.get::<&gst::BufferRef>("codec_data") .get::<&gst::BufferRef>("codec_data")
@ -1439,7 +1442,7 @@ fn write_xml_meta_data_sample_entry(
stream: &super::HeaderStream, stream: &super::HeaderStream,
) -> Result<(), Error> { ) -> Result<(), Error> {
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
let namespace = match s.name() { let namespace = match s.name().as_str() {
"application/x-onvif-metadata" => b"http://www.onvif.org/ver10/schema", "application/x-onvif-metadata" => b"http://www.onvif.org/ver10/schema",
_ => unreachable!(), _ => unreachable!(),
}; };

View file

@ -1638,7 +1638,7 @@ impl FMP4Mux {
let s = caps.structure(0).unwrap(); let s = caps.structure(0).unwrap();
let mut delta_frames = DeltaFrames::IntraOnly; let mut delta_frames = DeltaFrames::IntraOnly;
match s.name() { match s.name().as_str() {
"video/x-h264" | "video/x-h265" => { "video/x-h264" | "video/x-h265" => {
if !s.has_field_with_type("codec_data", gst::Buffer::static_type()) { if !s.has_field_with_type("codec_data", gst::Buffer::static_type()) {
gst::error!(CAT, obj: pad, "Received caps without codec_data"); gst::error!(CAT, obj: pad, "Received caps without codec_data");

View file

@ -190,7 +190,10 @@ fn write_moov(v: &mut Vec<u8>, header: &super::Header) -> Result<(), Error> {
for (idx, other_stream) in header.streams.iter().enumerate() { for (idx, other_stream) in header.streams.iter().enumerate() {
let s = other_stream.caps.structure(0).unwrap(); let s = other_stream.caps.structure(0).unwrap();
if matches!(s.name(), "video/x-h264" | "video/x-h265" | "image/jpeg") { if matches!(
s.name().as_str(),
"video/x-h264" | "video/x-h265" | "image/jpeg"
) {
references.push(TrackReference { references.push(TrackReference {
reference_type: *b"cdsc", reference_type: *b"cdsc",
track_ids: vec![idx as u32 + 1], track_ids: vec![idx as u32 + 1],
@ -378,7 +381,7 @@ fn write_tkhd(
// Volume // Volume
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
match s.name() { match s.name().as_str() {
"audio/mpeg" | "audio/x-opus" | "audio/x-alaw" | "audio/x-mulaw" | "audio/x-adpcm" => { "audio/mpeg" | "audio/x-opus" | "audio/x-alaw" | "audio/x-mulaw" | "audio/x-adpcm" => {
v.extend((1u16 << 8).to_be_bytes()) v.extend((1u16 << 8).to_be_bytes())
} }
@ -406,7 +409,7 @@ fn write_tkhd(
); );
// Width/height // Width/height
match s.name() { match s.name().as_str() {
"video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => {
let width = s.get::<i32>("width").context("video caps without width")? as u32; let width = s.get::<i32>("width").context("video caps without width")? as u32;
let height = s let height = s
@ -507,7 +510,7 @@ fn write_hdlr(
v.extend([0u8; 4]); v.extend([0u8; 4]);
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
let (handler_type, name) = match s.name() { let (handler_type, name) = match s.name().as_str() {
"video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => {
(b"vide", b"VideoHandler\0".as_slice()) (b"vide", b"VideoHandler\0".as_slice())
} }
@ -537,7 +540,7 @@ fn write_minf(
) -> Result<(), Error> { ) -> Result<(), Error> {
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
match s.name() { match s.name().as_str() {
"video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => {
// Flags are always 1 for unspecified reasons // Flags are always 1 for unspecified reasons
write_full_box(v, b"vmhd", FULL_BOX_VERSION_0, 1, |v| write_vmhd(v, header))? write_full_box(v, b"vmhd", FULL_BOX_VERSION_0, 1, |v| write_vmhd(v, header))?
@ -696,7 +699,7 @@ fn write_stsd(
v.extend(1u32.to_be_bytes()); v.extend(1u32.to_be_bytes());
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
match s.name() { match s.name().as_str() {
"video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => {
write_visual_sample_entry(v, header, stream)? write_visual_sample_entry(v, header, stream)?
} }
@ -732,7 +735,7 @@ fn write_visual_sample_entry(
stream: &super::Stream, stream: &super::Stream,
) -> Result<(), Error> { ) -> Result<(), Error> {
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
let fourcc = match s.name() { let fourcc = match s.name().as_str() {
"video/x-h264" => { "video/x-h264" => {
let stream_format = s.get::<&str>("stream-format").context("no stream-format")?; let stream_format = s.get::<&str>("stream-format").context("no stream-format")?;
match stream_format { match stream_format {
@ -794,7 +797,7 @@ fn write_visual_sample_entry(
v.extend((-1i16).to_be_bytes()); v.extend((-1i16).to_be_bytes());
// Codec specific boxes // Codec specific boxes
match s.name() { match s.name().as_str() {
"video/x-h264" => { "video/x-h264" => {
let codec_data = s let codec_data = s
.get::<&gst::BufferRef>("codec_data") .get::<&gst::BufferRef>("codec_data")
@ -949,7 +952,7 @@ fn write_visual_sample_entry(
} }
// Write fiel box for codecs that require it // Write fiel box for codecs that require it
if ["image/jpeg"].contains(&s.name()) { if ["image/jpeg"].contains(&s.name().as_str()) {
let interlace_mode = s let interlace_mode = s
.get::<&str>("interlace-mode") .get::<&str>("interlace-mode")
.ok() .ok()
@ -993,7 +996,7 @@ fn write_audio_sample_entry(
stream: &super::Stream, stream: &super::Stream,
) -> Result<(), Error> { ) -> Result<(), Error> {
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
let fourcc = match s.name() { let fourcc = match s.name().as_str() {
"audio/mpeg" => b"mp4a", "audio/mpeg" => b"mp4a",
"audio/x-opus" => b"Opus", "audio/x-opus" => b"Opus",
"audio/x-alaw" => b"alaw", "audio/x-alaw" => b"alaw",
@ -1009,7 +1012,7 @@ fn write_audio_sample_entry(
_ => unreachable!(), _ => unreachable!(),
}; };
let sample_size = match s.name() { let sample_size = match s.name().as_str() {
"audio/x-adpcm" => { "audio/x-adpcm" => {
let bitrate = s.get::<i32>("bitrate").context("no ADPCM bitrate field")?; let bitrate = s.get::<i32>("bitrate").context("no ADPCM bitrate field")?;
(bitrate / 8000) as u16 (bitrate / 8000) as u16
@ -1040,7 +1043,7 @@ fn write_audio_sample_entry(
v.extend((u32::from(rate) << 16).to_be_bytes()); v.extend((u32::from(rate) << 16).to_be_bytes());
// Codec specific boxes // Codec specific boxes
match s.name() { match s.name().as_str() {
"audio/mpeg" => { "audio/mpeg" => {
let codec_data = s let codec_data = s
.get::<&gst::BufferRef>("codec_data") .get::<&gst::BufferRef>("codec_data")
@ -1256,7 +1259,7 @@ fn write_xml_meta_data_sample_entry(
stream: &super::Stream, stream: &super::Stream,
) -> Result<(), Error> { ) -> Result<(), Error> {
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
let namespace = match s.name() { let namespace = match s.name().as_str() {
"application/x-onvif-metadata" => b"http://www.onvif.org/ver10/schema", "application/x-onvif-metadata" => b"http://www.onvif.org/ver10/schema",
_ => unreachable!(), _ => unreachable!(),
}; };

View file

@ -870,7 +870,7 @@ impl MP4Mux {
let s = caps.structure(0).unwrap(); let s = caps.structure(0).unwrap();
let mut delta_frames = super::DeltaFrames::IntraOnly; let mut delta_frames = super::DeltaFrames::IntraOnly;
match s.name() { match s.name().as_str() {
"video/x-h264" | "video/x-h265" => { "video/x-h264" | "video/x-h265" => {
if !s.has_field_with_type("codec_data", gst::Buffer::static_type()) { if !s.has_field_with_type("codec_data", gst::Buffer::static_type()) {
gst::error!(CAT, obj: pad, "Received caps without codec_data"); gst::error!(CAT, obj: pad, "Received caps without codec_data");

View file

@ -389,7 +389,7 @@ impl BinImpl for HlsSink3 {
} }
let s = msg.structure().unwrap(); let s = msg.structure().unwrap();
match s.name() { match s.name().as_str() {
"splitmuxsink-fragment-opened" => { "splitmuxsink-fragment-opened" => {
if let Ok(new_fragment_opened_at) = s.get::<gst::ClockTime>("running-time") if let Ok(new_fragment_opened_at) = s.get::<gst::ClockTime>("running-time")
{ {

View file

@ -148,9 +148,9 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
} }
static TIMECODE_CAPS: Lazy<gst::Caps> = static TIMECODE_CAPS: Lazy<gst::Caps> =
Lazy::new(|| gst::Caps::new_simple("timestamp/x-ndi-timecode", &[])); Lazy::new(|| gst::Caps::new_empty_simple("timestamp/x-ndi-timecode"));
static TIMESTAMP_CAPS: Lazy<gst::Caps> = static TIMESTAMP_CAPS: Lazy<gst::Caps> =
Lazy::new(|| gst::Caps::new_simple("timestamp/x-ndi-timestamp", &[])); Lazy::new(|| gst::Caps::new_empty_simple("timestamp/x-ndi-timestamp"));
gst::plugin_define!( gst::plugin_define!(
ndi, ndi,

View file

@ -91,7 +91,7 @@ impl OnvifMetadataOverlay {
let upstream_has_meta = caps let upstream_has_meta = caps
.features(0) .features(0)
.map(|f| f.contains(&gst_video::CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION)) .map(|f| f.contains(gst_video::CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION))
.unwrap_or(false); .unwrap_or(false);
if !upstream_has_meta { if !upstream_has_meta {
@ -99,7 +99,7 @@ impl OnvifMetadataOverlay {
let overlay_caps = caps_clone.make_mut(); let overlay_caps = caps_clone.make_mut();
if let Some(features) = overlay_caps.features_mut(0) { if let Some(features) = overlay_caps.features_mut(0) {
features.add(&gst_video::CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION); features.add(gst_video::CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
let peercaps = self.srcpad.peer_query_caps(Some(&caps_clone)); let peercaps = self.srcpad.peer_query_caps(Some(&caps_clone));
downstream_accepts_meta = !peercaps.is_empty(); downstream_accepts_meta = !peercaps.is_empty();
if downstream_accepts_meta { if downstream_accepts_meta {

View file

@ -379,7 +379,7 @@ impl ReqwestHttpSrc {
if let Some(ref extra_headers) = settings.extra_headers { if let Some(ref extra_headers) = settings.extra_headers {
for (field, value) in extra_headers.iter() { for (field, value) in extra_headers.iter() {
let field = match HeaderName::try_from(field) { let field = match HeaderName::try_from(field.as_str()) {
Ok(field) => field, Ok(field) => field,
Err(err) => { Err(err) => {
gst::warning!( gst::warning!(

View file

@ -263,12 +263,12 @@ impl Default for Settings {
fn default() -> Self { fn default() -> Self {
Self { Self {
video_caps: ["video/x-vp8", "video/x-h264", "video/x-vp9", "video/x-h265"] video_caps: ["video/x-vp8", "video/x-h264", "video/x-vp9", "video/x-h265"]
.iter() .into_iter()
.map(|s| gst::Structure::new_empty(s)) .map(gst::Structure::new_empty)
.collect::<gst::Caps>(), .collect::<gst::Caps>(),
audio_caps: ["audio/x-opus"] audio_caps: ["audio/x-opus"]
.iter() .into_iter()
.map(|s| gst::Structure::new_empty(s)) .map(gst::Structure::new_empty)
.collect::<gst::Caps>(), .collect::<gst::Caps>(),
stun_server: DEFAULT_STUN_SERVER.map(String::from), stun_server: DEFAULT_STUN_SERVER.map(String::from),
turn_servers: gst::Array::new(Vec::new() as Vec<glib::SendValue>), turn_servers: gst::Array::new(Vec::new() as Vec<glib::SendValue>),
@ -848,7 +848,7 @@ impl Session {
{ {
let payloader_caps_mut = payloader_caps.make_mut(); let payloader_caps_mut = payloader_caps.make_mut();
payloader_caps_mut.set_simple(&[("ssrc", &ssrc)]); payloader_caps_mut.set("ssrc", ssrc);
} }
gst::info!( gst::info!(
@ -949,7 +949,7 @@ impl Session {
.property::<gst_webrtc::WebRTCRTPTransceiver>("transceiver"); .property::<gst_webrtc::WebRTCRTPTransceiver>("transceiver");
transceiver.set_property("codec-preferences", None::<gst::Caps>); transceiver.set_property("codec-preferences", None::<gst::Caps>);
let mut global_caps = gst::Caps::new_simple("application/x-unknown", &[]); let mut global_caps = gst::Caps::new_empty_simple("application/x-unknown");
let sdp = self.sdp.as_ref().unwrap(); let sdp = self.sdp.as_ref().unwrap();
let sdp_media = sdp.media(webrtc_pad.media_idx).unwrap(); let sdp_media = sdp.media(webrtc_pad.media_idx).unwrap();
@ -1107,10 +1107,9 @@ impl NavigationEventHandler {
"create-data-channel", "create-data-channel",
&[ &[
&"input", &"input",
&gst::Structure::new( &gst::Structure::builder("config")
"config", .field("priority", gst_webrtc::WebRTCPriorityType::High)
&[("priority", &gst_webrtc::WebRTCPriorityType::High)], .build(),
),
], ],
); );
@ -2138,7 +2137,7 @@ impl WebRTCSink {
if let Some(s) = caps.structure(0) { if let Some(s) = caps.structure(0) {
let mut s = s.to_owned(); let mut s = s.to_owned();
s.remove_fields(&[ s.remove_fields([
"timestamp-offset", "timestamp-offset",
"seqnum-offset", "seqnum-offset",
"ssrc", "ssrc",
@ -2173,7 +2172,7 @@ impl WebRTCSink {
) -> (String, gst::Caps) { ) -> (String, gst::Caps) {
let sink_caps = in_caps.as_ref().to_owned(); let sink_caps = in_caps.as_ref().to_owned();
let is_video = match sink_caps.structure(0).unwrap().name() { let is_video = match sink_caps.structure(0).unwrap().name().as_str() {
"video/x-raw" => true, "video/x-raw" => true,
"audio/x-raw" => false, "audio/x-raw" => false,
_ => unreachable!(), _ => unreachable!(),
@ -2710,15 +2709,15 @@ impl ElementImpl for WebRTCSink {
.structure(gst::Structure::builder("video/x-raw").build()) .structure(gst::Structure::builder("video/x-raw").build())
.structure_with_features( .structure_with_features(
gst::Structure::builder("video/x-raw").build(), gst::Structure::builder("video/x-raw").build(),
gst::CapsFeatures::new(&[CUDA_MEMORY_FEATURE]), gst::CapsFeatures::new([CUDA_MEMORY_FEATURE]),
) )
.structure_with_features( .structure_with_features(
gst::Structure::builder("video/x-raw").build(), gst::Structure::builder("video/x-raw").build(),
gst::CapsFeatures::new(&[GL_MEMORY_FEATURE]), gst::CapsFeatures::new([GL_MEMORY_FEATURE]),
) )
.structure_with_features( .structure_with_features(
gst::Structure::builder("video/x-raw").build(), gst::Structure::builder("video/x-raw").build(),
gst::CapsFeatures::new(&[NVMM_MEMORY_FEATURE]), gst::CapsFeatures::new([NVMM_MEMORY_FEATURE]),
) )
.build(); .build();
let video_pad_template = gst::PadTemplate::new( let video_pad_template = gst::PadTemplate::new(

View file

@ -59,12 +59,12 @@ impl Default for Settings {
"video/x-h265", "video/x-h265",
"video/x-av1", "video/x-av1",
] ]
.iter() .into_iter()
.map(|s| gst::Structure::new_empty(s)) .map(gst::Structure::new_empty)
.collect::<gst::Caps>(), .collect::<gst::Caps>(),
audio_caps: ["audio/x-opus"] audio_caps: ["audio/x-opus"]
.iter() .into_iter()
.map(|s| gst::Structure::new_empty(s)) .map(gst::Structure::new_empty)
.collect::<gst::Caps>(), .collect::<gst::Caps>(),
stun_server: None, stun_server: None,
turn_server: None, turn_server: None,

View file

@ -202,7 +202,7 @@ impl ObjectImpl for RegEx {
} }
}; };
match operation { match operation.as_str() {
"replace-all" | "replace_all" => { "replace-all" | "replace_all" => {
let replacement = match s.get::<Option<String>>("replacement") { let replacement = match s.get::<Option<String>>("replacement") {
Ok(Some(pattern)) => pattern, Ok(Some(pattern)) => pattern,

View file

@ -860,7 +860,7 @@ impl FallbackSwitch {
let caps = caps.caps(); let caps = caps.caps();
debug!(CAT, obj: pad, "Received caps {}", caps); debug!(CAT, obj: pad, "Received caps {}", caps);
let caps_info = match caps.structure(0).unwrap().name() { let caps_info = match caps.structure(0).unwrap().name().as_str() {
"audio/x-raw" => { "audio/x-raw" => {
CapsInfo::Audio(gst_audio::AudioInfo::from_caps(caps).unwrap()) CapsInfo::Audio(gst_audio::AudioInfo::from_caps(caps).unwrap())
} }

View file

@ -204,7 +204,7 @@ impl VideoDecoderImpl for CdgDec {
let pools = query.allocation_pools(); let pools = query.allocation_pools();
if let Some((Some(ref pool), _, _, _)) = pools.first() { if let Some((Some(ref pool), _, _, _)) = pools.first() {
let mut config = pool.config(); let mut config = pool.config();
config.add_option(&gst_video::BUFFER_POOL_OPTION_VIDEO_META); config.add_option(gst_video::BUFFER_POOL_OPTION_VIDEO_META);
pool.set_config(config) pool.set_config(config)
.map_err(|_| gst::loggable_error!(CAT, "Failed to configure buffer pool"))?; .map_err(|_| gst::loggable_error!(CAT, "Failed to configure buffer pool"))?;
} }

View file

@ -266,7 +266,7 @@ impl Cea608Overlay {
let upstream_has_meta = caps let upstream_has_meta = caps
.features(0) .features(0)
.map(|f| f.contains(&gst_video::CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION)) .map(|f| f.contains(gst_video::CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION))
.unwrap_or(false); .unwrap_or(false);
if !upstream_has_meta { if !upstream_has_meta {
@ -274,7 +274,7 @@ impl Cea608Overlay {
let overlay_caps = caps_clone.make_mut(); let overlay_caps = caps_clone.make_mut();
if let Some(features) = overlay_caps.features_mut(0) { if let Some(features) = overlay_caps.features_mut(0) {
features.add(&gst_video::CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION); features.add(gst_video::CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
let peercaps = self.srcpad.peer_query_caps(Some(&caps_clone)); let peercaps = self.srcpad.peer_query_caps(Some(&caps_clone));
downstream_accepts_meta = !peercaps.is_empty(); downstream_accepts_meta = !peercaps.is_empty();
if downstream_accepts_meta { if downstream_accepts_meta {

View file

@ -147,10 +147,16 @@ impl ElementImpl for PaintableSink {
for features in [ for features in [
None, None,
Some(&["memory:GLMemory", "meta:GstVideoOverlayComposition"][..]), Some(gst::CapsFeatures::new([
Some(&["memory:GLMemory"][..]), "memory:GLMemory",
Some(&["memory:SystemMemory", "meta:GstVideoOverlayComposition"][..]), "meta:GstVideoOverlayComposition",
Some(&["meta:GstVideoOverlayComposition"][..]), ])),
Some(gst::CapsFeatures::new(["memory:GLMemory"])),
Some(gst::CapsFeatures::new([
"memory:SystemMemory",
"meta:GstVideoOverlayComposition",
])),
Some(gst::CapsFeatures::new(["meta:GstVideoOverlayComposition"])),
] { ] {
let mut c = gst_video::video_make_raw_caps(&[ let mut c = gst_video::video_make_raw_caps(&[
gst_video::VideoFormat::Bgra, gst_video::VideoFormat::Bgra,
@ -163,15 +169,12 @@ impl ElementImpl for PaintableSink {
.build(); .build();
if let Some(features) = features { if let Some(features) = features {
c.get_mut() let c = c.get_mut().unwrap();
.unwrap()
.set_features_simple(Some(gst::CapsFeatures::new(features)));
if features.contains(&"memory:GLMemory") { if features.contains("memory:GLMemory") {
c.get_mut() c.set("texture-target", "2D")
.unwrap()
.set_simple(&[("texture-target", &"2D")])
} }
c.set_features_simple(Some(features));
} }
caps.append(c); caps.append(c);