summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorVineeth T M <vineeth.tm@samsung.com>2015-07-07 19:55:44 +0900
committerLuis de Bethencourt <luis@debethencourt.com>2015-07-07 12:50:39 +0100
commitefdb0fc28181b86a340db933c5a9f0ca9ce92382 (patch)
tree501abbf88ae0e69b7676f353cc790dabde19d148 /sys
parenta1f8fb32cbb93094d98fd8aa267204e32424322c (diff)
downloadgst-plugins-base-efdb0fc28181b86a340db933c5a9f0ca9ce92382.tar.gz
gst-plugins-base-efdb0fc28181b86a340db933c5a9f0ca9ce92382.tar.xz
xvimagesink: refactor to use gst_pad_push_event
Right now navigation events are being sent via gst_pad_send_event after getting the peer pad of the sinkpad. But the same functionality can be done using gst_pad_push_event without need of getting peer pad in xvimagesink. https://bugzilla.gnome.org/show_bug.cgi?id=752059
Diffstat (limited to 'sys')
-rw-r--r--sys/xvimage/xvimagesink.c107
1 files changed, 51 insertions, 56 deletions
diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c
index 80b452bb9..bc9f6bf34 100644
--- a/sys/xvimage/xvimagesink.c
+++ b/sys/xvimage/xvimagesink.c
@@ -1112,75 +1112,70 @@ gst_xv_image_sink_navigation_send_event (GstNavigation * navigation,
GstStructure * structure)
{
GstXvImageSink *xvimagesink = GST_XV_IMAGE_SINK (navigation);
- GstPad *peer;
gboolean handled = FALSE;
GstEvent *event = NULL;
- if ((peer = gst_pad_get_peer (GST_VIDEO_SINK_PAD (xvimagesink)))) {
- GstVideoRectangle src = { 0, };
- GstVideoRectangle dst = { 0, };
- GstVideoRectangle result;
- gdouble x, y, xscale = 1.0, yscale = 1.0;
- GstXWindow *xwindow;
-
- /* We take the flow_lock while we look at the window */
- g_mutex_lock (&xvimagesink->flow_lock);
-
- if (!(xwindow = xvimagesink->xwindow)) {
- g_mutex_unlock (&xvimagesink->flow_lock);
- gst_object_unref (peer);
- return;
- }
+ GstVideoRectangle src = { 0, };
+ GstVideoRectangle dst = { 0, };
+ GstVideoRectangle result;
+ gdouble x, y, xscale = 1.0, yscale = 1.0;
+ GstXWindow *xwindow;
- if (xvimagesink->keep_aspect) {
- /* We get the frame position using the calculated geometry from _setcaps
- that respect pixel aspect ratios */
- src.w = GST_VIDEO_SINK_WIDTH (xvimagesink);
- src.h = GST_VIDEO_SINK_HEIGHT (xvimagesink);
- dst.w = xwindow->render_rect.w;
- dst.h = xwindow->render_rect.h;
-
- gst_video_sink_center_rect (src, dst, &result, TRUE);
- result.x += xwindow->render_rect.x;
- result.y += xwindow->render_rect.y;
- } else {
- memcpy (&result, &xwindow->render_rect, sizeof (GstVideoRectangle));
- }
+ /* We take the flow_lock while we look at the window */
+ g_mutex_lock (&xvimagesink->flow_lock);
+ if (!(xwindow = xvimagesink->xwindow)) {
g_mutex_unlock (&xvimagesink->flow_lock);
+ return;
+ }
- /* We calculate scaling using the original video frames geometry to include
- pixel aspect ratio scaling. */
- xscale = (gdouble) xvimagesink->video_width / result.w;
- yscale = (gdouble) xvimagesink->video_height / result.h;
-
- /* Converting pointer coordinates to the non scaled geometry */
- if (gst_structure_get_double (structure, "pointer_x", &x)) {
- x = MIN (x, result.x + result.w);
- x = MAX (x - result.x, 0);
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
- (gdouble) x * xscale, NULL);
- }
- if (gst_structure_get_double (structure, "pointer_y", &y)) {
- y = MIN (y, result.y + result.h);
- y = MAX (y - result.y, 0);
- gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
- (gdouble) y * yscale, NULL);
- }
+ if (xvimagesink->keep_aspect) {
+ /* We get the frame position using the calculated geometry from _setcaps
+ that respect pixel aspect ratios */
+ src.w = GST_VIDEO_SINK_WIDTH (xvimagesink);
+ src.h = GST_VIDEO_SINK_HEIGHT (xvimagesink);
+ dst.w = xwindow->render_rect.w;
+ dst.h = xwindow->render_rect.h;
- event = gst_event_new_navigation (structure);
- gst_event_ref (event);
- handled = gst_pad_send_event (peer, event);
- gst_object_unref (peer);
+ gst_video_sink_center_rect (src, dst, &result, TRUE);
+ result.x += xwindow->render_rect.x;
+ result.y += xwindow->render_rect.y;
+ } else {
+ memcpy (&result, &xwindow->render_rect, sizeof (GstVideoRectangle));
}
- if (!handled && event) {
- gst_element_post_message ((GstElement *) xvimagesink,
- gst_navigation_message_new_event ((GstObject *) xvimagesink, event));
+ g_mutex_unlock (&xvimagesink->flow_lock);
+
+ /* We calculate scaling using the original video frames geometry to include
+ pixel aspect ratio scaling. */
+ xscale = (gdouble) xvimagesink->video_width / result.w;
+ yscale = (gdouble) xvimagesink->video_height / result.h;
+
+ /* Converting pointer coordinates to the non scaled geometry */
+ if (gst_structure_get_double (structure, "pointer_x", &x)) {
+ x = MIN (x, result.x + result.w);
+ x = MAX (x - result.x, 0);
+ gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
+ (gdouble) x * xscale, NULL);
+ }
+ if (gst_structure_get_double (structure, "pointer_y", &y)) {
+ y = MIN (y, result.y + result.h);
+ y = MAX (y - result.y, 0);
+ gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
+ (gdouble) y * yscale, NULL);
}
- if (event)
+ event = gst_event_new_navigation (structure);
+ if (event) {
+ gst_event_ref (event);
+ handled = gst_pad_push_event (GST_VIDEO_SINK_PAD (xvimagesink), event);
+
+ if (!handled)
+ gst_element_post_message ((GstElement *) xvimagesink,
+ gst_navigation_message_new_event ((GstObject *) xvimagesink, event));
+
gst_event_unref (event);
+ }
}
static void