I'm learning GStreamer and its fun, but I have hit a wall in using it with wxWidgets. No matter what I try I cannot break through. Examples out there are GTK/Qt which are helpful only to some limits. Here is Current code (which does not work) and below it error messages I get
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);
}
where wxGStreamer is defined as
class wxGStreamer : public wxPanel {............};
Errors
即使您不想只使用它(为什么?),也至少要看看wxMediaCtrl
(在Unix下使用GStreamer实现)做什么。
Add sync handler using gst_bus_set_sync_handler and then inside that function use GstVideoOverlay to channel video to your widget. Here is a working sample function.
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;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.