summaryrefslogtreecommitdiffstats
path: root/ext/sdl
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2004-03-14 22:34:33 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2004-03-14 22:34:33 +0000
commit7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 (patch)
treef863b467dea9559a6ec9c48affbfae11f8104164 /ext/sdl
parenta19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 (diff)
downloadgst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.gz
gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.bz2
gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.zip
gst-indent
Original commit message from CVS: gst-indent
Diffstat (limited to 'ext/sdl')
-rw-r--r--ext/sdl/sdlvideosink.c390
-rw-r--r--ext/sdl/sdlvideosink.h18
2 files changed, 189 insertions, 219 deletions
diff --git a/ext/sdl/sdlvideosink.c b/ext/sdl/sdlvideosink.c
index 57547102..f5d46a4f 100644
--- a/ext/sdl/sdlvideosink.c
+++ b/ext/sdl/sdlvideosink.c
@@ -40,45 +40,39 @@ static GstElementDetails gst_sdlvideosink_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
};
-static void gst_sdlvideosink_base_init (gpointer g_class);
-static void gst_sdlvideosink_class_init (GstSDLVideoSinkClass *klass);
-static void gst_sdlvideosink_init (GstSDLVideoSink *sdl);
+static void gst_sdlvideosink_base_init (gpointer g_class);
+static void gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass);
+static void gst_sdlvideosink_init (GstSDLVideoSink * sdl);
-static void gst_sdlvideosink_interface_init (GstImplementsInterfaceClass *klass);
-static gboolean gst_sdlvideosink_supported (GstImplementsInterface *iface,
- GType type);
+static void gst_sdlvideosink_interface_init (GstImplementsInterfaceClass *
+ klass);
+static gboolean gst_sdlvideosink_supported (GstImplementsInterface * iface,
+ GType type);
-static void gst_sdlvideosink_xoverlay_init (GstXOverlayClass *klass);
-static void gst_sdlvideosink_xoverlay_set_xwindow_id
- (GstXOverlay *overlay,
- unsigned long parent);
+static void gst_sdlvideosink_xoverlay_init (GstXOverlayClass * klass);
+static void gst_sdlvideosink_xoverlay_set_xwindow_id
+ (GstXOverlay * overlay, unsigned long parent);
-static gboolean gst_sdlvideosink_lock (GstSDLVideoSink *sdl);
-static void gst_sdlvideosink_unlock (GstSDLVideoSink *sdl);
+static gboolean gst_sdlvideosink_lock (GstSDLVideoSink * sdl);
+static void gst_sdlvideosink_unlock (GstSDLVideoSink * sdl);
-static gboolean gst_sdlvideosink_initsdl (GstSDLVideoSink *sdl);
-static void gst_sdlvideosink_deinitsdl (GstSDLVideoSink *sdl);
+static gboolean gst_sdlvideosink_initsdl (GstSDLVideoSink * sdl);
+static void gst_sdlvideosink_deinitsdl (GstSDLVideoSink * sdl);
-static gboolean gst_sdlvideosink_create (GstSDLVideoSink *sdl);
-static void gst_sdlvideosink_destroy (GstSDLVideoSink *sdl);
+static gboolean gst_sdlvideosink_create (GstSDLVideoSink * sdl);
+static void gst_sdlvideosink_destroy (GstSDLVideoSink * sdl);
static GstPadLinkReturn
- gst_sdlvideosink_sinkconnect (GstPad *pad,
- const GstCaps *caps);
-static GstCaps * gst_sdlvideosink_fixate (GstPad *pad, const GstCaps *caps);
-static void gst_sdlvideosink_chain (GstPad *pad,
- GstData *data);
-
-static void gst_sdlvideosink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_sdlvideosink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+gst_sdlvideosink_sinkconnect (GstPad * pad, const GstCaps * caps);
+static GstCaps *gst_sdlvideosink_fixate (GstPad * pad, const GstCaps * caps);
+static void gst_sdlvideosink_chain (GstPad * pad, GstData * data);
+
+static void gst_sdlvideosink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_sdlvideosink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
static GstElementStateReturn
- gst_sdlvideosink_change_state (GstElement *element);
+gst_sdlvideosink_change_state (GstElement * element);
static GstPadTemplate *sink_template;
@@ -113,13 +107,12 @@ gst_sdlvideosink_get_type (void)
NULL,
};
- sdlvideosink_type = g_type_register_static(GST_TYPE_VIDEOSINK,
- "GstSDLVideoSink",
- &sdlvideosink_info, 0);
- g_type_add_interface_static(sdlvideosink_type, GST_TYPE_IMPLEMENTS_INTERFACE,
- &iface_info);
- g_type_add_interface_static(sdlvideosink_type, GST_TYPE_X_OVERLAY,
- &xoverlay_info);
+ sdlvideosink_type = g_type_register_static (GST_TYPE_VIDEOSINK,
+ "GstSDLVideoSink", &sdlvideosink_info, 0);
+ g_type_add_interface_static (sdlvideosink_type,
+ GST_TYPE_IMPLEMENTS_INTERFACE, &iface_info);
+ g_type_add_interface_static (sdlvideosink_type, GST_TYPE_X_OVERLAY,
+ &xoverlay_info);
}
return sdlvideosink_type;
@@ -131,36 +124,33 @@ gst_sdlvideosink_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstCaps *capslist;
gint i;
- gulong format[6] = { GST_MAKE_FOURCC('I','4','2','0'),
- GST_MAKE_FOURCC('Y','V','1','2'),
- GST_MAKE_FOURCC('Y','U','Y','2'),
- GST_MAKE_FOURCC('Y','V','Y','U'),
- GST_MAKE_FOURCC('U','Y','V','Y')
- };
+ gulong format[6] = { GST_MAKE_FOURCC ('I', '4', '2', '0'),
+ GST_MAKE_FOURCC ('Y', 'V', '1', '2'),
+ GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
+ GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'),
+ GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y')
+ };
/* make a list of all available caps */
- capslist = gst_caps_new_empty();
+ capslist = gst_caps_new_empty ();
for (i = 0; i < 5; i++) {
- gst_caps_append_structure (capslist,
- gst_structure_new ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, format[i],
- "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE,
- NULL));
+ gst_caps_append_structure (capslist,
+ gst_structure_new ("video/x-raw-yuv",
+ "format", GST_TYPE_FOURCC, format[i],
+ "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+ "height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL));
}
sink_template = gst_pad_template_new ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- capslist);
-
+ GST_PAD_SINK, GST_PAD_ALWAYS, capslist);
+
gst_element_class_add_pad_template (element_class, sink_template);
gst_element_class_set_details (element_class, &gst_sdlvideosink_details);
}
static void
-gst_sdlvideosink_dispose (GObject *obj)
+gst_sdlvideosink_dispose (GObject * obj)
{
g_mutex_free (GST_SDLVIDEOSINK (obj)->lock);
@@ -169,16 +159,16 @@ gst_sdlvideosink_dispose (GObject *obj)
}
static void
-gst_sdlvideosink_class_init (GstSDLVideoSinkClass *klass)
+gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstVideoSinkClass *gstvs_class;
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
- gstvs_class = (GstVideoSinkClass*) klass;
-
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstvs_class = (GstVideoSinkClass *) klass;
+
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_sdlvideosink_set_property;
@@ -186,19 +176,17 @@ gst_sdlvideosink_class_init (GstSDLVideoSinkClass *klass)
gobject_class->dispose = gst_sdlvideosink_dispose;
gstelement_class->change_state = gst_sdlvideosink_change_state;
-
+
/*gstvs_class->set_video_out = gst_sdlvideosink_set_video_out;
- gstvs_class->push_ui_event = gst_sdlvideosink_push_ui_event;
- gstvs_class->set_geometry = gst_sdlvideosink_set_geometry;*/
+ gstvs_class->push_ui_event = gst_sdlvideosink_push_ui_event;
+ gstvs_class->set_geometry = gst_sdlvideosink_set_geometry; */
}
#if 0
/* FIXME */
static GstBuffer *
-gst_sdlvideosink_buffer_new (GstBufferPool *pool,
- gint64 location,
- guint size,
- gpointer user_data)
+gst_sdlvideosink_buffer_new (GstBufferPool * pool,
+ gint64 location, guint size, gpointer user_data)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (user_data);
GstBuffer *buffer;
@@ -206,7 +194,7 @@ gst_sdlvideosink_buffer_new (GstBufferPool *pool,
if (!sdlvideosink->overlay)
return NULL;
- if (!gst_sdlvideosink_lock(sdlvideosink)) {
+ if (!gst_sdlvideosink_lock (sdlvideosink)) {
return NULL;
}
@@ -219,10 +207,9 @@ gst_sdlvideosink_buffer_new (GstBufferPool *pool,
if (sdlvideosink->format == SDL_YV12_OVERLAY ||
sdlvideosink->format == SDL_IYUV_OVERLAY) {
GST_BUFFER_SIZE (buffer) =
- sdlvideosink->width * sdlvideosink->height * 3/2;
+ sdlvideosink->width * sdlvideosink->height * 3 / 2;
} else {
- GST_BUFFER_SIZE (buffer) =
- sdlvideosink->width * sdlvideosink->height * 2;
+ GST_BUFFER_SIZE (buffer) = sdlvideosink->width * sdlvideosink->height * 2;
}
GST_BUFFER_MAXSIZE (buffer) = GST_BUFFER_SIZE (buffer);
@@ -230,21 +217,20 @@ gst_sdlvideosink_buffer_new (GstBufferPool *pool,
}
static void
-gst_sdlvideosink_buffer_free (GstBufferPool *pool,
- GstBuffer *buffer,
- gpointer user_data)
+gst_sdlvideosink_buffer_free (GstBufferPool * pool,
+ GstBuffer * buffer, gpointer user_data)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (user_data);
g_mutex_unlock (sdlvideosink->lock);
- gst_sdlvideosink_unlock(sdlvideosink);
+ gst_sdlvideosink_unlock (sdlvideosink);
gst_buffer_default_free (buffer);
}
static GstBufferPool *
-gst_sdlvideosink_get_bufferpool (GstPad *pad)
+gst_sdlvideosink_get_bufferpool (GstPad * pad)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (gst_pad_get_parent (pad));
@@ -256,19 +242,19 @@ gst_sdlvideosink_get_bufferpool (GstPad *pad)
#endif
static void
-gst_sdlvideosink_init (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_init (GstSDLVideoSink * sdlvideosink)
{
GST_VIDEOSINK_PAD (sdlvideosink) = gst_pad_new_from_template (sink_template,
- "sink");
+ "sink");
gst_element_add_pad (GST_ELEMENT (sdlvideosink),
- GST_VIDEOSINK_PAD (sdlvideosink));
+ GST_VIDEOSINK_PAD (sdlvideosink));
gst_pad_set_chain_function (GST_VIDEOSINK_PAD (sdlvideosink),
- gst_sdlvideosink_chain);
+ gst_sdlvideosink_chain);
gst_pad_set_link_function (GST_VIDEOSINK_PAD (sdlvideosink),
- gst_sdlvideosink_sinkconnect);
+ gst_sdlvideosink_sinkconnect);
gst_pad_set_fixate_function (GST_VIDEOSINK_PAD (sdlvideosink),
- gst_sdlvideosink_fixate);
+ gst_sdlvideosink_fixate);
sdlvideosink->width = -1;
sdlvideosink->height = -1;
@@ -285,28 +271,26 @@ gst_sdlvideosink_init (GstSDLVideoSink *sdlvideosink)
sdlvideosink->lock = g_mutex_new ();
#if 0
- sdlvideosink->bufferpool = gst_buffer_pool_new (
- NULL, /* free */
- NULL, /* copy */
- (GstBufferPoolBufferNewFunction) gst_sdlvideosink_buffer_new,
- NULL, /* buffer copy, the default is fine */
- (GstBufferPoolBufferFreeFunction) gst_sdlvideosink_buffer_free,
- sdlvideosink);
+ sdlvideosink->bufferpool = gst_buffer_pool_new (NULL, /* free */
+ NULL, /* copy */
+ (GstBufferPoolBufferNewFunction) gst_sdlvideosink_buffer_new, NULL, /* buffer copy, the default is fine */
+ (GstBufferPoolBufferFreeFunction) gst_sdlvideosink_buffer_free,
+ sdlvideosink);
#endif
- GST_FLAG_SET(sdlvideosink, GST_ELEMENT_THREAD_SUGGESTED);
- GST_FLAG_SET(sdlvideosink, GST_ELEMENT_EVENT_AWARE);
+ GST_FLAG_SET (sdlvideosink, GST_ELEMENT_THREAD_SUGGESTED);
+ GST_FLAG_SET (sdlvideosink, GST_ELEMENT_EVENT_AWARE);
}
static void
-gst_sdlvideosink_interface_init (GstImplementsInterfaceClass *klass)
+gst_sdlvideosink_interface_init (GstImplementsInterfaceClass * klass)
{
klass->supported = gst_sdlvideosink_supported;
}
static gboolean
-gst_sdlvideosink_supported (GstImplementsInterface *interface,
- GType iface_type)
+gst_sdlvideosink_supported (GstImplementsInterface * interface,
+ GType iface_type)
{
g_assert (iface_type == GST_TYPE_X_OVERLAY);
@@ -315,13 +299,13 @@ gst_sdlvideosink_supported (GstImplementsInterface *interface,
}
static void
-gst_sdlvideosink_xoverlay_init (GstXOverlayClass *klass)
+gst_sdlvideosink_xoverlay_init (GstXOverlayClass * klass)
{
klass->set_xwindow_id = gst_sdlvideosink_xoverlay_set_xwindow_id;
}
static void
-gst_sdlvideosink_xoverlay_set_xwindow_id (GstXOverlay *overlay,
+gst_sdlvideosink_xoverlay_set_xwindow_id (GstXOverlay * overlay,
unsigned long parent)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (overlay);
@@ -344,20 +328,19 @@ gst_sdlvideosink_xoverlay_set_xwindow_id (GstXOverlay *overlay,
static guint32
-gst_sdlvideosink_get_sdl_from_fourcc (GstSDLVideoSink *sdlvideosink,
- guint32 code)
+gst_sdlvideosink_get_sdl_from_fourcc (GstSDLVideoSink * sdlvideosink,
+ guint32 code)
{
- switch (code)
- {
- case GST_MAKE_FOURCC('I','4','2','0'):
+ switch (code) {
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
return SDL_IYUV_OVERLAY;
- case GST_MAKE_FOURCC('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
return SDL_YV12_OVERLAY;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
return SDL_YUY2_OVERLAY;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
return SDL_UYVY_OVERLAY;
- case GST_MAKE_FOURCC('Y','V','Y','U'):
+ case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
return SDL_YVYU_OVERLAY;
default:
return 0;
@@ -366,29 +349,26 @@ gst_sdlvideosink_get_sdl_from_fourcc (GstSDLVideoSink *sdlvideosink,
static gboolean
-gst_sdlvideosink_lock (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_lock (GstSDLVideoSink * sdlvideosink)
{
/* assure that we've got a screen */
if (!sdlvideosink->screen || !sdlvideosink->overlay) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("Tried to lock screen without being set-up"));
+ ("Tried to lock screen without being set-up"));
return FALSE;
}
/* Lock SDL/yuv-overlay */
- if (SDL_MUSTLOCK(sdlvideosink->screen))
- {
- if (SDL_LockSurface(sdlvideosink->screen) < 0)
- {
+ if (SDL_MUSTLOCK (sdlvideosink->screen)) {
+ if (SDL_LockSurface (sdlvideosink->screen) < 0) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: couldn't lock the SDL video window: %s", SDL_GetError()));
+ ("SDL: couldn't lock the SDL video window: %s", SDL_GetError ()));
return FALSE;
}
}
- if (SDL_LockYUVOverlay(sdlvideosink->overlay) < 0)
- {
+ if (SDL_LockYUVOverlay (sdlvideosink->overlay) < 0) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: couldn\'t lock the SDL YUV overlay: %s", SDL_GetError()));
+ ("SDL: couldn\'t lock the SDL YUV overlay: %s", SDL_GetError ()));
return FALSE;
}
@@ -399,16 +379,16 @@ gst_sdlvideosink_lock (GstSDLVideoSink *sdlvideosink)
static void
-gst_sdlvideosink_unlock (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_unlock (GstSDLVideoSink * sdlvideosink)
{
/* Unlock SDL_overlay */
- SDL_UnlockYUVOverlay(sdlvideosink->overlay);
- if (SDL_MUSTLOCK(sdlvideosink->screen))
- SDL_UnlockSurface(sdlvideosink->screen);
+ SDL_UnlockYUVOverlay (sdlvideosink->overlay);
+ if (SDL_MUSTLOCK (sdlvideosink->screen))
+ SDL_UnlockSurface (sdlvideosink->screen);
}
static void
-gst_sdlvideosink_deinitsdl (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_deinitsdl (GstSDLVideoSink * sdlvideosink)
{
if (sdlvideosink->init) {
SDL_Quit ();
@@ -417,22 +397,23 @@ gst_sdlvideosink_deinitsdl (GstSDLVideoSink *sdlvideosink)
}
static gboolean
-gst_sdlvideosink_initsdl (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_initsdl (GstSDLVideoSink * sdlvideosink)
{
gst_sdlvideosink_deinitsdl (sdlvideosink);
if (!sdlvideosink->xwindow_id) {
- unsetenv("SDL_WINDOWID");
+ unsetenv ("SDL_WINDOWID");
} else {
char SDL_hack[32];
- sprintf(SDL_hack, "%lu", sdlvideosink->xwindow_id);
- setenv("SDL_WINDOWID", SDL_hack, 1);
+
+ sprintf (SDL_hack, "%lu", sdlvideosink->xwindow_id);
+ setenv ("SDL_WINDOWID", SDL_hack, 1);
}
/* Initialize the SDL library */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0 ) {
+ if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, INIT, (NULL),
- ("Couldn't initialize SDL: %s", SDL_GetError()));
+ ("Couldn't initialize SDL: %s", SDL_GetError ()));
return FALSE;
}
@@ -440,10 +421,10 @@ gst_sdlvideosink_initsdl (GstSDLVideoSink *sdlvideosink)
}
static void
-gst_sdlvideosink_destroy (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_destroy (GstSDLVideoSink * sdlvideosink)
{
if (sdlvideosink->overlay) {
- SDL_FreeYUVOverlay(sdlvideosink->overlay);
+ SDL_FreeYUVOverlay (sdlvideosink->overlay);
sdlvideosink->overlay = NULL;
}
@@ -454,7 +435,7 @@ gst_sdlvideosink_destroy (GstSDLVideoSink *sdlvideosink)
}
static gboolean
-gst_sdlvideosink_create (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_create (GstSDLVideoSink * sdlvideosink)
{
if (GST_VIDEOSINK_HEIGHT (sdlvideosink) <= 0)
GST_VIDEOSINK_HEIGHT (sdlvideosink) = sdlvideosink->height;
@@ -464,34 +445,30 @@ gst_sdlvideosink_create (GstSDLVideoSink *sdlvideosink)
gst_sdlvideosink_destroy (sdlvideosink);
/* create a SDL window of the size requested by the user */
- sdlvideosink->screen = SDL_SetVideoMode(GST_VIDEOSINK_WIDTH (sdlvideosink),
- GST_VIDEOSINK_HEIGHT (sdlvideosink), 0, SDL_HWSURFACE | SDL_RESIZABLE);
- if (sdlvideosink->screen == NULL)
- {
+ sdlvideosink->screen = SDL_SetVideoMode (GST_VIDEOSINK_WIDTH (sdlvideosink),
+ GST_VIDEOSINK_HEIGHT (sdlvideosink), 0, SDL_HWSURFACE | SDL_RESIZABLE);
+ if (sdlvideosink->screen == NULL) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: Couldn't set %dx%d: %s", GST_VIDEOSINK_WIDTH (sdlvideosink),
- GST_VIDEOSINK_HEIGHT (sdlvideosink), SDL_GetError()));
+ ("SDL: Couldn't set %dx%d: %s", GST_VIDEOSINK_WIDTH (sdlvideosink),
+ GST_VIDEOSINK_HEIGHT (sdlvideosink), SDL_GetError ()));
return FALSE;
}
/* create a new YUV overlay */
- sdlvideosink->overlay = SDL_CreateYUVOverlay(sdlvideosink->width,
- sdlvideosink->height, sdlvideosink->format, sdlvideosink->screen);
- if ( sdlvideosink->overlay == NULL )
- {
+ sdlvideosink->overlay = SDL_CreateYUVOverlay (sdlvideosink->width,
+ sdlvideosink->height, sdlvideosink->format, sdlvideosink->screen);
+ if (sdlvideosink->overlay == NULL) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: Couldn't create SDL YUV overlay (%dx%d \'" GST_FOURCC_FORMAT "\'): %s",
- sdlvideosink->width, sdlvideosink->height,
- GST_FOURCC_ARGS(sdlvideosink->format), SDL_GetError()));
+ ("SDL: Couldn't create SDL YUV overlay (%dx%d \'" GST_FOURCC_FORMAT
+ "\'): %s", sdlvideosink->width, sdlvideosink->height,
+ GST_FOURCC_ARGS (sdlvideosink->format), SDL_GetError ()));
return FALSE;
- }
- else
- {
- GST_DEBUG("Using a %dx%d %dbpp SDL screen with a %dx%d \'" GST_FOURCC_FORMAT "\' YUV overlay",
- GST_VIDEOSINK_WIDTH (sdlvideosink), GST_VIDEOSINK_HEIGHT (sdlvideosink),
- sdlvideosink->screen->format->BitsPerPixel,
- sdlvideosink->width, sdlvideosink->height,
- GST_FOURCC_ARGS(sdlvideosink->format));
+ } else {
+ GST_DEBUG ("Using a %dx%d %dbpp SDL screen with a %dx%d \'"
+ GST_FOURCC_FORMAT "\' YUV overlay", GST_VIDEOSINK_WIDTH (sdlvideosink),
+ GST_VIDEOSINK_HEIGHT (sdlvideosink),
+ sdlvideosink->screen->format->BitsPerPixel, sdlvideosink->width,
+ sdlvideosink->height, GST_FOURCC_ARGS (sdlvideosink->format));
}
sdlvideosink->rect.x = 0;
@@ -499,24 +476,24 @@ gst_sdlvideosink_create (GstSDLVideoSink *sdlvideosink)
sdlvideosink->rect.w = GST_VIDEOSINK_WIDTH (sdlvideosink);
sdlvideosink->rect.h = GST_VIDEOSINK_HEIGHT (sdlvideosink);
- SDL_DisplayYUVOverlay(sdlvideosink->overlay, &(sdlvideosink->rect));
+ SDL_DisplayYUVOverlay (sdlvideosink->overlay, &(sdlvideosink->rect));
GST_DEBUG ("sdlvideosink: setting %08x (" GST_FOURCC_FORMAT ")",
- sdlvideosink->format, GST_FOURCC_ARGS(sdlvideosink->format));
+ sdlvideosink->format, GST_FOURCC_ARGS (sdlvideosink->format));
gst_x_overlay_got_desired_size (GST_X_OVERLAY (sdlvideosink),
- GST_VIDEOSINK_WIDTH (sdlvideosink),
- GST_VIDEOSINK_HEIGHT (sdlvideosink));
+ GST_VIDEOSINK_WIDTH (sdlvideosink), GST_VIDEOSINK_HEIGHT (sdlvideosink));
return TRUE;
}
static GstCaps *
-gst_sdlvideosink_fixate (GstPad *pad, const GstCaps *caps)
+gst_sdlvideosink_fixate (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure;
GstCaps *newcaps;
- if (gst_caps_get_size (caps) > 1) return NULL;
+ if (gst_caps_get_size (caps) > 1)
+ return NULL;
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
@@ -528,7 +505,7 @@ gst_sdlvideosink_fixate (GstPad *pad, const GstCaps *caps)
return newcaps;
}
if (gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
- 30.0)) {
+ 30.0)) {
return newcaps;
}
@@ -537,8 +514,7 @@ gst_sdlvideosink_fixate (GstPad *pad, const GstCaps *caps)
}
static GstPadLinkReturn
-gst_sdlvideosink_sinkconnect (GstPad *pad,
- const GstCaps *vscapslist)
+gst_sdlvideosink_sinkconnect (GstPad * pad, const GstCaps * vscapslist)
{
GstSDLVideoSink *sdlvideosink;
guint32 format;
@@ -549,11 +525,11 @@ gst_sdlvideosink_sinkconnect (GstPad *pad,
structure = gst_caps_get_structure (vscapslist, 0);
gst_structure_get_fourcc (structure, "format", &format);
sdlvideosink->format =
- gst_sdlvideosink_get_sdl_from_fourcc (sdlvideosink, format);
+ gst_sdlvideosink_get_sdl_from_fourcc (sdlvideosink, format);
gst_structure_get_int (structure, "width", &sdlvideosink->width);
gst_structure_get_int (structure, "height", &sdlvideosink->height);
- if (!sdlvideosink->format || !gst_sdlvideosink_create(sdlvideosink))
+ if (!sdlvideosink->format || !gst_sdlvideosink_create (sdlvideosink))
return GST_PAD_LINK_REFUSED;
return GST_PAD_LINK_OK;
@@ -561,7 +537,7 @@ gst_sdlvideosink_sinkconnect (GstPad *pad,
static void
-gst_sdlvideosink_chain (GstPad *pad, GstData *_data)
+gst_sdlvideosink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstSDLVideoSink *sdlvideosink;
@@ -581,7 +557,7 @@ gst_sdlvideosink_chain (GstPad *pad, GstData *_data)
case GST_EVENT_DISCONTINUOUS:
offset = GST_EVENT_DISCONT_OFFSET (event, 0).value;
/*gst_clock_handle_discont (sdlvideosink->clock,
- (guint64) GST_EVENT_DISCONT_OFFSET (event, 0).value);*/
+ (guint64) GST_EVENT_DISCONT_OFFSET (event, 0).value); */
break;
default:
gst_pad_event_default (pad, event);
@@ -596,61 +572,59 @@ gst_sdlvideosink_chain (GstPad *pad, GstData *_data)
}
if (GST_BUFFER_DATA (buf) != sdlvideosink->overlay->pixels[0]) {
- if (!gst_sdlvideosink_lock(sdlvideosink)) {
+ if (!gst_sdlvideosink_lock (sdlvideosink)) {
return;
}
/* buf->yuv - FIXME: bufferpool! */
if (sdlvideosink->format == SDL_IYUV_OVERLAY ||
- sdlvideosink->format == SDL_YV12_OVERLAY)
- {
+ sdlvideosink->format == SDL_YV12_OVERLAY) {
memcpy (sdlvideosink->overlay->pixels[0], GST_BUFFER_DATA (buf),
- sdlvideosink->width * sdlvideosink->height);
+ sdlvideosink->width * sdlvideosink->height);
memcpy (sdlvideosink->overlay->pixels[1],
- GST_BUFFER_DATA (buf) + sdlvideosink->width*sdlvideosink->height,
- sdlvideosink->width * sdlvideosink->height / 4);
+ GST_BUFFER_DATA (buf) + sdlvideosink->width * sdlvideosink->height,
+ sdlvideosink->width * sdlvideosink->height / 4);
memcpy (sdlvideosink->overlay->pixels[2],
- GST_BUFFER_DATA (buf) + sdlvideosink->width*sdlvideosink->height*5/4,
- sdlvideosink->width * sdlvideosink->height / 4);
+ GST_BUFFER_DATA (buf) +
+ sdlvideosink->width * sdlvideosink->height * 5 / 4,
+ sdlvideosink->width * sdlvideosink->height / 4);
} else {
memcpy (sdlvideosink->overlay->pixels[0], GST_BUFFER_DATA (buf),
- sdlvideosink->width * sdlvideosink->height * 2);
+ sdlvideosink->width * sdlvideosink->height * 2);
}
- gst_sdlvideosink_unlock(sdlvideosink);
+ gst_sdlvideosink_unlock (sdlvideosink);
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
/* Show, baby, show! */
- SDL_DisplayYUVOverlay(sdlvideosink->overlay, &(sdlvideosink->rect));
+ SDL_DisplayYUVOverlay (sdlvideosink->overlay, &(sdlvideosink->rect));
- while (SDL_PollEvent(&sdl_event))
- {
- switch(sdl_event.type)
- {
+ while (SDL_PollEvent (&sdl_event)) {
+ switch (sdl_event.type) {
case SDL_VIDEORESIZE:
- /* create a SDL window of the size requested by the user */
- GST_VIDEOSINK_WIDTH (sdlvideosink) = sdl_event.resize.w;
- GST_VIDEOSINK_HEIGHT (sdlvideosink) = sdl_event.resize.h;
- gst_sdlvideosink_create(sdlvideosink);
- break;
+ /* create a SDL window of the size requested by the user */
+ GST_VIDEOSINK_WIDTH (sdlvideosink) = sdl_event.resize.w;
+ GST_VIDEOSINK_HEIGHT (sdlvideosink) = sdl_event.resize.h;
+ gst_sdlvideosink_create (sdlvideosink);
+ break;
}
}
}
static void
-gst_sdlvideosink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_sdlvideosink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSDLVideoSink *sdlvideosink;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SDLVIDEOSINK (object));
- sdlvideosink = GST_SDLVIDEOSINK(object);
+ sdlvideosink = GST_SDLVIDEOSINK (object);
- switch (prop_id)
- {
+ switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -659,13 +633,14 @@ gst_sdlvideosink_set_property (GObject *object, guint prop_id, const GValue *val
static void
-gst_sdlvideosink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_sdlvideosink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSDLVideoSink *sdlvideosink;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SDLVIDEOSINK (object));
- sdlvideosink = GST_SDLVIDEOSINK(object);
+ sdlvideosink = GST_SDLVIDEOSINK (object);
switch (prop_id) {
default:
@@ -676,17 +651,17 @@ gst_sdlvideosink_get_property (GObject *object, guint prop_id, GValue *value, GP
static GstElementStateReturn
-gst_sdlvideosink_change_state (GstElement *element)
+gst_sdlvideosink_change_state (GstElement * element)
{
GstSDLVideoSink *sdlvideosink;
+
g_return_val_if_fail (GST_IS_SDLVIDEOSINK (element), GST_STATE_FAILURE);
- sdlvideosink = GST_SDLVIDEOSINK(element);
+ sdlvideosink = GST_SDLVIDEOSINK (element);
- switch (GST_STATE_TRANSITION (element))
- {
+ switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!gst_sdlvideosink_initsdl (sdlvideosink))
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
GST_FLAG_SET (sdlvideosink, GST_SDLVIDEOSINK_OPEN);
break;
case GST_STATE_PAUSED_TO_READY:
@@ -696,7 +671,7 @@ gst_sdlvideosink_change_state (GstElement *element)
gst_sdlvideosink_deinitsdl (sdlvideosink);
GST_FLAG_UNSET (sdlvideosink, GST_SDLVIDEOSINK_OPEN);
break;
- default: /* do nothing */
+ default: /* do nothing */
break;
}
@@ -708,25 +683,20 @@ gst_sdlvideosink_change_state (GstElement *element)
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* Loading the library containing GstVideoSink, our parent object */
if (!gst_library_load ("gstvideo"))
return FALSE;
- if (!gst_element_register (plugin, "sdlvideosink", GST_RANK_NONE, GST_TYPE_SDLVIDEOSINK))
+ if (!gst_element_register (plugin, "sdlvideosink", GST_RANK_NONE,
+ GST_TYPE_SDLVIDEOSINK))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "sdlvideosink",
- "SDL Video Sink",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "sdlvideosink",
+ "SDL Video Sink", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/sdl/sdlvideosink.h b/ext/sdl/sdlvideosink.h
index ad682385..5c42abc4 100644
--- a/ext/sdl/sdlvideosink.h
+++ b/ext/sdl/sdlvideosink.h
@@ -25,7 +25,6 @@
#include <SDL.h>
G_BEGIN_DECLS
-
#define GST_TYPE_SDLVIDEOSINK \
(gst_sdlvideosink_get_type())
#define GST_SDLVIDEOSINK(obj) \
@@ -36,9 +35,9 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SDLVIDEOSINK))
#define GST_IS_SDLVIDEOSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SDLVIDEOSINK))
-
-typedef enum {
- GST_SDLVIDEOSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+{
+ GST_SDLVIDEOSINK_OPEN = GST_ELEMENT_FLAG_LAST,
GST_SDLVIDEOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} GstSDLVideoSinkFlags;
@@ -46,11 +45,12 @@ typedef enum {
typedef struct _GstSDLVideoSink GstSDLVideoSink;
typedef struct _GstSDLVideoSinkClass GstSDLVideoSinkClass;
-struct _GstSDLVideoSink {
+struct _GstSDLVideoSink
+{
GstVideoSink videosink;
guint32 format;
- gint width, height; /* the size of the incoming YUV stream */
+ gint width, height; /* the size of the incoming YUV stream */
unsigned long xwindow_id;
gboolean init;
@@ -62,13 +62,13 @@ struct _GstSDLVideoSink {
GMutex *lock;
};
-struct _GstSDLVideoSinkClass {
+struct _GstSDLVideoSinkClass
+{
GstVideoSinkClass parent_class;
};
-GType gst_sdlsink_get_type(void);
+GType gst_sdlsink_get_type (void);
G_END_DECLS
-
#endif /* __GST_SDLVIDEOSINK_H__ */