amldmx: CF1 add sec dump flow for dbg [1/1]

PD#SWPL-178855

Problem:
add sec dump flow for dbg

Solution:
add sec dump flow for dbg

Verify:
(detail info)

Change-Id: I60207c4ec5efe76032e0b361f3b0440ef8f0c686
Signed-off-by: xuesong.jiang <xuesong.jiang@amlogic.com>
diff --git a/src/aml_defs.h b/src/aml_defs.h
index 8edd662..2a1c1a8 100644
--- a/src/aml_defs.h
+++ b/src/aml_defs.h
@@ -113,6 +113,10 @@
 #define GST_AML_TS_INFO_VIDEO_PID "video-pid"
 #define GST_AML_TS_INFO_AUDIO_PID "audio-pid"
 
+
+/** for debug **/
+// #define DBG_SECMEM
+
 typedef enum
 {
     GST_MPEGTS_STREAM_TYPE_RESERVED_00 = 0x00,
diff --git a/src/gstamldmx.c b/src/gstamldmx.c
index 80d0555..e87348e 100644
--- a/src/gstamldmx.c
+++ b/src/gstamldmx.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 #include <stdio.h>
+#include <sys/mman.h>
 #include "gstamldmx.h"
 #include "gstamldmxfilter.h"
 #include "gstamldmxwrap.h"
@@ -97,7 +98,7 @@
 void gst_amlhwdmx_load_balance_control(GstAmlhwdmx *amlhwdmx, gint idx, gint ts);
 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);
+static void gst_amlhwdmx_dump_ts(GstAmlhwdmx *amlhwdmx, GstBuffer *buffer, const char *file_name);
 
 /* Properties */
 enum
@@ -119,6 +120,19 @@
 
 static GstBinClass *parent_class;
 
