summaryrefslogtreecommitdiff
path: root/ext/smoothstreaming
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2016-11-10 17:20:27 +1100
committerMatthew Waters <matthew@centricular.com>2016-11-11 00:18:47 +1100
commit0fbee8f37427b88339194b22ba9aa210772a8613 (patch)
tree372d20b861181d447f8f2b0ac4cc7198348f4d6a /ext/smoothstreaming
parente9178fa082116d4bf733b184a8b6951112c17900 (diff)
downloadgstreamer-plugins-bad-0fbee8f37427b88339194b22ba9aa210772a8613.tar.gz
smoothstreaming: use the duration from the list of fragments if not present in the manifest
Provides a more accurate duration for live streams that may be minutes or hours in front of the earliest fragment. https://bugzilla.gnome.org/show_bug.cgi?id=774178
Diffstat (limited to 'ext/smoothstreaming')
-rw-r--r--ext/smoothstreaming/gstmssmanifest.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/smoothstreaming/gstmssmanifest.c b/ext/smoothstreaming/gstmssmanifest.c
index 317b3cef9..144bbb42d 100644
--- a/ext/smoothstreaming/gstmssmanifest.c
+++ b/ext/smoothstreaming/gstmssmanifest.c
@@ -888,6 +888,7 @@ gst_mss_manifest_get_duration (GstMssManifest * manifest)
gchar *duration;
guint64 dur = -1;
+ /* try the property */
duration =
(gchar *) xmlGetProp (manifest->xmlrootnode,
(xmlChar *) MSS_PROP_STREAM_DURATION);
@@ -895,6 +896,29 @@ gst_mss_manifest_get_duration (GstMssManifest * manifest)
dur = g_ascii_strtoull (duration, NULL, 10);
xmlFree (duration);
}
+ /* else use the fragment list */
+ if (dur <= 0) {
+ guint64 max_dur = 0;
+ GSList *iter;
+
+ for (iter = manifest->streams; iter; iter = g_slist_next (iter)) {
+ GstMssStream *stream = iter->data;
+
+ if (stream->active) {
+ if (stream->fragments) {
+ GList *l = g_list_last (stream->fragments);
+ GstMssStreamFragment *fragment = (GstMssStreamFragment *) l->data;
+ guint64 frag_dur =
+ fragment->time + fragment->duration * fragment->repetitions;
+ max_dur = MAX (frag_dur, max_dur);
+ }
+ }
+ }
+
+ if (max_dur != 0)
+ dur = max_dur;
+ }
+
return dur;
}