No need to clone

This commit is contained in:
Rafael Caricio 2021-05-15 19:51:50 +02:00
parent 442146887e
commit 6a7a0dcb8c
2 changed files with 11 additions and 19 deletions

View file

@ -8,6 +8,7 @@ use crate::playlist::PlaylistRenderState;
use m3u8_rs::playlist::{MediaPlaylist, MediaPlaylistType, MediaSegment};
use once_cell::sync::Lazy;
use std::fs::{File, OpenOptions};
use std::path;
use std::sync::{Arc, Mutex};
const DEFAULT_LOCATION: &str = "segment%05d.ts";
@ -172,7 +173,7 @@ impl FlexHlsSink {
let giostreamsink = settings.giostreamsink.as_ref().unwrap();
let stream = self
.get_fragment_stream(segment_file_location.clone())
.get_fragment_stream(&segment_file_location)
.map_err(|err| err.to_string())?;
giostreamsink.set_property("stream", &stream).unwrap();
@ -184,13 +185,16 @@ impl FlexHlsSink {
Ok(segment_file_location)
}
fn get_fragment_stream(&self, location: String) -> Result<gio::WriteOutputStream, glib::Error> {
let file_stream = File::create(&location).map_err(|err| {
fn get_fragment_stream<P>(&self, location: &P) -> Result<gio::WriteOutputStream, glib::Error>
where
P: AsRef<path::Path>,
{
let file_stream = File::create(location).map_err(|err| {
glib::Error::new(
gst::URIError::BadReference,
format!(
"Could create segment file {} for writing: {}",
&location,
location.as_ref().to_str().unwrap(),
err.to_string()
)
.as_str(),

View file

@ -36,7 +36,7 @@ fn test_basic_element_with_video_content() {
let video_src = gst::ElementFactory::make("videotestsrc", Some("test_videotestsrc")).unwrap();
video_src.set_property("is-live", &true).unwrap();
let x264enc= gst::ElementFactory::make("x264enc", Some("test_x264enc")).unwrap();
let x264enc = gst::ElementFactory::make("x264enc", Some("test_x264enc")).unwrap();
let h264parse = gst::ElementFactory::make("h264parse", Some("test_h264parse")).unwrap();
let tee = gst::ElementFactory::make("tee", Some("test_tee")).unwrap();
@ -63,12 +63,7 @@ fn test_basic_element_with_video_content() {
])
.unwrap();
gst::Element::link_many(&[
&video_src,
&x264enc,
&h264parse,
&tee,
]).unwrap();
gst::Element::link_many(&[&video_src, &x264enc, &h264parse, &tee]).unwrap();
gst::Element::link_many(&[&app_queue, &app_sink]).unwrap();
gst::Element::link_many(&[&hls_queue, &flexhlssink]).unwrap();
@ -83,7 +78,6 @@ fn test_basic_element_with_video_content() {
let hls_queue_pad = hls_queue.static_pad("sink").unwrap();
tee_hls_pad.link(&hls_queue_pad).unwrap();
let appsink = app_sink.dynamic_cast::<gst_app::AppSink>().unwrap();
appsink.set_emit_signals(true);
let (sender, receiver) = mpsc::channel();
@ -112,7 +106,6 @@ fn test_basic_element_with_video_content() {
pipeline.set_state(gst::State::Null).unwrap();
}
#[test]
fn test_basic_element_properties() {
init();
@ -125,7 +118,6 @@ fn test_basic_element_properties() {
audio_src.set_property("is-live", &true).unwrap();
audio_src.set_property("num-buffers", &BUFFER_NB).unwrap();
let tee = gst::ElementFactory::make("tee", Some("tee")).unwrap();
let hls_queue = gst::ElementFactory::make("queue", Some("hls_queue")).unwrap();
@ -181,11 +173,7 @@ fn test_basic_element_properties() {
pipeline.set_state(gst::State::Playing).unwrap();
gst_info!(
CAT,
"audio_pipeline: waiting for {} buffers",
BUFFER_NB
);
gst_info!(CAT, "audio_pipeline: waiting for {} buffers", BUFFER_NB);
for idx in 0..BUFFER_NB {
receiver.recv().unwrap();
gst_info!(CAT, "audio_pipeline: received buffer #{}", idx);