--- gstomx_base_filter1.c	2008-08-21 11:13:35.000000000 +0800
+++ gstomx_base_filter.c	2008-08-21 11:13:15.000000000 +0800
@@ -30,7 +30,8 @@
     ARG_0,
     ARG_COMPONENT_NAME,
     ARG_LIBRARY_NAME,
-    ARG_USE_TIMESTAMPS
+    ARG_USE_TIMESTAMPS,
+    ARG_ENABLE_CODECDATA
 };
 
 static GstElementClass *parent_class = NULL;
@@ -186,6 +187,9 @@
         case ARG_USE_TIMESTAMPS:
             self->use_timestamps = g_value_get_boolean (value);
             break;
+        case ARG_ENABLE_CODECDATA:
+            self->enable_codecdata = g_value_get_boolean (value);
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
             break;
@@ -213,6 +217,9 @@
         case ARG_USE_TIMESTAMPS:
             g_value_set_boolean (value, self->use_timestamps);
             break;
+        case ARG_ENABLE_CODECDATA:
+            g_value_set_boolean (value, self->enable_codecdata);
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
             break;
@@ -253,6 +260,11 @@
                                          g_param_spec_boolean ("use-timestamps", "Use timestamps",
                                                                "Whether or not to use timestamps",
                                                                TRUE, G_PARAM_READWRITE));
+
+        g_object_class_install_property (gobject_class, ARG_ENABLE_CODECDATA,
+                                         g_param_spec_boolean ("enable-codecdata", "Enable codec_data",
+                                                               "Whether or not to add a codec_data in the first frame",
+                                                               TRUE, G_PARAM_READWRITE));
     }
 }
 
@@ -492,7 +504,24 @@
         {
             GST_ERROR_OBJECT (self, "Whoa! very wrong");
         }
-
+        if(self->enable_codecdata)
+        {
+            static gboolean first_frame=true;
+            GstBuffer * headerbuffer = NULL;
+            if(first_frame)
+            {
+                int  headerbuffersize = GST_BUFFER_SIZE (self->codec_data) + GST_BUFFER_SIZE (buf);
+                headerbuffer = gst_buffer_new_and_alloc(headerbuffersize);
+                if(!headerbuffer)
+                    GST_ELEMENT_ERROR(self,RESOURCE,FAILED,(NULL),("Failed to create a new buffer!"));               
+                memcpy (GST_BUFFER_DATA(headerbuffer), GST_BUFFER_DATA( self->codec_data), GST_BUFFER_SIZE(self->codec_data));
+                memcpy (GST_BUFFER_DATA(headerbuffer)+GST_BUFFER_SIZE (self->codec_data), GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
+                headerbuffer->size = headerbuffersize;
+                gst_buffer_unref(buf);
+                buf = headerbuffer;  
+                first_frame=false;
+            }
+        }
         while (G_LIKELY (buffer_offset < GST_BUFFER_SIZE (buf)))
         {
             OMX_BUFFERHEADERTYPE *omx_buffer;
@@ -626,6 +657,7 @@
     GST_LOG_OBJECT (self, "begin");
 
     self->use_timestamps = TRUE;
+    self->enable_codecdata = FALSE;
 
     /* GOmx */
     {
