mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-03 13:02:29 +00:00
Making XShm code shorter.
Original commit message from CVS: Making XShm code shorter. Fixing some mem leaks. Reverting some changes about depth and sinkconnect that need to be discussed.
This commit is contained in:
parent
44ef75e2e7
commit
94e402ef83
2 changed files with 32 additions and 62 deletions
|
@ -155,15 +155,12 @@ gst_ximagesink_ximage_destroy (GstXImageSink *ximagesink, GstXImage *ximage)
|
|||
shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_XSHM */
|
||||
{
|
||||
if (ximage->ximage)
|
||||
XDestroyImage (ximage->ximage);
|
||||
}
|
||||
#else
|
||||
if (ximage->ximage)
|
||||
XDestroyImage (ximage->ximage);
|
||||
#endif /* HAVE_XSHM */
|
||||
|
||||
|
||||
g_mutex_unlock (ximagesink->x_lock);
|
||||
|
||||
g_free (ximage);
|
||||
|
@ -193,16 +190,12 @@ gst_ximagesink_ximage_put (GstXImageSink *ximagesink, GstXImage *ximage)
|
|||
FALSE);
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_XSHM */
|
||||
{
|
||||
XPutImage (ximagesink->xcontext->disp, ximagesink->xwindow->win,
|
||||
ximagesink->xwindow->gc, ximage->ximage,
|
||||
0, 0, x, y, ximage->width, ximage->height);
|
||||
}
|
||||
#else
|
||||
XPutImage (ximagesink->xcontext->disp, ximagesink->xwindow->win,
|
||||
ximagesink->xwindow->gc, ximage->ximage,
|
||||
0, 0, x, y, ximage->width, ximage->height);
|
||||
#endif /* HAVE_XSHM */
|
||||
|
||||
XSync(ximagesink->xcontext->disp, FALSE);
|
||||
|
||||
|
@ -311,7 +304,7 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
|
|||
r = gst_pad_try_set_caps (GST_VIDEOSINK_PAD (ximagesink),
|
||||
GST_CAPS_NEW ("ximagesink_ximage_caps", "video/x-raw-rgb",
|
||||
"bpp", GST_PROPS_INT (ximagesink->xcontext->bpp),
|
||||
//"depth", GST_PROPS_INT (ximagesink->xcontext->depth),
|
||||
"depth", GST_PROPS_INT (ximagesink->xcontext->depth),
|
||||
"endianness", GST_PROPS_INT (G_BIG_ENDIAN),
|
||||
"red_mask", GST_PROPS_INT (GINT_FROM_BE (ximagesink->xcontext->visual->red_mask)),
|
||||
"green_mask", GST_PROPS_INT (GINT_FROM_BE (ximagesink->xcontext->visual->green_mask)),
|
||||
|
@ -458,7 +451,7 @@ gst_ximagesink_xcontext_get (GstXImageSink *ximagesink)
|
|||
|
||||
xcontext->caps = GST_CAPS_NEW ("ximagesink_ximage_caps", "video/x-raw-rgb",
|
||||
"bpp", GST_PROPS_INT (xcontext->bpp),
|
||||
//"depth", GST_PROPS_INT (xcontext->depth),
|
||||
"depth", GST_PROPS_INT (xcontext->depth),
|
||||
"endianness", GST_PROPS_INT (G_BIG_ENDIAN),
|
||||
"red_mask", GST_PROPS_INT (GINT_FROM_BE (xcontext->visual->red_mask)),
|
||||
"green_mask", GST_PROPS_INT (GINT_FROM_BE (xcontext->visual->green_mask)),
|
||||
|
@ -517,8 +510,7 @@ static GstPadLinkReturn
|
|||
gst_ximagesink_sinkconnect (GstPad *pad, GstCaps *caps)
|
||||
{
|
||||
GstXImageSink *ximagesink;
|
||||
gint check;
|
||||
G_GNUC_UNUSED gchar *str;
|
||||
char *caps_str1, *caps_str2;
|
||||
|
||||
ximagesink = GST_XIMAGESINK (gst_pad_get_parent (pad));
|
||||
|
||||
|
@ -530,27 +522,16 @@ gst_ximagesink_sinkconnect (GstPad *pad, GstCaps *caps)
|
|||
if (!ximagesink->xcontext)
|
||||
return GST_PAD_LINK_DELAYED;
|
||||
|
||||
str = gst_caps_to_string(ximagesink->xcontext->caps);
|
||||
GST_DEBUG ("sinkconnect %s with %s", gst_caps_to_string(caps),
|
||||
str);
|
||||
g_free (str);
|
||||
if (!gst_caps_get_int (caps, "blue_mask", &check) ||
|
||||
check != GINT_FROM_BE (ximagesink->xcontext->visual->blue_mask))
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
if (!gst_caps_get_int (caps, "green_mask", &check) ||
|
||||
check != GINT_FROM_BE (ximagesink->xcontext->visual->green_mask))
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
if (!gst_caps_get_int (caps, "red_mask", &check) ||
|
||||
check != GINT_FROM_BE (ximagesink->xcontext->visual->red_mask))
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
if (!gst_caps_get_int (caps, "bpp", &check) ||
|
||||
check != ximagesink->xcontext->bpp)
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
/* disable, because bpp check is enough
|
||||
if (!gst_caps_get_int (caps, "depth", &check) ||
|
||||
check != ximagesink->xcontext->depth)
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
*/
|
||||
caps_str1 = gst_caps_to_string (ximagesink->xcontext->caps);
|
||||
caps_str2 = gst_caps_to_string (caps);
|
||||
|
||||
GST_DEBUG ("sinkconnect %s with %s", caps_str1, caps_str2);
|
||||
|
||||
if (caps_str1)
|
||||
g_free (caps_str1);
|
||||
if (caps_str2)
|
||||
g_free (caps_str2);
|
||||
|
||||
if (!gst_caps_get_int (caps, "width", &(GST_VIDEOSINK_WIDTH (ximagesink))))
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
if (!gst_caps_get_int (caps, "height", &(GST_VIDEOSINK_HEIGHT (ximagesink))))
|
||||
|
|
|
@ -102,6 +102,7 @@ gst_xvimagesink_xvimage_new (GstXvImageSink *xvimagesink,
|
|||
XShmAttach (xvimagesink->xcontext->disp, &xvimage->SHMInfo);
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_XSHM */
|
||||
{
|
||||
xvimage->xvimage = XvCreateImage (xvimagesink->xcontext->disp,
|
||||
xvimagesink->xcontext->xv_port_id,
|
||||
|
@ -111,16 +112,7 @@ gst_xvimagesink_xvimage_new (GstXvImageSink *xvimagesink,
|
|||
|
||||
xvimage->data = g_malloc (xvimage->xvimage->data_size);
|
||||
}
|
||||
#else
|
||||
xvimage->xvimage = XvCreateImage (xvimagesink->xcontext->disp,
|
||||
xvimagesink->xcontext->xv_port_id,
|
||||
xvimagesink->xcontext->im_format,
|
||||
xvimage->data,
|
||||
xvimage->width, xvimage->height);
|
||||
|
||||
xvimage->data = g_malloc (xvimage->xvimage->data_size);
|
||||
#endif /* HAVE_XSHM */
|
||||
|
||||
|
||||
if (xvimage->xvimage)
|
||||
{
|
||||
XSync(xvimagesink->xcontext->disp, 0);
|
||||
|
@ -167,15 +159,12 @@ gst_xvimagesink_xvimage_destroy (GstXvImageSink *xvimagesink,
|
|||
shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_XSHM */
|
||||
{
|
||||
if (xvimage->xvimage)
|
||||
XFree (xvimage->xvimage);
|
||||
}
|
||||
#else
|
||||
if (xvimage->xvimage)
|
||||
XFree (xvimage->xvimage);
|
||||
#endif /* HAVE_XSHM */
|
||||
|
||||
|
||||
g_mutex_unlock (xvimagesink->x_lock);
|
||||
|
||||
g_free (xvimage);
|
||||
|
@ -204,6 +193,7 @@ gst_xvimagesink_xvimage_put (GstXvImageSink *xvimagesink, GstXvImage *xvimage)
|
|||
xvimagesink->xwindow->height, FALSE);
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_XSHM */
|
||||
{
|
||||
XvPutImage (xvimagesink->xcontext->disp,
|
||||
xvimagesink->xcontext->xv_port_id,
|
||||
|
@ -213,15 +203,6 @@ gst_xvimagesink_xvimage_put (GstXvImageSink *xvimagesink, GstXvImage *xvimage)
|
|||
0, 0, xvimagesink->xwindow->width,
|
||||
xvimagesink->xwindow->height);
|
||||
}
|
||||
#else
|
||||
XvPutImage (xvimagesink->xcontext->disp,
|
||||
xvimagesink->xcontext->xv_port_id,
|
||||
xvimagesink->xwindow->win,
|
||||
xvimagesink->xwindow->gc, xvimage->xvimage,
|
||||
0, 0, xvimage->width, xvimage->height,
|
||||
0, 0, xvimagesink->xwindow->width,
|
||||
xvimagesink->xwindow->height);
|
||||
#endif /* HAVE_XSHM */
|
||||
|
||||
XSync(xvimagesink->xcontext->disp, FALSE);
|
||||
|
||||
|
@ -604,6 +585,7 @@ static GstPadLinkReturn
|
|||
gst_xvimagesink_sinkconnect (GstPad *pad, GstCaps *caps)
|
||||
{
|
||||
GstXvImageSink *xvimagesink;
|
||||
char *caps_str1, *caps_str2;
|
||||
|
||||
xvimagesink = GST_XVIMAGESINK (gst_pad_get_parent (pad));
|
||||
|
||||
|
@ -612,9 +594,16 @@ gst_xvimagesink_sinkconnect (GstPad *pad, GstCaps *caps)
|
|||
return GST_PAD_LINK_DELAYED;
|
||||
if (GST_CAPS_IS_CHAINED (caps))
|
||||
return GST_PAD_LINK_DELAYED;
|
||||
|
||||
GST_DEBUG ("sinkconnect %s with %s", gst_caps_to_string(caps),
|
||||
gst_caps_to_string(xvimagesink->xcontext->caps));
|
||||
|
||||
caps_str1 = gst_caps_to_string (xvimagesink->xcontext->caps);
|
||||
caps_str2 = gst_caps_to_string (caps);
|
||||
|
||||
GST_DEBUG ("sinkconnect %s with %s", caps_str1, caps_str2);
|
||||
|
||||
if (caps_str1)
|
||||
g_free (caps_str1);
|
||||
if (caps_str2)
|
||||
g_free (caps_str2);
|
||||
|
||||
if (!gst_caps_get_int (caps, "width", &(GST_VIDEOSINK_WIDTH (xvimagesink))))
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
|
|
Loading…
Reference in a new issue