Replacing videotestsrc with Playbin2 as video source
Stefano D. Mtangoo
mwinjilisti at gmail.com
Fri Mar 20 18:13:24 PDT 2015
Hi,
I have been playing with wxWidgets and Gst and I was unsuccesful for
some day. Thank God today I made it, but alas it was videotestsrc. Now
I want to test my code with real video/audio file and every attempt
have been furtile. Before I put my code below, let me say that am new
to Gst and that I use 1.x version
Thanks
my code
static GstBusSyncReply
create_window(GstBus * bus, GstMessage * message, gpointer user_data)
{
// ignore anything but 'prepare-window-handle' element messages
if(!gst_is_video_overlay_prepare_window_handle_message(message))
return GST_BUS_PASS;
CustomData *data = reinterpret_cast<CustomData*>(user_data);
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;
}
and wx thing
wxGStreamer::wxGStreamer(wxWindow* parent, wxWindowID id, const
wxString& uri) : wxPanel(parent, id)
{
SetBackgroundColour(*wxBLACK);
if(!g_thread_supported())
g_thread_init(NULL);
int i;
char **argv = new char*[wxTheApp->argc + 1];
for(i = 0; i < wxTheApp->argc; i++)
{
argv[i] = wxStrdupA(wxTheApp->argv[i].utf8_str());
}
argv[wxTheApp->argc] = NULL;
gst_init(&wxTheApp->argc, &argv);
// 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);
GtkWidget* video_window = GetHandle();
gtk_widget_realize(GetHandle());
GdkWindow *videoareaXwindow = gtk_widget_get_window(video_window);
guintptr xid = GDK_WINDOW_XID(videoareaXwindow);
// 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);
}
CustomData* data = new CustomData(xid);
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
gst_bus_set_sync_handler(bus, (GstBusSyncHandler) create_window, data,
NULL);
//gst_element_set_state(pipeline, GST_STATE_NULL);
//gst_object_unref(pipeline);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150321/172fc932/attachment.html>
More information about the gstreamer-devel
mailing list