Merge branch 'upstream/1.16' into tizen_gst_1.16.2
[platform/upstream/gstreamer.git] / libs / gst / base / gstbasesrc.c
index e7e3815..aa9a459 100644 (file)
@@ -189,6 +189,9 @@ enum
 #define DEFAULT_BLOCKSIZE       4096
 #define DEFAULT_NUM_BUFFERS     -1
 #define DEFAULT_DO_TIMESTAMP    FALSE
+#ifdef TIZEN_PROFILE_TV
+#define DEFAULT_SEGMENT_TIME   -1
+#endif
 
 enum
 {
@@ -199,6 +202,9 @@ enum
   PROP_TYPEFIND,
 #endif
   PROP_DO_TIMESTAMP
+#ifdef TIZEN_PROFILE_TV
+  ,PROP_UPDATE_SEGMENT
+#endif
 };
 
 /* The basesrc implementation need to respect the following locking order:
@@ -403,6 +409,13 @@ gst_base_src_class_init (GstBaseSrcClass * klass)
       g_param_spec_boolean ("do-timestamp", "Do timestamp",
           "Apply current stream time to buffers", DEFAULT_DO_TIMESTAMP,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#ifdef TIZEN_PROFILE_TV
+  g_object_class_install_property (gobject_class, PROP_UPDATE_SEGMENT,
+      g_param_spec_int64 ("update-segment", "Update Segment",
+          "Timestamp that application want to set (-1 unlimited)",
+         -1, G_MAXINT64, DEFAULT_SEGMENT_TIME,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#endif
 
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_base_src_change_state);
@@ -826,6 +839,31 @@ gst_base_src_set_do_timestamp (GstBaseSrc * src, gboolean timestamp)
   GST_OBJECT_UNLOCK (src);
 }
 
+#ifdef TIZEN_PROFILE_TV
+/**
+*gst_base_src_update_segment:
+*@src: the source
+*@timestamp: timestamp to set
+*/
+void
+gst_base_src_update_segment (GstBaseSrc * src, gint64 timestamp)
+{
+  g_return_if_fail (GST_IS_BASE_SRC (src));
+
+  GST_OBJECT_LOCK (src);
+  if (timestamp != -1) {
+    GST_DEBUG_OBJECT (src,
+        "udpate the segment parameter for es player resume playback,%lld",
+        timestamp);
+    src->segment.start = timestamp;
+    src->segment.time = timestamp;
+    src->segment.position = timestamp;
+  }
+  GST_OBJECT_UNLOCK (src);
+  GST_DEBUG_OBJECT (src, "udpate the segment end");
+}
+#endif
+
 /**
  * gst_base_src_get_do_timestamp:
  * @src: the source
@@ -2139,6 +2177,11 @@ gst_base_src_set_property (GObject * object, guint prop_id,
     case PROP_DO_TIMESTAMP:
       gst_base_src_set_do_timestamp (src, g_value_get_boolean (value));
       break;
+#ifdef TIZEN_PROFILE_TV
+    case PROP_UPDATE_SEGMENT:
+      gst_base_src_update_segment (src, g_value_get_int64 (value));
+      break;
+#endif
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -2546,8 +2589,20 @@ again:
    * discard when the create function returned _OK. */
   if (G_UNLIKELY (g_atomic_int_get (&src->priv->has_pending_eos))) {
     if (ret == GST_FLOW_OK) {
+#ifdef TIZEN_FEATURE_TRUSTZONE
+      if (own_res_buf) {
+        /*tzappsrc patch : release handle when unref res_buf*/
+        if(bclass->tz_src_release_handle)
+        {
+          GST_INFO_OBJECT (src, "tzappsrc release the handle");
+          bclass->tz_src_release_handle(src,res_buf);
+        }
+        gst_buffer_unref (res_buf);
+      }
+#else
       if (own_res_buf)
         gst_buffer_unref (res_buf);
+#endif
     }
     src->priv->forced_eos = TRUE;
     goto eos;
@@ -2615,9 +2670,23 @@ again:
       /* this case is triggered when we were waiting for the clock and
        * it got unlocked because we did a state change. In any case, get rid of
        * the buffer. */
+#ifdef TIZEN_FEATURE_TRUSTZONE
+      if (own_res_buf) {
+
+        /*tzappsrc patch : release handle when unref res_buf*/
+        GstBaseSrcClass *klass = GST_BASE_SRC_GET_CLASS(src);
+        if(klass->tz_src_release_handle)
+        {
+          GST_INFO_OBJECT (src, "tzappsrc release the handle");
+          klass->tz_src_release_handle(src,res_buf);
+        }
+
+        gst_buffer_unref (res_buf);
+      }
+#else
       if (own_res_buf)
         gst_buffer_unref (res_buf);
-
+#endif
       if (!src->live_running) {
         /* We return FLUSHING when we are not running to stop the dataflow also
          * get rid of the produced buffer. */
@@ -2637,8 +2706,21 @@ again:
       GST_ELEMENT_ERROR (src, CORE, CLOCK,
           (_("Internal clock error.")),
           ("clock returned unexpected return value %d", status));
+#ifdef TIZEN_FEATURE_TRUSTZONE
+      if (own_res_buf) {
+        /*tzappsrc patch : release handle when unref res_buf*/
+        GstBaseSrcClass *klass = GST_BASE_SRC_GET_CLASS(src);
+        if(klass->tz_src_release_handle)
+        {
+          GST_INFO_OBJECT (src, "tzappsrc release the handle");
+          klass->tz_src_release_handle(src,res_buf);
+        }
+        gst_buffer_unref (res_buf);
+      }
+#else
       if (own_res_buf)
         gst_buffer_unref (res_buf);
+#endif
       ret = GST_FLOW_ERROR;
       break;
   }
@@ -2665,8 +2747,21 @@ map_failed:
     GST_ELEMENT_ERROR (src, RESOURCE, BUSY,
         (_("Failed to map buffer.")),
         ("failed to map result buffer in WRITE mode"));
+#ifdef TIZEN_FEATURE_TRUSTZONE
+    if (own_res_buf) {
+      /*tzappsrc patch : release handle when unref res_buf*/
+      GstBaseSrcClass *klass = GST_BASE_SRC_GET_CLASS(src);
+      if(klass->tz_src_release_handle)
+      {
+        GST_INFO_OBJECT (src, "tzappsrc release the handle");
+        klass->tz_src_release_handle(src,res_buf);
+      }
+      gst_buffer_unref (res_buf);
+    }
+#else
     if (own_res_buf)
       gst_buffer_unref (res_buf);
+#endif
     return GST_FLOW_ERROR;
   }
 not_started:
