}
/**
+ * @brief Set the changing status of repo.
+ */
+gboolean
+gst_tensor_repo_set_changed (guint o_nth, guint nth, gboolean is_sink)
+{
+ gboolean ret = FALSE;
+ GstTensorRepoData *data;
+ GST_TENSOR_REPO_LOCK (o_nth);
+ data = gst_tensor_repo_get_repodata (o_nth);
+
+ if (data) {
+ if (is_sink) {
+ data->sink_changed = TRUE;
+ data->sink_id = nth;
+ if (DBG)
+ GST_DEBUG ("SET sink_changed! @id %d \n", o_nth);
+ GST_TENSOR_REPO_SIGNAL_PULL (o_nth);
+ } else {
+ data->src_changed = TRUE;
+ data->src_id = nth;
+ if (DBG)
+ GST_DEBUG ("SET src_changed! @id %d\n", o_nth);
+ GST_TENSOR_REPO_SIGNAL_PUSH (o_nth);
+ }
+ ret = TRUE;
+ }
+
+ GST_TENSOR_REPO_UNLOCK (o_nth);
+ return ret;
+}
+
+/**
* @brief add GstTensorRepoData into repo
*/
gboolean
-gst_tensor_repo_add_repodata (guint nth)
+gst_tensor_repo_add_repodata (guint nth, gboolean is_sink)
{
gboolean ret = FALSE;
GstTensorRepoData *new;
gpointer check = g_hash_table_lookup (_repo.hash, GINT_TO_POINTER (nth));
if (check != NULL) {
+ new = (GstTensorRepoData *) check;
+ if (is_sink)
+ new->sink_changed = FALSE;
+ else
+ new->src_changed = FALSE;
+ new->pushed = FALSE;
+ if (DBG)
+ GST_DEBUG ("SET SINK & SRC Changed FALSE!! @%d\n", nth);
GST_REPO_UNLOCK ();
return TRUE;
}
g_cond_init (&new->cond_push);
g_cond_init (&new->cond_pull);
g_mutex_init (&new->lock);
+ new->sink_changed = FALSE;
+ new->src_changed = FALSE;
+ new->pushed = FALSE;
ret = g_hash_table_insert (_repo.hash, GINT_TO_POINTER (nth), new);
g_assert (ret);
* @brief push GstBuffer into repo
*/
gboolean
-gst_tensor_repo_set_buffer (guint nth, GstBuffer * buffer, GstCaps * caps)
+gst_tensor_repo_set_buffer (guint nth, guint o_nth, GstBuffer * buffer,
+ GstCaps * caps)
{
GST_TENSOR_REPO_LOCK (nth);
}
/**
+ * @brief check eos of slot
+ */
+gboolean
+gst_tensor_repo_check_changed (guint nth, guint * newid, gboolean is_sink)
+{
+ gboolean ret = FALSE;
+ GstTensorRepoData *data = gst_tensor_repo_get_repodata (nth);
+ if (DBG)
+ GST_DEBUG ("%dth RepoData : sink_chaned %d, src_changed %d\n", nth,
+ data->sink_changed, data->src_changed);
+
+ if (is_sink) {
+ if (data->sink_changed) {
+ *newid = data->sink_id;
+ ret = data->sink_changed;
+ }
+ } else {
+ if (data->src_changed) {
+ *newid = data->src_id;
+ ret = data->src_changed;
+ }
+ }
+ return ret;
+}
+
+
+/**
* @brief set eos of slot
*/
gboolean
* @brief get GstTensorRepoData from repo
*/
GstBuffer *
-gst_tensor_repo_get_buffer (guint nth)
+gst_tensor_repo_get_buffer (guint nth, guint o_nth, gboolean * eos,
+ guint * newid)
{
GstTensorRepoData *current_data;
GstBuffer *buf;
- gboolean eos = FALSE;
GST_TENSOR_REPO_LOCK (nth);
current_data = gst_tensor_repo_get_repodata (nth);
while (!current_data->buffer) {
+ if (gst_tensor_repo_check_changed (nth, newid, FALSE)) {
+ buf = NULL;
+ goto done;
+ }
+
if (gst_tensor_repo_check_eos (nth)) {
- eos = TRUE;
- break;
+ *eos = TRUE;
+ buf = NULL;
+ goto done;
}
GST_TENSOR_REPO_WAIT_PUSH (nth);
}
- if (eos) {
- if (DBG)
- GST_DEBUG ("Get EOS Signal while waiting\n");
- buf = NULL;
- } else {
- buf = gst_buffer_copy_deep (current_data->buffer);
- if (DBG) {
- unsigned long size = gst_buffer_get_size (buf);
- GST_DEBUG ("Popped [ %d ] (size: %lu)\n", nth, size);
- }
+
+ buf = gst_buffer_copy_deep (current_data->buffer);
+ gst_buffer_unref (current_data->buffer);
+ if (DBG) {
+ unsigned long size = gst_buffer_get_size (buf);
+ GST_DEBUG ("Popped [ %d ] (size: %lu)\n", nth, size);
}
+
+done:
current_data->buffer = NULL;
GST_TENSOR_REPO_SIGNAL_PULL (nth);
GST_TENSOR_REPO_UNLOCK (nth);
GCond cond_pull;
GMutex lock;
gboolean eos;
+ gboolean src_changed;
+ guint src_id;
+ gboolean sink_changed;
+ guint sink_id;
+ gboolean pushed;
} GstTensorRepoData;
/**
*/
/* guint */
gboolean
-gst_tensor_repo_add_repodata (guint myid);
+gst_tensor_repo_add_repodata (guint myid, gboolean is_sink);
/**
* @brief push GstBuffer into repo
*/
gboolean
-gst_tensor_repo_set_buffer (guint nth, GstBuffer * buffer, GstCaps * caps);
+gst_tensor_repo_set_buffer (guint nth, guint o_nth, GstBuffer * buffer, GstCaps * caps);
/**
* @brief get EOS
gboolean
gst_tensor_repo_set_eos(guint nth);
+gboolean
+gst_tensor_repo_set_changed(guint o_nth, guint nth, gboolean is_sink);
+
/**
* @brief Get GstTensorRepoData from repo
*/
GstBuffer *
-gst_tensor_repo_get_buffer (guint nth);
+gst_tensor_repo_get_buffer (guint nth, guint o_nth, gboolean *eos, guint *newid);
+
+gboolean
+gst_tensor_repo_check_changed (guint nth, guint *newid, gboolean is_sink);
/**
* @brief remove nth GstTensorRepoData from GstTensorRepo
self->silent = DEFAULT_SILENT;
self->signal_rate = DEFAULT_SIGNAL_RATE;
self->last_render_time = GST_CLOCK_TIME_NONE;
+ self->set_startid = FALSE;
self->in_caps = NULL;
gst_base_sink_set_qos_enabled (basesink, DEFAULT_QOS);
self->silent = g_value_get_boolean (value);
break;
case PROP_SLOT:
+ self->o_myid = self->myid;
self->myid = g_value_get_uint (value);
- gst_tensor_repo_add_repodata (self->myid);
+ gst_tensor_repo_add_repodata (self->myid, TRUE);
+ if (!self->set_startid) {
+ self->o_myid = self->myid;
+ self->set_startid = TRUE;
+ }
+ if (self->o_myid != self->myid)
+ gst_tensor_repo_set_changed (self->o_myid, self->myid, TRUE);
+
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
if (notify) {
gboolean ret = FALSE;
self->last_render_time = now;
- ret = gst_tensor_repo_set_buffer (self->myid, buffer, self->in_caps);
+ ret =
+ gst_tensor_repo_set_buffer (self->myid, self->o_myid, buffer,
+ self->in_caps);
if (!ret)
GST_ELEMENT_ERROR (self, RESOURCE, WRITE,
("Cannot Set buffer into repo [key: %d]", self->myid), NULL);
guint signal_rate;
GstClockTime last_render_time;
GstCaps *in_caps;
+ gboolean set_startid;
guint myid;
+ guint o_myid;
};
/**
self->negotiation = FALSE;
gst_tensors_config_init (&self->config);
self->caps = NULL;
+ self->set_startid = FALSE;
}
/**
self->silent = g_value_get_boolean (value);
break;
case PROP_SLOT_ID:
+ self->o_myid = self->myid;
self->myid = g_value_get_uint (value);
self->negotiation = FALSE;
+
+ gst_tensor_repo_add_repodata (self->myid, FALSE);
+
+ if (!self->set_startid) {
+ self->o_myid = self->myid;
+ self->set_startid = TRUE;
+ }
+ if (self->o_myid != self->myid)
+ gst_tensor_repo_set_changed (self->o_myid, self->myid, FALSE);
+
break;
case PROP_CAPS:
{
}
/**
+ * @brief create dummy buffer for initialization
+ */
+static GstBuffer *
+gst_tensor_reposrc_gen_dummy_buffer (GstTensorRepoSrc * self)
+{
+ GstBuffer *buf = NULL;
+ int i;
+ guint num_tensors = self->config.info.num_tensors;
+ gsize size = 0;
+ buf = gst_buffer_new ();
+ for (i = 0; i < num_tensors; i++) {
+ GstMemory *mem;
+ GstMapInfo info;
+ size = gst_tensor_info_get_size (&self->config.info.info[i]);
+ mem = gst_allocator_alloc (NULL, size, NULL);
+ gst_memory_map (mem, &info, GST_MAP_WRITE);
+ memset (info.data, 0, size);
+ gst_memory_unmap (mem, &info);
+ gst_buffer_append_memory (buf, mem);
+ }
+ return buf;
+}
+
+/**
* @brief create func of tensor_reposrc
*/
static GstFlowReturn
{
GstTensorRepoSrc *self;
GstBuffer *buf = NULL;
+ gboolean eos = FALSE;
+ GstMetaRepo *meta;
+ guint newid;
self = GST_TENSOR_REPOSRC (src);
gst_tensor_repo_wait ();
if (!self->ini) {
- int i;
- guint num_tensors = self->config.info.num_tensors;
- gsize size = 0;
- buf = gst_buffer_new ();
- for (i = 0; i < num_tensors; i++) {
- GstMemory *mem;
- GstMapInfo info;
- size = gst_tensor_info_get_size (&self->config.info.info[i]);
- mem = gst_allocator_alloc (NULL, size, NULL);
- gst_memory_map (mem, &info, GST_MAP_WRITE);
- memset (info.data, 0, size);
- gst_memory_unmap (mem, &info);
- gst_buffer_append_memory (buf, mem);
- }
+ buf = gst_tensor_reposrc_gen_dummy_buffer (self);
self->ini = TRUE;
} else {
- buf = gst_tensor_repo_get_buffer (self->myid);
-
- if (buf == NULL)
+ while (!buf && !eos) {
+ buf = gst_tensor_repo_get_buffer (self->myid, self->o_myid, &eos, &newid);
+ }
+ if (eos)
return GST_FLOW_EOS;
- GstMetaRepo *meta = GST_META_REPO_GET (buf);
+ meta = GST_META_REPO_GET (buf);
- if (!self->negotiation) {
+ if (!self->negotiation && buf != NULL) {
if (!gst_caps_can_intersect (self->caps, meta->caps)) {
GST_ELEMENT_ERROR (GST_ELEMENT (self), CORE, NEGOTIATION,
("Negotiation Failed! : repo_sink & repos_src"), (NULL));
}
self->negotiation = TRUE;
- }
+ }
gst_buffer_remove_meta (buf, (GstMeta *) meta);
}
GstTensorsConfig config;
gboolean silent;
guint myid;
+ guint o_myid;
GstCaps *caps;
gboolean ini;
gint fps_n, fps_d;
gboolean negotiation;
+ gboolean set_startid;
};
/**