[GStreamer] Bump internal jhbuild versions to 1.8.0 and patches to support MSE
[WebKit-https.git] / Tools / gtk / patches / gst-plugins-good-use-the-tfdt-decode-time.patch
1 From 46d3e0faa922643094a5e46a32e4f82f774ae772 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Enrique=20Oca=C3=B1a=20Gonz=C3=A1lez?= <eocanha@igalia.com>
3 Date: Tue, 10 Nov 2015 13:09:00 +0100
4 Subject: [PATCH] Use the tfdt decode time when it's significantly different
5  than the time in the last sample if always-honor-tfdt is enabled
6
7 https://bugzilla.gnome.org/show_bug.cgi?id=754230
8 ---
9  gst/isomp4/qtdemux.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
10  gst/isomp4/qtdemux.h |  1 +
11  2 files changed, 73 insertions(+)
12
13 diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c
14 index 880595e..d8b54f0 100644
15 --- a/gst/isomp4/qtdemux.c
16 +++ b/gst/isomp4/qtdemux.c
17 @@ -535,6 +535,11 @@ static void gst_qtdemux_append_protection_system_id (GstQTDemux * qtdemux,
18      const gchar * id);
19  static void qtdemux_gst_structure_free (GstStructure * gststructure);
20  
21 +static void gst_qtdemux_set_property (GObject * object, guint prop_id,
22 +    const GValue * value, GParamSpec * spec);
23 +static void gst_qtdemux_get_property (GObject * object, guint prop_id,
24 +    GValue * value, GParamSpec * spec);
25 +
26  static void
27  gst_qtdemux_class_init (GstQTDemuxClass * klass)
28  {
29 @@ -546,8 +551,21 @@ gst_qtdemux_class_init (GstQTDemuxClass * klass)
30  
31    parent_class = g_type_class_peek_parent (klass);
32  
33 +  gobject_class->set_property = gst_qtdemux_set_property;
34 +  gobject_class->get_property = gst_qtdemux_get_property;
35 +
36    gobject_class->dispose = gst_qtdemux_dispose;
37  
38 + /**
39 +   * GstQtDemux::always-honor-tfdt:
40 +   *
41 +   * Requests the demuxer to respect what the TFDT atom says in order to produce presentation timestamps. Defaults to FALSE.
42 +   */
43 +  g_object_class_install_property (gobject_class, PROP_ALWAYS_HONOR_TFDT,
44 +      g_param_spec_boolean ("always-honor-tfdt", "Always honor TFDT",
45 +          "When enabled, TFDT atom will always be respected in order to produce presentation timestamps",
46 +          FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
47 +
48    gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_qtdemux_change_state);
49  #if 0
50    gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_qtdemux_set_index);
51 @@ -611,6 +629,7 @@ gst_qtdemux_init (GstQTDemux * qtdemux)
52    qtdemux->cenc_aux_info_sizes = NULL;
53    qtdemux->cenc_aux_sample_count = 0;
54    qtdemux->protection_system_ids = NULL;
55 +  qtdemux->always_honor_tfdt = FALSE;
56    g_queue_init (&qtdemux->protection_event_queue);
57    gst_segment_init (&qtdemux->segment, GST_FORMAT_TIME);
58    qtdemux->flowcombiner = gst_flow_combiner_new ();
59 @@ -639,6 +658,42 @@ gst_qtdemux_dispose (GObject * object)
60  }
61  
62  static void
63 +gst_qtdemux_set_property (GObject * object, guint prop_id,
64 +    const GValue * value, GParamSpec * pspec)
65 +{
66 +  GstQTDemux *qtdemux = GST_QTDEMUX (object);
67 +
68 +  switch (prop_id) {
69 +    case PROP_ALWAYS_HONOR_TFDT:
70 +      GST_OBJECT_LOCK (qtdemux);
71 +      qtdemux->always_honor_tfdt = g_value_get_boolean (value);
72 +      GST_OBJECT_UNLOCK (qtdemux);
73 +      break;
74 +    default:
75 +      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
76 +      break;
77 +  }
78 +}
79 +
80 +static void
81 +gst_qtdemux_get_property (GObject * object, guint prop_id, GValue * value,
82 +    GParamSpec * pspec)
83 +{
84 +  GstQTDemux *qtdemux = GST_QTDEMUX (object);
85 +
86 +  switch (prop_id) {
87 +    case PROP_ALWAYS_HONOR_TFDT:
88 +      GST_OBJECT_LOCK (qtdemux);
89 +      g_value_set_boolean (value, qtdemux->always_honor_tfdt);
90 +      GST_OBJECT_UNLOCK (qtdemux);
91 +      break;
92 +    default:
93 +      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
94 +      break;
95 +  }
96 +}
97 +
98 +static void
99  gst_qtdemux_post_no_playable_stream_error (GstQTDemux * qtdemux)
100  {
101    if (qtdemux->posted_redirect) {
102 @@ -2995,6 +3050,16 @@ qtdemux_parse_trun (GstQTDemux * qtdemux, GstByteReader * trun,
103            stream->samples[stream->n_samples - 1].timestamp +
104            stream->samples[stream->n_samples - 1].duration;
105  
106 +      /* If we're always honoring TFDT and there's a significative difference
107 +       * between the decode_ts and the timestamp, prefer decode_ts */
108 +      if (qtdemux->always_honor_tfdt == TRUE
109 +          && abs (decode_ts - timestamp) >
110 +          stream->samples[stream->n_samples - 1].duration) {
111 +        GST_INFO_OBJECT (qtdemux,
112 +            "decode_ts is significantly different from timestamp, using decode_ts");
113 +        timestamp = decode_ts;
114 +      }
115 +
116        gst_ts = QTSTREAMTIME_TO_GSTTIME (stream, timestamp);
117        GST_INFO_OBJECT (qtdemux, "first sample ts %" GST_TIME_FORMAT
118            " (extends previous samples)", GST_TIME_ARGS (gst_ts));
119 diff --git a/gst/isomp4/qtdemux.h b/gst/isomp4/qtdemux.h
120 index 53bd071..ecf0c63 100644
121 --- a/gst/isomp4/qtdemux.h
122 +++ b/gst/isomp4/qtdemux.h
123 @@ -154,12 +154,20 @@ struct _GstQTDemux {
124    guint8 *cenc_aux_info_sizes;
125    guint32 cenc_aux_sample_count;
126  
127 +  gboolean always_honor_tfdt;
128  };
129  
130  struct _GstQTDemuxClass {
131    GstElementClass parent_class;
132  };
133  
134 +/* props */
135 +enum
136 +{
137 +  PROP_0,
138 +  PROP_ALWAYS_HONOR_TFDT
139 +};
140 +
141  GType gst_qtdemux_get_type (void);
142  
143  G_END_DECLS
144 -- 
145 2.6.1
146