hlsdemux: add property about live info 06/258306/1 accepted/tizen/unified/20210602.122622 submit/tizen/20210531.015432
authorEunhye Choi <eunhae1.choi@samsung.com>
Wed, 12 May 2021 11:26:51 +0000 (20:26 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Thu, 13 May 2021 08:20:21 +0000 (17:20 +0900)
- add readable property about live info
  : is live, live start time, live end time

Change-Id: I0be1bfec4527cad2db6910e8e0cae5a6fa2eb498

ext/hls/gsthlsdemux.c
packaging/gst-plugins-bad.spec

index 615886c..5ad6a7e 100644 (file)
@@ -62,8 +62,24 @@ GST_DEBUG_CATEGORY (gst_hls_demux_debug);
 #define GST_M3U8_CLIENT_LOCK(l) /* FIXME */
 #define GST_M3U8_CLIENT_UNLOCK(l)       /* FIXME */
 
+#ifdef TIZEN_FEATURE_HLSDEMUX_PROPERTY
+enum
+{
+  PROP_0,
+  PROP_IS_LIVE,
+  PROP_LIVE_START_TIME,
+  PROP_LIVE_END_TIME,
+  PROP_LAST
+};
+#endif
+
 /* GObject */
 static void gst_hls_demux_finalize (GObject * obj);
+#ifdef TIZEN_FEATURE_HLSDEMUX_PROPERTY
+static void
+gst_hls_demux_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec);
+#endif
 
 /* GstElement */
 static GstStateChangeReturn
@@ -147,8 +163,27 @@ gst_hls_demux_class_init (GstHLSDemuxClass * klass)
   element_class = (GstElementClass *) klass;
   adaptivedemux_class = (GstAdaptiveDemuxClass *) klass;
 
+#ifdef TIZEN_FEATURE_HLSDEMUX_PROPERTY
+  gobject_class->get_property = gst_hls_demux_get_property;
+#endif
   gobject_class->finalize = gst_hls_demux_finalize;
 
+#ifdef TIZEN_FEATURE_HLSDEMUX_PROPERTY
+  g_object_class_install_property (gobject_class, PROP_IS_LIVE,
+      g_param_spec_boolean ("is-live", "is-live", "Whether the source is live",
+          FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (gobject_class, PROP_LIVE_START_TIME,
+      g_param_spec_uint64 ("live-start-time", "start time of the first fragment",
+          "start time of the first fragment in the current media playlist in case of live", 0, G_MAXUINT64,
+          0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (gobject_class, PROP_LIVE_END_TIME,
+      g_param_spec_uint64 ("live-end-time", "end time of the last fragment",
+          "end time of the last fragment in the current media playlist in case of live", 0, G_MAXUINT64,
+          0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+#endif
+
   element_class->change_state = GST_DEBUG_FUNCPTR (gst_hls_demux_change_state);
 
   gst_element_class_add_static_pad_template (element_class, &srctemplate);
@@ -197,6 +232,44 @@ gst_hls_demux_init (GstHLSDemux * demux)
   g_mutex_init (&demux->keys_lock);
 }
 
+#ifdef TIZEN_FEATURE_HLSDEMUX_PROPERTY
+static void
+gst_hls_demux_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GstAdaptiveDemux *adaptivedemux = GST_ADAPTIVE_DEMUX (object);
+  GstHLSDemux *demux = GST_HLS_DEMUX (adaptivedemux);
+  GstHLSVariantStream *variant = demux->current_variant;
+  gboolean is_live = FALSE;
+
+  if (variant)
+    is_live = gst_hls_variant_stream_is_live (variant);
+
+  switch (prop_id) {
+    case PROP_IS_LIVE:
+      g_value_set_boolean (value, is_live);
+      break;
+    case PROP_LIVE_START_TIME:{
+      GstClockTime start_time = 0;
+      if (is_live)
+        start_time = variant->m3u8->first_file_start;
+      g_value_set_uint64 (value, start_time);
+      break;
+    }
+    case PROP_LIVE_END_TIME:{
+      GstClockTime end_time = 0;
+      if (is_live)
+        end_time = variant->m3u8->last_file_end;
+      g_value_set_uint64 (value, end_time);
+      break;
+    }
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+#endif
+
 static GstStateChangeReturn
 gst_hls_demux_change_state (GstElement * element, GstStateChange transition)
 {
index bfc7c7f..035ff02 100644 (file)
@@ -4,7 +4,7 @@
 
 Name:           gst-plugins-bad
 Version:        1.16.2
-Release:        12
+Release:        13
 Summary:        GStreamer Streaming-Media Framework Plug-Ins
 License:        LGPL-2.0+
 Group:          Multimedia/Framework
@@ -80,6 +80,7 @@ export V=1
 NOCONFIGURE=1 ./autogen.sh
 export CFLAGS+=" -Wall -g -fPIC\
   -DTIZEN_FEATURE_ADAPTIVE_MODIFICATION\
+  -DTIZEN_FEATURE_HLSDEMUX_PROPERTY\
   -DTIZEN_FEATURE_TSDEMUX_MODIFICATION\
   -DTIZEN_FEATURE_OALSINK_MODIFICATION\
   -DTIZEN_FEATURE_MPEGDEMUX_MODIFICATION\