unexpected result when writing to GstBuffer

longkas longkas at gmail.com
Thu Apr 18 06:32:12 UTC 2019


Hello,
I'm writing a simple test of appsrc, the appsrc generates 1x1 BGRA pixels
with framerate 1/1:

----------------------------------------
        GstCaps *srcCaps;
        srcCaps = gst_caps_new_simple("video/x-raw",
                                        "width", G_TYPE_INT, 1,
                                        "height", G_TYPE_INT, 1,
                                      "format", G_TYPE_STRING, "BGRA",
                                      "framerate", GST_TYPE_FRACTION, 1, 1,
                                        NULL);
        gst_app_src_set_caps(appSrc, srcCaps);
----------------------------------------

the need_data callback will push a red color pixel when be invoked, but it
displays pink instead of red color on the screen:

----------------------------------------
void  cb_need_data(GstAppSrc *src, guint length, gpointer user_data) {
    GstBuffer *buffer;
    guint8 data[] = {0, 0, 255, 255}; //red color in BGRA
    buffer = gst_buffer_new_and_alloc(4); // 4 bytes for 1x1 pixel
    gst_buffer_insert_memory(buffer,  0,
gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, &data[0], 4, 0, 4, NULL,
NULL)); 
    //set time and duration
    ...
}
----------------------------------------

if I write buffer one by one, I do get the red color as expected

----------------------------------------
        for(int i=0; i < 4; i++) {
            gst_buffer_memset(buffer, i, data[i], 1);
        }
----------------------------------------

need advice how to use gst_memory_new_wrapped, thanks






--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list