Hi,<div><br></div><div>I think using following lines</div><div><br></div><div><div>raw_buffer = g_malloc0 (640*480*3);</div><div>        memset((void *)raw_buffer, 0xff, (640*480*3));</div><div><br></div><div>        buffer = gst_app_buffer_new (raw_buffer, (640*480*3), g_free, raw_buffer);</div>
<div><br></div><div>instead of </div><div><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">//       pb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 640, 480);</span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">//       gdk_pixbuf_fill(pb, 0xffffffff);</span></div>
<div><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">//       GST_BUFFER_DATA (buffer) = gdk_pixbuf_get_pixels(pb);</span></div><div><br></div><div>may help you.</div><div><br></div><div>raw buffer is of type gpointer.</div>
<div><br></div><div>--Ashwini</div><br><div class="gmail_quote">On Fri, Nov 25, 2011 at 1:27 PM, Chinnapong Angsuchotmetee <span dir="ltr">&lt;<a href="mailto:achinapong@gmail.com">achinapong@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Dear all,<br>
<br>
I try to create a basic video application whose generate a raw frame<br>
buffer, encoded it via x264enc and stream it via AutovideoSink. I<br>
stucked on the error as followed:<br>
<br>
<br>
(a.out:11729): GStreamer-CRITICAL **: gst_buffer_create_sub: assertion<br>
`buffer-&gt;mini_object.refcount &gt; 0&#39; failed<br>
<br>
(a.out:11729): GStreamer-CRITICAL **: gst_mini_object_unref: assertion<br>
`mini_object-&gt;refcount &gt; 0&#39; failed<br>
Segmentation fault<br>
<br>
<br>
I have no idea what to do to solve this error, Some suggestion on<br>
google recommend me to set the caps property of the appsrc source.<br>
However, I already did that and the assertion is still remained.<br>
Sourcecode is attached below. Any suggestion or explanation would be<br>
highly appreciated.<br>
<br>
Best regards,<br>
<br>
Chinnapong<br>
<br>
<br>
Here are the sourcecode:<br>
<br>
<br>
#include &lt;gst/gst.h&gt;<br>
#include &lt;gst/app/gstappsrc.h&gt;<br>
#include &lt;gdk-pixbuf/gdk-pixbuf.h&gt;<br>
<br>
<br>
GstElement *pipeline, *source, *decoder, *video_sink;<br>
GstCaps * caps;<br>
<br>
static gboolean bus_call(GstBus * bus,<br>
                         GstMessage * msg,<br>
                         gpointer data)<br>
{<br>
        GMainLoop *loop = (GMainLoop *) data;<br>
        switch (GST_MESSAGE_TYPE (msg))<br>
        {<br>
                case GST_MESSAGE_EOS:<br>
                        g_print(&quot;End-of-stream\n&quot;);<br>
                        g_main_loop_quit(loop);<br>
                        break;<br>
                case GST_MESSAGE_ERROR:<br>
                {<br>
                        gchar * debug;<br>
                        GError *err;<br>
<br>
                        gst_message_parse_error (msg, &amp;err, &amp;debug);<br>
                        g_free (debug);<br>
<br>
                        g_print(&quot;Error: %s\n&quot;, err-&gt;message);<br>
                        g_main_loop_quit(loop);<br>
                        break;<br>
                }<br>
                default:<br>
                        break;<br>
                return TRUE;<br>
        }<br>
}<br>
<br>
<br>
 static void feed(      GstElement* object,<br>
                        guint arg0,<br>
                        gpointer src )<br>
{<br>
<br>
        GstBuffer *buffer;<br>
        GdkPixbuf *pb;<br>
        GstFlowReturn ret;<br>
        gboolean ok = TRUE;<br>
        buffer = gst_buffer_new();<br>
        pb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 640, 480);<br>
        gdk_pixbuf_fill(pb, 0xffffffff);<br>
<br>
        GST_BUFFER_DATA (buffer) = gdk_pixbuf_get_pixels(pb);<br>
        GST_BUFFER_SIZE (buffer) = 640*480*3*sizeof(guchar);<br>
<br>
        GST_DEBUG (&quot;feed buffer&quot;);<br>
        g_signal_emit_by_name (src, &quot;push-buffer&quot;, buffer, &amp;ret);<br>
<br>
<br>
        if (ret != GST_FLOW_OK) {<br>
          GST_DEBUG (&quot;some error&quot;);<br>
        }<br>
<br>
        gst_buffer_unref (buffer);<br>
<br>
<br>
}<br>
<br>
static void new_pad(    GstElement * element,<br>
                        GstPad  * pad,<br>
                        gpointer data )<br>
{<br>
        GstPad *sinkpad = NULL;<br>
        GstElement *decoder = (GstElement *) data;<br>
        sinkpad = gst_element_get_static_pad(decoder,&quot;vsink&quot;);<br>
        gst_pad_link(pad,sinkpad);<br>
        gst_object_unref (sinkpad);<br>
}<br>
<br>
int main(int argc, char * argv[])<br>
{<br>
        GMainLoop * loop;<br>
        GstBus * bus;<br>
<br>
        gst_init(&amp;argc, &amp;argv);<br>
        loop = g_main_loop_new(NULL, FALSE);<br>
<br>
<br>
        pipeline = gst_pipeline_new(&quot;test-push-buffer&quot;);<br>
        source = gst_element_factory_make(&quot;appsrc&quot;,&quot;source&quot;);<br>
        decoder = gst_element_factory_make(&quot;x264enc&quot;,&quot;decoder&quot;);<br>
        caps = gst_caps_new_simple (&quot;video/x-raw-rgb&quot;,<br>
                    &quot;bpp&quot;,G_TYPE_INT,24,<br>
                    &quot;depth&quot;,G_TYPE_INT,24,<br>
                    &quot;width&quot;, G_TYPE_INT, 640,<br>
                    &quot;height&quot;, G_TYPE_INT, 480,<br>
                 NULL);<br>
<br>
        video_sink = gst_element_factory_make(&quot;autovideosink&quot;,&quot;vsink&quot;);<br>
        if(!pipeline || !source || ! video_sink || ! decoder)<br>
        {<br>
                g_print(&quot;Element creation Error\n&quot;);<br>
                return -1;<br>
        }<br>
<br>
        gst_app_src_set_caps((GstAppSrc*)source, caps);<br>
        g_signal_connect (source, &quot;need-data&quot;, G_CALLBACK (feed), source);<br>
<br>
        g_object_set(G_OBJECT(source), &quot;caps&quot;, caps, NULL);<br>
        bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br>
        gst_bus_add_watch (bus, bus_call, loop);<br>
        gst_object_unref (bus);<br>
<br>
<br>
        gst_bin_add_many(GST_BIN (pipeline), source, decoder, video_sink, NULL);<br>
        gst_element_link_many (source, decoder, video_sink);<br>
<br>
<br>
        g_signal_connect (decoder, &quot;pad-added&quot;, G_CALLBACK(new_pad), NULL);<br>
<br>
        g_print(&quot;Setting to Playing\n&quot;);<br>
        gst_element_set_state(pipeline, GST_STATE_PLAYING);<br>
        g_print(&quot;Running\n&quot;);<br>
        g_main_loop_run(loop);<br>
<br>
<br>
        g_print(&quot;Stop playback\n&quot;);<br>
        gst_element_set_state(pipeline, GST_STATE_NULL);<br>
        g_print(&quot;Delete Pipeline\n&quot;);<br>
        gst_object_unref (GST_OBJECT (pipeline));<br>
<br>
        return 0;<br>
<br>
<br>
}<br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div><br></div>