115 lines
4.9 KiB
C
115 lines
4.9 KiB
C
/* GStreamer
|
|
* Copyright (C) 2023 <[email protected]>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef __GST_AML_ADAPTER_PIPE_H__
|
|
#define __GST_AML_ADAPTER_PIPE_H__
|
|
|
|
#include "gstamldmx.h"
|
|
#include <gst/base/gstadapter.h>
|
|
#include <gst/base/gstqueuearray.h>
|
|
|
|
/* pipe protocol helpers */
|
|
#define GST_ADAPTER_PIPE_MUTEX_LOCK(m) \
|
|
G_STMT_START \
|
|
{ \
|
|
GST_TRACE("locking tlock from thread %p", g_thread_self()); \
|
|
g_mutex_lock(&m->tlock); \
|
|
GST_TRACE("locked tlock from thread %p", g_thread_self()); \
|
|
} \
|
|
G_STMT_END
|
|
|
|
#define GST_ADAPTER_PIPE_MUTEX_UNLOCK(m) \
|
|
G_STMT_START \
|
|
{ \
|
|
GST_TRACE("unlocking tlock from thread %p", g_thread_self()); \
|
|
g_mutex_unlock(&m->tlock); \
|
|
} \
|
|
G_STMT_END
|
|
|
|
#define GST_ADAPTER_PIPE_WAIT(m) \
|
|
G_STMT_START \
|
|
{ \
|
|
GST_TRACE("thread %p waiting", g_thread_self()); \
|
|
g_cond_wait(&m->cond, &m->tlock); \
|
|
} \
|
|
G_STMT_END
|
|
|
|
#define GST_ADAPTER_PIPE_WAITT_TIME(m, wait_time, ret) \
|
|
G_STMT_START \
|
|
{ \
|
|
GST_TRACE("thread %p waiting for:%d(ms)", g_thread_self(), wait_time); \
|
|
ret = g_cond_wait_until(&m->cond, &m->tlock, g_get_monotonic_time() + wait_time); \
|
|
} \
|
|
G_STMT_END
|
|
|
|
#define GST_ADAPTER_PIPE_SIGNAL(m) \
|
|
G_STMT_START \
|
|
{ \
|
|
GST_TRACE("signaling from thread %p", g_thread_self()); \
|
|
g_cond_signal(&m->cond); \
|
|
} \
|
|
G_STMT_END
|
|
|
|
#define GST_FLOW_AMLAP_EMPTY GST_FLOW_CUSTOM_SUCCESS
|
|
|
|
typedef struct _GstAdapterPipe GstAdapterPipe;
|
|
typedef struct _GstAdapterPipeStatus GstAdapterPipeStatus;
|
|
|
|
struct _GstAdapterPipeStatus
|
|
{
|
|
/* statistics */
|
|
guint pushed_num;
|
|
guint pushed_size;
|
|
guint poped_num;
|
|
guint poped_size;
|
|
|
|
/* amount needed/low/max in adapter by src task */
|
|
guint needed_num;
|
|
guint low_num;
|
|
guint max_num;
|
|
guint cur_num;
|
|
|
|
guint needed_size;
|
|
guint low_size;
|
|
guint max_size;
|
|
guint cur_size;
|
|
};
|
|
|
|
typedef enum
|
|
{
|
|
GST_AP_TS = 0,
|
|
GST_AP_ES = 1,
|
|
} GstAdapterPipeDataType;
|
|
|
|
GstAdapterPipe *gst_amladapterpipe_new();
|
|
GstAdapterPipe *gst_amladapterpipe_new_full(GstAdapterPipeDataType type, gboolean is_secure, gboolean is_unlimit);
|
|
void gst_amladapterpipe_free(GstAdapterPipe *pipe);
|
|
GstFlowReturn gst_amladapterpipe_reset(GstAdapterPipe *pipe);
|
|
GstFlowReturn gst_amladapterpipe_clear(GstAdapterPipe *pipe);
|
|
gboolean gst_amladapterpipe_get_status(GstAdapterPipe *pipe, GstAdapterPipeStatus *status);
|
|
GstFlowReturn gst_amladapterpipe_push(GstAdapterPipe *pipe, GstBuffer *buffer);
|
|
GstFlowReturn gst_amladapterpipe_push_uncheck(GstAdapterPipe *pipe, GstBuffer *buffer);
|
|
GstFlowReturn gst_amladapterpipe_pop(GstAdapterPipe *pipe, GstBuffer **buffer);
|
|
GstFlowReturn gst_amladapterpipe_peek(GstAdapterPipe *pipe, GstBuffer **buffer);
|
|
GstFlowReturn gst_amladapterpipe_set_flushing(GstAdapterPipe *pipe, gboolean flushing);
|
|
GstFlowReturn gst_amladapterpipe_is_flushing(GstAdapterPipe *pipe, gboolean *flushing);
|
|
void gst_amladapterpipe_set_eos(GstAdapterPipe *pipe);
|
|
gboolean gst_amladapterpipe_is_eos(GstAdapterPipe *pipe);
|
|
|
|
#endif /* __GST_AML_ADAPTER_PIPE_H__ */ |