我正在学习GStreamer及其乐趣,但是我已经在使用wxWidgets时遇到了障碍。无论我尝试什么,我都无法突破。例如GTK / Qt仅对某些限制有帮助。这是当前代码(不起作用),下面是我得到的错误消息
wxGStreamer::wxGStreamer(wxWindow* parent, wxWindowID winid, const wxURI& location):wxPanel(parent, winid)
{
SetBackgroundColour(*wxBLACK);
/* Build the pipeline */
wxString uri = location.BuildURI();
wxPuts(uri);
// prepare the pipeline
GstElement *pipeline = gst_pipeline_new("xvoverlay");
GstElement *src = gst_element_factory_make("videotestsrc", NULL);
GstElement *sink = gst_element_factory_make("xvimagesink", NULL);
gst_bin_add_many(GST_BIN(pipeline), src, sink, NULL);
gst_element_link(src, sink);
/* Set the URI to play */
g_object_set (pipeline, "uri", "http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);
GtkWidget* widget = GetHandle();
guintptr video_window_handle = GDK_WINDOW_XID (gtk_widget_get_window (widget));
gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sink), video_window_handle);
// run the pipeline
GstStateChangeReturn sret = gst_element_set_state(pipeline,
GST_STATE_PLAYING);
if(sret == GST_STATE_CHANGE_FAILURE)
{
gst_element_set_state(pipeline, GST_STATE_NULL);
gst_object_unref(pipeline);
}
gst_element_set_state(pipeline, GST_STATE_NULL);
gst_object_unref(pipeline);
}
其中wxGStreamer定义为
class wxGStreamer : public wxPanel {............};
错误
答案 0 :(得分:1)
即使你不想使用它(为什么?),至少要看一下使用Unix下的GStreamer实现的wxMediaCtrl
。
答案 1 :(得分:0)
使用gst_bus_set_sync_handler添加同步处理程序,然后在该函数内部使用GstVideoOverlay将视频引导到您的小部件。这是一个工作样本函数。
static GstBusSyncReply
bus_sync(GstBus* bus, GstMessage* message, gpointer user_data)
{
CustomData* data = reinterpret_cast<CustomData*>(user_data);
if(!gst_is_video_overlay_prepare_window_handle_message(message))
return GST_BUS_PASS;
else
{
if(data->xid!=NULL)
{
GstVideoOverlay *overlay;
overlay = GST_VIDEO_OVERLAY(GST_MESSAGE_SRC(message));
gst_video_overlay_set_window_handle(overlay, data->xid);
}
return GST_BUS_DROP;
}
}