Go to the documentation of this file.
40 #define GST_REPO_LOCK() (g_mutex_lock(&_repo.repo_lock))
41 #define GST_REPO_UNLOCK() (g_mutex_unlock(&_repo.repo_lock))
42 #define GST_REPO_WAIT() (g_cond_wait(&_repo.repo_cond, &_repo.repo_lock))
43 #define GST_REPO_BROADCAST() (g_cond_broadcast (&_repo.repo_cond))
52 g_return_if_fail (_data != NULL);
54 g_mutex_lock (&_data->
lock);
58 gst_buffer_unref (_data->
buffer);
60 gst_caps_unref (_data->
caps);
61 g_mutex_unlock (&_data->
lock);
63 g_mutex_clear (&_data->
lock);
81 p = g_hash_table_lookup (
_repo.
hash, GINT_TO_POINTER (nth));
98 g_mutex_lock (&
data->lock);
104 GST_DEBUG (
"SET sink_changed! @id %d \n", o_nth);
107 g_cond_signal (&
data->cond_pull);
112 GST_DEBUG (
"SET src_changed! @id %d\n", o_nth);
115 g_cond_signal (&
data->cond_push);
118 g_mutex_unlock (&
data->lock);
131 gboolean ret =
FALSE;
137 g_mutex_lock (&
data->lock);
146 g_mutex_unlock (&
data->lock);
149 GST_DEBUG (
"SET SINK & SRC Changed FALSE!! @%d\n", nth);
155 GST_ERROR (
"Failed to allocate memory for repo data.");
159 g_cond_init (&
data->cond_push);
160 g_cond_init (&
data->cond_pull);
161 g_mutex_init (&
data->lock);
163 g_mutex_lock (&
data->lock);
170 g_mutex_unlock (&
data->lock);
173 ret = g_hash_table_insert (
_repo.
hash, GINT_TO_POINTER (nth),
data);
179 GST_DEBUG (
"Successfully added in hash table with key[%d]", nth);
182 ml_logf (
"The key[%d] is duplicated. Cannot proceed.\n", nth);
199 g_return_val_if_fail (
data != NULL,
FALSE);
201 g_mutex_lock (&
data->lock);
203 while (
data->buffer != NULL && !
data->eos) {
205 g_cond_wait (&
data->cond_pull, &
data->lock);
209 g_mutex_unlock (&
data->lock);
213 data->buffer = gst_buffer_copy_deep (buffer);
214 if (!
data->caps || !gst_caps_is_equal (
data->caps, caps)) {
216 gst_caps_unref (
data->caps);
217 data->caps = gst_caps_copy (caps);
221 unsigned long size = gst_buffer_get_size (
data->buffer);
222 GST_DEBUG (
"Pushed [%d] (size : %lu)\n", nth, size);
226 g_cond_signal (&
data->cond_push);
228 g_mutex_unlock (&
data->lock);
244 GST_DEBUG (
"check eos done [%s]\n",
data->eos ?
"TRUE" :
"FALSE");
257 gboolean ret =
FALSE;
262 g_return_val_if_fail (
data != NULL,
FALSE);
265 GST_DEBUG (
"%dth RepoData : sink_changed %d, src_changed %d\n", nth,
266 data->sink_changed,
data->src_changed);
269 if (
data->sink_changed) {
270 *newid =
data->sink_id;
274 if (
data->src_changed) {
275 *newid =
data->src_id;
293 g_return_val_if_fail (
data != NULL,
FALSE);
295 g_mutex_lock (&
data->lock);
298 g_cond_signal (&
data->cond_push);
299 g_cond_signal (&
data->cond_pull);
301 g_mutex_unlock (&
data->lock);
313 GstBuffer *buf = NULL;
317 g_return_val_if_fail (
data != NULL, NULL);
319 g_mutex_lock (&
data->lock);
321 while (!
data->buffer) {
334 g_cond_wait (&
data->cond_push, &
data->lock);
339 *caps = gst_caps_ref (
data->caps);
341 unsigned long size = gst_buffer_get_size (buf);
342 GST_DEBUG (
"Popped [ %d ] (size: %lu)\n", nth, size);
348 g_cond_signal (&
data->cond_pull);
349 g_mutex_unlock (&
data->lock);
359 gboolean ret =
FALSE;
368 ret = g_hash_table_remove (
_repo.
hash, GINT_TO_POINTER (nth));
373 GST_DEBUG (
"key[%d] is removed\n", nth);
395 _repo.
hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
gboolean gst_tensor_repo_set_changed(guint o_nth, guint nth, gboolean is_sink)
Set the changing status of repo.
#define GST_REPO_LOCK()
Macro for Lock & Cond.
GstTensorRepo data structure.
gboolean gst_tensor_repo_remove_repodata(guint nth)
Remove nth GstTensorRepoData from GstTensorRepo.
g_free(self->option[(opnum) - 1])
opnum: \
gboolean gst_tensor_repo_wait(void)
Wait for finish of initialization.
#define GST_REPO_UNLOCK()
gboolean gst_tensor_repo_set_eos(guint nth)
Set EOS (End-of-Stream) of slot.
static void gst_tensor_repo_release_repodata(gpointer data)
Internal function to release repo data.
GstTensorRepo internal data structure.
#define GST_REPO_BROADCAST()
GstTensorRepoData * gst_tensor_repo_get_repodata(guint nth)
Getter to get nth GstTensorRepoData.
static GstTensorRepo _repo
tensor repo global variable with init.
tensor repo header file for NNStreamer, the GStreamer plugin for neural networks
gboolean gst_tensor_repo_set_buffer(guint nth, GstBuffer *buffer, GstCaps *caps)
Push GstBuffer into repo.
gboolean gst_tensor_repo_check_changed(guint nth, guint *newid, gboolean is_sink)
Check repo data is changed.
gboolean gst_tensor_repo_check_eos(guint nth)
Check EOS (End-of-Stream) of slot.
gboolean gst_tensor_repo_add_repodata(guint nth, gboolean is_sink)
Add GstTensorRepoData into repo.
GstBuffer * gst_tensor_repo_get_buffer(guint nth, gboolean *eos, guint *newid, GstCaps **caps)
Get GstTensorRepoData from repo.
GST_ERROR("Failed to register nnstreamer plugin : tensor_" # name)
type)) { \
void gst_tensor_repo_init(void)
GstTensorRepo initialization.