amldemux: CF1 add sinkpad ts caps and clean redundant code [1/1]
PD#SWPL-131108
Problem:
add sinkpad ts caps and clean redundant code
Solution:
add sinkpad ts caps and clean redundant code
Verify:
(detail info)
Change-Id: I94072bd8f761260dbc518fb9846a833d0ae3e011
Signed-off-by: xuesong.jiang <xuesong.jiang@amlogic.com>
diff --git a/src/aml_defs.h b/src/aml_defs.h
index ea4cd7e..328dc85 100644
--- a/src/aml_defs.h
+++ b/src/aml_defs.h
@@ -95,7 +95,7 @@
#define DEFAULT_IS_LIVE TRUE
// #define DEFAULT_IS_LIVE FALSE
#define DEFAULT_IS_SECURE FALSE
-#define DEFAULT_IS_SECURE_ES FALSE
+#define DEFAULT_IS_SECURE_ES TRUE
/** aml ts info **/
#define GST_AML_TS_INFO_QUERY_NAME "aml-ts-info"
diff --git a/src/gstamldmx.c b/src/gstamldmx.c
index 6dbe13e..683c599 100644
--- a/src/gstamldmx.c
+++ b/src/gstamldmx.c
@@ -41,7 +41,8 @@
GST_STATIC_PAD_TEMPLATE("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY);
+ GST_STATIC_CAPS("video/mpegts, "
+ "systemstream = (boolean) true "));
static GstStaticPadTemplate video_src_template =
GST_STATIC_PAD_TEMPLATE("video_%u",
@@ -86,7 +87,6 @@
static void gst_amlhwdmx_wait(GstAmlhwdmx *amlhwdmx);
static gboolean gst_amlhwdmx_write(GstAmlhwdmx *amlhwdmx, GstBuffer *buffer);
static gboolean gst_amlhwdmx_check_mem(GstAmlhwdmx *amlhwdmx);
-static gboolean gst_amlhwdmx_check_pts_diff(GstAmlhwdmx *amlhwdmx);
static void gst_amlhwdmx_update_pts_cb(gpointer elem, guint64 pts, gpointer user_data);
static void gst_amlhwdmx_dump_es(GstDmxSrcStreamPad *srcpad, GstBuffer *buf);
static void gst_amlhwdmx_dump_ts(GstBuffer *buffer, const char *file_name);
@@ -128,6 +128,8 @@
set_osd_blank(1);
set_dmx_source();
+ amlhwdmx->sinkpad.adapter_pipe = gst_amladapterpipe_new_full(GST_AP_TS, amlhwdmx->is_secure, FALSE); // new adaptor and do stream control
+
snprintf(node, sizeof(node), "/dev/dvb0.dvr%d", amlhwdmx->dmx_dev_id);
snprintf(node2, sizeof(node2), "/dev/dvb0.demux%d", amlhwdmx->dmx_dev_id);
amlhwdmx->dmx_src_fd = open(node, O_WRONLY);
@@ -318,7 +320,7 @@
g_mutex_init(&amlhwdmx->context_lock);
/* context para for push mode */
- amlhwdmx->sinkpad.adapter_pipe = gst_amladapterpipe_new_full(GST_AP_TS, TRUE, FALSE); // new adaptor and do stream control
+ // amlhwdmx->sinkpad.adapter_pipe = gst_amladapterpipe_new_full(GST_AP_TS, TRUE, FALSE); // new adaptor and do stream control
amlhwdmx->sinkpad.task = gst_task_new((GstTaskFunction)gst_amlhwdmx_loop, amlhwdmx, NULL); // push mode
g_rec_mutex_init(&amlhwdmx->sinkpad.task_lock);
gst_task_set_lock(amlhwdmx->sinkpad.task, &amlhwdmx->sinkpad.task_lock);
@@ -538,7 +540,7 @@
{
while (!(amlhwdmx->flags & GST_AML_DMX_FLUSHING))
{
- if (gst_amlhwdmx_check_pts_diff(amlhwdmx))
+ if (gst_amlhwdmx_check_mem(amlhwdmx))
break;
usleep(50 * 1000);
GST_DEBUG_OBJECT(amlhwdmx, "waitting for filters mem");
@@ -1159,7 +1161,7 @@
caps = gst_caps_new_simple("video/x-h264",
"stream-format", G_TYPE_STRING, "byte-stream",
"alignment", G_TYPE_STRING, "au",
- "parsed", G_TYPE_BOOLEAN, TRUE, NULL);
+ "parsed", G_TYPE_BOOLEAN, FALSE, NULL);
}
else
{
@@ -1320,36 +1322,61 @@
return res;
}
+static guint gst_amlhwdmx_convert_type_gst2dmx(GstStreamType type)
+{
+ switch (type)
+ {
+ case GST_STREAM_TYPE_VIDEO:
+ return DMX_VIDEO_TYPE;
+ case GST_STREAM_TYPE_AUDIO:
+ return DMX_AUDIO_TYPE;
+ case GST_STREAM_TYPE_TEXT:
+ return DMX_SUBTITLE_TYPE;
+ default:
+ return DMX_SECTION_TYPE;
+ }
+}
+
static gboolean gst_amlhwdmx_check_mem(GstAmlhwdmx *amlhwdmx)
{
struct dmx_mem_info info;
+
memset(&info, 0, sizeof(info));
for (gint i = 0; i < amlhwdmx->srcpad_num; i++)
{
- guint es_fid = amlhwdmx->srcpads[i].es_fid;
- guint stream_type = amlhwdmx->srcpads[i].stream_type;
- guint pid = amlhwdmx->srcpads[i].pid;
- GST_DEBUG_OBJECT(amlhwdmx, "check pad[%d] es_fid:%d, stream_type:%d, pid:%d", i, es_fid, stream_type, pid);
+ guint es_fid;
+ guint stream_type;
+ guint pid;
- if (gst_amldmxwrap_get_filter_mem_info(amlhwdmx->dmx_dev_id, es_fid, stream_type, pid, &info) == -1)
+ es_fid = amlhwdmx->srcpads[i].es_fid;
+ stream_type = gst_amlhwdmx_convert_type_gst2dmx(amlhwdmx->srcpads[i].stream_type);
+ pid = amlhwdmx->srcpads[i].pid;
+ if (stream_type == DMX_VIDEO_TYPE)
{
- GST_ERROR_OBJECT(amlhwdmx, "dmx get mem info failed error:%s", strerror(errno));
- return FALSE;
- }
- GST_DEBUG_OBJECT(amlhwdmx, "dmx_total_size:0x%x, dmx_buf_phy_start:0x%x, dmx_free_size:0x%x, dvb_core_total_size:0x%x, dvb_core_free_size:0x%x, wp_offset:0x%x",
- info.dmx_total_size, info.dmx_buf_phy_start, info.dmx_free_size, info.dvb_core_total_size, info.dvb_core_free_size, info.wp_offset);
+ GST_DEBUG_OBJECT(amlhwdmx, "check pad[%d] es_fid:%d, stream_type:%d, pid:%d", i, es_fid, stream_type, pid);
- /*
- flow rate control method 1:
- DMX driver return err free size when using ioctl:DMX_GET_FILTER_MEM_INFO.
- this free size didn't take into account the updated rp position of decoder.
- DMX has a patch to solve this problem, but it is not merged(https://scgit.amlogic.com/#/c/319330/).
- Temporarily retain the process for future expansion.
- */
- {
- if (info.dmx_free_size < AMLHWDMX_MIN_ES_BUF_SIZE)
+ if (gst_amldmxwrap_get_filter_mem_info(amlhwdmx->dmx_dev_id, es_fid, stream_type, pid, &info) == -1)
+ {
+ GST_ERROR_OBJECT(amlhwdmx, "dmx get mem info failed error:%s", strerror(errno));
return FALSE;
- }
+ }
+ GST_DEBUG_OBJECT(amlhwdmx, "dmx_total_size:0x%x, dmx_buf_phy_start:0x%x, dmx_free_size:0x%x, dvb_core_total_size:0x%x, dvb_core_free_size:0x%x, wp_offset:0x%x, newest_pts:%llu",
+ info.dmx_total_size, info.dmx_buf_phy_start, info.dmx_free_size, info.dvb_core_total_size, info.dvb_core_free_size, info.wp_offset, info.newest_pts);
+
+#if 0
+ /*
+ flow rate control method 1:
+ DMX driver return err free size when using ioctl:DMX_GET_FILTER_MEM_INFO.
+ this free size didn't take into account the updated rp position of decoder.
+ DMX has a patch to solve this problem, but it is not merged(https://scgit.amlogic.com/#/c/319330/).
+ Temporarily retain the process for future expansion.
+ */
+ {
+ if (info.dmx_free_size < AMLHWDMX_MIN_ES_BUF_SIZE)
+ return FALSE;
+ }
+#endif
+
#if 0
/*
flow rate control method 2:
@@ -1379,51 +1406,8 @@
}
}
#endif
- }
- return TRUE;
-}
-static guint gst_amlhwdmx_convert_type_gst2dmx(GstStreamType type)
-{
- switch (type)
- {
- case GST_STREAM_TYPE_VIDEO:
- return DMX_VIDEO_TYPE;
- case GST_STREAM_TYPE_AUDIO:
- return DMX_AUDIO_TYPE;
- case GST_STREAM_TYPE_TEXT:
- return DMX_SUBTITLE_TYPE;
- default:
- return DMX_SECTION_TYPE;
- }
-}
-
-static gboolean gst_amlhwdmx_check_pts_diff(GstAmlhwdmx *amlhwdmx)
-{
- struct dmx_mem_info info;
-
- memset(&info, 0, sizeof(info));
- for (gint i = 0; i < amlhwdmx->srcpad_num; i++)
- {
- guint es_fid;
- guint stream_type;
- guint pid;
-
- es_fid = amlhwdmx->srcpads[i].es_fid;
- stream_type = gst_amlhwdmx_convert_type_gst2dmx(amlhwdmx->srcpads[i].stream_type);
- pid = amlhwdmx->srcpads[i].pid;
- if (stream_type == DMX_VIDEO_TYPE)
- {
- GST_DEBUG_OBJECT(amlhwdmx, "check pad[%d] es_fid:%d, stream_type:%d, pid:%d", i, es_fid, stream_type, pid);
-
- if (gst_amldmxwrap_get_filter_mem_info(amlhwdmx->dmx_dev_id, es_fid, stream_type, pid, &info) == -1)
- {
- GST_ERROR_OBJECT(amlhwdmx, "dmx get mem info failed error:%s", strerror(errno));
- return FALSE;
- }
- GST_DEBUG_OBJECT(amlhwdmx, "dmx_total_size:0x%x, dmx_buf_phy_start:0x%x, dmx_free_size:0x%x, dvb_core_total_size:0x%x, dvb_core_free_size:0x%x, wp_offset:0x%x, newest_pts:%llu",
- info.dmx_total_size, info.dmx_buf_phy_start, info.dmx_free_size, info.dvb_core_total_size, info.dvb_core_free_size, info.wp_offset, info.newest_pts);
-
+#if 1
/*
flow rate control method 3:
using decoded_pts to do flow rate control
@@ -1455,7 +1439,7 @@
return TRUE;
}
}
-
+#endif
break;
}
}
@@ -1791,7 +1775,7 @@
{
GST_DEBUG_CATEGORY_INIT(gst_amlhwdmx_debug, "amlhwdmx", 0, "amlhwdmx");
- return gst_element_register(plugin, "amlhwdmx", GST_RANK_NONE, GST_TYPE_AMLHWDMX);
+ return gst_element_register(plugin, "amlhwdmx", 300, GST_TYPE_AMLHWDMX);
}
/* PACKAGE: this is usually set by autotools depending on some _INIT macro