mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-25 21:11:00 +00:00
hlssink3: Use fragment duration from splitmuxsink if available
splitmuxsink now reports fragment offset and duration in the splitmuxsink-fragment-closed message. Use this duration value for the MediaSegment when available. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1728>
This commit is contained in:
parent
4cf93ccbdb
commit
320f36a462
2 changed files with 27 additions and 12 deletions
|
@ -466,7 +466,7 @@ impl BinImpl for HlsSink3 {
|
||||||
"splitmuxsink-fragment-closed" => {
|
"splitmuxsink-fragment-closed" => {
|
||||||
let s = msg.structure().unwrap();
|
let s = msg.structure().unwrap();
|
||||||
if let Ok(fragment_closed_at) = s.get::<gst::ClockTime>("running-time") {
|
if let Ok(fragment_closed_at) = s.get::<gst::ClockTime>("running-time") {
|
||||||
self.on_fragment_closed(fragment_closed_at);
|
self.on_fragment_closed(s, fragment_closed_at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -543,7 +543,7 @@ impl HlsSink3 {
|
||||||
Ok(segment_file_location)
|
Ok(segment_file_location)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_fragment_closed(&self, closed_at: gst::ClockTime) {
|
fn on_fragment_closed(&self, s: &gst::StructureRef, closed_at: gst::ClockTime) {
|
||||||
let mut state = self.state.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
let location = match state.current_segment_location.take() {
|
let location = match state.current_segment_location.take() {
|
||||||
Some(location) => location,
|
Some(location) => location,
|
||||||
|
@ -553,15 +553,30 @@ impl HlsSink3 {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let opened_at = match state.fragment_opened_at.take() {
|
let (duration, duration_msec) = {
|
||||||
Some(opened_at) => opened_at,
|
if let Ok(fragment_duration) = s.get::<gst::ClockTime>("fragment-duration") {
|
||||||
None => {
|
(
|
||||||
gst::error!(CAT, imp = self, "Unknown segment duration");
|
fragment_duration,
|
||||||
return;
|
fragment_duration.mseconds() as f32 / 1_000f32,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
let opened_at = match state.fragment_opened_at.take() {
|
||||||
|
Some(opened_at) => opened_at,
|
||||||
|
None => {
|
||||||
|
gst::error!(CAT, imp = self, "Unknown segment duration");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let fragment_duration = closed_at - opened_at;
|
||||||
|
|
||||||
|
(
|
||||||
|
fragment_duration,
|
||||||
|
fragment_duration.mseconds() as f32 / 1_000f32,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let duration = closed_at - opened_at;
|
|
||||||
let running_time = state.fragment_running_time;
|
let running_time = state.fragment_running_time;
|
||||||
drop(state);
|
drop(state);
|
||||||
|
|
||||||
|
@ -574,7 +589,7 @@ impl HlsSink3 {
|
||||||
duration,
|
duration,
|
||||||
MediaSegment {
|
MediaSegment {
|
||||||
uri,
|
uri,
|
||||||
duration: duration.mseconds() as f32 / 1_000f32,
|
duration: duration_msec,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -267,9 +267,9 @@ fn test_hlssink3_element_with_video_content() -> Result<(), ()> {
|
||||||
#EXT-X-VERSION:3
|
#EXT-X-VERSION:3
|
||||||
#EXT-X-TARGETDURATION:2
|
#EXT-X-TARGETDURATION:2
|
||||||
#EXT-X-MEDIA-SEQUENCE:4
|
#EXT-X-MEDIA-SEQUENCE:4
|
||||||
#EXTINF:2,
|
#EXTINF:1.999,
|
||||||
segment00003.ts
|
segment00003.ts
|
||||||
#EXTINF:0.3,
|
#EXTINF:0.333,
|
||||||
segment00004.ts
|
segment00004.ts
|
||||||
#EXT-X-ENDLIST
|
#EXT-X-ENDLIST
|
||||||
"###,
|
"###,
|
||||||
|
@ -488,7 +488,7 @@ fn test_hlssink3_write_correct_playlist_content() -> Result<(), ()> {
|
||||||
#EXT-X-VERSION:3
|
#EXT-X-VERSION:3
|
||||||
#EXT-X-TARGETDURATION:15
|
#EXT-X-TARGETDURATION:15
|
||||||
#EXT-X-MEDIA-SEQUENCE:1
|
#EXT-X-MEDIA-SEQUENCE:1
|
||||||
#EXTINF:1.633,
|
#EXTINF:1.666,
|
||||||
segments/my-own-filename-000.ts
|
segments/my-own-filename-000.ts
|
||||||
#EXT-X-ENDLIST
|
#EXT-X-ENDLIST
|
||||||
"###,
|
"###,
|
||||||
|
|
Loading…
Reference in a new issue