I am trying to get data from a GstSample to process it in my app sink. But I cannot find a way to extract the data from a sample. I have set the callball function "new-sample":
static void GStPipeline::new_sample (GstAppSink *sink, CustomData *data) {
GstSample* sample;
sample = gst_app_sink_pull_sample(data->app_sink);
if (sample) {
data->sampleBuffer[data->num_samples] = sample;
data->num_samples++;
}
gst_sample_unref(sample);
}
Am I missing some basic concept? Is it true, that since gstreamer-1.0 I have to provide a callback "new-sample" instead of "pull-buffer" ? For my understanding, a buffer contains the samples.
I think you kind of got it right. The GstAppSink is pretty well documented about the callbacks. You just have to go a little further to access the data.
sample = gst_app_sink_pull_sample(sink)
buffer = gst_sample_get_buffer(sample)
gst_buffer_map(buffer, &info, GST_MAP_READ)
Where info
is of type GstMapInfo
. Your data is then found at
info.data
with a payload length of info.size
.