We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include <gst/gst.h> #include <gst/gstbin.h> #include struct CustomData { GstElement* pipeline; GMainLoop* loop; };
gboolean bus_call(GstBus* bus, GstMessage* msg, gpointer user_data) { CustomData* data = reinterpret_cast<CustomData*>(user_data);
GMainLoop* loop = data->loop; switch (GST_MESSAGE_TYPE(msg)) { case GST_MESSAGE_EOS: g_main_loop_quit(loop); break; case GST_MESSAGE_ERROR: { gchar* debug = NULL; GError* error = NULL; gst_message_parse_error(msg, &error, &debug); if (debug) { g_free(debug); } if (error) { g_error_free(error); } g_main_loop_quit(loop); break; } case GST_MESSAGE_STATE_CHANGED: { if (GST_MESSAGE_SRC(msg) == GST_OBJECT(data->pipeline)) { GstState old_state, new_state; gst_message_parse_state_changed( msg, &old_state, &new_state, NULL); } break; } default: break; } return TRUE;
}
GstFlowReturn user_function (GstElement* object, gpointer user_data) { printf("-------------new sample\n"); return GST_FLOW_OK; }
int main(int argc, char** argv) { CustomData data; GstBus *bus;
/* Initialize GStreamer */ gst_init(&argc, &argv); /* Build the pipeline */ data.pipeline = gst_parse_launch ("videotestsrc ! interpipesink name=sink0", NULL); GstElement* sink = gst_bin_get_by_name((GstBin*)data.pipeline, "sink0"); g_signal_connect(sink, "new-sample", G_CALLBACK(user_function), NULL); g_object_set(sink, "emit-signals", TRUE, NULL); data.loop = g_main_loop_new(NULL, false); bus = gst_pipeline_get_bus((GstPipeline*)data.pipeline); int bus_id_ = gst_bus_add_watch(bus, bus_call, &data); gst_element_set_state(data.pipeline, GST_STATE_PLAYING); g_main_loop_run(data.loop); gst_object_unref(bus); gst_element_set_state (data.pipeline, GST_STATE_NULL); gst_object_unref (data.pipeline); return 0;
The text was updated successfully, but these errors were encountered:
if I replace interpipesink with appsink, the new-sample signal can emit, and call the user_function
Sorry, something went wrong.
No branches or pull requests
#include <gst/gst.h>
#include <gst/gstbin.h>
#include
struct CustomData {
GstElement* pipeline;
GMainLoop* loop;
};
gboolean bus_call(GstBus* bus, GstMessage* msg, gpointer user_data) {
CustomData* data = reinterpret_cast<CustomData*>(user_data);
}
GstFlowReturn user_function (GstElement* object, gpointer user_data) {
printf("-------------new sample\n");
return GST_FLOW_OK;
}
int main(int argc, char** argv) {
CustomData data;
GstBus *bus;
}
The text was updated successfully, but these errors were encountered: