mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-10-31 14:48:55 +00:00
Fix various warnings from clippy 1.50
This commit is contained in:
parent
f63c4284c1
commit
cbda137fbf
11 changed files with 101 additions and 210 deletions
|
@ -139,7 +139,7 @@ impl State {
|
|||
gst::Buffer::from_mut_slice(sealed)
|
||||
}
|
||||
|
||||
fn encrypt_blocks(&mut self, block_size: usize) -> Result<BufferVec, gst::FlowError> {
|
||||
fn encrypt_blocks(&mut self, block_size: usize) -> BufferVec {
|
||||
assert_ne!(block_size, 0);
|
||||
|
||||
let mut buffers = BufferVec::new();
|
||||
|
@ -154,7 +154,7 @@ impl State {
|
|||
buffers.push(out_buf);
|
||||
}
|
||||
|
||||
Ok(buffers)
|
||||
buffers
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,19 +193,7 @@ impl Encrypter {
|
|||
state.adapter.push(buffer);
|
||||
|
||||
// Encrypt the whole blocks, if any, and push them.
|
||||
buffers.extend(
|
||||
state
|
||||
.encrypt_blocks(state.block_size as usize)
|
||||
.map_err(|err| {
|
||||
// log the error to the bus
|
||||
gst::element_error!(
|
||||
element,
|
||||
gst::ResourceError::Write,
|
||||
["Failed to decrypt buffer"]
|
||||
);
|
||||
err
|
||||
})?,
|
||||
);
|
||||
buffers.extend(state.encrypt_blocks(state.block_size as usize));
|
||||
|
||||
drop(state_guard);
|
||||
|
||||
|
@ -245,17 +233,8 @@ impl Encrypter {
|
|||
assert!(avail < state.block_size as usize);
|
||||
|
||||
if avail > 0 {
|
||||
match state.encrypt_blocks(avail) {
|
||||
Err(_) => {
|
||||
gst::element_error!(
|
||||
element,
|
||||
gst::ResourceError::Write,
|
||||
["Failed to encrypt buffers at EOS"]
|
||||
);
|
||||
return false;
|
||||
}
|
||||
Ok(b) => buffers.extend(b),
|
||||
}
|
||||
let b = state.encrypt_blocks(avail);
|
||||
buffers.extend(b);
|
||||
}
|
||||
|
||||
// drop the lock before pushing into the pad
|
||||
|
|
|
@ -383,13 +383,11 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
|||
});
|
||||
|
||||
impl InputSelector {
|
||||
fn unprepare(&self, element: &super::InputSelector) -> Result<(), ()> {
|
||||
fn unprepare(&self, element: &super::InputSelector) {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
gst_debug!(CAT, obj: element, "Unpreparing");
|
||||
*state = State::default();
|
||||
gst_debug!(CAT, obj: element, "Unprepared");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -574,7 +572,7 @@ impl ElementImpl for InputSelector {
|
|||
gst_trace!(CAT, obj: element, "Changing state {:?}", transition);
|
||||
|
||||
if let gst::StateChange::ReadyToNull = transition {
|
||||
self.unprepare(element).map_err(|_| gst::StateChangeError)?;
|
||||
self.unprepare(element);
|
||||
}
|
||||
|
||||
let mut success = self.parent_change_state(element, transition)?;
|
||||
|
|
|
@ -655,30 +655,18 @@ impl Transcriber {
|
|||
},
|
||||
EventView::FlushStart(_) => {
|
||||
gst_info!(CAT, obj: element, "Received flush start, disconnecting");
|
||||
match self.disconnect(element) {
|
||||
self.disconnect(element);
|
||||
let mut ret = pad.event_default(Some(element), event);
|
||||
|
||||
match self.srcpad.stop_task() {
|
||||
Err(err) => {
|
||||
element.post_error_message(err);
|
||||
false
|
||||
gst_error!(CAT, obj: element, "Failed to stop srcpad task: {}", err);
|
||||
ret = false;
|
||||
}
|
||||
Ok(_) => {
|
||||
let mut ret = pad.event_default(Some(element), event);
|
||||
Ok(_) => (),
|
||||
};
|
||||
|
||||
match self.srcpad.stop_task() {
|
||||
Err(err) => {
|
||||
gst_error!(
|
||||
CAT,
|
||||
obj: element,
|
||||
"Failed to stop srcpad task: {}",
|
||||
err
|
||||
);
|
||||
ret = false;
|
||||
}
|
||||
Ok(_) => (),
|
||||
};
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
||||
ret
|
||||
}
|
||||
EventView::FlushStop(_) => {
|
||||
gst_info!(CAT, obj: element, "Received flush stop, restarting task");
|
||||
|
@ -946,7 +934,7 @@ impl Transcriber {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn disconnect(&self, element: &super::Transcriber) -> Result<(), gst::ErrorMessage> {
|
||||
fn disconnect(&self, element: &super::Transcriber) {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
|
||||
gst_info!(CAT, obj: element, "Unpreparing");
|
||||
|
@ -967,8 +955,6 @@ impl Transcriber {
|
|||
"Unprepared, connected: {}!",
|
||||
state.connected
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1173,10 +1159,7 @@ impl ElementImpl for Transcriber {
|
|||
|
||||
match transition {
|
||||
gst::StateChange::PausedToReady => {
|
||||
self.disconnect(element).map_err(|err| {
|
||||
element.post_error_message(err);
|
||||
gst::StateChangeError
|
||||
})?;
|
||||
self.disconnect(element);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ impl S3Src {
|
|||
};
|
||||
}
|
||||
|
||||
fn connect(self: &S3Src, url: &GstS3Url) -> Result<S3Client, gst::ErrorMessage> {
|
||||
Ok(S3Client::new(url.region.clone()))
|
||||
fn connect(self: &S3Src, url: &GstS3Url) -> S3Client {
|
||||
S3Client::new(url.region.clone())
|
||||
}
|
||||
|
||||
fn set_uri(self: &S3Src, _: &super::S3Src, url_str: Option<&str>) -> Result<(), glib::Error> {
|
||||
|
@ -345,7 +345,7 @@ impl BaseSrcImpl for S3Src {
|
|||
}
|
||||
};
|
||||
|
||||
let s3client = self.connect(&s3url)?;
|
||||
let s3client = self.connect(&s3url);
|
||||
let size = self.head(src, &s3client, &s3url)?;
|
||||
|
||||
*state = StreamingState::Started {
|
||||
|
|
|
@ -300,7 +300,7 @@ impl JsonGstParse {
|
|||
|
||||
state = self.state.lock().unwrap();
|
||||
} else {
|
||||
state = self.handle_skipped_line(element, pts, state)?;
|
||||
state = self.handle_skipped_line(element, pts, state);
|
||||
}
|
||||
}
|
||||
Ok(Some(Line::Header { format })) => {
|
||||
|
@ -343,7 +343,7 @@ impl JsonGstParse {
|
|||
element: &super::JsonGstParse,
|
||||
pts: gst::ClockTime,
|
||||
mut state: MutexGuard<State>,
|
||||
) -> Result<MutexGuard<State>, gst::FlowError> {
|
||||
) -> MutexGuard<State> {
|
||||
if pts >= state.segment.get_start() {
|
||||
state.seeking = false;
|
||||
state.discont = true;
|
||||
|
@ -355,7 +355,7 @@ impl JsonGstParse {
|
|||
|
||||
drop(state);
|
||||
|
||||
Ok(self.state.lock().unwrap())
|
||||
self.state.lock().unwrap()
|
||||
}
|
||||
|
||||
fn sink_activate(
|
||||
|
|
|
@ -158,7 +158,7 @@ impl ElementImpl for CustomSource {
|
|||
|
||||
match transition {
|
||||
gst::StateChange::ReadyToNull => {
|
||||
self.stop(element)?;
|
||||
self.stop(element);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@ -177,9 +177,7 @@ impl BinImpl for CustomSource {
|
|||
// TODO: Drop stream collection message for now, we only create a simple custom
|
||||
// one here so that fallbacksrc can know about our streams. It is never
|
||||
// forwarded.
|
||||
if let Err(msg) = self.handle_source_no_more_pads(&bin) {
|
||||
bin.post_error_message(msg);
|
||||
}
|
||||
self.handle_source_no_more_pads(&bin);
|
||||
}
|
||||
_ => self.parent_handle_message(bin, msg),
|
||||
}
|
||||
|
@ -222,10 +220,7 @@ impl CustomSource {
|
|||
}
|
||||
|
||||
if !has_sometimes_pads {
|
||||
if let Err(msg) = self.handle_source_no_more_pads(&element) {
|
||||
element.post_error_message(msg);
|
||||
return Err(gst::StateChangeError);
|
||||
}
|
||||
self.handle_source_no_more_pads(&element);
|
||||
} else {
|
||||
gst_debug!(CAT, obj: element, "Found sometimes pads");
|
||||
|
||||
|
@ -249,9 +244,7 @@ impl CustomSource {
|
|||
};
|
||||
let src = CustomSource::from_instance(&element);
|
||||
|
||||
if let Err(msg) = src.handle_source_pad_removed(&element, pad) {
|
||||
element.post_error_message(msg);
|
||||
}
|
||||
src.handle_source_pad_removed(&element, pad);
|
||||
});
|
||||
|
||||
let element_weak = element.downgrade();
|
||||
|
@ -262,9 +255,7 @@ impl CustomSource {
|
|||
};
|
||||
let src = CustomSource::from_instance(&element);
|
||||
|
||||
if let Err(msg) = src.handle_source_no_more_pads(&element) {
|
||||
element.post_error_message(msg);
|
||||
}
|
||||
src.handle_source_no_more_pads(&element);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -347,11 +338,7 @@ impl CustomSource {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_source_pad_removed(
|
||||
&self,
|
||||
element: &super::CustomSource,
|
||||
pad: &gst::Pad,
|
||||
) -> Result<(), gst::ErrorMessage> {
|
||||
fn handle_source_pad_removed(&self, element: &super::CustomSource, pad: &gst::Pad) {
|
||||
gst_debug!(CAT, obj: element, "Source removed pad {}", pad.get_name());
|
||||
|
||||
let mut state = self.state.lock().unwrap();
|
||||
|
@ -361,7 +348,7 @@ impl CustomSource {
|
|||
.enumerate()
|
||||
.find(|(_i, p)| &p.source_pad == pad)
|
||||
{
|
||||
None => return Ok(()),
|
||||
None => return,
|
||||
Some(v) => v,
|
||||
};
|
||||
|
||||
|
@ -372,14 +359,9 @@ impl CustomSource {
|
|||
ghost_pad.set_active(false).unwrap();
|
||||
let _ = ghost_pad.set_target(None::<&gst::Pad>);
|
||||
let _ = element.remove_pad(&ghost_pad);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_source_no_more_pads(
|
||||
&self,
|
||||
element: &super::CustomSource,
|
||||
) -> Result<(), gst::ErrorMessage> {
|
||||
fn handle_source_no_more_pads(&self, element: &super::CustomSource) {
|
||||
gst_debug!(CAT, obj: element, "Source signalled no-more-pads");
|
||||
|
||||
let state = self.state.lock().unwrap();
|
||||
|
@ -400,14 +382,9 @@ impl CustomSource {
|
|||
.src(element)
|
||||
.build(),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn stop(
|
||||
&self,
|
||||
element: &super::CustomSource,
|
||||
) -> Result<gst::StateChangeSuccess, gst::StateChangeError> {
|
||||
fn stop(&self, element: &super::CustomSource) {
|
||||
gst_debug!(CAT, obj: element, "Stopping");
|
||||
|
||||
let mut state = self.state.lock().unwrap();
|
||||
|
@ -420,7 +397,5 @@ impl CustomSource {
|
|||
let _ = pad.ghost_pad.set_target(None::<&gst::Pad>);
|
||||
let _ = element.remove_pad(&pad.ghost_pad);
|
||||
}
|
||||
|
||||
Ok(gst::StateChangeSuccess::Success)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -640,7 +640,7 @@ impl ElementImpl for FallbackSrc {
|
|||
|
||||
// Change the source state manually here to be able to catch errors. State changes always
|
||||
// happen from sink to source, so we do this after chaining up.
|
||||
self.change_source_state(element, transition)?;
|
||||
self.change_source_state(element, transition);
|
||||
|
||||
// Ignore parent state change return to prevent spurious async/no-preroll return values
|
||||
// due to core state change bugs
|
||||
|
@ -649,7 +649,7 @@ impl ElementImpl for FallbackSrc {
|
|||
Ok(gst::StateChangeSuccess::NoPreroll)
|
||||
}
|
||||
gst::StateChange::ReadyToNull => {
|
||||
self.stop(element)?;
|
||||
self.stop(element);
|
||||
Ok(gst::StateChangeSuccess::Success)
|
||||
}
|
||||
_ => Ok(gst::StateChangeSuccess::Success),
|
||||
|
@ -689,7 +689,7 @@ impl FallbackSrc {
|
|||
element: &super::FallbackSrc,
|
||||
source: &Source,
|
||||
buffer_duration: i64,
|
||||
) -> Result<gst::Element, gst::StateChangeError> {
|
||||
) -> gst::Element {
|
||||
let source = match source {
|
||||
Source::Uri(ref uri) => {
|
||||
let source = gst::ElementFactory::make("uridecodebin3", Some("uridecodebin"))
|
||||
|
@ -741,14 +741,12 @@ impl FallbackSrc {
|
|||
};
|
||||
let src = FallbackSrc::from_instance(&element);
|
||||
|
||||
if let Err(msg) = src.handle_source_pad_removed(&element, pad) {
|
||||
element.post_error_message(msg);
|
||||
}
|
||||
src.handle_source_pad_removed(&element, pad);
|
||||
});
|
||||
|
||||
element.add_many(&[&source]).unwrap();
|
||||
|
||||
Ok(source)
|
||||
source
|
||||
}
|
||||
|
||||
fn create_fallback_video_input(
|
||||
|
@ -756,14 +754,11 @@ impl FallbackSrc {
|
|||
_element: &super::FallbackSrc,
|
||||
min_latency: u64,
|
||||
fallback_uri: Option<&str>,
|
||||
) -> Result<gst::Element, gst::StateChangeError> {
|
||||
Ok(VideoFallbackSource::new(fallback_uri, min_latency).upcast())
|
||||
) -> gst::Element {
|
||||
VideoFallbackSource::new(fallback_uri, min_latency).upcast()
|
||||
}
|
||||
|
||||
fn create_fallback_audio_input(
|
||||
&self,
|
||||
_element: &super::FallbackSrc,
|
||||
) -> Result<gst::Element, gst::StateChangeError> {
|
||||
fn create_fallback_audio_input(&self, _element: &super::FallbackSrc) -> gst::Element {
|
||||
let input = gst::Bin::new(Some("fallback_audio"));
|
||||
let audiotestsrc = gst::ElementFactory::make("audiotestsrc", Some("fallback_audiosrc"))
|
||||
.expect("No audiotestsrc found");
|
||||
|
@ -781,7 +776,7 @@ impl FallbackSrc {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
Ok(input.upcast())
|
||||
input.upcast()
|
||||
}
|
||||
|
||||
fn create_stream(
|
||||
|
@ -791,11 +786,11 @@ impl FallbackSrc {
|
|||
min_latency: u64,
|
||||
is_audio: bool,
|
||||
fallback_uri: Option<&str>,
|
||||
) -> Result<Stream, gst::StateChangeError> {
|
||||
) -> Stream {
|
||||
let fallback_input = if is_audio {
|
||||
self.create_fallback_audio_input(element)?
|
||||
self.create_fallback_audio_input(element)
|
||||
} else {
|
||||
self.create_fallback_video_input(element, min_latency, fallback_uri)?
|
||||
self.create_fallback_video_input(element, min_latency, fallback_uri)
|
||||
};
|
||||
|
||||
let switch =
|
||||
|
@ -865,7 +860,7 @@ impl FallbackSrc {
|
|||
|
||||
element.add_pad(&ghostpad).unwrap();
|
||||
|
||||
Ok(Stream {
|
||||
Stream {
|
||||
fallback_input,
|
||||
source_srcpad: None,
|
||||
source_srcpad_block: None,
|
||||
|
@ -874,7 +869,7 @@ impl FallbackSrc {
|
|||
clocksync_queue,
|
||||
switch,
|
||||
srcpad: ghostpad.upcast(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn start(&self, element: &super::FallbackSrc) -> Result<(), gst::StateChangeError> {
|
||||
|
@ -907,8 +902,7 @@ impl FallbackSrc {
|
|||
let fallback_uri = &settings.fallback_uri;
|
||||
|
||||
// Create main input
|
||||
let source =
|
||||
self.create_main_input(element, &configured_source, settings.buffer_duration)?;
|
||||
let source = self.create_main_input(element, &configured_source, settings.buffer_duration);
|
||||
|
||||
let mut flow_combiner = gst_base::UniqueFlowCombiner::new();
|
||||
|
||||
|
@ -920,7 +914,7 @@ impl FallbackSrc {
|
|||
settings.min_latency,
|
||||
false,
|
||||
fallback_uri.as_deref(),
|
||||
)?;
|
||||
);
|
||||
flow_combiner.add_pad(&stream.srcpad);
|
||||
Some(stream)
|
||||
} else {
|
||||
|
@ -930,7 +924,7 @@ impl FallbackSrc {
|
|||
// Create audio stream
|
||||
let audio_stream = if settings.enable_audio {
|
||||
let stream =
|
||||
self.create_stream(element, settings.timeout, settings.min_latency, true, None)?;
|
||||
self.create_stream(element, settings.timeout, settings.min_latency, true, None);
|
||||
flow_combiner.add_pad(&stream.srcpad);
|
||||
Some(stream)
|
||||
} else {
|
||||
|
@ -964,12 +958,12 @@ impl FallbackSrc {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn stop(&self, element: &super::FallbackSrc) -> Result<(), gst::StateChangeError> {
|
||||
fn stop(&self, element: &super::FallbackSrc) {
|
||||
gst_debug!(CAT, obj: element, "Stopping");
|
||||
let mut state_guard = self.state.lock().unwrap();
|
||||
let mut state = match state_guard.take() {
|
||||
Some(state) => state,
|
||||
None => return Ok(()),
|
||||
None => return,
|
||||
};
|
||||
drop(state_guard);
|
||||
|
||||
|
@ -1018,19 +1012,14 @@ impl FallbackSrc {
|
|||
}
|
||||
|
||||
gst_debug!(CAT, obj: element, "Stopped");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn change_source_state(
|
||||
&self,
|
||||
element: &super::FallbackSrc,
|
||||
transition: gst::StateChange,
|
||||
) -> Result<(), gst::StateChangeError> {
|
||||
fn change_source_state(&self, element: &super::FallbackSrc, transition: gst::StateChange) {
|
||||
gst_debug!(CAT, obj: element, "Changing source state: {:?}", transition);
|
||||
let mut state_guard = self.state.lock().unwrap();
|
||||
let state = match &mut *state_guard {
|
||||
Some(state) => state,
|
||||
None => return Ok(()),
|
||||
None => return,
|
||||
};
|
||||
|
||||
if transition.current() <= transition.next() && state.source_pending_restart {
|
||||
|
@ -1039,7 +1028,7 @@ impl FallbackSrc {
|
|||
obj: element,
|
||||
"Not starting source because pending restart"
|
||||
);
|
||||
return Ok(());
|
||||
return;
|
||||
} else if transition.next() <= gst::State::Ready && state.source_pending_restart {
|
||||
gst_debug!(
|
||||
CAT,
|
||||
|
@ -1094,8 +1083,6 @@ impl FallbackSrc {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn proxy_pad_chain(
|
||||
|
@ -1610,11 +1597,7 @@ impl FallbackSrc {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_source_pad_removed(
|
||||
&self,
|
||||
element: &super::FallbackSrc,
|
||||
pad: &gst::Pad,
|
||||
) -> Result<(), gst::ErrorMessage> {
|
||||
fn handle_source_pad_removed(&self, element: &super::FallbackSrc, pad: &gst::Pad) {
|
||||
gst_debug!(
|
||||
CAT,
|
||||
obj: element,
|
||||
|
@ -1625,7 +1608,7 @@ impl FallbackSrc {
|
|||
let mut state_guard = self.state.lock().unwrap();
|
||||
let state = match &mut *state_guard {
|
||||
None => {
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
Some(state) => state,
|
||||
};
|
||||
|
@ -1646,7 +1629,7 @@ impl FallbackSrc {
|
|||
{
|
||||
stream
|
||||
} else {
|
||||
return Ok(());
|
||||
return;
|
||||
};
|
||||
|
||||
stream.source_srcpad = None;
|
||||
|
@ -1655,8 +1638,6 @@ impl FallbackSrc {
|
|||
|
||||
drop(state_guard);
|
||||
element.notify("status");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_buffering(&self, element: &super::FallbackSrc, m: &gst::message::Buffering) {
|
||||
|
@ -1992,13 +1973,11 @@ impl FallbackSrc {
|
|||
// See https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/746
|
||||
element.remove(&state.source).unwrap();
|
||||
|
||||
let source = src
|
||||
.create_main_input(
|
||||
element,
|
||||
&state.configured_source,
|
||||
state.settings.buffer_duration,
|
||||
)
|
||||
.expect("failed to create new source");
|
||||
let source = src.create_main_input(
|
||||
element,
|
||||
&state.configured_source,
|
||||
state.settings.buffer_duration,
|
||||
);
|
||||
|
||||
(
|
||||
source.clone(),
|
||||
|
|
|
@ -204,7 +204,7 @@ impl ElementImpl for VideoFallbackSource {
|
|||
|
||||
match transition {
|
||||
gst::StateChange::ReadyToNull => {
|
||||
self.stop(element)?;
|
||||
self.stop(element);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@ -220,9 +220,10 @@ impl BinImpl for VideoFallbackSource {
|
|||
|
||||
match msg.view() {
|
||||
MessageView::Error(err) => {
|
||||
if !self
|
||||
if self
|
||||
.got_error
|
||||
.compare_and_swap(false, true, Ordering::SeqCst)
|
||||
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
|
||||
.is_err()
|
||||
{
|
||||
gst_warning!(CAT, obj: bin, "Got error {:?}", err);
|
||||
self.parent_handle_message(bin, msg)
|
||||
|
@ -283,7 +284,7 @@ impl VideoFallbackSource {
|
|||
element: &super::VideoFallbackSource,
|
||||
min_latency: u64,
|
||||
uri: Option<&str>,
|
||||
) -> Result<gst::Element, gst::StateChangeError> {
|
||||
) -> gst::Element {
|
||||
gst_debug!(CAT, obj: element, "Creating source with uri {:?}", uri);
|
||||
|
||||
let source = gst::Bin::new(None);
|
||||
|
@ -440,7 +441,7 @@ impl VideoFallbackSource {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
Ok(source.upcast())
|
||||
source.upcast()
|
||||
}
|
||||
|
||||
fn start(
|
||||
|
@ -457,7 +458,7 @@ impl VideoFallbackSource {
|
|||
|
||||
let settings = self.settings.lock().unwrap().clone();
|
||||
let uri = &settings.uri;
|
||||
let source = self.create_source(element, settings.min_latency, uri.as_deref())?;
|
||||
let source = self.create_source(element, settings.min_latency, uri.as_deref());
|
||||
|
||||
element.add(&source).unwrap();
|
||||
|
||||
|
@ -469,16 +470,13 @@ impl VideoFallbackSource {
|
|||
Ok(gst::StateChangeSuccess::Success)
|
||||
}
|
||||
|
||||
fn stop(
|
||||
&self,
|
||||
element: &super::VideoFallbackSource,
|
||||
) -> Result<gst::StateChangeSuccess, gst::StateChangeError> {
|
||||
fn stop(&self, element: &super::VideoFallbackSource) {
|
||||
gst_debug!(CAT, obj: element, "Stopping");
|
||||
|
||||
let mut state_guard = self.state.lock().unwrap();
|
||||
let state = match state_guard.take() {
|
||||
Some(state) => state,
|
||||
None => return Ok(gst::StateChangeSuccess::Success),
|
||||
None => return,
|
||||
};
|
||||
|
||||
drop(state_guard);
|
||||
|
@ -488,7 +486,5 @@ impl VideoFallbackSource {
|
|||
element.remove(&state.source).unwrap();
|
||||
self.got_error.store(false, Ordering::Relaxed);
|
||||
gst_debug!(CAT, obj: element, "Stopped");
|
||||
|
||||
Ok(gst::StateChangeSuccess::Success)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,14 +214,11 @@ impl VideoDecoderImpl for CdgDec {
|
|||
.is_some()
|
||||
{
|
||||
let pools = allocation.get_allocation_pools();
|
||||
if let Some((ref pool, _, _, _)) = pools.first() {
|
||||
if let Some(pool) = pool {
|
||||
let mut config = pool.get_config();
|
||||
config.add_option(&gst_video::BUFFER_POOL_OPTION_VIDEO_META);
|
||||
pool.set_config(config).map_err(|e| {
|
||||
gst::error_msg!(gst::CoreError::Negotiation, [&e.message])
|
||||
})?;
|
||||
}
|
||||
if let Some((Some(ref pool), _, _, _)) = pools.first() {
|
||||
let mut config = pool.get_config();
|
||||
config.add_option(&gst_video::BUFFER_POOL_OPTION_VIDEO_META);
|
||||
pool.set_config(config)
|
||||
.map_err(|e| gst::error_msg!(gst::CoreError::Negotiation, [&e.message]))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -494,15 +494,12 @@ impl VideoDecoderImpl for Dav1dDec {
|
|||
.is_some()
|
||||
{
|
||||
let pools = allocation.get_allocation_pools();
|
||||
if let Some((ref pool, _, _, _)) = pools.first() {
|
||||
if let Some(pool) = pool {
|
||||
let mut config = pool.get_config();
|
||||
config.add_option(&gst_video::BUFFER_POOL_OPTION_VIDEO_META);
|
||||
pool.set_config(config).map_err(|e| {
|
||||
gst::error_msg!(gst::CoreError::Negotiation, [&e.message])
|
||||
})?;
|
||||
self.negotiation_infos.lock().unwrap().video_meta_supported = true;
|
||||
}
|
||||
if let Some((Some(ref pool), _, _, _)) = pools.first() {
|
||||
let mut config = pool.get_config();
|
||||
config.add_option(&gst_video::BUFFER_POOL_OPTION_VIDEO_META);
|
||||
pool.set_config(config)
|
||||
.map_err(|e| gst::error_msg!(gst::CoreError::Negotiation, [&e.message]))?;
|
||||
self.negotiation_infos.lock().unwrap().video_meta_supported = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,10 @@ impl ObjectSubclass for FlvDemux {
|
|||
"Panic activating sink pad with mode"
|
||||
))
|
||||
},
|
||||
|demux, element| demux.sink_activatemode(pad, element, mode, active),
|
||||
|demux, element| {
|
||||
demux.sink_activatemode(pad, element, mode, active);
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
})
|
||||
.chain_function(|pad, parent, buffer| {
|
||||
|
@ -332,12 +335,9 @@ impl FlvDemux {
|
|||
element: &super::FlvDemux,
|
||||
mode: gst::PadMode,
|
||||
active: bool,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
) {
|
||||
if active {
|
||||
self.start(element, mode).map_err(|err| {
|
||||
element.post_error_message(err);
|
||||
gst::loggable_error!(CAT, "Failed to start element with mode {:?}", mode)
|
||||
})?;
|
||||
self.start(element, mode);
|
||||
|
||||
if mode == gst::PadMode::Pull {
|
||||
// TODO implement pull mode
|
||||
|
@ -349,26 +349,15 @@ impl FlvDemux {
|
|||
let _ = self.sinkpad.stop_task();
|
||||
}
|
||||
|
||||
self.stop(element).map_err(|err| {
|
||||
element.post_error_message(err);
|
||||
gst::loggable_error!(CAT, "Failed to stop element")
|
||||
})?;
|
||||
self.stop(element);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn start(
|
||||
&self,
|
||||
_element: &super::FlvDemux,
|
||||
_mode: gst::PadMode,
|
||||
) -> Result<(), gst::ErrorMessage> {
|
||||
fn start(&self, _element: &super::FlvDemux, _mode: gst::PadMode) {
|
||||
*self.state.lock().unwrap() = State::NeedHeader;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn stop(&self, element: &super::FlvDemux) -> Result<(), gst::ErrorMessage> {
|
||||
fn stop(&self, element: &super::FlvDemux) {
|
||||
*self.state.lock().unwrap() = State::Stopped;
|
||||
self.adapter.lock().unwrap().clear();
|
||||
|
||||
|
@ -384,8 +373,6 @@ impl FlvDemux {
|
|||
}
|
||||
|
||||
flow_combiner.reset();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn sink_event(&self, pad: &gst::Pad, element: &super::FlvDemux, event: gst::Event) -> bool {
|
||||
|
@ -753,7 +740,7 @@ impl StreamingState {
|
|||
flavors::TagType::Script => {
|
||||
gst_trace!(CAT, obj: element, "Found script tag");
|
||||
|
||||
self.handle_script_tag(element, &tag_header, adapter)
|
||||
Ok(self.handle_script_tag(element, &tag_header, adapter))
|
||||
}
|
||||
flavors::TagType::Audio => {
|
||||
gst_trace!(CAT, obj: element, "Found audio tag");
|
||||
|
@ -774,7 +761,7 @@ impl StreamingState {
|
|||
element: &super::FlvDemux,
|
||||
tag_header: &flavors::TagHeader,
|
||||
adapter: &mut gst_base::UniqueAdapter,
|
||||
) -> Result<SmallVec<[Event; 4]>, gst::ErrorMessage> {
|
||||
) -> SmallVec<[Event; 4]> {
|
||||
assert!(adapter.available() >= tag_header.data_size as usize);
|
||||
|
||||
let mut events = SmallVec::new();
|
||||
|
@ -827,14 +814,14 @@ impl StreamingState {
|
|||
drop(data);
|
||||
adapter.flush(tag_header.data_size as usize);
|
||||
|
||||
Ok(events)
|
||||
events
|
||||
}
|
||||
|
||||
fn update_audio_stream(
|
||||
&mut self,
|
||||
element: &super::FlvDemux,
|
||||
data_header: &flavors::AudioDataHeader,
|
||||
) -> Result<SmallVec<[Event; 4]>, gst::ErrorMessage> {
|
||||
) -> SmallVec<[Event; 4]> {
|
||||
let mut events = SmallVec::new();
|
||||
|
||||
gst_trace!(
|
||||
|
@ -871,7 +858,7 @@ impl StreamingState {
|
|||
events.push(Event::HaveAllStreams);
|
||||
}
|
||||
|
||||
Ok(events)
|
||||
events
|
||||
}
|
||||
|
||||
fn handle_aac_audio_packet_header(
|
||||
|
@ -953,7 +940,7 @@ impl StreamingState {
|
|||
drop(data);
|
||||
adapter.flush(1);
|
||||
|
||||
let mut events = self.update_audio_stream(element, &data_header)?;
|
||||
let mut events = self.update_audio_stream(element, &data_header);
|
||||
|
||||
// AAC special case
|
||||
if data_header.sound_format == flavors::SoundFormat::AAC
|
||||
|
@ -1004,7 +991,7 @@ impl StreamingState {
|
|||
&mut self,
|
||||
element: &super::FlvDemux,
|
||||
data_header: &flavors::VideoDataHeader,
|
||||
) -> Result<SmallVec<[Event; 4]>, gst::ErrorMessage> {
|
||||
) -> SmallVec<[Event; 4]> {
|
||||
let mut events = SmallVec::new();
|
||||
|
||||
gst_trace!(
|
||||
|
@ -1041,7 +1028,7 @@ impl StreamingState {
|
|||
events.push(Event::HaveAllStreams);
|
||||
}
|
||||
|
||||
Ok(events)
|
||||
events
|
||||
}
|
||||
|
||||
fn handle_avc_video_packet_header(
|
||||
|
@ -1134,7 +1121,7 @@ impl StreamingState {
|
|||
drop(data);
|
||||
adapter.flush(1);
|
||||
|
||||
let mut events = self.update_video_stream(element, &data_header)?;
|
||||
let mut events = self.update_video_stream(element, &data_header);
|
||||
|
||||
// AVC/H264 special case
|
||||
let cts = if data_header.codec_id == flavors::CodecId::H264 {
|
||||
|
|
Loading…
Reference in a new issue