From 722ef4219646aab5d9cb2c1c4163ab3d736a0bdd Mon Sep 17 00:00:00 2001
From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= <slomo@circular-chaos.org>
Date: Mon, 29 Jul 2013 10:53:54 +0200
Subject: [PATCH] matroskademux: Implement SEGMENT query

---
 gst/matroska/matroska-demux.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
index 22d542700f..dc5c6cbc2c 100644
--- a/gst/matroska/matroska-demux.c
+++ b/gst/matroska/matroska-demux.c
@@ -1505,6 +1505,34 @@ gst_matroska_demux_query (GstMatroskaDemux * demux, GstPad * pad,
       GST_OBJECT_UNLOCK (demux);
       break;
     }
+    case GST_QUERY_SEGMENT:
+    {
+      GstFormat format;
+      gint64 start, stop;
+
+      format = demux->common.segment.format;
+
+      start =
+          gst_segment_to_stream_time (&demux->common.segment, format,
+          demux->common.segment.start);
+      if ((stop = demux->common.segment.stop) == -1)
+        stop = demux->common.segment.duration;
+      else
+        stop =
+            gst_segment_to_stream_time (&demux->common.segment, format, stop);
+
+      if (demux->common.segment.rate < 0.0) {
+        gint64 tmp;
+        tmp = stop;
+        stop = start;
+        start = tmp;
+      }
+
+      gst_query_set_segment (query, demux->common.segment.rate, format, start,
+          stop);
+      res = TRUE;
+      break;
+    }
     default:
       if (pad)
         res = gst_pad_query_default (pad, (GstObject *) demux, query);
-- 
2.34.1