]> code.ossystems Code Review - openembedded-core.git/blob
4e51040863dd695c875409768b6119f9b4be4a0a
[openembedded-core.git] /
1 From 0fbee8f37427b88339194b22ba9aa210772a8613 Mon Sep 17 00:00:00 2001
2 From: Matthew Waters <matthew@centricular.com>
3 Date: Thu, 10 Nov 2016 17:20:27 +1100
4 Subject: [PATCH] smoothstreaming: use the duration from the list of fragments
5  if not present in the manifest
6
7 Provides a more accurate duration for live streams that may be minutes
8 or hours in front of the earliest fragment.
9
10 https://bugzilla.gnome.org/show_bug.cgi?id=774178
11 ---
12 Upstream-Status: Backport
13 Signed-off-by: Khem Raj <raj.khem@gmail.com>
14
15  ext/smoothstreaming/gstmssmanifest.c | 24 ++++++++++++++++++++++++
16  1 file changed, 24 insertions(+)
17
18 diff --git a/ext/smoothstreaming/gstmssmanifest.c b/ext/smoothstreaming/gstmssmanifest.c
19 index 317b3cef9..144bbb42d 100644
20 --- a/ext/smoothstreaming/gstmssmanifest.c
21 +++ b/ext/smoothstreaming/gstmssmanifest.c
22 @@ -888,6 +888,7 @@ gst_mss_manifest_get_duration (GstMssManifest * manifest)
23    gchar *duration;
24    guint64 dur = -1;
25  
26 +  /* try the property */
27    duration =
28        (gchar *) xmlGetProp (manifest->xmlrootnode,
29        (xmlChar *) MSS_PROP_STREAM_DURATION);
30 @@ -895,6 +896,29 @@ gst_mss_manifest_get_duration (GstMssManifest * manifest)
31      dur = g_ascii_strtoull (duration, NULL, 10);
32      xmlFree (duration);
33    }
34 +  /* else use the fragment list */
35 +  if (dur <= 0) {
36 +    guint64 max_dur = 0;
37 +    GSList *iter;
38 +
39 +    for (iter = manifest->streams; iter; iter = g_slist_next (iter)) {
40 +      GstMssStream *stream = iter->data;
41 +
42 +      if (stream->active) {
43 +        if (stream->fragments) {
44 +          GList *l = g_list_last (stream->fragments);
45 +          GstMssStreamFragment *fragment = (GstMssStreamFragment *) l->data;
46 +          guint64 frag_dur =
47 +              fragment->time + fragment->duration * fragment->repetitions;
48 +          max_dur = MAX (frag_dur, max_dur);
49 +        }
50 +      }
51 +    }
52 +
53 +    if (max_dur != 0)
54 +      dur = max_dur;
55 +  }
56 +
57    return dur;
58  }
59  
60 -- 
61 2.11.0
62