Reputation:
I'm implementing gstreamer media player with my own source of data using appsrc
. Everything works fine except one thing:
When stream reaches it's end, callback emits "end-of-stream"
signal. Signals sending fucntion
g_signal_emit_by_name(appsrc, "end-of-stream", &ret)
returns GstFlowReturn
value GST_FLOW_OK
. But then it calls need-data
my callback again, so it returns "end-of-stream"
signal again. And this time GstFlowReturn
value is (-3)
which is GST_FLOW UNEXPECTED
. I assume that it does not expect "end-of-stream"
signal when it already recieved one, but why it requests more data than? Maybe it is because I didn't set size
value iof the steam?
Gstreamer version is 0.10.
Callback function code (appsrc
type is seekable btw):
static void cb_need_data (GstElement *appsrc, guint size, gpointer user_data)
{
GstBuffer *buffer;
GstFlowReturn ret;
AppsrcData* data = static_cast<AppsrcData*>(user_data);
buffer = gst_buffer_new_and_alloc(size);
int read = fread(GST_BUFFER_DATA(buffer), 1, size, data->file);
GST_BUFFER_SIZE(buffer) = read;
g_signal_emit_by_name (appsrc, "push-buffer", buffer, &ret);
if (ret != GST_FLOW_OK) {
/* something wrong, stop pushing */
g_printerr("GST_FLOW != OK, return value is %d\n", ret);
g_main_loop_quit (data->loop);
}
if(feof(data->file) || read == 0)
{
g_signal_emit_by_name(appsrc, "end-of-stream", &ret);
if (ret != GST_FLOW_OK) {
g_printerr("EOF reached, GST_FLOW != OK, return value is %d\nAborting...", ret);
g_main_loop_quit (data->loop);
}
}
}
Upvotes: 2
Views: 3113
Reputation: 3378
Have you tried the method gst_app_src_end_of_stream()? I'm not sure what return code you should use after invoking it, but it should be either GST_FLOW_OK or GST_FLOW_UNEXPECTED.
In GStreamer 1.x you return GST_FLOW_EOS.
Upvotes: 0
Reputation: 7566
You should provide some corrections to your code(if they are not there already) that should alleviate your issue and help the overall application:
Upvotes: 1