Error using gst_app_src_push_buffer while emitting signal works well.

Kat katnboykin at gmail.com
Wed Apr 29 01:40:50 UTC 2020


Hi,
I'm trying to use gst_app_src_push_buffer method but it causes error below.
As I know the difference between them is about ownership of buffer. Can it
be replaced each other?

----------
** (example:26934): CRITICAL **: 10:22:35.112: gst_video_frame_map_id:
assertion 'GST_IS_BUFFER (buffer)' failed

(example:26934): GStreamer-CRITICAL **: 10:22:35.112: gst_pad_push:
assertion 'GST_IS_BUFFER (buffer)' failed
----------
// NOT WORKING!
//    GstElement *source;
//    source = gst_bin_get_by_name (GST_BIN (data.sinkpipe), "appsrc");
//    gst_app_src_push_buffer (GST_APP_SRC (source), buffer);

// PUSH BUFFER WELL!
    GstFlowReturn *ret;
    g_signal_emit_by_name(data.sinkdata.source, "push-buffer", buffer,
&ret);
------



Let me add my whole code, just in case :)
-------
GstFlowReturn new_sample(GstAppSink *appsink, gpointer /*data*/)
{
    static int framecount = 0;

    // Get caps and frames
    GstSample *sample = gst_app_sink_pull_sample(appsink);
    GstCaps *caps = gst_sample_get_caps(sample);
    GstBuffer *buffer = gst_sample_get_buffer(sample);
    GstStructure *structure = gst_caps_get_structure(caps, 0);
    const int width = g_value_get_int(gst_structure_get_value(structure,
"width"));
    const int height = g_value_get_int(gst_structure_get_value(structure,
"height"));

    // every 30th frame
    if(!(framecount%30)) {
        printf("GST_BUFFER_PTS(buffer) %" GST_STIME_FORMAT "\n",
GST_STIME_ARGS(GST_BUFFER_PTS(buffer)));
    }
    framecount++;

    // Get frame data
    GstMapInfo map;
    gst_buffer_map(buffer, &map, GST_MAP_READ);

    // GStreamer data to Mat frame
    Mat *getFrame;
    getFrame = new Mat (cv::Size(width, height), CV_8UC3, (char*)map.data,
Mat::AUTO_STEP);
#ifdef IMAGE_PROCESS
    imageProcess(getFrame);
#endif
    getFrame->release();
    delete getFrame;

// NOT WORKING!
//    GstElement *source;
//    source = gst_bin_get_by_name (GST_BIN (data.sinkpipe), "appsrc");
//    gst_app_src_push_buffer (GST_APP_SRC (source), buffer);

// PUSH BUFFER WELL!
    GstFlowReturn *ret;
    g_signal_emit_by_name(data.sinkdata.source, "push-buffer", buffer,
&ret);

    //unref
    gst_buffer_unmap(buffer, &map);
    gst_sample_unref(sample);

    return GST_FLOW_OK;
}

I'm very new to GStreamer, so please give any comment if you see anything
wrong or more efficient way.
Thank you.



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


More information about the gstreamer-devel mailing list