+#ifdef DBG_SECMEM
+#define GST_AMLHWDMX_DBG_BUF_QUARK gst_amlhwdmx_dbg_buf_import_quark ()
+static GQuark gst_amlhwdmx_dbg_buf_import_quark (void)
+{
+  static GQuark quark = 0;
+
+  if (quark == 0)
+    quark = g_quark_from_string ("GstAmlhwdmxDbgBuf");
+
+  return quark;
+}
+#endif
+
 static GstStateChangeReturn
 gst_amlhwdmx_change_state(GstElement *element, GstStateChange transition)
 {
@@ -143,9 +157,11 @@
         GST_LOG_OBJECT(amlhwdmx, "GST_STATE_CHANGE_READY_TO_PAUSED");
 
         amlhwdmx->flags |= GST_AML_DMX_PROB;
-
+#ifdef DBG_SECMEM
+        dmxret = gst_amldmxwrap_set_config(amlhwdmx->dmx_dev_id, FALSE);
+#else
         dmxret = gst_amldmxwrap_set_config(amlhwdmx->dmx_dev_id, amlhwdmx->is_secure);
-
+#endif
         /*set PAT filter for HW demux*/
         dmxret |= gst_amldmxwrap_alloc_filter(amlhwdmx->dmx_dev_id, &amlhwdmx->sinkpad.pat_para.fid);
         dmxret |= gst_amldmxwrap_set_cb(amlhwdmx->dmx_dev_id, amlhwdmx->sinkpad.pat_para.fid, gst_parse_pat_cb, amlhwdmx);
@@ -155,8 +171,11 @@
         amlhwdmx->sinkpad.pat_para.filter_para.filter.filter[0] = 0;
         amlhwdmx->sinkpad.pat_para.filter_para.filter.mask[0] = 0xff;
         amlhwdmx->sinkpad.pat_para.filter_para.flags = DMX_CHECK_CRC;
+#ifdef DBG_SECMEM
+#else
         if (amlhwdmx->is_secure)
             amlhwdmx->sinkpad.pat_para.filter_para.flags |= DMX_MEM_SEC_LEVEL2;
+#endif
         dmxret |= gst_amldmxwrap_sec_secfilter(amlhwdmx->dmx_dev_id, amlhwdmx->sinkpad.pat_para.fid, &amlhwdmx->sinkpad.pat_para.filter_para);
         dmxret |= gst_amldmxwrap_set_bufsize(amlhwdmx->dmx_dev_id, amlhwdmx->sinkpad.pat_para.fid, SECTION_FILTER_BUF_SIZE);
 
@@ -569,13 +588,11 @@
 
 static void gst_amlhwdmx_stop_es_streams(GstAmlhwdmx *amlhwdmx)
 {
-    int dmxret = 0;
-
     for (gint i = 0; i < amlhwdmx->srcpad_num; i++)
     {
         if (amlhwdmx->srcpads[i].es_fid != -1)
         {
-            dmxret = gst_amldmxwrap_stop_filter(amlhwdmx->dmx_dev_id, amlhwdmx->srcpads[i].es_fid);
+            gst_amldmxwrap_stop_filter(amlhwdmx->dmx_dev_id, amlhwdmx->srcpads[i].es_fid);
             gst_pad_pause_task(amlhwdmx->srcpads[i].pad);
         }
     }
@@ -596,9 +613,16 @@
 {
     GstMapInfo map;
     GstFlowReturn ret = GST_FLOW_OK;
-    ssize_t actual_write = 0;
     DVB_RESULT dmx_ret = DVB_SUCCESS;
 
+    if (GST_LEVEL_MEMDUMP == gst_debug_category_get_threshold(gst_amlhwdmx_debug))
+    {
+        if (amlhwdmx->flags & GST_AML_DMX_PROB)
+            gst_amlhwdmx_dump_ts(amlhwdmx, buffer, "/data/test/input-loop-probe.ts");
+        else
+            gst_amlhwdmx_dump_ts(amlhwdmx, buffer, "/data/test/input-loop.ts");
+    }
+
     ret = gst_amlhwdmx_buffer_map(amlhwdmx, buffer, &map);
     if (ret != GST_FLOW_OK)
     {
@@ -610,14 +634,19 @@
 
     if (amlhwdmx->is_secure)
     {
+#ifdef DBG_SECMEM
+        GST_DEBUG_OBJECT(amlhwdmx, "status:%x | try to write ts data into DMX. buf:%p, data:%p, size:%d", amlhwdmx->flags, buffer, (gchar *)map.data, map.size);
+        dmx_ret = gst_amldmxwrap_write(amlhwdmx->dmx_dev_id, (gchar *)map.data, map.size);
+#else
         struct dmx_sec_ts_data ts_sec_data;
         memset(&ts_sec_data, 0, sizeof(ts_sec_data));
-        ts_sec_data.buf_start = (guint)map.data; // TODO:need check if data size is not integer multiple of 188
+        ts_sec_data.buf_start = (guint)map.data;
         ts_sec_data.buf_end = (guint)map.data + map.size;
-        GST_DEBUG_OBJECT(amlhwdmx, "secure mode write buf_start:%p, buf_end:%p, size:%d, actual_write:%d",
-                         (void *)ts_sec_data.buf_start, (void *)ts_sec_data.buf_end, sizeof(ts_sec_data), actual_write);
+        GST_DEBUG_OBJECT(amlhwdmx, "secure mode write buf_start:%p, buf_end:%p, size:%d",
+                         (void *)ts_sec_data.buf_start, (void *)ts_sec_data.buf_end, sizeof(ts_sec_data));
 
         dmx_ret = gst_amldmxwrap_write(amlhwdmx->dmx_dev_id, (gchar *)(&ts_sec_data), sizeof(ts_sec_data));
+#endif
     }
     else
     {
@@ -1138,11 +1167,28 @@
             ret = GST_FLOW_ERROR;
             goto done;
         }
-        GST_ERROR_OBJECT(amlhwdmx, "paddr:0x%x", gst_secmem_memory_get_paddr(mem));
+        GST_TRACE_OBJECT(amlhwdmx, "paddr:0x%x", gst_secmem_memory_get_paddr(mem));
 
+#ifdef DBG_SECMEM
+        GstBuffer * dump_buf = gst_mini_object_get_qdata (GST_MINI_OBJECT (buffer), GST_AMLHWDMX_DBG_BUF_QUARK);
+        if (!dump_buf)
+        {
+            dump_buf = gst_buffer_mem_dump(mem->allocator, mem);
+            GST_TRACE_OBJECT(amlhwdmx, "new dump buf:%p", dump_buf);
+            gst_mini_object_set_qdata (GST_MINI_OBJECT (buffer), GST_AMLHWDMX_DBG_BUF_QUARK, dump_buf, (GDestroyNotify) gst_buffer_unref);
+        }
+        if (dump_buf)
+        {
+            gst_buffer_map(dump_buf, info, GST_MAP_READ);
+            info->size = info->size;
+            GST_TRACE_OBJECT(amlhwdmx, "got dump_buf(%p) from sec_buf(%p) addr:%p, size:%u", dump_buf, buffer, info->data, info->size);
+        }
+#else
         info->data = (guint8 *)gst_secmem_memory_get_paddr(mem);
         info->size = gst_memory_get_sizes(mem, &offset, &maxsize);
-        GST_DEBUG_OBJECT(amlhwdmx, "got secure buffer paddr:%p, size:%u", info->data, info->size);
+        info->size = info->size;
+        GST_TRACE_OBJECT(amlhwdmx, "got secure buffer paddr:%p, size:%u", info->data, info->size);
+#endif
     }
     else
     {
@@ -1162,6 +1208,18 @@
     {
         gst_buffer_unmap(buffer, info);
     }
+#ifdef DBG_SECMEM
+    else
+    {
+        GstBuffer *dump_buf = gst_mini_object_get_qdata (GST_MINI_OBJECT (buffer), GST_AMLHWDMX_DBG_BUF_QUARK);
+        GST_TRACE_OBJECT(amlhwdmx, "got dump buf:%p", dump_buf);
+        if (dump_buf)
+        {
+            gst_buffer_unmap(dump_buf, info);
+            GST_TRACE_OBJECT(amlhwdmx, "unmap dump buf:%p done", dump_buf);
+        }
+    }
+#endif
 }
 
 static GstFlowReturn gst_amlhwdmx_chain(GstPad *sinkpad, GstObject *parent, GstBuffer *buffer)
@@ -1179,7 +1237,8 @@
     GST_DEBUG_OBJECT(sinkpad, "got buf:%p size:%d, pts: %" GST_TIME_FORMAT,
                      buffer, gst_buffer_get_size(buffer), GST_TIME_ARGS(GST_BUFFER_PTS(buffer)));
 
-    // gst_amlhwdmx_dump_ts(buffer, "/data/test/chain.ts");
+    if (GST_LEVEL_MEMDUMP == gst_debug_category_get_threshold(gst_amlhwdmx_debug))
+        gst_amlhwdmx_dump_ts(amlhwdmx, buffer, "/data/test/chain.ts");
 
     ret = gst_amladapterpipe_push(amlhwdmx->sinkpad.adapter_pipe, buffer);
 
@@ -1392,13 +1451,17 @@
         gst_stream_set_caps(stream_object, caps);
         gst_stream_set_stream_type(stream_object, type);
 
+        GST_DEBUG("pushing pad event %" GST_PTR_FORMAT, event);
         gst_pad_push_event(pad, event);
+        GST_DEBUG("setting pad caps %" GST_PTR_FORMAT, caps);
         gst_pad_set_caps(pad, caps);
         gst_pad_set_query_function(pad, gst_amlhwdmx_src_query);
         gst_pad_set_event_function(pad, gst_amlhwdmx_src_event);
         gst_pad_set_activatemode_function(pad, GST_DEBUG_FUNCPTR(gst_amlhwdmx_src_activate_mode));
 
+        GST_DEBUG("adding pad:%s(%p)", name, pad);
         gst_element_add_pad(GST_ELEMENT_CAST(amlhwdmx), pad);
+        GST_DEBUG("added pad:%s(%p)", name, pad);
 
         stream_pad->pad = pad;
         stream_pad->adapter_pipe = gst_amladapterpipe_new_full(GST_AP_ES, TRUE, FALSE);
@@ -1417,6 +1480,10 @@
     if (caps)
         gst_caps_unref(caps);
 
+
+    GST_LOG("create pad for stream 0x%04x with stream_type %d done with ret:%d",
+            pmt_stream->elementary_PID, pmt_stream->stream_type, ret);
+
     return ret;
 }
 
@@ -1503,21 +1570,21 @@
         return FALSE;
     }
 
-    GST_DEBUG_OBJECT(amlhwdmx, "filters num:%d", info_all.filter_num);
     if (info_all.filter_num > 0)
     {
         for (int i = 0; i < info_all.filter_num; i++)
         {
             struct dmx_mem_info *info = &info_all.info[i].filter_info;
 
-            GST_DEBUG("filter[idx:%d type:%d pid:%d] | \
-                       dmx_total_size:%d, dmx_buf_phy_start:0x%x, dmx_free_size:%d | \
-                       dvb_core_total_size:%d, dvb_core_free_size:%d | \
-                       wp_offset:0x%x, newest_pts:%llu",
-                      i, info_all.info[i].type, info_all.info[i].pid,
-                      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);
+            GST_TRACE_OBJECT(amlhwdmx,
+                             "filter[idx:%d type:%d pid:%d] | "
+                             "dmx_total_size:%d, dmx_buf_phy_start:0x%x, dmx_free_size:%d | "
+                             "dvb_core_total_size:%d, dvb_core_free_size:%d | "
+                             "wp_offset:0x%x, newest_pts:%llu",
+                             i, info_all.info[i].type, info_all.info[i].pid,
+                             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 (DMX_VIDEO_TYPE == info_all.info[i].type)
             {
@@ -1525,7 +1592,9 @@
 
                 newest_video_pts = info_all.info[i].filter_info.newest_pts / 90 * GST_MSECOND;
 
-                GST_DEBUG_OBJECT(amlhwdmx->srcpads[i].pad, "check video pts(now video pts: %" GST_TIME_FORMAT ", decoded video pts: %" GST_TIME_FORMAT ")",
+                GST_DEBUG_OBJECT(amlhwdmx,
+                                 "check video pts(now video pts: %" GST_TIME_FORMAT
+                                 ", decoded video pts: %" GST_TIME_FORMAT ")",
                                  GST_TIME_ARGS(newest_video_pts),
                                  GST_TIME_ARGS(amlhwdmx->sinkpad.decoded_pts));
 
@@ -1540,13 +1609,13 @@
                 }
                 else if (newest_video_pts - amlhwdmx->sinkpad.decoded_pts > AMLHWDMX_MAX_ES_BUF_PTS_DIFF)
                 {
-                    GST_ERROR_OBJECT(amlhwdmx->srcpads[i].pad, "check video pts fail(pts diff: %" GST_TIME_FORMAT ", Threshold exceeded)",
+                    GST_ERROR_OBJECT(amlhwdmx, "check video pts fail(pts diff: %" GST_TIME_FORMAT ", Threshold exceeded)",
                                      GST_TIME_ARGS(newest_video_pts - amlhwdmx->sinkpad.decoded_pts));
                     pts_check_result = FALSE;
                 }
                 else
                 {
-                    GST_DEBUG_OBJECT(amlhwdmx->srcpads[i].pad, "check video pts succ(pts diff: %" GST_TIME_FORMAT ")",
+                    GST_DEBUG_OBJECT(amlhwdmx, "check video pts succ(pts diff: %" GST_TIME_FORMAT ")",
                                      GST_TIME_ARGS(newest_video_pts - amlhwdmx->sinkpad.decoded_pts));
                     pts_check_result = TRUE;
                 }
@@ -1813,35 +1882,6 @@
 
     srcpad->newest_pts = GST_BUFFER_PTS(buf);
 
-    // gst_amlhwdmx_dump_es(srcpad, buf);
-
-    // if (srcpad->stream_type == GST_STREAM_TYPE_VIDEO)
-    // {
-    //     char name[50];
-    //     FILE *fd;
-    //     GstMapInfo map;
-    //     GstMemory *mem;
-    //     gsize offset, maxsize;
-
-    //     GST_ERROR_OBJECT(srcpad->pad, "check dump");
-    //     sprintf(name, "/data/test/%s.es", GST_PAD_NAME(srcpad->pad));
-    //     fd = fopen(name, "ab");
-    //     if (!fd)
-    //         return;
-
-    //     GST_ERROR_OBJECT(srcpad->pad, "before write");
-    //     if (buf)
-    //     {
-
-    //         memset(&map, 0, sizeof(map));
-    //         gst_buffer_map(buf, &map, GST_MAP_READ);
-    //         fwrite(map.data, 1, map.size, fd);
-    //         gst_buffer_unmap(buf, &map);
-    //     }
-
-    //     fclose(fd);
-    // }
-
     if (!srcpad->pushed_segment_event)
     {
         if (!amlhwdmx->sinkpad.segment_event)
@@ -1864,6 +1904,9 @@
 
     gst_amlhwdmx_load_balance_control(amlhwdmx, srcpad->idx, GST_BUFFER_PTS(buf) / GST_MSECOND);
 
+    if (GST_LEVEL_MEMDUMP == gst_debug_category_get_threshold(gst_amlhwdmx_debug))
+        gst_amlhwdmx_dump_es(srcpad, buf);
+
     gst_pad_push(srcpad->pad, buf);
 
     GST_DEBUG_OBJECT(srcpad->pad, "pushed buf:%p (size:%d start: %" GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ")",
@@ -1904,80 +1947,102 @@
         return;
 
     amlhwdmx = (GstAmlhwdmx *)gst_pad_get_parent(srcpad->pad);
-    GST_ERROR_OBJECT(amlhwdmx, "trace in");
+    sprintf(name, "/data/test/%s.es", GST_PAD_NAME(srcpad->pad));
+    if (!(fd = fopen(name, "ab")))
+        goto done;
+    memset(&map, 0, sizeof(map));
 
-    // if (srcpad->stream_type == GST_STREAM_TYPE_AUDIO)
-    // {
-    //     sprintf(name, "/data/test/%s.es", GST_PAD_NAME(srcpad->pad));
-    //     fd = fopen(name, "ab");
-    //     if (!fd)
-    //         return;
-
-    //     memset(&map, 0, sizeof(map));
-    //     GST_ERROR_OBJECT(amlhwdmx, "before gst_amlhwdmx_buffer_map");
-    //     gst_buffer_map(buf, &map, GST_MAP_READ);
-    //     GST_ERROR_OBJECT(amlhwdmx, "write file");
-    //     fwrite(map.data, 1, map.size, fd);
-    //     gst_buffer_unmap(buf, &map);
-    //     GST_ERROR_OBJECT(amlhwdmx, "after gst_amlhwdmx_buffer_map");
-    //     fclose(fd);
-    //     GST_ERROR_OBJECT(amlhwdmx, "trace out");
-    //     return;
-    // }
+    if (srcpad->stream_type == GST_STREAM_TYPE_AUDIO)
+        goto dump_clear;
 
     if (srcpad->stream_type == GST_STREAM_TYPE_VIDEO)
     {
-        if (!amlhwdmx->is_secure_es || (amlhwdmx->is_secure_es && !amlhwdmx->is_secure))
+        if (!amlhwdmx->is_secure_es)
+            goto dump_clear;
+
+        if (amlhwdmx->is_secure_es && !amlhwdmx->is_secure)
+            goto dump_dma;
+
+        if (amlhwdmx->is_secure_es && amlhwdmx->is_secure)
         {
-            GST_ERROR_OBJECT(amlhwdmx, "check dump");
-            sprintf(name, "/data/test/%s.es", GST_PAD_NAME(srcpad->pad));
-            fd = fopen(name, "ab");
-            if (!fd)
-                return;
-
-            memset(&map, 0, sizeof(map));
-            GST_ERROR_OBJECT(amlhwdmx, "before gst_amlhwdmx_buffer_map");
-            if (gst_amlhwdmx_buffer_map(amlhwdmx, buf, &map) == GST_FLOW_OK)
-            {
-                GST_ERROR_OBJECT(amlhwdmx, "write file");
-                fwrite(map.data, 1, map.size, fd);
-                gst_amlhwdmx_buffer_unmap(amlhwdmx, buf, &map);
-            }
-            GST_ERROR_OBJECT(amlhwdmx, "after gst_amlhwdmx_buffer_map");
-
-            fclose(fd);
+#ifdef DBG_SECMEM
+            goto dump_dma;
+#else
+            GST_TRACE_OBJECT(amlhwdmx, "can't dump sec video es data");
+            goto done;
+#endif
         }
     }
+dump_clear:
+    GST_TRACE_OBJECT(amlhwdmx, "dump clear for %s with buf:%p and size:%d", GST_PAD_NAME(srcpad->pad), buf, gst_buffer_get_size(buf));
+    gst_buffer_map(buf, &map, GST_MAP_READ);
+    GST_TRACE_OBJECT(amlhwdmx, "data:%p size:%d", map.data, map.size);
+    fwrite(map.data, 1, map.size, fd);
+    gst_buffer_unmap(buf, &map);
+    goto done;
+dump_dma:
+    GST_TRACE_OBJECT(amlhwdmx, "dump dma for %s with buf:%p and size:%d", GST_PAD_NAME(srcpad->pad), buf, gst_buffer_get_size(buf));
 
-    GST_ERROR_OBJECT(amlhwdmx, "trace out");
+    GstMemory * fd_mem;
+    gint dma_fd;
+    gint mem_size;
+    void *mapped_ptr;
+    int unmap_ret;
+
+    if (!(fd_mem = gst_buffer_get_memory(buf ,0)))
+        goto done;
+    if (!gst_is_fd_memory(fd_mem))
+        goto done;
+    if (-1 == (dma_fd = gst_fd_memory_get_fd(fd_mem)))
+        goto done;
+    mem_size = gst_buffer_get_size(buf);
+    mapped_ptr = mmap(NULL, mem_size, PROT_READ, MAP_PRIVATE, dma_fd, 0);
+    if (!mapped_ptr || -1 == (int)mapped_ptr)
+        goto done;
+    GST_TRACE_OBJECT(amlhwdmx, "mmap ret:%p", mapped_ptr);
+    fwrite(mapped_ptr, 1, mem_size, fd);
+    unmap_ret = munmap(mapped_ptr, mem_size);
+    GST_TRACE_OBJECT(amlhwdmx, "unmap ret:%d", unmap_ret);
+done:
+    if (fd)
+        fclose(fd);
+    return;
 }
 
-static void gst_amlhwdmx_dump_ts(GstBuffer *buffer, const char *file_name)
+static void gst_amlhwdmx_dump_ts(GstAmlhwdmx *amlhwdmx, GstBuffer *buffer, const char *file_name)
 {
     FILE *fd;
     GstMapInfo map;
-    GST_DEBUG("trace in dump buf:%p", buffer);
 
-    fd = fopen(file_name, "ab");
-    if (!fd)
+    if (!(fd = fopen(file_name, "ab")))
         return;
 
     memset(&map, 0, sizeof(map));
-    gst_buffer_map(buffer, &map, GST_MAP_READ);
-    fwrite(map.data, 1, map.size, fd);
-    gst_buffer_unmap(buffer, &map);
+    if (!amlhwdmx->is_secure)
+    {
+        gst_buffer_map(buffer, &map, GST_MAP_READ);
+        fwrite(map.data, 1, map.size, fd);
+        gst_buffer_unmap(buffer, &map);
+
+    }
+#ifdef DBG_SECMEM
+    else
+    {
+        gst_amlhwdmx_buffer_map(amlhwdmx, buffer, &map);
+        fwrite(map.data, 1, map.size, fd);
+        gst_amlhwdmx_buffer_unmap(amlhwdmx, buffer, &map);
+    }
+#endif
 
     fclose(fd);
 }
 
 GType gst_amlhwdmx_get_type(void)
 {
-    GST_DEBUG("get amlhwdmx type\n");
     static GType gst_amlhwdmx_type = 0;
 
     if (!gst_amlhwdmx_type)
     {
-        GST_DEBUG("create amlhwdmx type\n");
         static const GTypeInfo gst_amlhwdmx_info = {
             sizeof(GstAmlhwdmxClass),
             NULL,
diff --git a/src/gstamldmxfilter.c b/src/gstamldmxfilter.c
index 7eadaf4..4bb943b 100644
--- a/src/gstamldmxfilter.c
+++ b/src/gstamldmxfilter.c
@@ -69,8 +69,11 @@
             amlhwdmx->sinkpad.pmt_para[i].filter_para.filter.filter[0] = 2;
             amlhwdmx->sinkpad.pmt_para[i].filter_para.filter.mask[0] = 0xff;
             amlhwdmx->sinkpad.pmt_para[i].filter_para.flags = DMX_CHECK_CRC;
+#ifdef DBG_SECMEM
+#else
             if (amlhwdmx->is_secure)
                 amlhwdmx->sinkpad.pat_para.filter_para.flags |= DMX_MEM_SEC_LEVEL2;
+#endif
             dmxret = gst_amldmxwrap_sec_secfilter(amlhwdmx->dmx_dev_id, amlhwdmx->sinkpad.pmt_para[i].fid, &amlhwdmx->sinkpad.pmt_para[i].filter_para);
             GST_DEBUG_OBJECT(amlhwdmx, "pmt[%d] gst_amldmxwrap_sec_secfilter ret:%d, pmt_fid:%d, pmt pid:%d",
                              i, dmxret, amlhwdmx->sinkpad.pmt_para[i].fid, amlhwdmx->sinkpad.pmt_para[i].filter_para.pid);
@@ -142,8 +145,11 @@
         es_fpara->output = DMX_OUT_TAP;
 
         es_fpara->flags = DMX_ES_OUTPUT;
+#ifdef DBG_SECMEM
+#else
         if (amlhwdmx->is_secure)
             es_fpara->flags |= DMX_MEM_SEC_LEVEL2;
+#endif
         switch (amlhwdmx->srcpads[i].stream_type)
         {
         case GST_STREAM_TYPE_VIDEO:
@@ -164,7 +170,7 @@
                 GST_ERROR_OBJECT(amlhwdmx, "parse acodec type error");
                 return;
             }
-            GST_ERROR_OBJECT(amlhwdmx, "parse acodec type 0x%x", acodec_type);
+            GST_INFO_OBJECT(amlhwdmx, "parse acodec type 0x%x", acodec_type);
             es_fpara->flags |= ((acodec_type & 0xff) << DMX_AUDIO_FORMAT_BIT);
             break;
         }