Add tedious documentation.

This commit is contained in:
gb 2010-03-19 15:45:21 +00:00
parent 9a1741a193
commit d63f196c73
18 changed files with 962 additions and 38 deletions

View file

@ -18,6 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* SECTION:gst-vaapi-display
* @short_description:
*/
#include "config.h"
#include "gstvaapiutils.h"
#include "gstvaapidisplay.h"
@ -417,6 +422,15 @@ gst_vaapi_display_init(GstVaapiDisplay *display)
g_static_mutex_init(&priv->mutex);
}
/**
* gst_vaapi_display_new_with_display:
* @va_display: a #VADisplay
*
* Creates a new #GstVaapiDisplay, using @va_display as the VA
* display.
*
* Return value: the newly created #GstVaapiDisplay object
*/
GstVaapiDisplay *
gst_vaapi_display_new_with_display(VADisplay va_display)
{
@ -425,6 +439,14 @@ gst_vaapi_display_new_with_display(VADisplay va_display)
NULL);
}
/**
* gst_vaapi_display_lock:
* @display: a #GstVaapiDisplay
*
* Locks @display. If @display is already locked by another thread,
* the current thread will block until @display is unlocked by the
* other thread.
*/
void
gst_vaapi_display_lock(GstVaapiDisplay *display)
{
@ -437,6 +459,14 @@ gst_vaapi_display_lock(GstVaapiDisplay *display)
klass->lock_display(display);
}
/**
* gst_vaapi_display_unlock:
* @display: a #GstVaapiDisplay
*
* Unlocks @display. If another thread is blocked in a
* gst_vaapi_display_lock() call for @display, it will be woken and
* can lock @display itself.
*/
void
gst_vaapi_display_unlock(GstVaapiDisplay *display)
{
@ -449,6 +479,14 @@ gst_vaapi_display_unlock(GstVaapiDisplay *display)
klass->unlock_display(display);
}
/**
* gst_vaapi_display_get_display:
* @display: a #GstVaapiDisplay
*
* Returns the #VADisplay bound to @display.
*
* Return value: the #VADisplay
*/
VADisplay
gst_vaapi_display_get_display(GstVaapiDisplay *display)
{
@ -457,6 +495,15 @@ gst_vaapi_display_get_display(GstVaapiDisplay *display)
return display->priv->display;
}
/**
* gst_vaapi_display_has_profile:
* @display: a #GstVaapiDisplay
* @profile: a #VAProfile
*
* Returns whether VA @display supports @profile.
*
* Return value: %TRUE if VA @display supports @profile
*/
gboolean
gst_vaapi_display_has_profile(GstVaapiDisplay *display, VAProfile profile)
{
@ -465,6 +512,22 @@ gst_vaapi_display_has_profile(GstVaapiDisplay *display, VAProfile profile)
return find_profile(display->priv->profiles, profile);
}
/**
* gst_vaapi_display_get_image_caps:
* @display: a #GstVaapiDisplay
*
* Gets the supported image formats for gst_vaapi_surface_get_image()
* or gst_vaapi_surface_put_image() as #GstCaps capabilities.
*
* Note that this method does not necessarily map image formats
* returned by vaQueryImageFormats(). The set of capabilities can be
* stripped down, if gstreamer-vaapi does not support the format, or
* expanded to cover compatible formats not exposed by the underlying
* driver. e.g. I420 can be supported even if the driver only exposes
* YV12.
*
* Return value: a newly allocated #GstCaps object, possibly empty
*/
GstCaps *
gst_vaapi_display_get_image_caps(GstVaapiDisplay *display)
{
@ -473,6 +536,15 @@ gst_vaapi_display_get_image_caps(GstVaapiDisplay *display)
return get_caps(display->priv->image_formats);
}
/**
* gst_vaapi_display_has_image_format:
* @display: a #GstVaapiDisplay
* @format: a #GstVaapiFormat
*
* Returns whether VA @display supports @format image format.
*
* Return value: %TRUE if VA @display supports @format image format
*/
gboolean
gst_vaapi_display_has_image_format(
GstVaapiDisplay *display,
@ -485,6 +557,19 @@ gst_vaapi_display_has_image_format(
return find_format(display->priv->image_formats, format);
}
/**
* gst_vaapi_display_get_subpicture_caps:
* @display: a #GstVaapiDisplay
*
* Gets the supported subpicture formats as #GstCaps capabilities.
*
* Note that this method does not necessarily map subpicture formats
* returned by vaQuerySubpictureFormats(). The set of capabilities can
* be stripped down if gstreamer-vaapi does not support the
* format. e.g. this is the case for paletted formats like IA44.
*
* Return value: a newly allocated #GstCaps object, possibly empty
*/
GstCaps *
gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display)
{
@ -493,6 +578,15 @@ gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display)
return get_caps(display->priv->subpicture_formats);
}
/**
* gst_vaapi_display_has_subpicture_format:
* @display: a #GstVaapiDisplay
* @format: a #GstVaapiFormat
*
* Returns whether VA @display supports @format subpicture format.
*
* Return value: %TRUE if VA @display supports @format subpicture format
*/
gboolean
gst_vaapi_display_has_subpicture_format(
GstVaapiDisplay *display,

View file

@ -51,12 +51,30 @@ G_BEGIN_DECLS
GST_VAAPI_TYPE_DISPLAY, \
GstVaapiDisplayClass))
/**
* GST_VAAPI_DISPLAY_VADISPLAY:
* @display: a #GstVaapiDisplay
*
* Macro that evaluates to the #VADisplay bound to @display
*/
#define GST_VAAPI_DISPLAY_VADISPLAY(display) \
gst_vaapi_display_get_display(display)
/**
* GST_VAAPI_DISPLAY_LOCK:
* @display: a #GstVaapiDisplay
*
* Locks @display
*/
#define GST_VAAPI_DISPLAY_LOCK(display) \
gst_vaapi_display_lock(display)
/**
* GST_VAAPI_DISPLAY_UNLOCK:
* @display: a #GstVaapiDisplay
*
* Unlocks @display
*/
#define GST_VAAPI_DISPLAY_UNLOCK(display) \
gst_vaapi_display_unlock(display)
@ -64,13 +82,29 @@ typedef struct _GstVaapiDisplay GstVaapiDisplay;
typedef struct _GstVaapiDisplayPrivate GstVaapiDisplayPrivate;
typedef struct _GstVaapiDisplayClass GstVaapiDisplayClass;
/**
* GstVaapiDisplay:
*
* Base class for VA displays.
*/
struct _GstVaapiDisplay {
/*< private >*/
GObject parent_instance;
/*< private >*/
GstVaapiDisplayPrivate *priv;
};
/**
* GstVaapiDisplayClass:
* @open_display: virtual function to open a display
* @close_display: virtual function to close a display
* @lock_display: virtual function to lock a display
* @unlock_display: virtual function to unlock a display
* @get_display: virtual function to retrieve the #VADisplay
*
* Base class for VA displays.
*/
struct _GstVaapiDisplayClass {
/*< private >*/
GObjectClass parent_class;

View file

@ -18,6 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* SECTION:gst-vaapi-display-x11
* @short_description:
*/
#include "config.h"
#include "gstvaapiutils.h"
#include "gstvaapidisplay_x11.h"
@ -189,6 +194,12 @@ gst_vaapi_display_x11_class_init(GstVaapiDisplayX11Class *klass)
dpy_class->close_display = gst_vaapi_display_x11_close_display;
dpy_class->get_display = gst_vaapi_display_x11_get_va_display;
/**
* GstVaapiDisplayX11:x11-display:
*
* The X11 #Display that was created by gst_vaapi_display_x11_new()
* or that was bound from gst_vaapi_display_x11_new_with_display().
*/
g_object_class_install_property
(object_class,
PROP_X11_DISPLAY,
@ -197,6 +208,11 @@ gst_vaapi_display_x11_class_init(GstVaapiDisplayX11Class *klass)
"X11 display",
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
/**
* GstVaapiDisplayX11:display-name:
*
* The X11 display name.
*/
g_object_class_install_property
(object_class,
PROP_DISPLAY_NAME,
@ -218,6 +234,16 @@ gst_vaapi_display_x11_init(GstVaapiDisplayX11 *display)
priv->display_name = NULL;
}
/**
* gst_vaapi_display_x11_new:
* @display_name: the X11 display name
*
* Opens an X11 #Display using @display_name and returns a newly
* allocated #GstVaapiDisplay object. The X11 display will be cloed
* when the reference count of the object reaches zero.
*
* Return value: a newly allocated #GstVaapiDisplay object
*/
GstVaapiDisplay *
gst_vaapi_display_x11_new(const gchar *display_name)
{
@ -226,6 +252,17 @@ gst_vaapi_display_x11_new(const gchar *display_name)
NULL);
}
/**
* gst_vaapi_display_x11_new_with_display:
* @x11_display: an X11 #Display
*
* Creates a #GstVaapiDisplay based on the X11 @x11_display
* display. The caller still owns the display and must call
* XCloseDisplay() when all #GstVaapiDisplay references are
* released. Doing so too early can yield undefined behaviour.
*
* Return value: a newly allocated #GstVaapiDisplay object
*/
GstVaapiDisplay *
gst_vaapi_display_x11_new_with_display(Display *x11_display)
{
@ -234,6 +271,16 @@ gst_vaapi_display_x11_new_with_display(Display *x11_display)
NULL);
}
/**
* gst_vaapi_display_x11_get_display:
* @display: a #GstVaapiDisplayX11
*
* Returns the underlying X11 #Display that was created by
* gst_vaapi_display_x11_new() or that was bound from
* gst_vaapi_display_x11_new_with_display().
*
* Return value: the X11 #Display attached to @display
*/
Display *
gst_vaapi_display_x11_get_display(GstVaapiDisplayX11 *display)
{

View file

@ -50,6 +50,12 @@ G_BEGIN_DECLS
GST_VAAPI_TYPE_DISPLAY_X11, \
GstVaapiDisplayX11Class))
/**
* GST_VAAPI_DISPLAY_XDISPLAY:
* @display: a #GstVaapiDisplay
*
* Macro that evaluates to the underlying X11 #Display of @display
*/
#define GST_VAAPI_DISPLAY_XDISPLAY(display) \
gst_vaapi_display_x11_get_display(GST_VAAPI_DISPLAY_X11(display))
@ -57,13 +63,25 @@ typedef struct _GstVaapiDisplayX11 GstVaapiDisplayX11;
typedef struct _GstVaapiDisplayX11Private GstVaapiDisplayX11Private;
typedef struct _GstVaapiDisplayX11Class GstVaapiDisplayX11Class;
/**
* GstVaapiDisplayX11:
*
* VA/X11 display wrapper.
*/
struct _GstVaapiDisplayX11 {
/*< private >*/
GstVaapiDisplay parent_instance;
/*< private >*/
GstVaapiDisplayX11Private *priv;
};
/**
* GstVaapiDisplayX11Class:
*
* VA/X11 display wrapper clas.
*/
struct _GstVaapiDisplayX11Class {
/*< private >*/
GstVaapiDisplayClass parent_class;

View file

@ -18,6 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* SECTION:gst-vaapi-image
* @short_description:
*/
#include "config.h"
#include <string.h>
#include "gstvaapiutils.h"
@ -351,12 +356,17 @@ gst_vaapi_image_class_init(GstVaapiImageClass *klass)
object_class->get_property = gst_vaapi_image_get_property;
object_class->constructed = gst_vaapi_image_constructed;
/**
* GstVaapiImage:display:
*
* The #GstVaapiDisplay this image is bound to.
*/
g_object_class_install_property
(object_class,
PROP_DISPLAY,
g_param_spec_object("display",
"display",
"GStreamer Va display",
"Display",
"The GstVaapiDisplay this image is bound to",
GST_VAAPI_TYPE_DISPLAY,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
@ -365,16 +375,21 @@ gst_vaapi_image_class_init(GstVaapiImageClass *klass)
PROP_IMAGE,
g_param_spec_boxed("image",
"Image",
"The VA image",
"The underlying VA image",
VAAPI_TYPE_IMAGE,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
/**
* GstVaapiImage:id:
*
* The underlying #VAImageID of the image.
*/
g_object_class_install_property
(object_class,
PROP_IMAGE_ID,
g_param_spec_uint("id",
"VA image id",
"VA image id",
"The underlying VA image id",
0, G_MAXUINT32, VA_INVALID_ID,
G_PARAM_READABLE));
@ -383,7 +398,7 @@ gst_vaapi_image_class_init(GstVaapiImageClass *klass)
PROP_WIDTH,
g_param_spec_uint("width",
"width",
"Image width",
"The image width",
0, G_MAXUINT32, 0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
@ -391,17 +406,22 @@ gst_vaapi_image_class_init(GstVaapiImageClass *klass)
(object_class,
PROP_HEIGHT,
g_param_spec_uint("height",
"height",
"Image height",
"heighr",
"The image height",
0, G_MAXUINT32, 0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
/**
* GstVaapiImage:format:
*
* The #GstVaapiImageFormat of the image
*/
g_object_class_install_property
(object_class,
PROP_FORMAT,
g_param_spec_uint("format",
"format",
"Image format",
"Format",
"The underlying image format",
0, G_MAXUINT32, 0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
}
@ -431,6 +451,18 @@ gst_vaapi_image_init(GstVaapiImage *image)
priv->image.buf = VA_INVALID_ID;
}
/**
* gst_vaapi_image_new:
* @display: a #GstVaapiDisplay
* @format: a #GstVaapiImageFormat
* @width: the requested image width
* @height: the requested image height
*
* Creates a new #GstVaapiImage with the specified format and
* dimensions.
*
* Return value: the newly allocated #GstVaapiImage object
*/
GstVaapiImage *
gst_vaapi_image_new(
GstVaapiDisplay *display,
@ -466,6 +498,18 @@ gst_vaapi_image_new(
return image;
}
/**
* gst_vaapi_image_new_with_image:
* @display: a #GstVaapiDisplay
* @va_image: a VA image
*
* Creates a new #GstVaapiImage from a foreign VA image. The image
* format and dimensions will be extracted from @va_image. This
* function is mainly used by gst_vaapi_surface_derive_image() to bind
* a VA image to a #GstVaapiImage object.
*
* Return value: the newly allocated #GstVaapiImage object
*/
GstVaapiImage *
gst_vaapi_image_new_with_image(GstVaapiDisplay *display, VAImage *va_image)
{
@ -497,6 +541,14 @@ gst_vaapi_image_new_with_image(GstVaapiDisplay *display, VAImage *va_image)
return image;
}
/**
* gst_vaapi_image_get_id:
* @image: a #GstVaapiImage
*
* Returns the underlying VAImageID of the @image.
*
* Return value: the underlying VA image id
*/
VAImageID
gst_vaapi_image_get_id(GstVaapiImage *image)
{
@ -506,6 +558,15 @@ gst_vaapi_image_get_id(GstVaapiImage *image)
return image->priv->image.image_id;
}
/**
* gst_vaapi_image_get_image:
* @image: a #GstVaapiImage
* @va_image: (output): a VA image
*
* Fills @va_image with the VA image used internally.
*
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_image_get_image(GstVaapiImage *image, VAImage *va_image)
{
@ -518,6 +579,20 @@ gst_vaapi_image_get_image(GstVaapiImage *image, VAImage *va_image)
return TRUE;
}
/*
* _gst_vaapi_image_set_image:
* @image: a #GstVaapiImage
* @va_image: a VA image
*
* Initializes #GstVaapiImage with a foreign VA image. This function
* will try to "linearize" the VA image. i.e. making sure that the VA
* image offsets into the data buffer are in increasing order with the
* number of planes available in the image.
*
* This is an internal function used by gst_vaapi_image_new_with_image().
*
* Return value: %TRUE on success
*/
gboolean
_gst_vaapi_image_set_image(GstVaapiImage *image, const VAImage *va_image)
{
@ -573,6 +648,14 @@ _gst_vaapi_image_set_image(GstVaapiImage *image, const VAImage *va_image)
return TRUE;
}
/**
* gst_vaapi_image_get_display:
* @image: a #GstVaapiImage
*
* Returns the #GstVaapiDisplay this @image is bound to.
*
* Return value: the parent #GstVaapiDisplay object
*/
GstVaapiDisplay *
gst_vaapi_image_get_display(GstVaapiImage *image)
{
@ -582,6 +665,14 @@ gst_vaapi_image_get_display(GstVaapiImage *image)
return image->priv->display;
}
/**
* gst_vaapi_image_get_format:
* @image: a #GstVaapiImage
*
* Returns the #GstVaapiImageFormat the @image was created with.
*
* Return value: the #GstVaapiImageFormat
*/
GstVaapiImageFormat
gst_vaapi_image_get_format(GstVaapiImage *image)
{
@ -591,6 +682,14 @@ gst_vaapi_image_get_format(GstVaapiImage *image)
return image->priv->format;
}
/**
* gst_vaapi_image_get_width:
* @image: a #GstVaapiImage
*
* Returns the @image width.
*
* Return value: the image width, in pixels
*/
guint
gst_vaapi_image_get_width(GstVaapiImage *image)
{
@ -600,6 +699,14 @@ gst_vaapi_image_get_width(GstVaapiImage *image)
return image->priv->width;
}
/**
* gst_vaapi_image_get_height:
* @image: a #GstVaapiImage
*
* Returns the @image height.
*
* Return value: the image height, in pixels.
*/
guint
gst_vaapi_image_get_height(GstVaapiImage *image)
{
@ -609,6 +716,14 @@ gst_vaapi_image_get_height(GstVaapiImage *image)
return image->priv->height;
}
/**
* gst_vaapi_image_get_size:
* @image: a #GstVaapiImage
* @pwidth: (out) (allow-none): return location for the width, or %NULL
* @pheight: (out) (allow-none): return location for the height, or %NULL
*
* Retrieves the dimensions of a #GstVaapiImage.
*/
void
gst_vaapi_image_get_size(GstVaapiImage *image, guint *pwidth, guint *pheight)
{
@ -622,6 +737,16 @@ gst_vaapi_image_get_size(GstVaapiImage *image, guint *pwidth, guint *pheight)
*pheight = image->priv->height;
}
/**
* gst_vaapi_image_is_linear:
* @image: a #GstVaapiImage
*
* Checks whether the @image has data planes allocated from a single
* buffer and offsets into that buffer are in increasing order with
* the number of planes.
*
* Return value: %TRUE if image data planes are allocated from a single buffer
*/
gboolean
gst_vaapi_image_is_linear(GstVaapiImage *image)
{
@ -631,6 +756,14 @@ gst_vaapi_image_is_linear(GstVaapiImage *image)
return image->priv->is_linear;
}
/**
* gst_vaapi_image_is_mapped:
* @image: a #GstVaapiImage
*
* Checks whether the @image is currently mapped or not.
*
* Return value: %TRUE if the @image is mapped
*/
static inline gboolean
_gst_vaapi_image_is_mapped(GstVaapiImage *image)
{
@ -646,6 +779,15 @@ gst_vaapi_image_is_mapped(GstVaapiImage *image)
return _gst_vaapi_image_is_mapped(image);
}
/**
* gst_vaapi_image_map:
* @image: a #GstVaapiImage
*
* Maps the image data buffer. The actual pixels are returned by the
* gst_vaapi_image_get_plane() function.
*
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_image_map(GstVaapiImage *image)
{
@ -678,6 +820,15 @@ _gst_vaapi_image_map(GstVaapiImage *image)
return TRUE;
}
/**
* gst_vaapi_image_unmap:
* @image: a #GstVaapiImage
*
* Unmaps the image data buffer. Pointers to pixels returned by
* gst_vaapi_image_get_plane() are then no longer valid.
*
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_image_unmap(GstVaapiImage *image)
{
@ -708,6 +859,15 @@ _gst_vaapi_image_unmap(GstVaapiImage *image)
return TRUE;
}
/**
* gst_vaapi_image_get_plane_count:
* @image: a #GstVaapiImage
*
* Retrieves the number of planes available in the @image. The @image
* must be mapped for this function to work properly.
*
* Return value: the number of planes available in the @image
*/
guint
gst_vaapi_image_get_plane_count(GstVaapiImage *image)
{
@ -718,6 +878,16 @@ gst_vaapi_image_get_plane_count(GstVaapiImage *image)
return image->priv->image.num_planes;
}
/**
* gst_vaapi_image_get_plane:
* @image: a #GstVaapiImage
* @plane: the requested plane number
*
* Retrieves the pixels data to the specified @plane. The @image must
* be mapped for this function to work properly.
*
* Return value: the pixels data of the specified @plane
*/
guchar *
gst_vaapi_image_get_plane(GstVaapiImage *image, guint plane)
{
@ -729,6 +899,16 @@ gst_vaapi_image_get_plane(GstVaapiImage *image, guint plane)
return image->priv->image_data + image->priv->image.offsets[plane];
}
/**
* gst_vaapi_image_get_pitch:
* @image: a #GstVaapiImage
* @plane: the requested plane number
*
* Retrieves the line size (stride) of the specified @plane. The
* @image must be mapped for this function to work properly.
*
* Return value: the line size (stride) of the specified plane
*/
guint
gst_vaapi_image_get_pitch(GstVaapiImage *image, guint plane)
{
@ -740,6 +920,16 @@ gst_vaapi_image_get_pitch(GstVaapiImage *image, guint plane)
return image->priv->image.pitches[plane];
}
/**
* gst_vaapi_image_get_data_size:
* @image: a #GstVaapiImage
*
* Retrieves the underlying image data size. This function could be
* used to determine whether the image has a compatible layout with
* another image structure.
*
* Return value: the whole image data size of the @image
*/
guint
gst_vaapi_image_get_data_size(GstVaapiImage *image)
{
@ -749,6 +939,16 @@ gst_vaapi_image_get_data_size(GstVaapiImage *image)
return image->priv->image.data_size;
}
/**
* gst_vaapi_image_update_from_buffer:
* @image: a #GstVaapiImage
* @buffer: a #GstBuffer
*
* Transfers pixels data contained in the #GstBuffer into the
* @image. Both image structures shall have the same format.
*
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_image_update_from_buffer(GstVaapiImage *image, GstBuffer *buffer)
{

View file

@ -51,21 +51,52 @@ G_BEGIN_DECLS
GST_VAAPI_TYPE_IMAGE, \
GstVaapiImageClass))
#define GST_VAAPI_IMAGE_FORMAT(img) gst_vaapi_image_get_format(img)
#define GST_VAAPI_IMAGE_WIDTH(img) gst_vaapi_image_get_width(img)
#define GST_VAAPI_IMAGE_HEIGHT(img) gst_vaapi_image_get_height(img)
/**
* GST_VAAPI_IMAGE_FORMAT:
* @image: a #GstVaapiImage
*
* Macro that evaluates to the #GstVaapiImageFormat of @image.
*/
#define GST_VAAPI_IMAGE_FORMAT(image) gst_vaapi_image_get_format(image)
/**
* GST_VAAPI_IMAGE_WIDTH:
* @image: a #GstVaapiImage
*
* Macro that evaluates to the width of @image.
*/
#define GST_VAAPI_IMAGE_WIDTH(image) gst_vaapi_image_get_width(image)
/**
* GST_VAAPI_IMAGE_HEIGHT:
* @image: a #GstVaapiImage
*
* Macro that evaluates to the height of @image.
*/
#define GST_VAAPI_IMAGE_HEIGHT(image) gst_vaapi_image_get_height(image)
typedef struct _GstVaapiImage GstVaapiImage;
typedef struct _GstVaapiImagePrivate GstVaapiImagePrivate;
typedef struct _GstVaapiImageClass GstVaapiImageClass;
/**
* GstVaapiImage:
*
* A VA image wrapper
*/
struct _GstVaapiImage {
/*< private >*/
GObject parent_instance;
/*< private >*/
GstVaapiImagePrivate *priv;
};
/**
* GstVaapiImageClass:
*
* A VA image wrapper class
*/
struct _GstVaapiImageClass {
/*< private >*/
GObjectClass parent_class;

View file

@ -18,6 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* SECTION:gst-vaapi-image-format
* @short_description:
*/
#include "config.h"
#include <glib.h>
#include <gst/video/video.h>
@ -27,9 +32,9 @@ typedef enum _GstVaapiImageFormatType GstVaapiImageFormatType;
typedef struct _GstVaapiImageFormatMap GstVaapiImageFormatMap;
enum _GstVaapiImageFormatType {
GST_VAAPI_IMAGE_FORMAT_TYPE_YCBCR = 1,
GST_VAAPI_IMAGE_FORMAT_TYPE_RGB,
GST_VAAPI_IMAGE_FORMAT_TYPE_INDEXED
GST_VAAPI_IMAGE_FORMAT_TYPE_YCBCR = 1, /* YUV */
GST_VAAPI_IMAGE_FORMAT_TYPE_RGB, /* RGB */
GST_VAAPI_IMAGE_FORMAT_TYPE_INDEXED /* paletted */
};
struct _GstVaapiImageFormatMap {
@ -94,6 +99,14 @@ get_map(GstVaapiImageFormat format)
return NULL;
}
/**
* gst_vaapi_image_format_is_rgb:
* @format: a #GstVaapiImageFormat
*
* Checks whether the format is an RGB format.
*
* Return value: %TRUE if @format is RGB format
*/
gboolean
gst_vaapi_image_format_is_rgb(GstVaapiImageFormat format)
{
@ -102,6 +115,14 @@ gst_vaapi_image_format_is_rgb(GstVaapiImageFormat format)
return m ? (m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_RGB) : FALSE;
}
/**
* gst_vaapi_image_format_is_yuv:
* @format: a #GstVaapiImageFormat
*
* Checks whether the format is an YUV format.
*
* Return value: %TRUE if @format is YUV format
*/
gboolean
gst_vaapi_image_format_is_yuv(GstVaapiImageFormat format)
{
@ -110,6 +131,16 @@ gst_vaapi_image_format_is_yuv(GstVaapiImageFormat format)
return m ? (m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_YCBCR) : FALSE;
}
/**
* gst_vaapi_image_format:
* @va_format: a #VAImageFormat
*
* Converts a VA image format into the corresponding #GstVaapiImageFormat.
* If the image format cannot be represented by #GstVaapiImageFormat,
* then zero is returned.
*
* Return value: the #GstVaapiImageFormat describing the @va_format
*/
GstVaapiImageFormat
gst_vaapi_image_format(const VAImageFormat *va_format)
{
@ -125,6 +156,16 @@ gst_vaapi_image_format(const VAImageFormat *va_format)
return 0;
}
/**
* gst_vaapi_image_format_from_caps:
* @caps: a #GstCaps
*
* Converts @caps into the corresponding #GstVaapiImageFormat. If the
* image format cannot be represented by #GstVaapiImageFormat, then
* zero is returned.
*
* Return value: the #GstVaapiImageFormat describing the @caps
*/
GstVaapiImageFormat
gst_vaapi_image_format_from_caps(GstCaps *caps)
{
@ -174,12 +215,32 @@ gst_vaapi_image_format_from_caps(GstCaps *caps)
return 0;
}
/**
* gst_vaapi_image_format_from_fourcc:
* @fourcc: a FOURCC value
*
* Converts a FOURCC value into the corresponding #GstVaapiImageFormat.
* If the image format cannot be represented by #GstVaapiImageFormat,
* then zero is returned.
*
* Return value: the #GstVaapiImageFormat describing the FOURCC value
*/
GstVaapiImageFormat
gst_vaapi_image_format_from_fourcc(guint32 fourcc)
{
return (GstVaapiImageFormat)fourcc;
}
/**
* gst_vaapi_image_format_get_va_format:
* @format: a #GstVaapiImageFormat
*
* Converts a #GstVaapiImageFormat into the corresponding VA image
* format. If no matching VA image format was found, %NULL is returned
* and this error must be reported to be fixed.
*
* Return value: the VA image format, or %NULL if none was found
*/
const VAImageFormat *
gst_vaapi_image_format_get_va_format(GstVaapiImageFormat format)
{
@ -188,6 +249,15 @@ gst_vaapi_image_format_get_va_format(GstVaapiImageFormat format)
return m ? &m->va_format : NULL;
}
/**
* gst_vaapi_image_format_get_caps:
* @format: a #GstVaapiImageFormat
*
* Converts a #GstVaapiImageFormat into the corresponding #GstCaps. If
* no matching caps were found, %NULL is returned.
*
* Return value: the newly allocated #GstCaps, or %NULL if none was found
*/
GstCaps *
gst_vaapi_image_format_get_caps(GstVaapiImageFormat format)
{
@ -196,6 +266,15 @@ gst_vaapi_image_format_get_caps(GstVaapiImageFormat format)
return m ? gst_caps_from_string(m->caps_str) : NULL;
}
/**
* gst_vaapi_image_format_get_score:
* @format: a #GstVaapiImageFormat
*
* Determines how "native" is this @format. The lower is the returned
* score, the best format this is for the underlying hardware.
*
* Return value: the @format score, or %G_MAXUINT if none was found
*/
guint
gst_vaapi_image_format_get_score(GstVaapiImageFormat format)
{

View file

@ -28,20 +28,32 @@ G_BEGIN_DECLS
typedef enum _GstVaapiImageFormat GstVaapiImageFormat;
/**
* GstVaapiImageFormat:
* @GST_VAAPI_IMAGE_NV12:
* planar YUV 4:2:0, 12-bit, 1 plane for Y and 1 plane for UV
* @GST_VAAPI_IMAGE_YV12:
* planar YUV 4:2:0, 12-bit, 3 planes for Y V U
* @GST_VAAPI_IMAGE_I420:
* planar YUV 4:2:0, 12-bit, 3 planes for Y U V
* @GST_VAAPI_IMAGE_ARGB:
* packed RGB 8:8:8, 32-bit, A R G B
* @GST_VAAPI_IMAGE_RGBA:
* packed RGB 8:8:8, 32-bit, R G B A
* @GST_VAAPI_IMAGE_ABGR:
* packed RGB 8:8:8, 32-bit, A B G R
* @GST_VAAPI_IMAGE_BGRA:
* packed RGB 8:8:8, 32-bit, B G R A
*
* The set of all image formats for #GstVaapiImage.
*/
enum _GstVaapiImageFormat {
/** Planar YUV 4:2:0, 12-bit, 1 plane for Y and 1 plane for UV */
GST_VAAPI_IMAGE_NV12 = VA_FOURCC('N','V','1','2'),
/** Planar YUV 4:2:0, 12-bit, 3 planes for Y V U */
GST_VAAPI_IMAGE_YV12 = VA_FOURCC('Y','V','1','2'),
/** Planar YUV 4:2:0, 12-bit, 3 planes for Y U V */
GST_VAAPI_IMAGE_I420 = VA_FOURCC('I','4','2','0'),
/** Packed RGB 8:8:8, 32-bit, A R G B */
GST_VAAPI_IMAGE_ARGB = VA_FOURCC('A','R','G','B'),
/** Packed RGB 8:8:8, 32-bit, R G B A */
GST_VAAPI_IMAGE_RGBA = VA_FOURCC('R','G','B','A'),
/** Packed RGB 8:8:8, 32-bit, A R G B */
GST_VAAPI_IMAGE_ABGR = VA_FOURCC('A','B','G','R'),
/** Packed RGB 8:8:8, 32-bit, R G B A */
GST_VAAPI_IMAGE_BGRA = VA_FOURCC('B','G','R','A'),
};

View file

@ -18,6 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* SECTION:gst-vaapi-subpicture
* @short_description:
*/
#include "config.h"
#include <string.h>
#include "gstvaapiutils.h"
@ -166,21 +171,31 @@ gst_vaapi_subpicture_class_init(GstVaapiSubpictureClass *klass)
object_class->set_property = gst_vaapi_subpicture_set_property;
object_class->get_property = gst_vaapi_subpicture_get_property;
/**
* GstVaapiSubpicture:id:
*
* The underlying #VASubpictureID of the subpicture.
*/
g_object_class_install_property
(object_class,
PROP_SUBPICTURE_ID,
g_param_spec_uint("id",
"VA subpicture id",
"VA subpicture id",
"The underlying VA subpicture id",
0, G_MAXUINT32, VA_INVALID_ID,
G_PARAM_READABLE));
/**
* GstVaapiSubpicture:image:
*
* The #GstVaapiImage this subpicture is bound to.
*/
g_object_class_install_property
(object_class,
PROP_IMAGE,
g_param_spec_object("image",
"image",
"GStreamer VA image",
"Image",
"The GstVaapiImage this subpicture is bound to",
GST_VAAPI_TYPE_IMAGE,
G_PARAM_READWRITE));
}
@ -195,6 +210,15 @@ gst_vaapi_subpicture_init(GstVaapiSubpicture *subpicture)
priv->image = NULL;
}
/**
* gst_vaapi_subpicture_new:
* @image: a #GstVaapiImage
*
* Creates a new #GstVaapiSubpicture with @image as source pixels. The
* newly created object holds a reference on @image.
*
* Return value: the newly allocated #GstVaapiSubpicture object
*/
GstVaapiSubpicture *
gst_vaapi_subpicture_new(GstVaapiImage *image)
{
@ -207,6 +231,14 @@ gst_vaapi_subpicture_new(GstVaapiImage *image)
NULL);
}
/**
* gst_vaapi_subpicture_get_id:
* @subpicture: a #GstVaapiSubpicture
*
* Returns the underlying VASubpictureID of the @subpicture.
*
* Return value: the underlying VA subpicture id
*/
VASubpictureID
gst_vaapi_subpicture_get_id(GstVaapiSubpicture *subpicture)
{
@ -215,6 +247,14 @@ gst_vaapi_subpicture_get_id(GstVaapiSubpicture *subpicture)
return subpicture->priv->subpicture_id;
}
/**
* gst_vaapi_subpicture_get_image:
* @subpicture: a #GstVaapiSubpicture
*
* Returns the #GstVaapiImage this @subpicture is bound to.
*
* Return value: the #GstVaapiImage this @subpicture is bound to
*/
GstVaapiImage *
gst_vaapi_subpicture_get_image(GstVaapiSubpicture *subpicture)
{
@ -223,6 +263,14 @@ gst_vaapi_subpicture_get_image(GstVaapiSubpicture *subpicture)
return subpicture->priv->image;
}
/**
* gst_vaapi_subpicture_set_image:
* @subpicture: a #GstVaapiSubpicture
* @image: a #GstVaapiImage
*
* Binds a new #GstVaapiImage to the @subpicture. The reference to the
* previous image is released a new one acquired on @image.
*/
void
gst_vaapi_subpicture_set_image(
GstVaapiSubpicture *subpicture,

View file

@ -54,13 +54,24 @@ typedef struct _GstVaapiSubpicture GstVaapiSubpicture;
typedef struct _GstVaapiSubpicturePrivate GstVaapiSubpicturePrivate;
typedef struct _GstVaapiSubpictureClass GstVaapiSubpictureClass;
/**
* GstVaapiSubpicture:
*
* A VA subpicture wrapper
*/
struct _GstVaapiSubpicture {
/*< private >*/
GObject parent_instance;
/*< private >*/
GstVaapiSubpicturePrivate *priv;
};
/**
* GstVaapiSubpictureClass:
*
* A VA subpicture wrapper class
*/
struct _GstVaapiSubpictureClass {
/*< private >*/
GObjectClass parent_class;

View file

@ -18,6 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* SECTION:gst-vaapi-surface
* @short_description:
*/
#include "config.h"
#include "gstvaapiutils.h"
#include "gstvaapisurface.h"
@ -210,21 +215,31 @@ gst_vaapi_surface_class_init(GstVaapiSurfaceClass *klass)
object_class->get_property = gst_vaapi_surface_get_property;
object_class->constructed = gst_vaapi_surface_constructed;
/**
* GstVaapiSurface:display:
*
* The #GstVaapiDisplay this surface is bound to.
*/
g_object_class_install_property
(object_class,
PROP_DISPLAY,
g_param_spec_object("display",
"display",
"GStreamer Va display",
"Display",
"The GstVaapiDisplay this surface is bound to",
GST_VAAPI_TYPE_DISPLAY,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
/**
* GstVaapiSurface:id:
*
* The underlying #VASurfaceID of the surface.
*/
g_object_class_install_property
(object_class,
PROP_SURFACE_ID,
g_param_spec_uint("id",
"VA surface id",
"VA surface id",
"The underlying VA surface id",
0, G_MAXUINT32, VA_INVALID_SURFACE,
G_PARAM_READABLE));
@ -232,8 +247,8 @@ gst_vaapi_surface_class_init(GstVaapiSurfaceClass *klass)
(object_class,
PROP_WIDTH,
g_param_spec_uint("width",
"width",
"VA surface width",
"Width",
"The width of the surface",
0, G_MAXINT32, 0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
@ -241,8 +256,8 @@ gst_vaapi_surface_class_init(GstVaapiSurfaceClass *klass)
(object_class,
PROP_HEIGHT,
g_param_spec_uint("height",
"height",
"VA surface height",
"Height",
"The height of the surface",
0, G_MAXINT32, 0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
@ -250,8 +265,8 @@ gst_vaapi_surface_class_init(GstVaapiSurfaceClass *klass)
(object_class,
PROP_CHROMA_TYPE,
g_param_spec_uint("chroma-type",
"chroma-type",
"VA surface chroma type",
"Chroma type",
"The chroma type of the surface",
0, G_MAXUINT32, 0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
}
@ -269,6 +284,18 @@ gst_vaapi_surface_init(GstVaapiSurface *surface)
priv->chroma_type = 0;
}
/**
* gst_vaapi_surface_new:
* @display: a #GstVaapiDisplay
* @chroma_type: the surface chroma format
* @width: the requested surface width
* @height: the requested surface height
*
* Creates a new #GstVaapiSurface with the specified chroma format and
* dimensions.
*
* Return value: the newly allocated #GstVaapiSurface object
*/
GstVaapiSurface *
gst_vaapi_surface_new(
GstVaapiDisplay *display,
@ -287,6 +314,14 @@ gst_vaapi_surface_new(
NULL);
}
/**
* gst_vaapi_surface_get_id:
* @surface: a #GstVaapiSurface
*
* Returns the underlying VASurfaceID of the @surface.
*
* Return value: the underlying VA surface id
*/
VASurfaceID
gst_vaapi_surface_get_id(GstVaapiSurface *surface)
{
@ -295,6 +330,14 @@ gst_vaapi_surface_get_id(GstVaapiSurface *surface)
return surface->priv->surface_id;
}
/**
* gst_vaapi_surface_get_display:
* @surface: a #GstVaapiSurface
*
* Returns the #GstVaapiDisplay this @surface is bound to.
*
* Return value: the parent #GstVaapiDisplay object
*/
GstVaapiDisplay *
gst_vaapi_surface_get_display(GstVaapiSurface *surface)
{
@ -303,6 +346,14 @@ gst_vaapi_surface_get_display(GstVaapiSurface *surface)
return surface->priv->display;
}
/**
* gst_vaapi_surface_get_chroma_type:
* @surface: a #GstVaapiSurface
*
* Returns the #GstVaapiChromaType the @surface was created with.
*
* Return value: the #GstVaapiChromaType
*/
GstVaapiChromaType
gst_vaapi_surface_get_chroma_type(GstVaapiSurface *surface)
{
@ -311,6 +362,14 @@ gst_vaapi_surface_get_chroma_type(GstVaapiSurface *surface)
return surface->priv->chroma_type;
}
/**
* gst_vaapi_surface_get_width:
* @surface: a #GstVaapiSurface
*
* Returns the @surface width.
*
* Return value: the surface width, in pixels
*/
guint
gst_vaapi_surface_get_width(GstVaapiSurface *surface)
{
@ -319,6 +378,14 @@ gst_vaapi_surface_get_width(GstVaapiSurface *surface)
return surface->priv->width;
}
/**
* gst_vaapi_surface_get_height:
* @surface: a #GstVaapiSurface
*
* Returns the @surface height.
*
* Return value: the surface height, in pixels.
*/
guint
gst_vaapi_surface_get_height(GstVaapiSurface *surface)
{
@ -327,6 +394,14 @@ gst_vaapi_surface_get_height(GstVaapiSurface *surface)
return surface->priv->height;
}
/**
* gst_vaapi_surface_get_size:
* @surface: a #GstVaapiSurface
* @pwidth: (out) (allow-none): return location for the width, or %NULL
* @pheight: (out) (allow-none): return location for the height, or %NULL
*
* Retrieves the dimensions of a #GstVaapiSurface.
*/
void
gst_vaapi_surface_get_size(
GstVaapiSurface *surface,
@ -343,6 +418,30 @@ gst_vaapi_surface_get_size(
*pheight = gst_vaapi_surface_get_height(surface);
}
/**
* gst_vaapi_surface_derive_image:
* @surface: a #GstVaapiSurface
*
* Derives a #GstVaapiImage from the @surface. This image buffer can
* then be mapped/unmapped for direct CPU access. This operation is
* only possible if the underlying implementation supports direct
* rendering capabilities and internal surface formats that can be
* represented with a #GstVaapiImage.
*
* When the operation is not possible, the function returns %NULL and
* the user should then fallback to using gst_vaapi_surface_get_image()
* or gst_vaapi_surface_put_image() to accomplish the same task in an
* indirect manner (additional copy).
*
* An image created with gst_vaapi_surface_derive_image() should be
* unreferenced when it's no longer needed. The image and image buffer
* data structures will be destroyed. However, the surface contents
* will remain unchanged until destroyed through the last call to
* g_object_unref().
*
* Return value: the newly allocated #GstVaapiImage object, or %NULL
* on failure
*/
GstVaapiImage *
gst_vaapi_surface_derive_image(GstVaapiSurface *surface)
{
@ -369,6 +468,16 @@ gst_vaapi_surface_derive_image(GstVaapiSurface *surface)
return gst_vaapi_image_new_with_image(surface->priv->display, &va_image);
}
/**
* gst_vaapi_surface_get_image
* @surface: a #GstVaapiSurface
* @image: a #GstVaapiImage
*
* Retrieves surface data into a #GstVaapiImage. The @image must have
* a format supported by the @surface.
*
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_surface_get_image(GstVaapiSurface *surface, GstVaapiImage *image)
{
@ -401,6 +510,16 @@ gst_vaapi_surface_get_image(GstVaapiSurface *surface, GstVaapiImage *image)
return TRUE;
}
/**
* gst_vaapi_surface_put_image:
* @surface: a #GstVaapiSurface
* @image: a #GstVaapiImage
*
* Copies data from a #GstVaapiImage into a @surface. The @image must
* have a format supported by the @surface.
*
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_surface_put_image(GstVaapiSurface *surface, GstVaapiImage *image)
{
@ -434,6 +553,15 @@ gst_vaapi_surface_put_image(GstVaapiSurface *surface, GstVaapiImage *image)
return TRUE;
}
/**
* gst_vaapi_surface_sync:
* @surface: a #GstVaapiSurface
*
* Blocks until all pending operations on the @surface have been
* completed.
*
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_surface_sync(GstVaapiSurface *surface)
{

View file

@ -28,6 +28,14 @@ G_BEGIN_DECLS
typedef enum _GstVaapiChromaType GstVaapiChromaType;
/**
* GstVaapiChromaType:
* @GST_VAAPI_CHROMA_TYPE_YUV420: 4:2:0 chroma format
* @GST_VAAPI_CHROMA_TYPE_YUV422: 4:2:2 chroma format
* @GST_VAAPI_CHROMA_TYPE_YUV444: 4:4:4 chroma format
*
* The set of all chroma types for #GstVaapiSurface.
*/
enum _GstVaapiChromaType {
GST_VAAPI_CHROMA_TYPE_YUV420 = 1,
GST_VAAPI_CHROMA_TYPE_YUV422,
@ -62,13 +70,24 @@ typedef struct _GstVaapiSurface GstVaapiSurface;
typedef struct _GstVaapiSurfacePrivate GstVaapiSurfacePrivate;
typedef struct _GstVaapiSurfaceClass GstVaapiSurfaceClass;
/**
* GstVaapiSurface:
*
* A VA surface wrapper.
*/
struct _GstVaapiSurface {
/*< private >*/
GObject parent_instance;
/*< private >*/
GstVaapiSurfacePrivate *priv;
};
/**
* GstVaapiSurfaceClass:
*
* A VA surface wrapper class.
*/
struct _GstVaapiSurfaceClass {
/*< private >*/
GObjectClass parent_class;

View file

@ -18,6 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* SECTION:gst-vaapi-video-sink:
* @short_description: An interface for implementing VA-API sink elements
*/
#include "config.h"
#include "gstvaapivideosink.h"
@ -53,6 +58,14 @@ gst_vaapi_video_sink_get_type(void)
return iface_type;
}
/**
* gst_vaapi_video_sink_get_display:
* @sink: a #GstElement
*
* Returns the #GstVaapiDisplay created by the VA-API @sink element.
*
* Return value: the #GstVaapiDisplay created by the @sink element
*/
GstVaapiDisplay *
gst_vaapi_video_sink_get_display(GstVaapiVideoSink *sink)
{
@ -61,6 +74,18 @@ gst_vaapi_video_sink_get_display(GstVaapiVideoSink *sink)
return GST_VAAPI_VIDEO_SINK_GET_INTERFACE(sink)->get_display(sink);
}
/**
* gst_vaapi_video_sink_lookup:
* @element: a #GstElement
*
* Traverses the whole downstream elements chain and finds a suitable
* #GstVaapiDisplay. This is a helper function for intermediate VA-API
* elements that don't create a #GstVaapiDisplay but require one.
* e.g. the `vaapiconvert' element.
*
* Return value: the #GstVaapiDisplay created by a downstream sink
* element, or %NULL if none was found
*/
GstVaapiVideoSink *
gst_vaapi_video_sink_lookup(GstElement *element)
{

View file

@ -45,10 +45,17 @@ G_BEGIN_DECLS
typedef struct _GstVaapiVideoSink GstVaapiVideoSink; /* dummy */
typedef struct _GstVaapiVideoSinkInterface GstVaapiVideoSinkInterface;
/**
* GstVaapiVideoSinkInterface:
* @get_display: virtual function for retrieving the #GstVaapiDisplay created
* by the downstream sink element. The implementation of that virtual
* function is required for all Gstreamer/VAAPI sink elements.
*/
struct _GstVaapiVideoSinkInterface {
/*< private >*/
GTypeInterface g_iface;
/*< public >*/
GstVaapiDisplay *(*get_display)(GstVaapiVideoSink *sink);
};

View file

@ -18,6 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* SECTION:gst-vaapi-window
* @short_description:
*/
#include "config.h"
#include "gstvaapiwindow.h"
@ -153,8 +158,8 @@ gst_vaapi_window_class_init(GstVaapiWindowClass *klass)
(object_class,
PROP_WIDTH,
g_param_spec_uint("width",
"width",
"Width",
"The window width",
1, G_MAXUINT32, 1,
G_PARAM_READWRITE));
@ -163,7 +168,7 @@ gst_vaapi_window_class_init(GstVaapiWindowClass *klass)
PROP_HEIGHT,
g_param_spec_uint("height",
"height",
"Height",
"The window height",
1, G_MAXUINT32, 1,
G_PARAM_READWRITE));
}
@ -179,6 +184,13 @@ gst_vaapi_window_init(GstVaapiWindow *window)
priv->height = 1;
}
/**
* gst_vaapi_window_show:
* @window: a #GstVaapiWindow
*
* Flags a window to be displayed. Any window that is not shown will
* not appear on the screen.
*/
void
gst_vaapi_window_show(GstVaapiWindow *window)
{
@ -188,6 +200,13 @@ gst_vaapi_window_show(GstVaapiWindow *window)
GST_VAAPI_WINDOW_GET_CLASS(window)->show(window);
}
/**
* gst_vaapi_window_hide:
* @window: a #GstVaapiWindow
*
* Reverses the effects of gst_vaapi_window_show(), causing the window
* to be hidden (invisible to the user).
*/
void
gst_vaapi_window_hide(GstVaapiWindow *window)
{
@ -197,6 +216,14 @@ gst_vaapi_window_hide(GstVaapiWindow *window)
GST_VAAPI_WINDOW_GET_CLASS(window)->hide(window);
}
/**
* gst_vaapi_window_get_width:
* @window: a #GstVaapiWindow
*
* Retrieves the width of a #GstVaapiWindow.
*
* Return value: the width of the @window, in pixels
*/
guint
gst_vaapi_window_get_width(GstVaapiWindow *window)
{
@ -206,6 +233,14 @@ gst_vaapi_window_get_width(GstVaapiWindow *window)
return window->priv->width;
}
/**
* gst_vaapi_window_get_height:
* @window: a #GstVaapiWindow
*
* Retrieves the height of a #GstVaapiWindow
*
* Return value: the height of the @window, in pixels
*/
guint
gst_vaapi_window_get_height(GstVaapiWindow *window)
{
@ -215,6 +250,14 @@ gst_vaapi_window_get_height(GstVaapiWindow *window)
return window->priv->height;
}
/**
* gst_vaapi_window_get_size:
* @window: a #GstVaapiWindow
* @pwidth: (out) (allow-none): return location for the width, or %NULL
* @pheight: (out) (allow-none): return location for the height, or %NULL
*
* Retrieves the dimensions of a #GstVaapiWindow.
*/
void
gst_vaapi_window_get_size(GstVaapiWindow *window, guint *pwidth, guint *pheight)
{
@ -228,6 +271,13 @@ gst_vaapi_window_get_size(GstVaapiWindow *window, guint *pwidth, guint *pheight)
*pheight = window->priv->height;
}
/**
* gst_vaapi_window_set_width:
* @window: a #GstVaapiWindow
* @width: requested new width for the window, in pixels
*
* Resizes the @window to match the specified @width.
*/
void
gst_vaapi_window_set_width(GstVaapiWindow *window, guint width)
{
@ -236,6 +286,13 @@ gst_vaapi_window_set_width(GstVaapiWindow *window, guint width)
gst_vaapi_window_set_size(window, width, window->priv->height);
}
/**
* gst_vaapi_window_set_height:
* @window: a #GstVaapiWindow
* @height: requested new height for the window, in pixels
*
* Resizes the @window to match the specified @height.
*/
void
gst_vaapi_window_set_height(GstVaapiWindow *window, guint height)
{
@ -244,6 +301,14 @@ gst_vaapi_window_set_height(GstVaapiWindow *window, guint height)
gst_vaapi_window_set_size(window, window->priv->width, height);
}
/**
* gst_vaapi_window_set_size:
* @window: a #GstVaapiWindow
* @width: requested new width for the window, in pixels
* @height: requested new height for the window, in pixels
*
* Resizes the @window to match the specified @width and @height.
*/
void
gst_vaapi_window_set_size(GstVaapiWindow *window, guint width, guint height)
{
@ -283,6 +348,17 @@ get_window_rect(GstVaapiWindow *window, GstVideoRectangle *rect)
rect->h = height;
}
/**
* gst_vaapi_window_put_surface:
* @window: a #GstVaapiWindow
* @surface: a #GstVaapiSurface
* @flags: postprocessing flags
*
* Renders the whole @surface into the @window. The surface will be
* scale to fit the window, while not preserving aspect ratio.
*
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_window_put_surface(
GstVaapiWindow *window,
@ -306,6 +382,24 @@ gst_vaapi_window_put_surface(
flags);
}
/**
* gst_vaapi_window_put_surface_full:
* @window: a #GstVaapiWindow
* @surface: a #GstVaapiSurface
* @src_rect: (allow-none): the sub-rectangle of the source surface to
* extract and process. If %NULL, the entire surface will be used.
* @dst_rect: (allow-none): the sub-rectangle of the destination
* window into which the surface is rendered. If %NULL, the entire
* window will be used.
* @flags: postprocessing flags. See #GstVaapiSurfaceRenderFlags
*
* Renders the @surface region specified by @src_rect into the @window
* region specified by @dst_rect. The @flags specify how de-interlacing
* (if needed), color space conversion, scaling and other postprocessing
* transformations are performed.
*
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_window_put_surface_full(
GstVaapiWindow *window,

View file

@ -67,13 +67,30 @@ typedef struct _GstVaapiWindow GstVaapiWindow;
typedef struct _GstVaapiWindowPrivate GstVaapiWindowPrivate;
typedef struct _GstVaapiWindowClass GstVaapiWindowClass;
/**
* GstVaapiWindow:
*
* Base class for system-dependent windows.
*/
struct _GstVaapiWindow {
/*< private >*/
GObject parent_instance;
/*< private >*/
GstVaapiWindowPrivate *priv;
};
/**
* GstVaapiWindowClass:
* @create: virtual function to create a window with width and height
* @destroy: virtual function to destroy a window
* @show: virtual function to show (map) a window
* @hide: virtual function to hide (unmap) a window
* @resize: virtual function to resize a window
* @render: virtual function to render a #GstVaapiSurface into a window
*
* Base class for system-dependent windows.
*/
struct _GstVaapiWindowClass {
/*< private >*/
GObjectClass parent_class;

View file

@ -18,6 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* SECTION:gst-vaapi-window-x11
* @short_description:
*/
#include "config.h"
#include "gstvaapiwindow_x11.h"
#include "gstvaapidisplay_x11.h"
@ -302,21 +307,31 @@ gst_vaapi_window_x11_class_init(GstVaapiWindowX11Class *klass)
window_class->resize = gst_vaapi_window_x11_resize;
window_class->render = gst_vaapi_window_x11_render;
/**
* GstVaapiWindowX11:display:
*
* The #GstVaapiDisplay this window is bound to
*/
g_object_class_install_property
(object_class,
PROP_DISPLAY,
g_param_spec_object("display",
"display",
"Display",
"The GstVaapiDisplay this window is bound to",
GST_VAAPI_TYPE_DISPLAY,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
/**
* GstVaapiWindowX11:xid:
*
* The underlying X11 #Window XID.
*/
g_object_class_install_property
(object_class,
PROP_XID,
g_param_spec_uint("xid",
"X window id",
"X window ID",
"The underlying X11 window id",
0, G_MAXUINT32, 0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
}
@ -333,6 +348,18 @@ gst_vaapi_window_x11_init(GstVaapiWindowX11 *window)
priv->is_visible = FALSE;
}
/**
* gst_vaapi_window_x11_new:
* @display: a #GstVaapiDisplay
* @width: the requested window width, in pixels
* @height: the requested windo height, in pixels
*
* Creates a window with the specified @width and @height. The window
* will be attached to the @display and remains invisible to the user
* until gst_vaapi_window_show() is called.
*
* Return value: the newly allocated #GstVaapiWindow object
*/
GstVaapiWindow *
gst_vaapi_window_x11_new(GstVaapiDisplay *display, guint width, guint height)
{
@ -349,6 +376,18 @@ gst_vaapi_window_x11_new(GstVaapiDisplay *display, guint width, guint height)
NULL);
}
/**
* gst_vaapi_window_x11_new_with_xid:
* @display: a #GstVaapiDisplay
* @xid: an X11 #Window id
*
* Creates a #GstVaapiWindow using the X11 #Window @xid. The caller
* still owns the window and must call XDestroyWindow() when all
* #GstVaapiWindow references are released. Doing so too early can
* yield undefined behaviour.
*
* Return value: the newly allocated #GstVaapiWindow object
*/
GstVaapiWindow *
gst_vaapi_window_x11_new_with_xid(GstVaapiDisplay *display, Window xid)
{
@ -363,6 +402,16 @@ gst_vaapi_window_x11_new_with_xid(GstVaapiDisplay *display, Window xid)
NULL);
}
/**
* gst_vaapi_window_x11_get_xid:
* @window: a #GstVaapiWindowX11
*
* Returns the underlying X11 #Window that was created by
* gst_vaapi_window_x11_new() or that was bound with
* gst_vaapi_window_x11_new_with_xid().
*
* Return value: the underlying X11 #Window bound to @window.
*/
Window
gst_vaapi_window_x11_get_xid(GstVaapiWindowX11 *window)
{

View file

@ -55,13 +55,24 @@ typedef struct _GstVaapiWindowX11 GstVaapiWindowX11;
typedef struct _GstVaapiWindowX11Private GstVaapiWindowX11Private;
typedef struct _GstVaapiWindowX11Class GstVaapiWindowX11Class;
/**
* GstVaapiWindowX11:
*
* An X11 #Window wrapper.
*/
struct _GstVaapiWindowX11 {
/*< private >*/
GstVaapiWindow parent_instance;
/*< private >*/
GstVaapiWindowX11Private *priv;
};
/**
* GstVaapiWindowX11Class:
*
* An X11 #Window wrapper class.
*/
struct _GstVaapiWindowX11Class {
/*< private >*/
GstVaapiWindowClass parent_class;