@@ -2693,8 +2788,21 @@ reached_num_buffers:
 flushing:
   {
     GST_DEBUG_OBJECT (src, "we are flushing");
+#ifdef TIZEN_FEATURE_TRUSTZONE
+    if (own_res_buf) {
+      /*tzappsrc patch : release handle when unref res_buf*/
+      GstBaseSrcClass *klass = GST_BASE_SRC_GET_CLASS(src);
+      if(klass->tz_src_release_handle)
+      {
+        GST_INFO_OBJECT (src, "tzappsrc release the handle");
+        klass->tz_src_release_handle(src,res_buf);
+      }
+      gst_buffer_unref (res_buf);
+    }
+#else
     if (own_res_buf)
       gst_buffer_unref (res_buf);
+#endif
     return GST_FLOW_FLUSHING;
   }
 eos:
@@ -2975,6 +3083,14 @@ gst_base_src_loop (GstPad * pad)
   }
 
   if (G_UNLIKELY (ret != GST_FLOW_OK)) {
+#ifdef TIZEN_FEATURE_TRUSTZONE
+    /*tzappsrc patch : release handle when unref res_buf*/
+    GstBaseSrcClass *klass = GST_BASE_SRC_GET_CLASS (src);
+    if (klass->tz_src_release_handle) {
+      GST_INFO_OBJECT (src, "tzappsrc release the handle");
+      klass->tz_src_release_handle (src,buf);
+    }
+#endif
     if (ret == GST_FLOW_NOT_NEGOTIATED) {
       goto not_negotiated;
     }