mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-27 12:30:28 +00:00
Update to latest gstreamer-rs master API changes
This commit is contained in:
parent
768b68f94a
commit
323bf3ea08
3 changed files with 46 additions and 58 deletions
|
@ -27,8 +27,8 @@ use byte_slice_cast::*;
|
|||
use num_traits::float::Float;
|
||||
use num_traits::cast::{FromPrimitive, ToPrimitive};
|
||||
|
||||
const DEFAULT_MAX_DELAY: u64 = 1 * gst::SECOND;
|
||||
const DEFAULT_DELAY: u64 = 500 * gst::MSECOND;
|
||||
const DEFAULT_MAX_DELAY: u64 = 1 * gst::SECOND_VAL;
|
||||
const DEFAULT_DELAY: u64 = 500 * gst::MSECOND_VAL;
|
||||
const DEFAULT_INTENSITY: f64 = 0.5;
|
||||
const DEFAULT_FEEDBACK: f64 = 0.0;
|
||||
|
||||
|
@ -165,7 +165,7 @@ impl AudioEcho {
|
|||
settings: &Settings,
|
||||
) {
|
||||
let delay_frames = (settings.delay as usize) * (state.info.channels() as usize)
|
||||
* (state.info.rate() as usize) / (gst::SECOND as usize);
|
||||
* (state.info.rate() as usize) / (gst::SECOND_VAL as usize);
|
||||
|
||||
for (i, (o, e)) in data.iter_mut().zip(state.buffer.iter(delay_frames)) {
|
||||
let inp = (*i).to_f64().unwrap();
|
||||
|
@ -283,7 +283,7 @@ impl BaseTransformImpl<RsBaseTransform> for AudioEcho {
|
|||
};
|
||||
|
||||
let max_delay = self.settings.lock().unwrap().max_delay;
|
||||
let size = max_delay * (info.rate() as u64) / gst::SECOND;
|
||||
let size = max_delay * (info.rate() as u64) / gst::SECOND_VAL;
|
||||
let buffer_size = size * (info.channels() as u64);
|
||||
|
||||
*self.state.lock().unwrap() = Some(State {
|
||||
|
|
|
@ -19,8 +19,6 @@ use gst_plugin::adapter::*;
|
|||
use gst_plugin::bytes::*;
|
||||
use gst_plugin_simple::demuxer::*;
|
||||
|
||||
use muldiv::*;
|
||||
|
||||
use gst;
|
||||
use gst::prelude::*;
|
||||
|
||||
|
@ -48,7 +46,7 @@ struct StreamingState {
|
|||
video: Option<VideoFormat>,
|
||||
expect_video: bool,
|
||||
got_all_streams: bool,
|
||||
last_position: Option<u64>,
|
||||
last_position: gst::ClockTime,
|
||||
|
||||
metadata: Option<Metadata>,
|
||||
|
||||
|
@ -64,7 +62,7 @@ impl StreamingState {
|
|||
video: None,
|
||||
expect_video: video,
|
||||
got_all_streams: false,
|
||||
last_position: None,
|
||||
last_position: gst::CLOCK_TIME_NONE,
|
||||
metadata: None,
|
||||
aac_sequence_header: None,
|
||||
avc_sequence_header: None,
|
||||
|
@ -385,7 +383,7 @@ impl PartialEq for VideoFormat {
|
|||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
struct Metadata {
|
||||
duration: Option<u64>,
|
||||
duration: gst::ClockTime,
|
||||
|
||||
creation_date: Option<String>,
|
||||
creator: Option<String>,
|
||||
|
@ -407,7 +405,7 @@ impl Metadata {
|
|||
assert_eq!(script_data.name, "onMetaData");
|
||||
|
||||
let mut metadata = Metadata {
|
||||
duration: None,
|
||||
duration: gst::CLOCK_TIME_NONE,
|
||||
creation_date: None,
|
||||
creator: None,
|
||||
title: None,
|
||||
|
@ -432,7 +430,7 @@ impl Metadata {
|
|||
for arg in args {
|
||||
match (arg.name, &arg.data) {
|
||||
("duration", &flavors::ScriptDataValue::Number(duration)) => {
|
||||
metadata.duration = Some((duration * 1000.0 * 1000.0 * 1000.0) as u64);
|
||||
metadata.duration = ((duration * 1000.0 * 1000.0 * 1000.0) as u64).into();
|
||||
}
|
||||
("creationdate", &flavors::ScriptDataValue::String(date)) => {
|
||||
metadata.creation_date = Some(String::from(date));
|
||||
|
@ -733,11 +731,7 @@ impl FlvDemux {
|
|||
|
||||
{
|
||||
let buffer = buffer.get_mut().unwrap();
|
||||
buffer.set_pts(
|
||||
(tag_header.timestamp as u64)
|
||||
.mul_div_floor(1000_000, 1)
|
||||
.unwrap(),
|
||||
);
|
||||
buffer.set_pts(gst::ClockTime::from_mseconds(tag_header.timestamp as u64));
|
||||
}
|
||||
|
||||
gst_trace!(
|
||||
|
@ -926,11 +920,7 @@ impl FlvDemux {
|
|||
if !is_keyframe {
|
||||
buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
|
||||
}
|
||||
buffer.set_dts(
|
||||
(tag_header.timestamp as u64)
|
||||
.mul_div_floor(1000_000, 1)
|
||||
.unwrap(),
|
||||
);
|
||||
buffer.set_dts(gst::ClockTime::from_mseconds(tag_header.timestamp as u64));
|
||||
|
||||
// Prevent negative numbers
|
||||
let pts = if cts < 0 && tag_header.timestamp < (-cts) as u32 {
|
||||
|
@ -938,7 +928,7 @@ impl FlvDemux {
|
|||
} else {
|
||||
((tag_header.timestamp as i64) + (cts as i64)) as u64
|
||||
};
|
||||
buffer.set_pts(pts.mul_div_floor(1000_000, 1).unwrap());
|
||||
buffer.set_pts(gst::ClockTime::from_mseconds(pts));
|
||||
}
|
||||
|
||||
gst_trace!(
|
||||
|
@ -1080,14 +1070,14 @@ impl FlvDemux {
|
|||
let pts = buffer.get_pts();
|
||||
streaming_state.last_position = streaming_state
|
||||
.last_position
|
||||
.map(|last| cmp::max(last, pts))
|
||||
.or_else(|| Some(pts));
|
||||
.map(|last| cmp::max(last.into(), pts))
|
||||
.unwrap_or(pts);
|
||||
} else if buffer.get_dts() != gst::CLOCK_TIME_NONE {
|
||||
let dts = buffer.get_dts();
|
||||
streaming_state.last_position = streaming_state
|
||||
.last_position
|
||||
.map(|last| cmp::max(last, dts))
|
||||
.or_else(|| Some(dts));
|
||||
.map(|last| cmp::max(last.into(), dts))
|
||||
.unwrap_or(dts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1120,8 +1110,8 @@ impl DemuxerImpl for FlvDemux {
|
|||
fn seek(
|
||||
&mut self,
|
||||
demuxer: &RsDemuxer,
|
||||
start: u64,
|
||||
stop: Option<u64>,
|
||||
start: gst::ClockTime,
|
||||
stop: gst::ClockTime,
|
||||
) -> Result<SeekResult, ErrorMessage> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
@ -1147,15 +1137,15 @@ impl DemuxerImpl for FlvDemux {
|
|||
false
|
||||
}
|
||||
|
||||
fn get_position(&self, demuxer: &RsDemuxer) -> Option<u64> {
|
||||
fn get_position(&self, demuxer: &RsDemuxer) -> gst::ClockTime {
|
||||
if let Some(StreamingState { last_position, .. }) = self.streaming_state {
|
||||
return last_position;
|
||||
}
|
||||
|
||||
None
|
||||
gst::CLOCK_TIME_NONE
|
||||
}
|
||||
|
||||
fn get_duration(&self, demuxer: &RsDemuxer) -> Option<u64> {
|
||||
fn get_duration(&self, demuxer: &RsDemuxer) -> gst::ClockTime {
|
||||
if let Some(StreamingState {
|
||||
metadata: Some(Metadata { duration, .. }),
|
||||
..
|
||||
|
@ -1164,6 +1154,6 @@ impl DemuxerImpl for FlvDemux {
|
|||
return duration;
|
||||
}
|
||||
|
||||
None
|
||||
gst::CLOCK_TIME_NONE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ pub trait DemuxerImpl: Send + 'static {
|
|||
fn seek(
|
||||
&mut self,
|
||||
demuxer: &RsDemuxer,
|
||||
start: u64,
|
||||
stop: Option<u64>,
|
||||
start: gst::ClockTime,
|
||||
stop: gst::ClockTime,
|
||||
) -> Result<SeekResult, ErrorMessage>;
|
||||
fn handle_buffer(
|
||||
&mut self,
|
||||
|
@ -71,8 +71,8 @@ pub trait DemuxerImpl: Send + 'static {
|
|||
fn end_of_stream(&mut self, demuxer: &RsDemuxer) -> Result<(), ErrorMessage>;
|
||||
|
||||
fn is_seekable(&self, demuxer: &RsDemuxer) -> bool;
|
||||
fn get_position(&self, demuxer: &RsDemuxer) -> Option<u64>;
|
||||
fn get_duration(&self, demuxer: &RsDemuxer) -> Option<u64>;
|
||||
fn get_position(&self, demuxer: &RsDemuxer) -> gst::ClockTime;
|
||||
fn get_duration(&self, demuxer: &RsDemuxer) -> gst::ClockTime;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -351,17 +351,11 @@ impl Demuxer {
|
|||
let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap();
|
||||
|
||||
if active {
|
||||
let mut query = gst::Query::new_duration(gst::Format::Bytes);
|
||||
let upstream_size = if demuxer.sinkpad.peer_query(query.get_mut().unwrap()) {
|
||||
use gst::QueryView;
|
||||
|
||||
match query.view() {
|
||||
QueryView::Duration(ref d) => Some(d.get().1 as u64),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let upstream_size = demuxer
|
||||
.sinkpad
|
||||
.peer_query_duration(gst::Format::Bytes)
|
||||
.and_then(|d| d.try_to_bytes())
|
||||
.and_then(|d| d);
|
||||
|
||||
if !demuxer.start(&element, upstream_size, mode == gst::PadMode::Pull) {
|
||||
return false;
|
||||
|
@ -530,7 +524,7 @@ impl Demuxer {
|
|||
|
||||
match query.view_mut() {
|
||||
QueryView::Position(ref mut q) => {
|
||||
let (fmt, _) = q.get();
|
||||
let fmt = q.get_format();
|
||||
if fmt == gst::Format::Time {
|
||||
let demuxer_impl = &demuxer.imp.lock().unwrap();
|
||||
|
||||
|
@ -542,10 +536,10 @@ impl Demuxer {
|
|||
position
|
||||
);
|
||||
|
||||
match position {
|
||||
match *position {
|
||||
None => return false,
|
||||
Some(position) => {
|
||||
q.set(fmt, position as i64);
|
||||
Some(_) => {
|
||||
q.set(position);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -554,7 +548,7 @@ impl Demuxer {
|
|||
}
|
||||
}
|
||||
QueryView::Duration(ref mut q) => {
|
||||
let (fmt, _) = q.get();
|
||||
let fmt = q.get_format();
|
||||
if fmt == gst::Format::Time {
|
||||
let demuxer_impl = &demuxer.imp.lock().unwrap();
|
||||
|
||||
|
@ -566,10 +560,10 @@ impl Demuxer {
|
|||
duration
|
||||
);
|
||||
|
||||
match duration {
|
||||
match *duration {
|
||||
None => return false,
|
||||
Some(duration) => {
|
||||
q.set(fmt, duration as i64);
|
||||
Some(_) => {
|
||||
q.set(duration);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -597,9 +591,13 @@ impl Demuxer {
|
|||
}
|
||||
}
|
||||
|
||||
fn seek(&self, element: &RsDemuxer, start: u64, stop: u64, offset: &mut u64) -> bool {
|
||||
let stop = if stop == u64::MAX { None } else { Some(stop) };
|
||||
|
||||
fn seek(
|
||||
&self,
|
||||
element: &RsDemuxer,
|
||||
start: gst::ClockTime,
|
||||
stop: gst::ClockTime,
|
||||
offset: &mut u64,
|
||||
) -> bool {
|
||||
gst_debug!(self.cat, obj: element, "Seeking to {:?}-{:?}", start, stop);
|
||||
|
||||
let res = {
|
||||
|
|
Loading…
Reference in a new issue