1
我想用SWIG将一些Gstreamer函数包装到PHP中,但我无法弄清楚如何处理C回调。我可以从C调用PHP函数吗?你将如何处理如下的回调?通过SWIG包装C回调
#include <gst/gst.h>
// ...
static gboolean my_callback(GstBus *bus, GstMessage *message, gpointer user_data) {
g_print("Got %s message\n", GST_MESSAGE_TYPE_NAME(message));
switch(GST_MESSAGE_TYPE(message)) {
// ...
}
return TRUE;
}
main(gint argc, gchar *argv[])
{
GstElement *pipeline;
GstBus *bus;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("my_pipeline");
/* add handler */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, my_bus_callback, NULL); // ------------<
gst_object_unref (bus);
// ...
}
感谢您的回答,但该示例使用C++ – Fuerteflojo 2011-01-26 10:29:35