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"><<a href="mailto:achinapong@gmail.com">achinapong@gmail.com</a>></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->mini_object.refcount > 0' failed<br>
<br>
(a.out:11729): GStreamer-CRITICAL **: gst_mini_object_unref: assertion<br>
`mini_object->refcount > 0' 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 <gst/gst.h><br>
#include <gst/app/gstappsrc.h><br>
#include <gdk-pixbuf/gdk-pixbuf.h><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("End-of-stream\n");<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, &err, &debug);<br>
g_free (debug);<br>
<br>
g_print("Error: %s\n", err->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 ("feed buffer");<br>
g_signal_emit_by_name (src, "push-buffer", buffer, &ret);<br>
<br>
<br>
if (ret != GST_FLOW_OK) {<br>
GST_DEBUG ("some error");<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,"vsink");<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(&argc, &argv);<br>
loop = g_main_loop_new(NULL, FALSE);<br>
<br>
<br>
pipeline = gst_pipeline_new("test-push-buffer");<br>
source = gst_element_factory_make("appsrc","source");<br>
decoder = gst_element_factory_make("x264enc","decoder");<br>
caps = gst_caps_new_simple ("video/x-raw-rgb",<br>
"bpp",G_TYPE_INT,24,<br>
"depth",G_TYPE_INT,24,<br>
"width", G_TYPE_INT, 640,<br>
"height", G_TYPE_INT, 480,<br>
NULL);<br>
<br>
video_sink = gst_element_factory_make("autovideosink","vsink");<br>
if(!pipeline || !source || ! video_sink || ! decoder)<br>
{<br>
g_print("Element creation Error\n");<br>
return -1;<br>
}<br>
<br>
gst_app_src_set_caps((GstAppSrc*)source, caps);<br>
g_signal_connect (source, "need-data", G_CALLBACK (feed), source);<br>
<br>
g_object_set(G_OBJECT(source), "caps", 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, "pad-added", G_CALLBACK(new_pad), NULL);<br>
<br>
g_print("Setting to Playing\n");<br>
gst_element_set_state(pipeline, GST_STATE_PLAYING);<br>
g_print("Running\n");<br>
g_main_loop_run(loop);<br>
<br>
<br>
g_print("Stop playback\n");<br>
gst_element_set_state(pipeline, GST_STATE_NULL);<br>
g_print("Delete Pipeline\n");<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>