Update for the TryInto/TryFrom gstreamer API changes

This commit is contained in:
Sebastian Dröge 2019-06-03 19:47:26 +03:00
parent 4eac148045
commit ea14f36a0d
5 changed files with 14 additions and 5 deletions

View file

@ -25,6 +25,7 @@ use gst::subclass::prelude::*;
use gst_video::{self, ValidVideoTimeCode}; use gst_video::{self, ValidVideoTimeCode};
use std::cmp; use std::cmp;
use std::convert::TryInto;
use std::sync::{Mutex, MutexGuard}; use std::sync::{Mutex, MutexGuard};
use crate::line_reader::LineReader; use crate::line_reader::LineReader;
@ -735,7 +736,7 @@ impl MccParse {
)); ));
} }
let size = match q.get_result().try_into_bytes().unwrap() { let size = match q.get_result().try_into().unwrap() {
gst::format::Bytes(Some(size)) => size, gst::format::Bytes(Some(size)) => size,
gst::format::Bytes(None) => { gst::format::Bytes(None) => {
return Err(gst_loggable_error!( return Err(gst_loggable_error!(
@ -1037,7 +1038,7 @@ impl MccParse {
let (rate, flags, start_type, start, stop_type, stop) = event.get(); let (rate, flags, start_type, start, stop_type, stop) = event.get();
let mut start = match start.try_into_time() { let mut start = match start.try_into() {
Ok(start) => start, Ok(start) => start,
Err(_) => { Err(_) => {
gst_error!(CAT, obj: element, "seek has invalid format"); gst_error!(CAT, obj: element, "seek has invalid format");
@ -1045,7 +1046,7 @@ impl MccParse {
} }
}; };
let mut stop = match stop.try_into_time() { let mut stop = match stop.try_into() {
Ok(stop) => stop, Ok(stop) => stop,
Err(_) => { Err(_) => {
gst_error!(CAT, obj: element, "seek has invalid format"); gst_error!(CAT, obj: element, "seek has invalid format");

View file

@ -97,6 +97,8 @@ impl State {
framerate: gst::Fraction, framerate: gst::Fraction,
element: &gst::Element, element: &gst::Element,
) -> Result<gst_video::ValidVideoTimeCode, gst::FlowError> { ) -> Result<gst_video::ValidVideoTimeCode, gst::FlowError> {
use std::convert::TryInto;
let timecode = gst_video::VideoTimeCode::new( let timecode = gst_video::VideoTimeCode::new(
framerate, framerate,
None, None,

View file

@ -111,6 +111,8 @@ fn test_parse() {
/// Test that ensures timecode parsing is the expected one /// Test that ensures timecode parsing is the expected one
#[test] #[test]
fn test_timecodes() { fn test_timecodes() {
use std::convert::TryInto;
init(); init();
let data = include_bytes!("timecodes-cut-down-sample.scc").as_ref(); let data = include_bytes!("timecodes-cut-down-sample.scc").as_ref();

View file

@ -327,6 +327,8 @@ impl Decrypter {
true true
} }
QueryView::Duration(ref mut q) => { QueryView::Duration(ref mut q) => {
use std::convert::TryInto;
if q.get_format() != gst::Format::Bytes { if q.get_format() != gst::Format::Bytes {
return pad.query_default(Some(element), query); return pad.query_default(Some(element), query);
} }
@ -339,7 +341,7 @@ impl Decrypter {
return false; return false;
} }
let size = match peer_query.get_result().try_into_bytes().unwrap() { let size = match peer_query.get_result().try_into().unwrap() {
gst::format::Bytes(Some(size)) => size, gst::format::Bytes(Some(size)) => size,
gst::format::Bytes(None) => { gst::format::Bytes(None) => {
gst_error!(CAT, "Failed to query upstream duration"); gst_error!(CAT, "Failed to query upstream duration");

View file

@ -368,6 +368,8 @@ impl Encrypter {
true true
} }
QueryView::Duration(ref mut q) => { QueryView::Duration(ref mut q) => {
use std::convert::TryInto;
if q.get_format() != gst::Format::Bytes { if q.get_format() != gst::Format::Bytes {
return pad.query_default(Some(element), query); return pad.query_default(Some(element), query);
} }
@ -380,7 +382,7 @@ impl Encrypter {
return false; return false;
} }
let size = match peer_query.get_result().try_into_bytes().unwrap() { let size = match peer_query.get_result().try_into().unwrap() {
gst::format::Bytes(Some(size)) => size, gst::format::Bytes(Some(size)) => size,
gst::format::Bytes(None) => { gst::format::Bytes(None) => {
gst_error!(CAT, "Failed to query upstream duration"); gst_error!(CAT, "Failed to query upstream duration");