From ef84f294c01bcc0b0fc88a872937806154e0283a Mon Sep 17 00:00:00 2001
From: Florin Apostol <florin.apostol@oregan.net>
Date: Thu, 19 Nov 2015 15:59:56 +0000
Subject: [PATCH] mpdparser: remove unused functions
 gst_mpdparser_get_chunk_by_index and gst_mpdparser_find_segment_by_index

https://bugzilla.gnome.org/show_bug.cgi?id=758233
---
 ext/dash/gstmpdparser.c         | 80 ---------------------------------
 ext/dash/gstmpdparser.h         |  1 -
 tests/check/elements/dash_mpd.c |  6 ---
 3 files changed, 87 deletions(-)

diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c
index 7642cebfb7..2aec32b49d 100644
--- a/ext/dash/gstmpdparser.c
+++ b/ext/dash/gstmpdparser.c
@@ -3790,86 +3790,6 @@ gst_mpdparser_get_segment_end_time (GstMpdClient * client, GPtrArray * segments,
   return end;
 }
 
-static gboolean
-gst_mpdparser_find_segment_by_index (GstMpdClient * client,
-    GPtrArray * segments, gint index, GstMediaSegment * result)
-{
-  gint i;
-  for (i = 0; i < segments->len; i++) {
-    GstMediaSegment *s;
-    gint repeat;
-
-    s = g_ptr_array_index (segments, i);
-    if (s->repeat >= 0) {
-      repeat = s->repeat;
-    } else {
-      GstClockTime start = s->start;
-      GstClockTime end =
-          gst_mpdparser_get_segment_end_time (client, segments, s, i);
-      repeat = (guint) (end - start) / s->duration;
-    }
-    if (s->number + repeat >= index) {
-      /* it is in this segment */
-      result->SegmentURL = s->SegmentURL;
-      result->number = index;
-      result->scale_start =
-          s->scale_start + (index - s->number) * s->scale_duration;
-      result->scale_duration = s->scale_duration;
-      result->start = s->start + (index - s->number) * s->duration;
-      result->duration = s->duration;
-      return TRUE;
-    }
-  }
-
-  return FALSE;
-}
-
-gboolean
-gst_mpdparser_get_chunk_by_index (GstMpdClient * client, guint indexStream,
-    guint indexChunk, GstMediaSegment * segment)
-{
-  GstActiveStream *stream;
-
-  /* select stream */
-  g_return_val_if_fail (client != NULL, FALSE);
-  g_return_val_if_fail (client->active_streams != NULL, FALSE);
-  stream = g_list_nth_data (client->active_streams, indexStream);
-  g_return_val_if_fail (stream != NULL, FALSE);
-
-  indexChunk += 1;
-
-  if (stream->segments) {
-    return gst_mpdparser_find_segment_by_index (client, stream->segments,
-        indexChunk, segment);
-  } else {
-    GstClockTime duration;
-    GstStreamPeriod *stream_period;
-    guint64 scale_dur;
-
-    g_return_val_if_fail (stream->cur_seg_template->MultSegBaseType->
-        SegmentTimeline == NULL, FALSE);
-    /* segment template generator */
-    duration = gst_mpd_client_get_segment_duration (client, stream, &scale_dur);
-    if (!GST_CLOCK_TIME_IS_VALID (duration))
-      return FALSE;
-
-    stream_period = gst_mpdparser_get_stream_period (client);
-
-    segment->number = indexChunk
-        + stream->cur_seg_template->MultSegBaseType->startNumber;
-    segment->scale_start = indexChunk * scale_dur;
-    segment->scale_duration = scale_dur;
-    segment->start = duration * indexChunk;
-    segment->duration = duration;
-    segment->SegmentURL = NULL;
-
-    if (segment->start >= stream_period->duration) {
-      return FALSE;
-    }
-  }
-  return TRUE;
-}
-
 static gboolean
 gst_mpd_client_add_media_segment (GstActiveStream * stream,
     GstSegmentURLNode * url_node, guint number, gint repeat,
diff --git a/ext/dash/gstmpdparser.h b/ext/dash/gstmpdparser.h
index 13b9b61aa4..533492bcdd 100644
--- a/ext/dash/gstmpdparser.h
+++ b/ext/dash/gstmpdparser.h
@@ -566,7 +566,6 @@ gint gst_mpdparser_get_rep_idx_with_min_bandwidth (GList * Representations);
 
 /* URL management */
 const gchar *gst_mpdparser_get_baseURL (GstMpdClient *client, guint indexStream);
-gboolean gst_mpdparser_get_chunk_by_index (GstMpdClient *client, guint indexStream, guint indexChunk, GstMediaSegment * segment);
 
 /* Active stream */
 guint gst_mpdparser_get_nb_active_stream (GstMpdClient *client);
diff --git a/tests/check/elements/dash_mpd.c b/tests/check/elements/dash_mpd.c
index 76bf9d2ee2..24212d2be9 100644
--- a/tests/check/elements/dash_mpd.c
+++ b/tests/check/elements/dash_mpd.c
@@ -3839,7 +3839,6 @@ GST_START_TEST (dash_mpdparser_segments)
   gboolean hasNextSegment;
   GstActiveStream *activeStream;
   GstFlowReturn flow;
-  GstMediaSegment segment;
   GstDateTime *segmentEndTime;
   GstDateTime *gst_time;
   GDateTime *g_time;
@@ -3932,11 +3931,6 @@ GST_START_TEST (dash_mpdparser_segments)
       gst_mpd_client_has_next_segment (mpdclient, activeStream, TRUE);
   assert_equals_int (hasNextSegment, 0);
 
-  /* get chunk 0. segment_index will not change */
-  ret = gst_mpdparser_get_chunk_by_index (mpdclient, 0, 0, &segment);
-  assert_equals_int (ret, 1);
-  assert_equals_int (segment.number, 1);
-
   /* segment index is still 1 */
   hasNextSegment =
       gst_mpd_client_has_next_segment (mpdclient, activeStream, TRUE);