blob: f04d9bbc32775b2698de12c6f0df969f32c95ab1 [file] [log] [blame]
/* GStreamer
* Copyright (C) 2023 <xuesong.jiang@amlogic.com>
*
* 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_AMLHWDMX_H__
#define __GST_AMLHWDMX_H__
#include <gst/gst.h>
#include "aml_defs.h"
#include "gstamldmxwrap.h"
#include "ts_patpmt_parse.h"
#include "gstamladapterpipe.h"
G_BEGIN_DECLS
#define GST_TYPE_AMLHWDMX \
(gst_amlhwdmx_get_type())
#define GST_AMLHWDMX(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AMLHWDMX, GstAmlhwdmx))
#define GST_amlhwdmx_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AMLHWDMX, GstAmlhwdmxClass))
#define GST_IS_AMLHWDMX(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AMLHWDMX))
#define GST_IS_amlhwdmx_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AMLHWDMX))
typedef enum
{
GST_STREAM_UPDATE_NONE = 0,
GST_INIT_PLAY = (1 << 0),
GST_PGM_CHANGED = (1 << 1),
GST_PMT_CHANGED = (1 << 2),
GST_PMT_UPDATED = (1 << 3),
GST_AUDIO_CHANGED = (1 << 4),
} GstStreamUpdateFlags;
typedef enum
{
GST_AML_DMX_NONE = 0,
GST_AML_DMX_FLUSHING = (1 << 0),
GST_AML_DMX_EOS = (1 << 1),
GST_AML_DMX_PROB = (1 << 2),
GST_AML_DMX_PROB_DONE = (1 << 3),
} GstAmlDmxFlags;
typedef struct _GstAmlhwdmx GstAmlhwdmx;
typedef struct _GstAmlhwdmxClass GstAmlhwdmxClass;
typedef struct _GstDmxSinkStreamPad GstDmxSinkStreamPad;
typedef struct _GstDmxSrcStreamPad GstDmxSrcStreamPad;
typedef struct _GstAdapterPipe GstAdapterPipe;
typedef struct _GstDmxPatPara GstDmxPatPara;
typedef struct _GstDmxPmtPara GstDmxPmtPara;
/* params of pat */
struct _GstDmxPatPara
{
int32_t fid;
struct dmx_sct_filter_params filter_para;
TS_PAT pat;
};
/* params of pmt */
struct _GstDmxPmtPara
{
int32_t fid;
struct dmx_sct_filter_params filter_para;
TS_PMT pmt;
};
struct _GstDmxSinkStreamPad
{
GstPad *pad;
GstAdapterPipe *adapter_pipe;
GstDmxPatPara pat_para;
GstDmxPmtPara pmt_para[MAX_PROGRAM_NUM];
guint prob_peek_idx;
/* context para for push mode */
GstTask *task;
GRecMutex task_lock;
gpointer obj_ptr;
gulong update_pts_sig_id;
GstClockTime decoded_pts;
GstEvent *segment_event;
};
struct _GstDmxSrcStreamPad
{
GstPad *pad;
GstAdapterPipe *adapter_pipe;
gint es_fid;
guint pid;
GstStream *stream_object;
GstStreamType stream_type;
struct dmx_pes_filter_params es_fpara;
GstClockTime newest_pts;
gboolean pushed_segment_event;
};
struct _GstAmlhwdmx
{
GstElement element;
GstDmxSinkStreamPad sinkpad;
GstDmxSrcStreamPad srcpads[MAX_STREAM_NUM];
gint srcpad_num;
GstAllocator *fd_allocator;
gint prog_no; /* ReadWriteable */
char available_languages[256]; /* Readable */
char preferred_language[8]; /* Writeable */
gboolean is_live; /* ReadWriteable */
gboolean is_secure;
gboolean is_secure_es;
int32_t dmx_dev_id;
/* params of stream info */
gint audio_stream_num;
gint selected_program_no;
gint selected_audio_stream;
gint updated_pmt_num;
GstStreamUpdateFlags suf;
/* context para for ts table update */
gboolean patUpdated;
gboolean streamUpdated;
gint defaultVPid;
gint defaultAPid;
gint defaultTPid;
gint vCodecid;
gint aCodecid;
gint tCodecid;
/* context para*/
GMutex context_lock;
guint64 offset;
GstAmlDmxFlags flags;
gboolean eosFlag;
gboolean needQueryTsInfo;
GstCaps *caps;
GList *cached_events;
gboolean seekable;
GstEvent *seek_event; /* cached seek in READY */
GstSegment segment; /* segment stuff */
// tmp
guint group_id;
gboolean have_group_id;
};
struct _GstAmlhwdmxClass
{
GstBinClass parent_class;
GstPadTemplate sinktempl;
};
GType gst_amlhwdmx_get_type(void);
gboolean add_pad_for_stream(GstAmlhwdmx *amlhwdmx, int fid, TS_PMT_Stream *pmt_stream, GstDmxSrcStreamPad *stream_pad);
void gst_amlhwdmx_src_loop(GstDmxSrcStreamPad *srcpad);
G_END_DECLS
#endif /* __GST_AMLHWDMX_H__ */