我试图使用SWIG将一些Gstreamer函数封装到PHP中,但我不知道如何处理C回调。我可以在C中调用PHP函数吗?你将如何处理下面这样的回调?
#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);
// ...
}发布于 2011-01-25 09:30:57
如果你下载最新的swig源码(2.0.1),有一个使用PHP回调的例子。它在swig 2.0.1/Examples/php/callback目录中。
https://stackoverflow.com/questions/4651619
复制相似问题