Use .into_write() instead of implementing it again
This commit is contained in:
parent
c337dd69e4
commit
d7b925a1f7
14
src/imp.rs
14
src/imp.rs
|
@ -4,7 +4,7 @@ use gst::prelude::*;
|
||||||
use gst::subclass::prelude::*;
|
use gst::subclass::prelude::*;
|
||||||
use gst::{gst_debug, gst_error, gst_info, gst_trace, gst_warning};
|
use gst::{gst_debug, gst_error, gst_info, gst_trace, gst_warning};
|
||||||
|
|
||||||
use crate::{output::StreamWriter, playlist::PlaylistRenderState};
|
use crate::playlist::PlaylistRenderState;
|
||||||
use m3u8_rs::playlist::{MediaPlaylist, MediaPlaylistType, MediaSegment};
|
use m3u8_rs::playlist::{MediaPlaylist, MediaPlaylistType, MediaSegment};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
@ -182,7 +182,7 @@ impl FlexHlsSink {
|
||||||
&self,
|
&self,
|
||||||
element: &super::FlexHlsSink,
|
element: &super::FlexHlsSink,
|
||||||
location: &P,
|
location: &P,
|
||||||
) -> Result<gio::WriteOutputStream, String>
|
) -> Result<gio::OutputStream, String>
|
||||||
where
|
where
|
||||||
P: AsRef<path::Path>,
|
P: AsRef<path::Path>,
|
||||||
{
|
{
|
||||||
|
@ -204,7 +204,7 @@ impl FlexHlsSink {
|
||||||
element.post_error_message(error_msg);
|
element.post_error_message(error_msg);
|
||||||
err.to_string()
|
err.to_string()
|
||||||
})?;
|
})?;
|
||||||
Ok(gio::WriteOutputStream::new(file))
|
Ok(gio::WriteOutputStream::new(file).upcast())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_playlist(
|
fn write_playlist(
|
||||||
|
@ -272,12 +272,12 @@ impl FlexHlsSink {
|
||||||
playlist.media_sequence = *playlist_index as i32 - playlist.segments.len() as i32;
|
playlist.media_sequence = *playlist_index as i32 - playlist.segments.len() as i32;
|
||||||
|
|
||||||
// TODO: this should be a call to the signal exposed by this plugin
|
// TODO: this should be a call to the signal exposed by this plugin
|
||||||
let playlist_file = self
|
let mut playlist_file = self
|
||||||
.new_file_stream(&element, &playlist_location)
|
.new_file_stream(&element, &playlist_location)
|
||||||
.map_err(|_| gst::StateChangeError)?;
|
.map_err(|_| gst::StateChangeError)?
|
||||||
|
.into_write();
|
||||||
|
|
||||||
let mut playlist_stream = StreamWriter(playlist_file);
|
playlist.write_to(&mut playlist_file).map_err(|err| {
|
||||||
playlist.write_to(&mut playlist_stream).map_err(|err| {
|
|
||||||
gst_error!(
|
gst_error!(
|
||||||
CAT,
|
CAT,
|
||||||
"Could not write new playlist file: {}",
|
"Could not write new playlist file: {}",
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use glib::prelude::*;
|
use glib::prelude::*;
|
||||||
|
|
||||||
mod imp;
|
mod imp;
|
||||||
mod output;
|
|
||||||
mod playlist;
|
mod playlist;
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
use gio::prelude::*;
|
|
||||||
use std::io;
|
|
||||||
|
|
||||||
pub(crate) struct StreamWriter(pub gio::WriteOutputStream);
|
|
||||||
|
|
||||||
impl io::Write for StreamWriter {
|
|
||||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
|
||||||
Ok(self
|
|
||||||
.0
|
|
||||||
.write(buf, gio::NONE_CANCELLABLE)
|
|
||||||
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))? as usize)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn flush(&mut self) -> std::io::Result<()> {
|
|
||||||
Ok(self
|
|
||||||
.0
|
|
||||||
.flush(gio::NONE_CANCELLABLE)
|
|
||||||
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue