why gst_x_overlay_set_render_rectangle don't work
LIDE
1053481745 at qq.com
Wed Apr 2 00:12:46 PDT 2014
I have problem with video render function gst_x_overlay_set_render_rectangle.
It returns TRUE,but have no
effect.The video plays in the full window app->win not my set render
rectangle.how to render video in the tectangle I set in the window?? sorry
with my poor English.
typedef struct _App
{
GstElement *playbin;
GstElement *appsrc; GstElement *xvimagesink;
GMainLoop *loop;
guint sourceid;
guint8 *data;
gsize length;
guint64 offset;
int fds[2];
Display *disp;
Window win;
}App;
typedef struct Rect{
int x;
int y;
int width;
int height;
}Rect;
static GstBusSyncReply create_window (GstBus * bus, GstMessage * message,
GstPipeline * pipeline)
{
if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
return GST_BUS_PASS;
if (!gst_structure_has_name (message->structure, "prepare-xwindow-id"))
return GST_BUS_PASS;
App *app = (App*) pipeline;
// GstXOverlay *overlay = GST_X_OVERLAY(app->xvimagesink);
GstXOverlay *overlay = GST_X_OVERLAY(GST_MESSAGE_SRC (message));
//app->xvimagesink = overlay;
//app->disp = XOpenDisplay(getenv("DISPALY"));
app->disp = XOpenDisplay(NULL);
Window win2;
XSync (app->disp, FALSE);
app->win = XCreateSimpleWindow (app->disp, XDefaultRootWindow(app->disp),
0, 0, 1440, 900, 0, 0, 0);
XMapRaised (app->disp, app->win);
//g_object_set (app->xvimagesink, "force-aspect-ratio", TRUE, NULL);
gst_x_overlay_set_window_handle (overlay, app->win);
#if 1
gboolean ret;
ret = gst_x_overlay_set_render_rectangle (overlay, 0, 0, 600,400);
if(ret)
printf("gst_x_overlay_set_render_rectangle success!!!\n");
g_object_set (G_OBJECT (GST_MESSAGE_SRC(message)), "force-aspect-ratio",
TRUE, NULL);
gst_x_overlay_expose(overlay);
#endif
gst_message_unref (message);
return GST_BUS_DROP;
}
static gboolean
bus_message (GstBus * bus, GstMessage * message, App * app)
{
GST_DEBUG ("got message %s",
gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ERROR:
g_error ("received error");
g_main_loop_quit (app->loop);
break;
#if 0
case GST_MESSAGE_ELEMENT:
if(gst_structure_has_name(message->structure,
"prepare-xwindow-id"))
{
GstXOverlay *xoverlay = NULL;
xoverlay = GST_X_OVERLAY (GST_MESSAGE_SRC (message));
app->disp = XOpenDisplay(NULL);
app->win = XCreateSimpleWindow (app->disp,
XDefaultRootWindow(app->disp), 0, 0, 1440, 900, 0, 0, 0);
//XMapWindow(app->disp, app->win);
XMapRaised (app->disp, app->win);
XSync (app->disp, FALSE);
gst_x_overlay_set_window_handle(xoverlay, app->win);
// gst_x_overlay_handle_events (xoverlay, FALSE);
if(gst_x_overlay_set_render_rectangle(xoverlay,
20,
20,
600,
400))
printf("render success\n\n");
gst_x_overlay_expose(xoverlay);
}
GstElement *element = GST_ELEMENT (GST_MESSAGE_SRC (message));
if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
"force-aspect-ratio")) {
printf("force-aspect-ratio\n");
g_object_set (element, "force-aspect-ratio", TRUE, NULL);
}
break;
#endif
case GST_MESSAGE_EOS:
/*g_error ("streamer eos");*/
printf("=====>get eos\n");
g_main_loop_quit (app->loop);
break;
default:
break;
}
return TRUE;
}
static void p_gst_init(void)
{
App *app = &s_app;
pipe(app->fds);
GError *error = NULL;
GstBus *bus;
gst_init (NULL, NULL);
/* create a mainloop to get messages */
app->loop = g_main_loop_new (NULL, TRUE);
app->playbin = gst_element_factory_make ("playbin2", NULL);
g_assert (app->playbin);
bus = gst_pipeline_get_bus (GST_PIPELINE (app->playbin));
/* add watch for messages */
gst_bus_add_watch (bus, (GstBusFunc) bus_message, app);
// gst_bus_set_sync_handler(bus, (GstBusSyncHandler)create_window,
app->playbin);
/* set to read from appsrc */
g_object_set (app->playbin, "uri", "appsrc://", NULL);
app->xvimagesink = gst_element_factory_make ("xvimagesink", NULL);
g_object_set (app->playbin, "video-sink", app->xvimagesink, NULL);
gst_object_unref (bus);
/* get notification when the source is created so that we get a handle to
it
* and can configure it */
g_signal_connect (app->playbin, "deep-notify::source",
(GCallback) found_source, app);
return ;
}
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/why-gst-x-overlay-set-render-rectangle-don-t-work-tp4666241.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list