summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/cdrom/gstcdplayer.c105
-rw-r--r--sys/cdrom/gstcdplayer.h41
-rw-r--r--sys/cdrom/gstcdplayer_ioctl.c71
-rw-r--r--sys/cdrom/gstcdplayer_ioctl.h47
-rw-r--r--sys/cdrom/gstcdplayer_ioctl_bsd.h556
-rw-r--r--sys/cdrom/gstcdplayer_ioctl_irix.h91
-rw-r--r--sys/cdrom/gstcdplayer_ioctl_solaris.h289
-rw-r--r--sys/dxr3/ac3_padder.c289
-rw-r--r--sys/dxr3/ac3_padder.h47
-rw-r--r--sys/dxr3/dxr3audiosink.c398
-rw-r--r--sys/dxr3/dxr3audiosink.h66
-rw-r--r--sys/dxr3/dxr3init.c24
-rw-r--r--sys/dxr3/dxr3spusink.c282
-rw-r--r--sys/dxr3/dxr3spusink.h40
-rw-r--r--sys/dxr3/dxr3videosink.c431
-rw-r--r--sys/dxr3/dxr3videosink.h38
-rw-r--r--sys/glsink/ARB_multitexture.h661
-rw-r--r--sys/glsink/EXT_paletted_texture.h221
-rw-r--r--sys/glsink/NV_register_combiners.h361
-rw-r--r--sys/glsink/gstgl_nvimage.c412
-rw-r--r--sys/glsink/gstgl_pdrimage.c411
-rw-r--r--sys/glsink/gstgl_rgbimage.c381
-rw-r--r--sys/glsink/gstglsink.c550
-rw-r--r--sys/glsink/gstglsink.h127
-rw-r--r--sys/glsink/gstglxwindow.c266
-rw-r--r--sys/glsink/regcomb_yuvrgb.c583
-rw-r--r--sys/qcam/dark.c65
-rw-r--r--sys/qcam/exposure.c99
-rw-r--r--sys/qcam/gstqcamsrc.c274
-rw-r--r--sys/qcam/gstqcamsrc.h48
-rw-r--r--sys/qcam/qcam-Linux.c202
-rw-r--r--sys/qcam/qcam-Linux.h2
-rw-r--r--sys/qcam/qcam-lib.c595
-rw-r--r--sys/qcam/qcam-os.c202
-rw-r--r--sys/qcam/qcam-os.h2
-rw-r--r--sys/qcam/qcam.h117
-rw-r--r--sys/qcam/qcamip.h18
-rw-r--r--sys/v4l2/gstv4l2.c22
-rw-r--r--sys/v4l2/gstv4l2colorbalance.c60
-rw-r--r--sys/v4l2/gstv4l2colorbalance.h12
-rw-r--r--sys/v4l2/gstv4l2element.c731
-rw-r--r--sys/v4l2/gstv4l2element.h68
-rw-r--r--sys/v4l2/gstv4l2src.c856
-rw-r--r--sys/v4l2/gstv4l2src.h97
-rw-r--r--sys/v4l2/gstv4l2tuner.c108
-rw-r--r--sys/v4l2/gstv4l2tuner.h28
-rw-r--r--sys/v4l2/gstv4l2xoverlay.c40
-rw-r--r--sys/v4l2/gstv4l2xoverlay.h13
-rw-r--r--sys/v4l2/v4l2-overlay_calls.c144
-rw-r--r--sys/v4l2/v4l2_calls.c942
-rw-r--r--sys/v4l2/v4l2_calls.h60
-rw-r--r--sys/v4l2/v4l2src_calls.c304
-rw-r--r--sys/v4l2/v4l2src_calls.h41
-rw-r--r--sys/vcd/vcdsrc.c242
-rw-r--r--sys/vcd/vcdsrc.h74
55 files changed, 6322 insertions, 5932 deletions
diff --git a/sys/cdrom/gstcdplayer.c b/sys/cdrom/gstcdplayer.c
index 92f75b86..f76e9df6 100644
--- a/sys/cdrom/gstcdplayer.c
+++ b/sys/cdrom/gstcdplayer.c
@@ -41,30 +41,27 @@ enum
LAST_SIGNAL,
};
-static void cdplayer_base_init (gpointer g_class);
-static void cdplayer_class_init (CDPlayerClass *klass);
-static void cdplayer_init (CDPlayer *cdp);
-static void cdplayer_dispose (GObject *object);
+static void cdplayer_base_init (gpointer g_class);
+static void cdplayer_class_init (CDPlayerClass * klass);
+static void cdplayer_init (CDPlayer * cdp);
+static void cdplayer_dispose (GObject * object);
-static void cdplayer_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *spec);
-static void cdplayer_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *spec);
-static gboolean cdplayer_iterate (GstBin *bin);
+static void cdplayer_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * spec);
+static void cdplayer_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * spec);
+static gboolean cdplayer_iterate (GstBin * bin);
-static GstElementStateReturn
- cdplayer_change_state (GstElement * element);
+static GstElementStateReturn cdplayer_change_state (GstElement * element);
static GstElementClass *parent_class;
static guint cdplayer_signals[LAST_SIGNAL] = { 0 };
-static GstElementDetails cdplayer_details = GST_ELEMENT_DETAILS (
- "CD Player",
- "Generic/Bin",
- "Play CD audio through the CD Drive",
- "Charles Schmidt <cbschmid@uiuc.edu>, "
- "Wim Taymans <wim.taymans@chello.be>"
-);
+static GstElementDetails cdplayer_details = GST_ELEMENT_DETAILS ("CD Player",
+ "Generic/Bin",
+ "Play CD audio through the CD Drive",
+ "Charles Schmidt <cbschmid@uiuc.edu>, "
+ "Wim Taymans <wim.taymans@chello.be>");
GType
@@ -86,7 +83,8 @@ cdplayer_get_type (void)
NULL
};
- cdplayer_type = g_type_register_static (GST_TYPE_BIN, "CDPlayer", &cdplayer_info, 0);
+ cdplayer_type =
+ g_type_register_static (GST_TYPE_BIN, "CDPlayer", &cdplayer_info, 0);
}
return cdplayer_type;
@@ -121,33 +119,31 @@ cdplayer_class_init (CDPlayerClass * klass)
gobject_klass->get_property = cdplayer_get_property;
g_object_class_install_property (gobject_klass, ARG_DEVICE,
- g_param_spec_string ("device", "device", "CDROM device", NULL,
- G_PARAM_READWRITE));
+ g_param_spec_string ("device", "device", "CDROM device", NULL,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_NUM_TRACKS,
- g_param_spec_int ("num_tracks", "num_tracks", "Number of Tracks",
- G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
+ g_param_spec_int ("num_tracks", "num_tracks", "Number of Tracks",
+ G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_klass, ARG_START_TRACK,
- g_param_spec_int ("start_track", "start_track",
- "Track to start playback on", 1,
- CDPLAYER_MAX_TRACKS - 1, 1,
- G_PARAM_READWRITE));
+ g_param_spec_int ("start_track", "start_track",
+ "Track to start playback on", 1,
+ CDPLAYER_MAX_TRACKS - 1, 1, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_END_TRACK,
- g_param_spec_int ("end_track", "end_track",
- "Track to end playback on", 0,
- CDPLAYER_MAX_TRACKS - 1, 0,
- G_PARAM_READWRITE));
+ g_param_spec_int ("end_track", "end_track",
+ "Track to end playback on", 0,
+ CDPLAYER_MAX_TRACKS - 1, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_CURRENT_TRACK,
- g_param_spec_int ("current_track", "current_track",
- "Current track playing", 1,
- CDPLAYER_MAX_TRACKS - 1, 1, G_PARAM_READABLE));
+ g_param_spec_int ("current_track", "current_track",
+ "Current track playing", 1,
+ CDPLAYER_MAX_TRACKS - 1, 1, G_PARAM_READABLE));
g_object_class_install_property (gobject_klass, ARG_CDDB_DISCID,
- g_param_spec_uint ("cddb_discid", "cddb_discid", "CDDB Disc ID",
- 0, G_MAXUINT, 1, G_PARAM_READABLE));
+ g_param_spec_uint ("cddb_discid", "cddb_discid", "CDDB Disc ID",
+ 0, G_MAXUINT, 1, G_PARAM_READABLE));
cdplayer_signals[TRACK_CHANGE] =
- g_signal_new ("track-change", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CDPlayerClass, track_change), NULL, NULL,
- gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("track-change", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CDPlayerClass, track_change), NULL,
+ NULL, gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
return;
}
@@ -169,7 +165,8 @@ cdplayer_init (CDPlayer * cdp)
}
static void
-cdplayer_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * spec)
+cdplayer_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * spec)
{
CDPlayer *cdp;
@@ -204,7 +201,8 @@ cdplayer_set_property (GObject * object, guint prop_id, const GValue * value, GP
static void
-cdplayer_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * spec)
+cdplayer_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * spec)
{
CDPlayer *cdp;
@@ -268,7 +266,8 @@ cdplayer_iterate (GstBin * bin)
if (current_track != -1 && current_track != cdp->current_track) {
cdp->current_track = current_track;
- g_signal_emit (G_OBJECT (cdp), cdplayer_signals[TRACK_CHANGE], 0, cdp->current_track);
+ g_signal_emit (G_OBJECT (cdp), cdplayer_signals[TRACK_CHANGE], 0,
+ cdp->current_track);
}
return TRUE;
@@ -328,7 +327,8 @@ cdplayer_change_state (GstElement * element)
cdp->paused = FALSE;
} else {
- if (cd_start (CDPLAYER_CD (cdp), cdp->start_track, cdp->end_track) == FALSE) {
+ if (cd_start (CDPLAYER_CD (cdp), cdp->start_track,
+ cdp->end_track) == FALSE) {
return GST_STATE_FAILURE;
}
}
@@ -336,7 +336,8 @@ cdplayer_change_state (GstElement * element)
break;
case GST_STATE_NULL:
/* stop & close fd */
- if (cd_stop (CDPLAYER_CD (cdp)) == FALSE || cd_close (CDPLAYER_CD (cdp)) == FALSE) {
+ if (cd_stop (CDPLAYER_CD (cdp)) == FALSE
+ || cd_close (CDPLAYER_CD (cdp)) == FALSE) {
return GST_STATE_FAILURE;
}
@@ -356,17 +357,9 @@ cdplayer_change_state (GstElement * element)
static gboolean
plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "cdplayer", GST_RANK_NONE, GST_TYPE_CDPLAYER);
+ return gst_element_register (plugin, "cdplayer", GST_RANK_NONE,
+ GST_TYPE_CDPLAYER);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "cdplayer",
- "CD Player",
- plugin_init,
- VERSION,
- GST_LICENSE, /* ? */
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "cdplayer", "CD Player", plugin_init, VERSION, GST_LICENSE, /* ? */
+ GST_PACKAGE, GST_ORIGIN);
diff --git a/sys/cdrom/gstcdplayer.h b/sys/cdrom/gstcdplayer.h
index 7c6c4bf9..60d0b606 100644
--- a/sys/cdrom/gstcdplayer.h
+++ b/sys/cdrom/gstcdplayer.h
@@ -35,30 +35,31 @@
typedef struct _CDPlayer CDPlayer;
typedef struct _CDPlayerClass CDPlayerClass;
-struct _CDPlayer {
- GstBin element;
-
- /* properties */
- gchar *device;
- gint num_tracks;
- gint start_track;
- gint end_track;
- gint current_track;
- guint32 cddb_discid;
+struct _CDPlayer
+{
+ GstBin element;
- /* private */
- struct cd cd;
- gboolean paused;
+ /* properties */
+ gchar *device;
+ gint num_tracks;
+ gint start_track;
+ gint end_track;
+ gint current_track;
+ guint32 cddb_discid;
+
+ /* private */
+ struct cd cd;
+ gboolean paused;
};
-struct _CDPlayerClass {
- GstBinClass parent_class;
+struct _CDPlayerClass
+{
+ GstBinClass parent_class;
- /* signal callbacks */
- void (*track_change) (GstElement *element,guint track);
+ /* signal callbacks */
+ void (*track_change) (GstElement * element, guint track);
};
-GType cdplayer_get_type(void);
-
-#endif
+GType cdplayer_get_type (void);
+#endif
diff --git a/sys/cdrom/gstcdplayer_ioctl.c b/sys/cdrom/gstcdplayer_ioctl.c
index 22ef22be..8cb3891b 100644
--- a/sys/cdrom/gstcdplayer_ioctl.c
+++ b/sys/cdrom/gstcdplayer_ioctl.c
@@ -35,8 +35,9 @@
/* private functions */
-static void cd_fix_track_range(struct cd *cd,gint *start_track,gint *end_track);
-static gint cddb_sum(gint n);
+static void cd_fix_track_range (struct cd *cd, gint * start_track,
+ gint * end_track);
+static gint cddb_sum (gint n);
#if defined(HAVE_LINUX_CDROM_H)
#include <linux/cdrom.h>
@@ -58,7 +59,7 @@ irix cdaudio works quite a bit differently than ioctl(), so its not ready
CDStatus cd_status(struct cd *cd);
gint cd_current_track(struct cd *cd);
gboolean cd_close(struct cd *cd);
-*/
+*/
#if defined(HAVE_CDROM_SOLARIS)
#include "gstcdplayer_ioctl_solaris.h"
#elif defined(HAVE_CDROM_BSD)
@@ -69,25 +70,26 @@ irix cdaudio works quite a bit differently than ioctl(), so its not ready
*/
#endif
-static void cd_fix_track_range(struct cd *cd,gint *start_track,gint *end_track)
+static void
+cd_fix_track_range (struct cd *cd, gint * start_track, gint * end_track)
{
- if (*start_track <= 0) {
- *start_track = 1;
- }
+ if (*start_track <= 0) {
+ *start_track = 1;
+ }
- if (*start_track > cd->num_tracks) {
- *start_track = cd->num_tracks;
- }
+ if (*start_track > cd->num_tracks) {
+ *start_track = cd->num_tracks;
+ }
- if (*end_track < *start_track && *end_track != LEADOUT) {
- *end_track = *start_track;
- }
+ if (*end_track < *start_track && *end_track != LEADOUT) {
+ *end_track = *start_track;
+ }
- if (*end_track > cd->num_tracks || *end_track + 1 > cd->num_tracks) {
- *end_track = LEADOUT;
- }
+ if (*end_track > cd->num_tracks || *end_track + 1 > cd->num_tracks) {
+ *end_track = LEADOUT;
+ }
- return;
+ return;
}
/* this cddb info is from
@@ -96,29 +98,32 @@ static void cd_fix_track_range(struct cd *cd,gint *start_track,gint *end_track)
this will probably be of interest to anyone wishing to actually use the discid
http://www.freedb.org/modules.php?name=Sections&sop=viewarticle&artid=28
*/
-static gint cddb_sum(gint n)
+static gint
+cddb_sum (gint n)
{
- gint ret = 0;
+ gint ret = 0;
- while (n > 0) {
- ret += n % 10;
- n /= 10;
- }
+ while (n > 0) {
+ ret += n % 10;
+ n /= 10;
+ }
- return ret;
+ return ret;
}
-guint32 cd_cddb_discid(struct cd *cd)
+guint32
+cd_cddb_discid (struct cd * cd)
{
- guint i;
- guint n = 0;
- guint t;
+ guint i;
+ guint n = 0;
+ guint t;
- for (i = 1; i <= cd->num_tracks; i++) {
- n += cddb_sum(cd->tracks[i].minute * 60 + cd->tracks[i].second);
- }
+ for (i = 1; i <= cd->num_tracks; i++) {
+ n += cddb_sum (cd->tracks[i].minute * 60 + cd->tracks[i].second);
+ }
- t = (cd->tracks[LEADOUT].minute * 60 + cd->tracks[LEADOUT].second) - (cd->tracks[1].minute * 60 + cd->tracks[1].second);
+ t = (cd->tracks[LEADOUT].minute * 60 + cd->tracks[LEADOUT].second) -
+ (cd->tracks[1].minute * 60 + cd->tracks[1].second);
- return ((n % 0xff) << 24 | t << 8 | (cd->num_tracks));
+ return ((n % 0xff) << 24 | t << 8 | (cd->num_tracks));
}
diff --git a/sys/cdrom/gstcdplayer_ioctl.h b/sys/cdrom/gstcdplayer_ioctl.h
index 65bc2c66..5998276e 100644
--- a/sys/cdrom/gstcdplayer_ioctl.h
+++ b/sys/cdrom/gstcdplayer_ioctl.h
@@ -28,37 +28,40 @@
#define CDPLAYER_MAX_TRACKS 128
-typedef enum {
- CD_PLAYING,
- CD_COMPLETED,
- CD_ERROR
+typedef enum
+{
+ CD_PLAYING,
+ CD_COMPLETED,
+ CD_ERROR
} CDStatus;
-struct cd_msf {
- guint8 minute;
- guint8 second;
- guint8 frame;
+struct cd_msf
+{
+ guint8 minute;
+ guint8 second;
+ guint8 frame;
- gboolean data_track;
+ gboolean data_track;
};
-struct cd {
- gint fd;
- gint num_tracks;
- struct cd_msf tracks[CDPLAYER_MAX_TRACKS];
+struct cd
+{
+ gint fd;
+ gint num_tracks;
+ struct cd_msf tracks[CDPLAYER_MAX_TRACKS];
};
/* these are defined by the different cdrom type header files */
-gboolean cd_init(struct cd *cd,const gchar *device);
-gboolean cd_start(struct cd *cd,gint start_track,gint end_track);
-gboolean cd_pause(struct cd *cd);
-gboolean cd_resume(struct cd *cd);
-gboolean cd_stop(struct cd *cd);
-CDStatus cd_status(struct cd *cd);
-gint cd_current_track(struct cd *cd);
-gboolean cd_close(struct cd *cd);
+gboolean cd_init (struct cd *cd, const gchar * device);
+gboolean cd_start (struct cd *cd, gint start_track, gint end_track);
+gboolean cd_pause (struct cd *cd);
+gboolean cd_resume (struct cd *cd);
+gboolean cd_stop (struct cd *cd);
+CDStatus cd_status (struct cd *cd);
+gint cd_current_track (struct cd *cd);
+gboolean cd_close (struct cd *cd);
-guint32 cd_cddb_discid(struct cd *cd);
+guint32 cd_cddb_discid (struct cd *cd);
#endif
diff --git a/sys/cdrom/gstcdplayer_ioctl_bsd.h b/sys/cdrom/gstcdplayer_ioctl_bsd.h
index f8a94cd7..34c2d9aa 100644
--- a/sys/cdrom/gstcdplayer_ioctl_bsd.h
+++ b/sys/cdrom/gstcdplayer_ioctl_bsd.h
@@ -17,329 +17,337 @@
* Boston, MA 02111-1307, USA.
*/
-#ifdef HAVE_CDROM_BSD_NETBSD /* net & open */
+#ifdef HAVE_CDROM_BSD_NETBSD /* net & open */
#ifndef CDIOREADTOCHDR
#define CDIOREADTOCHDR CDIOREADTOCHEADER
#endif
-gboolean cd_init(struct cd *cd,const gchar *device)
+gboolean
+cd_init (struct cd *cd, const gchar * device)
{
- struct ioc_toc_header toc_header;
- struct ioc_read_toc_entry toc_entry;
- struct cd_toc_entry toc_entry_data;
- guint i;
-
- cd->fd = open(device,O_RDONLY | O_NONBLOCK);
-
- if (cd->fd == -1) {
- return FALSE;
- }
-
- /* get the toc header information */
- if (ioctl(cd->fd,CDIOREADTOCHDR,&toc_header) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- /* read each entry in the toc header */
- for (i = 1; i <= toc_header.ending_track; i++) {
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = i;
- toc_entry.data = &toc_entry_data;
- toc_entry.data_len = sizeof(toc_entry_data);
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[i].minute = toc_entry.data->addr.msf.minute;
- cd->tracks[i].second = toc_entry.data->addr.msf.second;
- cd->tracks[i].frame = toc_entry.data->addr.msf.frame;
- cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
- }
-
- /* read the leadout */
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = 0xAA; /* leadout */
- toc_entry.data = &toc_entry_data;
- toc_entry.data_len = sizeof(toc_entry_data);
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[LEADOUT].minute = toc_entry.data->addr.msf.minute;
- cd->tracks[LEADOUT].second = toc_entry.data->addr.msf.second;
- cd->tracks[LEADOUT].frame = toc_entry.data->addr.msf.frame;
-
- cd->num_tracks = toc_header.ending_track;
-
- return TRUE;
+ struct ioc_toc_header toc_header;
+ struct ioc_read_toc_entry toc_entry;
+ struct cd_toc_entry toc_entry_data;
+ guint i;
+
+ cd->fd = open (device, O_RDONLY | O_NONBLOCK);
+
+ if (cd->fd == -1) {
+ return FALSE;
+ }
+
+ /* get the toc header information */
+ if (ioctl (cd->fd, CDIOREADTOCHDR, &toc_header) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ /* read each entry in the toc header */
+ for (i = 1; i <= toc_header.ending_track; i++) {
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = i;
+ toc_entry.data = &toc_entry_data;
+ toc_entry.data_len = sizeof (toc_entry_data);
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[i].minute = toc_entry.data->addr.msf.minute;
+ cd->tracks[i].second = toc_entry.data->addr.msf.second;
+ cd->tracks[i].frame = toc_entry.data->addr.msf.frame;
+ cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
+ }
+
+ /* read the leadout */
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = 0xAA; /* leadout */
+ toc_entry.data = &toc_entry_data;
+ toc_entry.data_len = sizeof (toc_entry_data);
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[LEADOUT].minute = toc_entry.data->addr.msf.minute;
+ cd->tracks[LEADOUT].second = toc_entry.data->addr.msf.second;
+ cd->tracks[LEADOUT].frame = toc_entry.data->addr.msf.frame;
+
+ cd->num_tracks = toc_header.ending_track;
+
+ return TRUE;
}
#elif defined HAVE_CDROM_BSD_DARWIN
-gboolean cd_init(struct cd *cd,const gchar *device)
+gboolean
+cd_init (struct cd *cd, const gchar * device)
{
- struct ioc_toc_header toc_header;
- struct ioc_read_toc_entry toc_entry;
- guint i;
-
- cd->fd = open(device,O_RDONLY | O_NONBLOCK);
-
- if (cd->fd == -1) {
- return FALSE;
- }
-
- /* get the toc header information */
- if (ioctl(cd->fd,CDIOREADTOCHDR,&toc_header) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- /* read each entry in the toc header */
- for (i = 1; i <= toc_header.ending_track; i++) {
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = i;
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[i].minute = toc_entry.data->addr[1];
- cd->tracks[i].second = toc_entry.data->addr[2];
- cd->tracks[i].frame = toc_entry.data->addr[3];
- cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
- }
-
- /* read the leadout */
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = 0xAA; /* leadout */
- toc_entry.data = &toc_entry_data;
- toc_entry.data_len = sizeof(toc_entry_data);
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[LEADOUT].minute = toc_entry.data->addr[1];
- cd->tracks[LEADOUT].second = toc_entry.data->addr[2];
- cd->tracks[LEADOUT].frame = toc_entry.data->addr[3];
-
- cd->num_tracks = toc_header.ending_track;
-
- return TRUE;
+ struct ioc_toc_header toc_header;
+ struct ioc_read_toc_entry toc_entry;
+ guint i;
+
+ cd->fd = open (device, O_RDONLY | O_NONBLOCK);
+
+ if (cd->fd == -1) {
+ return FALSE;
+ }
+
+ /* get the toc header information */
+ if (ioctl (cd->fd, CDIOREADTOCHDR, &toc_header) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ /* read each entry in the toc header */
+ for (i = 1; i <= toc_header.ending_track; i++) {
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = i;
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[i].minute = toc_entry.data->addr[1];
+ cd->tracks[i].second = toc_entry.data->addr[2];
+ cd->tracks[i].frame = toc_entry.data->addr[3];
+ cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
+ }
+
+ /* read the leadout */
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = 0xAA; /* leadout */
+ toc_entry.data = &toc_entry_data;
+ toc_entry.data_len = sizeof (toc_entry_data);
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[LEADOUT].minute = toc_entry.data->addr[1];
+ cd->tracks[LEADOUT].second = toc_entry.data->addr[2];
+ cd->tracks[LEADOUT].frame = toc_entry.data->addr[3];
+
+ cd->num_tracks = toc_header.ending_track;
+
+ return TRUE;
}
#else /* free */
-gboolean cd_init(struct cd *cd,const gchar *device)
+gboolean
+cd_init (struct cd *cd, const gchar * device)
{
- struct ioc_toc_header toc_header;
- struct ioc_read_toc_entry toc_entry;
- guint i;
-
- cd->fd = open(device,O_RDONLY | O_NONBLOCK);
-
- if (cd->fd == -1) {
- return FALSE;
- }
-
- /* get the toc header information */
- if (ioctl(cd->fd,CDIOREADTOCHDR,&toc_header) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- /* read each entry in the toc header */
- for (i = 1; i <= toc_header.ending_track; i++) {
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = i;
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[i].minute = toc_entry.entry.addr.msf.minute;
- cd->tracks[i].second = toc_entry.entry.addr.msf.second;
- cd->tracks[i].frame = toc_entry.entry.addr.msf.frame;
- cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
- }
-
- /* read the leadout */
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = 0xAA; /* leadout */
- toc_entry.data = &toc_entry_data;
- toc_entry.data_len = sizeof(toc_entry_data);
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[LEADOUT].minute = toc_entry.entry.addr.msf.minute;
- cd->tracks[LEADOUT].second = toc_entry.entry.addr.msf.second;
- cd->tracks[LEADOUT].frame = toc_entry.entry.addr.msf.frame;
-
- cd->num_tracks = toc_header.ending_track;
-
- return TRUE;
+ struct ioc_toc_header toc_header;
+ struct ioc_read_toc_entry toc_entry;
+ guint i;
+
+ cd->fd = open (device, O_RDONLY | O_NONBLOCK);
+
+ if (cd->fd == -1) {
+ return FALSE;
+ }
+
+ /* get the toc header information */
+ if (ioctl (cd->fd, CDIOREADTOCHDR, &toc_header) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ /* read each entry in the toc header */
+ for (i = 1; i <= toc_header.ending_track; i++) {
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = i;
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[i].minute = toc_entry.entry.addr.msf.minute;
+ cd->tracks[i].second = toc_entry.entry.addr.msf.second;
+ cd->tracks[i].frame = toc_entry.entry.addr.msf.frame;
+ cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
+ }
+
+ /* read the leadout */
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = 0xAA; /* leadout */
+ toc_entry.data = &toc_entry_data;
+ toc_entry.data_len = sizeof (toc_entry_data);
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[LEADOUT].minute = toc_entry.entry.addr.msf.minute;
+ cd->tracks[LEADOUT].second = toc_entry.entry.addr.msf.second;
+ cd->tracks[LEADOUT].frame = toc_entry.entry.addr.msf.frame;
+
+ cd->num_tracks = toc_header.ending_track;
+
+ return TRUE;
}
#endif
-gboolean cd_start(struct cd *cd,gint start_track,gint end_track)
+gboolean
+cd_start (struct cd * cd, gint start_track, gint end_track)
{
- struct ioc_play_msf msf;
+ struct ioc_play_msf msf;
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- cd_fix_track_range(cd,&start_track,&end_track);
+ cd_fix_track_range (cd, &start_track, &end_track);
- msf.start_m = cd->tracks[start_track].minute;
- msf.start_s = cd->tracks[start_track].second;
- msf.start_f = cd->tracks[start_track].frame;
+ msf.start_m = cd->tracks[start_track].minute;
+ msf.start_s = cd->tracks[start_track].second;
+ msf.start_f = cd->tracks[start_track].frame;
- if (end_track == LEADOUT) {
- msf.end_m = cd->tracks[end_track].minute;
- msf.end_s = cd->tracks[end_track].second;
- msf.end_f = cd->tracks[end_track].frame;
- } else {
- msf.end_m = cd->tracks[end_track+1].minute;
- msf.end_s = cd->tracks[end_track+1].second;
- msf.end_f = cd->tracks[end_track+1].frame;
- }
+ if (end_track == LEADOUT) {
+ msf.end_m = cd->tracks[end_track].minute;
+ msf.end_s = cd->tracks[end_track].second;
+ msf.end_f = cd->tracks[end_track].frame;
+ } else {
+ msf.end_m = cd->tracks[end_track + 1].minute;
+ msf.end_s = cd->tracks[end_track + 1].second;
+ msf.end_f = cd->tracks[end_track + 1].frame;
+ }
- if (ioctl(cd->fd,CDIOCPLAYMSF,&msf) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDIOCPLAYMSF, &msf) != 0) {
+ return FALSE;
+ }
}
-gboolean cd_pause(struct cd *cd)
+gboolean
+cd_pause (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDIOCPAUSE,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDIOCPAUSE, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-gboolean cd_resume(struct cd *cd)
+gboolean
+cd_resume (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDIOCRESUME,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDIOCRESUME, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-gboolean cd_stop(struct cd *cd)
+gboolean
+cd_stop (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDIOCSTOP,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDIOCSTOP, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/* -1 for error, 0 for not playing, 1 for playing */
-CDStatus cd_status(struct cd *cd)
+CDStatus
+cd_status (struct cd * cd)
{
- struct ioc_read_subchannel sub_channel;
- struct cd_sub_channel_info sub_channel_info;
-
- if (cd->fd == -1) {
- return -1;
- }
-
- sub_channel.address_format = CD_MSF_FORMAT;
- sub_channel.data_format = CD_CURRENT_POSITION;
- sub_channel.track = 0;
- sub_channel.data = &sub_channel_info;
- sub_channel.data_len = sizeof(sub_channel_info);
-
- if (ioctl(cd->fd,CDIOCREADSUBCHANNEL,&sub_channel) != 0) {
- return FALSE;
- }
-
- switch (sub_channel.data->header.audio_status) {
- case CD_AS_PLAY_IN_PROGRESS:
- case CD_AS_PLAY_PAUSED:
- return CD_PLAYING;
- break;
- case CD_AS_PLAY_COMPLETED:
- return CD_COMPLETED;
- break;
- case CD_AS_AUDIO_INVALID:
- case CD_AS_PLAY_ERROR:
- default:
- return CD_ERROR;
- break;
-
- }
+ struct ioc_read_subchannel sub_channel;
+ struct cd_sub_channel_info sub_channel_info;
+
+ if (cd->fd == -1) {
+ return -1;
+ }
+
+ sub_channel.address_format = CD_MSF_FORMAT;
+ sub_channel.data_format = CD_CURRENT_POSITION;
+ sub_channel.track = 0;
+ sub_channel.data = &sub_channel_info;
+ sub_channel.data_len = sizeof (sub_channel_info);
+
+ if (ioctl (cd->fd, CDIOCREADSUBCHANNEL, &sub_channel) != 0) {
+ return FALSE;
+ }
+
+ switch (sub_channel.data->header.audio_status) {
+ case CD_AS_PLAY_IN_PROGRESS:
+ case CD_AS_PLAY_PAUSED:
+ return CD_PLAYING;
+ break;
+ case CD_AS_PLAY_COMPLETED:
+ return CD_COMPLETED;
+ break;
+ case CD_AS_AUDIO_INVALID:
+ case CD_AS_PLAY_ERROR:
+ default:
+ return CD_ERROR;
+ break;
+
+ }
}
-gint cd_current_track(struct cd *cd)
+gint
+cd_current_track (struct cd *cd)
{
- struct ioc_read_subchannel sub_channel;
- struct cd_sub_channel_info sub_channel_info;
-
- if (cd->fd == -1) {
- return -1;
- }
-
- sub_channel.address_format = CD_MSF_FORMAT;
- sub_channel.data_format = CD_TRACK_INFO;
- sub_channel.track = 0;
- sub_channel.data = &sub_channel_info;
- sub_channel.data_len = sizeof(sub_channel_info);
-
- if (ioctl(cd->fd,CDIOCREADSUBCHANNEL,&sub_channel) != 0) {
- return -1;
- }
-
+ struct ioc_read_subchannel sub_channel;
+ struct cd_sub_channel_info sub_channel_info;
+
+ if (cd->fd == -1) {
+ return -1;
+ }
+
+ sub_channel.address_format = CD_MSF_FORMAT;
+ sub_channel.data_format = CD_TRACK_INFO;
+ sub_channel.track = 0;
+ sub_channel.data = &sub_channel_info;
+ sub_channel.data_len = sizeof (sub_channel_info);
+
+ if (ioctl (cd->fd, CDIOCREADSUBCHANNEL, &sub_channel) != 0) {
+ return -1;
+ }
#ifdef __NetBSD__
- return sub_channel.data->what.track_info.track_number;
+ return sub_channel.data->what.track_info.track_number;
#else
- return sub_channel.data->track_number;
+ return sub_channel.data->track_number;
#endif
}
-gboolean cd_close(struct cd *cd)
+gboolean
+cd_close (struct cd * cd)
{
- if (cd->fd == -1) {
- return TRUE;
- }
+ if (cd->fd == -1) {
+ return TRUE;
+ }
- if (close(cd->fd) != 0) {
- return FALSE;
- }
+ if (close (cd->fd) != 0) {
+ return FALSE;
+ }
- cd->fd = -1;
+ cd->fd = -1;
- return TRUE;
+ return TRUE;
}
-
diff --git a/sys/cdrom/gstcdplayer_ioctl_irix.h b/sys/cdrom/gstcdplayer_ioctl_irix.h
index 2f6be35c..fb18c489 100644
--- a/sys/cdrom/gstcdplayer_ioctl_irix.h
+++ b/sys/cdrom/gstcdplayer_ioctl_irix.h
@@ -22,88 +22,95 @@
#define CDPLAYER(x) ((CDPlayer *)x)
#define FD(x) ((int)x)
-gboolean cd_init(struct cd *cd,const gchar *device)
+gboolean
+cd_init (struct cd *cd, const gchar * device)
{
- CDPLAYER *cdplayer;
- CDSTATUS status;
- CDTRACKINFO info;
- guint i;
+ CDPLAYER *cdplayer;
+ CDSTATUS status;
+ CDTRACKINFO info;
+ guint i;
- cdplayer = CDOpen(device,"r");
+ cdplayer = CDOpen (device, "r");
- if (cdplayer == NULL) {
- return FALSE;
- }
+ if (cdplayer == NULL) {
+ return FALSE;
+ }
- cd->fd = FD(cdplayer);
+ cd->fd = FD (cdplayer);
- if (CDgetstatus(cdplayer,&status) == 0) {
- CDclose(cdplayer);
- cd->fd = 0;
- return FALSE;
- }
+ if (CDgetstatus (cdplayer, &status) == 0) {
+ CDclose (cdplayer);
+ cd->fd = 0;
+ return FALSE;
+ }
- for (i = 1; i < status.last; i++) {
- if (CDgettrackinfo(cdplayer,i,&info) == 0) {
- CDclose(cdplayer);
- cd->fd = 0;
- return FALSE;
- }
+ for (i = 1; i < status.last; i++) {
+ if (CDgettrackinfo (cdplayer, i, &info) == 0) {
+ CDclose (cdplayer);
+ cd->fd = 0;
+ return FALSE;
+ }
- cd->tracks[i].minute = info.start_min;
- cd->tracks[i].second = info.start_sec;
- cd->tracks[i].frame = info.start_frame;
+ cd->tracks[i].minute = info.start_min;
+ cd->tracks[i].second = info.start_sec;
+ cd->tracks[i].frame = info.start_frame;
- }
+ }
- /* there is no leadout information */
-
+ /* there is no leadout information */
- cd->num_tracks = status.last;
- return TRUE;
+ cd->num_tracks = status.last;
+
+ return TRUE;
}
-gboolean cd_start(struct cd *cd,gint start_track,gint end_track)
+gboolean
+cd_start (struct cd * cd, gint start_track, gint end_track)
{
- if (cd->fd == 0) {
- return FALSE;
- }
+ if (cd->fd == 0) {
+ return FALSE;
+ }
+
+ cd_fix_track_range (cd, &start_track, &end_track);
- cd_fix_track_range(cd,&start_track,&end_track);
-
}
-gboolean cd_pause(struct cd *cd)
+gboolean
+cd_pause (struct cd * cd)
{
}
-gboolean cd_resume(struct cd *cd)
+gboolean
+cd_resume (struct cd *cd)
{
}
-gboolean cd_stop(struct cd *cd)
+gboolean
+cd_stop (struct cd *cd)
{
}
/* -1 for error, 0 for not playing, 1 for playing */
-CDStatus cd_status(struct cd *cd)
+CDStatus
+cd_status (struct cd *cd)
{
}
-gint cd_current_track(struct cd *cd)
+gint
+cd_current_track (struct cd *cd)
{
}
-gboolean cd_close(struct cd *cd)
+gboolean
+cd_close (struct cd *cd)
{
}
-
diff --git a/sys/cdrom/gstcdplayer_ioctl_solaris.h b/sys/cdrom/gstcdplayer_ioctl_solaris.h
index 868fb251..dd91e127 100644
--- a/sys/cdrom/gstcdplayer_ioctl_solaris.h
+++ b/sys/cdrom/gstcdplayer_ioctl_solaris.h
@@ -17,188 +17,195 @@
* Boston, MA 02111-1307, USA.
*/
-gboolean cd_init(struct cd *cd,const gchar *device)
+gboolean
+cd_init (struct cd *cd, const gchar * device)
{
- struct cdrom_tochdr toc_header;
- struct cdrom_tocentry toc_entry;
- guint i;
-
- cd->fd = open(device,O_RDONLY | O_NONBLOCK);
-
- if (cd->fd == -1) {
- return FALSE;
- }
-
- /* get the toc header information */
- if (ioctl(cd->fd,CDROMREADTOCHDR,&toc_header) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- /* read each entry in the toc header */
- for (i = 1; i <= toc_header.cdth_trk1; i++) {
- toc_entry.cdte_format = CDROM_MSF;
- toc_entry.cdte_track = i;
-
- if (ioctl(cd->fd,CDROMREADTOCENTRY,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[i].minute = toc_entry.cdte_addr.msf.minute;
- cd->tracks[i].second = toc_entry.cdte_addr.msf.second;
- cd->tracks[i].frame = toc_entry.cdte_addr.msf.frame;
- cd->tracks[i].data_track = (toc_entry.cdte_ctrl == CDROM_DATA_TRACK);
- }
-
- /* read the leadout */
- toc_entry.cdte_track = CDROM_LEADOUT;
- toc_entry.cdte_format = CDROM_MSF;
- if (ioctl(cd->fd,CDROMREADTOCENTRY,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
- cd->tracks[LEADOUT].minute = toc_entry.cdte_addr.msf.minute;
- cd->tracks[LEADOUT].second = toc_entry.cdte_addr.msf.second;
- cd->tracks[LEADOUT].frame = toc_entry.cdte_addr.msf.frame;
-
- cd->num_tracks = toc_header.cdth_trk1;
-
- return TRUE;
+ struct cdrom_tochdr toc_header;
+ struct cdrom_tocentry toc_entry;
+ guint i;
+
+ cd->fd = open (device, O_RDONLY | O_NONBLOCK);
+
+ if (cd->fd == -1) {
+ return FALSE;
+ }
+
+ /* get the toc header information */
+ if (ioctl (cd->fd, CDROMREADTOCHDR, &toc_header) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ /* read each entry in the toc header */
+ for (i = 1; i <= toc_header.cdth_trk1; i++) {
+ toc_entry.cdte_format = CDROM_MSF;
+ toc_entry.cdte_track = i;
+
+ if (ioctl (cd->fd, CDROMREADTOCENTRY, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[i].minute = toc_entry.cdte_addr.msf.minute;
+ cd->tracks[i].second = toc_entry.cdte_addr.msf.second;
+ cd->tracks[i].frame = toc_entry.cdte_addr.msf.frame;
+ cd->tracks[i].data_track = (toc_entry.cdte_ctrl == CDROM_DATA_TRACK);
+ }
+
+ /* read the leadout */
+ toc_entry.cdte_track = CDROM_LEADOUT;
+ toc_entry.cdte_format = CDROM_MSF;
+ if (ioctl (cd->fd, CDROMREADTOCENTRY, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+ cd->tracks[LEADOUT].minute = toc_entry.cdte_addr.msf.minute;
+ cd->tracks[LEADOUT].second = toc_entry.cdte_addr.msf.second;
+ cd->tracks[LEADOUT].frame = toc_entry.cdte_addr.msf.frame;
+
+ cd->num_tracks = toc_header.cdth_trk1;
+
+ return TRUE;
}
-gboolean cd_start(struct cd *cd,gint start_track,gint end_track)
+gboolean
+cd_start (struct cd * cd, gint start_track, gint end_track)
{
- struct cdrom_msf msf;
+ struct cdrom_msf msf;
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- cd_fix_track_range(cd,&start_track,&end_track);
+ cd_fix_track_range (cd, &start_track, &end_track);
- msf.cdmsf_min0 = cd->tracks[start_track].minute;
- msf.cdmsf_sec0 = cd->tracks[start_track].second;
- msf.cdmsf_frame0 = cd->tracks[start_track].frame;
+ msf.cdmsf_min0 = cd->tracks[start_track].minute;
+ msf.cdmsf_sec0 = cd->tracks[start_track].second;
+ msf.cdmsf_frame0 = cd->tracks[start_track].frame;
- if (end_track == LEADOUT) {
- msf.cdmsf_min1 = cd->tracks[end_track].minute;
- msf.cdmsf_sec1 = cd->tracks[end_track].second;
- msf.cdmsf_frame1 = cd->tracks[end_track].frame;
- } else {
- msf.cdmsf_min1 = cd->tracks[end_track+1].minute;
- msf.cdmsf_sec1 = cd->tracks[end_track+1].second;
- msf.cdmsf_frame1 = cd->tracks[end_track+1].frame;
- }
+ if (end_track == LEADOUT) {
+ msf.cdmsf_min1 = cd->tracks[end_track].minute;
+ msf.cdmsf_sec1 = cd->tracks[end_track].second;
+ msf.cdmsf_frame1 = cd->tracks[end_track].frame;
+ } else {
+ msf.cdmsf_min1 = cd->tracks[end_track + 1].minute;
+ msf.cdmsf_sec1 = cd->tracks[end_track + 1].second;
+ msf.cdmsf_frame1 = cd->tracks[end_track + 1].frame;
+ }
- if (ioctl(cd->fd,CDROMPLAYMSF,&msf) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDROMPLAYMSF, &msf) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-gboolean cd_pause(struct cd *cd)
+gboolean
+cd_pause (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDROMPAUSE,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDROMPAUSE, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-gboolean cd_resume(struct cd *cd)
+gboolean
+cd_resume (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDROMRESUME,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDROMRESUME, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-gboolean cd_stop(struct cd *cd)
+gboolean
+cd_stop (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDROMSTOP,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDROMSTOP, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/* -1 for error, 0 for not playing, 1 for playing */
-CDStatus cd_status(struct cd *cd)
+CDStatus
+cd_status (struct cd * cd)
{
- struct cdrom_subchnl sub_channel;
-
- if (cd->fd == -1) {
- return -1;
- }
-
- sub_channel.cdsc_format = CDROM_MSF;
-
- if (ioctl(cd->fd,CDROMSUBCHNL,&sub_channel) != 0) {
- return -1;
- }
-
- switch (sub_channel.cdsc_audiostatus) {
- case CDROM_AUDIO_COMPLETED:
- return CD_COMPLETED;
- break;
- case CDROM_AUDIO_PLAY:
- case CDROM_AUDIO_PAUSED:
- return CD_PLAYING;
- break;
- case CDROM_AUDIO_ERROR:
- default:
- return CD_ERROR;
- }
+ struct cdrom_subchnl sub_channel;
+
+ if (cd->fd == -1) {
+ return -1;
+ }
+
+ sub_channel.cdsc_format = CDROM_MSF;
+
+ if (ioctl (cd->fd, CDROMSUBCHNL, &sub_channel) != 0) {
+ return -1;
+ }
+
+ switch (sub_channel.cdsc_audiostatus) {
+ case CDROM_AUDIO_COMPLETED:
+ return CD_COMPLETED;
+ break;
+ case CDROM_AUDIO_PLAY:
+ case CDROM_AUDIO_PAUSED:
+ return CD_PLAYING;
+ break;
+ case CDROM_AUDIO_ERROR:
+ default:
+ return CD_ERROR;
+ }
}
-gint cd_current_track(struct cd *cd)
+gint
+cd_current_track (struct cd * cd)
{
- struct cdrom_subchnl sub_channel;
+ struct cdrom_subchnl sub_channel;
- if (cd->fd == -1) {
- return -1;
- }
+ if (cd->fd == -1) {
+ return -1;
+ }
- sub_channel.cdsc_format = CDROM_MSF;
+ sub_channel.cdsc_format = CDROM_MSF;
- if (ioctl(cd->fd,CDROMSUBCHNL,&sub_channel) != 0) {
- return -1;
- }
+ if (ioctl (cd->fd, CDROMSUBCHNL, &sub_channel) != 0) {
+ return -1;
+ }
- return sub_channel.cdsc_trk;
+ return sub_channel.cdsc_trk;
}
-gboolean cd_close(struct cd *cd)
+gboolean
+cd_close (struct cd * cd)
{
- if (cd->fd == -1) {
- return TRUE;
- }
+ if (cd->fd == -1) {
+ return TRUE;
+ }
- if (close(cd->fd) != 0) {
- return FALSE;
- }
+ if (close (cd->fd) != 0) {
+ return FALSE;
+ }
- cd->fd = -1;
+ cd->fd = -1;
- return TRUE;
+ return TRUE;
}
-
diff --git a/sys/dxr3/ac3_padder.c b/sys/dxr3/ac3_padder.c
index bee59895..606923a7 100644
--- a/sys/dxr3/ac3_padder.c
+++ b/sys/dxr3/ac3_padder.c
@@ -35,49 +35,48 @@ struct frmsize_s
unsigned short bit_rate;
unsigned short frm_size[3];
};
-
-
-static const struct frmsize_s frmsizecod_tbl[64] =
- {
- { 32 ,{64 ,69 ,96 } },
- { 32 ,{64 ,70 ,96 } },
- { 40 ,{80 ,87 ,120 } },
- { 40 ,{80 ,88 ,120 } },
- { 48 ,{96 ,104 ,144 } },
- { 48 ,{96 ,105 ,144 } },
- { 56 ,{112 ,121 ,168 } },
- { 56 ,{112 ,122 ,168 } },
- { 64 ,{128 ,139 ,192 } },
- { 64 ,{128 ,140 ,192 } },
- { 80 ,{160 ,174 ,240 } },
- { 80 ,{160 ,175 ,240 } },
- { 96 ,{192 ,208 ,288 } },
- { 96 ,{192 ,209 ,288 } },
- { 112 ,{224 ,243 ,336 } },
- { 112 ,{224 ,244 ,336 } },
- { 128 ,{256 ,278 ,384 } },
- { 128 ,{256 ,279 ,384 } },
- { 160 ,{320 ,348 ,480 } },
- { 160 ,{320 ,349 ,480 } },
- { 192 ,{384 ,417 ,576 } },
- { 192 ,{384 ,418 ,576 } },
- { 224 ,{448 ,487 ,672 } },
- { 224 ,{448 ,488 ,672 } },
- { 256 ,{512 ,557 ,768 } },
- { 256 ,{512 ,558 ,768 } },
- { 320 ,{640 ,696 ,960 } },
- { 320 ,{640 ,697 ,960 } },
- { 384 ,{768 ,835 ,1152 } },
- { 384 ,{768 ,836 ,1152 } },
- { 448 ,{896 ,975 ,1344 } },
- { 448 ,{896 ,976 ,1344 } },
- { 512 ,{1024 ,1114 ,1536 } },
- { 512 ,{1024 ,1115 ,1536 } },
- { 576 ,{1152 ,1253 ,1728 } },
- { 576 ,{1152 ,1254 ,1728 } },
- { 640 ,{1280 ,1393 ,1920 } },
- { 640 ,{1280 ,1394 ,1920 } }
- };
+
+
+static const struct frmsize_s frmsizecod_tbl[64] = {
+ {32, {64, 69, 96}},
+ {32, {64, 70, 96}},
+ {40, {80, 87, 120}},
+ {40, {80, 88, 120}},
+ {48, {96, 104, 144}},
+ {48, {96, 105, 144}},
+ {56, {112, 121, 168}},
+ {56, {112, 122, 168}},
+ {64, {128, 139, 192}},
+ {64, {128, 140, 192}},
+ {80, {160, 174, 240}},
+ {80, {160, 175, 240}},
+ {96, {192, 208, 288}},
+ {96, {192, 209, 288}},
+ {112, {224, 243, 336}},
+ {112, {224, 244, 336}},
+ {128, {256, 278, 384}},
+ {128, {256, 279, 384}},
+ {160, {320, 348, 480}},
+ {160, {320, 349, 480}},
+ {192, {384, 417, 576}},
+ {192, {384, 418, 576}},
+ {224, {448, 487, 672}},
+ {224, {448, 488, 672}},
+ {256, {512, 557, 768}},
+ {256, {512, 558, 768}},
+ {320, {640, 696, 960}},
+ {320, {640, 697, 960}},
+ {384, {768, 835, 1152}},
+ {384, {768, 836, 1152}},
+ {448, {896, 975, 1344}},
+ {448, {896, 976, 1344}},
+ {512, {1024, 1114, 1536}},
+ {512, {1024, 1115, 1536}},
+ {576, {1152, 1253, 1728}},
+ {576, {1152, 1254, 1728}},
+ {640, {1280, 1393, 1920}},
+ {640, {1280, 1394, 1920}}
+};
@@ -97,7 +96,7 @@ static const struct frmsize_s frmsizecod_tbl[64] =
* (S/PDIF) padded packets.
*/
extern void
-ac3p_init(ac3_padder *padder)
+ac3p_init (ac3_padder * padder)
{
const char sync[4] = { 0x72, 0xF8, 0x1F, 0x4E };
@@ -107,7 +106,7 @@ ac3p_init(ac3_padder *padder)
padder->remaining = 0;
/* Initialize the sync bytes in the frame. */
- memcpy(padder->frame.header, sync, 4);
+ memcpy (padder->frame.header, sync, 4);
}
@@ -125,7 +124,7 @@ ac3p_init(ac3_padder *padder)
* function returns the %AC3P_EVENT_PUSH event.
*/
extern void
-ac3p_push_data(ac3_padder *padder, guchar *data, guint size)
+ac3p_push_data (ac3_padder * padder, guchar * data, guint size)
{
padder->in_ptr = data;
padder->remaining = size;
@@ -148,112 +147,108 @@ ac3p_push_data(ac3_padder *padder, guchar *data, guint size)
* pushing the data.
*/
extern int
-ac3p_parse(ac3_padder *padder)
+ac3p_parse (ac3_padder * padder)
{
while (padder->remaining > 0) {
switch (padder->state) {
- case AC3P_STATE_SYNC1:
- if (*(padder->in_ptr) == 0x0b) {
- /* The first sync byte was found. Go to the next state. */
- padder->frame.sync_byte1 = 0x0b;
- padder->state = AC3P_STATE_SYNC2;
- }
- ac3p_in_fw(padder);
- break;
-
- case AC3P_STATE_SYNC2:
- if (*(padder->in_ptr) == 0x77) {
- /* The second sync byte was seen right after the first. Go to
- the next state. */
- padder->frame.sync_byte2 = 0x77;
- padder->state = AC3P_STATE_HEADER;
-
- /* Skip one byte. */
- ac3p_in_fw(padder);
-
- /* Prepare for reading the header. */
- padder->out_ptr = (guchar *) &(padder->frame.crc1);
- /* Discount the 2 sync bytes from the header size. */
- padder->bytes_to_copy = AC3P_AC3_HEADER_SIZE - 2;
- }
- else {
- /* The second sync byte was not seen. Go back to the
- first state. */
- padder->state = AC3P_STATE_SYNC1;
- }
- break;
-
- case AC3P_STATE_HEADER:
- if (padder->bytes_to_copy > 0) {
- /* Copy one byte. */
- *(padder->out_ptr) = *(padder->in_ptr);
- ac3p_in_fw(padder);
- ac3p_out_fw(padder);
- }
- else {
- int fscod;
-
- /* The header is ready: */
-
- fscod = (padder->frame.code >> 6) & 0x03;
-
- /* Calculate the frame size. */
- padder->ac3_frame_size =
- 2 * frmsizecod_tbl[padder->frame.code & 0x3f].frm_size[fscod];
-
- /* Set up the IEC header. */
- if (padder->ac3_frame_size > 0) {
- padder->frame.header[4] = IEC61937_DATA_TYPE_AC3;
- }
- else {
- /* Don't know what it is, better be careful. */
- padder->state = AC3P_STATE_SYNC1;
- break;
- }
- padder->frame.header[5] = 0x00;
- padder->frame.header[6] = (padder->ac3_frame_size*8) & 0xFF;
- padder->frame.header[7] = ((padder->ac3_frame_size*8) >> 8) & 0xFF;
-
- /* Prepare for reading the body. */
- padder->bytes_to_copy = padder->ac3_frame_size - AC3P_AC3_HEADER_SIZE;
- padder->state = AC3P_STATE_CONTENT;
- }
- break;
-
- case AC3P_STATE_CONTENT:
- if (padder->bytes_to_copy > 0) {
- /* Copy one byte. */
- *(padder->out_ptr) = *(padder->in_ptr);
- ac3p_in_fw(padder);
- ac3p_out_fw(padder);
- }
- else {
- guint16 *ptr, i;
-
- /* Frame ready. Prepare for output: */
-
- /* Zero the non AC3 portion of the padded frame. */
- memset(&(padder->frame.sync_byte1) + padder->ac3_frame_size, 0,
- AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE - padder->ac3_frame_size);
-
- /* Fix the byte order in the AC3 portion: */
- ptr = (guint16 *) &(padder->frame.sync_byte1);
- i = padder->ac3_frame_size / 2;
- while (i > 0) {
- *ptr = GUINT16_TO_BE(*ptr);
- ptr++;
- i--;
- }
-
- /* Start over again. */
- padder->state = AC3P_STATE_SYNC1;
-
- return AC3P_EVENT_FRAME;
- }
- break;
+ case AC3P_STATE_SYNC1:
+ if (*(padder->in_ptr) == 0x0b) {
+ /* The first sync byte was found. Go to the next state. */
+ padder->frame.sync_byte1 = 0x0b;
+ padder->state = AC3P_STATE_SYNC2;
+ }
+ ac3p_in_fw (padder);
+ break;
+
+ case AC3P_STATE_SYNC2:
+ if (*(padder->in_ptr) == 0x77) {
+ /* The second sync byte was seen right after the first. Go to
+ the next state. */
+ padder->frame.sync_byte2 = 0x77;
+ padder->state = AC3P_STATE_HEADER;
+
+ /* Skip one byte. */
+ ac3p_in_fw (padder);
+
+ /* Prepare for reading the header. */
+ padder->out_ptr = (guchar *) & (padder->frame.crc1);
+ /* Discount the 2 sync bytes from the header size. */
+ padder->bytes_to_copy = AC3P_AC3_HEADER_SIZE - 2;
+ } else {
+ /* The second sync byte was not seen. Go back to the
+ first state. */
+ padder->state = AC3P_STATE_SYNC1;
+ }
+ break;
+
+ case AC3P_STATE_HEADER:
+ if (padder->bytes_to_copy > 0) {
+ /* Copy one byte. */
+ *(padder->out_ptr) = *(padder->in_ptr);
+ ac3p_in_fw (padder);
+ ac3p_out_fw (padder);
+ } else {
+ int fscod;
+
+ /* The header is ready: */
+
+ fscod = (padder->frame.code >> 6) & 0x03;
+
+ /* Calculate the frame size. */
+ padder->ac3_frame_size =
+ 2 * frmsizecod_tbl[padder->frame.code & 0x3f].frm_size[fscod];
+
+ /* Set up the IEC header. */
+ if (padder->ac3_frame_size > 0) {
+ padder->frame.header[4] = IEC61937_DATA_TYPE_AC3;
+ } else {
+ /* Don't know what it is, better be careful. */
+ padder->state = AC3P_STATE_SYNC1;
+ break;
+ }
+ padder->frame.header[5] = 0x00;
+ padder->frame.header[6] = (padder->ac3_frame_size * 8) & 0xFF;
+ padder->frame.header[7] = ((padder->ac3_frame_size * 8) >> 8) & 0xFF;
+
+ /* Prepare for reading the body. */
+ padder->bytes_to_copy = padder->ac3_frame_size - AC3P_AC3_HEADER_SIZE;
+ padder->state = AC3P_STATE_CONTENT;
+ }
+ break;
+
+ case AC3P_STATE_CONTENT:
+ if (padder->bytes_to_copy > 0) {
+ /* Copy one byte. */
+ *(padder->out_ptr) = *(padder->in_ptr);
+ ac3p_in_fw (padder);
+ ac3p_out_fw (padder);
+ } else {
+ guint16 *ptr, i;
+
+ /* Frame ready. Prepare for output: */
+
+ /* Zero the non AC3 portion of the padded frame. */
+ memset (&(padder->frame.sync_byte1) + padder->ac3_frame_size, 0,
+ AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE -
+ padder->ac3_frame_size);
+
+ /* Fix the byte order in the AC3 portion: */
+ ptr = (guint16 *) & (padder->frame.sync_byte1);
+ i = padder->ac3_frame_size / 2;
+ while (i > 0) {
+ *ptr = GUINT16_TO_BE (*ptr);
+ ptr++;
+ i--;
+ }
+
+ /* Start over again. */
+ padder->state = AC3P_STATE_SYNC1;
+
+ return AC3P_EVENT_FRAME;
+ }
+ break;
}
}
return AC3P_EVENT_PUSH;
}
-
diff --git a/sys/dxr3/ac3_padder.h b/sys/dxr3/ac3_padder.h
index c9a7447e..f2ca2faa 100644
--- a/sys/dxr3/ac3_padder.h
+++ b/sys/dxr3/ac3_padder.h
@@ -34,7 +34,8 @@
/* An IEC958 padded AC3 frame. */
-typedef struct {
+typedef struct
+{
/* IEC header. */
guchar header[AC3P_IEC_HEADER_SIZE];
@@ -47,9 +48,9 @@ typedef struct {
guchar bsidmod;
guchar acmod;
/* End of AC3 header. */
-
- unsigned char data[AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE
- - AC3P_AC3_HEADER_SIZE];
+
+ unsigned char data[AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE
+ - AC3P_AC3_HEADER_SIZE];
} ac3p_iec958_burst_frame;
@@ -74,39 +75,37 @@ typedef struct {
/* The internal state for the padder. */
-typedef struct {
- guint state; /* State of the reading automaton. */
+typedef struct
+{
+ guint state; /* State of the reading automaton. */
- guchar *in_ptr; /* Input pointer, marking the current
- postion in the input buffer. */
- guint remaining; /* The number of bytes remaining in the current
- reading buffer. */
+ guchar *in_ptr; /* Input pointer, marking the current
+ postion in the input buffer. */
+ guint remaining; /* The number of bytes remaining in the current
+ reading buffer. */
- guchar *out_ptr; /* Output pointer, marking the current
- position in the output frame. */
+ guchar *out_ptr; /* Output pointer, marking the current
+ position in the output frame. */
guint bytes_to_copy;
- /* Number of bytes that still must be copied
- to the output frame *during this reading
- stage*. */
+ /* Number of bytes that still must be copied
+ to the output frame *during this reading
+ stage*. */
guint ac3_frame_size;
- /* The size in bytes of the pure AC3 portion
- of the current frame. */
+ /* The size in bytes of the pure AC3 portion
+ of the current frame. */
ac3p_iec958_burst_frame frame;
- /* The current output frame. */
+ /* The current output frame. */
} ac3_padder;
-extern void
-ac3p_init(ac3_padder *padder);
+extern void ac3p_init (ac3_padder * padder);
-extern void
-ac3p_push_data(ac3_padder *padder, guchar *data, guint size);
+extern void ac3p_push_data (ac3_padder * padder, guchar * data, guint size);
-extern int
-ac3p_parse(ac3_padder *padder);
+extern int ac3p_parse (ac3_padder * padder);
/**
diff --git a/sys/dxr3/dxr3audiosink.c b/sys/dxr3/dxr3audiosink.c
index 0bde9e35..a1a7b8e6 100644
--- a/sys/dxr3/dxr3audiosink.c
+++ b/sys/dxr3/dxr3audiosink.c
@@ -56,95 +56,84 @@ static GstElementDetails dxr3audiosink_details = {
/* Dxr3AudioSink signals and args */
-enum {
+enum
+{
SIGNAL_FLUSHED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_DIGITAL_PCM
};
static GstStaticPadTemplate dxr3audiosink_pcm_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "pcm_sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) { 32000, 44100, 48000, 66000 }, "
- "channels = (int) 2"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("pcm_sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) TRUE, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) { 32000, 44100, 48000, 66000 }, " "channels = (int) 2")
+ );
static GstStaticPadTemplate dxr3audiosink_ac3_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "ac3_sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-ac3"
- /* no parameters needed, we don't need a parsed stream */
- )
-);
-
-
-static void dxr3audiosink_class_init (Dxr3AudioSinkClass *klass);
-static void dxr3audiosink_base_init (Dxr3AudioSinkClass *klass);
-static void dxr3audiosink_init (Dxr3AudioSink *sink);
-
-static void dxr3audiosink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void dxr3audiosink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static gboolean dxr3audiosink_open (Dxr3AudioSink *sink);
-static gboolean dxr3audiosink_set_mode_pcm (Dxr3AudioSink *sink);
-static gboolean dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink);
-static void dxr3audiosink_close (Dxr3AudioSink *sink);
-static void dxr3audiosink_set_clock (GstElement *element,
- GstClock *clock);
-
-static GstPadLinkReturn dxr3audiosink_pcm_sinklink (GstPad *pad,
- const GstCaps *caps);
-static void dxr3audiosink_set_scr (Dxr3AudioSink *sink,
- guint32 scr);
-
-static gboolean dxr3audiosink_handle_event (GstPad *pad,
- GstEvent *event);
-static void dxr3audiosink_chain_pcm (GstPad *pad,GstData *buf);
-static void dxr3audiosink_chain_ac3 (GstPad *pad, GstData *buf);
+GST_STATIC_PAD_TEMPLATE ("ac3_sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-ac3"
+ /* no parameters needed, we don't need a parsed stream */
+ )
+ );
+
+
+static void dxr3audiosink_class_init (Dxr3AudioSinkClass * klass);
+static void dxr3audiosink_base_init (Dxr3AudioSinkClass * klass);
+static void dxr3audiosink_init (Dxr3AudioSink * sink);
+
+static void dxr3audiosink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void dxr3audiosink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static gboolean dxr3audiosink_open (Dxr3AudioSink * sink);
+static gboolean dxr3audiosink_set_mode_pcm (Dxr3AudioSink * sink);
+static gboolean dxr3audiosink_set_mode_ac3 (Dxr3AudioSink * sink);
+static void dxr3audiosink_close (Dxr3AudioSink * sink);
+static void dxr3audiosink_set_clock (GstElement * element, GstClock * clock);
+
+static GstPadLinkReturn dxr3audiosink_pcm_sinklink (GstPad * pad,
+ const GstCaps * caps);
+static void dxr3audiosink_set_scr (Dxr3AudioSink * sink, guint32 scr);
+
+static gboolean dxr3audiosink_handle_event (GstPad * pad, GstEvent * event);
+static void dxr3audiosink_chain_pcm (GstPad * pad, GstData * buf);
+static void dxr3audiosink_chain_ac3 (GstPad * pad, GstData * buf);
/* static void dxr3audiosink_wait (Dxr3AudioSink *sink, */
/* GstClockTime time); */
/* static int dxr3audiosink_mvcommand (Dxr3AudioSink *sink, */
/* int command); */
-static GstElementStateReturn dxr3audiosink_change_state (GstElement *element);
+static GstElementStateReturn dxr3audiosink_change_state (GstElement * element);
-static void dxr3audiosink_flushed (Dxr3AudioSink *sink);
+static void dxr3audiosink_flushed (Dxr3AudioSink * sink);
static GstElementClass *parent_class = NULL;
static guint dxr3audiosink_signals[LAST_SIGNAL] = { 0 };
extern GType
-dxr3audiosink_get_type (void)
+dxr3audiosink_get_type (void)
{
static GType dxr3audiosink_type = 0;
if (!dxr3audiosink_type) {
static const GTypeInfo dxr3audiosink_info = {
- sizeof(Dxr3AudioSinkClass),
+ sizeof (Dxr3AudioSinkClass),
(GBaseInitFunc) dxr3audiosink_base_init,
NULL,
(GClassInitFunc) dxr3audiosink_class_init,
@@ -155,8 +144,7 @@ dxr3audiosink_get_type (void)
(GInstanceInitFunc) dxr3audiosink_init,
};
dxr3audiosink_type = g_type_register_static (GST_TYPE_ELEMENT,
- "Dxr3AudioSink",
- &dxr3audiosink_info, 0);
+ "Dxr3AudioSink", &dxr3audiosink_info, 0);
}
return dxr3audiosink_type;
@@ -164,43 +152,39 @@ dxr3audiosink_get_type (void)
static void
-dxr3audiosink_base_init (Dxr3AudioSinkClass *klass)
+dxr3audiosink_base_init (Dxr3AudioSinkClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&dxr3audiosink_pcm_sink_factory));
+ gst_static_pad_template_get (&dxr3audiosink_pcm_sink_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&dxr3audiosink_ac3_sink_factory));
- gst_element_class_set_details (element_class,
- &dxr3audiosink_details);
+ gst_static_pad_template_get (&dxr3audiosink_ac3_sink_factory));
+ gst_element_class_set_details (element_class, &dxr3audiosink_details);
}
static void
-dxr3audiosink_class_init (Dxr3AudioSinkClass *klass)
+dxr3audiosink_class_init (Dxr3AudioSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
dxr3audiosink_signals[SIGNAL_FLUSHED] =
- g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (Dxr3AudioSinkClass, flushed),
- NULL, NULL,
- dxr3_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (Dxr3AudioSinkClass, flushed),
+ NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0);
klass->flushed = dxr3audiosink_flushed;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DIGITAL_PCM,
- g_param_spec_boolean ("digital-pcm", "Digital PCM",
- "Use the digital output for PCM sound",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("digital-pcm", "Digital PCM",
+ "Use the digital output for PCM sound", FALSE, G_PARAM_READWRITE));
gobject_class->set_property = dxr3audiosink_set_property;
gobject_class->get_property = dxr3audiosink_get_property;
@@ -210,8 +194,8 @@ dxr3audiosink_class_init (Dxr3AudioSinkClass *klass)
}
-static void
-dxr3audiosink_init (Dxr3AudioSink *sink)
+static void
+dxr3audiosink_init (Dxr3AudioSink * sink)
{
GstPadTemplate *temp;
@@ -228,7 +212,7 @@ dxr3audiosink_init (Dxr3AudioSink *sink)
gst_pad_set_chain_function (sink->ac3_sinkpad, dxr3audiosink_chain_ac3);
gst_element_add_pad (GST_ELEMENT (sink), sink->ac3_sinkpad);
- GST_FLAG_SET (GST_ELEMENT(sink), GST_ELEMENT_EVENT_AWARE);
+ GST_FLAG_SET (GST_ELEMENT (sink), GST_ELEMENT_EVENT_AWARE);
sink->card_number = 0;
@@ -244,7 +228,7 @@ dxr3audiosink_init (Dxr3AudioSink *sink)
/* Initially don't use digital output. */
sink->digital_pcm = FALSE;
- /* Initially there's no padder.*/
+ /* Initially there's no padder. */
sink->padder = NULL;
sink->mode = DXR3AUDIOSINK_MODE_NONE;
@@ -252,8 +236,8 @@ dxr3audiosink_init (Dxr3AudioSink *sink)
static void
-dxr3audiosink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+dxr3audiosink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
Dxr3AudioSink *sink;
@@ -261,70 +245,69 @@ dxr3audiosink_set_property (GObject *object, guint prop_id,
sink = DXR3AUDIOSINK (object);
switch (prop_id) {
- case ARG_DIGITAL_PCM:
- sink->digital_pcm = g_value_get_boolean (value);
- /* Refresh the setup of the device. */
- if (sink->mode == DXR3AUDIOSINK_MODE_PCM) {
- dxr3audiosink_set_mode_pcm (sink);
- }
- g_object_notify (G_OBJECT (sink), "digital-pcm");
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_DIGITAL_PCM:
+ sink->digital_pcm = g_value_get_boolean (value);
+ /* Refresh the setup of the device. */
+ if (sink->mode == DXR3AUDIOSINK_MODE_PCM) {
+ dxr3audiosink_set_mode_pcm (sink);
+ }
+ g_object_notify (G_OBJECT (sink), "digital-pcm");
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
-static void
-dxr3audiosink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+dxr3audiosink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
Dxr3AudioSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_DXR3AUDIOSINK (object));
-
+
sink = DXR3AUDIOSINK (object);
-
+
switch (prop_id) {
- case ARG_DIGITAL_PCM:
- g_value_set_boolean (value, sink->digital_pcm);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_DIGITAL_PCM:
+ g_value_set_boolean (value, sink->digital_pcm);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static gboolean
-dxr3audiosink_open (Dxr3AudioSink *sink)
+dxr3audiosink_open (Dxr3AudioSink * sink)
{
- g_return_val_if_fail (!GST_FLAG_IS_SET (sink,
- DXR3AUDIOSINK_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN), FALSE);
/* Compute the name of the audio device file. */
sink->audio_filename = g_strdup_printf ("/dev/em8300_ma-%d",
- sink->card_number );
+ sink->card_number);
sink->audio_fd = open (sink->audio_filename, O_WRONLY);
if (sink->audio_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open audio device \"%s\" for writing."), sink->audio_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open audio device \"%s\" for writing."),
+ sink->audio_filename), GST_ERROR_SYSTEM);
return FALSE;
}
/* Open the control device. */
sink->control_filename = g_strdup_printf ("/dev/em8300-%d",
- sink->card_number );
+ sink->card_number);
sink->control_fd = open (sink->control_filename, O_WRONLY);
if (sink->control_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open control device \"%s\" for writing."), sink->control_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open control device \"%s\" for writing."),
+ sink->control_filename), GST_ERROR_SYSTEM);
return FALSE;
}
@@ -343,7 +326,7 @@ dxr3audiosink_open (Dxr3AudioSink *sink)
* Set the operation mode of the element to PCM.
*/
static gboolean
-dxr3audiosink_set_mode_pcm (Dxr3AudioSink *sink)
+dxr3audiosink_set_mode_pcm (Dxr3AudioSink * sink)
{
int tmp, oss_mode, audiomode;
@@ -354,31 +337,30 @@ dxr3audiosink_set_mode_pcm (Dxr3AudioSink *sink)
/* Set the audio device mode. */
oss_mode = (G_BYTE_ORDER == G_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE);
tmp = oss_mode;
- if (ioctl (sink->audio_fd, SNDCTL_DSP_SETFMT, &tmp) < 0 ||
- tmp != oss_mode) {
+ if (ioctl (sink->audio_fd, SNDCTL_DSP_SETFMT, &tmp) < 0 || tmp != oss_mode) {
GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS,
- (_("Could not configure audio device \"%s\"."), sink->audio_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not configure audio device \"%s\"."), sink->audio_filename),
+ GST_ERROR_SYSTEM);
return FALSE;
}
/* Set the card's general audio output mode. */
audiomode = sink->digital_pcm ?
- EM8300_AUDIOMODE_DIGITALPCM : EM8300_AUDIOMODE_ANALOG;
+ EM8300_AUDIOMODE_DIGITALPCM : EM8300_AUDIOMODE_ANALOG;
ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode);
/* Set the sampling rate. */
tmp = sink->rate;
if (ioctl (sink->audio_fd, SNDCTL_DSP_SPEED, &tmp) < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS,
- (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename, sink->rate),
- GST_ERROR_SYSTEM);
+ (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename,
+ sink->rate), GST_ERROR_SYSTEM);
return FALSE;
}
/* Get rid of the padder, if any. */
if (sink->padder != NULL) {
- g_free(sink->padder);
+ g_free (sink->padder);
sink->padder = NULL;
}
@@ -395,9 +377,9 @@ dxr3audiosink_set_mode_pcm (Dxr3AudioSink *sink)
* Set the operation mode of the element to AC3.
*/
static gboolean
-dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink)
+dxr3audiosink_set_mode_ac3 (Dxr3AudioSink * sink)
{
- int tmp, audiomode;
+ int tmp, audiomode;
if (sink->audio_fd == -1 || sink->control_fd == -1) {
return FALSE;
@@ -408,8 +390,8 @@ dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink)
if (ioctl (sink->audio_fd, SNDCTL_DSP_SPEED, &tmp) < 0 ||
tmp != AC3_BYTE_RATE) {
GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS,
- (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename, AC3_BYTE_RATE),
- GST_ERROR_SYSTEM);
+ (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename,
+ AC3_BYTE_RATE), GST_ERROR_SYSTEM);
return FALSE;
}
@@ -419,8 +401,8 @@ dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink)
/* Create a padder if necessary, */
if (sink->padder == NULL) {
- sink->padder = g_malloc (sizeof(ac3_padder));
- ac3p_init(sink->padder);
+ sink->padder = g_malloc (sizeof (ac3_padder));
+ ac3p_init (sink->padder);
}
sink->mode = DXR3AUDIOSINK_MODE_AC3;
@@ -430,21 +412,21 @@ dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink)
static void
-dxr3audiosink_close (Dxr3AudioSink *sink)
+dxr3audiosink_close (Dxr3AudioSink * sink)
{
g_return_if_fail (GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN));
if (close (sink->audio_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close audio device \"%s\"."), sink->audio_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close audio device \"%s\"."), sink->audio_filename),
+ GST_ERROR_SYSTEM);
return;
}
if (close (sink->control_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close control device \"%s\"."), sink->audio_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close control device \"%s\"."), sink->audio_filename),
+ GST_ERROR_SYSTEM);
return;
}
@@ -458,14 +440,14 @@ dxr3audiosink_close (Dxr3AudioSink *sink)
/* Get rid of the padder, if any. */
if (sink->padder != NULL) {
- g_free(sink->padder);
+ g_free (sink->padder);
sink->padder = NULL;
}
}
static void
-dxr3audiosink_set_clock (GstElement *element, GstClock *clock)
+dxr3audiosink_set_clock (GstElement * element, GstClock * clock)
{
Dxr3AudioSink *src = DXR3AUDIOSINK (element);
@@ -474,7 +456,7 @@ dxr3audiosink_set_clock (GstElement *element, GstClock *clock)
static GstPadLinkReturn
-dxr3audiosink_pcm_sinklink (GstPad *pad, const GstCaps *caps)
+dxr3audiosink_pcm_sinklink (GstPad * pad, const GstCaps * caps)
{
Dxr3AudioSink *sink = DXR3AUDIOSINK (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (caps, 0);
@@ -492,7 +474,7 @@ dxr3audiosink_pcm_sinklink (GstPad *pad, const GstCaps *caps)
static void
-dxr3audiosink_set_scr (Dxr3AudioSink *sink, guint32 scr)
+dxr3audiosink_set_scr (Dxr3AudioSink * sink, guint32 scr)
{
guint32 zero = 0;
@@ -503,7 +485,7 @@ dxr3audiosink_set_scr (Dxr3AudioSink *sink, guint32 scr)
static gboolean
-dxr3audiosink_handle_event (GstPad *pad, GstEvent *event)
+dxr3audiosink_handle_event (GstPad * pad, GstEvent * event)
{
GstEventType type;
Dxr3AudioSink *sink = DXR3AUDIOSINK (gst_pad_get_parent (pad));
@@ -511,33 +493,33 @@ dxr3audiosink_handle_event (GstPad *pad, GstEvent *event)
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
- case GST_EVENT_FLUSH:
- if (sink->control_fd >= 0) {
- unsigned audiomode;
-
- if (sink->mode == DXR3AUDIOSINK_MODE_AC3) {
- audiomode = EM8300_AUDIOMODE_DIGITALPCM;
- ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode);
- audiomode = EM8300_AUDIOMODE_DIGITALAC3;
- ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode);
+ case GST_EVENT_FLUSH:
+ if (sink->control_fd >= 0) {
+ unsigned audiomode;
+
+ if (sink->mode == DXR3AUDIOSINK_MODE_AC3) {
+ audiomode = EM8300_AUDIOMODE_DIGITALPCM;
+ ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode);
+ audiomode = EM8300_AUDIOMODE_DIGITALAC3;
+ ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode);
+ }
+
+ /* Report the flush operation. */
+ g_signal_emit (G_OBJECT (sink),
+ dxr3audiosink_signals[SIGNAL_FLUSHED], 0);
}
-
- /* Report the flush operation. */
- g_signal_emit (G_OBJECT (sink),
- dxr3audiosink_signals[SIGNAL_FLUSHED], 0);
- }
- break;
- default:
- gst_pad_event_default (pad, event);
- break;
+ break;
+ default:
+ gst_pad_event_default (pad, event);
+ break;
}
return TRUE;
}
-static void
-dxr3audiosink_chain_pcm (GstPad *pad, GstData *_data)
+static void
+dxr3audiosink_chain_pcm (GstPad * pad, GstData * _data)
{
Dxr3AudioSink *sink;
gint bytes_written = 0;
@@ -579,21 +561,21 @@ dxr3audiosink_chain_pcm (GstPad *pad, GstData *_data)
in = MPEGTIME_TO_DXRTIME (sink->scr - (odelay * 90) / 192);
diff = in > out ? in - out : out - in;
if (diff > 1800) {
- dxr3audiosink_set_scr (sink, in);
+ dxr3audiosink_set_scr (sink, in);
}
}
/* Update our SCR value. */
sink->scr += (unsigned) (GST_BUFFER_SIZE (buf) *
- (90000.0 / ((float)sink->rate * 4)));
+ (90000.0 / ((float) sink->rate * 4)));
/* Write the buffer to the sound device. */
bytes_written = write (sink->audio_fd, GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ GST_BUFFER_SIZE (buf));
if (bytes_written < GST_BUFFER_SIZE (buf)) {
fprintf (stderr, "dxr3audiosink: Warning: %d bytes should be "
- "written, only %d bytes written\n",
- GST_BUFFER_SIZE (buf), bytes_written);
+ "written, only %d bytes written\n",
+ GST_BUFFER_SIZE (buf), bytes_written);
}
}
@@ -601,8 +583,8 @@ dxr3audiosink_chain_pcm (GstPad *pad, GstData *_data)
}
-static void
-dxr3audiosink_chain_ac3 (GstPad *pad, GstData *_data)
+static void
+dxr3audiosink_chain_ac3 (GstPad * pad, GstData * _data)
{
Dxr3AudioSink *sink;
gint bytes_written = 0;
@@ -626,8 +608,7 @@ dxr3audiosink_chain_ac3 (GstPad *pad, GstData *_data)
dxr3audiosink_set_mode_ac3 (sink);
}
- if (GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN))
- {
+ if (GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN)) {
int event;
if (GST_BUFFER_TIMESTAMP (buf) != GST_CLOCK_TIME_NONE) {
@@ -640,55 +621,53 @@ dxr3audiosink_chain_ac3 (GstPad *pad, GstData *_data)
}
/* Push the new data into the padder. */
- ac3p_push_data(sink->padder, GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ ac3p_push_data (sink->padder, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
/* Parse the data. */
event = ac3p_parse (sink->padder);
while (event != AC3P_EVENT_PUSH) {
switch (event) {
- case AC3P_EVENT_FRAME:
- /* We have a new frame: */
+ case AC3P_EVENT_FRAME:
+ /* We have a new frame: */
- /* Update the system reference clock (SCR) in the card. */
- {
- unsigned in, out, odelay;
- unsigned diff;
+ /* Update the system reference clock (SCR) in the card. */
+ {
+ unsigned in, out, odelay;
+ unsigned diff;
- ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &out);
+ ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &out);
- ioctl (sink->audio_fd, SNDCTL_DSP_GETODELAY, &odelay);
- /* 192000 bytes/sec */
+ ioctl (sink->audio_fd, SNDCTL_DSP_GETODELAY, &odelay);
+ /* 192000 bytes/sec */
- in = MPEGTIME_TO_DXRTIME (sink->scr - (odelay * 90) / 192);
- diff = in > out ? in - out : out - in;
- if (diff > 1800) {
- dxr3audiosink_set_scr (sink, in);
- }
- }
+ in = MPEGTIME_TO_DXRTIME (sink->scr - (odelay * 90) / 192);
+ diff = in > out ? in - out : out - in;
+ if (diff > 1800) {
+ dxr3audiosink_set_scr (sink, in);
+ }
+ }
- /* Update our SCR value. */
- sink->scr += TIME_FOR_BYTES (ac3p_frame_size (sink->padder));
+ /* Update our SCR value. */
+ sink->scr += TIME_FOR_BYTES (ac3p_frame_size (sink->padder));
- /* Write the frame to the sound device. */
- bytes_written = write (sink->audio_fd, ac3p_frame (sink->padder),
- AC3P_IEC_FRAME_SIZE);
+ /* Write the frame to the sound device. */
+ bytes_written = write (sink->audio_fd, ac3p_frame (sink->padder),
+ AC3P_IEC_FRAME_SIZE);
- if (bytes_written < AC3P_IEC_FRAME_SIZE)
- {
- fprintf (stderr, "dxr3audiosink: Warning: %d bytes should be "
- "written, only %d bytes written\n",
- AC3P_IEC_FRAME_SIZE, bytes_written);
- }
+ if (bytes_written < AC3P_IEC_FRAME_SIZE) {
+ fprintf (stderr, "dxr3audiosink: Warning: %d bytes should be "
+ "written, only %d bytes written\n",
+ AC3P_IEC_FRAME_SIZE, bytes_written);
+ }
- break;
+ break;
}
event = ac3p_parse (sink->padder);
}
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
#if 0
@@ -697,7 +676,7 @@ dxr3audiosink_chain_ac3 (GstPad *pad, GstData *_data)
* Make the sink wait the specified amount of time.
*/
static void
-dxr3audiosink_wait (Dxr3AudioSink *sink, GstClockTime time)
+dxr3audiosink_wait (Dxr3AudioSink * sink, GstClockTime time)
{
GstClockID id;
GstClockTimeDiff jitter;
@@ -711,20 +690,20 @@ dxr3audiosink_wait (Dxr3AudioSink *sink, GstClockTime time)
static int
-dxr3audiosink_mvcommand (Dxr3AudioSink *sink, int command)
+dxr3audiosink_mvcommand (Dxr3AudioSink * sink, int command)
{
em8300_register_t regs;
-
+
regs.microcode_register = 1;
regs.reg = 0;
regs.val = command;
-
+
return ioctl (sink->control_fd, EM8300_IOCTL_WRITEREG, &regs);
}
#endif
static GstElementStateReturn
-dxr3audiosink_change_state (GstElement *element)
+dxr3audiosink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_DXR3AUDIOSINK (element), GST_STATE_FAILURE);
@@ -732,11 +711,10 @@ dxr3audiosink_change_state (GstElement *element)
if (GST_FLAG_IS_SET (element, DXR3AUDIOSINK_OPEN)) {
dxr3audiosink_close (DXR3AUDIOSINK (element));
}
- }
- else {
+ } else {
if (!GST_FLAG_IS_SET (element, DXR3AUDIOSINK_OPEN)) {
if (!dxr3audiosink_open (DXR3AUDIOSINK (element))) {
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
}
}
}
@@ -757,7 +735,7 @@ dxr3audiosink_change_state (GstElement *element)
* queues due to a received flush event
*/
static void
-dxr3audiosink_flushed (Dxr3AudioSink *sink)
+dxr3audiosink_flushed (Dxr3AudioSink * sink)
{
/* Do nothing. */
}
diff --git a/sys/dxr3/dxr3audiosink.h b/sys/dxr3/dxr3audiosink.h
index 28bb34ec..07527d9f 100644
--- a/sys/dxr3/dxr3audiosink.h
+++ b/sys/dxr3/dxr3audiosink.h
@@ -27,8 +27,6 @@
#include "ac3_padder.h"
G_BEGIN_DECLS
-
-
#define GST_TYPE_DXR3AUDIOSINK \
(dxr3audiosink_get_type())
#define DXR3AUDIOSINK(obj) \
@@ -39,75 +37,77 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DXR3AUDIOSINK))
#define GST_IS_DXR3AUDIOSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DXR3AUDIOSINK))
-
-
typedef struct _Dxr3AudioSink Dxr3AudioSink;
typedef struct _Dxr3AudioSinkClass Dxr3AudioSinkClass;
-typedef enum {
+typedef enum
+{
DXR3AUDIOSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- DXR3AUDIOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ DXR3AUDIOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} Dxr3AudioSinkFlags;
/* PCM or AC3? */
-typedef enum {
- DXR3AUDIOSINK_MODE_NONE, /* No mode set. */
- DXR3AUDIOSINK_MODE_AC3, /* AC3 out. */
- DXR3AUDIOSINK_MODE_PCM, /* PCM out. */
+typedef enum
+{
+ DXR3AUDIOSINK_MODE_NONE, /* No mode set. */
+ DXR3AUDIOSINK_MODE_AC3, /* AC3 out. */
+ DXR3AUDIOSINK_MODE_PCM, /* PCM out. */
} Dxr3AudioSinkMode;
/* Information for a delayed SCR set operation. */
-typedef struct {
+typedef struct
+{
struct _Dxr3AudioSink *sink;
guint32 scr;
} Dxr3AudioSinkDelayedSCR;
-struct _Dxr3AudioSink {
+struct _Dxr3AudioSink
+{
GstElement element;
- GstPad *pcm_sinkpad; /* The AC3 audio sink pad. */
- GstPad *ac3_sinkpad; /* The PCM audio sink pad. */
+ GstPad *pcm_sinkpad; /* The AC3 audio sink pad. */
+ GstPad *ac3_sinkpad; /* The PCM audio sink pad. */
- int card_number; /* The number of the card to open. */
+ int card_number; /* The number of the card to open. */
- gchar *audio_filename; /* File name for the audio device. */
- int audio_fd; /* File descriptor for the audio device. */
+ gchar *audio_filename; /* File name for the audio device. */
+ int audio_fd; /* File descriptor for the audio device. */
- gchar *control_filename; /* File name for the control device. */
- int control_fd; /* File descriptor for the control
- device. */
+ gchar *control_filename; /* File name for the control device. */
+ int control_fd; /* File descriptor for the control
+ device. */
- guint64 scr; /* The current System Reference Clock value
- for the audio stream. */
+ guint64 scr; /* The current System Reference Clock value
+ for the audio stream. */
- gboolean digital_pcm; /* Should PCM use the digital or the
- analog output? */
+ gboolean digital_pcm; /* Should PCM use the digital or the
+ analog output? */
- Dxr3AudioSinkMode mode; /* The current sound output mode. */
+ Dxr3AudioSinkMode mode; /* The current sound output mode. */
- gint rate; /* The sampling rate for PCM sound. */
+ gint rate; /* The sampling rate for PCM sound. */
- ac3_padder *padder; /* AC3 to SPDIF padder object. */
+ ac3_padder *padder; /* AC3 to SPDIF padder object. */
- GstClock *clock; /* The clock for this element. */
+ GstClock *clock; /* The clock for this element. */
};
-struct _Dxr3AudioSinkClass {
+struct _Dxr3AudioSinkClass
+{
GstElementClass parent_class;
/* signals */
- void (*flushed) (Dxr3AudioSink *sink);
+ void (*flushed) (Dxr3AudioSink * sink);
};
-extern GType dxr3audiosink_get_type (void);
-extern gboolean dxr3audiosink_factory_init (GstPlugin *plugin);
+extern GType dxr3audiosink_get_type (void);
+extern gboolean dxr3audiosink_factory_init (GstPlugin * plugin);
G_END_DECLS
-
#endif /* __DXR3AUDIOINK_H__ */
diff --git a/sys/dxr3/dxr3init.c b/sys/dxr3/dxr3init.c
index 9a08936c..d5bbd0f2 100644
--- a/sys/dxr3/dxr3init.c
+++ b/sys/dxr3/dxr3init.c
@@ -31,14 +31,14 @@
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "dxr3videosink",
- GST_RANK_NONE, GST_TYPE_DXR3VIDEOSINK) ||
+ GST_RANK_NONE, GST_TYPE_DXR3VIDEOSINK) ||
!gst_element_register (plugin, "dxr3audiosink",
- GST_RANK_NONE, GST_TYPE_DXR3AUDIOSINK) ||
+ GST_RANK_NONE, GST_TYPE_DXR3AUDIOSINK) ||
!gst_element_register (plugin, "dxr3spusink",
- GST_RANK_NONE, GST_TYPE_DXR3SPUSINK))
+ GST_RANK_NONE, GST_TYPE_DXR3SPUSINK))
return FALSE;
#ifdef ENABLE_NLS
@@ -49,14 +49,8 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "dxr3",
- "dxr3 mpeg video board elements",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "dxr3",
+ "dxr3 mpeg video board elements",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/sys/dxr3/dxr3spusink.c b/sys/dxr3/dxr3spusink.c
index fe1f4155..1652cdc6 100644
--- a/sys/dxr3/dxr3spusink.c
+++ b/sys/dxr3/dxr3spusink.c
@@ -49,7 +49,8 @@ static GstElementDetails dxr3spusink_details = {
/* Dxr3SpuSink signals and args */
-enum {
+enum
+{
SET_CLUT_SIGNAL,
HIGHLIGHT_ON_SIGNAL,
HIGHLIGHT_OFF_SIGNAL,
@@ -57,56 +58,47 @@ enum {
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
};
static GstStaticPadTemplate dxr3spusink_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
-static void dxr3spusink_class_init (Dxr3SpuSinkClass *klass);
-static void dxr3spusink_base_init (Dxr3SpuSinkClass *klass);
-static void dxr3spusink_init (Dxr3SpuSink *dxr3spusink);
+static void dxr3spusink_class_init (Dxr3SpuSinkClass * klass);
+static void dxr3spusink_base_init (Dxr3SpuSinkClass * klass);
+static void dxr3spusink_init (Dxr3SpuSink * dxr3spusink);
-static void dxr3spusink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void dxr3spusink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void dxr3spusink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void dxr3spusink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
-static gboolean dxr3spusink_open (Dxr3SpuSink *sink);
-static void dxr3spusink_close (Dxr3SpuSink *sink);
-static void dxr3spusink_set_clock (GstElement *element,
- GstClock *clock);
+static gboolean dxr3spusink_open (Dxr3SpuSink * sink);
+static void dxr3spusink_close (Dxr3SpuSink * sink);
+static void dxr3spusink_set_clock (GstElement * element, GstClock * clock);
-static gboolean dxr3spusink_handle_event (GstPad *pad, GstEvent *event);
-static void dxr3spusink_chain (GstPad *pad,GstData *_data);
+static gboolean dxr3spusink_handle_event (GstPad * pad, GstEvent * event);
+static void dxr3spusink_chain (GstPad * pad, GstData * _data);
-static GstElementStateReturn dxr3spusink_change_state (GstElement *element);
+static GstElementStateReturn dxr3spusink_change_state (GstElement * element);
/* static void dxr3spusink_wait (Dxr3SpuSink *sink, */
/* GstClockTime time); */
-static void dxr3spusink_set_clut (Dxr3SpuSink *sink,
- const guint32 *clut);
-static void dxr3spusink_highlight_on (Dxr3SpuSink *sink,
- unsigned palette,
- unsigned sx, unsigned sy,
- unsigned ex, unsigned ey,
- unsigned pts);
-static void dxr3spusink_highlight_off (Dxr3SpuSink *sink);
+static void dxr3spusink_set_clut (Dxr3SpuSink * sink, const guint32 * clut);
+static void dxr3spusink_highlight_on (Dxr3SpuSink * sink,
+ unsigned palette,
+ unsigned sx, unsigned sy, unsigned ex, unsigned ey, unsigned pts);
+static void dxr3spusink_highlight_off (Dxr3SpuSink * sink);
-static void dxr3spusink_flushed (Dxr3SpuSink *sink);
+static void dxr3spusink_flushed (Dxr3SpuSink * sink);
static GstElementClass *parent_class = NULL;
@@ -114,89 +106,80 @@ static guint dxr3spusink_signals[LAST_SIGNAL] = { 0 };
GType
-dxr3spusink_get_type (void)
+dxr3spusink_get_type (void)
{
static GType dxr3spusink_type = 0;
if (!dxr3spusink_type) {
static const GTypeInfo dxr3spusink_info = {
sizeof (Dxr3SpuSinkClass),
- (GBaseInitFunc)dxr3spusink_base_init,
+ (GBaseInitFunc) dxr3spusink_base_init,
NULL,
- (GClassInitFunc)dxr3spusink_class_init,
+ (GClassInitFunc) dxr3spusink_class_init,
NULL,
NULL,
sizeof (Dxr3SpuSink),
0,
- (GInstanceInitFunc)dxr3spusink_init,
+ (GInstanceInitFunc) dxr3spusink_init,
};
dxr3spusink_type = g_type_register_static (GST_TYPE_ELEMENT,
- "Dxr3SpuSink",
- &dxr3spusink_info, 0);
+ "Dxr3SpuSink", &dxr3spusink_info, 0);
}
return dxr3spusink_type;
}
static void
-dxr3spusink_base_init (Dxr3SpuSinkClass *klass)
+dxr3spusink_base_init (Dxr3SpuSinkClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&dxr3spusink_sink_factory));
- gst_element_class_set_details (element_class,
- &dxr3spusink_details);
+ gst_static_pad_template_get (&dxr3spusink_sink_factory));
+ gst_element_class_set_details (element_class, &dxr3spusink_details);
}
static void
-dxr3spusink_class_init (Dxr3SpuSinkClass *klass)
+dxr3spusink_class_init (Dxr3SpuSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
dxr3spusink_signals[SET_CLUT_SIGNAL] =
- g_signal_new ("set-clut",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (Dxr3SpuSinkClass, set_clut),
- NULL, NULL,
- dxr3_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
+ g_signal_new ("set-clut",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (Dxr3SpuSinkClass, set_clut),
+ NULL, NULL, dxr3_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
dxr3spusink_signals[HIGHLIGHT_ON_SIGNAL] =
- g_signal_new ("highlight-on",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_on),
- NULL, NULL,
- dxr3_marshal_VOID__UINT_UINT_UINT_UINT_UINT_UINT,
- G_TYPE_NONE, 6,
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,
- G_TYPE_UINT, G_TYPE_UINT);
+ g_signal_new ("highlight-on",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_on),
+ NULL, NULL,
+ dxr3_marshal_VOID__UINT_UINT_UINT_UINT_UINT_UINT,
+ G_TYPE_NONE, 6,
+ G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_UINT);
dxr3spusink_signals[HIGHLIGHT_OFF_SIGNAL] =
- g_signal_new ("highlight-off",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_off),
- NULL, NULL,
- dxr3_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("highlight-off",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_off),
+ NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0);
dxr3spusink_signals[SIGNAL_FLUSHED] =
- g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (Dxr3SpuSinkClass, flushed),
- NULL, NULL,
- dxr3_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (Dxr3SpuSinkClass, flushed),
+ NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0);
klass->set_clut = dxr3spusink_set_clut;
klass->highlight_on = dxr3spusink_highlight_on;
@@ -211,13 +194,14 @@ dxr3spusink_class_init (Dxr3SpuSinkClass *klass)
}
-static void
-dxr3spusink_init (Dxr3SpuSink *sink)
+static void
+dxr3spusink_init (Dxr3SpuSink * sink)
{
GstPad *pad;
- pad = gst_pad_new_from_template (
- gst_static_pad_template_get (&dxr3spusink_sink_factory), "sink");
+ pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&dxr3spusink_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (sink), pad);
gst_pad_set_chain_function (pad, dxr3spusink_chain);
@@ -235,8 +219,8 @@ dxr3spusink_init (Dxr3SpuSink *sink)
static void
-dxr3spusink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+dxr3spusink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
Dxr3SpuSink *sink;
@@ -250,51 +234,50 @@ dxr3spusink_set_property (GObject *object, guint prop_id,
}
-static void
-dxr3spusink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+dxr3spusink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
Dxr3SpuSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_DXR3SPUSINK (object));
-
+
sink = DXR3SPUSINK (object);
-
+
switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static gboolean
-dxr3spusink_open (Dxr3SpuSink *sink)
+dxr3spusink_open (Dxr3SpuSink * sink)
{
- g_return_val_if_fail (!GST_FLAG_IS_SET (sink,
- DXR3SPUSINK_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (sink, DXR3SPUSINK_OPEN), FALSE);
/* Compute the name of the spu device file. */
- sink->spu_filename = g_strdup_printf ("/dev/em8300_sp-%d",
- sink->card_number );
+ sink->spu_filename = g_strdup_printf ("/dev/em8300_sp-%d", sink->card_number);
sink->spu_fd = open (sink->spu_filename, O_WRONLY);
if (sink->spu_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open spu device \"%s\" for writing."), sink->spu_filename), GST_ERROR_SYSTEM);
+ (_("Could not open spu device \"%s\" for writing."),
+ sink->spu_filename), GST_ERROR_SYSTEM);
return FALSE;
}
/* Open the control device. */
sink->control_filename = g_strdup_printf ("/dev/em8300-%d",
- sink->card_number );
+ sink->card_number);
sink->control_fd = open (sink->control_filename, O_WRONLY);
if (sink->control_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open control device \"%s\" for writing."), sink->control_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open control device \"%s\" for writing."),
+ sink->control_filename), GST_ERROR_SYSTEM);
return FALSE;
}
@@ -305,22 +288,21 @@ dxr3spusink_open (Dxr3SpuSink *sink)
static void
-dxr3spusink_close (Dxr3SpuSink *sink)
+dxr3spusink_close (Dxr3SpuSink * sink)
{
g_return_if_fail (GST_FLAG_IS_SET (sink, DXR3SPUSINK_OPEN));
if (close (sink->spu_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close spu device \"%s\"."), sink->spu_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close spu device \"%s\"."), sink->spu_filename),
+ GST_ERROR_SYSTEM);
return;
}
- if (close (sink->control_fd) != 0)
- {
+ if (close (sink->control_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close control device \"%s\"."), sink->control_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close control device \"%s\"."), sink->control_filename),
+ GST_ERROR_SYSTEM);
return;
}
@@ -332,16 +314,16 @@ dxr3spusink_close (Dxr3SpuSink *sink)
static void
-dxr3spusink_set_clock (GstElement *element, GstClock *clock)
+dxr3spusink_set_clock (GstElement * element, GstClock * clock)
{
Dxr3SpuSink *src = DXR3SPUSINK (element);
-
+
src->clock = clock;
}
static gboolean
-dxr3spusink_handle_event (GstPad *pad, GstEvent *event)
+dxr3spusink_handle_event (GstPad * pad, GstEvent * event)
{
GstEventType type;
Dxr3SpuSink *sink;
@@ -351,34 +333,34 @@ dxr3spusink_handle_event (GstPad *pad, GstEvent *event)
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
- case GST_EVENT_FLUSH:
- if (sink->control_fd >= 0) {
- int subdevice;
- subdevice = EM8300_SUBDEVICE_SUBPICTURE;
- ioctl (sink->control_fd, EM8300_IOCTL_FLUSH, &subdevice);
-
- /* FIXME: There should be a nicer way to do this, but I tried
- everything and nothing else seems to really reset the video
- fifo. */
+ case GST_EVENT_FLUSH:
+ if (sink->control_fd >= 0) {
+ int subdevice;
+
+ subdevice = EM8300_SUBDEVICE_SUBPICTURE;
+ ioctl (sink->control_fd, EM8300_IOCTL_FLUSH, &subdevice);
+
+ /* FIXME: There should be a nicer way to do this, but I tried
+ everything and nothing else seems to really reset the video
+ fifo. */
/* dxr3spusink_close (sink); */
/* dxr3spusink_open (sink); */
- /* Report the flush operation. */
- g_signal_emit (G_OBJECT (sink),
- dxr3spusink_signals[SIGNAL_FLUSHED], 0);
- }
- break;
- default:
- gst_pad_event_default (pad, event);
- break;
+ /* Report the flush operation. */
+ g_signal_emit (G_OBJECT (sink), dxr3spusink_signals[SIGNAL_FLUSHED], 0);
+ }
+ break;
+ default:
+ gst_pad_event_default (pad, event);
+ break;
}
return TRUE;
}
-static void
-dxr3spusink_chain (GstPad *pad, GstData *_data)
+static void
+dxr3spusink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
Dxr3SpuSink *sink;
@@ -400,15 +382,15 @@ dxr3spusink_chain (GstPad *pad, GstData *_data)
The card needs the PTS to be written *before* the actual data. */
if (GST_BUFFER_TIMESTAMP (buf) != GST_CLOCK_TIME_NONE) {
guint pts = (guint) GSTTIME_TO_MPEGTIME (GST_BUFFER_TIMESTAMP (buf));
+
ioctl (sink->spu_fd, EM8300_IOCTL_SPU_SETPTS, &pts);
}
bytes_written = write (sink->spu_fd, GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ GST_BUFFER_SIZE (buf));
if (bytes_written < GST_BUFFER_SIZE (buf)) {
fprintf (stderr, "dxr3spusink: Warning: %d bytes should be written,"
- " only %d bytes written\n",
- GST_BUFFER_SIZE (buf), bytes_written);
+ " only %d bytes written\n", GST_BUFFER_SIZE (buf), bytes_written);
}
}
@@ -417,16 +399,16 @@ dxr3spusink_chain (GstPad *pad, GstData *_data)
static GstElementStateReturn
-dxr3spusink_change_state (GstElement *element)
+dxr3spusink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_DXR3SPUSINK (element), GST_STATE_FAILURE);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!GST_FLAG_IS_SET (element, DXR3SPUSINK_OPEN)) {
- if (!dxr3spusink_open (DXR3SPUSINK (element))) {
- return GST_STATE_FAILURE;
- }
+ if (!dxr3spusink_open (DXR3SPUSINK (element))) {
+ return GST_STATE_FAILURE;
+ }
}
break;
case GST_STATE_READY_TO_PAUSED:
@@ -439,7 +421,7 @@ dxr3spusink_change_state (GstElement *element)
break;
case GST_STATE_READY_TO_NULL:
if (GST_FLAG_IS_SET (element, DXR3SPUSINK_OPEN)) {
- dxr3spusink_close (DXR3SPUSINK (element));
+ dxr3spusink_close (DXR3SPUSINK (element));
}
break;
}
@@ -457,7 +439,7 @@ dxr3spusink_change_state (GstElement *element)
* Make the sink wait the specified amount of time.
*/
static void
-dxr3spusink_wait (Dxr3SpuSink *sink, GstClockTime time)
+dxr3spusink_wait (Dxr3SpuSink * sink, GstClockTime time)
{
GstClockID id;
GstClockTimeDiff jitter;
@@ -476,27 +458,25 @@ dxr3spusink_wait (Dxr3SpuSink *sink, GstClockTime time)
* Set a new SPU color lookup table (clut) in the dxr3 card.
*/
static void
-dxr3spusink_set_clut (Dxr3SpuSink *sink, const guint32 *clut)
+dxr3spusink_set_clut (Dxr3SpuSink * sink, const guint32 * clut)
{
guint32 clut_fixed[16];
int i;
/* Fix the byte order of the table. */
- for (i=0; i<16; i++) {
+ for (i = 0; i < 16; i++) {
clut_fixed[i] = GUINT32_TO_LE (clut[i]);
}
if (ioctl (sink->spu_fd, EM8300_IOCTL_SPU_SETPALETTE, clut_fixed))
fprintf (stderr, "dxr3spusink: failed to set CLUT (%s)\n",
- strerror (errno));
+ strerror (errno));
}
static void
-dxr3spusink_highlight_on (Dxr3SpuSink *sink, unsigned palette,
- unsigned sx, unsigned sy,
- unsigned ex, unsigned ey,
- unsigned pts)
+dxr3spusink_highlight_on (Dxr3SpuSink * sink, unsigned palette,
+ unsigned sx, unsigned sy, unsigned ex, unsigned ey, unsigned pts)
{
em8300_button_t btn;
@@ -509,17 +489,17 @@ dxr3spusink_highlight_on (Dxr3SpuSink *sink, unsigned palette,
if (ioctl (sink->spu_fd, EM8300_IOCTL_SPU_BUTTON, &btn)) {
fprintf (stderr, "dxr3spusink: failed to set spu button (%s)\n",
- strerror (errno));
+ strerror (errno));
}
}
static void
-dxr3spusink_highlight_off (Dxr3SpuSink *sink)
+dxr3spusink_highlight_off (Dxr3SpuSink * sink)
{
if (ioctl (sink->spu_fd, EM8300_IOCTL_SPU_BUTTON, NULL)) {
fprintf (stderr, "dxr3spusink: failed to set spu button (%s)\n",
- strerror (errno));
+ strerror (errno));
}
}
@@ -532,7 +512,7 @@ dxr3spusink_highlight_off (Dxr3SpuSink *sink)
* queues due to a received flush event
*/
static void
-dxr3spusink_flushed (Dxr3SpuSink *sink)
+dxr3spusink_flushed (Dxr3SpuSink * sink)
{
/* Do nothing. */
}
diff --git a/sys/dxr3/dxr3spusink.h b/sys/dxr3/dxr3spusink.h
index e2551714..51bfa39e 100644
--- a/sys/dxr3/dxr3spusink.h
+++ b/sys/dxr3/dxr3spusink.h
@@ -25,8 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_DXR3SPUSINK \
(dxr3spusink_get_type())
#define DXR3SPUSINK(obj) \
@@ -37,51 +35,49 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DXR3SPUSINK))
#define GST_IS_DXR3SPUSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DXR3SPUSINK))
-
-
typedef struct _Dxr3SpuSink Dxr3SpuSink;
typedef struct _Dxr3SpuSinkClass Dxr3SpuSinkClass;
-typedef enum {
+typedef enum
+{
DXR3SPUSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- DXR3SPUSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ DXR3SPUSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} Dxr3SpuSinkFlags;
-struct _Dxr3SpuSink {
+struct _Dxr3SpuSink
+{
GstElement element;
- int card_number; /* The number of the card to open. */
+ int card_number; /* The number of the card to open. */
- gchar *spu_filename; /* File name for the spu device. */
- int spu_fd; /* File descriptor for the spu device. */
+ gchar *spu_filename; /* File name for the spu device. */
+ int spu_fd; /* File descriptor for the spu device. */
gchar *control_filename; /* File name for the control device. */
int control_fd; /* File descriptor for the control
- device. */
+ device. */
GstClock *clock; /* The clock for this element. */
};
-struct _Dxr3SpuSinkClass {
+struct _Dxr3SpuSinkClass
+{
GstElementClass parent_class;
/* Signals */
- void (*set_clut) (Dxr3SpuSink *sink, const guint32 *clut);
- void (*highlight_on) (Dxr3SpuSink *sink, unsigned palette,
- unsigned sx, unsigned sy,
- unsigned ex, unsigned ey,
- unsigned pts);
- void (*highlight_off) (Dxr3SpuSink *sink);
- void (*flushed) (Dxr3SpuSink *sink);
+ void (*set_clut) (Dxr3SpuSink * sink, const guint32 * clut);
+ void (*highlight_on) (Dxr3SpuSink * sink, unsigned palette,
+ unsigned sx, unsigned sy, unsigned ex, unsigned ey, unsigned pts);
+ void (*highlight_off) (Dxr3SpuSink * sink);
+ void (*flushed) (Dxr3SpuSink * sink);
};
-extern GType dxr3spusink_get_type (void);
-extern gboolean dxr3spusink_factory_init (GstPlugin *plugin);
+extern GType dxr3spusink_get_type (void);
+extern gboolean dxr3spusink_factory_init (GstPlugin * plugin);
G_END_DECLS
-
#endif /* __DXR3SPUSINK_H__ */
diff --git a/sys/dxr3/dxr3videosink.c b/sys/dxr3/dxr3videosink.c
index a87a94d8..616c12f3 100644
--- a/sys/dxr3/dxr3videosink.c
+++ b/sys/dxr3/dxr3videosink.c
@@ -49,28 +49,32 @@ static GstElementDetails dxr3videosink_details = {
/* Dxr3VideoSink signals and args */
-enum {
+enum
+{
SIGNAL_FLUSHED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
};
/* Possible states for the MPEG start code scanner. */
-enum {
- SCAN_STATE_WAITING, /* Waiting for a code. */
- SCAN_STATE_0, /* 0 seen. */
- SCAN_STATE_00, /* 00 seen. */
- SCAN_STATE_001 /* 001 seen. */
+enum
+{
+ SCAN_STATE_WAITING, /* Waiting for a code. */
+ SCAN_STATE_0, /* 0 seen. */
+ SCAN_STATE_00, /* 00 seen. */
+ SCAN_STATE_001 /* 001 seen. */
};
/* Possible states for the MPEG sequence parser. */
-enum {
- PARSE_STATE_WAITING, /* Waiting for the start of a sequence. */
- PARSE_STATE_START, /* Start of sequence seen. */
- PARSE_STATE_PICTURE, /* Picture start seen. */
+enum
+{
+ PARSE_STATE_WAITING, /* Waiting for the start of a sequence. */
+ PARSE_STATE_START, /* Start of sequence seen. */
+ PARSE_STATE_PICTURE, /* Picture start seen. */
};
@@ -80,64 +84,53 @@ enum {
#define START_CODE_SEQUENCE_END 0xB7
static GstStaticPadTemplate dxr3videosink_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/mpeg, "
- "mpegversion = (int) { 1, 2 }, "
- "systemstream = (boolean) FALSE"
- /* width/height/framerate omitted, we don't
- * need a parsed stream */
- )
-);
-
-
-static void dxr3videosink_class_init (Dxr3VideoSinkClass *klass);
-static void dxr3videosink_base_init (Dxr3VideoSinkClass *klass);
-static void dxr3videosink_init (Dxr3VideoSink *dxr3videosink);
-
-static void dxr3videosink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void dxr3videosink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static gboolean dxr3videosink_open (Dxr3VideoSink *sink);
-static void dxr3videosink_close (Dxr3VideoSink *sink);
-static void dxr3videosink_set_clock (GstElement *element,
- GstClock *clock);
-
-static void dxr3videosink_reset_parser (Dxr3VideoSink *sink);
-static int dxr3videosink_next_start_code (Dxr3VideoSink *sink);
-static void dxr3videosink_discard_data (Dxr3VideoSink *sink,
- guint cut);
-static void dxr3videosink_write_data (Dxr3VideoSink *sink,
- guint cut);
-static void dxr3videosink_parse_data (Dxr3VideoSink *sink);
-
-static gboolean dxr3videosink_handle_event (GstPad *pad, GstEvent *event);
-static void dxr3videosink_chain (GstPad *pad,GstData *_data);
-
-static GstElementStateReturn dxr3videosink_change_state (GstElement *element);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/mpeg, "
+ "mpegversion = (int) { 1, 2 }, " "systemstream = (boolean) FALSE"
+ /* width/height/framerate omitted, we don't
+ * need a parsed stream */
+ )
+ );
+
+
+static void dxr3videosink_class_init (Dxr3VideoSinkClass * klass);
+static void dxr3videosink_base_init (Dxr3VideoSinkClass * klass);
+static void dxr3videosink_init (Dxr3VideoSink * dxr3videosink);
+
+static void dxr3videosink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void dxr3videosink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static gboolean dxr3videosink_open (Dxr3VideoSink * sink);
+static void dxr3videosink_close (Dxr3VideoSink * sink);
+static void dxr3videosink_set_clock (GstElement * element, GstClock * clock);
+
+static void dxr3videosink_reset_parser (Dxr3VideoSink * sink);
+static int dxr3videosink_next_start_code (Dxr3VideoSink * sink);
+static void dxr3videosink_discard_data (Dxr3VideoSink * sink, guint cut);
+static void dxr3videosink_write_data (Dxr3VideoSink * sink, guint cut);
+static void dxr3videosink_parse_data (Dxr3VideoSink * sink);
+
+static gboolean dxr3videosink_handle_event (GstPad * pad, GstEvent * event);
+static void dxr3videosink_chain (GstPad * pad, GstData * _data);
+
+static GstElementStateReturn dxr3videosink_change_state (GstElement * element);
/* static void dxr3videosink_wait (Dxr3VideoSink *sink, */
/* GstClockTime time); */
-static int dxr3videosink_mvcommand (Dxr3VideoSink *sink,
- int command);
+static int dxr3videosink_mvcommand (Dxr3VideoSink * sink, int command);
-static void dxr3videosink_flushed (Dxr3VideoSink *sink);
+static void dxr3videosink_flushed (Dxr3VideoSink * sink);
static GstElementClass *parent_class = NULL;
static guint dxr3videosink_signals[LAST_SIGNAL] = { 0 };
extern GType
-dxr3videosink_get_type (void)
+dxr3videosink_get_type (void)
{
static GType dxr3videosink_type = 0;
@@ -154,8 +147,7 @@ dxr3videosink_get_type (void)
(GInstanceInitFunc) dxr3videosink_init,
};
dxr3videosink_type = g_type_register_static (GST_TYPE_ELEMENT,
- "Dxr3VideoSink",
- &dxr3videosink_info, 0);
+ "Dxr3VideoSink", &dxr3videosink_info, 0);
}
return dxr3videosink_type;
@@ -163,34 +155,31 @@ dxr3videosink_get_type (void)
static void
-dxr3videosink_base_init (Dxr3VideoSinkClass *klass)
+dxr3videosink_base_init (Dxr3VideoSinkClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&dxr3videosink_sink_factory));
- gst_element_class_set_details (element_class,
- &dxr3videosink_details);
+ gst_static_pad_template_get (&dxr3videosink_sink_factory));
+ gst_element_class_set_details (element_class, &dxr3videosink_details);
}
static void
-dxr3videosink_class_init (Dxr3VideoSinkClass *klass)
+dxr3videosink_class_init (Dxr3VideoSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
dxr3videosink_signals[SIGNAL_FLUSHED] =
- g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (Dxr3VideoSinkClass, flushed),
- NULL, NULL,
- dxr3_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (Dxr3VideoSinkClass, flushed),
+ NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0);
klass->flushed = dxr3videosink_flushed;
@@ -202,13 +191,14 @@ dxr3videosink_class_init (Dxr3VideoSinkClass *klass)
}
-static void
-dxr3videosink_init (Dxr3VideoSink *sink)
+static void
+dxr3videosink_init (Dxr3VideoSink * sink)
{
GstPad *pad;
- pad = gst_pad_new_from_template (
- gst_static_pad_template_get (&dxr3videosink_sink_factory), "sink");
+ pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&dxr3videosink_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (sink), pad);
gst_pad_set_chain_function (pad, dxr3videosink_chain);
@@ -231,8 +221,8 @@ dxr3videosink_init (Dxr3VideoSink *sink)
static void
-dxr3videosink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+dxr3videosink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
Dxr3VideoSink *sink;
@@ -246,17 +236,17 @@ dxr3videosink_set_property (GObject *object, guint prop_id,
}
-static void
-dxr3videosink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+dxr3videosink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
Dxr3VideoSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_DXR3VIDEOSINK (object));
-
+
sink = DXR3VIDEOSINK (object);
-
+
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -266,32 +256,31 @@ dxr3videosink_get_property (GObject *object, guint prop_id,
static gboolean
-dxr3videosink_open (Dxr3VideoSink *sink)
+dxr3videosink_open (Dxr3VideoSink * sink)
{
- g_return_val_if_fail (!GST_FLAG_IS_SET (sink,
- DXR3VIDEOSINK_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN), FALSE);
/* Compute the name of the video device file. */
sink->video_filename = g_strdup_printf ("/dev/em8300_mv-%d",
- sink->card_number );
+ sink->card_number);
sink->video_fd = open (sink->video_filename, O_WRONLY);
if (sink->video_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open video device \"%s\" for writing."), sink->video_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open video device \"%s\" for writing."),
+ sink->video_filename), GST_ERROR_SYSTEM);
return FALSE;
}
/* Open the control device. */
sink->control_filename = g_strdup_printf ("/dev/em8300-%d",
- sink->card_number );
+ sink->card_number);
sink->control_fd = open (sink->control_filename, O_WRONLY);
if (sink->control_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open control device \"%s\" for writing."), sink->control_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open control device \"%s\" for writing."),
+ sink->control_filename), GST_ERROR_SYSTEM);
return FALSE;
}
@@ -302,23 +291,21 @@ dxr3videosink_open (Dxr3VideoSink *sink)
static void
-dxr3videosink_close (Dxr3VideoSink *sink)
+dxr3videosink_close (Dxr3VideoSink * sink)
{
g_return_if_fail (GST_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN));
- if (close (sink->video_fd) != 0)
- {
+ if (close (sink->video_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close video device \"%s\"."), sink->video_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close video device \"%s\"."), sink->video_filename),
+ GST_ERROR_SYSTEM);
return;
}
- if (close (sink->control_fd) != 0)
- {
+ if (close (sink->control_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close control device \"%s\"."), sink->control_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close control device \"%s\"."), sink->control_filename),
+ GST_ERROR_SYSTEM);
return;
}
@@ -330,7 +317,7 @@ dxr3videosink_close (Dxr3VideoSink *sink)
static void
-dxr3videosink_set_clock (GstElement *element, GstClock *clock)
+dxr3videosink_set_clock (GstElement * element, GstClock * clock)
{
Dxr3VideoSink *src = DXR3VIDEOSINK (element);
@@ -339,7 +326,7 @@ dxr3videosink_set_clock (GstElement *element, GstClock *clock)
static void
-dxr3videosink_reset_parser (Dxr3VideoSink *sink)
+dxr3videosink_reset_parser (Dxr3VideoSink * sink)
{
if (sink->cur_buf != NULL) {
gst_buffer_unref (sink->cur_buf);
@@ -355,7 +342,7 @@ dxr3videosink_reset_parser (Dxr3VideoSink *sink)
static int
-dxr3videosink_next_start_code (Dxr3VideoSink *sink)
+dxr3videosink_next_start_code (Dxr3VideoSink * sink)
{
guchar c;
@@ -365,31 +352,29 @@ dxr3videosink_next_start_code (Dxr3VideoSink *sink)
c = (GST_BUFFER_DATA (sink->cur_buf))[sink->scan_pos];
switch (sink->scan_state) {
- case SCAN_STATE_WAITING:
- if (c == 0x00) {
- sink->scan_state = SCAN_STATE_0;
- }
- break;
- case SCAN_STATE_0:
- if (c == 0x00) {
- sink->scan_state = SCAN_STATE_00;
- }
- else {
- sink->scan_state = SCAN_STATE_WAITING;
- }
- break;
- case SCAN_STATE_00:
- if (c == 0x01) {
- sink->scan_state = SCAN_STATE_001;
- }
- else if (c != 0x00) {
- sink->scan_state = SCAN_STATE_WAITING;
- }
- break;
- case SCAN_STATE_001:
- sink->scan_pos++;
- sink->scan_state = SCAN_STATE_WAITING;
- return c;
+ case SCAN_STATE_WAITING:
+ if (c == 0x00) {
+ sink->scan_state = SCAN_STATE_0;
+ }
+ break;
+ case SCAN_STATE_0:
+ if (c == 0x00) {
+ sink->scan_state = SCAN_STATE_00;
+ } else {
+ sink->scan_state = SCAN_STATE_WAITING;
+ }
+ break;
+ case SCAN_STATE_00:
+ if (c == 0x01) {
+ sink->scan_state = SCAN_STATE_001;
+ } else if (c != 0x00) {
+ sink->scan_state = SCAN_STATE_WAITING;
+ }
+ break;
+ case SCAN_STATE_001:
+ sink->scan_pos++;
+ sink->scan_state = SCAN_STATE_WAITING;
+ return c;
}
sink->scan_pos++;
@@ -400,7 +385,7 @@ dxr3videosink_next_start_code (Dxr3VideoSink *sink)
static void
-dxr3videosink_discard_data (Dxr3VideoSink *sink, guint cut)
+dxr3videosink_discard_data (Dxr3VideoSink * sink, guint cut)
{
GstBuffer *sub;
guint size;
@@ -415,11 +400,10 @@ dxr3videosink_discard_data (Dxr3VideoSink *sink, guint cut)
if (GST_BUFFER_SIZE (sink->cur_buf) == size) {
gst_buffer_unref (sink->cur_buf);
sink->cur_buf = NULL;
- }
- else {
+ } else {
sub = gst_buffer_create_sub (sink->cur_buf, size,
- GST_BUFFER_SIZE (sink->cur_buf)
- - size);
+ GST_BUFFER_SIZE (sink->cur_buf)
+ - size);
gst_buffer_unref (sink->cur_buf);
sink->cur_buf = sub;
}
@@ -432,7 +416,7 @@ dxr3videosink_discard_data (Dxr3VideoSink *sink, guint cut)
static void
-dxr3videosink_write_data (Dxr3VideoSink *sink, guint cut)
+dxr3videosink_write_data (Dxr3VideoSink * sink, guint cut)
{
guint size, written;
guint8 *data;
@@ -464,10 +448,10 @@ dxr3videosink_write_data (Dxr3VideoSink *sink, guint cut)
while (size > 0) {
written = write (sink->video_fd, data, size);
if (written < 0) {
- GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
- (_("Could not write to device \"%s\"."), sink->video_filename),
- GST_ERROR_SYSTEM);
- break;
+ GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
+ (_("Could not write to device \"%s\"."), sink->video_filename),
+ GST_ERROR_SYSTEM);
+ break;
}
size = size - written;
data = data + written;
@@ -479,7 +463,7 @@ dxr3videosink_write_data (Dxr3VideoSink *sink, guint cut)
static void
-dxr3videosink_parse_data (Dxr3VideoSink *sink)
+dxr3videosink_parse_data (Dxr3VideoSink * sink)
{
int code;
@@ -491,46 +475,46 @@ dxr3videosink_parse_data (Dxr3VideoSink *sink)
while (code >= 0) {
switch (sink->parse_state) {
- case PARSE_STATE_WAITING:
- if (code == START_CODE_SEQUENCE_HEADER) {
- dxr3videosink_discard_data (sink, 4);
- sink->parse_state = PARSE_STATE_START;
- sink->cur_ts = sink->last_ts;
- }
- break;
-
- case PARSE_STATE_START:
- switch (code) {
- case START_CODE_SEQUENCE_HEADER:
- dxr3videosink_discard_data (sink, 4);
- sink->cur_ts = sink->last_ts;
- break;
- case START_CODE_SEQUENCE_END:
- dxr3videosink_discard_data (sink, 0);
- sink->parse_state = PARSE_STATE_WAITING;
- break;
- case START_CODE_PICTURE:
- sink->parse_state = PARSE_STATE_PICTURE;
- break;
- }
- break;
-
- case PARSE_STATE_PICTURE:
- switch (code) {
- case START_CODE_SEQUENCE_HEADER:
- dxr3videosink_write_data (sink, 4);
- sink->parse_state = PARSE_STATE_START;
- sink->cur_ts = sink->last_ts;
- break;
- case START_CODE_SEQUENCE_END:
- dxr3videosink_write_data (sink, 0);
- sink->parse_state = PARSE_STATE_WAITING;
- break;
- case START_CODE_PICTURE:
- dxr3videosink_write_data (sink, 4);
- break;
- }
- break;
+ case PARSE_STATE_WAITING:
+ if (code == START_CODE_SEQUENCE_HEADER) {
+ dxr3videosink_discard_data (sink, 4);
+ sink->parse_state = PARSE_STATE_START;
+ sink->cur_ts = sink->last_ts;
+ }
+ break;
+
+ case PARSE_STATE_START:
+ switch (code) {
+ case START_CODE_SEQUENCE_HEADER:
+ dxr3videosink_discard_data (sink, 4);
+ sink->cur_ts = sink->last_ts;
+ break;
+ case START_CODE_SEQUENCE_END:
+ dxr3videosink_discard_data (sink, 0);
+ sink->parse_state = PARSE_STATE_WAITING;
+ break;
+ case START_CODE_PICTURE:
+ sink->parse_state = PARSE_STATE_PICTURE;
+ break;
+ }
+ break;
+
+ case PARSE_STATE_PICTURE:
+ switch (code) {
+ case START_CODE_SEQUENCE_HEADER:
+ dxr3videosink_write_data (sink, 4);
+ sink->parse_state = PARSE_STATE_START;
+ sink->cur_ts = sink->last_ts;
+ break;
+ case START_CODE_SEQUENCE_END:
+ dxr3videosink_write_data (sink, 0);
+ sink->parse_state = PARSE_STATE_WAITING;
+ break;
+ case START_CODE_PICTURE:
+ dxr3videosink_write_data (sink, 4);
+ break;
+ }
+ break;
}
@@ -544,7 +528,7 @@ dxr3videosink_parse_data (Dxr3VideoSink *sink)
static gboolean
-dxr3videosink_handle_event (GstPad *pad, GstEvent *event)
+dxr3videosink_handle_event (GstPad * pad, GstEvent * event)
{
GstEventType type;
Dxr3VideoSink *sink;
@@ -554,8 +538,8 @@ dxr3videosink_handle_event (GstPad *pad, GstEvent *event)
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
- case GST_EVENT_EMPTY:
- //fprintf (stderr, "++++++ Video empty event\n");
+ case GST_EVENT_EMPTY:
+ //fprintf (stderr, "++++++ Video empty event\n");
{
/* FIXME: Handle this with a discontinuity or something. */
/* Write an MPEG2 sequence end code, to ensure that the card
@@ -564,61 +548,59 @@ dxr3videosink_handle_event (GstPad *pad, GstEvent *event)
static guint8 sec[4] = { 0x00, 0x00, 0x01, 0xb7 };
if (sink->cur_buf != NULL) {
- dxr3videosink_write_data (sink, 0);
+ dxr3videosink_write_data (sink, 0);
}
write (sink->video_fd, &sec, 4);
}
- break;
+ break;
- case GST_EVENT_DISCONTINUOUS:
- //fprintf (stderr, "++++++ Video discont event\n");
+ case GST_EVENT_DISCONTINUOUS:
+ //fprintf (stderr, "++++++ Video discont event\n");
{
gint64 time;
gboolean has_time;
unsigned cur_scr, mpeg_scr, diff;
- has_time = gst_event_discont_get_value (event,
- GST_FORMAT_TIME,
- &time);
+ has_time = gst_event_discont_get_value (event, GST_FORMAT_TIME, &time);
if (has_time) {
/* fprintf (stderr, "^^^^^^ Discontinuous event has time %.4f\n", */
/* (double) time / GST_SECOND); */
- /* If the SCR in the card is way off, fix it. */
- ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &cur_scr);
- mpeg_scr = MPEGTIME_TO_DXRTIME (GSTTIME_TO_MPEGTIME (time));
+ /* If the SCR in the card is way off, fix it. */
+ ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &cur_scr);
+ mpeg_scr = MPEGTIME_TO_DXRTIME (GSTTIME_TO_MPEGTIME (time));
+
+ diff = cur_scr > mpeg_scr ? cur_scr - mpeg_scr : mpeg_scr - cur_scr;
+ if (diff > 1800) {
+ unsigned zero = 0;
- diff = cur_scr > mpeg_scr ? cur_scr - mpeg_scr : mpeg_scr - cur_scr;
- if (diff > 1800) {
- unsigned zero = 0;
/* fprintf (stderr, "====== Adjusting SCR from video\n"); */
- ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &zero);
- ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &mpeg_scr);
- }
- }
- else {
+ ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &zero);
+ ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &mpeg_scr);
+ }
+ } else {
/* fprintf (stderr, "^^^^^^ Discontinuous event has no time\n"); */
}
}
- break;
+ break;
- case GST_EVENT_FLUSH:
- dxr3videosink_reset_parser (sink);
- break;
+ case GST_EVENT_FLUSH:
+ dxr3videosink_reset_parser (sink);
+ break;
- default:
- gst_pad_event_default (pad, event);
- break;
+ default:
+ gst_pad_event_default (pad, event);
+ break;
}
return TRUE;
}
-static void
-dxr3videosink_chain (GstPad *pad, GstData *_data)
+static void
+dxr3videosink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
Dxr3VideoSink *sink;
@@ -639,8 +621,7 @@ dxr3videosink_chain (GstPad *pad, GstData *_data)
if (sink->cur_buf == NULL) {
sink->cur_buf = buf;
- }
- else {
+ } else {
merged = gst_buffer_merge (sink->cur_buf, buf);
gst_buffer_unref (sink->cur_buf);
gst_buffer_unref (buf);
@@ -654,16 +635,16 @@ dxr3videosink_chain (GstPad *pad, GstData *_data)
static GstElementStateReturn
-dxr3videosink_change_state (GstElement *element)
+dxr3videosink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_DXR3VIDEOSINK (element), GST_STATE_FAILURE);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!GST_FLAG_IS_SET (element, DXR3VIDEOSINK_OPEN)) {
- if (!dxr3videosink_open (DXR3VIDEOSINK (element))) {
- return GST_STATE_FAILURE;
- }
+ if (!dxr3videosink_open (DXR3VIDEOSINK (element))) {
+ return GST_STATE_FAILURE;
+ }
}
break;
case GST_STATE_READY_TO_PAUSED:
@@ -680,7 +661,7 @@ dxr3videosink_change_state (GstElement *element)
break;
case GST_STATE_READY_TO_NULL:
if (GST_FLAG_IS_SET (element, DXR3VIDEOSINK_OPEN)) {
- dxr3videosink_close (DXR3VIDEOSINK (element));
+ dxr3videosink_close (DXR3VIDEOSINK (element));
}
break;
}
@@ -698,7 +679,7 @@ dxr3videosink_change_state (GstElement *element)
* Make the sink wait the specified amount of time.
*/
static void
-dxr3videosink_wait (Dxr3VideoSink *sink, GstClockTime time)
+dxr3videosink_wait (Dxr3VideoSink * sink, GstClockTime time)
{
GstClockID id;
GstClockTimeDiff jitter;
@@ -717,14 +698,14 @@ dxr3videosink_wait (Dxr3VideoSink *sink, GstClockTime time)
* Send an MVCOMMAND to the card.
*/
static int
-dxr3videosink_mvcommand (Dxr3VideoSink *sink, int command)
+dxr3videosink_mvcommand (Dxr3VideoSink * sink, int command)
{
em8300_register_t regs;
-
+
regs.microcode_register = 1;
regs.reg = 0;
regs.val = command;
-
+
return ioctl (sink->control_fd, EM8300_IOCTL_WRITEREG, &regs);
}
@@ -737,7 +718,7 @@ dxr3videosink_mvcommand (Dxr3VideoSink *sink, int command)
* queues due to a received flush event
*/
static void
-dxr3videosink_flushed (Dxr3VideoSink *sink)
+dxr3videosink_flushed (Dxr3VideoSink * sink)
{
/* Do nothing. */
}
diff --git a/sys/dxr3/dxr3videosink.h b/sys/dxr3/dxr3videosink.h
index b0e5cadf..03aa8c36 100644
--- a/sys/dxr3/dxr3videosink.h
+++ b/sys/dxr3/dxr3videosink.h
@@ -25,8 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_DXR3VIDEOSINK \
(dxr3videosink_get_type())
#define DXR3VIDEOSINK(obj) \
@@ -37,19 +35,19 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DXR3VIDEOSINK))
#define GST_IS_DXR3VIDEOSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DXR3VIDEOSINK))
-
-
typedef struct _Dxr3VideoSink Dxr3VideoSink;
typedef struct _Dxr3VideoSinkClass Dxr3VideoSinkClass;
-typedef enum {
+typedef enum
+{
DXR3VIDEOSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- DXR3VIDEOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ DXR3VIDEOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} Dxr3VideoSinkFlags;
-struct _Dxr3VideoSink {
+struct _Dxr3VideoSink
+{
GstElement element;
int card_number; /* The number of the card to open. */
@@ -58,40 +56,40 @@ struct _Dxr3VideoSink {
int video_fd; /* File descriptor for the video device. */
gchar *control_filename; /* File name for the control device. */
- int control_fd; /* File descriptor for the control
- device. */
+ int control_fd; /* File descriptor for the control
+ device. */
GstClock *clock; /* The clock for this element. */
GstClockTime last_ts; /* Last timestamp received. */
GstBuffer *cur_buf; /* The buffer we are currently
- building. */
+ building. */
GstClockTime cur_ts; /* Timestamp associated to the
- current buffer. */
+ current buffer. */
guchar scan_state; /* The current state of the MPEG start
- code scanner. */
+ code scanner. */
guint scan_pos; /* The current position of the MPEG
- start code scanner (with respect to
- the start of the current buffer. */
+ start code scanner (with respect to
+ the start of the current buffer. */
guchar parse_state; /* The current state of the MPEG
- sequence parser. */
+ sequence parser. */
};
-struct _Dxr3VideoSinkClass {
+struct _Dxr3VideoSinkClass
+{
GstElementClass parent_class;
/* signals */
- void (*flushed) (Dxr3VideoSink *sink);
+ void (*flushed) (Dxr3VideoSink * sink);
};
-extern GType dxr3videosink_get_type (void);
-extern gboolean dxr3videosink_factory_init (GstPlugin *plugin);
+extern GType dxr3videosink_get_type (void);
+extern gboolean dxr3videosink_factory_init (GstPlugin * plugin);
G_END_DECLS
-
#endif /* __DXR3VIDEOSINK_H__ */
diff --git a/sys/glsink/ARB_multitexture.h b/sys/glsink/ARB_multitexture.h
index 36dcf011..6718e2fc 100644
--- a/sys/glsink/ARB_multitexture.h
+++ b/sys/glsink/ARB_multitexture.h
@@ -7,42 +7,42 @@
* *
* version 1.0ß *
* *
- *************************************************************/
-
+ *************************************************************/
+
#ifndef __ARB_MULTITEXTURE_H_
#define __ARB_MULTITEXTURE_H_
-
+
/*
* GLOBAL SWITCHES - enable/disable advanced features of this header
*
- */
-#define ARB_MULTITEXTURE_INITIALIZE 1 // enable generic init-routines
+ */
+#define ARB_MULTITEXTURE_INITIALIZE 1 // enable generic init-routines
#ifndef _WIN32
#define GL_GLEXT_PROTOTYPES 1
-#endif
-
+#endif /* */
+
#ifdef __cplusplus
-extern "C" {
-#endif
-
+extern "C"
+{
+
+#endif /* */
+
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
-#endif
-
+#endif /* */
+
#ifndef APIENTRY
#define APIENTRY
-#endif
-
-
+#endif /* */
+
// Header file version number, required by OpenGL ABI for Linux
//#define GL_GLEXT_VERSION 7
-
-
+
/*
* NEW TOKENS TO OPENGL 1.2.1
*
- */
+ */
#ifndef GL_ARB_multitexture
#define GL_TEXTURE0_ARB 0x84C0
#define GL_TEXTURE1_ARB 0x84C1
@@ -80,232 +80,421 @@ extern "C" {
#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
#define GL_ARB_multitexture 1
-#endif
-
+#endif /* */
+
#ifndef _WIN32
#ifdef GL_GLEXT_PROTOTYPES
-extern void APIENTRY glActiveTextureARB (GLenum);
-extern void APIENTRY glClientActiveTextureARB (GLenum);
-extern void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);
-extern void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);
-extern void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);
-extern void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);
-extern void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);
-extern void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);
-extern void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);
-extern void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);
-extern void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
-extern void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);
-extern void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);
-extern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);
-extern void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);
-extern void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);
-extern void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);
-extern void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);
-extern void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble);
-extern void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);
-extern void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat);
-extern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);
-extern void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);
-extern void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);
-extern void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort);
-extern void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);
-extern void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
-extern void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);
-extern void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
-extern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);
-extern void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint);
-extern void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);
-extern void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort);
-extern void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);
-#endif // GL_GLEXT_PROTOTYPES
-#else // not _WIN32
-typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
-typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
-#endif // _WIN32
-
+ extern void APIENTRY glActiveTextureARB (GLenum);
+ extern void APIENTRY glClientActiveTextureARB (GLenum);
+ extern void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);
+ extern void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);
+ extern void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);
+ extern void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);
+ extern void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);
+ extern void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);
+ extern void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);
+ extern void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);
+ extern void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
+ extern void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);
+ extern void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);
+ extern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);
+ extern void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);
+ extern void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);
+ extern void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);
+ extern void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);
+ extern void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble,
+ GLdouble);
+ extern void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);
+ extern void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat,
+ GLfloat);
+ extern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);
+ extern void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);
+ extern void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);
+ extern void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort,
+ GLshort);
+ extern void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);
+ extern void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble,
+ GLdouble, GLdouble);
+ extern void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);
+ extern void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat,
+ GLfloat, GLfloat);
+ extern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);
+ extern void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint,
+ GLint);
+ extern void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);
+ extern void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort,
+ GLshort, GLshort);
+ extern void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);
+
+#endif // GL_GLEXT_PROTOTYPES
+#else // not _WIN32
+ typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+ typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target,
+ GLdouble s);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target,
+ const GLdouble * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target,
+ GLfloat s);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target,
+ const GLfloat * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target,
+ GLint s);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target,
+ const GLint * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target,
+ GLshort s);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target,
+ const GLshort * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target,
+ GLdouble s, GLdouble t);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target,
+ const GLdouble * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target,
+ GLfloat s, GLfloat t);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target,
+ const GLfloat * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target,
+ GLint s, GLint t);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target,
+ const GLint * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target,
+ GLshort s, GLshort t);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target,
+ const GLshort * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target,
+ GLdouble s, GLdouble t, GLdouble r);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target,
+ const GLdouble * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target,
+ GLfloat s, GLfloat t, GLfloat r);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target,
+ const GLfloat * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target,
+ GLint s, GLint t, GLint r);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target,
+ const GLint * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target,
+ GLshort s, GLshort t, GLshort r);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target,
+ const GLshort * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target,
+ GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target,
+ const GLdouble * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target,
+ GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target,
+ const GLfloat * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target,
+ GLint s, GLint t, GLint r, GLint q);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target,
+ const GLint * v);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target,
+ GLshort s, GLshort t, GLshort r, GLshort q);
+ typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target,
+ const GLshort * v);
+
+#endif // _WIN32
+
#ifdef ARB_MULTITEXTURE_INITIALIZE
#include<string.h> // string manipulation for runtime-check
-
+
#ifdef _WIN32
-PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;
-PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = NULL;
-PFNGLMULTITEXCOORD1DARBPROC glMultiTexCoord1dARB = NULL;
-PFNGLMULTITEXCOORD1DVARBPROC glMultiTexCoord1dvARB = NULL;
-PFNGLMULTITEXCOORD1FARBPROC glMultiTexCoord1fARB = NULL;
-PFNGLMULTITEXCOORD1FVARBPROC glMultiTexCoord1fvARB = NULL;
-PFNGLMULTITEXCOORD1IARBPROC glMultiTexCoord1iARB = NULL;
-PFNGLMULTITEXCOORD1IVARBPROC glMultiTexCoord1ivARB = NULL;
-PFNGLMULTITEXCOORD1SARBPROC glMultiTexCoord1sARB = NULL;
-PFNGLMULTITEXCOORD1SVARBPROC glMultiTexCoord1svARB = NULL;
-PFNGLMULTITEXCOORD2DARBPROC glMultiTexCoord2dARB = NULL;
-PFNGLMULTITEXCOORD2DVARBPROC glMultiTexCoord2dvARB = NULL;
-PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = NULL;
-PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB = NULL;
-PFNGLMULTITEXCOORD2IARBPROC glMultiTexCoord2iARB = NULL;
-PFNGLMULTITEXCOORD2IVARBPROC glMultiTexCoord2ivARB = NULL;
-PFNGLMULTITEXCOORD2SARBPROC glMultiTexCoord2sARB = NULL;
-PFNGLMULTITEXCOORD2SVARBPROC glMultiTexCoord2svARB = NULL;
-PFNGLMULTITEXCOORD3DARBPROC glMultiTexCoord3dARB = NULL;
-PFNGLMULTITEXCOORD3DVARBPROC glMultiTexCoord3dvARB = NULL;
-PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3fARB = NULL;
-PFNGLMULTITEXCOORD3FVARBPROC glMultiTexCoord3fvARB = NULL;
-PFNGLMULTITEXCOORD3IARBPROC glMultiTexCoord3iARB = NULL;
-PFNGLMULTITEXCOORD3IVARBPROC glMultiTexCoord3ivARB = NULL;
-PFNGLMULTITEXCOORD3SARBPROC glMultiTexCoord3sARB = NULL;
-PFNGLMULTITEXCOORD3SVARBPROC glMultiTexCoord3svARB = NULL;
-PFNGLMULTITEXCOORD4DARBPROC glMultiTexCoord4dARB = NULL;
-PFNGLMULTITEXCOORD4DVARBPROC glMultiTexCoord4dvARB = NULL;
-PFNGLMULTITEXCOORD4FARBPROC glMultiTexCoord4fARB = NULL;
-PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB = NULL;
-PFNGLMULTITEXCOORD4IARBPROC glMultiTexCoord4iARB = NULL;
-PFNGLMULTITEXCOORD4IVARBPROC glMultiTexCoord4ivARB = NULL;
-PFNGLMULTITEXCOORD4SARBPROC glMultiTexCoord4sARB = NULL;
-PFNGLMULTITEXCOORD4SVARBPROC glMultiTexCoord4svARB = NULL;
-#endif // _WIN32
-
-int CheckForARBMultitextureSupport(void) {
- const char search[]="GL_ARB_multitexture";
- int i, pos=0;
- int maxpos=strlen(search)-1;
- char extensions[10000];
- printf("Getting GLstring, context is %p\n", glXGetCurrentContext());
- strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));
- printf("Examinig GLstring\n");
- int len=strlen(extensions);
- for ( i=0; i<len; i++) {
- if ((i==0) || ((i>1) && extensions[i-1]==' ')) {
- pos=0;
- while(extensions[i]!=' ') {
- if (extensions[i]==search[pos]) pos++;
- if ((pos>maxpos) && extensions[i+1]==' ') {
- //if (debug)
- {
- //fprintf(stderr, search);
- //fprintf(stderr, " supported.\n");
- }
- return 1;
- }
- ++i;
- }
- }
- }
- //printf(search);
- //printf(" not supported.\n");
- return 0;
-}
-
-int GL_ARB_multitexture_Init(void) {
- if (!CheckForARBMultitextureSupport()) return 0;
+ PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;
+ PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = NULL;
+ PFNGLMULTITEXCOORD1DARBPROC glMultiTexCoord1dARB = NULL;
+ PFNGLMULTITEXCOORD1DVARBPROC glMultiTexCoord1dvARB = NULL;
+ PFNGLMULTITEXCOORD1FARBPROC glMultiTexCoord1fARB = NULL;
+ PFNGLMULTITEXCOORD1FVARBPROC glMultiTexCoord1fvARB = NULL;
+ PFNGLMULTITEXCOORD1IARBPROC glMultiTexCoord1iARB = NULL;
+ PFNGLMULTITEXCOORD1IVARBPROC glMultiTexCoord1ivARB = NULL;
+ PFNGLMULTITEXCOORD1SARBPROC glMultiTexCoord1sARB = NULL;
+ PFNGLMULTITEXCOORD1SVARBPROC glMultiTexCoord1svARB = NULL;
+ PFNGLMULTITEXCOORD2DARBPROC glMultiTexCoord2dARB = NULL;
+ PFNGLMULTITEXCOORD2DVARBPROC glMultiTexCoord2dvARB = NULL;
+ PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = NULL;
+ PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB = NULL;
+ PFNGLMULTITEXCOORD2IARBPROC glMultiTexCoord2iARB = NULL;
+ PFNGLMULTITEXCOORD2IVARBPROC glMultiTexCoord2ivARB = NULL;
+ PFNGLMULTITEXCOORD2SARBPROC glMultiTexCoord2sARB = NULL;
+ PFNGLMULTITEXCOORD2SVARBPROC glMultiTexCoord2svARB = NULL;
+ PFNGLMULTITEXCOORD3DARBPROC glMultiTexCoord3dARB = NULL;
+ PFNGLMULTITEXCOORD3DVARBPROC glMultiTexCoord3dvARB = NULL;
+ PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3fARB = NULL;
+ PFNGLMULTITEXCOORD3FVARBPROC glMultiTexCoord3fvARB = NULL;
+ PFNGLMULTITEXCOORD3IARBPROC glMultiTexCoord3iARB = NULL;
+ PFNGLMULTITEXCOORD3IVARBPROC glMultiTexCoord3ivARB = NULL;
+ PFNGLMULTITEXCOORD3SARBPROC glMultiTexCoord3sARB = NULL;
+ PFNGLMULTITEXCOORD3SVARBPROC glMultiTexCoord3svARB = NULL;
+ PFNGLMULTITEXCOORD4DARBPROC glMultiTexCoord4dARB = NULL;
+ PFNGLMULTITEXCOORD4DVARBPROC glMultiTexCoord4dvARB = NULL;
+ PFNGLMULTITEXCOORD4FARBPROC glMultiTexCoord4fARB = NULL;
+ PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB = NULL;
+ PFNGLMULTITEXCOORD4IARBPROC glMultiTexCoord4iARB = NULL;
+ PFNGLMULTITEXCOORD4IVARBPROC glMultiTexCoord4ivARB = NULL;
+ PFNGLMULTITEXCOORD4SARBPROC glMultiTexCoord4sARB = NULL;
+ PFNGLMULTITEXCOORD4SVARBPROC glMultiTexCoord4svARB = NULL;
+
+#endif // _WIN32
+ int CheckForARBMultitextureSupport (void)
+ {
+ const char search[] = "GL_ARB_multitexture";
+ int i, pos = 0;
+ int maxpos = strlen (search) - 1;
+ char extensions[10000];
+ printf ("Getting GLstring, context is %p\n", glXGetCurrentContext ());
+ strcpy (extensions, (const char *) glGetString (GL_EXTENSIONS));
+ printf ("Examinig GLstring\n");
+ int len = strlen (extensions);
+ for (i = 0; i < len; i++)
+ {
+ if ((i == 0) || ((i > 1) && extensions[i - 1] == ' ')) {
+ pos = 0;
+ while (extensions[i] != ' ')
+ {
+ if (extensions[i] == search[pos])
+ pos++;
+ if ((pos > maxpos) && extensions[i + 1] == ' ') {
+
+ //if (debug)
+ {
+
+ //fprintf(stderr, search);
+ //fprintf(stderr, " supported.\n");
+ }
+ return 1;
+ }
+ ++i;
+ }
+ }
+ }
+
+ //printf(search);
+ //printf(" not supported.\n");
+ return 0;
+ }
+ int GL_ARB_multitexture_Init (void)
+ {
+ if (!CheckForARBMultitextureSupport ())
+ return 0;
+
#ifdef _WIN32
- glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
- if (glActiveTextureARB==NULL) {fprintf(stderr,"glActiveTextureARB not found.\n"); return 0; }
- glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) wglGetProcAddress("glClientActiveTextureARB");
- if (glClientActiveTextureARB==NULL) {fprintf(stderr,"glClientActiveTextureARB not found.\n"); return 0; }
- glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC) wglGetProcAddress("glMultiTexCoord1dARB");
- if (glMultiTexCoord1dARB==NULL) {fprintf(stderr,"glMultiTexCoord1dARB not found.\n"); return 0; }
- glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC) wglGetProcAddress("glMultiTexCoord1dvARB");
- if (glMultiTexCoord1dvARB==NULL) {fprintf(stderr,"glMultiTexCoord1dAvRB not found.\n"); return 0; }
- glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC) wglGetProcAddress("glMultiTexCoord1fARB");
- if (glMultiTexCoord1fARB==NULL) {fprintf(stderr,"glMultiTexCoord1fARB not found.\n"); return 0; }
- glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC) wglGetProcAddress("glMultiTexCoord1fvARB");
- if (glMultiTexCoord1fvARB==NULL) {fprintf(stderr,"glMultiTexCoord1fvARB not found.\n"); return 0; }
- glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC) wglGetProcAddress("glMultiTexCoord1iARB");
- if (glMultiTexCoord1iARB==NULL) {fprintf(stderr,"glMultiTexCoord1iARB not found.\n"); return 0; }
- glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC) wglGetProcAddress("glMultiTexCoord1ivARB");
- if (glMultiTexCoord1ivARB==NULL) {fprintf(stderr,"glMultiTexCoord1ivARB not found.\n"); return 0; }
- glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC) wglGetProcAddress("glMultiTexCoord1sARB");
- if (glMultiTexCoord1sARB==NULL) {fprintf(stderr,"glMultiTexCoord1sARB not found.\n"); return 0; }
- glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC) wglGetProcAddress("glMultiTexCoord1svARB");
- if (glMultiTexCoord1svARB==NULL) {fprintf(stderr,"glMultiTexCoord1svARB not found.\n"); return 0; }
- glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC) wglGetProcAddress("glMultiTexCoord2dARB");
- if (glMultiTexCoord2dARB==NULL) {fprintf(stderr,"glMultiTexCoord2dARB not found.\n"); return 0; }
- glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC) wglGetProcAddress("glMultiTexCoord2dvARB");
- if (glMultiTexCoord2dvARB==NULL) {fprintf(stderr,"glMultiTexCoord2dAvRB not found.\n"); return 0; }
- glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2fARB");
- if (glMultiTexCoord2fARB==NULL) {fprintf(stderr,"glMultiTexCoord2fARB not found.\n"); return 0; }
- glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC) wglGetProcAddress("glMultiTexCoord2fvARB");
- if (glMultiTexCoord2fvARB==NULL) {fprintf(stderr,"glMultiTexCoord2fvARB not found.\n"); return 0; }
- glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC) wglGetProcAddress("glMultiTexCoord2iARB");
- if (glMultiTexCoord2iARB==NULL) {fprintf(stderr,"glMultiTexCoord2iARB not found.\n"); return 0; }
- glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC) wglGetProcAddress("glMultiTexCoord2ivARB");
- if (glMultiTexCoord2ivARB==NULL) {fprintf(stderr,"glMultiTexCoord2ivARB not found.\n"); return 0; }
- glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC) wglGetProcAddress("glMultiTexCoord2sARB");
- if (glMultiTexCoord2sARB==NULL) {fprintf(stderr,"glMultiTexCoord2sARB not found.\n"); return 0; }
- glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC) wglGetProcAddress("glMultiTexCoord2svARB");
- if (glMultiTexCoord2svARB==NULL) {fprintf(stderr,"glMultiTexCoord2svARB not found.\n"); return 0; }
- glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC) wglGetProcAddress("glMultiTexCoord3dARB");
- if (glMultiTexCoord3dARB==NULL) {fprintf(stderr,"glMultiTexCoord3dARB not found.\n"); return 0; }
- glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC) wglGetProcAddress("glMultiTexCoord3dvARB");
- if (glMultiTexCoord3dvARB==NULL) {fprintf(stderr,"glMultiTexCoord3dAvRB not found.\n"); return 0; }
- glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC) wglGetProcAddress("glMultiTexCoord3fARB");
- if (glMultiTexCoord3fARB==NULL) {fprintf(stderr,"glMultiTexCoord3fARB not found.\n"); return 0; }
- glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC) wglGetProcAddress("glMultiTexCoord3fvARB");
- if (glMultiTexCoord3fvARB==NULL) {fprintf(stderr,"glMultiTexCoord3fvARB not found.\n"); return 0; }
- glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC) wglGetProcAddress("glMultiTexCoord3iARB");
- if (glMultiTexCoord3iARB==NULL) {fprintf(stderr,"glMultiTexCoord3iARB not found.\n"); return 0; }
- glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC) wglGetProcAddress("glMultiTexCoord3ivARB");
- if (glMultiTexCoord3ivARB==NULL) {fprintf(stderr,"glMultiTexCoord3ivARB not found.\n"); return 0; }
- glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC) wglGetProcAddress("glMultiTexCoord3sARB");
- if (glMultiTexCoord3sARB==NULL) {fprintf(stderr,"glMultiTexCoord3sARB not found.\n"); return 0; }
- glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC) wglGetProcAddress("glMultiTexCoord3svARB");
- if (glMultiTexCoord3svARB==NULL) {fprintf(stderr,"glMultiTexCoord3svARB not found.\n"); return 0; }
- glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC) wglGetProcAddress("glMultiTexCoord4dARB");
- if (glMultiTexCoord4dARB==NULL) {fprintf(stderr,"glMultiTexCoord4dARB not found.\n"); return 0; }
- glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC) wglGetProcAddress("glMultiTexCoord4dvARB");
- if (glMultiTexCoord4dvARB==NULL) {fprintf(stderr,"glMultiTexCoord4dAvRB not found.\n"); return 0; }
- glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC) wglGetProcAddress("glMultiTexCoord4fARB");
- if (glMultiTexCoord4fARB==NULL) {fprintf(stderr,"glMultiTexCoord4fARB not found.\n"); return 0; }
- glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC) wglGetProcAddress("glMultiTexCoord4fvARB");
- if (glMultiTexCoord4fvARB==NULL) {fprintf(stderr,"glMultiTexCoord4fvARB not found.\n"); return 0; }
- glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC) wglGetProcAddress("glMultiTexCoord4iARB");
- if (glMultiTexCoord4iARB==NULL) {fprintf(stderr,"glMultiTexCoord4iARB not found.\n"); return 0; }
- glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC) wglGetProcAddress("glMultiTexCoord4ivARB");
- if (glMultiTexCoord4ivARB==NULL) {fprintf(stderr,"glMultiTexCoord4ivARB not found.\n"); return 0; }
- glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC) wglGetProcAddress("glMultiTexCoord4sARB");
- if (glMultiTexCoord4sARB==NULL) {fprintf(stderr,"glMultiTexCoord4sARB not found.\n"); return 0; }
- glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC) wglGetProcAddress("glMultiTexCoord4svARB");
- if (glMultiTexCoord4svARB==NULL) {fprintf(stderr,"glMultiTexCoord4svARB not found.\n"); return 0; }
+ glActiveTextureARB =
+ (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress ("glActiveTextureARB");
+ if (glActiveTextureARB == NULL) {
+ fprintf (stderr, "glActiveTextureARB not found.\n");
+ return 0;
+ }
+ glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)
+ wglGetProcAddress ("glClientActiveTextureARB");
+ if (glClientActiveTextureARB == NULL) {
+ fprintf (stderr, "glClientActiveTextureARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1dARB");
+ if (glMultiTexCoord1dARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1dARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1dvARB");
+ if (glMultiTexCoord1dvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1dAvRB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1fARB");
+ if (glMultiTexCoord1fARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1fARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1fvARB");
+ if (glMultiTexCoord1fvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1fvARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1iARB");
+ if (glMultiTexCoord1iARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1iARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1ivARB");
+ if (glMultiTexCoord1ivARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1ivARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1sARB");
+ if (glMultiTexCoord1sARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1sARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1svARB");
+ if (glMultiTexCoord1svARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1svARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2dARB");
+ if (glMultiTexCoord2dARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2dARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2dvARB");
+ if (glMultiTexCoord2dvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2dAvRB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2fARB");
+ if (glMultiTexCoord2fARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2fARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2fvARB");
+ if (glMultiTexCoord2fvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2fvARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2iARB");
+ if (glMultiTexCoord2iARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2iARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2ivARB");
+ if (glMultiTexCoord2ivARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2ivARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2sARB");
+ if (glMultiTexCoord2sARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2sARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2svARB");
+ if (glMultiTexCoord2svARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2svARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3dARB");
+ if (glMultiTexCoord3dARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3dARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3dvARB");
+ if (glMultiTexCoord3dvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3dAvRB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3fARB");
+ if (glMultiTexCoord3fARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3fARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3fvARB");
+ if (glMultiTexCoord3fvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3fvARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3iARB");
+ if (glMultiTexCoord3iARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3iARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3ivARB");
+ if (glMultiTexCoord3ivARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3ivARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3sARB");
+ if (glMultiTexCoord3sARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3sARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3svARB");
+ if (glMultiTexCoord3svARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3svARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4dARB");
+ if (glMultiTexCoord4dARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4dARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4dvARB");
+ if (glMultiTexCoord4dvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4dAvRB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4fARB");
+ if (glMultiTexCoord4fARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4fARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4fvARB");
+ if (glMultiTexCoord4fvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4fvARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4iARB");
+ if (glMultiTexCoord4iARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4iARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4ivARB");
+ if (glMultiTexCoord4ivARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4ivARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4sARB");
+ if (glMultiTexCoord4sARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4sARB not found.\n");
+ return 0;
+ }
+ glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4svARB");
+ if (glMultiTexCoord4svARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4svARB not found.\n");
+ return 0;
+ }
+
#endif // _WIN32
- return 1;
-}
-
+ return 1;
+ }
+
#endif // ARB_MULTITEXTURE_INITIALIZE
-
+
#ifdef __cplusplus
-}
-#endif
+}
+
+#endif /* */
+
#endif // not __ARB_MULTITEXTURE_H_
diff --git a/sys/glsink/EXT_paletted_texture.h b/sys/glsink/EXT_paletted_texture.h
index 37e9a9bf..7cc3e5d9 100644
--- a/sys/glsink/EXT_paletted_texture.h
+++ b/sys/glsink/EXT_paletted_texture.h
@@ -7,42 +7,42 @@
* *
* version 1.0ß *
* *
- *************************************************************/
-
+ *************************************************************/
+
#ifndef __EXT_paletted_texture_H_
#define __EXT_paletted_texture_H_
-
+
/*
* GLOBAL SWITCHES - enable/disable advanced features of this header
*
- */
-#define EXT_PALETTED_TEXTURE_INITIALIZE 1 // enable generic init-routines
+ */
+#define EXT_PALETTED_TEXTURE_INITIALIZE 1 // enable generic init-routines
#ifndef _WIN32
#define GL_GLEXT_PROTOTYPES 1
-#endif
-
+#endif /* */
+
#ifdef __cplusplus
-extern "C" {
-#endif
-
+extern "C"
+{
+
+#endif /* */
+
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
-#endif
-
+#endif /* */
+
#ifndef APIENTRY
#define APIENTRY
-#endif
-
-
+#endif /* */
+
// Header file version number, required by OpenGL ABI for Linux
//#define GL_GLEXT_VERSION 7
-
-
+
/*
* NEW TOKENS TO OPENGL 1.2.1
*
- */
+ */
#ifndef GL_EXT_paletted_texture
#define GL_COLOR_INDEX1_EXT 0x80E2
#define GL_COLOR_INDEX2_EXT 0x80E3
@@ -60,83 +60,128 @@ extern "C" {
#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF
#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
#define GL_EXT_paletted_texture 1
-#endif
-
+#endif /* */
+
#ifndef _WIN32
#ifdef GL_GLEXT_PROTOTYPES
-extern void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
-extern void APIENTRY glColorSubTableEXT(GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-extern void APIENTRY glGetColorTableEXT(GLenum, GLenum, GLenum, GLvoid *);
-extern void APIENTRY glGetColorTableParameterivEXT(GLenum, GLenum, GLint *);
-extern void APIENTRY glGetColorTableParameterfvEXT(GLenum, GLenum, GLfloat *);
-#endif // GL_GLEXT_PROTOTYPES
-#else // _WIN32
-typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *data);
-typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC)(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
-typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC)(GLenum target, GLenum format, GLenum type, GLvoid *data);
-typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)(GLenum target, GLenum pname, GLfloat *params);
-#endif // not _WIN32
-
+ extern void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum,
+ const GLvoid *);
+ extern void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum,
+ GLenum, const GLvoid *);
+ extern void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *);
+ extern void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum,
+ GLint *);
+ extern void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum,
+ GLfloat *);
+
+#endif // GL_GLEXT_PROTOTYPES
+#else // _WIN32
+ typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target,
+ GLenum internalFormat, GLsizei width, GLenum format, GLenum type,
+ const GLvoid * data);
+ typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target,
+ GLsizei start, GLsizei count, GLenum format, GLenum type,
+ const GLvoid * data);
+ typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target,
+ GLenum format, GLenum type, GLvoid * data);
+ typedef void (APIENTRY *
+ PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname,
+ GLint * params);
+ typedef void (APIENTRY *
+ PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname,
+ GLfloat * params);
+
+#endif // not _WIN32
+
#ifdef EXT_PALETTED_TEXTURE_INITIALIZE
-#include<string.h> // string manipulation for runtime-check
-
+#include<string.h> // string manipulation for runtime-check
+
#ifdef _WIN32
-PFNGLCOLORTABLEEXTPROC glColorTableEXT = NULL;
-PFNGLCOLORSUBTABLEEXTPROC glColorSubTableEXT = NULL;
-PFNGLGETCOLORTABLEEXTPROC glGetColorTableEXT = NULL;
-PFNGLGETCOLORTABLEPARAMETERIVEXTPROC glGetColorTableParameterivEXT = NULL;
-PFNGLGETCOLORTABLEPARAMETERFVEXTPROC glGetColorTableParameterfvEXT = NULL;
-#endif // _WIN32
-
-int CheckForEXTPalettedTextureSupport(void) {
- const char search[]="GL_EXT_paletted_texture";
- int i, pos=0;
- int maxpos=strlen(search)-1;
- char extensions[10000];
- strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));
- int len=strlen(extensions);
- for (i=0; i<len; i++) {
- if ((i==0) || ((i>1) && extensions[i-1]==' ')) {
- pos=0;
- while(extensions[i]!=' ') {
- if (extensions[i]==search[pos]) pos++;
- if ((pos>maxpos) && extensions[i+1]==' ') {
- //printf(search);
- //printf(" supported.\n");
- return 1;
- }
- i++;
- }
- }
- }
- //printf(search);
- //printf(" not supported.\n");
- return 0;
-}
-
-int GL_EXT_paletted_texture_Init(void) {
- if (!CheckForEXTPalettedTextureSupport()) return 0;
-
+ PFNGLCOLORTABLEEXTPROC glColorTableEXT = NULL;
+ PFNGLCOLORSUBTABLEEXTPROC glColorSubTableEXT = NULL;
+ PFNGLGETCOLORTABLEEXTPROC glGetColorTableEXT = NULL;
+ PFNGLGETCOLORTABLEPARAMETERIVEXTPROC glGetColorTableParameterivEXT = NULL;
+ PFNGLGETCOLORTABLEPARAMETERFVEXTPROC glGetColorTableParameterfvEXT = NULL;
+
+#endif // _WIN32
+ int CheckForEXTPalettedTextureSupport (void)
+ {
+ const char search[] = "GL_EXT_paletted_texture";
+ int i, pos = 0;
+ int maxpos = strlen (search) - 1;
+ char extensions[10000];
+ strcpy (extensions, (const char *) glGetString (GL_EXTENSIONS));
+ int len = strlen (extensions);
+ for (i = 0; i < len; i++)
+ {
+ if ((i == 0) || ((i > 1) && extensions[i - 1] == ' ')) {
+ pos = 0;
+ while (extensions[i] != ' ')
+ {
+ if (extensions[i] == search[pos])
+ pos++;
+ if ((pos > maxpos) && extensions[i + 1] == ' ') {
+
+ //printf(search);
+ //printf(" supported.\n");
+ return 1;
+ }
+ i++;
+ }
+ }
+ }
+
+ //printf(search);
+ //printf(" not supported.\n");
+ return 0;
+ }
+ int GL_EXT_paletted_texture_Init (void)
+ {
+ if (!CheckForEXTPalettedTextureSupport ())
+ return 0;
+
#ifdef _WIN32
- glColorTableEXT = (PFNGLCOLORTABLEEXTPROC) wglGetProcAddress("glColorTableEXT");
- if (glColorTableEXT==NULL) {fprintf(stderr,"glColorTableEXT not found.\n"); return 0;}
- glColorSubTableEXT = (PFNGLCOLORSUBTABLEEXTPROC) wglGetProcAddress("glColorSubTableEXT");
- if (glColorSubTableEXT==NULL) {fprintf(stderr,"glColorSubTableEXT not found.\n"); return 0;}
- glGetColorTableEXT = (PFNGLGETCOLORTABLEEXTPROC) wglGetProcAddress("glGetColorTableEXT");
- if (glGetColorTableEXT==NULL) {fprintf(stderr,"glGetColorTableEXT not found.\n"); return 0;}
- glGetColorTableParameterivEXT = (PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) wglGetProcAddress("glGetColorTableParameterivEXT");
- if (glGetColorTableParameterivEXT==NULL) {fprintf(stderr,"glGetColorTableParameterivEXT not found.\n"); return 0;}
- glGetColorTableParameterfvEXT = (PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) wglGetProcAddress("glGetColorTableParameterfvEXT");
- if (glGetColorTableParameterfvEXT==NULL) {fprintf(stderr,"glGetColorTableParameterfvEXT not found.\n"); return 0;}
+ glColorTableEXT =
+ (PFNGLCOLORTABLEEXTPROC) wglGetProcAddress ("glColorTableEXT");
+ if (glColorTableEXT == NULL) {
+ fprintf (stderr, "glColorTableEXT not found.\n");
+ return 0;
+ }
+ glColorSubTableEXT =
+ (PFNGLCOLORSUBTABLEEXTPROC) wglGetProcAddress ("glColorSubTableEXT");
+ if (glColorSubTableEXT == NULL) {
+ fprintf (stderr, "glColorSubTableEXT not found.\n");
+ return 0;
+ }
+ glGetColorTableEXT =
+ (PFNGLGETCOLORTABLEEXTPROC) wglGetProcAddress ("glGetColorTableEXT");
+ if (glGetColorTableEXT == NULL) {
+ fprintf (stderr, "glGetColorTableEXT not found.\n");
+ return 0;
+ }
+ glGetColorTableParameterivEXT = (PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)
+ wglGetProcAddress ("glGetColorTableParameterivEXT");
+ if (glGetColorTableParameterivEXT == NULL) {
+ fprintf (stderr, "glGetColorTableParameterivEXT not found.\n");
+ return 0;
+ }
+ glGetColorTableParameterfvEXT = (PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)
+ wglGetProcAddress ("glGetColorTableParameterfvEXT");
+ if (glGetColorTableParameterfvEXT == NULL) {
+ fprintf (stderr, "glGetColorTableParameterfvEXT not found.\n");
+ return 0;
+ }
+
#endif // _WIN32
- return 1;
-}
-
+ return 1;
+ }
+
#endif // EXT_PALETTED_TEXTURE_INITIALIZE
-
+
#ifdef __cplusplus
-}
-#endif
+}
+
+#endif /* */
+
#endif // not __EXT_PALETTED_TEXTURE_H_
diff --git a/sys/glsink/NV_register_combiners.h b/sys/glsink/NV_register_combiners.h
index 52b74c39..83f33edc 100644
--- a/sys/glsink/NV_register_combiners.h
+++ b/sys/glsink/NV_register_combiners.h
@@ -7,42 +7,42 @@
* *
* version 2.0ß *
* *
- *************************************************************/
-
+ *************************************************************/
+
#ifndef __NV_register_combiners_H_
#define __NV_register_combiners_H_
-
+
/*
* GLOBAL SWITCHES - enable/disable advanced features of this header
*
- */
-#define NV_REGISTER_COMBINERS_INITIALIZE 1 // enable generic init-routines
+ */
+#define NV_REGISTER_COMBINERS_INITIALIZE 1 // enable generic init-routines
#ifndef _WIN32
#define GL_GLEXT_PROTOTYPES 1
-#endif
-
+#endif /* */
+
#ifdef __cplusplus
-extern "C" {
-#endif
-
+extern "C"
+{
+
+#endif /* */
+
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
-#endif
-
+#endif /* */
+
#ifndef APIENTRY
#define APIENTRY
-#endif
-
-
+#endif /* */
+
// Header file version number, required by OpenGL ABI for Linux
//#define GL_GLEXT_VERSION 7
-
-
+
/*
* NEW TOKENS TO OPENGL 1.2.1
*
- */
+ */
#ifndef GL_NV_register_combiners
#define GL_REGISTER_COMBINERS_NV 0x8522
#define GL_COMBINER0_NV 0x8550
@@ -96,123 +96,228 @@ extern "C" {
#define GL_COLOR_SUM_CLAMP_NV 0x854F
#define GL_MAX_GENERAL_COMBINERS_NV 0x854D
#define GL_NV_register_combiners 1
-#endif
-
+#endif /* */
+
#ifndef _WIN32
#ifdef GL_GLEXT_PROTOTYPES
-extern void APIENTRY glCombinerParameterfvNV(GLenum, const GLfloat *);
-extern void APIENTRY glCombinerParameterivNV(GLenum, const GLint *);
-extern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat);
-extern void APIENTRY glCombinerParameteriNV (GLenum, GLint);
-extern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum);
-extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean);
-extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum);
-extern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *);
-extern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *);
-extern void APIENTRY glGetCombinerOutputParameterfvNV(GLenum, GLenum, GLenum, GLfloat *);
-extern void APIENTRY glGetCombinerOutputParameterivNV(GLenum, GLenum, GLenum, GLint *);
-extern void APIENTRY glGetFinalCombinerInputParameterfvNV(GLenum, GLenum, GLfloat *);
-extern void APIENTRY glGetFinalCombinerInputParameterivNV(GLenum, GLenum, GLint *);
-#endif // GL_GLEXT_PROTOTYPES
-#else // _WIN32
-typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
-typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
-typedef void (APIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
-typedef void (APIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
-typedef void (APIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
-typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
-typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
-typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)(GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
-typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)(GLenum stage, GLenum portion, GLenum pname, GLint *params);
-typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)(GLenum variable, GLenum pname, GLfloat *params);
-typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)(GLenum variable, GLenum pname, GLint *params);
-#endif // not _WIN32
-
+ extern void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *);
+ extern void APIENTRY glCombinerParameterivNV (GLenum, const GLint *);
+ extern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat);
+ extern void APIENTRY glCombinerParameteriNV (GLenum, GLint);
+ extern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum,
+ GLenum, GLenum);
+ extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum,
+ GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean);
+ extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum,
+ GLenum);
+ extern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum,
+ GLenum, GLenum, GLfloat *);
+ extern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum,
+ GLenum, GLenum, GLint *);
+ extern void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum,
+ GLenum, GLfloat *);
+ extern void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum,
+ GLenum, GLint *);
+ extern void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum,
+ GLfloat *);
+ extern void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum,
+ GLint *);
+
+#endif // GL_GLEXT_PROTOTYPES
+#else // _WIN32
+ typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname,
+ const GLfloat * params);
+ typedef void (APIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname,
+ const GLint * params);
+ typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname,
+ GLfloat param);
+ typedef void (APIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname,
+ GLint param);
+ typedef void (APIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage,
+ GLenum portion, GLenum variable, GLenum input, GLenum mapping,
+ GLenum componentUsage);
+ typedef void (APIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage,
+ GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput,
+ GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct,
+ GLboolean muxSum);
+ typedef void (APIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable,
+ GLenum input, GLenum mapping, GLenum componentUsage);
+ typedef void (APIENTRY *
+ PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion,
+ GLenum variable, GLenum pname, GLfloat * params);
+ typedef void (APIENTRY *
+ PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion,
+ GLenum variable, GLenum pname, GLint * params);
+ typedef void (APIENTRY *
+ PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion,
+ GLenum pname, GLfloat * params);
+ typedef void (APIENTRY *
+ PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion,
+ GLenum pname, GLint * params);
+ typedef void (APIENTRY *
+ PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable,
+ GLenum pname, GLfloat * params);
+ typedef void (APIENTRY *
+ PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable,
+ GLenum pname, GLint * params);
+
+#endif // not _WIN32
+
#ifdef NV_REGISTER_COMBINERS_INITIALIZE
-#include<string.h> // string manipulation for runtime-check
-
+#include<string.h> // string manipulation for runtime-check
+
#ifdef _WIN32
-PFNGLCOMBINERPARAMETERFVNVPROC glCombinerParameterfvNV = NULL;
-PFNGLCOMBINERPARAMETERIVNVPROC glCombinerParameterivNV = NULL;
-PFNGLCOMBINERPARAMETERFNVPROC glCombinerParameterfNV = NULL;
-PFNGLCOMBINERPARAMETERINVPROC glCombinerParameteriNV = NULL;
-PFNGLCOMBINERINPUTNVPROC glCombinerInputNV = NULL;
-PFNGLCOMBINEROUTPUTNVPROC glCombinerOutputNV = NULL;
-PFNGLFINALCOMBINERINPUTNVPROC glFinalCombinerInputNV = NULL;
-PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC glGetCombinerInputParameterfvNV = NULL;
-PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC glGetCombinerInputParameterivNV = NULL;
-PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC glGetCombinerOutputParameterfvNV = NULL;
-PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC glGetCombinerOutputParameterivNV = NULL;
-PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC glGetFinalCombinerInputParameterfvNV = NULL;
-PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC glGetFinalCombinerInputParameterivNV = NULL;
-#endif // _WIN32
-
-int CheckForNVRegisterCombinersSupport(void) {
- const char search[]="GL_NV_register_combiners";
- int i, pos=0;
- int maxpos=strlen(search)-1;
- char extensions[10000];
- strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));
- int len=strlen(extensions);
- for (i=0; i<len; i++) {
- if ((i==0) || ((i>1) && extensions[i-1]==' ')) {
- pos=0;
- while(extensions[i]!=' ') {
- if (extensions[i]==search[pos]) pos++;
- if ((pos>maxpos) && extensions[i+1]==' ') {
- //printf(search);
- // printf(" supported.\n");
- return 1;
- }
- i++;
- }
- }
- }
- //printf(search);
- //printf(" not supported.\n");
- return 0;
-}
-
-int GL_NV_register_combiners_Init(void) {
- if (!CheckForNVRegisterCombinersSupport()) return 0;
-
+ PFNGLCOMBINERPARAMETERFVNVPROC glCombinerParameterfvNV = NULL;
+ PFNGLCOMBINERPARAMETERIVNVPROC glCombinerParameterivNV = NULL;
+ PFNGLCOMBINERPARAMETERFNVPROC glCombinerParameterfNV = NULL;
+ PFNGLCOMBINERPARAMETERINVPROC glCombinerParameteriNV = NULL;
+ PFNGLCOMBINERINPUTNVPROC glCombinerInputNV = NULL;
+ PFNGLCOMBINEROUTPUTNVPROC glCombinerOutputNV = NULL;
+ PFNGLFINALCOMBINERINPUTNVPROC glFinalCombinerInputNV = NULL;
+ PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC glGetCombinerInputParameterfvNV =
+ NULL;
+ PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC glGetCombinerInputParameterivNV =
+ NULL;
+ PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC glGetCombinerOutputParameterfvNV =
+ NULL;
+ PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC glGetCombinerOutputParameterivNV =
+ NULL;
+ PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC
+ glGetFinalCombinerInputParameterfvNV = NULL;
+ PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC
+ glGetFinalCombinerInputParameterivNV = NULL;
+
+#endif // _WIN32
+ int CheckForNVRegisterCombinersSupport (void)
+ {
+ const char search[] = "GL_NV_register_combiners";
+ int i, pos = 0;
+ int maxpos = strlen (search) - 1;
+ char extensions[10000];
+ strcpy (extensions, (const char *) glGetString (GL_EXTENSIONS));
+ int len = strlen (extensions);
+ for (i = 0; i < len; i++)
+ {
+ if ((i == 0) || ((i > 1) && extensions[i - 1] == ' ')) {
+ pos = 0;
+ while (extensions[i] != ' ')
+ {
+ if (extensions[i] == search[pos])
+ pos++;
+ if ((pos > maxpos) && extensions[i + 1] == ' ') {
+
+ //printf(search);
+ // printf(" supported.\n");
+ return 1;
+ }
+ i++;
+ }
+ }
+ }
+
+ //printf(search);
+ //printf(" not supported.\n");
+ return 0;
+ }
+ int GL_NV_register_combiners_Init (void)
+ {
+ if (!CheckForNVRegisterCombinersSupport ())
+ return 0;
+
#ifdef _WIN32
- glCombinerParameterfvNV=(PFNGLCOMBINERPARAMETERFVNVPROC) wglGetProcAddress("glCombinerParameterfvNV");
- if (glCombinerParameterfvNV==NULL) {fprintf(stderr,"glCombinerParameterfvNV not found.\n"); return 0;}
- glCombinerParameterivNV=(PFNGLCOMBINERPARAMETERIVNVPROC) wglGetProcAddress("glCombinerParameterivNV");
- if (glCombinerParameterivNV==NULL) {fprintf(stderr,"glCombinerParameterivNV not found.\n"); return 0;}
- glCombinerParameterfNV=(PFNGLCOMBINERPARAMETERFNVPROC) wglGetProcAddress("glCombinerParameterfNV");
- if (glCombinerParameterfvNV==NULL) {fprintf(stderr,"glCombinerParameterfNV not found.\n"); return 0;}
- glCombinerParameteriNV=(PFNGLCOMBINERPARAMETERINVPROC) wglGetProcAddress("glCombinerParameteriNV");
- if (glCombinerParameterivNV==NULL) {fprintf(stderr,"glCombinerParameteriNV not found.\n"); return 0;}
- glCombinerInputNV=(PFNGLCOMBINERINPUTNVPROC) wglGetProcAddress("glCombinerInputNV");
- if (glCombinerInputNV==NULL) {fprintf(stderr,"glCombinerInputNV not found.\n"); return 0;}
- glCombinerOutputNV=(PFNGLCOMBINEROUTPUTNVPROC) wglGetProcAddress("glCombinerOutputNV");
- if (glCombinerOutputNV==NULL) {fprintf(stderr,"glCombinerOutputNV not found.\n"); return 0;}
- glFinalCombinerInputNV=(PFNGLFINALCOMBINERINPUTNVPROC) wglGetProcAddress("glFinalCombinerInputNV");
- if (glFinalCombinerInputNV==NULL) {fprintf(stderr,"glFinalCombinerInputNV not found.\n"); return 0;}
- glGetCombinerInputParameterfvNV=(PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) wglGetProcAddress("glGetCombinerInputParameterfvNV");
- if (glGetCombinerInputParameterfvNV==NULL) {fprintf(stderr,"glGetCombinerInputParameterfvNV not found.\n"); return 0;}
- glGetCombinerInputParameterivNV=(PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) wglGetProcAddress("glGetCombinerInputParameterivNV");
- if (glGetCombinerInputParameterivNV==NULL) {fprintf(stderr,"glGetCombinerInputParameterivNV not found.\n"); return 0;}
- glGetCombinerOutputParameterfvNV=(PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) wglGetProcAddress("glGetCombinerOutputParameterfvNV");
- if (glGetCombinerOutputParameterfvNV==NULL) {fprintf(stderr,"glGetCombinerOutputParameterfvNV not found.\n"); return 0;}
- glGetCombinerOutputParameterivNV=(PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) wglGetProcAddress("glGetCombinerOutputParameterivNV");
- if (glGetCombinerOutputParameterivNV==NULL) {fprintf(stderr,"glGetCombinerOutputParameterivNV not found.\n"); return 0;}
- glGetFinalCombinerInputParameterfvNV=(PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) wglGetProcAddress("glGetFinalCombinerInputParameterfvNV");
- if (glGetFinalCombinerInputParameterfvNV==NULL) {fprintf(stderr,"glGetFinalCombinerInputParameterfvNV not found.\n"); return 0;}
- glGetFinalCombinerInputParameterivNV=(PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) wglGetProcAddress("glGetFinalCombinerInputParameterivNV");
- if (glGetFinalCombinerInputParameterivNV==NULL) {fprintf(stderr,"glGetFinalCombinerInputParameterivNV not found.\n"); return 0;}
+ glCombinerParameterfvNV = (PFNGLCOMBINERPARAMETERFVNVPROC)
+ wglGetProcAddress ("glCombinerParameterfvNV");
+ if (glCombinerParameterfvNV == NULL) {
+ fprintf (stderr, "glCombinerParameterfvNV not found.\n");
+ return 0;
+ }
+ glCombinerParameterivNV = (PFNGLCOMBINERPARAMETERIVNVPROC)
+ wglGetProcAddress ("glCombinerParameterivNV");
+ if (glCombinerParameterivNV == NULL) {
+ fprintf (stderr, "glCombinerParameterivNV not found.\n");
+ return 0;
+ }
+ glCombinerParameterfNV = (PFNGLCOMBINERPARAMETERFNVPROC)
+ wglGetProcAddress ("glCombinerParameterfNV");
+ if (glCombinerParameterfvNV == NULL) {
+ fprintf (stderr, "glCombinerParameterfNV not found.\n");
+ return 0;
+ }
+ glCombinerParameteriNV = (PFNGLCOMBINERPARAMETERINVPROC)
+ wglGetProcAddress ("glCombinerParameteriNV");
+ if (glCombinerParameterivNV == NULL) {
+ fprintf (stderr, "glCombinerParameteriNV not found.\n");
+ return 0;
+ }
+ glCombinerInputNV =
+ (PFNGLCOMBINERINPUTNVPROC) wglGetProcAddress ("glCombinerInputNV");
+ if (glCombinerInputNV == NULL) {
+ fprintf (stderr, "glCombinerInputNV not found.\n");
+ return 0;
+ }
+ glCombinerOutputNV =
+ (PFNGLCOMBINEROUTPUTNVPROC) wglGetProcAddress ("glCombinerOutputNV");
+ if (glCombinerOutputNV == NULL) {
+ fprintf (stderr, "glCombinerOutputNV not found.\n");
+ return 0;
+ }
+ glFinalCombinerInputNV = (PFNGLFINALCOMBINERINPUTNVPROC)
+ wglGetProcAddress ("glFinalCombinerInputNV");
+ if (glFinalCombinerInputNV == NULL) {
+ fprintf (stderr, "glFinalCombinerInputNV not found.\n");
+ return 0;
+ }
+ glGetCombinerInputParameterfvNV = (PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC)
+ wglGetProcAddress ("glGetCombinerInputParameterfvNV");
+ if (glGetCombinerInputParameterfvNV == NULL) {
+ fprintf (stderr, "glGetCombinerInputParameterfvNV not found.\n");
+ return 0;
+ }
+ glGetCombinerInputParameterivNV = (PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC)
+ wglGetProcAddress ("glGetCombinerInputParameterivNV");
+ if (glGetCombinerInputParameterivNV == NULL) {
+ fprintf (stderr, "glGetCombinerInputParameterivNV not found.\n");
+ return 0;
+ }
+ glGetCombinerOutputParameterfvNV =
+ (PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)
+ wglGetProcAddress ("glGetCombinerOutputParameterfvNV");
+ if (glGetCombinerOutputParameterfvNV == NULL) {
+ fprintf (stderr, "glGetCombinerOutputParameterfvNV not found.\n");
+ return 0;
+ }
+ glGetCombinerOutputParameterivNV =
+ (PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)
+ wglGetProcAddress ("glGetCombinerOutputParameterivNV");
+ if (glGetCombinerOutputParameterivNV == NULL) {
+ fprintf (stderr, "glGetCombinerOutputParameterivNV not found.\n");
+ return 0;
+ }
+ glGetFinalCombinerInputParameterfvNV =
+ (PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)
+ wglGetProcAddress ("glGetFinalCombinerInputParameterfvNV");
+ if (glGetFinalCombinerInputParameterfvNV == NULL) {
+ fprintf (stderr, "glGetFinalCombinerInputParameterfvNV not found.\n");
+ return 0;
+ }
+ glGetFinalCombinerInputParameterivNV =
+ (PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)
+ wglGetProcAddress ("glGetFinalCombinerInputParameterivNV");
+ if (glGetFinalCombinerInputParameterivNV == NULL) {
+ fprintf (stderr, "glGetFinalCombinerInputParameterivNV not found.\n");
+ return 0;
+ }
+
#endif // _WIN32
- return 1;
-}
-
+ return 1;
+ }
+
#endif // NV_REGISTER_COMBINERS_INITIALIZE
-
+
#ifdef __cplusplus
-}
-#endif
+}
+
+#endif /* */
+
#endif // not __NV_REGISTER_COMBINERS_H_
diff --git a/sys/glsink/gstgl_nvimage.c b/sys/glsink/gstgl_nvimage.c
index 84a1ad95..1aab5c4f 100644
--- a/sys/glsink/gstgl_nvimage.c
+++ b/sys/glsink/gstgl_nvimage.c
@@ -23,7 +23,7 @@
//#include <GL/glext.h>
#include <GL/glu.h>
#include <string.h>
-#include <math.h>
+#include <math.h>
// too lazy to write an API for this ;)
#include "regcomb_yuvrgb.c"
@@ -31,15 +31,16 @@
#include "gstglsink.h"
typedef struct _GstGLImageConnection GstGLImageConnection;
-struct _GstGLImageConnection {
+struct _GstGLImageConnection
+{
GstImageConnection conn;
Display *dpy;
gint w, h;
gint bpp;
-
+
int ytex_id;
int uvtex_id;
- int septex_id;
+ int septex_id;
unsigned char *m_memory;
int m_bufslots[4];
};
@@ -54,50 +55,57 @@ typedef struct _GstNvImage GstNvImage;
struct _GstNvImage
{
GstImageData data;
- int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
+ int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
GstGLImageConnection *conn;
};
-static GstGLImageInfo * gst_gl_nvimage_info (GstImageInfo *info);
-static GstGLImageConnection * gst_gl_nvimage_connection (GstImageConnection *conn);
-static gboolean gst_gl_nvimage_check_xvideo ();
-
-static GstCaps * gst_gl_nvimage_get_caps (GstImageInfo *info);
-static GstImageConnection * gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps);
-static GstImageData * gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn);
-static void gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image);
-static void gst_gl_nvimage_free_image (GstImageData *image);
-static void gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_nvimage_free_conn (GstImageConnection *conn);
-
-GstImagePlugin* get_gl_nvimage_plugin(void)
+static GstGLImageInfo *gst_gl_nvimage_info (GstImageInfo * info);
+static GstGLImageConnection *gst_gl_nvimage_connection (GstImageConnection *
+ conn);
+static gboolean gst_gl_nvimage_check_xvideo ();
+
+static GstCaps *gst_gl_nvimage_get_caps (GstImageInfo * info);
+static GstImageConnection *gst_gl_nvimage_set_caps (GstImageInfo * info,
+ GstCaps * caps);
+static GstImageData *gst_gl_nvimage_get_image (GstImageInfo * info,
+ GstImageConnection * conn);
+static void gst_gl_nvimage_put_image (GstImageInfo * info,
+ GstImageData * image);
+static void gst_gl_nvimage_free_image (GstImageData * image);
+static void gst_gl_nvimage_open_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_nvimage_close_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_nvimage_free_conn (GstImageConnection * conn);
+
+GstImagePlugin *
+get_gl_nvimage_plugin (void)
{
static GstImagePlugin plugin = { gst_gl_nvimage_get_caps,
- gst_gl_nvimage_set_caps,
- gst_gl_nvimage_get_image,
- gst_gl_nvimage_put_image,
- gst_gl_nvimage_free_image};
+ gst_gl_nvimage_set_caps,
+ gst_gl_nvimage_get_image,
+ gst_gl_nvimage_put_image,
+ gst_gl_nvimage_free_image
+ };
return &plugin;
}
static GstGLImageInfo *
-gst_gl_nvimage_info (GstImageInfo *info)
+gst_gl_nvimage_info (GstImageInfo * info)
{
- if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b'))
- {
+ if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b')) {
return NULL;
}
return (GstGLImageInfo *) info;
}
static GstGLImageConnection *
-gst_gl_nvimage_connection (GstImageConnection *conn)
+gst_gl_nvimage_connection (GstImageConnection * conn)
{
if (conn == NULL || conn->free_conn != gst_gl_nvimage_free_conn)
- return NULL;
+ return NULL;
return (GstGLImageConnection *) conn;
}
@@ -105,57 +113,58 @@ gboolean
gst_gl_nvimage_check_xvideo ()
{
//int ver, rel, req, ev, err;
- printf("Checking NVidia OpenGL extensions.\n");
- if (!GL_ARB_multitexture_Init()) return FALSE;
- if (!GL_EXT_paletted_texture_Init()) return FALSE;
- if (!GL_NV_register_combiners_Init()) return FALSE;
+ printf ("Checking NVidia OpenGL extensions.\n");
+ if (!GL_ARB_multitexture_Init ())
+ return FALSE;
+ if (!GL_EXT_paletted_texture_Init ())
+ return FALSE;
+ if (!GL_NV_register_combiners_Init ())
+ return FALSE;
-#if 0
+#if 0
if (display == NULL)
return FALSE;
- if (Success == XvQueryExtension (display,&ver,&rel,&req,&ev,&err))
+ if (Success == XvQueryExtension (display, &ver, &rel, &req, &ev, &err))
return TRUE;
#endif
return TRUE;
}
-static GstCaps *
-gst_gl_nvimage_get_caps (GstImageInfo *info)
+static GstCaps *
+gst_gl_nvimage_get_caps (GstImageInfo * info)
{
//gint i;
//int adaptors;
//int formats;
GstCaps *caps = NULL;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
-
- g_warning("nvimage get caps called, context %p !\n", glXGetCurrentContext());
+
+ g_warning ("nvimage get caps called, context %p !\n",
+ glXGetCurrentContext ());
/* we don't handle these image information */
- if (xinfo == NULL)
- {
- printf("Invalid XInfo struct !\n");
- return NULL;
- }
+ if (xinfo == NULL) {
+ printf ("Invalid XInfo struct !\n");
+ return NULL;
+ }
- if (gst_gl_nvimage_check_xvideo () == FALSE)
- {
- g_warning("GL_NVImage: Server has no NVidia extension support\n");
+ if (gst_gl_nvimage_check_xvideo () == FALSE) {
+ g_warning ("GL_NVImage: Server has no NVidia extension support\n");
return NULL;
}
- caps = gst_caps_append (caps, GST_CAPS_NEW (
- "nvimage_caps",
- "video/x-raw-yuv",
- "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'V', '1', '2')),
- "width", GST_PROPS_INT_RANGE (0, 1024),
- "height", GST_PROPS_INT_RANGE (0, 1024))
- );
- g_warning("nvimage returns caps !\n");
+ caps = gst_caps_append (caps, GST_CAPS_NEW ("nvimage_caps",
+ "video/x-raw-yuv",
+ "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'V', '1', '2')),
+ "width", GST_PROPS_INT_RANGE (0, 1024),
+ "height", GST_PROPS_INT_RANGE (0, 1024))
+ );
+ g_warning ("nvimage returns caps !\n");
return caps;
}
static GstImageConnection *
-gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
+gst_gl_nvimage_set_caps (GstImageInfo * info, GstCaps * caps)
{
//gint i, j = 0;
//int adaptors;
@@ -163,64 +172,62 @@ gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
GstGLImageConnection *conn;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
guint32 format;
-
+
/* we don't handle these image information */
- if (xinfo == NULL) return NULL;
-
+ if (xinfo == NULL)
+ return NULL;
+
conn = g_new0 (GstGLImageConnection, 1);
conn->conn.open_conn = gst_gl_nvimage_open_conn;
conn->conn.close_conn = gst_gl_nvimage_close_conn;
conn->conn.free_conn = gst_gl_nvimage_free_conn;
- gst_caps_get (caps,
- "width", &conn->w,
- "height", &conn->h,
- "format", &format,
- NULL);
+ gst_caps_get (caps,
+ "width", &conn->w, "height", &conn->h, "format", &format, NULL);
// maybe I should a bit more checking here, e.g. maximum size smaller than maximum texture extents
- if (format != GST_MAKE_FOURCC ('Y', 'V', '1', '2'))
- {
- GST_DEBUG ("GL_NVImage: Format is invalid !\n");
- return NULL;
- }
- if (0) //conn->port == (XvPortID) -1)
+ if (format != GST_MAKE_FOURCC ('Y', 'V', '1', '2')) {
+ GST_DEBUG ("GL_NVImage: Format is invalid !\n");
+ return NULL;
+ }
+ if (0) //conn->port == (XvPortID) -1)
{
/* this happens if the plugin can't handle the caps, so no warning */
g_free (conn);
return NULL;
}
-
+
GST_DEBUG ("GL_NVImage: caps %p are ok, creating image", caps);
return (GstImageConnection *) conn;
}
static GstImageData *
-gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
+gst_gl_nvimage_get_image (GstImageInfo * info, GstImageConnection * conn)
{
GstNvImage *image;
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
- GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
-
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+ GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
+
/* checks */
- if (xinfo == NULL) return NULL;
- if (nvconn == NULL) return NULL;
+ if (xinfo == NULL)
+ return NULL;
+ if (nvconn == NULL)
+ return NULL;
// I should also check the current GLX context !
// Ah, Don't have to, I am guarantueed to be in the same thread as put_image
- image = g_new0(GstNvImage, 1);
+ image = g_new0 (GstNvImage, 1);
- image->data.size = nvconn->w * nvconn->h * 3/2;
+ image->data.size = nvconn->w * nvconn->h * 3 / 2;
//g_warning("Allocating %d bytes from main memory !", image->data.size);
- image->data.data = g_malloc(image->data.size);
+ image->data.data = g_malloc (image->data.size);
//image->slot = AGP_BUFSLOTS; // no AGP slot
image->conn = nvconn;
- if (image->data.data == NULL)
- {
+ if (image->data.data == NULL) {
g_warning ("GL_NvImage: data allocation failed!");
g_free (image);
return NULL;
@@ -229,187 +236,194 @@ gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
return (GstImageData *) image;
}
-static void
-gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
+static void
+gst_gl_nvimage_put_image (GstImageInfo * info, GstImageData * image)
{
GstNvImage *im = (GstNvImage *) image;
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
-
- int img_width = im->conn->w;
- int img_height = im->conn->h;
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+
+ int img_width = im->conn->w;
+ int img_height = im->conn->h;
int uv_width = img_width >> 1;
int uv_height = img_height >> 1;
-
+
unsigned char *buf_y = im->data.data;
unsigned char *buf_v = (buf_y + img_width * img_height);
- unsigned char *buf_u = buf_v + ((img_width/2) * (img_height/2));
+ unsigned char *buf_u = buf_v + ((img_width / 2) * (img_height / 2));
/* checks omitted for speed (and lazyness), do we need them? */
g_assert (xinfo != NULL);
-
+
// both upload the video, and redraw the screen
//glClearColor(0,0.5, 0.3,1.0); // a test color
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.0, 0.0, -5.0);
- glDisable(GL_TEXTURE_2D);
+ glMatrixMode (GL_MODELVIEW);
+ glLoadIdentity ();
+ glTranslatef (0.0, 0.0, -5.0);
+ glDisable (GL_TEXTURE_2D);
- if (xinfo->info.demo)
- {
- //g_print("Putting image, context is %p\n", glXGetCurrentContext());
+ if (xinfo->info.demo) {
+ //g_print("Putting image, context is %p\n", glXGetCurrentContext());
- glTranslatef(0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
- glRotatef(180.0*sin(xinfo->rotX),1,0,0);
- glRotatef(180.0*cos(xinfo->rotY),0,1,0);
+ glTranslatef (0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
+ glRotatef (180.0 * sin (xinfo->rotX), 1, 0, 0);
+ glRotatef (180.0 * cos (xinfo->rotY), 0, 1, 0);
- xinfo->rotX += 0.01;
- xinfo->rotY -= 0.015;
- float zoom = xinfo->zoom;
- glScalef(zoom,zoom,zoom);
- //glScalef(0.1,0.1,0.1);
+ xinfo->rotX += 0.01;
+ xinfo->rotY -= 0.015;
+ float zoom = xinfo->zoom;
- if (xinfo->zoom > 2.0)
- xinfo->zoomdir = -0.01;
+ glScalef (zoom, zoom, zoom);
+ //glScalef(0.1,0.1,0.1);
- if (xinfo->zoom < 1.0)
- xinfo->zoomdir = 0.01;
+ if (xinfo->zoom > 2.0)
+ xinfo->zoomdir = -0.01;
- xinfo->zoom += xinfo->zoomdir;
- }
+ if (xinfo->zoom < 1.0)
+ xinfo->zoomdir = 0.01;
+ xinfo->zoom += xinfo->zoomdir;
+ }
//Draws the surface rectangle
- if (Ywidth != im->conn->w || Yheight != im->conn->h)
- {
- Ywidth = im->conn->w; Yheight = im->conn->h; UVwidth = im->conn->w/2; UVheight = im->conn->h/2;
- Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,GL_LINEAR);
+ if (Ywidth != im->conn->w || Yheight != im->conn->h) {
+ Ywidth = im->conn->w;
+ Yheight = im->conn->h;
+ UVwidth = im->conn->w / 2;
+ UVheight = im->conn->h / 2;
+ Initialize_Backend (Ywidth, Yheight, UVwidth, UVheight, GL_LINEAR);
}
- LoadYUVPlanes(Yhandle,Uhandle,Vhandle,img_width,img_height,uv_width,uv_height,buf_y,buf_u,buf_v);
- float xmax = (float)(im->conn->w-1)/tex_xsize;
- float ymax = (float)(im->conn->h-1)/tex_ysize;
+ LoadYUVPlanes (Yhandle, Uhandle, Vhandle, img_width, img_height, uv_width,
+ uv_height, buf_y, buf_u, buf_v);
+ float xmax = (float) (im->conn->w - 1) / tex_xsize;
+ float ymax = (float) (im->conn->h - 1) / tex_ysize;
/* Upload the texture here */
//g_warning("PUTTING IMAGE %f %f %d %d\n", xmax, ymax, tex_xsize, tex_ysize);
//glColor4f(1,1,1,1); // do NOT set a color here ! Done by Initialize_Backend, or actually SetConst !
- glBegin(GL_QUADS);
+ glBegin (GL_QUADS);
- float aspect = img_width/(float)img_height;
+ float aspect = img_width / (float) img_height;
float hor = aspect;
//g_print("Drawing vertices, context is %p\n", glXGetCurrentContext());
- glNormal3f(0, -1, 0);
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,0);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
- glMultiTexCoord2fARB(GL_TEXTURE2_ARB,0,0);
- glVertex3f(-hor,1,0);
-
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,ymax);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,ymax);
- glMultiTexCoord2fARB(GL_TEXTURE2_ARB,0,ymax);
- glVertex3f(-hor,-1,0);
-
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB,xmax,ymax);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB,xmax,ymax);
- glMultiTexCoord2fARB(GL_TEXTURE2_ARB,xmax,ymax);
- glVertex3f(hor,-1,0);
-
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB,xmax,0);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB,xmax,0);
- glMultiTexCoord2fARB(GL_TEXTURE2_ARB,xmax,0);
- glVertex3f(hor,1,0);
-
- glEnd();
-
- if (xinfo->info.dumpvideo)
- {
- static int framenr = 0;
- char capfilename[255];
- static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
- int i;
-
- // hmmmm, is this reentrant ?!
- if (cap_image_data == NULL)
- cap_image_data = (guint8 *)malloc(img_width * img_height * 3);
-
- if (cap_image_data2 == NULL)
- cap_image_data2 = (guint8 *)malloc(img_width * img_height * 3);
-
- printf("Recording frame #%d\n", framenr);
- glReadPixels(0,0,img_width,img_height,GL_RGB,GL_UNSIGNED_BYTE,cap_image_data);
- // invert the pixels
- for (i = 0; i < img_height; i++)
- memcpy(cap_image_data2 + i * img_width * 3, cap_image_data + (img_height-1-i) * img_width * 3, img_width*3);
-
- sprintf(capfilename, "cap%04d.ppm", framenr);
- FILE *outfile = fopen(capfilename, "wb");
- if (outfile != NULL)
- {
- fprintf(outfile, "P6\n");
- fprintf(outfile,"# created by glsink from GStreamer\n");
- fprintf(outfile,"%d %d\n",img_width,img_height);
- fprintf(outfile,"255\n");
- fwrite(cap_image_data2, sizeof(char), img_width*img_height*3, outfile);
- fclose(outfile);
- }
- framenr++;
+ glNormal3f (0, -1, 0);
+ glMultiTexCoord2fARB (GL_TEXTURE0_ARB, 0, 0);
+ glMultiTexCoord2fARB (GL_TEXTURE1_ARB, 0, 0);
+ glMultiTexCoord2fARB (GL_TEXTURE2_ARB, 0, 0);
+ glVertex3f (-hor, 1, 0);
+
+ glMultiTexCoord2fARB (GL_TEXTURE0_ARB, 0, ymax);
+ glMultiTexCoord2fARB (GL_TEXTURE1_ARB, 0, ymax);
+ glMultiTexCoord2fARB (GL_TEXTURE2_ARB, 0, ymax);
+ glVertex3f (-hor, -1, 0);
+
+ glMultiTexCoord2fARB (GL_TEXTURE0_ARB, xmax, ymax);
+ glMultiTexCoord2fARB (GL_TEXTURE1_ARB, xmax, ymax);
+ glMultiTexCoord2fARB (GL_TEXTURE2_ARB, xmax, ymax);
+ glVertex3f (hor, -1, 0);
+
+ glMultiTexCoord2fARB (GL_TEXTURE0_ARB, xmax, 0);
+ glMultiTexCoord2fARB (GL_TEXTURE1_ARB, xmax, 0);
+ glMultiTexCoord2fARB (GL_TEXTURE2_ARB, xmax, 0);
+ glVertex3f (hor, 1, 0);
+
+ glEnd ();
+
+ if (xinfo->info.dumpvideo) {
+ static int framenr = 0;
+ char capfilename[255];
+ static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
+ int i;
+
+ // hmmmm, is this reentrant ?!
+ if (cap_image_data == NULL)
+ cap_image_data = (guint8 *) malloc (img_width * img_height * 3);
+
+ if (cap_image_data2 == NULL)
+ cap_image_data2 = (guint8 *) malloc (img_width * img_height * 3);
+
+ printf ("Recording frame #%d\n", framenr);
+ glReadPixels (0, 0, img_width, img_height, GL_RGB, GL_UNSIGNED_BYTE,
+ cap_image_data);
+ // invert the pixels
+ for (i = 0; i < img_height; i++)
+ memcpy (cap_image_data2 + i * img_width * 3,
+ cap_image_data + (img_height - 1 - i) * img_width * 3, img_width * 3);
+
+ sprintf (capfilename, "cap%04d.ppm", framenr);
+ FILE *outfile = fopen (capfilename, "wb");
+
+ if (outfile != NULL) {
+ fprintf (outfile, "P6\n");
+ fprintf (outfile, "# created by glsink from GStreamer\n");
+ fprintf (outfile, "%d %d\n", img_width, img_height);
+ fprintf (outfile, "255\n");
+ fwrite (cap_image_data2, sizeof (char), img_width * img_height * 3,
+ outfile);
+ fclose (outfile);
}
+ framenr++;
+ }
- glXSwapBuffers(xinfo->dpy, xinfo->win);
+ glXSwapBuffers (xinfo->dpy, xinfo->win);
}
-static void
-gst_gl_nvimage_free_image (GstImageData *image)
+static void
+gst_gl_nvimage_free_image (GstImageData * image)
{
GstNvImage *im = (GstNvImage *) image;
+
g_return_if_fail (im != NULL);
- GstGLImageConnection *nvconn = im->conn;
+ GstGLImageConnection *nvconn = im->conn;
- if (im->slot < AGP_BUFSLOTS)
- {
- nvconn->m_bufslots[im->slot] = 0;
- }
- else
- g_free(im->data.data);
+ if (im->slot < AGP_BUFSLOTS) {
+ nvconn->m_bufslots[im->slot] = 0;
+ } else
+ g_free (im->data.data);
g_free (im);
}
static void
-gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
+gst_gl_nvimage_open_conn (GstImageConnection * conn, GstImageInfo * info)
{
//GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
//GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
- g_print("Opening NVidia connection; OpenGL on Nvidia, using register combiners.\n");
+ g_print
+ ("Opening NVidia connection; OpenGL on Nvidia, using register combiners.\n");
{
- Ywidth = TEX_XSIZE; Yheight = TEX_YSIZE; UVwidth = TEX_XSIZE/2; UVheight = TEX_YSIZE/2;
- Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,GL_LINEAR);
+ Ywidth = TEX_XSIZE;
+ Yheight = TEX_YSIZE;
+ UVwidth = TEX_XSIZE / 2;
+ UVheight = TEX_YSIZE / 2;
+ Initialize_Backend (Ywidth, Yheight, UVwidth, UVheight, GL_LINEAR);
}
- g_print("Done\n");
+ g_print ("Done\n");
}
static void
-gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
+gst_gl_nvimage_close_conn (GstImageConnection * conn, GstImageInfo * info)
{
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
+
//GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
// anything needed in here ? Oh, maybe drawing de-init, or something
- glDeleteTextures(1, &xconn->ytex_id);
- glDeleteTextures(1, &xconn->uvtex_id);
- glDeleteTextures(1, &xconn->septex_id);
+ glDeleteTextures (1, &xconn->ytex_id);
+ glDeleteTextures (1, &xconn->uvtex_id);
+ glDeleteTextures (1, &xconn->septex_id);
}
-static void
-gst_gl_nvimage_free_conn (GstImageConnection *conn)
+static void
+gst_gl_nvimage_free_conn (GstImageConnection * conn)
{
- GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
+ GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
g_free (nvconn);
}
-
diff --git a/sys/glsink/gstgl_pdrimage.c b/sys/glsink/gstgl_pdrimage.c
index 3cc5c57f..20582ebf 100644
--- a/sys/glsink/gstgl_pdrimage.c
+++ b/sys/glsink/gstgl_pdrimage.c
@@ -31,15 +31,16 @@
#include "gstglsink.h"
typedef struct _GstGLImageConnection GstGLImageConnection;
-struct _GstGLImageConnection {
+struct _GstGLImageConnection
+{
GstImageConnection conn;
Display *dpy;
gint w, h;
gint bpp;
-
+
int ytex_id;
int uvtex_id;
- int septex_id;
+ int septex_id;
unsigned char *m_memory;
int m_bufslots[4];
};
@@ -54,50 +55,57 @@ typedef struct _GstNvImage GstNvImage;
struct _GstNvImage
{
GstImageData data;
- int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
+ int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
GstGLImageConnection *conn;
};
-static GstGLImageInfo * gst_gl_nvimage_info (GstImageInfo *info);
-static GstGLImageConnection * gst_gl_nvimage_connection (GstImageConnection *conn);
-static gboolean gst_gl_nvimage_check_xvideo ();
-
-static GstCaps * gst_gl_nvimage_get_caps (GstImageInfo *info);
-static GstImageConnection * gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps);
-static GstImageData * gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn);
-static void gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image);
-static void gst_gl_nvimage_free_image (GstImageData *image);
-static void gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_nvimage_free_conn (GstImageConnection *conn);
-
-GstImagePlugin* get_gl_nvimage_plugin(void)
+static GstGLImageInfo *gst_gl_nvimage_info (GstImageInfo * info);
+static GstGLImageConnection *gst_gl_nvimage_connection (GstImageConnection *
+ conn);
+static gboolean gst_gl_nvimage_check_xvideo ();
+
+static GstCaps *gst_gl_nvimage_get_caps (GstImageInfo * info);
+static GstImageConnection *gst_gl_nvimage_set_caps (GstImageInfo * info,
+ GstCaps * caps);
+static GstImageData *gst_gl_nvimage_get_image (GstImageInfo * info,
+ GstImageConnection * conn);
+static void gst_gl_nvimage_put_image (GstImageInfo * info,
+ GstImageData * image);
+static void gst_gl_nvimage_free_image (GstImageData * image);
+static void gst_gl_nvimage_open_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_nvimage_close_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_nvimage_free_conn (GstImageConnection * conn);
+
+GstImagePlugin *
+get_gl_nvimage_plugin (void)
{
static GstImagePlugin plugin = { gst_gl_nvimage_get_caps,
- gst_gl_nvimage_set_caps,
- gst_gl_nvimage_get_image,
- gst_gl_nvimage_put_image,
- gst_gl_nvimage_free_image};
+ gst_gl_nvimage_set_caps,
+ gst_gl_nvimage_get_image,
+ gst_gl_nvimage_put_image,
+ gst_gl_nvimage_free_image
+ };
return &plugin;
}
static GstGLImageInfo *
-gst_gl_nvimage_info (GstImageInfo *info)
+gst_gl_nvimage_info (GstImageInfo * info)
{
- if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b'))
- {
+ if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b')) {
return NULL;
}
return (GstGLImageInfo *) info;
}
static GstGLImageConnection *
-gst_gl_nvimage_connection (GstImageConnection *conn)
+gst_gl_nvimage_connection (GstImageConnection * conn)
{
if (conn == NULL || conn->free_conn != gst_gl_nvimage_free_conn)
- return NULL;
+ return NULL;
return (GstGLImageConnection *) conn;
}
@@ -105,47 +113,46 @@ gboolean
gst_gl_nvimage_check_xvideo ()
{
int ver, rel, req, ev, err;
-
-#if 0
+
+#if 0
if (display == NULL)
return FALSE;
- if (Success == XvQueryExtension (display,&ver,&rel,&req,&ev,&err))
+ if (Success == XvQueryExtension (display, &ver, &rel, &req, &ev, &err))
return TRUE;
#endif
return FALSE;
}
-static GstCaps *
-gst_gl_nvimage_get_caps (GstImageInfo *info)
+static GstCaps *
+gst_gl_nvimage_get_caps (GstImageInfo * info)
{
gint i;
int adaptors;
int formats;
GstCaps *caps = NULL;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
-
+
/* we don't handle these image information */
- if (xinfo == NULL) return NULL;
+ if (xinfo == NULL)
+ return NULL;
- if (gst_gl_nvimage_check_xvideo () == FALSE)
- {
- g_warning("GL_NVImage: Server has no NVidia extension support\n");
+ if (gst_gl_nvimage_check_xvideo () == FALSE) {
+ g_warning ("GL_NVImage: Server has no NVidia extension support\n");
return NULL;
}
- caps = gst_caps_append (caps, GST_CAPS_NEW (
- "xvimage_caps",
- "video/raw",
- "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'C', '1', '2')),
- "width", GST_PROPS_INT_RANGE (0, 1024),
- "height", GST_PROPS_INT_RANGE (0, 1024))
- );
+ caps = gst_caps_append (caps, GST_CAPS_NEW ("xvimage_caps",
+ "video/raw",
+ "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'C', '1', '2')),
+ "width", GST_PROPS_INT_RANGE (0, 1024),
+ "height", GST_PROPS_INT_RANGE (0, 1024))
+ );
return caps;
}
static GstImageConnection *
-gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
+gst_gl_nvimage_set_caps (GstImageInfo * info, GstCaps * caps)
{
gint i, j = 0;
int adaptors;
@@ -153,78 +160,75 @@ gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
GstGLImageConnection *conn;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
guint32 format;
-
+
/* we don't handle these image information */
- if (xinfo == NULL) return NULL;
-
+ if (xinfo == NULL)
+ return NULL;
+
conn = g_new0 (GstGLImageConnection, 1);
conn->conn.open_conn = gst_gl_nvimage_open_conn;
conn->conn.close_conn = gst_gl_nvimage_close_conn;
conn->conn.free_conn = gst_gl_nvimage_free_conn;
- gst_caps_get (caps,
- "width", &conn->w,
- "height", &conn->h,
- "format", &format,
- NULL);
+ gst_caps_get (caps,
+ "width", &conn->w, "height", &conn->h, "format", &format, NULL);
// maybe I should a bit more checking here, e.g. maximum size smaller than maximum texture extents
- if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' '))
- {
- GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: Format is invalid !\n");
- return NULL;
- }
- if (0) //conn->port == (XvPortID) -1)
+ if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) {
+ GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: Format is invalid !\n");
+ return NULL;
+ }
+ if (0) //conn->port == (XvPortID) -1)
{
/* this happens if the plugin can't handle the caps, so no warning */
g_free (conn);
return NULL;
}
-
- GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: caps %p are ok, creating image", caps);
+
+ GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: caps %p are ok, creating image",
+ caps);
return (GstImageConnection *) conn;
}
static GstImageData *
-gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
+gst_gl_nvimage_get_image (GstImageInfo * info, GstImageConnection * conn)
{
GstNvImage *image;
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
- GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+ GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
int slot = 0;
-
+
/* checks */
- if (xinfo == NULL) return NULL;
- if (nvconn == NULL) return NULL;
+ if (xinfo == NULL)
+ return NULL;
+ if (nvconn == NULL)
+ return NULL;
// I should also check the current GLX context !
// Ah, Don't have to, I am guarantueed to always be in the same thread
- image = g_new0(GstNvImage, 1);
-
- for (slot = 0; slot < AGP_BUFSLOTS; slot++)
- {
- if (!nvconn->m_bufslots[slot]) break;
- }
-
- image->data.size = nvconn->w * nvconn->h * 3/2;
-
- if (slot < AGP_BUFSLOTS) // found an AGP buffer slot
- {
- image->data.data = nvconn->m_memory + slot * YUVTEX_SIZE;
- image->slot = slot; // store for freeing
- nvconn->m_bufslots[slot] = 1; // it is now taken
- }
- else
- {
- g_warning("Allocating from main memory !");
- image->data.data = g_malloc(image->data.size);
- image->slot = AGP_BUFSLOTS; // no AGP slot
- }
- image->conn = nvconn;
+ image = g_new0 (GstNvImage, 1);
- if (image->data.data == NULL)
+ for (slot = 0; slot < AGP_BUFSLOTS; slot++) {
+ if (!nvconn->m_bufslots[slot])
+ break;
+ }
+
+ image->data.size = nvconn->w * nvconn->h * 3 / 2;
+
+ if (slot < AGP_BUFSLOTS) // found an AGP buffer slot
{
+ image->data.data = nvconn->m_memory + slot * YUVTEX_SIZE;
+ image->slot = slot; // store for freeing
+ nvconn->m_bufslots[slot] = 1; // it is now taken
+ } else {
+ g_warning ("Allocating from main memory !");
+ image->data.data = g_malloc (image->data.size);
+ image->slot = AGP_BUFSLOTS; // no AGP slot
+ }
+ image->conn = nvconn;
+
+ if (image->data.data == NULL) {
g_warning ("GL_NvImage: data allocation failed!");
g_free (image);
return NULL;
@@ -233,166 +237,169 @@ gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
return (GstImageData *) image;
}
-static void
-gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
+static void
+gst_gl_nvimage_put_image (GstImageInfo * info, GstImageData * image)
{
GstNvImage *im = (GstNvImage *) image;
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
-
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+
/* checks omitted for speed (and lazyness), do we need them? */
g_assert (xinfo != NULL);
-
+
/* Upload the texture here */
- g_warning("PUTTING IMAGE - BROOOKEN");
+ g_warning ("PUTTING IMAGE - BROOOKEN");
// both upload the video, and redraw the screen
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glEnable(GL_TEXTURE_2D);
+ glEnable (GL_TEXTURE_2D);
- glPushMatrix();
+ glPushMatrix ();
//glTranslatef(0,1,0);
- glRotatef(xinfo->rotX-250,1,0,0);
- glRotatef(xinfo->rotY,0,1,0);
+ glRotatef (xinfo->rotX - 250, 1, 0, 0);
+ glRotatef (xinfo->rotY, 0, 1, 0);
int zoom = xinfo->zoom;
- glScaled(zoom,zoom,zoom);
+
+ glScaled (zoom, zoom, zoom);
//Draws the surface rectangle
- glBindTexture(GL_TEXTURE_2D, im->conn->ytex_id);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGBA,
- GL_UNSIGNED_BYTE, im->data.data);
- float xmax = (float)im->conn->w/TEX_XSIZE;
- float ymax = (float)im->conn->h/TEX_YSIZE;
+ glBindTexture (GL_TEXTURE_2D, im->conn->ytex_id);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGBA,
+ GL_UNSIGNED_BYTE, im->data.data);
+ float xmax = (float) im->conn->w / TEX_XSIZE;
+ float ymax = (float) im->conn->h / TEX_YSIZE;
+
+ glColor4f (1, 1, 1, 1);
+ glBegin (GL_QUADS);
- glColor4f(1,1,1,1);
- glBegin(GL_QUADS);
+ glNormal3f (0, -1, 0);
- glNormal3f(0, -1, 0);
-
- glTexCoord2f(xmax, 0);
- glVertex3f(4,0,-4);
+ glTexCoord2f (xmax, 0);
+ glVertex3f (4, 0, -4);
- glTexCoord2f(0, 0);
- glVertex3f(-4,0,-4);
+ glTexCoord2f (0, 0);
+ glVertex3f (-4, 0, -4);
- glTexCoord2f(0, ymax);
- glVertex3f(-4,0,4);
+ glTexCoord2f (0, ymax);
+ glVertex3f (-4, 0, 4);
- glTexCoord2f(xmax, ymax);
- glVertex3f(4,0,4);
+ glTexCoord2f (xmax, ymax);
+ glVertex3f (4, 0, 4);
- glEnd();
+ glEnd ();
- glPopMatrix();
+ glPopMatrix ();
- glXSwapBuffers(xinfo->dpy, xinfo->win);
+ glXSwapBuffers (xinfo->dpy, xinfo->win);
}
-static void
-gst_gl_nvimage_free_image (GstImageData *image)
+static void
+gst_gl_nvimage_free_image (GstImageData * image)
{
GstNvImage *im = (GstNvImage *) image;
+
g_return_if_fail (im != NULL);
- GstGLImageConnection *nvconn = im->conn;
+ GstGLImageConnection *nvconn = im->conn;
- if (im->slot < AGP_BUFSLOTS)
- {
- nvconn->m_bufslots[im->slot] = 0;
- }
- else
- g_free(im->data.data);
+ if (im->slot < AGP_BUFSLOTS) {
+ nvconn->m_bufslots[im->slot] = 0;
+ } else
+ g_free (im->data.data);
g_free (im);
}
static void
-gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
+gst_gl_nvimage_open_conn (GstImageConnection * conn, GstImageInfo * info)
{
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
- unsigned char data_sep[2][2] = {{0, 255}, {0, 255}};
+ unsigned char data_sep[2][2] = { {0, 255}, {0, 255} };
int slot;
- g_warning("Opening NVidia Connection");
- xconn->m_memory = (unsigned char*)glXAllocateMemoryNV(AGP_BUFSLOTS*YUVTEX_SIZE, 0, 1.0, 1.0);
-
- if (!xconn->m_memory)
- {
- printf("Unable to acquire graphics card mem... will acquire in normal memory.\n");
- for (slot = 0; slot < AGP_BUFSLOTS; slot++)
- xconn->m_bufslots[slot] = 1;
- }
- else
- {
- // maybe this fast writable memory, awfully slow to read from, though
- glPixelDataRangeNV(GL_WRITE_PIXEL_DATA_RANGE_NV, AGP_BUFSLOTS*YUVTEX_SIZE, xconn->m_memory);
- glEnableClientState(GL_WRITE_PIXEL_DATA_RANGE_NV);
-
- for (slot = 0; slot < AGP_BUFSLOTS; slot++)
- xconn->m_bufslots[slot] = 0;
- }
-
- glGenTextures(1, &xconn->ytex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->ytex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE, TEX_YSIZE, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
-
- glActiveTextureARB(GL_TEXTURE1_ARB);
- glGenTextures(1, &xconn->uvtex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->uvtex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE/2, TEX_YSIZE/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
-
- glActiveTextureARB(GL_TEXTURE2_ARB);
- glGenTextures(1, &xconn->septex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->septex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, 2, 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data_sep);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
-
- glFlushPixelDataRangeNV(GL_WRITE_PIXEL_DATA_RANGE_NV);
+ g_warning ("Opening NVidia Connection");
+ xconn->m_memory =
+ (unsigned char *) glXAllocateMemoryNV (AGP_BUFSLOTS * YUVTEX_SIZE, 0, 1.0,
+ 1.0);
+
+ if (!xconn->m_memory) {
+ printf
+ ("Unable to acquire graphics card mem... will acquire in normal memory.\n");
+ for (slot = 0; slot < AGP_BUFSLOTS; slot++)
+ xconn->m_bufslots[slot] = 1;
+ } else {
+ // maybe this fast writable memory, awfully slow to read from, though
+ glPixelDataRangeNV (GL_WRITE_PIXEL_DATA_RANGE_NV,
+ AGP_BUFSLOTS * YUVTEX_SIZE, xconn->m_memory);
+ glEnableClientState (GL_WRITE_PIXEL_DATA_RANGE_NV);
+
+ for (slot = 0; slot < AGP_BUFSLOTS; slot++)
+ xconn->m_bufslots[slot] = 0;
+ }
+
+ glGenTextures (1, &xconn->ytex_id);
+ glBindTexture (GL_TEXTURE_2D, xconn->ytex_id);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE, TEX_YSIZE, 0,
+ GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
+
+ glActiveTextureARB (GL_TEXTURE1_ARB);
+ glGenTextures (1, &xconn->uvtex_id);
+ glBindTexture (GL_TEXTURE_2D, xconn->uvtex_id);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE / 2,
+ TEX_YSIZE / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
+
+ glActiveTextureARB (GL_TEXTURE2_ARB);
+ glGenTextures (1, &xconn->septex_id);
+ glBindTexture (GL_TEXTURE_2D, xconn->septex_id);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8, 2, 2, 0, GL_LUMINANCE,
+ GL_UNSIGNED_BYTE, data_sep);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
+
+ glFlushPixelDataRangeNV (GL_WRITE_PIXEL_DATA_RANGE_NV);
//glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE0_ARB);
- glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE1_ARB);
- glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE2_ARB);
- glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE0_ARB);
+ glActiveTextureARB (GL_TEXTURE0_ARB);
+ glEnable (GL_TEXTURE_2D);
+ glActiveTextureARB (GL_TEXTURE1_ARB);
+ glEnable (GL_TEXTURE_2D);
+ glActiveTextureARB (GL_TEXTURE2_ARB);
+ glEnable (GL_TEXTURE_2D);
+ glActiveTextureARB (GL_TEXTURE0_ARB);
}
static void
-gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
+gst_gl_nvimage_close_conn (GstImageConnection * conn, GstImageInfo * info)
{
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
// anything needed in here ? Oh, maybe drawing de-init, or something
- glDeleteTextures(1, &xconn->ytex_id);
- glDeleteTextures(1, &xconn->uvtex_id);
- glDeleteTextures(1, &xconn->septex_id);
+ glDeleteTextures (1, &xconn->ytex_id);
+ glDeleteTextures (1, &xconn->uvtex_id);
+ glDeleteTextures (1, &xconn->septex_id);
}
-static void
-gst_gl_nvimage_free_conn (GstImageConnection *conn)
+static void
+gst_gl_nvimage_free_conn (GstImageConnection * conn)
{
- GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
+ GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
g_free (nvconn);
}
-
diff --git a/sys/glsink/gstgl_rgbimage.c b/sys/glsink/gstgl_rgbimage.c
index ab856bbc..8c61e390 100644
--- a/sys/glsink/gstgl_rgbimage.c
+++ b/sys/glsink/gstgl_rgbimage.c
@@ -22,20 +22,21 @@
#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glu.h>
-#include <math.h>
+#include <math.h>
#include "gstglsink.h"
typedef struct _GstGLImageConnection GstGLImageConnection;
// this contains everything to draw an image, including all necessary graphics card data.
-struct _GstGLImageConnection {
+struct _GstGLImageConnection
+{
GstImageConnection conn;
- Display *dpy; // the Xlib drawing context
- GLXContext ctx; // The GLX drawing context
+ Display *dpy; // the Xlib drawing context
+ GLXContext ctx; // The GLX drawing context
gint w, h;
gint bpp;
-
+
int rgbatex_id;
unsigned char *m_memory;
};
@@ -51,49 +52,56 @@ struct _GstGLImage
GstGLImageConnection *conn;
};
-static GstGLImageInfo * gst_gl_rgbimage_info (GstImageInfo *info);
-static GstGLImageConnection * gst_gl_rgbimage_connection (GstImageConnection *conn);
-
-static GstCaps * gst_gl_rgbimage_get_caps (GstImageInfo *info);
-static GstImageConnection * gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps);
-static GstImageData * gst_gl_rgbimage_get_image (GstImageInfo *info, GstImageConnection *conn);
-static void gst_gl_rgbimage_put_image (GstImageInfo *info, GstImageData *image);
-static void gst_gl_rgbimage_free_image (GstImageData *image);
-static void gst_gl_rgbimage_open_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_rgbimage_close_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_rgbimage_free_conn (GstImageConnection *conn);
-
-GstImagePlugin* get_gl_rgbimage_plugin(void)
+static GstGLImageInfo *gst_gl_rgbimage_info (GstImageInfo * info);
+static GstGLImageConnection *gst_gl_rgbimage_connection (GstImageConnection *
+ conn);
+
+static GstCaps *gst_gl_rgbimage_get_caps (GstImageInfo * info);
+static GstImageConnection *gst_gl_rgbimage_set_caps (GstImageInfo * info,
+ GstCaps * caps);
+static GstImageData *gst_gl_rgbimage_get_image (GstImageInfo * info,
+ GstImageConnection * conn);
+static void gst_gl_rgbimage_put_image (GstImageInfo * info,
+ GstImageData * image);
+static void gst_gl_rgbimage_free_image (GstImageData * image);
+static void gst_gl_rgbimage_open_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_rgbimage_close_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_rgbimage_free_conn (GstImageConnection * conn);
+
+GstImagePlugin *
+get_gl_rgbimage_plugin (void)
{
static GstImagePlugin plugin = { gst_gl_rgbimage_get_caps,
- gst_gl_rgbimage_set_caps,
- gst_gl_rgbimage_get_image,
- gst_gl_rgbimage_put_image,
- gst_gl_rgbimage_free_image};
+ gst_gl_rgbimage_set_caps,
+ gst_gl_rgbimage_get_image,
+ gst_gl_rgbimage_put_image,
+ gst_gl_rgbimage_free_image
+ };
return &plugin;
}
static GstGLImageInfo *
-gst_gl_rgbimage_info (GstImageInfo *info)
+gst_gl_rgbimage_info (GstImageInfo * info)
{
- if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b'))
- {
+ if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b')) {
return NULL;
}
return (GstGLImageInfo *) info;
}
static GstGLImageConnection *
-gst_gl_rgbimage_connection (GstImageConnection *conn)
+gst_gl_rgbimage_connection (GstImageConnection * conn)
{
if (conn == NULL || conn->free_conn != gst_gl_rgbimage_free_conn)
- return NULL;
+ return NULL;
return (GstGLImageConnection *) conn;
}
GstCaps *
-gst_gl_rgbimage_get_caps (GstImageInfo *info)
+gst_gl_rgbimage_get_caps (GstImageInfo * info)
{
GstCaps *caps = NULL;
Visual *visual;
@@ -101,13 +109,15 @@ gst_gl_rgbimage_get_caps (GstImageInfo *info)
XWindowAttributes attrib;
XImage *ximage;
GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
-
- g_warning("rgbimage get caps called, context %p, endianness %d !\n", glXGetCurrentContext(), G_BIG_ENDIAN);
+
+ g_warning ("rgbimage get caps called, context %p, endianness %d !\n",
+ glXGetCurrentContext (), G_BIG_ENDIAN);
/* we don't handle this image information */
- if (xinfo == NULL) return NULL;
+ if (xinfo == NULL)
+ return NULL;
+
+ XGetWindowAttributes (xinfo->dpy, xinfo->win, &attrib);
- XGetWindowAttributes(xinfo->dpy, xinfo->win, &attrib);
-
visual = attrib.visual;
if (attrib.depth <= 8)
xpad = 8;
@@ -115,42 +125,37 @@ gst_gl_rgbimage_get_caps (GstImageInfo *info)
xpad = 16;
else
xpad = 32;
-
+
// create a temporary image
- ximage = XCreateImage (xinfo->dpy, visual, attrib.depth, ZPixmap, 0, NULL,
- 100, 100, xpad, (attrib.depth + 7) / 8 * 100);
+ ximage = XCreateImage (xinfo->dpy, visual, attrib.depth, ZPixmap, 0, NULL,
+ 100, 100, xpad, (attrib.depth + 7) / 8 * 100);
if (ximage != NULL) {
- caps =
- GST_CAPS_NEW (
- "forcing Video RGB",
- "video/x-raw-rgb",
- "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")),
- "depth", GST_PROPS_INT(24),
- "bpp", GST_PROPS_INT(24),
- "red_mask", GST_PROPS_INT(0xff),
- "green_mask", GST_PROPS_INT(0xff00),
- "blue_mask", GST_PROPS_INT(0xff0000),
- "endianness", GST_PROPS_INT(G_BIG_ENDIAN), /*= 1234/4321 (INT) <- endianness */
-
- "width", GST_PROPS_INT_RANGE (0, TEX_XSIZE), /* can't have videos larger than TEX_SIZE */
- "height", GST_PROPS_INT_RANGE (0, TEX_YSIZE)
- );
+ caps =
+ GST_CAPS_NEW ("forcing Video RGB", "video/x-raw-rgb", "format",
+ GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")), "depth", GST_PROPS_INT (24),
+ "bpp", GST_PROPS_INT (24), "red_mask", GST_PROPS_INT (0xff),
+ "green_mask", GST_PROPS_INT (0xff00), "blue_mask",
+ GST_PROPS_INT (0xff0000), "endianness", GST_PROPS_INT (G_BIG_ENDIAN),
+ /*= 1234/4321 (INT) <- endianness */
+ "width", GST_PROPS_INT_RANGE (0, TEX_XSIZE), /* can't have videos larger than TEX_SIZE */
+ "height", GST_PROPS_INT_RANGE (0, TEX_YSIZE)
+ );
XDestroyImage (ximage);
}
-
+
printf ("GL_RGBImage: returning caps at %p", caps);
return caps;
}
-static GstImageConnection *
-gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps)
+static GstImageConnection *
+gst_gl_rgbimage_set_caps (GstImageInfo * info, GstCaps * caps)
{
- g_warning("in set_caps !\n");
+ g_warning ("in set_caps !\n");
GstGLImageConnection *new = NULL;
Visual *visual;
XWindowAttributes attrib;
- GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
+ GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
guint32 format;
gint depth;
gint endianness;
@@ -158,26 +163,25 @@ gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps)
gint width, height, bpp;
/* check if this is the right image info */
- if (xinfo == NULL) return NULL;
-
- XGetWindowAttributes(xinfo->dpy, xinfo->win, &attrib);
-
+ if (xinfo == NULL)
+ return NULL;
+
+ XGetWindowAttributes (xinfo->dpy, xinfo->win, &attrib);
+
visual = attrib.visual;
gst_caps_get (caps,
- "format", &format,
- "depth", &depth,
- "endianness", &endianness,
- "red_mask", &red_mask,
- "green_mask", &green_mask,
- "blue_mask", &blue_mask,
- "width", &width,
- "height", &height,
- "bpp", &bpp,
- NULL);
-
+ "format", &format,
+ "depth", &depth,
+ "endianness", &endianness,
+ "red_mask", &red_mask,
+ "green_mask", &green_mask,
+ "blue_mask", &blue_mask,
+ "width", &width, "height", &height, "bpp", &bpp, NULL);
+
/* check if the caps are ok */
- if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) return NULL;
+ if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' '))
+ return NULL;
/* if (gst_caps_get_int (caps, "bpp") != ???) return NULL; */
//if (depth != attrib.depth) return NULL;
//if (endianness != ((ImageByteOrder (xinfo->dpy) == LSBFirst) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN)) return NULL;
@@ -185,7 +189,7 @@ gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps)
//if (green_mask != visual->green_mask) return NULL;
//if (blue_mask != visual->blue_mask) return NULL;
GST_DEBUG ("GL_RGBImage: caps %p are ok, creating image", caps);
-
+
new = g_new (GstGLImageConnection, 1);
new->conn.open_conn = gst_gl_rgbimage_open_conn;
new->conn.close_conn = gst_gl_rgbimage_close_conn;
@@ -195,34 +199,35 @@ gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps)
new->w = width;
new->h = height;
new->bpp = bpp;
-
+
return (GstImageConnection *) new;
}
static GstImageData *
-gst_gl_rgbimage_get_image (GstImageInfo *info, GstImageConnection *conn)
+gst_gl_rgbimage_get_image (GstImageInfo * info, GstImageConnection * conn)
{
GstGLImage *image;
+
//XWindowAttributes attrib;
- GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
- GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
-
+ GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
+ GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
+
image = g_new (GstGLImage, 1);
/* checks */
- if (xinfo == NULL) return NULL;
- if (xconn == NULL) return NULL;
- if (xinfo->dpy != xconn->dpy)
- {
+ if (xinfo == NULL)
+ return NULL;
+ if (xconn == NULL)
+ return NULL;
+ if (xinfo->dpy != xconn->dpy) {
g_warning ("XImage: wrong x display specified in 'get_image'\n");
return NULL;
}
image->conn = xconn;
image->data.size = xconn->w * xconn->h * 4;
- image->data.data = g_malloc(image->data.size);
- if (image->data.data == NULL)
- {
+ image->data.data = g_malloc (image->data.size);
+ if (image->data.data == NULL) {
g_warning ("GL_RGBImage: data allocation failed!");
g_free (image);
return NULL;
@@ -233,160 +238,162 @@ gst_gl_rgbimage_get_image (GstImageInfo *info, GstImageConnection *conn)
static void
-gst_gl_rgbimage_put_image (GstImageInfo *info, GstImageData *image)
+gst_gl_rgbimage_put_image (GstImageInfo * info, GstImageData * image)
{
float xmax, ymax;
GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
GstGLImage *im = (GstGLImage *) image;
- int img_width = im->conn->w;
- int img_height = im->conn->h;
+ int img_width = im->conn->w;
+ int img_height = im->conn->h;
g_assert (xinfo != NULL);
// both upload the video, and redraw the screen
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.0, 0.0, -5.0);
+ glMatrixMode (GL_MODELVIEW);
+ glLoadIdentity ();
+ glTranslatef (0.0, 0.0, -5.0);
- glEnable(GL_TEXTURE_2D);
+ glEnable (GL_TEXTURE_2D);
- if (xinfo->info.demo)
- {
- glTranslatef(0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
- glRotatef(180.0*sin(xinfo->rotX),1,0,0);
- glRotatef(180.0*cos(xinfo->rotY),0,1,0);
+ if (xinfo->info.demo) {
+ glTranslatef (0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
+ glRotatef (180.0 * sin (xinfo->rotX), 1, 0, 0);
+ glRotatef (180.0 * cos (xinfo->rotY), 0, 1, 0);
- xinfo->rotX += 0.01;
- xinfo->rotY -= 0.015;
- float zoom = xinfo->zoom;
- glScalef(zoom,zoom,zoom);
+ xinfo->rotX += 0.01;
+ xinfo->rotY -= 0.015;
+ float zoom = xinfo->zoom;
- if (xinfo->zoom > 2.0)
- xinfo->zoomdir = -0.01;
+ glScalef (zoom, zoom, zoom);
- if (xinfo->zoom < 1.0)
- xinfo->zoomdir = 0.01;
+ if (xinfo->zoom > 2.0)
+ xinfo->zoomdir = -0.01;
- xinfo->zoom += xinfo->zoomdir;
- }
+ if (xinfo->zoom < 1.0)
+ xinfo->zoomdir = 0.01;
+ xinfo->zoom += xinfo->zoomdir;
+ }
//Draws the surface rectangle
- glBindTexture(GL_TEXTURE_2D, im->conn->rgbatex_id);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGB,
- GL_UNSIGNED_BYTE, im->data.data);
- xmax = (float)im->conn->w/TEX_XSIZE;
- ymax = (float)im->conn->h/TEX_YSIZE;
+ glBindTexture (GL_TEXTURE_2D, im->conn->rgbatex_id);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGB,
+ GL_UNSIGNED_BYTE, im->data.data);
+ xmax = (float) im->conn->w / TEX_XSIZE;
+ ymax = (float) im->conn->h / TEX_YSIZE;
- float aspect = img_width/(float)img_height;
+ float aspect = img_width / (float) img_height;
float hor = aspect;
- glColor4f(1,1,1,1);
- glBegin(GL_QUADS);
-
- glNormal3f(0, -1, 0);
-
- glTexCoord2f(xmax, 0);
- glVertex3f(hor,1,0);
-
- glTexCoord2f(0, 0);
- glVertex3f(-hor,1,0);
-
- glTexCoord2f(0, ymax);
- glVertex3f(-hor,-1,0);
-
- glTexCoord2f(xmax, ymax);
- glVertex3f(hor,-1,0);
- glEnd();
-
- if (xinfo->info.dumpvideo)
- {
- static int framenr = 0;
- char capfilename[255];
- static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
- int i;
-
- // hmmmm, is this reentrant ?!
- if (cap_image_data == NULL)
- cap_image_data = (guint8 *)malloc(img_width * img_height * 3);
-
- if (cap_image_data2 == NULL)
- cap_image_data2 = (guint8 *)malloc(img_width * img_height * 3);
-
- printf("Recording frame #%d\n", framenr);
- glReadPixels(0,0,img_width,img_height,GL_RGB,GL_UNSIGNED_BYTE,cap_image_data);
- // invert the pixels
- for (i = 0; i < img_height; i++)
- memcpy(cap_image_data2 + i * img_width * 3, cap_image_data + (img_height-1-i) * img_width * 3, img_width*3);
-
- sprintf(capfilename, "cap%04d.ppm", framenr);
- FILE *outfile = fopen(capfilename, "wb");
- if (outfile != NULL)
- {
- fprintf(outfile, "P6\n");
- fprintf(outfile,"# created by raw_zb\n");
- fprintf(outfile,"%d %d\n",img_width,img_height);
- fprintf(outfile,"255\n");
- fwrite(cap_image_data2, sizeof(char), img_width*img_height*3, outfile);
- fclose(outfile);
- }
- framenr++;
+ glColor4f (1, 1, 1, 1);
+ glBegin (GL_QUADS);
+
+ glNormal3f (0, -1, 0);
+
+ glTexCoord2f (xmax, 0);
+ glVertex3f (hor, 1, 0);
+
+ glTexCoord2f (0, 0);
+ glVertex3f (-hor, 1, 0);
+
+ glTexCoord2f (0, ymax);
+ glVertex3f (-hor, -1, 0);
+
+ glTexCoord2f (xmax, ymax);
+ glVertex3f (hor, -1, 0);
+ glEnd ();
+
+ if (xinfo->info.dumpvideo) {
+ static int framenr = 0;
+ char capfilename[255];
+ static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
+ int i;
+
+ // hmmmm, is this reentrant ?!
+ if (cap_image_data == NULL)
+ cap_image_data = (guint8 *) malloc (img_width * img_height * 3);
+
+ if (cap_image_data2 == NULL)
+ cap_image_data2 = (guint8 *) malloc (img_width * img_height * 3);
+
+ printf ("Recording frame #%d\n", framenr);
+ glReadPixels (0, 0, img_width, img_height, GL_RGB, GL_UNSIGNED_BYTE,
+ cap_image_data);
+ // invert the pixels
+ for (i = 0; i < img_height; i++)
+ memcpy (cap_image_data2 + i * img_width * 3,
+ cap_image_data + (img_height - 1 - i) * img_width * 3, img_width * 3);
+
+ sprintf (capfilename, "cap%04d.ppm", framenr);
+ FILE *outfile = fopen (capfilename, "wb");
+
+ if (outfile != NULL) {
+ fprintf (outfile, "P6\n");
+ fprintf (outfile, "# created by raw_zb\n");
+ fprintf (outfile, "%d %d\n", img_width, img_height);
+ fprintf (outfile, "255\n");
+ fwrite (cap_image_data2, sizeof (char), img_width * img_height * 3,
+ outfile);
+ fclose (outfile);
}
+ framenr++;
+ }
- glXSwapBuffers(xinfo->dpy, xinfo->win);
+ glXSwapBuffers (xinfo->dpy, xinfo->win);
}
void
-gst_gl_rgbimage_free_image (GstImageData *image)
+gst_gl_rgbimage_free_image (GstImageData * image)
{
GstGLImage *im = (GstGLImage *) image;
- g_warning ("gst_gl_rgbimage_free_image doesn't do anything yet -> freeing image\n");
+ g_warning
+ ("gst_gl_rgbimage_free_image doesn't do anything yet -> freeing image\n");
g_free (im->data.data);
g_free (im);
}
/* Creates an OpenGL texture to upload the picture over */
static void
-gst_gl_rgbimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
+gst_gl_rgbimage_open_conn (GstImageConnection * conn, GstImageInfo * info)
{
- g_warning("Opening RGB Connection; classic OpenGL 1.2 renderer.");
+ g_warning ("Opening RGB Connection; classic OpenGL 1.2 renderer.");
//GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
- glGenTextures(1, &xconn->rgbatex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->rgbatex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_XSIZE, TEX_YSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glGenTextures (1, &xconn->rgbatex_id);
+ glBindTexture (GL_TEXTURE_2D, xconn->rgbatex_id);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, TEX_XSIZE, TEX_YSIZE, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, NULL);
}
/* Deletes the creates OpenGL textures */
-static void
-gst_gl_rgbimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
+static void
+gst_gl_rgbimage_close_conn (GstImageConnection * conn, GstImageInfo * info)
{
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
+
//GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
- glDeleteTextures(1, &xconn->rgbatex_id);
- }
+ glDeleteTextures (1, &xconn->rgbatex_id);
+}
static void
-gst_gl_rgbimage_free_conn (GstImageConnection *conn)
+gst_gl_rgbimage_free_conn (GstImageConnection * conn)
{
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
-
+
g_assert (xconn != NULL);
-
+
g_free (xconn);
}
-
-
diff --git a/sys/glsink/gstglsink.c b/sys/glsink/gstglsink.c
index 21cac1f3..a545c2a8 100644
--- a/sys/glsink/gstglsink.c
+++ b/sys/glsink/gstglsink.c
@@ -52,37 +52,39 @@ static GstElementDetails gst_glsink_details = {
/* default template - initiated with class struct to allow gst-register to work
with X running */
GST_PAD_TEMPLATE_FACTORY (gst_glsink_sink_template_factory,
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_CAPS_NEW ( "glsink_rgbsink", "video/x-raw-rgb",
- "framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT),
- "width", GST_PROPS_INT_RANGE(0, G_MAXINT),
- "height", GST_PROPS_INT_RANGE(0, G_MAXINT)),
- GST_CAPS_NEW ( "glsink_yuvsink", "video/x-raw-yuv",
- "framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT),
- "width", GST_PROPS_INT_RANGE(0, G_MAXINT),
- "height", GST_PROPS_INT_RANGE(0, G_MAXINT))
-)
+ "sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_CAPS_NEW ("glsink_rgbsink", "video/x-raw-rgb",
+ "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
+ "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "height", GST_PROPS_INT_RANGE (0, G_MAXINT)),
+ GST_CAPS_NEW ("glsink_yuvsink", "video/x-raw-yuv",
+ "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
+ "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "height", GST_PROPS_INT_RANGE (0, G_MAXINT))
+ )
/* glsink signals and args */
-enum {
- LAST_SIGNAL
-};
-
-
-enum {
- ARG_0,
- ARG_WIDTH,
- ARG_HEIGHT,
- ARG_FRAMES_DISPLAYED,
- ARG_FRAME_TIME,
- ARG_HOOK,
- ARG_MUTE,
- ARG_REPAINT,
- ARG_DEMO,
- ARG_DUMP
-};
+ enum
+ {
+ LAST_SIGNAL
+ };
+
+
+ enum
+ {
+ ARG_0,
+ ARG_WIDTH,
+ ARG_HEIGHT,
+ ARG_FRAMES_DISPLAYED,
+ ARG_FRAME_TIME,
+ ARG_HOOK,
+ ARG_MUTE,
+ ARG_REPAINT,
+ ARG_DEMO,
+ ARG_DUMP
+ };
/* GLsink class */
#define GST_TYPE_GLSINK (gst_glsink_get_type())
@@ -91,96 +93,105 @@ enum {
#define GST_IS_GLSINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_GLSINK))
#define GST_IS_GLSINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GLSINK))
-typedef struct _GstGLSink GstGLSink;
-typedef struct _GstGLSinkClass GstGLSinkClass;
+ typedef struct _GstGLSink GstGLSink;
+ typedef struct _GstGLSinkClass GstGLSinkClass;
-struct _GstGLSink {
- GstElement element;
+ struct _GstGLSink
+ {
+ GstElement element;
- GstPad *sinkpad;
+ GstPad *sinkpad;
- gint frames_displayed;
- guint64 frame_time;
- gint width, height;
- gboolean muted;
- gint demo; // some kind of fun demo mode to let GL show its 3D capabilities
- gboolean dumpvideo; // dump the video down to .ppm:s
- GstBuffer *last_image; /* not thread safe ? */
-
- GstClock *clock;
+ gint frames_displayed;
+ guint64 frame_time;
+ gint width, height;
+ gboolean muted;
+ gint demo; // some kind of fun demo mode to let GL show its 3D capabilities
+ gboolean dumpvideo; // dump the video down to .ppm:s
+ GstBuffer *last_image; /* not thread safe ? */
- GMutex *cache_lock;
- GList *cache;
-
- /* plugins */
- GstImagePlugin* plugin;
- GstImageConnection *conn;
-
- /* allow anybody to hook in here */
- GstImageInfo *hook;
-};
+ GstClock *clock;
-struct _GstGLSinkClass {
- GstElementClass parent_class;
+ GMutex *cache_lock;
+ GList *cache;
- /* plugins */
- GList *plugins;
-};
+ /* plugins */
+ GstImagePlugin *plugin;
+ GstImageConnection *conn;
+
+ /* allow anybody to hook in here */
+ GstImageInfo *hook;
+ };
+ struct _GstGLSinkClass
+ {
+ GstElementClass parent_class;
+
+ /* plugins */
+ GList *plugins;
+ };
+
+
+ static GType gst_glsink_get_type (void);
+ static void gst_glsink_base_init (gpointer g_class);
+ static void gst_glsink_class_init (GstGLSinkClass * klass);
+ static void gst_glsink_init (GstGLSink * sink);
-static GType gst_glsink_get_type (void);
-static void gst_glsink_base_init (gpointer g_class);
-static void gst_glsink_class_init (GstGLSinkClass *klass);
-static void gst_glsink_init (GstGLSink *sink);
/* static void gst_glsink_dispose (GObject *object); */
-static void gst_glsink_chain (GstPad *pad, GstData *_data);
-static void gst_glsink_set_clock (GstElement *element, GstClock *clock);
-static GstElementStateReturn gst_glsink_change_state (GstElement *element);
-static GstPadLinkReturn gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps);
-static GstCaps * gst_glsink_getcaps (GstPad *pad, GstCaps *caps);
+ static void gst_glsink_chain (GstPad * pad, GstData * _data);
+ static void gst_glsink_set_clock (GstElement * element, GstClock * clock);
+ static GstElementStateReturn gst_glsink_change_state (GstElement *
+ element);
+ static GstPadLinkReturn gst_glsink_sinkconnect (GstPad * pad,
+ GstCaps * caps);
+ static GstCaps *gst_glsink_getcaps (GstPad * pad, GstCaps * caps);
-static void gst_glsink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_glsink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+ static void gst_glsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+ static void gst_glsink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_glsink_release_conn (GstGLSink *sink);
-static void gst_glsink_append_cache (GstGLSink *sink, GstImageData *image);
-static gboolean gst_glsink_set_caps (GstGLSink *sink, GstCaps *caps);
+ static void gst_glsink_release_conn (GstGLSink * sink);
+ static void gst_glsink_append_cache (GstGLSink * sink,
+ GstImageData * image);
+ static gboolean gst_glsink_set_caps (GstGLSink * sink, GstCaps * caps);
/* prototypes from plugins */
-extern GstImagePlugin* get_gl_rgbimage_plugin (void);
-extern GstImagePlugin* get_gl_nvimage_plugin (void);
+ extern GstImagePlugin *get_gl_rgbimage_plugin (void);
+ extern GstImagePlugin *get_gl_nvimage_plugin (void);
+
/* default output */
-extern void gst_glxwindow_new (GstGLSink *sink);
-extern void gst_glxwindow_hook_context (GstImageInfo *info);
-extern void gst_glxwindow_unhook_context (GstImageInfo *info);
+ extern void gst_glxwindow_new (GstGLSink * sink);
+ extern void gst_glxwindow_hook_context (GstImageInfo * info);
+ extern void gst_glxwindow_unhook_context (GstImageInfo * info);
-static GstPadTemplate *sink_template;
+ static GstPadTemplate *sink_template;
+
+ static GstElementClass *parent_class = NULL;
-static GstElementClass *parent_class = NULL;
/* static guint gst_glsink_signals[LAST_SIGNAL] = { 0 }; */
-static GType
-gst_glsink_get_type (void)
+ static GType gst_glsink_get_type (void)
{
static GType videosink_type = 0;
if (!videosink_type) {
static const GTypeInfo videosink_info = {
- sizeof(GstGLSinkClass),
+ sizeof (GstGLSinkClass),
gst_glsink_base_init,
NULL,
(GClassInitFunc) gst_glsink_class_init,
NULL,
NULL,
- sizeof(GstGLSink),
+ sizeof (GstGLSink),
0,
(GInstanceInitFunc) gst_glsink_init,
};
- videosink_type = g_type_register_static(GST_TYPE_ELEMENT, "GstGLSink", &videosink_info, 0);
+ videosink_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstGLSink", &videosink_info,
+ 0);
}
return videosink_type;
}
@@ -189,56 +200,52 @@ static void
gst_glsink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (element_class, &gst_glsink_details);
- gst_element_class_add_pad_template (
- element_class,
- GST_PAD_TEMPLATE_GET (gst_glsink_sink_template_factory));
+ gst_element_class_add_pad_template (element_class,
+ GST_PAD_TEMPLATE_GET (gst_glsink_sink_template_factory));
}
static void
-gst_glsink_class_init (GstGLSinkClass *klass)
+gst_glsink_class_init (GstGLSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass*) klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- g_object_class_install_property (gobject_class, ARG_WIDTH,
- g_param_spec_int ("width", "Width", "The video width",
- G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
- g_object_class_install_property (gobject_class, ARG_HEIGHT,
- g_param_spec_int ("height", "Height", "The video height",
- G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
- g_object_class_install_property (gobject_class, ARG_FRAMES_DISPLAYED,
- g_param_spec_int ("frames_displayed", "Frames Displayed", "The number of frames displayed so far",
- G_MININT,G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property (gobject_class, ARG_FRAME_TIME,
- g_param_spec_int ("frame_time", "Frame time", "The interval between frames",
- G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (gobject_class, ARG_WIDTH, g_param_spec_int ("width", "Width", "The video width", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
+ g_object_class_install_property (gobject_class, ARG_HEIGHT, g_param_spec_int ("height", "Height", "The video height", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
+ g_object_class_install_property (gobject_class, ARG_FRAMES_DISPLAYED, g_param_spec_int ("frames_displayed", "Frames Displayed", "The number of frames displayed so far", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (gobject_class, ARG_FRAME_TIME, g_param_spec_int ("frame_time", "Frame time", "The interval between frames", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
g_object_class_install_property (gobject_class, ARG_HOOK,
- g_param_spec_pointer ("hook", "Hook", "The object receiving the output", G_PARAM_WRITABLE));
+ g_param_spec_pointer ("hook", "Hook", "The object receiving the output",
+ G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class, ARG_MUTE,
- g_param_spec_boolean ("mute", "Mute", "mute the output ?", FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("mute", "Mute", "mute the output ?", FALSE,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_REPAINT,
- g_param_spec_boolean ("repaint", "Repaint", "repaint the current frame", FALSE, G_PARAM_WRITABLE));
+ g_param_spec_boolean ("repaint", "Repaint", "repaint the current frame",
+ FALSE, G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class, ARG_DEMO,
- g_param_spec_int ("demo", "Demo", "demo mode (shows 3D capabilities)",0, 1, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("demo", "Demo", "demo mode (shows 3D capabilities)", 0,
+ 1, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_DUMP,
- g_param_spec_boolean ("dump", "Dump", "stores sequence of frames in .ppm files", FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("dump", "Dump",
+ "stores sequence of frames in .ppm files", FALSE, G_PARAM_READWRITE));
gobject_class->set_property = gst_glsink_set_property;
gobject_class->get_property = gst_glsink_get_property;
/*gobject_class->dispose = gst_glsink_dispose; */
-
+
gstelement_class->change_state = gst_glsink_change_state;
gstelement_class->set_clock = gst_glsink_set_clock;
-
+
/* plugins */
klass->plugins = NULL;
klass->plugins = g_list_append (klass->plugins, get_gl_rgbimage_plugin ());
@@ -251,7 +258,7 @@ gst_glsink_class_init (GstGLSinkClass *klass)
buffer upload
*/
static void
-gst_glsink_init (GstGLSink *sink)
+gst_glsink_init (GstGLSink * sink)
{
sink->sinkpad = gst_pad_new_from_template (sink_template, "sink");
gst_element_add_pad (GST_ELEMENT (sink), sink->sinkpad);
@@ -264,53 +271,52 @@ gst_glsink_init (GstGLSink *sink)
sink->width = 0;
sink->height = 0;
sink->muted = FALSE;
- sink->clock = NULL;
- GST_FLAG_SET(sink, GST_ELEMENT_THREAD_SUGGESTED);
+ sink->clock = NULL;
+ GST_FLAG_SET (sink, GST_ELEMENT_THREAD_SUGGESTED);
GST_FLAG_SET (sink, GST_ELEMENT_EVENT_AWARE);
-
+
/* create bufferpool and image cache */
GST_DEBUG ("glsink: creating bufferpool");
- sink->cache_lock = g_mutex_new();
- sink->cache = NULL;
-
+ sink->cache_lock = g_mutex_new ();
+ sink->cache = NULL;
+
/* plugins */
sink->plugin = NULL;
sink->conn = NULL;
-
+
/* do initialization of default hook here */
- gst_glxwindow_new (sink);
+ gst_glxwindow_new (sink);
//printf("GLSink_init: Current context %p\n", glXGetCurrentContext());
- gst_glxwindow_unhook_context(sink->hook);
+ gst_glxwindow_unhook_context (sink->hook);
}
/** frees the temporary connection that tests the window system capabilities */
static void
-gst_glsink_release_conn (GstGLSink *sink)
+gst_glsink_release_conn (GstGLSink * sink)
{
- if (sink->conn == NULL) return;
-
+ if (sink->conn == NULL)
+ return;
+
/* free last image if any */
- if (sink->last_image != NULL)
- {
+ if (sink->last_image != NULL) {
gst_buffer_unref (sink->last_image);
sink->last_image = NULL;
}
/* free cache */
g_mutex_lock (sink->cache_lock);
- while (sink->cache)
- {
+ while (sink->cache) {
sink->plugin->free_image ((GstImageData *) sink->cache->data);
sink->cache = g_list_delete_link (sink->cache, sink->cache);
}
g_mutex_unlock (sink->cache_lock);
-
+
/* release connection */
sink->conn->free_conn (sink->conn);
sink->conn = NULL;
}
-static void
-gst_glsink_append_cache (GstGLSink *sink, GstImageData *image)
+static void
+gst_glsink_append_cache (GstGLSink * sink, GstImageData * image)
{
g_mutex_lock (sink->cache_lock);
sink->cache = g_list_prepend (sink->cache, image);
@@ -322,16 +328,16 @@ gst_glsink_append_cache (GstGLSink *sink, GstImageData *image)
Create a new buffer to hand up the chain.
This allows the plugins to make its own decoding buffers
*/
-static GstBuffer*
-gst_glsink_buffer_new (GstBufferPool *pool, gint64 location,
- guint size, gpointer user_data)
+static GstBuffer *
+gst_glsink_buffer_new (GstBufferPool * pool, gint64 location,
+ guint size, gpointer user_data)
{
GstGLSink *sink;
GstBuffer *buffer;
GstImageData *image;
-
+
sink = GST_GLSINK (user_data);
-
+
/* If cache is non-empty, get buffer from there */
if (sink->cache != NULL) {
g_mutex_lock (sink->cache_lock);
@@ -342,12 +348,12 @@ gst_glsink_buffer_new (GstBufferPool *pool, gint64 location,
/* otherwise, get one from the plugin */
image = sink->plugin->get_image (sink->hook, sink->conn);
}
-
+
buffer = gst_buffer_new ();
GST_BUFFER_DATA (buffer) = image->data;
GST_BUFFER_SIZE (buffer) = image->size;
GST_BUFFER_POOL_PRIVATE (buffer) = image;
-
+
return buffer;
}
@@ -355,11 +361,15 @@ gst_glsink_buffer_new (GstBufferPool *pool, gint64 location,
Free a buffer that the chain doesn't need anymore.
*/
static void
-gst_glsink_buffer_free (GstBufferPool *pool, GstBuffer *buffer, gpointer user_data)
+gst_glsink_buffer_free (GstBufferPool * pool, GstBuffer * buffer,
+ gpointer user_data)
{
- GstGLSink *sink = GST_GLSINK (gst_buffer_pool_get_user_data (GST_BUFFER_BUFFERPOOL (buffer)));
+ GstGLSink *sink =
+ GST_GLSINK (gst_buffer_pool_get_user_data (GST_BUFFER_BUFFERPOOL
+ (buffer)));
- gst_glsink_append_cache (sink, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
+ gst_glsink_append_cache (sink,
+ (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
/* set to NULL so the data is not freed */
GST_BUFFER_DATA (buffer) = NULL;
@@ -373,23 +383,23 @@ gst_glsink_buffer_free (GstBufferPool *pool, GstBuffer *buffer, gpointer user_da
Go through the plugin list, finding the plugin that first fits the given parameters
*/
static gboolean
-gst_glsink_set_caps (GstGLSink *sink, GstCaps *caps)
+gst_glsink_set_caps (GstGLSink * sink, GstCaps * caps)
{
- g_warning("in glsink set caps!\n");
- printf("Getting GLstring, context is %p\n", glXGetCurrentContext());
-
+ g_warning ("in glsink set caps!\n");
+ printf ("Getting GLstring, context is %p\n", glXGetCurrentContext ());
+
GList *list = ((GstGLSinkClass *) G_OBJECT_GET_CLASS (sink))->plugins;
GstImageConnection *conn = NULL;
- while (list)
- {
- printf("AGetting GLstring, context is %p\n", glXGetCurrentContext());
+
+ while (list) {
+ printf ("AGetting GLstring, context is %p\n", glXGetCurrentContext ());
GstImagePlugin *plugin = (GstImagePlugin *) list->data;
- if ((conn = plugin->set_caps (sink->hook, caps)) != NULL)
- {
+
+ if ((conn = plugin->set_caps (sink->hook, caps)) != NULL) {
//gst_glsink_release_conn (sink);
- printf("BGetting GLstring, context is %p\n", glXGetCurrentContext());
+ printf ("BGetting GLstring, context is %p\n", glXGetCurrentContext ());
sink->conn = conn;
- printf("CGetting GLstring, context is %p\n", glXGetCurrentContext());
+ printf ("CGetting GLstring, context is %p\n", glXGetCurrentContext ());
sink->plugin = plugin;
sink->conn->open_conn (sink->conn, sink->hook);
return TRUE;
@@ -403,9 +413,9 @@ gst_glsink_set_caps (GstGLSink *sink, GstCaps *caps)
Link the input video sink internally.
*/
static GstPadLinkReturn
-gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps)
+gst_glsink_sinkconnect (GstPad * pad, GstCaps * caps)
{
- g_warning("in glsink sinkconnect!\n");
+ g_warning ("in glsink sinkconnect!\n");
GstGLSink *sink;
guint32 fourcc, print_format, result;
@@ -414,25 +424,24 @@ gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps)
/* we are not going to act on variable caps */
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_LINK_DELAYED;
-
- gst_glxwindow_hook_context(sink->hook);
+
+ gst_glxwindow_hook_context (sink->hook);
/* try to set the caps on the output */
result = gst_glsink_set_caps (sink, caps);
- gst_glxwindow_unhook_context(sink->hook);
+ gst_glxwindow_unhook_context (sink->hook);
+
+ if (result == FALSE) {
+ return GST_PAD_LINK_REFUSED;
+ }
- if (result == FALSE)
- {
- return GST_PAD_LINK_REFUSED;
- }
-
/* remember width & height */
gst_caps_get_int (caps, "width", &sink->width);
gst_caps_get_int (caps, "height", &sink->height);
gst_caps_get_fourcc_int (caps, "format", &fourcc);
print_format = GULONG_FROM_LE (fourcc);
- GST_DEBUG ("glsink: setting %08x (%4.4s) %dx%d\n",
- fourcc, (gchar*)&print_format, sink->width, sink->height);
+ GST_DEBUG ("glsink: setting %08x (%4.4s) %dx%d\n",
+ fourcc, (gchar *) & print_format, sink->width, sink->height);
/* emit signal */
g_object_freeze_notify (G_OBJECT (sink));
@@ -443,34 +452,35 @@ gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps)
return GST_PAD_LINK_OK;
}
static GstCaps *
-gst_glsink_getcaps (GstPad *pad, GstCaps *caps)
+gst_glsink_getcaps (GstPad * pad, GstCaps * caps)
{
- g_warning("in glsink get caps!\n");
+ g_warning ("in glsink get caps!\n");
/* what is the "caps" parameter good for? */
GstGLSink *sink = GST_GLSINK (gst_pad_get_parent (pad));
GstCaps *ret = NULL;
GList *list = ((GstGLSinkClass *) G_OBJECT_GET_CLASS (sink))->plugins;
-
- gst_glxwindow_hook_context(sink->hook);
- while (list)
- {
- ret = gst_caps_append (ret, ((GstImagePlugin *) list->data)->get_caps (sink->hook));
+
+ gst_glxwindow_hook_context (sink->hook);
+ while (list) {
+ ret =
+ gst_caps_append (ret,
+ ((GstImagePlugin *) list->data)->get_caps (sink->hook));
list = g_list_next (list);
}
- gst_glxwindow_unhook_context(sink->hook);
+ gst_glxwindow_unhook_context (sink->hook);
return ret;
}
static void
-gst_glsink_set_clock (GstElement *element, GstClock *clock)
+gst_glsink_set_clock (GstElement * element, GstClock * clock)
{
GstGLSink *sink = GST_GLSINK (element);
-
+
sink->clock = clock;
}
static void
-gst_glsink_chain (GstPad *pad, GstData *_data)
+gst_glsink_chain (GstPad * pad, GstData * _data)
{
//g_warning("in glsink_chain!\n");
GstBuffer *buf = GST_BUFFER (_data);
@@ -489,30 +499,30 @@ gst_glsink_chain (GstPad *pad, GstData *_data)
switch (GST_EVENT_TYPE (event)) {
default:
- gst_pad_event_default (pad, event);
+ gst_pad_event_default (pad, event);
}
return;
}
- GST_DEBUG ("glsink: clock wait: %llu %u",
- GST_BUFFER_TIMESTAMP (buf), GST_BUFFER_SIZE (buf));
+ GST_DEBUG ("glsink: clock wait: %llu %u",
+ GST_BUFFER_TIMESTAMP (buf), GST_BUFFER_SIZE (buf));
#if 0
GstClockTime time = GST_BUFFER_TIMESTAMP (buf);
static int frame_drops = 0;
if (sink->clock && time != -1) {
- if (time < gst_clock_get_time(sink->clock))
- {
- g_warning("Frame drop (%d consecutive) !!", frame_drops);
- /* we are going to drop late buffers */
- gst_buffer_unref (buf);
- frame_drops++;
- return;
- }
- frame_drops = 0; // we made it - reset time
+ if (time < gst_clock_get_time (sink->clock)) {
+ g_warning ("Frame drop (%d consecutive) !!", frame_drops);
+ /* we are going to drop late buffers */
+ gst_buffer_unref (buf);
+ frame_drops++;
+ return;
+ }
+ frame_drops = 0; // we made it - reset time
GstClockReturn ret;
- GstClockID id = gst_clock_new_single_shot_id (sink->clock, GST_BUFFER_TIMESTAMP (buf));
+ GstClockID id =
+ gst_clock_new_single_shot_id (sink->clock, GST_BUFFER_TIMESTAMP (buf));
ret = gst_element_clock_wait (GST_ELEMENT (sink), id, NULL);
gst_clock_id_free (id);
@@ -529,71 +539,74 @@ gst_glsink_chain (GstPad *pad, GstData *_data)
sink->frames_displayed++;
g_object_notify (G_OBJECT (sink), "frames_displayed");
- if (!sink->muted)
- {
- if (glXGetCurrentContext() == NULL)
- {
- printf("Rehooking window !\n");
- gst_glxwindow_hook_context(sink->hook);
+ if (!sink->muted) {
+ if (glXGetCurrentContext () == NULL) {
+ printf ("Rehooking window !\n");
+ gst_glxwindow_hook_context (sink->hook);
#if 1
- GST_DEBUG("Initializing OpenGL parameters\n");
- /* initialize OpenGL drawing */
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_TEXTURE_2D);
- glClearDepth(1.0f);
- glClearColor(0, 0, 0, 0);
-
- glEnable(GL_AUTO_NORMAL); // let OpenGL generate the Normals
-
- glDisable(GL_BLEND);
- glDisable(GL_CULL_FACE);
- glPolygonMode(GL_FRONT, GL_FILL);
- glPolygonMode(GL_BACK, GL_FILL);
-
- glShadeModel(GL_SMOOTH);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
-
- GstGLImageInfo *window = (GstGLImageInfo *)sink->hook;
- int w=window->width, h = window->height;
-
- glViewport(0, 0, (GLint) w, (GLint) h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- GLfloat aspect = (GLfloat) w / (GLfloat) h;
- glFrustum(-aspect, aspect, -1.0, 1.0, 5.0, 500.0);
+ GST_DEBUG ("Initializing OpenGL parameters\n");
+ /* initialize OpenGL drawing */
+ glEnable (GL_DEPTH_TEST);
+ glEnable (GL_TEXTURE_2D);
+ glClearDepth (1.0f);
+ glClearColor (0, 0, 0, 0);
+
+ glEnable (GL_AUTO_NORMAL); // let OpenGL generate the Normals
+
+ glDisable (GL_BLEND);
+ glDisable (GL_CULL_FACE);
+ glPolygonMode (GL_FRONT, GL_FILL);
+ glPolygonMode (GL_BACK, GL_FILL);
+
+ glShadeModel (GL_SMOOTH);
+ glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+
+ GstGLImageInfo *window = (GstGLImageInfo *) sink->hook;
+ int w = window->width, h = window->height;
+
+ glViewport (0, 0, (GLint) w, (GLint) h);
+ glMatrixMode (GL_PROJECTION);
+ glLoadIdentity ();
+
+ GLfloat aspect = (GLfloat) w / (GLfloat) h;
+
+ glFrustum (-aspect, aspect, -1.0, 1.0, 5.0, 500.0);
#endif
- gst_glxwindow_unhook_context(sink->hook);
- gst_glxwindow_hook_context(sink->hook);
- glMatrixMode(GL_MODELVIEW);
-#if 0
- sink->hook->free_info(sink->hook);
- printf("Reallocating window brutally !\n");
- gst_glxwindow_new(sink);
+ gst_glxwindow_unhook_context (sink->hook);
+ gst_glxwindow_hook_context (sink->hook);
+ glMatrixMode (GL_MODELVIEW);
+#if 0
+ sink->hook->free_info (sink->hook);
+ printf ("Reallocating window brutally !\n");
+ gst_glxwindow_new (sink);
#endif
- }
-
+ }
+
/* free last_image, if any */
if (sink->last_image != NULL)
gst_buffer_unref (sink->last_image);
if (sink->bufferpool && GST_BUFFER_BUFFERPOOL (buf) == sink->bufferpool) {
-
+
// awful hack ! But I currently have no other solution without changing the API
sink->hook->demo = sink->demo;
sink->hook->dumpvideo = sink->dumpvideo;
- sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buf));
+ sink->plugin->put_image (sink->hook,
+ (GstImageData *) GST_BUFFER_POOL_PRIVATE (buf));
sink->last_image = buf;
} else {
- buffer = gst_buffer_new_from_pool (gst_glsink_get_bufferpool (sink->sinkpad),
- 0, GST_BUFFER_SIZE (buf));
- memcpy (GST_BUFFER_DATA (buffer), GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf) > GST_BUFFER_SIZE (buffer) ?
- GST_BUFFER_SIZE (buffer) : GST_BUFFER_SIZE (buf));
+ buffer =
+ gst_buffer_new_from_pool (gst_glsink_get_bufferpool (sink->sinkpad),
+ 0, GST_BUFFER_SIZE (buf));
+ memcpy (GST_BUFFER_DATA (buffer), GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (buf) >
+ GST_BUFFER_SIZE (buffer) ? GST_BUFFER_SIZE (buffer) :
+ GST_BUFFER_SIZE (buf));
- sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
+ sink->plugin->put_image (sink->hook,
+ (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
sink->last_image = buffer;
gst_buffer_unref (buf);
@@ -601,12 +614,13 @@ gst_glsink_chain (GstPad *pad, GstData *_data)
//gst_glxwindow_unhook_context(sink->hook);
}
-
+
}
static void
-gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_glsink_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
//g_warning("in set_property!\n");
GstGLSink *sink;
@@ -625,8 +639,7 @@ gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GP
sink->frame_time = g_value_get_int (value);
break;
case ARG_HOOK:
- if (sink->hook)
- {
+ if (sink->hook) {
sink->hook->free_info (sink->hook);
}
sink->hook = g_value_get_pointer (value);
@@ -645,7 +658,8 @@ gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GP
break;
case ARG_REPAINT:
if (sink->last_image != NULL) {
- sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (sink->last_image));
+ sink->plugin->put_image (sink->hook,
+ (GstImageData *) GST_BUFFER_POOL_PRIVATE (sink->last_image));
}
break;
default:
@@ -655,13 +669,14 @@ gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GP
}
static void
-gst_glsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_glsink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
//g_warning("in get_property!\n");
GstGLSink *sink;
/* it's not null if we got it, but it might not be ours */
- sink = GST_GLSINK(object);
+ sink = GST_GLSINK (object);
switch (prop_id) {
case ARG_WIDTH:
@@ -674,7 +689,7 @@ gst_glsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
g_value_set_int (value, sink->frames_displayed);
break;
case ARG_FRAME_TIME:
- g_value_set_int (value, sink->frame_time/1000000);
+ g_value_set_int (value, sink->frame_time / 1000000);
break;
case ARG_MUTE:
g_value_set_boolean (value, sink->muted);
@@ -685,7 +700,7 @@ gst_glsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
case ARG_DUMP:
g_value_set_boolean (value, sink->dumpvideo);
break;
- default:
+ default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
@@ -693,7 +708,7 @@ gst_glsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
static GstElementStateReturn
-gst_glsink_change_state (GstElement *element)
+gst_glsink_change_state (GstElement * element)
{
//g_warning("in change_state!\n");
GstGLSink *sink;
@@ -704,23 +719,23 @@ gst_glsink_change_state (GstElement *element)
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
- {
- //g_warning("Going GST_STATE_READY_TO_PAUSED: %p", sink->conn);
- }
+ {
+ //g_warning("Going GST_STATE_READY_TO_PAUSED: %p", sink->conn);
+ }
break;
case GST_STATE_PAUSED_TO_PLAYING:
- {
- //g_warning("Going GST_STATE_PAUSED_TO_PLAYING: %p", sink->conn);
- }
+ {
+ //g_warning("Going GST_STATE_PAUSED_TO_PLAYING: %p", sink->conn);
+ }
break;
case GST_STATE_PLAYING_TO_PAUSED:
break;
case GST_STATE_PAUSED_TO_READY:
if (sink->conn)
- sink->conn->close_conn (sink->conn, sink->hook);
+ sink->conn->close_conn (sink->conn, sink->hook);
if (sink->last_image) {
gst_buffer_unref (sink->last_image);
- sink->last_image = NULL;
+ sink->last_image = NULL;
}
break;
case GST_STATE_READY_TO_NULL:
@@ -734,18 +749,15 @@ gst_glsink_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;
/* this is needed later on in the _real_ init (during a gst-launch) */
- sink_template = gst_pad_template_new (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- NULL);
+ sink_template = gst_pad_template_new ("sink",
+ GST_PAD_SINK, GST_PAD_ALWAYS, NULL);
if (!gst_element_register (plugin, "glsink", GST_RANK_NONE, GST_TYPE_GLSINK))
return FALSE;
@@ -753,14 +765,8 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "glsink",
- "An OpenGL based video sink - uses OpenGL and GLX to draw video, utilizing different acceleration options",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "glsink",
+ "An OpenGL based video sink - uses OpenGL and GLX to draw video, utilizing different acceleration options",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
diff --git a/sys/glsink/gstglsink.h b/sys/glsink/gstglsink.h
index 8a34df9a..036ee78d 100644
--- a/sys/glsink/gstglsink.h
+++ b/sys/glsink/gstglsink.h
@@ -25,72 +25,81 @@
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define MAX_FLIP_BUFFERS 1
-typedef struct _GstImageInfo GstImageInfo;
-struct _GstImageInfo {
- gulong id;
- int demo;
- int dumpvideo;
- void (*free_info) (GstImageInfo *info);
-};
-
-
-typedef struct _GstImageData GstImageData;
-struct _GstImageData {
- gint size;
- gchar *data;
-};
-
-typedef struct _GstImageConnection GstImageConnection;
-struct _GstImageConnection {
- void (*open_conn) (GstImageConnection *conn, GstImageInfo *info);
- void (*close_conn) (GstImageConnection *conn, GstImageInfo *info);
- void (*free_conn) (GstImageConnection *conn);
-};
-
-typedef GstCaps * (*GstImagePluginGetCapsFunc) (GstImageInfo *info);
-typedef GstImageConnection * (*GstImagePluginSetCapsFunc) (GstImageInfo *info, GstCaps *caps);
-typedef GstImageData* (*GstImagePluginGetImageFunc) (GstImageInfo *info, GstImageConnection *conn);
-typedef void (*GstImagePluginPutImageFunc) (GstImageInfo *info, GstImageData *image);
-typedef void (*GstImagePluginFreeImageFunc) (GstImageData *image);
-
-typedef struct _GstImagePlugin GstImagePlugin;
-struct _GstImagePlugin {
- GstImagePluginGetCapsFunc get_caps;
- GstImagePluginSetCapsFunc set_caps;
- GstImagePluginGetImageFunc get_image;
- GstImagePluginPutImageFunc put_image;
- GstImagePluginFreeImageFunc free_image;
-};
-
-typedef struct _GstGLImageInfo GstGLImageInfo;
+ typedef struct _GstImageInfo GstImageInfo;
+ struct _GstImageInfo
+ {
+ gulong id;
+ int demo;
+ int dumpvideo;
+ void (*free_info) (GstImageInfo * info);
+ };
+
+
+ typedef struct _GstImageData GstImageData;
+ struct _GstImageData
+ {
+ gint size;
+ gchar *data;
+ };
+
+ typedef struct _GstImageConnection GstImageConnection;
+ struct _GstImageConnection
+ {
+ void (*open_conn) (GstImageConnection * conn, GstImageInfo * info);
+ void (*close_conn) (GstImageConnection * conn, GstImageInfo * info);
+ void (*free_conn) (GstImageConnection * conn);
+ };
+
+ typedef GstCaps *(*GstImagePluginGetCapsFunc) (GstImageInfo * info);
+ typedef GstImageConnection *(*GstImagePluginSetCapsFunc) (GstImageInfo * info,
+ GstCaps * caps);
+ typedef GstImageData *(*GstImagePluginGetImageFunc) (GstImageInfo * info,
+ GstImageConnection * conn);
+ typedef void (*GstImagePluginPutImageFunc) (GstImageInfo * info,
+ GstImageData * image);
+ typedef void (*GstImagePluginFreeImageFunc) (GstImageData * image);
+
+ typedef struct _GstImagePlugin GstImagePlugin;
+ struct _GstImagePlugin
+ {
+ GstImagePluginGetCapsFunc get_caps;
+ GstImagePluginSetCapsFunc set_caps;
+ GstImagePluginGetImageFunc get_image;
+ GstImagePluginPutImageFunc put_image;
+ GstImagePluginFreeImageFunc free_image;
+ };
+
+ typedef struct _GstGLImageInfo GstGLImageInfo;
/* stuff about our window grouped together */
-struct _GstGLImageInfo {
- GstImageInfo info;
- Display *dpy;
- int screen;
- Window win;
- GLXContext ctx;
- XSetWindowAttributes attr;
- Bool fs;
- //XF86VidModeModeInfo deskMode;
- int x, y;
- unsigned int width, height;
- unsigned int depth;
- /* window specific from here */
- GstElement *sink;
- gulong handler_id;
- float rotX,rotY,zoom, zoomdir;
-};
+ struct _GstGLImageInfo
+ {
+ GstImageInfo info;
+ Display *dpy;
+ int screen;
+ Window win;
+ GLXContext ctx;
+ XSetWindowAttributes attr;
+ Bool fs;
+ //XF86VidModeModeInfo deskMode;
+ int x, y;
+ unsigned int width, height;
+ unsigned int depth;
+ /* window specific from here */
+ GstElement *sink;
+ gulong handler_id;
+ float rotX, rotY, zoom, zoomdir;
+ };
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_VIDEOSINK_H__ */
+#endif /* __GST_VIDEOSINK_H__ */
diff --git a/sys/glsink/gstglxwindow.c b/sys/glsink/gstglxwindow.c
index 3d173b2b..8fdacb2f 100644
--- a/sys/glsink/gstglxwindow.c
+++ b/sys/glsink/gstglxwindow.c
@@ -17,128 +17,119 @@
#include <GL/gl.h>
#include <GL/glu.h>
#include "gstglsink.h"
-#include <string.h> /* strncmp */
+#include <string.h> /* strncmp */
/* attributes for a single buffered visual in RGBA format with at least
* 4 bits per color and a 16 bit depth buffer */
-static int attrListSgl[] =
-{
- GLX_RGBA, GLX_RED_SIZE, 4,
- GLX_GREEN_SIZE, 4,
- GLX_BLUE_SIZE, 4,
+static int attrListSgl[] = {
+ GLX_RGBA, GLX_RED_SIZE, 4,
+ GLX_GREEN_SIZE, 4,
+ GLX_BLUE_SIZE, 4,
GLX_DEPTH_SIZE, 16,
None
};
/* attributes for a double buffered visual in RGBA format with at least
* 4 bits per color and a 16 bit depth buffer */
-static int attrListDbl[] =
- {
- GLX_RGBA, GLX_DOUBLEBUFFER,
- GLX_RED_SIZE, 4,
- GLX_GREEN_SIZE, 4,
- GLX_BLUE_SIZE, 4,
- GLX_DEPTH_SIZE, 16,
- None
- };
+static int attrListDbl[] = {
+ GLX_RGBA, GLX_DOUBLEBUFFER,
+ GLX_RED_SIZE, 4,
+ GLX_GREEN_SIZE, 4,
+ GLX_BLUE_SIZE, 4,
+ GLX_DEPTH_SIZE, 16,
+ None
+};
-GLfloat LightAmbient[] = { 0.1, 0.1, 0.1, 1.0 }; /* reddish ambient light */
-GLfloat LightDiffuse[] = { 0.6, 0.6, 0.6, 1.0 }; /* bluish diffuse light. */
-GLfloat LightPosition[] = { 1.5, 1.5, 1.5, 0.0 }; /* position */
+GLfloat LightAmbient[] = { 0.1, 0.1, 0.1, 1.0 }; /* reddish ambient light */
+GLfloat LightDiffuse[] = { 0.6, 0.6, 0.6, 1.0 }; /* bluish diffuse light. */
+GLfloat LightPosition[] = { 1.5, 1.5, 1.5, 0.0 }; /* position */
void
-gst_glxwindow_unhook_context(GstImageInfo *info)
+gst_glxwindow_unhook_context (GstImageInfo * info)
{
GstGLImageInfo *window = (GstGLImageInfo *) info;
- if (window->ctx)
- {
- if (!glXMakeCurrent(window->dpy, None, NULL))
- {
- printf("Could not release drawing context.\n");
- }
- else
- printf("Released drawing context.\n");
- }
+ if (window->ctx) {
+ if (!glXMakeCurrent (window->dpy, None, NULL)) {
+ printf ("Could not release drawing context.\n");
+ } else
+ printf ("Released drawing context.\n");
+ }
}
void
-gst_glxwindow_hook_context(GstImageInfo *info)
+gst_glxwindow_hook_context (GstImageInfo * info)
{
GstGLImageInfo *window = (GstGLImageInfo *) info;
- if (window->ctx && window->win && window->ctx)
- {
- if (!glXMakeCurrent(window->dpy, window->win, window->ctx))
- {
- printf("Could not acquire GLX drawing context.\n");
- }
- else
- printf("Acquired drawing context.\n");
- }
+ if (window->ctx && window->win && window->ctx) {
+ if (!glXMakeCurrent (window->dpy, window->win, window->ctx)) {
+ printf ("Could not acquire GLX drawing context.\n");
+ } else
+ printf ("Acquired drawing context.\n");
+ }
}
static void
-gst_glxwindow_free (GstImageInfo *info)
+gst_glxwindow_free (GstImageInfo * info)
{
GstGLImageInfo *window = (GstGLImageInfo *) info;
-
+
g_signal_handler_disconnect (window->sink, window->handler_id);
- if (window->ctx)
- {
- if (!glXMakeCurrent(window->dpy, None, NULL))
- {
- printf("Could not release drawing context.\n");
- }
- glXDestroyContext(window->dpy, window->ctx);
- window->ctx = NULL;
- }
-#if 0
- /* switch back to original desktop resolution if we were in fs */
- if (GLWin.fs)
- {
- XF86VidModeSwitchToMode(GLWin.dpy, GLWin.screen, &GLWin.deskMode);
- XF86VidModeSetViewPort(GLWin.dpy, GLWin.screen, 0, 0);
+ if (window->ctx) {
+ if (!glXMakeCurrent (window->dpy, None, NULL)) {
+ printf ("Could not release drawing context.\n");
}
+ glXDestroyContext (window->dpy, window->ctx);
+ window->ctx = NULL;
+ }
+#if 0
+ /* switch back to original desktop resolution if we were in fs */
+ if (GLWin.fs) {
+ XF86VidModeSwitchToMode (GLWin.dpy, GLWin.screen, &GLWin.deskMode);
+ XF86VidModeSetViewPort (GLWin.dpy, GLWin.screen, 0, 0);
+ }
#endif
XCloseDisplay (window->dpy);
g_free (window);
}
static void
-gst_glxwindow_callback(GObject *object, GParamSpec *pspec, GstGLImageInfo *data)
+gst_glxwindow_callback (GObject * object, GParamSpec * pspec,
+ GstGLImageInfo * data)
{
- XWindowAttributes attr;
- XGetWindowAttributes(data->dpy, data->win, &attr);
+ XWindowAttributes attr;
- if (strncmp (pspec->name, "width", 5) == 0 || strncmp (pspec->name, "height", 6) == 0)
- {
+ XGetWindowAttributes (data->dpy, data->win, &attr);
+
+ if (strncmp (pspec->name, "width", 5) == 0
+ || strncmp (pspec->name, "height", 6) == 0) {
gint w = 0;
gint h = 0;
+
g_object_get (object, "width", &w, NULL);
g_object_get (object, "height", &h, NULL);
- if (w != attr.width || h != attr.height)
- {
+ if (w != attr.width || h != attr.height) {
attr.width = w;
attr.height = h;
XResizeWindow (data->dpy, data->win, attr.width, attr.height);
XMapRaised (data->dpy, data->win);
// resize OpenGL
- g_warning("resizing in OpenGL");
- glViewport(0, 0, (GLint) w, (GLint) h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
+ g_warning ("resizing in OpenGL");
+ glViewport (0, 0, (GLint) w, (GLint) h);
+ glMatrixMode (GL_PROJECTION);
+ glLoadIdentity ();
+
GLfloat aspect = (GLfloat) h / (GLfloat) w;
- glFrustum(-1.0, 1.0, -aspect, aspect, 5.0, 500.0);
+
+ glFrustum (-1.0, 1.0, -aspect, aspect, 5.0, 500.0);
}
}
- if (attr.width != data->width || attr.height != data->height)
- {
+ if (attr.width != data->width || attr.height != data->height) {
data->width = attr.width;
data->height = attr.height;
}
@@ -146,57 +137,54 @@ gst_glxwindow_callback(GObject *object, GParamSpec *pspec, GstGLImageInfo *data)
}
void
-gst_glxwindow_new (GstElement *sink)
+gst_glxwindow_new (GstElement * sink)
{
//XGCValues values;
GstGLImageInfo *new;
int glxMajorVersion, glxMinorVersion;
+
//XSetWindowAttributes attrib;
XVisualInfo *vi;
Atom wmDelete;
Window winDummy;
unsigned int borderDummy;
Colormap cmap;
- char* title = "GLSink (experimental)";
+ char *title = "GLSink (experimental)";
new = g_new0 (GstGLImageInfo, 1);
- if (sink == NULL)
- {
+ if (sink == NULL) {
sink = gst_element_factory_make ("glsink", "glsink");
g_assert (sink != NULL);
}
-
+
/* fill in the ImageInfo */
new->info.id = GST_MAKE_FOURCC ('X', 'l', 'i', 'b');
new->info.free_info = gst_glxwindow_free;
-
+
new->dpy = XOpenDisplay (NULL);
if (!new->dpy) {
g_warning ("open display failed!\n");
g_free (new);
return;
}
- new->screen = DefaultScreen(new->dpy);
+ new->screen = DefaultScreen (new->dpy);
/* get an appropriate visual */
- vi = glXChooseVisual(new->dpy, new->screen, attrListDbl);
- if (vi == NULL)
- {
- vi = glXChooseVisual(new->dpy, new->screen, attrListSgl);
- GST_DEBUG("Only Singlebuffered Visual!\n");
- }
- else
- {
- GST_DEBUG("Got Doublebuffered Visual!\n");
- }
- glXQueryVersion(new->dpy, &glxMajorVersion, &glxMinorVersion);
- GST_DEBUG("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
-
+ vi = glXChooseVisual (new->dpy, new->screen, attrListDbl);
+ if (vi == NULL) {
+ vi = glXChooseVisual (new->dpy, new->screen, attrListSgl);
+ GST_DEBUG ("Only Singlebuffered Visual!\n");
+ } else {
+ GST_DEBUG ("Got Doublebuffered Visual!\n");
+ }
+ glXQueryVersion (new->dpy, &glxMajorVersion, &glxMinorVersion);
+ GST_DEBUG ("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
+
/* create a GLX context */
- new->ctx = glXCreateContext(new->dpy, vi, 0, GL_TRUE);
+ new->ctx = glXCreateContext (new->dpy, vi, 0, GL_TRUE);
/* create a color map */
- cmap = XCreateColormap(new->dpy, RootWindow(new->dpy, vi->screen),
- vi->visual, AllocNone);
+ cmap = XCreateColormap (new->dpy, RootWindow (new->dpy, vi->screen),
+ vi->visual, AllocNone);
new->attr.colormap = cmap;
new->attr.border_pixel = 0;
@@ -206,72 +194,72 @@ gst_glxwindow_new (GstElement *sink)
new->width = 10;
new->height = 10;
- new->rotX = 0;
- new->rotY = 0;
+ new->rotX = 0;
+ new->rotY = 0;
new->zoom = 1;
new->zoomdir = 0.01;
{
- /* create a window in window mode*/
+ /* create a window in window mode */
new->attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
- StructureNotifyMask;
- new->win = XCreateWindow(new->dpy, RootWindow(new->dpy, vi->screen),
- new->x, new->y, new->width, new->height, 0, vi->depth, InputOutput, vi->visual,
- CWBorderPixel | CWColormap | CWEventMask, &new->attr);
- if (!new->win)
- {
- g_warning ("create window failed\n");
- g_free (new);
- return;
- }
+ StructureNotifyMask;
+ new->win = XCreateWindow (new->dpy, RootWindow (new->dpy, vi->screen),
+ new->x, new->y, new->width, new->height, 0, vi->depth, InputOutput,
+ vi->visual, CWBorderPixel | CWColormap | CWEventMask, &new->attr);
+ if (!new->win) {
+ g_warning ("create window failed\n");
+ g_free (new);
+ return;
+ }
/* only set window title and handle wm_delete_events if in windowed mode */
- wmDelete = XInternAtom(new->dpy, "WM_DELETE_WINDOW", True);
- XSetWMProtocols(new->dpy, new->win, &wmDelete, 1);
- XSetStandardProperties(new->dpy, new->win, title,
- title, None, NULL, 0, NULL);
- XMapRaised(new->dpy, new->win);
- }
+ wmDelete = XInternAtom (new->dpy, "WM_DELETE_WINDOW", True);
+ XSetWMProtocols (new->dpy, new->win, &wmDelete, 1);
+ XSetStandardProperties (new->dpy, new->win, title,
+ title, None, NULL, 0, NULL);
+ XMapRaised (new->dpy, new->win);
+ }
/* connect the glx-context to the window */
- glXMakeCurrent(new->dpy, new->win, new->ctx);
- XGetGeometry(new->dpy, new->win, &winDummy, &new->x, &new->y,
- &new->width, &new->height, &borderDummy, &new->depth);
- printf("Depth %d\n", new->depth);
- if (glXIsDirect(new->dpy, new->ctx))
- GST_DEBUG ("Congrats, you have Direct Rendering!\n");
+ glXMakeCurrent (new->dpy, new->win, new->ctx);
+ XGetGeometry (new->dpy, new->win, &winDummy, &new->x, &new->y,
+ &new->width, &new->height, &borderDummy, &new->depth);
+ printf ("Depth %d\n", new->depth);
+ if (glXIsDirect (new->dpy, new->ctx))
+ GST_DEBUG ("Congrats, you have Direct Rendering!\n");
else
GST_DEBUG ("Sorry, no Direct Rendering possible!\n");
- g_warning("Initializing OpenGL parameters\n");
+ g_warning ("Initializing OpenGL parameters\n");
/* initialize OpenGL drawing */
- glEnable(GL_DEPTH_TEST);
+ glEnable (GL_DEPTH_TEST);
//glShadeModel(GL_SMOOTH);
- glEnable(GL_TEXTURE_2D);
- glDisable(GL_CULL_FACE);
- glClearDepth(1.0f);
- glClearColor(0, 0, 0, 0);
+ glEnable (GL_TEXTURE_2D);
+ glDisable (GL_CULL_FACE);
+ glClearDepth (1.0f);
+ glClearColor (0, 0, 0, 0);
+
+ glLightfv (GL_LIGHT0, GL_AMBIENT, LightAmbient); /* add lighting. (ambient) */
+ glLightfv (GL_LIGHT0, GL_DIFFUSE, LightDiffuse); /* add lighting. (diffuse). */
+ glLightfv (GL_LIGHT0, GL_POSITION, LightPosition); /* set light position. */
- glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); /* add lighting. (ambient) */
- glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); /* add lighting. (diffuse). */
- glLightfv(GL_LIGHT0, GL_POSITION,LightPosition); /* set light position. */
-
- //glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is Set Up)
- //glEnable(GL_LIGHTING); // Enable Lighting
- glDisable(GL_COLOR_MATERIAL); // Enable Material Coloring
- glEnable(GL_AUTO_NORMAL); // let OpenGL generate the Normals
+ //glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is Set Up)
+ //glEnable(GL_LIGHTING); // Enable Lighting
+ glDisable (GL_COLOR_MATERIAL); // Enable Material Coloring
+ glEnable (GL_AUTO_NORMAL); // let OpenGL generate the Normals
- glDisable(GL_BLEND);
+ glDisable (GL_BLEND);
- glPolygonMode(GL_FRONT, GL_FILL);
- glPolygonMode(GL_BACK, GL_FILL);
+ glPolygonMode (GL_FRONT, GL_FILL);
+ glPolygonMode (GL_BACK, GL_FILL);
- glShadeModel(GL_SMOOTH);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
+ glShadeModel (GL_SMOOTH);
+ glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
XSelectInput (new->dpy, new->win, ExposureMask | StructureNotifyMask);
g_object_set (sink, "hook", new, NULL);
new->sink = sink;
- new->handler_id = g_signal_connect (sink, "notify", G_CALLBACK (gst_glxwindow_callback), new);
+ new->handler_id =
+ g_signal_connect (sink, "notify", G_CALLBACK (gst_glxwindow_callback),
+ new);
}
-
diff --git a/sys/glsink/regcomb_yuvrgb.c b/sys/glsink/regcomb_yuvrgb.c
index d06427f4..54727d1e 100644
--- a/sys/glsink/regcomb_yuvrgb.c
+++ b/sys/glsink/regcomb_yuvrgb.c
@@ -23,313 +23,378 @@ unsigned char *UPlane;
unsigned char *VPlane;
// YUV 4:2:2 example
-unsigned int Ywidth=512, Yheight=512;
-unsigned int UVwidth=256, UVheight=512;
+unsigned int Ywidth = 512, Yheight = 512;
+unsigned int UVwidth = 256, UVheight = 512;
int tex_xsize, tex_ysize;
-void GenerateRGBTables(unsigned char *Ytable, // Y-palette
- unsigned char *Utable, // U-palette
- unsigned char *Vtable, // V-palette
- float *bias, // bias (fourth vector to be added)
- float *Uscale, // scaling color for U
- float *Vscale) // scaling color for V
+void
+GenerateRGBTables (unsigned char *Ytable, // Y-palette
+ unsigned char *Utable, // U-palette
+ unsigned char *Vtable, // V-palette
+ float *bias, // bias (fourth vector to be added)
+ float *Uscale, // scaling color for U
+ float *Vscale) // scaling color for V
{
- int i;
- const float mat[9]= { // the modified YUV->RGB matrix
- +1.130469478f,-0.058755723f,+1.596026304f,
- +1.130469478f,-0.450515935f,-0.812967512f,
- +1.130469478f,+1.958477882f, 0.0f
- };
- #define COMPRESS(a)(0.5f*(a)+128.0f) // counter-piece to EXPAND_NORMAL
- #define fCOMPRESS(a) (0.5f*(a)+0.5f);
- #define XCLAMP(a) ((a)<0.0f ? 0.0f : ((a)>255.0f ? 255.0f : (a))) // should not be necessary, but what do you know.
- bias[0]=fCOMPRESS(-0.842580964f);
- bias[1]=fCOMPRESS(+0.563287723f);
- bias[2]=fCOMPRESS(-1.0f);
- bias[3]=0.0f;
- Uscale[0]=8.0f/255.0f;
- Uscale[1]=60.0f/255.0f;
- Uscale[2]=250.0f/255.0f;
- Uscale[3]=0.0f;
- Vscale[0]=204.0f/255.0f;
- Vscale[1]=105.0f/255.0f;
- Vscale[2]=0.5f;
- Vscale[3]=0.0f;
- for (i=0; i<256; i++) {
- // Y-table holds unsigned values
- Ytable[3*i ]=(unsigned char)XCLAMP(mat[0]*(float)i); // R
- Ytable[3*i+1]=(unsigned char)XCLAMP(mat[3]*(float)i); // G
- Ytable[3*i+2]=(unsigned char)XCLAMP(mat[6]*(float)i); // B
- // U-table holds signed values
- Utable[3*i ]=(unsigned char)XCLAMP(COMPRESS(255.0f/ 16.0f*mat[1]*(float)i)); // R
- Utable[3*i+1]=(unsigned char)XCLAMP(COMPRESS(255.0f/120.0f*mat[4]*(float)i)); // G
- Utable[3*i+2]=(unsigned char)XCLAMP(COMPRESS(255.0f/500.0f*mat[7]*(float)i)); // B
- // V-table holds signed values
- Vtable[3*i ]=(unsigned char)XCLAMP(COMPRESS(255.0f/408.0f*mat[2]*(float)i)); // R
- Vtable[3*i+1]=(unsigned char)XCLAMP(COMPRESS(255.0f/210.0f*mat[5]*(float)i)); // G
- Vtable[3*i+2]=(unsigned char)(128.0f-14.0f); // G constant
- }
- #undef fCOMPRESS
- #undef COMPRESS
- #undef XCLAMP
+ int i;
+ const float mat[9] = { // the modified YUV->RGB matrix
+ +1.130469478f, -0.058755723f, +1.596026304f,
+ +1.130469478f, -0.450515935f, -0.812967512f,
+ +1.130469478f, +1.958477882f, 0.0f
+ };
+#define COMPRESS(a)(0.5f*(a)+128.0f) // counter-piece to EXPAND_NORMAL
+#define fCOMPRESS(a) (0.5f*(a)+0.5f);
+#define XCLAMP(a) ((a)<0.0f ? 0.0f : ((a)>255.0f ? 255.0f : (a))) // should not be necessary, but what do you know.
+ bias[0] = fCOMPRESS (-0.842580964f);
+ bias[1] = fCOMPRESS (+0.563287723f);
+ bias[2] = fCOMPRESS (-1.0f);
+ bias[3] = 0.0f;
+ Uscale[0] = 8.0f / 255.0f;
+ Uscale[1] = 60.0f / 255.0f;
+ Uscale[2] = 250.0f / 255.0f;
+ Uscale[3] = 0.0f;
+ Vscale[0] = 204.0f / 255.0f;
+ Vscale[1] = 105.0f / 255.0f;
+ Vscale[2] = 0.5f;
+ Vscale[3] = 0.0f;
+ for (i = 0; i < 256; i++) {
+ // Y-table holds unsigned values
+ Ytable[3 * i] = (unsigned char) XCLAMP (mat[0] * (float) i); // R
+ Ytable[3 * i + 1] = (unsigned char) XCLAMP (mat[3] * (float) i); // G
+ Ytable[3 * i + 2] = (unsigned char) XCLAMP (mat[6] * (float) i); // B
+ // U-table holds signed values
+ Utable[3 * i] = (unsigned char) XCLAMP (COMPRESS (255.0f / 16.0f * mat[1] * (float) i)); // R
+ Utable[3 * i + 1] = (unsigned char) XCLAMP (COMPRESS (255.0f / 120.0f * mat[4] * (float) i)); // G
+ Utable[3 * i + 2] = (unsigned char) XCLAMP (COMPRESS (255.0f / 500.0f * mat[7] * (float) i)); // B
+ // V-table holds signed values
+ Vtable[3 * i] = (unsigned char) XCLAMP (COMPRESS (255.0f / 408.0f * mat[2] * (float) i)); // R
+ Vtable[3 * i + 1] = (unsigned char) XCLAMP (COMPRESS (255.0f / 210.0f * mat[5] * (float) i)); // G
+ Vtable[3 * i + 2] = (unsigned char) (128.0f - 14.0f); // G constant
+ }
+#undef fCOMPRESS
+#undef COMPRESS
+#undef XCLAMP
}
// Sets the constants. Call once prior to rendering.
-void SetConsts(float *bias, float *Uscale, float *Vscale) {
- glEnable(GL_REGISTER_COMBINERS_NV);
- glColor3fv(bias);
- //printf("%f %f %f\n",bias[0],bias[1],bias[2]);
- glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV,Uscale);
- glCombinerParameterfvNV(GL_CONSTANT_COLOR1_NV,Vscale);
+void
+SetConsts (float *bias, float *Uscale, float *Vscale)
+{
+ glEnable (GL_REGISTER_COMBINERS_NV);
+ glColor3fv (bias);
+ //printf("%f %f %f\n",bias[0],bias[1],bias[2]);
+ glCombinerParameterfvNV (GL_CONSTANT_COLOR0_NV, Uscale);
+ glCombinerParameterfvNV (GL_CONSTANT_COLOR1_NV, Vscale);
}
/*
* SOFTWARE PATH
- */
+ */
-inline void map_EXPAND_NORMAL(float *v) {
- v[0]=2.0f*v[0]-1.0f;
- v[1]=2.0f*v[1]-1.0f;
- v[2]=2.0f*v[2]-1.0f;
+inline void
+map_EXPAND_NORMAL (float *v)
+{
+ v[0] = 2.0f * v[0] - 1.0f;
+ v[1] = 2.0f * v[1] - 1.0f;
+ v[2] = 2.0f * v[2] - 1.0f;
}
-inline void map_UNSIGNED_INVERT(float *v) {
- v[0]=1.0f-v[0];
- v[1]=1.0f-v[1];
- v[2]=1.0f-v[2];
+inline void
+map_UNSIGNED_INVERT (float *v)
+{
+ v[0] = 1.0f - v[0];
+ v[1] = 1.0f - v[1];
+ v[2] = 1.0f - v[2];
}
-inline void map_UNSIGNED_IDENTITY(float *v) {
- v[0]=(v[0]<0.0f ? 0.0f : v[0]);
- v[1]=(v[1]<0.0f ? 0.0f : v[1]);
- v[2]=(v[2]<0.0f ? 0.0f : v[2]);
+inline void
+map_UNSIGNED_IDENTITY (float *v)
+{
+ v[0] = (v[0] < 0.0f ? 0.0f : v[0]);
+ v[1] = (v[1] < 0.0f ? 0.0f : v[1]);
+ v[2] = (v[2] < 0.0f ? 0.0f : v[2]);
}
-inline void map_SIGNED_IDENTITY(float *v) {
+inline void
+map_SIGNED_IDENTITY (float *v)
+{
}
-inline void omap_SCALE_BY_TWO(float *v) {
- v[0]*=2.0f;
- v[1]*=2.0f;
- v[2]*=2.0f;
+inline void
+omap_SCALE_BY_TWO (float *v)
+{
+ v[0] *= 2.0f;
+ v[1] *= 2.0f;
+ v[2] *= 2.0f;
}
-inline void omap_SCALE_BY_ONE_HALF(float *v) {
- v[0]*=0.5f;
- v[1]*=0.5f;
- v[2]*=0.5f;
+inline void
+omap_SCALE_BY_ONE_HALF (float *v)
+{
+ v[0] *= 0.5f;
+ v[1] *= 0.5f;
+ v[2] *= 0.5f;
}
-inline void omap_RANGE(float *v) {
- v[0]=(v[0]<-1.0f ? -1.0f : (v[0]>1.0f ? 1.0f : v[0]));
- v[1]=(v[1]<-1.0f ? -1.0f : (v[1]>1.0f ? 1.0f : v[1]));
- v[2]=(v[2]<-1.0f ? -1.0f : (v[2]>1.0f ? 1.0f : v[2]));
+inline void
+omap_RANGE (float *v)
+{
+ v[0] = (v[0] < -1.0f ? -1.0f : (v[0] > 1.0f ? 1.0f : v[0]));
+ v[1] = (v[1] < -1.0f ? -1.0f : (v[1] > 1.0f ? 1.0f : v[1]));
+ v[2] = (v[2] < -1.0f ? -1.0f : (v[2] > 1.0f ? 1.0f : v[2]));
}
-inline void omap_CLAMP_01(float *v) {
- v[0]=(v[0]<0.0f ? 0.0f : (v[0]>1.0f ? 1.0f : v[0]));
- v[1]=(v[1]<0.0f ? 0.0f : (v[1]>1.0f ? 1.0f : v[1]));
- v[2]=(v[2]<0.0f ? 0.0f : (v[2]>1.0f ? 1.0f : v[2]));
+inline void
+omap_CLAMP_01 (float *v)
+{
+ v[0] = (v[0] < 0.0f ? 0.0f : (v[0] > 1.0f ? 1.0f : v[0]));
+ v[1] = (v[1] < 0.0f ? 0.0f : (v[1] > 1.0f ? 1.0f : v[1]));
+ v[2] = (v[2] < 0.0f ? 0.0f : (v[2] > 1.0f ? 1.0f : v[2]));
}
-void PerformSWCombiner(unsigned char *Result,
- unsigned char *tex0,
- unsigned char *tex1,
- unsigned char *tex2,
- float *COLOR0,
- float *CONST0,
- float *CONST1
- )
+void
+PerformSWCombiner (unsigned char *Result,
+ unsigned char *tex0,
+ unsigned char *tex1,
+ unsigned char *tex2, float *COLOR0, float *CONST0, float *CONST1)
{
- float SPARE0[3];
- float SPARE1[3];
- float A[3],B[3],C[3],D[3];
- float TEX0[3],TEX1[3],TEX2[3];
- float ZERO[3]={0.0f,0.0f,0.0f};
-
- TEX0[0]=(float)tex0[0]/255.0f;
- TEX0[1]=(float)tex0[1]/255.0f;
- TEX0[2]=(float)tex0[2]/255.0f;
-
- TEX1[0]=(float)tex1[0]/255.0f;
- TEX1[1]=(float)tex1[1]/255.0f;
- TEX1[2]=(float)tex1[2]/255.0f;
-
- TEX2[0]=(float)tex2[0]/255.0f;
- TEX2[1]=(float)tex2[1]/255.0f;
- TEX2[2]=(float)tex2[2]/255.0f;
-
- // Combiner Stage 0:
- memcpy(A,TEX0,3*sizeof(float)); map_UNSIGNED_IDENTITY(A);
- memcpy(B,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(B);
- memcpy(C,COLOR0,3*sizeof(float)); map_EXPAND_NORMAL(C);
- memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(D);
- SPARE0[0]=A[0]*B[0]+C[0]*D[0];
- SPARE0[1]=A[1]*B[1]+C[1]*D[1];
- SPARE0[2]=A[2]*B[2]+C[2]*D[2];
- omap_SCALE_BY_ONE_HALF(SPARE0);
- omap_RANGE(SPARE0);
-
- // Combiner Stage 1:
- memcpy(A,TEX1,3*sizeof(float)); map_EXPAND_NORMAL(A);
- memcpy(B,CONST0,3*sizeof(float)); map_UNSIGNED_IDENTITY(B);
- memcpy(C,TEX2,3*sizeof(float)); map_EXPAND_NORMAL(C);
- memcpy(D,CONST1,3*sizeof(float)); map_UNSIGNED_IDENTITY(D);
- SPARE1[0]=A[0]*B[0]+C[0]*D[0];
- SPARE1[1]=A[1]*B[1]+C[1]*D[1];
- SPARE1[2]=A[2]*B[2]+C[2]*D[2];
- omap_RANGE(SPARE1);
-
- // Combiner Stage 2:
- memcpy(A,SPARE0,3*sizeof(float)); map_SIGNED_IDENTITY(A);
- memcpy(B,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(B);
- memcpy(C,SPARE1,3*sizeof(float)); map_SIGNED_IDENTITY(C);
- memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(D);
- SPARE0[0]=A[0]*B[0]+C[0]*D[0];
- SPARE0[1]=A[1]*B[1]+C[1]*D[1];
- SPARE0[2]=A[2]*B[2]+C[2]*D[2];
- omap_SCALE_BY_TWO(SPARE0);
- omap_RANGE(SPARE0);
-
- // Final Combiner Stage:
- memcpy(A,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(A);
- memcpy(B,SPARE0,3*sizeof(float)); map_UNSIGNED_IDENTITY(B);
- memcpy(C,ZERO,3*sizeof(float)); map_UNSIGNED_IDENTITY(C);
- memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_IDENTITY(D);
- SPARE0[0]=A[0]*B[0]+(1.0f-A[0])*C[0]+D[0];
- SPARE0[1]=A[1]*B[1]+(1.0f-A[1])*C[1]+D[1];
- SPARE0[2]=A[2]*B[2]+(1.0f-A[2])*C[2]+D[2];
- omap_CLAMP_01(SPARE0);
- Result[0]=(unsigned char)(SPARE0[0]*255.0f);
- Result[1]=(unsigned char)(SPARE0[1]*255.0f);
- Result[2]=(unsigned char)(SPARE0[2]*255.0f);
+ float SPARE0[3];
+ float SPARE1[3];
+ float A[3], B[3], C[3], D[3];
+ float TEX0[3], TEX1[3], TEX2[3];
+ float ZERO[3] = { 0.0f, 0.0f, 0.0f };
+
+ TEX0[0] = (float) tex0[0] / 255.0f;
+ TEX0[1] = (float) tex0[1] / 255.0f;
+ TEX0[2] = (float) tex0[2] / 255.0f;
+
+ TEX1[0] = (float) tex1[0] / 255.0f;
+ TEX1[1] = (float) tex1[1] / 255.0f;
+ TEX1[2] = (float) tex1[2] / 255.0f;
+
+ TEX2[0] = (float) tex2[0] / 255.0f;
+ TEX2[1] = (float) tex2[1] / 255.0f;
+ TEX2[2] = (float) tex2[2] / 255.0f;
+
+ // Combiner Stage 0:
+ memcpy (A, TEX0, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (A);
+ memcpy (B, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_INVERT (B);
+ memcpy (C, COLOR0, 3 * sizeof (float));
+ map_EXPAND_NORMAL (C);
+ memcpy (D, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_INVERT (D);
+ SPARE0[0] = A[0] * B[0] + C[0] * D[0];
+ SPARE0[1] = A[1] * B[1] + C[1] * D[1];
+ SPARE0[2] = A[2] * B[2] + C[2] * D[2];
+ omap_SCALE_BY_ONE_HALF (SPARE0);
+ omap_RANGE (SPARE0);
+
+ // Combiner Stage 1:
+ memcpy (A, TEX1, 3 * sizeof (float));
+ map_EXPAND_NORMAL (A);
+ memcpy (B, CONST0, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (B);
+ memcpy (C, TEX2, 3 * sizeof (float));
+ map_EXPAND_NORMAL (C);
+ memcpy (D, CONST1, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (D);
+ SPARE1[0] = A[0] * B[0] + C[0] * D[0];
+ SPARE1[1] = A[1] * B[1] + C[1] * D[1];
+ SPARE1[2] = A[2] * B[2] + C[2] * D[2];
+ omap_RANGE (SPARE1);
+
+ // Combiner Stage 2:
+ memcpy (A, SPARE0, 3 * sizeof (float));
+ map_SIGNED_IDENTITY (A);
+ memcpy (B, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_INVERT (B);
+ memcpy (C, SPARE1, 3 * sizeof (float));
+ map_SIGNED_IDENTITY (C);
+ memcpy (D, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_INVERT (D);
+ SPARE0[0] = A[0] * B[0] + C[0] * D[0];
+ SPARE0[1] = A[1] * B[1] + C[1] * D[1];
+ SPARE0[2] = A[2] * B[2] + C[2] * D[2];
+ omap_SCALE_BY_TWO (SPARE0);
+ omap_RANGE (SPARE0);
+
+ // Final Combiner Stage:
+ memcpy (A, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_INVERT (A);
+ memcpy (B, SPARE0, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (B);
+ memcpy (C, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (C);
+ memcpy (D, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (D);
+ SPARE0[0] = A[0] * B[0] + (1.0f - A[0]) * C[0] + D[0];
+ SPARE0[1] = A[1] * B[1] + (1.0f - A[1]) * C[1] + D[1];
+ SPARE0[2] = A[2] * B[2] + (1.0f - A[2]) * C[2] + D[2];
+ omap_CLAMP_01 (SPARE0);
+ Result[0] = (unsigned char) (SPARE0[0] * 255.0f);
+ Result[1] = (unsigned char) (SPARE0[1] * 255.0f);
+ Result[2] = (unsigned char) (SPARE0[2] * 255.0f);
}
// Sets up the register combiners. Call once prior to rendering
-void SetupCombiners(void)
+void
+SetupCombiners (void)
{
- glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV,3);
- // Combiner Stage 0: th. OK
- glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_A_NV,GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_B_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_C_NV,GL_PRIMARY_COLOR_NV,GL_EXPAND_NORMAL_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
- glCombinerOutputNV(GL_COMBINER0_NV,GL_RGB,GL_DISCARD_NV,GL_DISCARD_NV,GL_SPARE0_NV,GL_SCALE_BY_ONE_HALF_NV,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
- // Combiner Stage 1: th. OK
- glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_A_NV,GL_TEXTURE1_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_B_NV,GL_CONSTANT_COLOR0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_C_NV,GL_TEXTURE2_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_D_NV,GL_CONSTANT_COLOR1_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glCombinerOutputNV(GL_COMBINER1_NV,GL_RGB,GL_DISCARD_NV,GL_DISCARD_NV,GL_SPARE1_NV,GL_NONE,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
- // Combiner Stage 2: th. OK
- glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_A_NV,GL_SPARE0_NV, GL_SIGNED_IDENTITY_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_B_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_C_NV,GL_SPARE1_NV, GL_SIGNED_IDENTITY_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
- glCombinerOutputNV(GL_COMBINER2_NV,GL_RGB,GL_DISCARD_NV,GL_DISCARD_NV,GL_SPARE0_NV,GL_SCALE_BY_TWO_NV,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
- // Final Sage: th. OK
- glFinalCombinerInputNV(GL_VARIABLE_A_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
- glFinalCombinerInputNV(GL_VARIABLE_B_NV,GL_SPARE0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glFinalCombinerInputNV(GL_VARIABLE_C_NV,GL_ZERO, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glFinalCombinerInputNV(GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glFinalCombinerInputNV(GL_VARIABLE_G_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
+ glCombinerParameteriNV (GL_NUM_GENERAL_COMBINERS_NV, 3);
+ // Combiner Stage 0: th. OK
+ glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB,
+ GL_UNSIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO,
+ GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV,
+ GL_PRIMARY_COLOR_NV, GL_EXPAND_NORMAL_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO,
+ GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerOutputNV (GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV,
+ GL_SPARE0_NV, GL_SCALE_BY_ONE_HALF_NV, GL_NONE, GL_FALSE, GL_FALSE,
+ GL_FALSE);
+ // Combiner Stage 1: th. OK
+ glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE1_ARB,
+ GL_EXPAND_NORMAL_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV,
+ GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE2_ARB,
+ GL_EXPAND_NORMAL_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_D_NV,
+ GL_CONSTANT_COLOR1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerOutputNV (GL_COMBINER1_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV,
+ GL_SPARE1_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
+ // Combiner Stage 2: th. OK
+ glCombinerInputNV (GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE0_NV,
+ GL_SIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO,
+ GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_C_NV, GL_SPARE1_NV,
+ GL_SIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO,
+ GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerOutputNV (GL_COMBINER2_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV,
+ GL_SPARE0_NV, GL_SCALE_BY_TWO_NV, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
+ // Final Sage: th. OK
+ glFinalCombinerInputNV (GL_VARIABLE_A_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV,
+ GL_RGB);
+ glFinalCombinerInputNV (GL_VARIABLE_B_NV, GL_SPARE0_NV,
+ GL_UNSIGNED_IDENTITY_NV, GL_RGB);
+ glFinalCombinerInputNV (GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV,
+ GL_RGB);
+ glFinalCombinerInputNV (GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV,
+ GL_RGB);
+ glFinalCombinerInputNV (GL_VARIABLE_G_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV,
+ GL_ALPHA);
}
-unsigned int PowerOfTwo(unsigned int i) {
- unsigned int bitsum=0;
- unsigned int shifts=0;
- unsigned int j=(unsigned int)i;
- // Check wether i is a power of two - may contain at most one set bit
- do {
- bitsum+=j&1;
- j=j>>1;
- ++shifts;
- } while (j>0);
- if (bitsum==1) return i;
- else return (1<<shifts);
+unsigned int
+PowerOfTwo (unsigned int i)
+{
+ unsigned int bitsum = 0;
+ unsigned int shifts = 0;
+ unsigned int j = (unsigned int) i;
+
+ // Check wether i is a power of two - may contain at most one set bit
+ do {
+ bitsum += j & 1;
+ j = j >> 1;
+ ++shifts;
+ } while (j > 0);
+ if (bitsum == 1)
+ return i;
+ else
+ return (1 << shifts);
}
// Initializes textures. Call once prior to rendering
-void InitYUVPlanes(GLuint *Yhandle, GLuint *Uhandle, GLuint *Vhandle,
- unsigned int Ywidth, unsigned int Yheight,
- unsigned int UVwidth, unsigned int UVheight,
- GLenum filter, // filter should be either GL_NEAREST or GL_LINEAR. Test this!
- unsigned char* Ypal, unsigned char *Upal, unsigned char *Vpal)
+void
+InitYUVPlanes (GLuint * Yhandle, GLuint * Uhandle, GLuint * Vhandle, unsigned int Ywidth, unsigned int Yheight, unsigned int UVwidth, unsigned int UVheight, GLenum filter, // filter should be either GL_NEAREST or GL_LINEAR. Test this!
+ unsigned char *Ypal, unsigned char *Upal, unsigned char *Vpal)
{
- glGenTextures(1,Yhandle);
- glGenTextures(1,Uhandle);
- glGenTextures(1,Vhandle);
- glBindTexture(GL_TEXTURE_2D,(*Yhandle));
+ glGenTextures (1, Yhandle);
+ glGenTextures (1, Uhandle);
+ glGenTextures (1, Vhandle);
+ glBindTexture (GL_TEXTURE_2D, (*Yhandle));
#ifdef _WIN32
- glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Ypal);
+ glColorTableEXT (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Ypal);
#else // Hopefully Linux
- glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Ypal);
+ glColorTable (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Ypal);
#endif
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
- tex_xsize = PowerOfTwo(Ywidth);
- tex_ysize = PowerOfTwo(Yheight);
- glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,PowerOfTwo(Ywidth),PowerOfTwo(Yheight),0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,NULL);
-
- glBindTexture(GL_TEXTURE_2D,(*Uhandle));
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ tex_xsize = PowerOfTwo (Ywidth);
+ tex_ysize = PowerOfTwo (Yheight);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, PowerOfTwo (Ywidth),
+ PowerOfTwo (Yheight), 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, NULL);
+
+ glBindTexture (GL_TEXTURE_2D, (*Uhandle));
#ifdef _WIN32
- glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Upal);
+ glColorTableEXT (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Upal);
#else // Hopefully Linux
- glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Upal);
+ glColorTable (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Upal);
#endif
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
- glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,PowerOfTwo(UVwidth),PowerOfTwo(UVheight),0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,NULL);
-
- glBindTexture(GL_TEXTURE_2D,(*Vhandle));
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, PowerOfTwo (UVwidth),
+ PowerOfTwo (UVheight), 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, NULL);
+
+ glBindTexture (GL_TEXTURE_2D, (*Vhandle));
#ifdef _WIN32
- glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Vpal);
+ glColorTableEXT (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Vpal);
#else // Hopefully Linux
- glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Vpal);
+ glColorTable (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Vpal);
#endif
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
- glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,PowerOfTwo(UVwidth),PowerOfTwo(UVheight),0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,NULL);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, PowerOfTwo (UVwidth),
+ PowerOfTwo (UVheight), 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, NULL);
}
-void LoadYUVPlanes(GLuint Yhandle, GLuint Uhandle, GLuint Vhandle,
- unsigned int Ywidth, unsigned int Yheight,
- unsigned int UVwidth, unsigned int UVheight,
- unsigned char *Ydata,
- unsigned char *Udata,
- unsigned char *Vdata)
+void
+LoadYUVPlanes (GLuint Yhandle, GLuint Uhandle, GLuint Vhandle,
+ unsigned int Ywidth, unsigned int Yheight,
+ unsigned int UVwidth, unsigned int UVheight,
+ unsigned char *Ydata, unsigned char *Udata, unsigned char *Vdata)
{
- glActiveTextureARB(GL_TEXTURE0_ARB);
- glBindTexture(GL_TEXTURE_2D,Yhandle);
- glTexSubImage2D(GL_TEXTURE_2D,0,0,0,Ywidth,Yheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Ydata);
- glEnable(GL_TEXTURE_2D);
-
- glActiveTextureARB(GL_TEXTURE1_ARB);
- glBindTexture(GL_TEXTURE_2D,Uhandle);
- glTexSubImage2D(GL_TEXTURE_2D,0,0,0,UVwidth,UVheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Udata);
- glEnable(GL_TEXTURE_2D);
-
- glActiveTextureARB(GL_TEXTURE2_ARB);
- glBindTexture(GL_TEXTURE_2D,Vhandle);
- glTexSubImage2D(GL_TEXTURE_2D,0,0,0,UVwidth,UVheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Vdata);
- glEnable(GL_TEXTURE_2D);
+ glActiveTextureARB (GL_TEXTURE0_ARB);
+ glBindTexture (GL_TEXTURE_2D, Yhandle);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, Ywidth, Yheight, GL_COLOR_INDEX,
+ GL_UNSIGNED_BYTE, Ydata);
+ glEnable (GL_TEXTURE_2D);
+
+ glActiveTextureARB (GL_TEXTURE1_ARB);
+ glBindTexture (GL_TEXTURE_2D, Uhandle);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, UVwidth, UVheight, GL_COLOR_INDEX,
+ GL_UNSIGNED_BYTE, Udata);
+ glEnable (GL_TEXTURE_2D);
+
+ glActiveTextureARB (GL_TEXTURE2_ARB);
+ glBindTexture (GL_TEXTURE_2D, Vhandle);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, UVwidth, UVheight, GL_COLOR_INDEX,
+ GL_UNSIGNED_BYTE, Vdata);
+ glEnable (GL_TEXTURE_2D);
}
-void Initialize_Backend(unsigned int Ywidth, unsigned int Yheight, unsigned int UVwidth, unsigned int UVheight, GLenum filter)
+void
+Initialize_Backend (unsigned int Ywidth, unsigned int Yheight,
+ unsigned int UVwidth, unsigned int UVheight, GLenum filter)
{
- printf("Reinitializing register combiner backend with res %d x %d!\n", Ywidth, Yheight);
+ printf ("Reinitializing register combiner backend with res %d x %d!\n",
+ Ywidth, Yheight);
//if (!GL_ARB_multitexture_Init()) exit(0);
//if (!GL_EXT_paletted_texture_Init()) exit(0);
//if (!GL_NV_register_combiners_Init()) exit(0);
@@ -339,16 +404,20 @@ void Initialize_Backend(unsigned int Ywidth, unsigned int Yheight, unsigned int
float bias[4];
float Uscale[4];
float Vscale[4];
- GenerateRGBTables(Ypal,Upal,Vpal,bias,Uscale,Vscale);
- InitYUVPlanes(&Yhandle,&Uhandle,&Vhandle,Ywidth,Yheight,UVwidth,UVheight,filter,Ypal,Upal,Vpal);
- SetupCombiners();
- SetConsts(bias,Uscale,Vscale);
+
+ GenerateRGBTables (Ypal, Upal, Vpal, bias, Uscale, Vscale);
+ InitYUVPlanes (&Yhandle, &Uhandle, &Vhandle, Ywidth, Yheight, UVwidth,
+ UVheight, filter, Ypal, Upal, Vpal);
+ SetupCombiners ();
+ SetConsts (bias, Uscale, Vscale);
}
-void initialize(GLenum filter) {
- glShadeModel(GL_SMOOTH);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
- glClearColor(0.0f,0.0f,0.2f,1.0f);
- Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,filter);
+void
+initialize (GLenum filter)
+{
+ glShadeModel (GL_SMOOTH);
+ glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+ glClearColor (0.0f, 0.0f, 0.2f, 1.0f);
+ Initialize_Backend (Ywidth, Yheight, UVwidth, UVheight, filter);
}
diff --git a/sys/qcam/dark.c b/sys/qcam/dark.c
index 70acf979..e15a53c9 100644
--- a/sys/qcam/dark.c
+++ b/sys/qcam/dark.c
@@ -50,8 +50,8 @@ OTHER DEALINGS IN THE SOFTWARE.
#define FNAME "qcam.darkfile"
static unsigned char master_darkmask1[MAX_HEIGHT][MAX_WIDTH];
-static unsigned char master_darkmask2[MAX_HEIGHT/2+1][MAX_WIDTH/2+1];
-static unsigned char master_darkmask4[MAX_HEIGHT/4+1][MAX_WIDTH/4+1];
+static unsigned char master_darkmask2[MAX_HEIGHT / 2 + 1][MAX_WIDTH / 2 + 1];
+static unsigned char master_darkmask4[MAX_HEIGHT / 4 + 1][MAX_WIDTH / 4 + 1];
/*
int
@@ -133,7 +133,7 @@ read_darkmask()
*/
int
-fixdark(const struct qcam *q, scanbuf *scan)
+fixdark (const struct qcam *q, scanbuf * scan)
{
static int init = 0;
static int smallest_dm = 255;
@@ -150,14 +150,15 @@ fixdark(const struct qcam *q, scanbuf *scan)
int scale = q->transfer_scale;
if (!init) {
- if (!read_darkmask()) return 0;
+ if (!read_darkmask ())
+ return 0;
for (y = 0; y < MAX_HEIGHT; y++)
for (x = 0; x < MAX_HEIGHT; x++)
- if (master_darkmask1[y][x] < smallest_dm) {
+ if (master_darkmask1[y][x] < smallest_dm) {
smallest_dm = master_darkmask1[y][x];
#ifdef DEBUG
- fprintf(stderr, "Smallest mask is %d at (%d, %d)\n",
- smallest_dm, x, y);
+ fprintf (stderr, "Smallest mask is %d at (%d, %d)\n",
+ smallest_dm, x, y);
#endif
}
init = 1;
@@ -165,7 +166,8 @@ fixdark(const struct qcam *q, scanbuf *scan)
if (brightness < smallest_dm) {
#ifdef DEBUG
- fprintf(stderr, "Brightness %d (dark current starts at %d), no fixup needed\n",
+ fprintf (stderr,
+ "Brightness %d (dark current starts at %d), no fixup needed\n",
brightness, smallest_dm);
#endif
return 1;
@@ -186,53 +188,53 @@ fixdark(const struct qcam *q, scanbuf *scan)
darkmask[y][x] = master_darkmask4[y][x];
} else {
#ifdef DEBUG
- fprintf(stderr, "Bad transfer_scale in darkmask assignment!\n");
+ fprintf (stderr, "Bad transfer_scale in darkmask assignment!\n");
#endif
return 0;
}
do {
again = 0;
- ccd_y = (q->top-1)/scale;
+ ccd_y = (q->top - 1) / scale;
for (y = 0; y < height; y++, ccd_y++) {
- ccd_x = q->left-1;
+ ccd_x = q->left - 1;
ccd_x /= 2;
ccd_x *= 2;
ccd_x /= scale;
for (x = 0; x < width; x++, ccd_x++) {
- val = scan[y*width + x];
- if (brightness < darkmask[ccd_y][ccd_x]) { /* good pixel */
+ val = scan[y * width + x];
+ if (brightness < darkmask[ccd_y][ccd_x]) { /* good pixel */
new_image[y][x] = val;
- } else { /* bad pixel */
+ } else { /* bad pixel */
/* look at nearby pixels, average the good values */
pixelcount = 0;
pixeltotal = 0;
- if (x > 0) { /* left */
- if (brightness < darkmask[ccd_y][ccd_x-1]) {
+ if (x > 0) { /* left */
+ if (brightness < darkmask[ccd_y][ccd_x - 1]) {
pixelcount++;
- pixeltotal += scan[y*width + x - 1];
+ pixeltotal += scan[y * width + x - 1];
}
}
- if (x < width-1) { /* right */
- if (brightness < darkmask[ccd_y][ccd_x+1]) {
+ if (x < width - 1) { /* right */
+ if (brightness < darkmask[ccd_y][ccd_x + 1]) {
pixelcount++;
- pixeltotal += scan[y*width + x + 1];
+ pixeltotal += scan[y * width + x + 1];
}
}
- if (y > 0) { /* above */
- if (brightness < darkmask[ccd_y-1][ccd_x]) {
+ if (y > 0) { /* above */
+ if (brightness < darkmask[ccd_y - 1][ccd_x]) {
pixelcount++;
- pixeltotal += scan[(y-1)*width + x];
+ pixeltotal += scan[(y - 1) * width + x];
}
}
- if (y < height-1) { /* below */
- if (brightness < darkmask[ccd_y+1][ccd_x]) {
+ if (y < height - 1) { /* below */
+ if (brightness < darkmask[ccd_y + 1][ccd_x]) {
pixelcount++;
- pixeltotal += scan[(y+1)*width + x];
+ pixeltotal += scan[(y + 1) * width + x];
}
}
-
- if (pixelcount == 0) { /* no valid neighbors! */
+
+ if (pixelcount == 0) { /* no valid neighbors! */
again = 1;
} else {
new_image[y][x] = pixeltotal / pixelcount;
@@ -245,13 +247,12 @@ fixdark(const struct qcam *q, scanbuf *scan)
for (y = 0; y < height; y++)
for (x = 0; x < width; x++)
- scan[y*width + x] = new_image[y][x];
+ scan[y * width + x] = new_image[y][x];
} while (loopcount++ < MAX_LOOPS && again);
#ifdef DEBUG
- fprintf(stderr, "Darkmask fix took %d loop%s\n",
- loopcount, (loopcount == 1)?"":"s");
+ fprintf (stderr, "Darkmask fix took %d loop%s\n",
+ loopcount, (loopcount == 1) ? "" : "s");
#endif
return 1;
}
-
diff --git a/sys/qcam/exposure.c b/sys/qcam/exposure.c
index b393bdb7..b63e364f 100644
--- a/sys/qcam/exposure.c
+++ b/sys/qcam/exposure.c
@@ -49,8 +49,8 @@ SOFTWARE.
* prototyped in qcamip.h
*/
-static int qcip_pixel_average(struct qcam *q, scanbuf *scan);
-static int qcip_luminance_std(struct qcam *q, scanbuf *scan, int avg);
+static int qcip_pixel_average (struct qcam *q, scanbuf * scan);
+static int qcip_luminance_std (struct qcam *q, scanbuf * scan, int avg);
/* Private data used by the auto exposure routine */
@@ -63,7 +63,7 @@ static int ae_mode = AE_ALL_AVG;
/* Calculate average pixel value for entire image */
static int
-qcip_pixel_average(struct qcam *q, scanbuf *scan)
+qcip_pixel_average (struct qcam *q, scanbuf * scan)
{
int count = 0;
int sum = 0;
@@ -83,7 +83,7 @@ qcip_pixel_average(struct qcam *q, scanbuf *scan)
/* Calculate average pixel value for center of image */
static int
-qcip_pixel_average_center(struct qcam *q, scanbuf *scan)
+qcip_pixel_average_center (struct qcam *q, scanbuf * scan)
{
int count = 0;
int sum = 0;
@@ -95,12 +95,12 @@ qcip_pixel_average_center(struct qcam *q, scanbuf *scan)
width = q->width / q->transfer_scale;
height = q->height / q->transfer_scale;
- maxcol = width * 2 / 3;
+ maxcol = width * 2 / 3;
maxrow = height * 2 / 3;
- for (i = width/3; i < maxcol; i++) {
- for (j = height/3; j < maxrow; j++) {
- sum += scan[j*width+i];
+ for (i = width / 3; i < maxcol; i++) {
+ for (j = height / 3; j < maxrow; j++) {
+ sum += scan[j * width + i];
count++;
}
}
@@ -108,7 +108,7 @@ qcip_pixel_average_center(struct qcam *q, scanbuf *scan)
}
int
-qcip_set_luminance_target(struct qcam *q, int val)
+qcip_set_luminance_target (struct qcam *q, int val)
{
const int max_pixel_val = q->bpp == 6 ? 63 : 15;
@@ -121,7 +121,7 @@ qcip_set_luminance_target(struct qcam *q, int val)
}
int
-qcip_set_luminance_tolerance(struct qcam *q, int val)
+qcip_set_luminance_tolerance (struct qcam *q, int val)
{
const int max_pixel_val = q->bpp == 6 ? 63 : 15;
@@ -139,21 +139,21 @@ qcip_set_luminance_tolerance(struct qcam *q, int val)
}
int
-qcip_set_luminance_std_target(struct qcam *q, int val)
+qcip_set_luminance_std_target (struct qcam *q, int val)
{
luminance_std_target = val;
return QCIP_XPSR_OK;
}
int
-qcip_set_luminance_std_tolerance(struct qcam *q, int val)
+qcip_set_luminance_std_tolerance (struct qcam *q, int val)
{
luminance_std_tolerance = val;
return QCIP_XPSR_OK;
}
int
-qcip_set_autoexposure_mode(int val)
+qcip_set_autoexposure_mode (int val)
{
ae_mode = val;
return 0;
@@ -162,7 +162,7 @@ qcip_set_autoexposure_mode(int val)
/* Calculate standard deviation of pixel value for entire image */
static int
-qcip_luminance_std(struct qcam *q, scanbuf *scan, int avg)
+qcip_luminance_std (struct qcam *q, scanbuf * scan, int avg)
{
int count = 0;
int sum = 0;
@@ -197,7 +197,7 @@ qcip_luminance_std(struct qcam *q, scanbuf *scan, int avg)
*/
int
-qcip_autoexposure(struct qcam *q, scanbuf *scan)
+qcip_autoexposure (struct qcam *q, scanbuf * scan)
{
int luminance_dif;
int luminance_avg;
@@ -207,45 +207,46 @@ qcip_autoexposure(struct qcam *q, scanbuf *scan)
int ret = QCIP_XPSR_OK;
#ifdef DEBUG
- fprintf(stderr, "Brightness: %d Contrast: %d\n",
- qc_getbrightness(q), qc_getcontrast(q));
+ fprintf (stderr, "Brightness: %d Contrast: %d\n",
+ qc_getbrightness (q), qc_getcontrast (q));
#endif
switch (ae_mode) {
- case AE_CTR_AVG:
- luminance_avg = qcip_pixel_average_center(q, scan);
- break;
- case AE_STD_AVG:
- luminance_avg = qcip_pixel_average(q, scan);
- lum_std = qcip_luminance_std(q, scan, luminance_avg);
-
- /* ==>> Contrast adjustment <<== */
-
- /* set target if it has not been explicitly set */
- if (luminance_std_target == -1) {
- luminance_std_target = q->bpp == 6 ? 10 : 2;
- }
+ case AE_CTR_AVG:
+ luminance_avg = qcip_pixel_average_center (q, scan);
+ break;
+ case AE_STD_AVG:
+ luminance_avg = qcip_pixel_average (q, scan);
+ lum_std = qcip_luminance_std (q, scan, luminance_avg);
+
+ /* ==>> Contrast adjustment <<== */
+
+ /* set target if it has not been explicitly set */
+ if (luminance_std_target == -1) {
+ luminance_std_target = q->bpp == 6 ? 10 : 2;
+ }
- /* Adjust contrast to reach target luminance standard deviation */
- lum_std_min = luminance_std_target - luminance_std_tolerance;
- lum_std_max = luminance_std_target + luminance_std_tolerance;
+ /* Adjust contrast to reach target luminance standard deviation */
+ lum_std_min = luminance_std_target - luminance_std_tolerance;
+ lum_std_max = luminance_std_target + luminance_std_tolerance;
- if (lum_std < lum_std_min || lum_std > lum_std_max) {
- ret = QCIP_XPSR_RSCN;
- if (qc_setcontrast(q, luminance_std_target - lum_std + qc_getcontrast(q))) {
- return QCIP_XPSR_ERR;
+ if (lum_std < lum_std_min || lum_std > lum_std_max) {
+ ret = QCIP_XPSR_RSCN;
+ if (qc_setcontrast (q,
+ luminance_std_target - lum_std + qc_getcontrast (q))) {
+ return QCIP_XPSR_ERR;
+ }
}
- }
#ifdef DEBUG
- fprintf(stderr, "Luminance std/target/tolerance: %d/%d/%d\n",
- lum_std, luminance_std_target, luminance_std_tolerance );
+ fprintf (stderr, "Luminance std/target/tolerance: %d/%d/%d\n",
+ lum_std, luminance_std_target, luminance_std_tolerance);
#endif
-
- break;
- case AE_ALL_AVG:
- default:
- luminance_avg = qcip_pixel_average(q, scan);
- break;
+
+ break;
+ case AE_ALL_AVG:
+ default:
+ luminance_avg = qcip_pixel_average (q, scan);
+ break;
}
/* ==>> Brightness adjustment <<== */
@@ -259,8 +260,8 @@ qcip_autoexposure(struct qcam *q, scanbuf *scan)
lum_max = luminance_target + luminance_tolerance;
#ifdef DEBUG
- fprintf(stderr, "Luminance avg/target/tolerance: %d/%d/%d\n",
- luminance_avg, luminance_target, luminance_tolerance );
+ fprintf (stderr, "Luminance avg/target/tolerance: %d/%d/%d\n",
+ luminance_avg, luminance_target, luminance_tolerance);
#endif
/* check for luminance within target range */
@@ -277,7 +278,7 @@ qcip_autoexposure(struct qcam *q, scanbuf *scan)
/* Adjusted brightness is out of range ..
* throw in the towel ... auto-exposure has failed!
*/
- if (qc_setbrightness(q, brightness_adj + qc_getbrightness(q))) {
+ if (qc_setbrightness (q, brightness_adj + qc_getbrightness (q))) {
return QCIP_XPSR_ERR;
}
}
diff --git a/sys/qcam/gstqcamsrc.c b/sys/qcam/gstqcamsrc.c
index 04de351f..0c68ca13 100644
--- a/sys/qcam/gstqcamsrc.c
+++ b/sys/qcam/gstqcamsrc.c
@@ -34,12 +34,11 @@
#include "qcamip.h"
/* elementfactory information */
-static GstElementDetails gst_qcamsrc_details = GST_ELEMENT_DETAILS (
- "QCam Source",
- "Source/Video",
- "Read from a QuickCam device",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+static GstElementDetails gst_qcamsrc_details =
+GST_ELEMENT_DETAILS ("QCam Source",
+ "Source/Video",
+ "Read from a QuickCam device",
+ "Wim Taymans <wim.taymans@chello.be>");
#define AE_NONE 3
@@ -56,12 +55,11 @@ static GstElementDetails gst_qcamsrc_details = GST_ELEMENT_DETAILS (
#define DEF_AUTOEXP AE_NONE
static GstStaticPadTemplate gst_qcamsrc_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("I420"))
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
#define GST_TYPE_AUTOEXP_MODE (gst_autoexp_mode_get_type())
static GType
@@ -69,25 +67,28 @@ gst_autoexp_mode_get_type (void)
{
static GType autoexp_mode_type = 0;
static GEnumValue autoexp_modes[] = {
- { AE_ALL_AVG, "0", "Average Picture" },
- { AE_CTR_AVG, "1", "Average Center" },
- { AE_STD_AVG, "2", "Standard Deviation" },
- { AE_NONE, "3", "None" },
- { 0, NULL, NULL },
+ {AE_ALL_AVG, "0", "Average Picture"},
+ {AE_CTR_AVG, "1", "Average Center"},
+ {AE_STD_AVG, "2", "Standard Deviation"},
+ {AE_NONE, "3", "None"},
+ {0, NULL, NULL},
};
if (!autoexp_mode_type) {
- autoexp_mode_type = g_enum_register_static ("GstAutoExposureMode", autoexp_modes);
+ autoexp_mode_type =
+ g_enum_register_static ("GstAutoExposureMode", autoexp_modes);
}
return autoexp_mode_type;
}
/* QCamSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_WIDTH,
ARG_HEIGHT,
@@ -102,22 +103,23 @@ enum {
ARG_AUTOEXP,
};
-static void gst_qcamsrc_base_init (gpointer g_class);
-static void gst_qcamsrc_class_init (GstQCamSrcClass *klass);
-static void gst_qcamsrc_init (GstQCamSrc *qcamsrc);
+static void gst_qcamsrc_base_init (gpointer g_class);
+static void gst_qcamsrc_class_init (GstQCamSrcClass * klass);
+static void gst_qcamsrc_init (GstQCamSrc * qcamsrc);
-static void gst_qcamsrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_qcamsrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_qcamsrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_qcamsrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_qcamsrc_change_state (GstElement *element);
-static void gst_qcamsrc_close (GstQCamSrc *src);
-static gboolean gst_qcamsrc_open (GstQCamSrc *src);
+static GstElementStateReturn gst_qcamsrc_change_state (GstElement * element);
+static void gst_qcamsrc_close (GstQCamSrc * src);
+static gboolean gst_qcamsrc_open (GstQCamSrc * src);
-static GstData* gst_qcamsrc_get (GstPad *pad);
+static GstData *gst_qcamsrc_get (GstPad * pad);
static GstElementClass *parent_class = NULL;
+
/*//static guint gst_qcamsrc_signals[LAST_SIGNAL] = { 0 }; */
GType
@@ -127,18 +129,20 @@ gst_qcamsrc_get_type (void)
if (!qcamsrc_type) {
static const GTypeInfo qcamsrc_info = {
- sizeof(GstQCamSrcClass),
+ sizeof (GstQCamSrcClass),
gst_qcamsrc_base_init,
NULL,
- (GClassInitFunc)gst_qcamsrc_class_init,
+ (GClassInitFunc) gst_qcamsrc_class_init,
NULL,
NULL,
- sizeof(GstQCamSrc),
+ sizeof (GstQCamSrc),
0,
- (GInstanceInitFunc)gst_qcamsrc_init,
+ (GInstanceInitFunc) gst_qcamsrc_init,
NULL
};
- qcamsrc_type = g_type_register_static(GST_TYPE_ELEMENT, "GstQCamSrc", &qcamsrc_info, 0);
+ qcamsrc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstQCamSrc", &qcamsrc_info,
+ 0);
}
return qcamsrc_type;
}
@@ -146,54 +150,55 @@ static void
gst_qcamsrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_qcamsrc_src_factory));
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_qcamsrc_src_factory));
gst_element_class_set_details (element_class, &gst_qcamsrc_details);
}
static void
-gst_qcamsrc_class_init (GstQCamSrcClass *klass)
+gst_qcamsrc_class_init (GstQCamSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH,
- g_param_spec_int ("width", "width", "width",
- 0, 320, DEF_WIDTH, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS(klass), ARG_HEIGHT,
- g_param_spec_int ("height", "height", "height",
- 0, 240, DEF_HEIGHT, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BRIGHTNESS,
- g_param_spec_int ("brightness", "brightness", "brightness",
- 0, 255, DEF_BRIGHTNESS, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WHITEBAL,
- g_param_spec_int ("whitebal", "whitebal", "whitebal",
- 0, 255, DEF_WHITEBAL, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CONTRAST,
- g_param_spec_int ("contrast", "contrast", "contrast",
- 0, 255, DEF_CONTRAST, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TOP,
- g_param_spec_int ("top", "top", "top",
- 0, 240, DEF_TOP, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LEFT,
- g_param_spec_int ("left", "left", "left",
- 0, 320, DEF_LEFT, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TRANSFER_SCALE,
- g_param_spec_int ("transfer_scale", "transfer_scale", "transfer_scale",
- 1, 4, DEF_TRANSFER_SCALE, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_DEPTH,
- g_param_spec_int ("depth", "depth", "depth",
- 4, 6, DEF_DEPTH, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PORT,
- g_param_spec_int ("port","port","port",
- 0, G_MAXINT, DEF_PORT, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_AUTOEXP,
- g_param_spec_enum ("autoexposure", "autoexposure", "autoexposure",
- GST_TYPE_AUTOEXP_MODE, DEF_AUTOEXP, G_PARAM_READWRITE));
+ g_param_spec_int ("width", "width", "width",
+ 0, 320, DEF_WIDTH, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT,
+ g_param_spec_int ("height", "height", "height",
+ 0, 240, DEF_HEIGHT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BRIGHTNESS,
+ g_param_spec_int ("brightness", "brightness", "brightness",
+ 0, 255, DEF_BRIGHTNESS, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WHITEBAL,
+ g_param_spec_int ("whitebal", "whitebal", "whitebal",
+ 0, 255, DEF_WHITEBAL, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CONTRAST,
+ g_param_spec_int ("contrast", "contrast", "contrast",
+ 0, 255, DEF_CONTRAST, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOP,
+ g_param_spec_int ("top", "top", "top",
+ 0, 240, DEF_TOP, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LEFT,
+ g_param_spec_int ("left", "left", "left",
+ 0, 320, DEF_LEFT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TRANSFER_SCALE,
+ g_param_spec_int ("transfer_scale", "transfer_scale", "transfer_scale",
+ 1, 4, DEF_TRANSFER_SCALE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEPTH,
+ g_param_spec_int ("depth", "depth", "depth",
+ 4, 6, DEF_DEPTH, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
+ g_param_spec_int ("port", "port", "port",
+ 0, G_MAXINT, DEF_PORT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_AUTOEXP,
+ g_param_spec_enum ("autoexposure", "autoexposure", "autoexposure",
+ GST_TYPE_AUTOEXP_MODE, DEF_AUTOEXP, G_PARAM_READWRITE));
gobject_class->set_property = gst_qcamsrc_set_property;
gobject_class->get_property = gst_qcamsrc_get_property;
@@ -202,15 +207,16 @@ gst_qcamsrc_class_init (GstQCamSrcClass *klass)
}
static void
-gst_qcamsrc_init (GstQCamSrc *qcamsrc)
+gst_qcamsrc_init (GstQCamSrc * qcamsrc)
{
- qcamsrc->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_qcamsrc_src_factory), "src");
- gst_element_add_pad(GST_ELEMENT(qcamsrc),qcamsrc->srcpad);
- gst_pad_set_get_function (qcamsrc->srcpad,gst_qcamsrc_get);
+ qcamsrc->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_qcamsrc_src_factory), "src");
+ gst_element_add_pad (GST_ELEMENT (qcamsrc), qcamsrc->srcpad);
+ gst_pad_set_get_function (qcamsrc->srcpad, gst_qcamsrc_get);
/* if the destination cannot say what it wants, we give this */
- qcamsrc->qcam = qc_init();
+ qcamsrc->qcam = qc_init ();
qcamsrc->qcam->port = DEF_PORT;
qc_setwidth (qcamsrc->qcam, DEF_WIDTH);
qc_setheight (qcamsrc->qcam, DEF_HEIGHT);
@@ -222,12 +228,12 @@ gst_qcamsrc_init (GstQCamSrc *qcamsrc)
qc_settransfer_scale (qcamsrc->qcam, DEF_TRANSFER_SCALE);
qc_setbitdepth (qcamsrc->qcam, DEF_DEPTH);
qcamsrc->autoexposure = DEF_AUTOEXP;
- if (qcamsrc->autoexposure != AE_NONE)
+ if (qcamsrc->autoexposure != AE_NONE)
qcip_set_autoexposure_mode (qcamsrc->autoexposure);
}
-static GstData*
-gst_qcamsrc_get (GstPad *pad)
+static GstData *
+gst_qcamsrc_get (GstPad * pad)
{
GstQCamSrc *qcamsrc;
GstBuffer *buf;
@@ -243,45 +249,46 @@ gst_qcamsrc_get (GstPad *pad)
frame = qcamsrc->qcam->width * qcamsrc->qcam->height / (scale * scale);
- buf = gst_buffer_new();
- outdata = GST_BUFFER_DATA(buf) = g_malloc0((frame * 3) / 2);
- GST_BUFFER_SIZE(buf) = (frame * 3) / 2;
+ buf = gst_buffer_new ();
+ outdata = GST_BUFFER_DATA (buf) = g_malloc0 ((frame * 3) / 2);
+ GST_BUFFER_SIZE (buf) = (frame * 3) / 2;
qc_set (qcamsrc->qcam);
if (!GST_PAD_CAPS (pad)) {
- gst_pad_try_set_caps (pad, gst_caps_new_simple("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, "I420",
- "width", G_TYPE_INT, qcamsrc->qcam->width / scale,
- "height", G_TYPE_INT, qcamsrc->qcam->height / scale,
- "framerate", G_TYPE_DOUBLE, 10., NULL));
+ gst_pad_try_set_caps (pad, gst_caps_new_simple ("video/x-raw-yuv",
+ "format", GST_TYPE_FOURCC, "I420",
+ "width", G_TYPE_INT, qcamsrc->qcam->width / scale,
+ "height", G_TYPE_INT, qcamsrc->qcam->height / scale,
+ "framerate", G_TYPE_DOUBLE, 10., NULL));
}
scan = qc_scan (qcamsrc->qcam);
/* FIXME, this doesn't seem to work... */
/*fixdark(qcamsrc->qcam, scan); */
-
- if (qcamsrc->autoexposure != AE_NONE)
- qcip_autoexposure(qcamsrc->qcam, scan);
- convert = (qcamsrc->qcam->bpp==4?4:2);
+ if (qcamsrc->autoexposure != AE_NONE)
+ qcip_autoexposure (qcamsrc->qcam, scan);
+
+ convert = (qcamsrc->qcam->bpp == 4 ? 4 : 2);
- for (i=frame; i; i--) {
- outdata[i] = scan[i]<<convert;
+ for (i = frame; i; i--) {
+ outdata[i] = scan[i] << convert;
}
- memset (outdata+frame, 128, frame>>1);
+ memset (outdata + frame, 128, frame >> 1);
g_free (scan);
return GST_DATA (buf);
}
static void
-gst_qcamsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_qcamsrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstQCamSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_QCAMSRC(object));
- src = GST_QCAMSRC(object);
+ g_return_if_fail (GST_IS_QCAMSRC (object));
+ src = GST_QCAMSRC (object);
switch (prop_id) {
case ARG_WIDTH:
@@ -316,8 +323,8 @@ gst_qcamsrc_set_property (GObject *object, guint prop_id, const GValue *value, G
break;
case ARG_AUTOEXP:
src->autoexposure = g_value_get_enum (value);
- if (src->autoexposure != AE_NONE)
- qcip_set_autoexposure_mode (src->autoexposure);
+ if (src->autoexposure != AE_NONE)
+ qcip_set_autoexposure_mode (src->autoexposure);
break;
default:
break;
@@ -325,13 +332,14 @@ gst_qcamsrc_set_property (GObject *object, guint prop_id, const GValue *value, G
}
static void
-gst_qcamsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_qcamsrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstQCamSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_QCAMSRC(object));
- src = GST_QCAMSRC(object);
+ g_return_if_fail (GST_IS_QCAMSRC (object));
+ src = GST_QCAMSRC (object);
switch (prop_id) {
case ARG_WIDTH:
@@ -374,69 +382,63 @@ gst_qcamsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
}
static GstElementStateReturn
-gst_qcamsrc_change_state (GstElement *element)
+gst_qcamsrc_change_state (GstElement * element)
{
- g_return_val_if_fail(GST_IS_QCAMSRC(element), FALSE);
+ g_return_val_if_fail (GST_IS_QCAMSRC (element), FALSE);
/* if going down into NULL state, close the file if it's open */
- if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
- if (GST_FLAG_IS_SET(element,GST_QCAMSRC_OPEN))
- gst_qcamsrc_close(GST_QCAMSRC(element));
- /* otherwise (READY or higher) we need to open the sound card */
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
+ if (GST_FLAG_IS_SET (element, GST_QCAMSRC_OPEN))
+ gst_qcamsrc_close (GST_QCAMSRC (element));
+ /* otherwise (READY or higher) we need to open the sound card */
} else {
- if (!GST_FLAG_IS_SET(element,GST_QCAMSRC_OPEN)) {
+ if (!GST_FLAG_IS_SET (element, GST_QCAMSRC_OPEN)) {
gst_info ("qcamsrc: opening\n");
- if (!gst_qcamsrc_open(GST_QCAMSRC(element))) {
+ if (!gst_qcamsrc_open (GST_QCAMSRC (element))) {
gst_info ("qcamsrc: open failed\n");
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
}
}
}
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
static gboolean
-gst_qcamsrc_open (GstQCamSrc *qcamsrc)
+gst_qcamsrc_open (GstQCamSrc * qcamsrc)
{
if (qc_open (qcamsrc->qcam)) {
- g_warning("qcamsrc: Cannot open QuickCam.\n");
+ g_warning ("qcamsrc: Cannot open QuickCam.\n");
return FALSE;
}
- GST_FLAG_SET(qcamsrc, GST_QCAMSRC_OPEN);
+ GST_FLAG_SET (qcamsrc, GST_QCAMSRC_OPEN);
return TRUE;
}
static void
-gst_qcamsrc_close (GstQCamSrc *src)
+gst_qcamsrc_close (GstQCamSrc * src)
{
qc_close (src->qcam);
- GST_FLAG_UNSET(src, GST_QCAMSRC_OPEN);
+ GST_FLAG_UNSET (src, GST_QCAMSRC_OPEN);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "qcamsrc", GST_RANK_NONE, GST_TYPE_QCAMSRC))
+ if (!gst_element_register (plugin, "qcamsrc", GST_RANK_NONE,
+ GST_TYPE_QCAMSRC))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "qcamsrc",
- "Read from a QuickCam device",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "qcamsrc",
+ "Read from a QuickCam device",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
diff --git a/sys/qcam/gstqcamsrc.h b/sys/qcam/gstqcamsrc.h
index 0bd201c8..c6e763d4 100644
--- a/sys/qcam/gstqcamsrc.h
+++ b/sys/qcam/gstqcamsrc.h
@@ -25,8 +25,9 @@
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/** QuickCam include files */
#include "qcam.h"
@@ -44,35 +45,38 @@ extern "C" {
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QCAMSRC))
/* NOTE: per-element flags start with 16 for now */
-typedef enum {
- GST_QCAMSRC_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+ {
+ GST_QCAMSRC_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_QCAMSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
-} GstQCamSrcFlags;
+ GST_QCAMSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstQCamSrcFlags;
-typedef struct _GstQCamSrc GstQCamSrc;
-typedef struct _GstQCamSrcClass GstQCamSrcClass;
+ typedef struct _GstQCamSrc GstQCamSrc;
+ typedef struct _GstQCamSrcClass GstQCamSrcClass;
-struct _GstQCamSrc {
- GstElement element;
+ struct _GstQCamSrc
+ {
+ GstElement element;
- /* pads */
- GstPad *srcpad;
+ /* pads */
+ GstPad *srcpad;
- struct qcam *qcam;
- gboolean autoexposure;
- gint port;
-};
+ struct qcam *qcam;
+ gboolean autoexposure;
+ gint port;
+ };
-struct _GstQCamSrcClass {
- GstElementClass parent_class;
-};
+ struct _GstQCamSrcClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_qcamsrc_get_type(void);
+ GType gst_qcamsrc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_QCAMSRC_H__ */
+#endif /* __GST_QCAMSRC_H__ */
diff --git a/sys/qcam/qcam-Linux.c b/sys/qcam/qcam-Linux.c
index e73933d9..2c959e72 100644
--- a/sys/qcam/qcam-Linux.c
+++ b/sys/qcam/qcam-Linux.c
@@ -48,22 +48,50 @@ OTHER DEALINGS IN THE SOFTWARE.
#include "qcam.h"
#include "qcam-Linux.h"
-int __inline__ read_lpstatus(const struct qcam *q) { return inb(q->port+1); }
-int read_lpcontrol(const struct qcam *q) { return inb(q->port+2); }
-int read_lpdata(const struct qcam *q) { return inb(q->port); }
-void write_lpdata(const struct qcam *q, int d) { outb(d,q->port); }
-void write_lpcontrol(const struct qcam *q, int d) { outb(d,q->port+2); }
+int __inline__
+read_lpstatus (const struct qcam *q)
+{
+ return inb (q->port + 1);
+}
+
+int
+read_lpcontrol (const struct qcam *q)
+{
+ return inb (q->port + 2);
+}
+
+int
+read_lpdata (const struct qcam *q)
+{
+ return inb (q->port);
+}
-int enable_ports(const struct qcam *q)
+void
+write_lpdata (const struct qcam *q, int d)
{
- if(q->port<0x278) return 1; /* Better safe than sorry */
- if(q->port>0x3bc) return 1;
- return (ioperm(q->port, 3, 1));
+ outb (d, q->port);
}
-int disable_ports(const struct qcam *q)
+void
+write_lpcontrol (const struct qcam *q, int d)
{
- return (ioperm(q->port, 3, 0));
+ outb (d, q->port + 2);
+}
+
+int
+enable_ports (const struct qcam *q)
+{
+ if (q->port < 0x278)
+ return 1; /* Better safe than sorry */
+ if (q->port > 0x3bc)
+ return 1;
+ return (ioperm (q->port, 3, 1));
+}
+
+int
+disable_ports (const struct qcam *q)
+{
+ return (ioperm (q->port, 3, 0));
}
/* Lock port. This is currently sub-optimal, and is begging to be
@@ -81,121 +109,118 @@ int disable_ports(const struct qcam *q)
* multiple processes (eg. qcam) taking "snapshots" can peacefully coexist.
* - Dave Plonka (plonka@carroll1.cc.edu)
*/
-int qc_lock_wait(struct qcam *q, int wait)
+int
+qc_lock_wait (struct qcam *q, int wait)
{
#if 1
static struct flock sfl;
- if (-1 == q->fd) /* we've yet to open the lock file */
- {
- static char lockfile[128];
-
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- if (-1 == (q->fd = open(lockfile, O_WRONLY | O_CREAT, 0666)))
- {
- perror("open");
- return 1;
- }
+ if (-1 == q->fd) { /* we've yet to open the lock file */
+ static char lockfile[128];
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ if (-1 == (q->fd = open (lockfile, O_WRONLY | O_CREAT, 0666))) {
+ perror ("open");
+ return 1;
+ }
#ifdef TESTING
- fprintf(stderr, "%s - %d: %s open(2)ed\n", __FILE__, __LINE__, lockfile);
+ fprintf (stderr, "%s - %d: %s open(2)ed\n", __FILE__, __LINE__, lockfile);
#endif
- /* initialize the l_type memver to lock the file exclusively */
- sfl.l_type = F_WRLCK;
+ /* initialize the l_type memver to lock the file exclusively */
+ sfl.l_type = F_WRLCK;
}
-
#ifdef TESTING
- if (0 != fcntl(q->fd, F_SETLK, &sfl)) /* non-blocking set lock */
+ if (0 != fcntl (q->fd, F_SETLK, &sfl)) /* non-blocking set lock */
#else
- if (0 != fcntl(q->fd, wait? F_SETLKW : F_SETLK, &sfl))
+ if (0 != fcntl (q->fd, wait ? F_SETLKW : F_SETLK, &sfl))
#endif
{
#ifdef TESTING
- perror("fcntl");
- if (EAGAIN != errno || !wait) return 1;
-
- fprintf(stderr, "%s - %d: waiting for exclusive lock on fd %d...\n", __FILE__, __LINE__, q->fd);
+ perror ("fcntl");
+ if (EAGAIN != errno || !wait)
+ return 1;
+
+ fprintf (stderr, "%s - %d: waiting for exclusive lock on fd %d...\n",
+ __FILE__, __LINE__, q->fd);
- if (0 != fcntl(q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */
+ if (0 != fcntl (q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */
#endif
- {
- perror("fcntl");
- return 1;
- }
+ {
+ perror ("fcntl");
+ return 1;
+ }
}
-
#ifdef TESTING
- fprintf(stderr, "%s - %d: fd %d locked exclusively\n", __FILE__, __LINE__, q->fd);
+ fprintf (stderr, "%s - %d: fd %d locked exclusively\n", __FILE__, __LINE__,
+ q->fd);
#endif
#else
char lockfile[128], tmp[128];
struct stat statbuf;
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- sprintf(tmp,"%s-%d",lockfile,getpid());
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ sprintf (tmp, "%s-%d", lockfile, getpid ());
- if ((creat(tmp,0)==-1) ||
- (link(tmp,lockfile)==-1) ||
- (stat(tmp,&statbuf)==-1) ||
- (statbuf.st_nlink==1))
- {
+ if ((creat (tmp, 0) == -1) ||
+ (link (tmp, lockfile) == -1) ||
+ (stat (tmp, &statbuf) == -1) || (statbuf.st_nlink == 1)) {
#ifdef DEBUGQC
- perror("QuickCam Locked");
- if(unlink(tmp)==-1)
- perror("Error unlinking temp file.");
+ perror ("QuickCam Locked");
+ if (unlink (tmp) == -1)
+ perror ("Error unlinking temp file.");
#else
- unlink(tmp);
+ unlink (tmp);
#endif
return 1;
}
-
- unlink(tmp);
- if (chown(lockfile,getuid(),getgid())==-1)
- perror("Chown problems");
+
+ unlink (tmp);
+ if (chown (lockfile, getuid (), getgid ()) == -1)
+ perror ("Chown problems");
#endif
return 0;
}
-int qc_lock(struct qcam *q)
+int
+qc_lock (struct qcam *q)
{
#if 1
- return qc_lock_wait(q, 1 /*wait*/);
+ return qc_lock_wait (q, 1 /*wait */ );
#else
- return qc_lock_wait(q, 0 /*don't wait*/);
+ return qc_lock_wait (q, 0 /*don't wait */ );
#endif
}
/* Unlock port */
-int qc_unlock(struct qcam *q)
+int
+qc_unlock (struct qcam *q)
{
static struct flock sfl;
+
#if 1
- if (-1 == q->fd)
- { /* port was not locked */
- return 1;
+ if (-1 == q->fd) { /* port was not locked */
+ return 1;
}
/* clear the exclusive lock */
sfl.l_type = F_UNLCK;
- if (0 != fcntl(q->fd, F_SETLK, &sfl))
- {
- perror("fcntl");
- return 1;
+ if (0 != fcntl (q->fd, F_SETLK, &sfl)) {
+ perror ("fcntl");
+ return 1;
}
-
#ifdef TESTING
- fprintf(stderr, "%s - %d: fd %d unlocked\n", __FILE__, __LINE__, q->fd);
+ fprintf (stderr, "%s - %d: fd %d unlocked\n", __FILE__, __LINE__, q->fd);
#endif
#else
char lockfile[128];
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- unlink(lockfile); /* What would I do with an error? */
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ unlink (lockfile); /* What would I do with an error? */
#endif
return 0;
@@ -205,28 +230,28 @@ int qc_unlock(struct qcam *q)
/* Probe for camera. Returns 0 if found, 1 if not found, sets
q->port.*/
-int qc_probe(struct qcam *q)
+int
+qc_probe (struct qcam *q)
{
- int ioports[]={0x378, 0x278, 0x3bc,0};
- int i=0;
+ int ioports[] = { 0x378, 0x278, 0x3bc, 0 };
+ int i = 0;
/* Attempt to get permission to access IO ports. Must be root */
- while(ioports[i]!=0) {
- q->port=ioports[i++];
+ while (ioports[i] != 0) {
+ q->port = ioports[i++];
- if (qc_open(q)) {
- perror("Can't get I/O permission");
- exit(1);
+ if (qc_open (q)) {
+ perror ("Can't get I/O permission");
+ exit (1);
}
- if(qc_detect(q)) {
- fprintf(stderr,"QuickCam detected at 0x%x\n",q->port);
- qc_close(q);
- return(0);
- }
- else
- qc_close(q);
+ if (qc_detect (q)) {
+ fprintf (stderr, "QuickCam detected at 0x%x\n", q->port);
+ qc_close (q);
+ return (0);
+ } else
+ qc_close (q);
}
return 1;
@@ -240,10 +265,11 @@ usleep(0)'s, and that's too slow -- qc_start was taking over a second
to run. This seems to help, but if anyone has a good
speed-independent pause routine, please tell me. -- Scott */
-void qc_wait(int val)
+void
+qc_wait (int val)
{
int i;
-
- while(val--)
- for(i=0;i<50000;i++);
+
+ while (val--)
+ for (i = 0; i < 50000; i++);
}
diff --git a/sys/qcam/qcam-Linux.h b/sys/qcam/qcam-Linux.h
index 46dcbe51..06c1cb20 100644
--- a/sys/qcam/qcam-Linux.h
+++ b/sys/qcam/qcam-Linux.h
@@ -28,5 +28,3 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
******************************************************************/
-
-
diff --git a/sys/qcam/qcam-lib.c b/sys/qcam/qcam-lib.c
index cacd5d08..e7208cdc 100644
--- a/sys/qcam/qcam-lib.c
+++ b/sys/qcam/qcam-lib.c
@@ -53,11 +53,11 @@ OTHER DEALINGS IN THE SOFTWARE.
/* Prototypes for static functions. Externally visible functions
* should be prototyped in qcam.h */
-static int qc_waithand(const struct qcam *q, int val);
-static int qc_command(const struct qcam *q, int command);
-static int qc_readparam(const struct qcam *q);
-static int qc_setscanmode(struct qcam *q);
-static int qc_readbytes(const struct qcam *q, char buffer[]);
+static int qc_waithand (const struct qcam *q, int val);
+static int qc_command (const struct qcam *q, int command);
+static int qc_readparam (const struct qcam *q);
+static int qc_setscanmode (struct qcam *q);
+static int qc_readbytes (const struct qcam *q, char buffer[]);
/* The next several functions are used for controlling the qcam
* structure. They aren't used inside this library, but they should
@@ -65,15 +65,17 @@ static int qc_readbytes(const struct qcam *q, char buffer[]);
/* Gets/sets the brightness. */
-int qc_getbrightness(const struct qcam *q)
+int
+qc_getbrightness (const struct qcam *q)
{
return q->brightness;
}
-int qc_setbrightness(struct qcam *q, int val)
+int
+qc_setbrightness (struct qcam *q, int val)
{
if (val >= 0 && val <= 255) {
- q->brightness=val;
+ q->brightness = val;
return 0;
}
return 1;
@@ -82,15 +84,17 @@ int qc_setbrightness(struct qcam *q, int val)
/* Gets/sets the contrast */
-int qc_getcontrast(const struct qcam *q)
+int
+qc_getcontrast (const struct qcam *q)
{
return q->contrast;
}
-int qc_setcontrast(struct qcam *q, int val)
+int
+qc_setcontrast (struct qcam *q, int val)
{
if (val >= 0 && val <= 255) {
- q->contrast=val;
+ q->contrast = val;
return 0;
}
return 1;
@@ -99,15 +103,17 @@ int qc_setcontrast(struct qcam *q, int val)
/* Gets/sets the white balance */
-int qc_getwhitebal(const struct qcam *q)
+int
+qc_getwhitebal (const struct qcam *q)
{
return q->whitebal;
}
-int qc_setwhitebal(struct qcam *q, int val)
+int
+qc_setwhitebal (struct qcam *q, int val)
{
if (val >= 0 && val <= 255) {
- q->whitebal=val;
+ q->whitebal = val;
return 0;
}
return 1;
@@ -116,45 +122,51 @@ int qc_setwhitebal(struct qcam *q, int val)
/* Gets/sets the resolution */
-void qc_getresolution(const struct qcam *q, int *x, int *y)
+void
+qc_getresolution (const struct qcam *q, int *x, int *y)
{
- *x=q->width;
- *y=q->height;
+ *x = q->width;
+ *y = q->height;
}
-int qc_setresolution(struct qcam *q, int x, int y)
+int
+qc_setresolution (struct qcam *q, int x, int y)
{
if (x >= 0 && x <= 336 && y >= 0 && y <= 243) {
- q->width=x;
- q->height=y;
+ q->width = x;
+ q->height = y;
return 0;
}
return 1;
}
-int qc_getheight(const struct qcam *q)
+int
+qc_getheight (const struct qcam *q)
{
return q->height;
}
-int qc_setheight(struct qcam *q, int y)
+int
+qc_setheight (struct qcam *q, int y)
{
if (y >= 0 && y <= 243) {
- q->height=y;
+ q->height = y;
return 0;
}
return 1;
}
-int qc_getwidth(const struct qcam *q)
+int
+qc_getwidth (const struct qcam *q)
{
return q->width;
}
-int qc_setwidth(struct qcam *q, int x)
+int
+qc_setwidth (struct qcam *q, int x)
{
if (x >= 0 && x <= 336) {
- q->width=x;
+ q->width = x;
return 0;
}
return 1;
@@ -162,26 +174,30 @@ int qc_setwidth(struct qcam *q, int x)
/* Gets/sets the bit depth */
-int qc_getbitdepth(const struct qcam *q)
+int
+qc_getbitdepth (const struct qcam *q)
{
return q->bpp;
}
-int qc_setbitdepth(struct qcam *q, int val)
+int
+qc_setbitdepth (struct qcam *q, int val)
{
if (val == 4 || val == 6) {
- q->bpp=val;
- return qc_setscanmode(q);
+ q->bpp = val;
+ return qc_setscanmode (q);
}
return 1;
}
-int qc_gettop(const struct qcam *q)
+int
+qc_gettop (const struct qcam *q)
{
return q->top;
}
-int qc_settop(struct qcam *q, int val)
+int
+qc_settop (struct qcam *q, int val)
{
if (val >= 1 && val <= 243) {
q->top = val;
@@ -190,12 +206,14 @@ int qc_settop(struct qcam *q, int val)
return 1;
}
-int qc_getleft(const struct qcam *q)
+int
+qc_getleft (const struct qcam *q)
{
return q->left;
}
-int qc_setleft(struct qcam *q, int val)
+int
+qc_setleft (struct qcam *q, int val)
{
if (val % 2 == 0 && val >= 2 && val <= 336) {
q->left = val;
@@ -204,22 +222,24 @@ int qc_setleft(struct qcam *q, int val)
return 1;
}
-int qc_gettransfer_scale(const struct qcam *q)
+int
+qc_gettransfer_scale (const struct qcam *q)
{
return q->transfer_scale;
}
-int qc_settransfer_scale(struct qcam *q, int val)
+int
+qc_settransfer_scale (struct qcam *q, int val)
{
if (val == 1 || val == 2 || val == 4) {
q->transfer_scale = val;
- return qc_setscanmode(q);
+ return qc_setscanmode (q);
}
return 1;
}
int
-qc_calibrate(struct qcam *q)
+qc_calibrate (struct qcam *q)
/* bugfix by Hanno Mueller hmueller@kabel.de, Mai 21 96 */
/* The white balance is an individiual value for each */
/* quickcam. Run calibration once, write the value down */
@@ -227,19 +247,21 @@ qc_calibrate(struct qcam *q)
/* recalibrate your camera again. */
{
int value;
+
#ifdef DEBUG
int count = 0;
#endif
- qc_command(q, 27); /* AutoAdjustOffset */
- qc_command(q, 0); /* Dummy Parameter, ignored by the camera */
+ qc_command (q, 27); /* AutoAdjustOffset */
+ qc_command (q, 0); /* Dummy Parameter, ignored by the camera */
/* GetOffset (33) will read 255 until autocalibration */
/* is finished. After that, a value of 1-254 will be */
/* returned. */
do {
- qc_command(q, 33); value = qc_readparam(q);
+ qc_command (q, 33);
+ value = qc_readparam (q);
#ifdef DEBUG
count++;
#endif
@@ -248,15 +270,15 @@ qc_calibrate(struct qcam *q)
q->whitebal = value;
#ifdef DEBUG
- fprintf(stderr, "%d loops to calibrate\n", count);
- fprintf(stderr, "Calibrated to %d\n", value);
+ fprintf (stderr, "%d loops to calibrate\n", count);
+ fprintf (stderr, "Calibrated to %d\n", value);
#endif
return value;
}
int
-qc_forceunidir(struct qcam *q)
+qc_forceunidir (struct qcam *q)
{
q->port_mode = (q->port_mode & ~QC_FORCE_MASK) | QC_FORCE_UNIDIR;
return 0;
@@ -266,29 +288,29 @@ qc_forceunidir(struct qcam *q)
/* Initialize the QuickCam driver control structure. This is where
* defaults are set for people who don't have a config file.*/
struct qcam *
-qc_init(void)
+qc_init (void)
{
struct qcam *q;
- q=malloc(sizeof(struct qcam));
+ q = malloc (sizeof (struct qcam));
- q->port=0; /* Port 0 == Autoprobe */
- q->port_mode=(QC_ANY | QC_NOTSET);
- q->width=160;
- q->height=120;
- q->bpp=4;
+ q->port = 0; /* Port 0 == Autoprobe */
+ q->port_mode = (QC_ANY | QC_NOTSET);
+ q->width = 160;
+ q->height = 120;
+ q->bpp = 4;
q->transfer_scale = 2;
- q->contrast=104;
- q->brightness=150;
- q->whitebal=150;
+ q->contrast = 104;
+ q->brightness = 150;
+ q->whitebal = 150;
q->top = 1;
q->left = 14;
q->mode = -1;
- q->fd=-1; /* added initialization of fd member
- * BTW, there doesn't seem to be a place to close this fd...
- * I think we need a qc_free function.
- * - Dave Plonka (plonka@carroll1.cc.edu)
- */
+ q->fd = -1; /* added initialization of fd member
+ * BTW, there doesn't seem to be a place to close this fd...
+ * I think we need a qc_free function.
+ * - Dave Plonka (plonka@carroll1.cc.edu)
+ */
return q;
}
@@ -301,21 +323,22 @@ qc_init(void)
* Returns 0 for success, 1 for opening error, 2 for locking error,
* and 3 for qcam not found */
-int qc_open(struct qcam *q)
+int
+qc_open (struct qcam *q)
{
- if(q->port==0)
- if(qc_probe(q)) {
- fprintf(stderr,"Qcam not found\n");
+ if (q->port == 0)
+ if (qc_probe (q)) {
+ fprintf (stderr, "Qcam not found\n");
return 3;
}
- if(qc_lock(q)) {
- fprintf(stderr,"Cannot lock qcam.\n");
+ if (qc_lock (q)) {
+ fprintf (stderr, "Cannot lock qcam.\n");
return 2;
}
- if(enable_ports(q)) {
- fprintf(stderr,"Cannot open QuickCam -- permission denied.");
+ if (enable_ports (q)) {
+ fprintf (stderr, "Cannot open QuickCam -- permission denied.");
return 1;
} else {
return 0;
@@ -326,11 +349,12 @@ int qc_open(struct qcam *q)
/* qc_close closes and unlocks the driver. You *need* to call this,
* or lockfiles will be left behind and everything will be screwed. */
-int qc_close(struct qcam *q)
+int
+qc_close (struct qcam *q)
{
- qc_unlock(q);
+ qc_unlock (q);
- disable_ports(q);
+ disable_ports (q);
return 0;
}
@@ -340,43 +364,46 @@ int qc_close(struct qcam *q)
* or arguments to commands, so the name fits, but it still bugs me a
* bit. See the documentation for a list of commands. */
-static int qc_command(const struct qcam *q, int command)
+static int
+qc_command (const struct qcam *q, int command)
{
int n1, n2;
int cmd;
- write_lpdata(q, command);
- write_lpcontrol(q,6);
+ write_lpdata (q, command);
+ write_lpcontrol (q, 6);
- n1 = qc_waithand(q,1);
+ n1 = qc_waithand (q, 1);
- write_lpcontrol(q,0xe);
- n2 = qc_waithand(q,0);
+ write_lpcontrol (q, 0xe);
+ n2 = qc_waithand (q, 0);
cmd = (n1 & 0xf0) | ((n2 & 0xf0) >> 4);
#ifdef DEBUG
if (cmd != command) {
- fprintf(stderr, "Command 0x%02x sent, 0x%02x echoed", command, cmd);
- n2 = read_lpstatus(q);
+ fprintf (stderr, "Command 0x%02x sent, 0x%02x echoed", command, cmd);
+ n2 = read_lpstatus (q);
cmd = (n1 & 0xf0) | ((n2 & 0xf0) >> 4);
- if (cmd != command) fprintf(stderr, " (re-read does not help)\n");
- else fprintf(stderr, " (fixed on re-read)\n");
+ if (cmd != command)
+ fprintf (stderr, " (re-read does not help)\n");
+ else
+ fprintf (stderr, " (fixed on re-read)\n");
}
#endif
return cmd;
}
static int
-qc_readparam(const struct qcam *q)
+qc_readparam (const struct qcam *q)
{
int n1, n2;
int cmd;
- write_lpcontrol(q,6);
- n1 = qc_waithand(q,1);
+ write_lpcontrol (q, 6);
+ n1 = qc_waithand (q, 1);
- write_lpcontrol(q,0xe);
- n2 = qc_waithand(q,0);
+ write_lpcontrol (q, 0xe);
+ n2 = qc_waithand (q, 0);
cmd = (n1 & 0xf0) | ((n2 & 0xf0) >> 4);
return cmd;
@@ -385,16 +412,15 @@ qc_readparam(const struct qcam *q)
/* qc_waithand busy-waits for a handshake signal from the QuickCam.
* Almost all communication with the camera requires handshaking. */
-static int qc_waithand(const struct qcam *q, int val)
+static int
+qc_waithand (const struct qcam *q, int val)
{
int status;
if (val)
- while(! ((status = read_lpstatus(q))&8))
- ;
+ while (!((status = read_lpstatus (q)) & 8));
else
- while (((status = read_lpstatus(q))&8))
- ;
+ while (((status = read_lpstatus (q)) & 8));
return status;
}
@@ -405,12 +431,13 @@ static int qc_waithand(const struct qcam *q, int val)
* since this data is useful. */
static unsigned int
-qc_waithand2(const struct qcam *q, int val)
+qc_waithand2 (const struct qcam *q, int val)
{
unsigned int status;
+
do {
- status = read_lpdata(q);
- } while ( (status & 1) != val);
+ status = read_lpdata (q);
+ } while ((status & 1) != val);
return status;
}
@@ -423,27 +450,29 @@ qc_waithand2(const struct qcam *q, int val)
almost completely safe, while their method screws up my printer if
I plug it in before the camera. */
-int qc_detect(const struct qcam *q)
+int
+qc_detect (const struct qcam *q)
{
- int reg,lastreg;
- int count=0;
+ int reg, lastreg;
+ int count = 0;
int i;
- lastreg=reg=read_lpstatus(q)&0xf0;
+ lastreg = reg = read_lpstatus (q) & 0xf0;
- for(i=0;i<30;i++) {
- reg=read_lpstatus(q)&0xf0;
- if(reg!=lastreg) count++;
- lastreg=reg;
- usleep(10000);
+ for (i = 0; i < 30; i++) {
+ reg = read_lpstatus (q) & 0xf0;
+ if (reg != lastreg)
+ count++;
+ lastreg = reg;
+ usleep (10000);
}
/* Be liberal in what you accept... */
- if(count>3&&count<15)
- return 1; /* found */
- else
- return 0; /* not found */
+ if (count > 3 && count < 15)
+ return 1; /* found */
+ else
+ return 0; /* not found */
}
@@ -452,10 +481,10 @@ int qc_detect(const struct qcam *q)
* check that bi-directional mode is detected right, and then
* implement bi-directional mode in qc_readbyte(). */
-void qc_reset(struct qcam *q)
+void
+qc_reset (struct qcam *q)
{
- switch (q->port_mode & QC_FORCE_MASK)
- {
+ switch (q->port_mode & QC_FORCE_MASK) {
case QC_FORCE_UNIDIR:
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
break;
@@ -465,10 +494,10 @@ void qc_reset(struct qcam *q)
break;
case QC_ANY:
- write_lpcontrol(q,0x20);
- write_lpdata(q,0x75);
+ write_lpcontrol (q, 0x20);
+ write_lpdata (q, 0x75);
- if (read_lpdata(q) != 0x75) {
+ if (read_lpdata (q) != 0x75) {
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR;
} else {
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
@@ -477,15 +506,15 @@ void qc_reset(struct qcam *q)
case QC_FORCE_SERIAL:
default:
- fprintf(stderr, "Illegal port_mode %x\n", q->port_mode);
+ fprintf (stderr, "Illegal port_mode %x\n", q->port_mode);
break;
}
- /* usleep(250);*/
- write_lpcontrol(q,0xb);
- usleep(250);
- write_lpcontrol(q,0xe);
- (void)qc_setscanmode(q); /* in case port_mode changed */
+ /* usleep(250); */
+ write_lpcontrol (q, 0xb);
+ usleep (250);
+ write_lpcontrol (q, 0xe);
+ (void) qc_setscanmode (q); /* in case port_mode changed */
}
@@ -498,28 +527,43 @@ void qc_reset(struct qcam *q)
* returned. If the scan is smaller, then the rest of the image
* returned contains garbage. */
-static int qc_setscanmode(struct qcam *q)
+static int
+qc_setscanmode (struct qcam *q)
{
switch (q->transfer_scale) {
- case 1: q->mode = 0; break;
- case 2: q->mode = 4; break;
- case 4: q->mode = 8; break;
- default: return 1;
+ case 1:
+ q->mode = 0;
+ break;
+ case 2:
+ q->mode = 4;
+ break;
+ case 4:
+ q->mode = 8;
+ break;
+ default:
+ return 1;
}
switch (q->bpp) {
- case 4: break;
- case 6: q->mode+=2; break;
- default:
- fprintf(stderr,"Error: Unsupported bit depth\n");
- return 1;
+ case 4:
+ break;
+ case 6:
+ q->mode += 2;
+ break;
+ default:
+ fprintf (stderr, "Error: Unsupported bit depth\n");
+ return 1;
}
switch (q->port_mode & QC_MODE_MASK) {
- case QC_BIDIR: q->mode += 1; break;
- case QC_NOTSET:
- case QC_UNIDIR: break;
- default: return 1;
+ case QC_BIDIR:
+ q->mode += 1;
+ break;
+ case QC_NOTSET:
+ case QC_UNIDIR:
+ break;
+ default:
+ return 1;
}
return 0;
}
@@ -528,44 +572,51 @@ static int qc_setscanmode(struct qcam *q)
/* Reset the QuickCam and program for brightness, contrast,
* white-balance, and resolution. */
-void qc_set(struct qcam *q)
+void
+qc_set (struct qcam *q)
{
int val;
int val2;
- qc_reset(q);
+ qc_reset (q);
/* Set the brightness. Yes, this is repetitive, but it works.
* Shorter versions seem to fail subtly. Feel free to try :-). */
/* I think the problem was in qc_command, not here -- bls */
- qc_command(q,0xb);
- qc_command(q,q->brightness);
+ qc_command (q, 0xb);
+ qc_command (q, q->brightness);
val = q->height / q->transfer_scale;
- qc_command(q,0x11); qc_command(q, val);
+ qc_command (q, 0x11);
+ qc_command (q, val);
if ((q->port_mode & QC_MODE_MASK) == QC_UNIDIR && q->bpp == 6) {
/* The normal "transfers per line" calculation doesn't seem to work
- as expected here (and yet it works fine in qc_scan). No idea
- why this case is the odd man out. Fortunately, Laird's original
- working version gives me a good way to guess at working values.
- -- bls */
+ as expected here (and yet it works fine in qc_scan). No idea
+ why this case is the odd man out. Fortunately, Laird's original
+ working version gives me a good way to guess at working values.
+ -- bls */
val = q->width;
val2 = q->transfer_scale * 4;
} else {
val = q->width * q->bpp;
- val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR)?24:8) *
+ val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) *
q->transfer_scale;
}
val = (val + val2 - 1) / val2;
- qc_command(q,0x13); qc_command(q, val);
+ qc_command (q, 0x13);
+ qc_command (q, val);
/* I still don't know what these do! */
/* They're setting top and left -- bls */
- qc_command(q,0xd); qc_command(q,q->top);
- qc_command(q,0xf); qc_command(q,q->left/2);
+ qc_command (q, 0xd);
+ qc_command (q, q->top);
+ qc_command (q, 0xf);
+ qc_command (q, q->left / 2);
- qc_command(q,0x19); qc_command(q,q->contrast);
- qc_command(q,0x1f); qc_command(q,q->whitebal);
+ qc_command (q, 0x19);
+ qc_command (q, q->contrast);
+ qc_command (q, 0x1f);
+ qc_command (q, q->whitebal);
}
@@ -573,9 +624,8 @@ void qc_set(struct qcam *q)
the supplied buffer. It returns the number of bytes read,
or -1 on error. */
-static int
-__inline__
-qc_readbytes(const struct qcam *q, char buffer[])
+static int __inline__
+qc_readbytes (const struct qcam *q, char buffer[])
{
int ret;
unsigned int hi, lo;
@@ -585,84 +635,90 @@ qc_readbytes(const struct qcam *q, char buffer[])
if (buffer == NULL) {
state = 0;
- return 0;
+ return 0;
}
switch (q->port_mode & QC_MODE_MASK) {
- case QC_BIDIR: /* Bi-directional Port */
- write_lpcontrol(q, 0x26);
- lo = (qc_waithand2(q, 1) >> 1);
- hi = (read_lpstatus(q) >> 3) & 0x1f;
- write_lpcontrol(q, 0x2e);
- lo2 = (qc_waithand2(q, 0) >> 1);
- hi2 = (read_lpstatus(q) >> 3) & 0x1f;
- switch (q->bpp) {
- case 4:
- buffer[0] = lo & 0xf;
- buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3);
- buffer[2] = (hi & 0x1e) >> 1;
- buffer[3] = lo2 & 0xf;
- buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3);
- buffer[5] = (hi2 & 0x1e) >> 1;
- ret = 6;
- break;
- case 6:
- buffer[0] = lo & 0x3f;
- buffer[1] = ((lo & 0x40) >> 6) | (hi << 1);
- buffer[2] = lo2 & 0x3f;
- buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1);
- ret = 4;
- break;
- default:
- fprintf(stderr, "Bad bidir pixel depth %d\n", q->bpp);
- ret = -1;
- break;
- }
- break;
-
- case QC_UNIDIR: /* Unidirectional Port */
- write_lpcontrol(q,6);
- lo = (qc_waithand(q,1) & 0xf0) >> 4;
- write_lpcontrol(q,0xe);
- hi = (qc_waithand(q,0) & 0xf0) >> 4;
-
- switch (q->bpp) {
- case 4:
- buffer[0] = lo;
- buffer[1] = hi;
- ret = 2;
- break;
- case 6:
- switch (state) {
- case 0:
- buffer[0] = (lo << 2) | ((hi & 0xc) >> 2);
- saved_bits = (hi & 3) << 4;
- state = 1; ret = 1; break;
- case 1:
- buffer[0] = lo | saved_bits;
- saved_bits = hi << 2;
- state = 2; ret = 1; break;
- case 2:
- buffer[0] = ((lo & 0xc) >> 2) | saved_bits;
- buffer[1] = ((lo & 3) << 4) | hi;
- state = 0; ret = 2; break;
- default:
- fprintf(stderr, "Unidir 6-bit state %d?\n", state);
- ret = -1;
- break;
- }
- break;
- default:
- fprintf(stderr, "Bad unidir pixel depth %d\n", q->bpp);
- ret = -1;
- break;
- }
- break;
- case QC_SERIAL: /* Serial Interface. Just in case.*/
- default:
- fprintf(stderr,"Mode %x not supported\n",q->port_mode);
- ret=-1;
- break;
+ case QC_BIDIR: /* Bi-directional Port */
+ write_lpcontrol (q, 0x26);
+ lo = (qc_waithand2 (q, 1) >> 1);
+ hi = (read_lpstatus (q) >> 3) & 0x1f;
+ write_lpcontrol (q, 0x2e);
+ lo2 = (qc_waithand2 (q, 0) >> 1);
+ hi2 = (read_lpstatus (q) >> 3) & 0x1f;
+ switch (q->bpp) {
+ case 4:
+ buffer[0] = lo & 0xf;
+ buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3);
+ buffer[2] = (hi & 0x1e) >> 1;
+ buffer[3] = lo2 & 0xf;
+ buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3);
+ buffer[5] = (hi2 & 0x1e) >> 1;
+ ret = 6;
+ break;
+ case 6:
+ buffer[0] = lo & 0x3f;
+ buffer[1] = ((lo & 0x40) >> 6) | (hi << 1);
+ buffer[2] = lo2 & 0x3f;
+ buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1);
+ ret = 4;
+ break;
+ default:
+ fprintf (stderr, "Bad bidir pixel depth %d\n", q->bpp);
+ ret = -1;
+ break;
+ }
+ break;
+
+ case QC_UNIDIR: /* Unidirectional Port */
+ write_lpcontrol (q, 6);
+ lo = (qc_waithand (q, 1) & 0xf0) >> 4;
+ write_lpcontrol (q, 0xe);
+ hi = (qc_waithand (q, 0) & 0xf0) >> 4;
+
+ switch (q->bpp) {
+ case 4:
+ buffer[0] = lo;
+ buffer[1] = hi;
+ ret = 2;
+ break;
+ case 6:
+ switch (state) {
+ case 0:
+ buffer[0] = (lo << 2) | ((hi & 0xc) >> 2);
+ saved_bits = (hi & 3) << 4;
+ state = 1;
+ ret = 1;
+ break;
+ case 1:
+ buffer[0] = lo | saved_bits;
+ saved_bits = hi << 2;
+ state = 2;
+ ret = 1;
+ break;
+ case 2:
+ buffer[0] = ((lo & 0xc) >> 2) | saved_bits;
+ buffer[1] = ((lo & 3) << 4) | hi;
+ state = 0;
+ ret = 2;
+ break;
+ default:
+ fprintf (stderr, "Unidir 6-bit state %d?\n", state);
+ ret = -1;
+ break;
+ }
+ break;
+ default:
+ fprintf (stderr, "Bad unidir pixel depth %d\n", q->bpp);
+ ret = -1;
+ break;
+ }
+ break;
+ case QC_SERIAL: /* Serial Interface. Just in case. */
+ default:
+ fprintf (stderr, "Mode %x not supported\n", q->port_mode);
+ ret = -1;
+ break;
}
return ret;
}
@@ -679,7 +735,8 @@ qc_readbytes(const struct qcam *q, char buffer[])
* n=2^(bit depth)-1. Ask me for more details if you don't understand
* this. */
-scanbuf *qc_scan(const struct qcam *q)
+scanbuf *
+qc_scan (const struct qcam * q)
{
unsigned char *ret;
int i, j, k;
@@ -692,31 +749,32 @@ scanbuf *qc_scan(const struct qcam *q)
char invert;
if (q->mode != -1) {
- qc_command(q, 0x7);
- qc_command(q, q->mode);
+ qc_command (q, 0x7);
+ qc_command (q, q->mode);
} else {
struct qcam bogus_cam;
+
/* We're going through these odd hoops to retain the "const"
- qualification on q. We can't do a qc_setscanmode directly on q,
- so we copy it, do a setscanmode on that, and pass in the newly
- computed mode. -- bls 11/21/96
- */
+ qualification on q. We can't do a qc_setscanmode directly on q,
+ so we copy it, do a setscanmode on that, and pass in the newly
+ computed mode. -- bls 11/21/96
+ */
#ifdef DEBUG
- fprintf(stderr, "Warning! qc->mode not set!\n");
+ fprintf (stderr, "Warning! qc->mode not set!\n");
#endif
bogus_cam = *q;
- (void)qc_setscanmode(&bogus_cam);
- qc_command(q, 0x7);
- qc_command(q, bogus_cam.mode);
+ (void) qc_setscanmode (&bogus_cam);
+ qc_command (q, 0x7);
+ qc_command (q, bogus_cam.mode);
}
if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) {
- write_lpcontrol(q, 0x2e); /* turn port around */
- write_lpcontrol(q, 0x26);
- (void) qc_waithand(q, 1);
- write_lpcontrol(q, 0x2e);
- (void) qc_waithand(q, 0);
+ write_lpcontrol (q, 0x2e); /* turn port around */
+ write_lpcontrol (q, 0x26);
+ (void) qc_waithand (q, 1);
+ write_lpcontrol (q, 0x2e);
+ (void) qc_waithand (q, 0);
}
/* strange -- should be 15:63 below, but 4bpp is odd */
@@ -725,23 +783,23 @@ scanbuf *qc_scan(const struct qcam *q)
linestotrans = q->height / q->transfer_scale;
pixels_per_line = q->width / q->transfer_scale;
transperline = q->width * q->bpp;
- divisor = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR)?24:8) *
- q->transfer_scale;
+ divisor = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) *
+ q->transfer_scale;
transperline = (transperline + divisor - 1) / divisor;
- ret = malloc(linestotrans * pixels_per_line);
- assert(ret);
+ ret = malloc (linestotrans * pixels_per_line);
+ assert (ret);
#ifdef DEBUG
- fprintf(stderr, "%s %d bpp\n%d lines of %d transfers each\n",
- ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)?"Bidir":"Unidir",
- q->bpp, linestotrans, transperline);
+ fprintf (stderr, "%s %d bpp\n%d lines of %d transfers each\n",
+ ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? "Bidir" : "Unidir",
+ q->bpp, linestotrans, transperline);
#endif
for (i = 0; i < linestotrans; i++) {
for (pixels_read = j = 0; j < transperline; j++) {
- bytes = qc_readbytes(q, buffer);
- assert(bytes > 0);
+ bytes = qc_readbytes (q, buffer);
+ assert (bytes > 0);
for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++) {
assert (buffer[k] <= invert);
assert (buffer[k] >= 0);
@@ -750,18 +808,18 @@ scanbuf *qc_scan(const struct qcam *q)
must be 0-15 -- bls */
buffer[k] = 16;
}
- ret[i*pixels_per_line + pixels_read + k] = invert - buffer[k];
+ ret[i * pixels_per_line + pixels_read + k] = invert - buffer[k];
}
pixels_read += bytes;
}
- (void) qc_readbytes(q, 0); /* reset state machine */
+ (void) qc_readbytes (q, 0); /* reset state machine */
}
if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) {
- write_lpcontrol(q, 2);
- write_lpcontrol(q, 6);
- usleep(3);
- write_lpcontrol(q, 0xe);
+ write_lpcontrol (q, 2);
+ write_lpcontrol (q, 6);
+ usleep (3);
+ write_lpcontrol (q, 0xe);
}
return ret;
@@ -769,24 +827,23 @@ scanbuf *qc_scan(const struct qcam *q)
void
-qc_dump(const struct qcam *q, char *fname)
+qc_dump (const struct qcam *q, char *fname)
{
FILE *fp;
time_t t;
- if ((fp = fopen(fname, "w")) == 0)
- {
- fprintf(stderr, "Error: cannot open %s\n", fname);
+ if ((fp = fopen (fname, "w")) == 0) {
+ fprintf (stderr, "Error: cannot open %s\n", fname);
return;
}
- fprintf(fp, "# Version 0.9\n");
- time(&t);
- fprintf(fp, "# Created %s", ctime(&t));
- fprintf(fp, "Width %d\nHeight %d\n", q->width, q->height);
- fprintf(fp, "Top %d\nLeft %d\n", q->top, q->left);
- fprintf(fp, "Bpp %d\nContrast %d\n", q->bpp, q->contrast);
- fprintf(fp, "Brightness %d\nWhitebal %d\n", q->brightness, q->whitebal);
- fprintf(fp, "Port 0x%x\nScale %d\n", q->port, q->transfer_scale);
- fclose(fp);
+ fprintf (fp, "# Version 0.9\n");
+ time (&t);
+ fprintf (fp, "# Created %s", ctime (&t));
+ fprintf (fp, "Width %d\nHeight %d\n", q->width, q->height);
+ fprintf (fp, "Top %d\nLeft %d\n", q->top, q->left);
+ fprintf (fp, "Bpp %d\nContrast %d\n", q->bpp, q->contrast);
+ fprintf (fp, "Brightness %d\nWhitebal %d\n", q->brightness, q->whitebal);
+ fprintf (fp, "Port 0x%x\nScale %d\n", q->port, q->transfer_scale);
+ fclose (fp);
}
diff --git a/sys/qcam/qcam-os.c b/sys/qcam/qcam-os.c
index e73933d9..2c959e72 100644
--- a/sys/qcam/qcam-os.c
+++ b/sys/qcam/qcam-os.c
@@ -48,22 +48,50 @@ OTHER DEALINGS IN THE SOFTWARE.
#include "qcam.h"
#include "qcam-Linux.h"
-int __inline__ read_lpstatus(const struct qcam *q) { return inb(q->port+1); }
-int read_lpcontrol(const struct qcam *q) { return inb(q->port+2); }
-int read_lpdata(const struct qcam *q) { return inb(q->port); }
-void write_lpdata(const struct qcam *q, int d) { outb(d,q->port); }
-void write_lpcontrol(const struct qcam *q, int d) { outb(d,q->port+2); }
+int __inline__
+read_lpstatus (const struct qcam *q)
+{
+ return inb (q->port + 1);
+}
+
+int
+read_lpcontrol (const struct qcam *q)
+{
+ return inb (q->port + 2);
+}
+
+int
+read_lpdata (const struct qcam *q)
+{
+ return inb (q->port);
+}
-int enable_ports(const struct qcam *q)
+void
+write_lpdata (const struct qcam *q, int d)
{
- if(q->port<0x278) return 1; /* Better safe than sorry */
- if(q->port>0x3bc) return 1;
- return (ioperm(q->port, 3, 1));
+ outb (d, q->port);
}
-int disable_ports(const struct qcam *q)
+void
+write_lpcontrol (const struct qcam *q, int d)
{
- return (ioperm(q->port, 3, 0));
+ outb (d, q->port + 2);
+}
+
+int
+enable_ports (const struct qcam *q)
+{
+ if (q->port < 0x278)
+ return 1; /* Better safe than sorry */
+ if (q->port > 0x3bc)
+ return 1;
+ return (ioperm (q->port, 3, 1));
+}
+
+int
+disable_ports (const struct qcam *q)
+{
+ return (ioperm (q->port, 3, 0));
}
/* Lock port. This is currently sub-optimal, and is begging to be
@@ -81,121 +109,118 @@ int disable_ports(const struct qcam *q)
* multiple processes (eg. qcam) taking "snapshots" can peacefully coexist.
* - Dave Plonka (plonka@carroll1.cc.edu)
*/
-int qc_lock_wait(struct qcam *q, int wait)
+int
+qc_lock_wait (struct qcam *q, int wait)
{
#if 1
static struct flock sfl;
- if (-1 == q->fd) /* we've yet to open the lock file */
- {
- static char lockfile[128];
-
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- if (-1 == (q->fd = open(lockfile, O_WRONLY | O_CREAT, 0666)))
- {
- perror("open");
- return 1;
- }
+ if (-1 == q->fd) { /* we've yet to open the lock file */
+ static char lockfile[128];
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ if (-1 == (q->fd = open (lockfile, O_WRONLY | O_CREAT, 0666))) {
+ perror ("open");
+ return 1;
+ }
#ifdef TESTING
- fprintf(stderr, "%s - %d: %s open(2)ed\n", __FILE__, __LINE__, lockfile);
+ fprintf (stderr, "%s - %d: %s open(2)ed\n", __FILE__, __LINE__, lockfile);
#endif
- /* initialize the l_type memver to lock the file exclusively */
- sfl.l_type = F_WRLCK;
+ /* initialize the l_type memver to lock the file exclusively */
+ sfl.l_type = F_WRLCK;
}
-
#ifdef TESTING
- if (0 != fcntl(q->fd, F_SETLK, &sfl)) /* non-blocking set lock */
+ if (0 != fcntl (q->fd, F_SETLK, &sfl)) /* non-blocking set lock */
#else
- if (0 != fcntl(q->fd, wait? F_SETLKW : F_SETLK, &sfl))
+ if (0 != fcntl (q->fd, wait ? F_SETLKW : F_SETLK, &sfl))
#endif
{
#ifdef TESTING
- perror("fcntl");
- if (EAGAIN != errno || !wait) return 1;
-
- fprintf(stderr, "%s - %d: waiting for exclusive lock on fd %d...\n", __FILE__, __LINE__, q->fd);
+ perror ("fcntl");
+ if (EAGAIN != errno || !wait)
+ return 1;
+
+ fprintf (stderr, "%s - %d: waiting for exclusive lock on fd %d...\n",
+ __FILE__, __LINE__, q->fd);
- if (0 != fcntl(q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */
+ if (0 != fcntl (q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */
#endif
- {
- perror("fcntl");
- return 1;
- }
+ {
+ perror ("fcntl");
+ return 1;
+ }
}
-
#ifdef TESTING
- fprintf(stderr, "%s - %d: fd %d locked exclusively\n", __FILE__, __LINE__, q->fd);
+ fprintf (stderr, "%s - %d: fd %d locked exclusively\n", __FILE__, __LINE__,
+ q->fd);
#endif
#else
char lockfile[128], tmp[128];
struct stat statbuf;
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- sprintf(tmp,"%s-%d",lockfile,getpid());
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ sprintf (tmp, "%s-%d", lockfile, getpid ());
- if ((creat(tmp,0)==-1) ||
- (link(tmp,lockfile)==-1) ||
- (stat(tmp,&statbuf)==-1) ||
- (statbuf.st_nlink==1))
- {
+ if ((creat (tmp, 0) == -1) ||
+ (link (tmp, lockfile) == -1) ||
+ (stat (tmp, &statbuf) == -1) || (statbuf.st_nlink == 1)) {
#ifdef DEBUGQC
- perror("QuickCam Locked");
- if(unlink(tmp)==-1)
- perror("Error unlinking temp file.");
+ perror ("QuickCam Locked");
+ if (unlink (tmp) == -1)
+ perror ("Error unlinking temp file.");
#else
- unlink(tmp);
+ unlink (tmp);
#endif
return 1;
}
-
- unlink(tmp);
- if (chown(lockfile,getuid(),getgid())==-1)
- perror("Chown problems");
+
+ unlink (tmp);
+ if (chown (lockfile, getuid (), getgid ()) == -1)
+ perror ("Chown problems");
#endif
return 0;
}
-int qc_lock(struct qcam *q)
+int
+qc_lock (struct qcam *q)
{
#if 1
- return qc_lock_wait(q, 1 /*wait*/);
+ return qc_lock_wait (q, 1 /*wait */ );
#else
- return qc_lock_wait(q, 0 /*don't wait*/);
+ return qc_lock_wait (q, 0 /*don't wait */ );
#endif
}
/* Unlock port */
-int qc_unlock(struct qcam *q)
+int
+qc_unlock (struct qcam *q)
{
static struct flock sfl;
+
#if 1
- if (-1 == q->fd)
- { /* port was not locked */
- return 1;
+ if (-1 == q->fd) { /* port was not locked */
+ return 1;
}
/* clear the exclusive lock */
sfl.l_type = F_UNLCK;
- if (0 != fcntl(q->fd, F_SETLK, &sfl))
- {
- perror("fcntl");
- return 1;
+ if (0 != fcntl (q->fd, F_SETLK, &sfl)) {
+ perror ("fcntl");
+ return 1;
}
-
#ifdef TESTING
- fprintf(stderr, "%s - %d: fd %d unlocked\n", __FILE__, __LINE__, q->fd);
+ fprintf (stderr, "%s - %d: fd %d unlocked\n", __FILE__, __LINE__, q->fd);
#endif
#else
char lockfile[128];
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- unlink(lockfile); /* What would I do with an error? */
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ unlink (lockfile); /* What would I do with an error? */
#endif
return 0;
@@ -205,28 +230,28 @@ int qc_unlock(struct qcam *q)
/* Probe for camera. Returns 0 if found, 1 if not found, sets
q->port.*/
-int qc_probe(struct qcam *q)
+int
+qc_probe (struct qcam *q)
{
- int ioports[]={0x378, 0x278, 0x3bc,0};
- int i=0;
+ int ioports[] = { 0x378, 0x278, 0x3bc, 0 };
+ int i = 0;
/* Attempt to get permission to access IO ports. Must be root */
- while(ioports[i]!=0) {
- q->port=ioports[i++];
+ while (ioports[i] != 0) {
+ q->port = ioports[i++];
- if (qc_open(q)) {
- perror("Can't get I/O permission");
- exit(1);
+ if (qc_open (q)) {
+ perror ("Can't get I/O permission");
+ exit (1);
}
- if(qc_detect(q)) {
- fprintf(stderr,"QuickCam detected at 0x%x\n",q->port);
- qc_close(q);
- return(0);
- }
- else
- qc_close(q);
+ if (qc_detect (q)) {
+ fprintf (stderr, "QuickCam detected at 0x%x\n", q->port);
+ qc_close (q);
+ return (0);
+ } else
+ qc_close (q);
}
return 1;
@@ -240,10 +265,11 @@ usleep(0)'s, and that's too slow -- qc_start was taking over a second
to run. This seems to help, but if anyone has a good
speed-independent pause routine, please tell me. -- Scott */
-void qc_wait(int val)
+void
+qc_wait (int val)
{
int i;
-
- while(val--)
- for(i=0;i<50000;i++);
+
+ while (val--)
+ for (i = 0; i < 50000; i++);
}
diff --git a/sys/qcam/qcam-os.h b/sys/qcam/qcam-os.h
index 46dcbe51..06c1cb20 100644
--- a/sys/qcam/qcam-os.h
+++ b/sys/qcam/qcam-os.h
@@ -28,5 +28,3 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
******************************************************************/
-
-
diff --git a/sys/qcam/qcam.h b/sys/qcam/qcam.h
index 35b2dc26..4697befd 100644
--- a/sys/qcam/qcam.h
+++ b/sys/qcam/qcam.h
@@ -54,7 +54,8 @@ OTHER DEALINGS IN THE SOFTWARE.
#define MAX_HEIGHT 243
#define MAX_WIDTH 336
-struct qcam {
+struct qcam
+{
int width, height;
int bpp;
int mode;
@@ -63,72 +64,72 @@ struct qcam {
int port_mode;
int transfer_scale;
int top, left;
- int fd; /* lock file descriptor
- * It was, unfortunately, necessary to add this member to the
- * struct qcam to conveniently implement POSIX fcntl-style locking.
- * We need a seperate lock file for each struct qcam, for instance,
- * if the same process (using qcam-lib) is accessing multiple
- * QuickCams on (of course) multiple ports.
- * - Dave Plonka (plonka@carroll1.cc.edu)
- */
+ int fd; /* lock file descriptor
+ * It was, unfortunately, necessary to add this member to the
+ * struct qcam to conveniently implement POSIX fcntl-style locking.
+ * We need a seperate lock file for each struct qcam, for instance,
+ * if the same process (using qcam-lib) is accessing multiple
+ * QuickCams on (of course) multiple ports.
+ * - Dave Plonka (plonka@carroll1.cc.edu)
+ */
};
typedef unsigned char scanbuf;
/* General QuickCam handling routines */
-int qc_getbrightness(const struct qcam *q);
-int qc_setbrightness(struct qcam *q, int val);
-int qc_getcontrast(const struct qcam *q);
-int qc_setcontrast(struct qcam *q, int val);
-int qc_getwhitebal(const struct qcam *q);
-int qc_setwhitebal(struct qcam *q, int val);
-void qc_getresolution(const struct qcam *q, int *x, int *y);
-int qc_setresolution(struct qcam *q, int x, int y);
-int qc_getbitdepth(const struct qcam *q);
-int qc_setbitdepth(struct qcam *q, int val);
-int qc_getheight(const struct qcam *q);
-int qc_setheight(struct qcam *q, int y);
-int qc_getwidth(const struct qcam *q);
-int qc_setwidth(struct qcam *q, int x);
-int qc_gettop(const struct qcam *q);
-int qc_settop(struct qcam *q, int val);
-int qc_getleft(const struct qcam *q);
-int qc_setleft(struct qcam *q, int val);
-int qc_gettransfer_scale(const struct qcam *q);
-int qc_settransfer_scale(struct qcam *q, int val);
-int qc_calibrate(struct qcam *q);
-int qc_forceunidir(struct qcam *q);
-void qc_dump(const struct qcam *q, char *file);
-
-struct qcam *qc_init(void);
-int qc_initfile(struct qcam *q, char *fname);
-int qc_open(struct qcam *q);
-int qc_close(struct qcam *q);
-int qc_detect(const struct qcam *q);
-void qc_reset(struct qcam *q);
-void qc_set(struct qcam *q);
-scanbuf *qc_scan(const struct qcam *q);
-scanbuf *qc_convertscan(struct qcam *q, scanbuf *scan);
-void qc_writepgm(const struct qcam *q, FILE *f, scanbuf *scan);
-void qc_wait(int val);
+int qc_getbrightness (const struct qcam *q);
+int qc_setbrightness (struct qcam *q, int val);
+int qc_getcontrast (const struct qcam *q);
+int qc_setcontrast (struct qcam *q, int val);
+int qc_getwhitebal (const struct qcam *q);
+int qc_setwhitebal (struct qcam *q, int val);
+void qc_getresolution (const struct qcam *q, int *x, int *y);
+int qc_setresolution (struct qcam *q, int x, int y);
+int qc_getbitdepth (const struct qcam *q);
+int qc_setbitdepth (struct qcam *q, int val);
+int qc_getheight (const struct qcam *q);
+int qc_setheight (struct qcam *q, int y);
+int qc_getwidth (const struct qcam *q);
+int qc_setwidth (struct qcam *q, int x);
+int qc_gettop (const struct qcam *q);
+int qc_settop (struct qcam *q, int val);
+int qc_getleft (const struct qcam *q);
+int qc_setleft (struct qcam *q, int val);
+int qc_gettransfer_scale (const struct qcam *q);
+int qc_settransfer_scale (struct qcam *q, int val);
+int qc_calibrate (struct qcam *q);
+int qc_forceunidir (struct qcam *q);
+void qc_dump (const struct qcam *q, char *file);
+
+struct qcam *qc_init (void);
+int qc_initfile (struct qcam *q, char *fname);
+int qc_open (struct qcam *q);
+int qc_close (struct qcam *q);
+int qc_detect (const struct qcam *q);
+void qc_reset (struct qcam *q);
+void qc_set (struct qcam *q);
+scanbuf *qc_scan (const struct qcam *q);
+scanbuf *qc_convertscan (struct qcam *q, scanbuf * scan);
+void qc_writepgm (const struct qcam *q, FILE * f, scanbuf * scan);
+void qc_wait (int val);
/* OS/hardware specific routines */
-int read_lpstatus(const struct qcam *q);
-int read_lpcontrol(const struct qcam *q);
-int read_lpdata(const struct qcam *q);
-void write_lpdata(const struct qcam *q, int d);
-void write_lpcontrol(const struct qcam *q, int d);
-int enable_ports(const struct qcam *q);
-int disable_ports(const struct qcam *q);
-int qc_unlock(struct qcam *q);
-int qc_lock(struct qcam *q);
-void qc_wait(int val);
-int qc_probe(struct qcam *q);
+int read_lpstatus (const struct qcam *q);
+int read_lpcontrol (const struct qcam *q);
+int read_lpdata (const struct qcam *q);
+void write_lpdata (const struct qcam *q, int d);
+void write_lpcontrol (const struct qcam *q, int d);
+int enable_ports (const struct qcam *q);
+int disable_ports (const struct qcam *q);
+int qc_unlock (struct qcam *q);
+int qc_lock (struct qcam *q);
+void qc_wait (int val);
+int qc_probe (struct qcam *q);
/* Image processing routines */
-int fixdark(const struct qcam *q, scanbuf *scan);
-int qc_edge_detect(const struct qcam *q, scanbuf *scan, int tolerance);
+int fixdark (const struct qcam *q, scanbuf * scan);
+int qc_edge_detect (const struct qcam *q, scanbuf * scan, int tolerance);
-#endif /*! _QCAM_H*/
+#endif /*! _QCAM_H */
diff --git a/sys/qcam/qcamip.h b/sys/qcam/qcamip.h
index 3bab6faf..e3bc5c2e 100644
--- a/sys/qcam/qcamip.h
+++ b/sys/qcam/qcamip.h
@@ -55,13 +55,13 @@ SOFTWARE.
/* Prototypes for image processing routines */
-int qcip_autoexposure(struct qcam *q, scanbuf *scan);
-int qcip_set_luminance_target(struct qcam *q, int val);
-int qcip_set_luminance_tolerance(struct qcam *q, int val);
-int qcip_set_luminance_std_target(struct qcam *q, int val);
-int qcip_set_luminance_std_tolerance(struct qcam *q, int val);
-int qcip_set_autoexposure_mode(int val);
-void qcip_histogram(struct qcam *q, scanbuf *scan, int *histogram);
-void qcip_display_histogram(struct qcam *q, scanbuf *scan);
+int qcip_autoexposure (struct qcam *q, scanbuf * scan);
+int qcip_set_luminance_target (struct qcam *q, int val);
+int qcip_set_luminance_tolerance (struct qcam *q, int val);
+int qcip_set_luminance_std_target (struct qcam *q, int val);
+int qcip_set_luminance_std_tolerance (struct qcam *q, int val);
+int qcip_set_autoexposure_mode (int val);
+void qcip_histogram (struct qcam *q, scanbuf * scan, int *histogram);
+void qcip_display_histogram (struct qcam *q, scanbuf * scan);
-#endif /*! _QCAMIP_H*/
+#endif /*! _QCAMIP_H */
diff --git a/sys/v4l2/gstv4l2.c b/sys/v4l2/gstv4l2.c
index dffb3f07..633ce52e 100644
--- a/sys/v4l2/gstv4l2.c
+++ b/sys/v4l2/gstv4l2.c
@@ -29,7 +29,7 @@
#include "gstv4l2src.h"
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* actually, we can survive without it, but I'll create
* that handling later on. */
@@ -37,9 +37,9 @@ plugin_init (GstPlugin *plugin)
return FALSE;
if (!gst_element_register (plugin, "v4l2element",
- GST_RANK_NONE, GST_TYPE_V4L2ELEMENT) ||
+ GST_RANK_NONE, GST_TYPE_V4L2ELEMENT) ||
!gst_element_register (plugin, "v4l2src",
- GST_RANK_NONE, GST_TYPE_V4L2SRC))
+ GST_RANK_NONE, GST_TYPE_V4L2SRC))
return FALSE;
#ifdef ENABLE_NLS
@@ -50,14 +50,8 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "video4linux2",
- "elements for Video 4 Linux 2",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "video4linux2",
+ "elements for Video 4 Linux 2",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
diff --git a/sys/v4l2/gstv4l2colorbalance.c b/sys/v4l2/gstv4l2colorbalance.c
index 0fd18677..274043d8 100644
--- a/sys/v4l2/gstv4l2colorbalance.c
+++ b/sys/v4l2/gstv4l2colorbalance.c
@@ -28,19 +28,17 @@
#include "gstv4l2element.h"
static void
-gst_v4l2_color_balance_channel_class_init(GstV4l2ColorBalanceChannelClass *klass);
-static void
-gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *channel);
-
-static const GList *
-gst_v4l2_color_balance_list_channels (GstColorBalance *balance);
-static void
-gst_v4l2_color_balance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value);
-static gint
-gst_v4l2_color_balance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel);
+gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
+ klass);
+static void gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *
+ channel);
+
+static const GList *gst_v4l2_color_balance_list_channels (GstColorBalance *
+ balance);
+static void gst_v4l2_color_balance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value);
+static gint gst_v4l2_color_balance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel);
static GstColorBalanceChannelClass *parent_class = NULL;
@@ -65,30 +63,30 @@ gst_v4l2_color_balance_channel_get_type (void)
gst_v4l2_color_balance_channel_type =
g_type_register_static (GST_TYPE_COLOR_BALANCE_CHANNEL,
- "GstV4l2ColorBalanceChannel",
- &v4l2_tuner_channel_info, 0);
+ "GstV4l2ColorBalanceChannel", &v4l2_tuner_channel_info, 0);
}
return gst_v4l2_color_balance_channel_type;
}
static void
-gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *klass)
+gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
+ klass)
{
parent_class = g_type_class_ref (GST_TYPE_COLOR_BALANCE_CHANNEL);
}
static void
-gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *channel)
+gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel * channel)
{
channel->index = 0;
}
void
-gst_v4l2_color_balance_interface_init (GstColorBalanceClass *klass)
+gst_v4l2_color_balance_interface_init (GstColorBalanceClass * klass)
{
GST_COLOR_BALANCE_TYPE (klass) = GST_COLOR_BALANCE_HARDWARE;
-
+
/* default virtual functions */
klass->list_channels = gst_v4l2_color_balance_list_channels;
klass->set_value = gst_v4l2_color_balance_set_value;
@@ -96,8 +94,8 @@ gst_v4l2_color_balance_interface_init (GstColorBalanceClass *klass)
}
static gboolean
-gst_v4l2_color_balance_contains_channel (GstV4l2Element *v4l2element,
- GstV4l2ColorBalanceChannel *v4l2channel)
+gst_v4l2_color_balance_contains_channel (GstV4l2Element * v4l2element,
+ GstV4l2ColorBalanceChannel * v4l2channel)
{
const GList *item;
@@ -109,42 +107,40 @@ gst_v4l2_color_balance_contains_channel (GstV4l2Element *v4l2element
}
static const GList *
-gst_v4l2_color_balance_list_channels (GstColorBalance *balance)
+gst_v4l2_color_balance_list_channels (GstColorBalance * balance)
{
return GST_V4L2ELEMENT (balance)->colors;
}
static void
-gst_v4l2_color_balance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value)
+gst_v4l2_color_balance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
GstV4l2ColorBalanceChannel *v4l2channel =
- GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
+ GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
/* assert that we're opened and that we're using a known item */
g_return_if_fail (GST_V4L2_IS_OPEN (v4l2element));
g_return_if_fail (gst_v4l2_color_balance_contains_channel (v4l2element,
- v4l2channel));
+ v4l2channel));
gst_v4l2_set_attribute (v4l2element, v4l2channel->index, value);
}
static gint
-gst_v4l2_color_balance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel)
+gst_v4l2_color_balance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
GstV4l2ColorBalanceChannel *v4l2channel =
- GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
+ GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
gint value;
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
g_return_val_if_fail (gst_v4l2_color_balance_contains_channel (v4l2element,
- v4l2channel),
- 0);
+ v4l2channel), 0);
if (!gst_v4l2_get_attribute (v4l2element, v4l2channel->index, &value))
return 0;
diff --git a/sys/v4l2/gstv4l2colorbalance.h b/sys/v4l2/gstv4l2colorbalance.h
index 4003203b..f0de44ce 100644
--- a/sys/v4l2/gstv4l2colorbalance.h
+++ b/sys/v4l2/gstv4l2colorbalance.h
@@ -27,7 +27,6 @@
#include "v4l2_calls.h"
G_BEGIN_DECLS
-
#define GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL \
(gst_v4l2_color_balance_channel_get_type ())
#define GST_V4L2_COLOR_BALANCE_CHANNEL(obj) \
@@ -40,19 +39,20 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL))
#define GST_IS_V4L2_COLOR_BALANCE_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL))
-
-typedef struct _GstV4l2ColorBalanceChannel {
+ typedef struct _GstV4l2ColorBalanceChannel
+{
GstColorBalanceChannel parent;
guint32 index;
} GstV4l2ColorBalanceChannel;
-typedef struct _GstV4l2ColorBalanceChannelClass {
+typedef struct _GstV4l2ColorBalanceChannelClass
+{
GstColorBalanceChannelClass parent;
} GstV4l2ColorBalanceChannelClass;
-GType gst_v4l2_color_balance_channel_get_type (void);
+GType gst_v4l2_color_balance_channel_get_type (void);
-void gst_v4l2_color_balance_interface_init (GstColorBalanceClass *klass);
+void gst_v4l2_color_balance_interface_init (GstColorBalanceClass * klass);
#endif /* __GST_V4L2_COLOR_BALANCE_H__ */
diff --git a/sys/v4l2/gstv4l2element.c b/sys/v4l2/gstv4l2element.c
index eb12501d..246d4949 100644
--- a/sys/v4l2/gstv4l2element.c
+++ b/sys/v4l2/gstv4l2element.c
@@ -35,21 +35,23 @@
/* elementfactory details */
static GstElementDetails gst_v4l2element_details = {
- "Generic video4linux2 Element",
- "Generic/Video",
- "Generic plugin for handling common video4linux2 calls",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
+ "Generic video4linux2 Element",
+ "Generic/Video",
+ "Generic plugin for handling common video4linux2 calls",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>"
};
/* V4l2Element signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_OPEN,
SIGNAL_CLOSE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_DEVICE,
ARG_DEVICE_NAME,
@@ -60,20 +62,16 @@ enum {
};
-static void gst_v4l2element_class_init (GstV4l2ElementClass *klass);
-static void gst_v4l2element_base_init (GstV4l2ElementClass *klass);
-static void gst_v4l2element_init (GstV4l2Element *v4lelement);
-static void gst_v4l2element_dispose (GObject *object);
-static void gst_v4l2element_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_v4l2element_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_v4l2element_class_init (GstV4l2ElementClass * klass);
+static void gst_v4l2element_base_init (GstV4l2ElementClass * klass);
+static void gst_v4l2element_init (GstV4l2Element * v4lelement);
+static void gst_v4l2element_dispose (GObject * object);
+static void gst_v4l2element_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_v4l2element_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
static GstElementStateReturn
- gst_v4l2element_change_state (GstElement *element);
+gst_v4l2element_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
@@ -81,260 +79,244 @@ static guint gst_v4l2element_signals[LAST_SIGNAL] = { 0 };
static gboolean
-gst_v4l2_iface_supported (GstImplementsInterface *iface,
- GType iface_type)
+gst_v4l2_iface_supported (GstImplementsInterface * iface, GType iface_type)
{
- GstV4l2Element *v4l2element = GST_V4L2ELEMENT (iface);
+ GstV4l2Element *v4l2element = GST_V4L2ELEMENT (iface);
- g_assert (iface_type == GST_TYPE_TUNER ||
- iface_type == GST_TYPE_X_OVERLAY ||
- iface_type == GST_TYPE_COLOR_BALANCE);
+ g_assert (iface_type == GST_TYPE_TUNER ||
+ iface_type == GST_TYPE_X_OVERLAY || iface_type == GST_TYPE_COLOR_BALANCE);
- if (v4l2element->video_fd == -1)
- return FALSE;
+ if (v4l2element->video_fd == -1)
+ return FALSE;
- if (iface_type == GST_TYPE_X_OVERLAY &&
- !GST_V4L2_IS_OVERLAY(v4l2element))
- return FALSE;
+ if (iface_type == GST_TYPE_X_OVERLAY && !GST_V4L2_IS_OVERLAY (v4l2element))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
static void
-gst_v4l2_interface_init (GstImplementsInterfaceClass *klass)
+gst_v4l2_interface_init (GstImplementsInterfaceClass * klass)
{
- /* default virtual functions */
- klass->supported = gst_v4l2_iface_supported;
+ /* default virtual functions */
+ klass->supported = gst_v4l2_iface_supported;
}
static const GList *
-gst_v4l2_probe_get_properties (GstPropertyProbe *probe)
+gst_v4l2_probe_get_properties (GstPropertyProbe * probe)
{
- GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
- static GList *list = NULL;
+ GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
+ static GList *list = NULL;
- if (!list) {
- list = g_list_append (NULL,
- g_object_class_find_property (klass, "device"));
- }
+ if (!list) {
+ list = g_list_append (NULL, g_object_class_find_property (klass, "device"));
+ }
- return list;
+ return list;
}
static gboolean
-gst_v4l2_class_probe_devices (GstV4l2ElementClass *klass,
- gboolean check)
+gst_v4l2_class_probe_devices (GstV4l2ElementClass * klass, gboolean check)
{
- static gboolean init = FALSE;
- static GList *devices = NULL;
-
- if (!init && !check) {
- gchar *dev_base[] = { "/dev/video", "/dev/v4l/video", NULL };
- gint base, n, fd;
-
- while (devices) {
- GList *item = devices;
- gchar *device = item->data;
-
- devices = g_list_remove (devices, item);
- g_free (device);
- }
-
- /* detect /dev entries */
- for (n = 0; n < 64; n++) {
- for (base = 0; dev_base[base] != NULL; base++) {
- struct stat s;
- gchar *device = g_strdup_printf ("%s%d",
- dev_base[base], n);
-
- /* does the /dev/ entry exist at all? */
- if (stat (device, &s) == 0) {
- /* yes: is a device attached? */
- if ((fd = open (device, O_RDONLY)) > 0 ||
- errno == EBUSY) {
- if (fd > 0)
- close (fd);
-
- devices =
- g_list_append (devices,
- device);
- break;
- }
- }
- g_free (device);
- }
- }
-
- init = TRUE;
+ static gboolean init = FALSE;
+ static GList *devices = NULL;
+
+ if (!init && !check) {
+ gchar *dev_base[] = { "/dev/video", "/dev/v4l/video", NULL };
+ gint base, n, fd;
+
+ while (devices) {
+ GList *item = devices;
+ gchar *device = item->data;
+
+ devices = g_list_remove (devices, item);
+ g_free (device);
+ }
+
+ /* detect /dev entries */
+ for (n = 0; n < 64; n++) {
+ for (base = 0; dev_base[base] != NULL; base++) {
+ struct stat s;
+ gchar *device = g_strdup_printf ("%s%d",
+ dev_base[base], n);
+
+ /* does the /dev/ entry exist at all? */
+ if (stat (device, &s) == 0) {
+ /* yes: is a device attached? */
+ if ((fd = open (device, O_RDONLY)) > 0 || errno == EBUSY) {
+ if (fd > 0)
+ close (fd);
+
+ devices = g_list_append (devices, device);
+ break;
+ }
}
+ g_free (device);
+ }
+ }
- klass->devices = devices;
+ init = TRUE;
+ }
- return init;
+ klass->devices = devices;
+
+ return init;
}
static void
-gst_v4l2_probe_probe_property (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l2_probe_probe_property (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
- GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
-
- switch (prop_id) {
- case ARG_DEVICE:
- gst_v4l2_class_probe_devices (klass, FALSE);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- break;
- }
+ GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
+
+ switch (prop_id) {
+ case ARG_DEVICE:
+ gst_v4l2_class_probe_devices (klass, FALSE);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
+ break;
+ }
}
static gboolean
-gst_v4l2_probe_needs_probe (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l2_probe_needs_probe (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
- GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
- gboolean ret = FALSE;
-
- switch (prop_id) {
- case ARG_DEVICE:
- ret = !gst_v4l2_class_probe_devices (klass, TRUE);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- break;
- }
+ GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
+ gboolean ret = FALSE;
- return ret;
+ switch (prop_id) {
+ case ARG_DEVICE:
+ ret = !gst_v4l2_class_probe_devices (klass, TRUE);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
+ break;
+ }
+
+ return ret;
}
static GValueArray *
-gst_v4l2_class_list_devices (GstV4l2ElementClass *klass)
+gst_v4l2_class_list_devices (GstV4l2ElementClass * klass)
{
- GValueArray *array;
- GValue value = { 0 };
- GList *item;
+ GValueArray *array;
+ GValue value = { 0 };
+ GList *item;
- if (!klass->devices)
- return NULL;
+ if (!klass->devices)
+ return NULL;
- array = g_value_array_new (g_list_length (klass->devices));
- item = klass->devices;
- g_value_init (&value, G_TYPE_STRING);
- while (item) {
- gchar *device = item->data;
+ array = g_value_array_new (g_list_length (klass->devices));
+ item = klass->devices;
+ g_value_init (&value, G_TYPE_STRING);
+ while (item) {
+ gchar *device = item->data;
- g_value_set_string (&value, device);
- g_value_array_append (array, &value);
+ g_value_set_string (&value, device);
+ g_value_array_append (array, &value);
- item = item->next;
- }
- g_value_unset (&value);
+ item = item->next;
+ }
+ g_value_unset (&value);
- return array;
+ return array;
}
static GValueArray *
-gst_v4l2_probe_get_values (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l2_probe_get_values (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
- GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
- GValueArray *array = NULL;
-
- switch (prop_id) {
- case ARG_DEVICE:
- array = gst_v4l2_class_list_devices (klass);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- break;
- }
+ GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
+ GValueArray *array = NULL;
+
+ switch (prop_id) {
+ case ARG_DEVICE:
+ array = gst_v4l2_class_list_devices (klass);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
+ break;
+ }
- return array;
+ return array;
}
static void
-gst_v4l2_property_probe_interface_init (GstPropertyProbeInterface *iface)
+gst_v4l2_property_probe_interface_init (GstPropertyProbeInterface * iface)
{
- iface->get_properties = gst_v4l2_probe_get_properties;
- iface->probe_property = gst_v4l2_probe_probe_property;
- iface->needs_probe = gst_v4l2_probe_needs_probe;
- iface->get_values = gst_v4l2_probe_get_values;
+ iface->get_properties = gst_v4l2_probe_get_properties;
+ iface->probe_property = gst_v4l2_probe_probe_property;
+ iface->needs_probe = gst_v4l2_probe_needs_probe;
+ iface->get_values = gst_v4l2_probe_get_values;
}
GType
gst_v4l2element_get_type (void)
{
- static GType v4l2element_type = 0;
-
- if (!v4l2element_type) {
- static const GTypeInfo v4l2element_info = {
- sizeof(GstV4l2ElementClass),
- (GBaseInitFunc) gst_v4l2element_base_init,
- NULL,
- (GClassInitFunc) gst_v4l2element_class_init,
- NULL,
- NULL,
- sizeof(GstV4l2Element),
- 0,
- (GInstanceInitFunc) gst_v4l2element_init,
- NULL
- };
- static const GInterfaceInfo v4l2iface_info = {
- (GInterfaceInitFunc) gst_v4l2_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_tuner_info = {
- (GInterfaceInitFunc) gst_v4l2_tuner_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_xoverlay_info = {
- (GInterfaceInitFunc) gst_v4l2_xoverlay_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_colorbalance_info = {
- (GInterfaceInitFunc) gst_v4l2_color_balance_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_propertyprobe_info = {
- (GInterfaceInitFunc) gst_v4l2_property_probe_interface_init,
- NULL,
- NULL,
- };
-
- v4l2element_type =
- g_type_register_static(GST_TYPE_ELEMENT,
- "GstV4l2Element", &v4l2element_info, 0);
-
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_IMPLEMENTS_INTERFACE,
- &v4l2iface_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_TUNER,
- &v4l2_tuner_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_X_OVERLAY,
- &v4l2_xoverlay_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_COLOR_BALANCE,
- &v4l2_colorbalance_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_PROPERTY_PROBE,
- &v4l2_propertyprobe_info);
- }
+ static GType v4l2element_type = 0;
+
+ if (!v4l2element_type) {
+ static const GTypeInfo v4l2element_info = {
+ sizeof (GstV4l2ElementClass),
+ (GBaseInitFunc) gst_v4l2element_base_init,
+ NULL,
+ (GClassInitFunc) gst_v4l2element_class_init,
+ NULL,
+ NULL,
+ sizeof (GstV4l2Element),
+ 0,
+ (GInstanceInitFunc) gst_v4l2element_init,
+ NULL
+ };
+ static const GInterfaceInfo v4l2iface_info = {
+ (GInterfaceInitFunc) gst_v4l2_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_tuner_info = {
+ (GInterfaceInitFunc) gst_v4l2_tuner_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_xoverlay_info = {
+ (GInterfaceInitFunc) gst_v4l2_xoverlay_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_colorbalance_info = {
+ (GInterfaceInitFunc) gst_v4l2_color_balance_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_propertyprobe_info = {
+ (GInterfaceInitFunc) gst_v4l2_property_probe_interface_init,
+ NULL,
+ NULL,
+ };
+
+ v4l2element_type =
+ g_type_register_static (GST_TYPE_ELEMENT,
+ "GstV4l2Element", &v4l2element_info, 0);
+
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_IMPLEMENTS_INTERFACE, &v4l2iface_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_TUNER, &v4l2_tuner_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_X_OVERLAY, &v4l2_xoverlay_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_COLOR_BALANCE, &v4l2_colorbalance_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_PROPERTY_PROBE, &v4l2_propertyprobe_info);
+ }
- return v4l2element_type;
+ return v4l2element_type;
}
@@ -342,80 +324,78 @@ gst_v4l2element_get_type (void)
GType
gst_v4l2_device_get_type (void)
{
- static GType v4l2_device_type = 0;
-
- if (v4l2_device_type == 0) {
- static const GFlagsValue values[] = {
- { V4L2_CAP_VIDEO_CAPTURE, "CAPTURE",
- "Device can capture" },
- { V4L2_CAP_VIDEO_OUTPUT, "PLAYBACK",
- "Device can playback" },
- { V4L2_CAP_VIDEO_OVERLAY, "OVERLAY",
- "Device can do overlay" },
- { V4L2_CAP_TUNER, "TUNER",
- "Device has a tuner" },
- { V4L2_CAP_AUDIO, "AUDIO",
- "Device handles audio" },
- { 0, NULL, NULL }
- };
-
- v4l2_device_type =
- g_flags_register_static ("GstV4l2DeviceTypeFlags",
- values);
- }
+ static GType v4l2_device_type = 0;
+
+ if (v4l2_device_type == 0) {
+ static const GFlagsValue values[] = {
+ {V4L2_CAP_VIDEO_CAPTURE, "CAPTURE",
+ "Device can capture"},
+ {V4L2_CAP_VIDEO_OUTPUT, "PLAYBACK",
+ "Device can playback"},
+ {V4L2_CAP_VIDEO_OVERLAY, "OVERLAY",
+ "Device can do overlay"},
+ {V4L2_CAP_TUNER, "TUNER",
+ "Device has a tuner"},
+ {V4L2_CAP_AUDIO, "AUDIO",
+ "Device handles audio"},
+ {0, NULL, NULL}
+ };
+
+ v4l2_device_type =
+ g_flags_register_static ("GstV4l2DeviceTypeFlags", values);
+ }
- return v4l2_device_type;
+ return v4l2_device_type;
}
static void
-gst_v4l2element_base_init (GstV4l2ElementClass *klass)
+gst_v4l2element_base_init (GstV4l2ElementClass * klass)
{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
- klass->devices = NULL;
+ klass->devices = NULL;
- gst_element_class_set_details (gstelement_class,
- &gst_v4l2element_details);
+ gst_element_class_set_details (gstelement_class, &gst_v4l2element_details);
}
static void
-gst_v4l2element_class_init (GstV4l2ElementClass *klass)
+gst_v4l2element_class_init (GstV4l2ElementClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
- g_object_class_install_property(gobject_class, ARG_DEVICE,
- g_param_spec_string("device", "Device", "Device location",
- NULL, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_DEVICE_NAME,
- g_param_spec_string("device_name", "Device name",
- "Name of the device", NULL, G_PARAM_READABLE));
- g_object_class_install_property(gobject_class, ARG_FLAGS,
- g_param_spec_flags("flags", "Flags", "Device type flags",
- GST_TYPE_V4L2_DEVICE_FLAGS, 0, G_PARAM_READABLE));
- g_object_class_install_property(gobject_class, ARG_NORM,
- g_param_spec_string("norm", "norm",
- "Norm to use", NULL, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_CHANNEL,
- g_param_spec_string("channel", "channel",
- "input/output to switch to", NULL, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_FREQUENCY,
+ g_object_class_install_property (gobject_class, ARG_DEVICE,
+ g_param_spec_string ("device", "Device", "Device location",
+ NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_DEVICE_NAME,
+ g_param_spec_string ("device_name", "Device name",
+ "Name of the device", NULL, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, ARG_FLAGS,
+ g_param_spec_flags ("flags", "Flags", "Device type flags",
+ GST_TYPE_V4L2_DEVICE_FLAGS, 0, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, ARG_NORM,
+ g_param_spec_string ("norm", "norm",
+ "Norm to use", NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_CHANNEL,
+ g_param_spec_string ("channel", "channel",
+ "input/output to switch to", NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_FREQUENCY,
g_param_spec_ulong ("frequency", "frequency",
"frequency to tune to", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
/* signals */
gst_v4l2element_signals[SIGNAL_OPEN] =
- g_signal_new("open", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2ElementClass, open),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("open", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4l2ElementClass, open),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
gst_v4l2element_signals[SIGNAL_CLOSE] =
- g_signal_new("close", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2ElementClass, close),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("close", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4l2ElementClass, close),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
gobject_class->set_property = gst_v4l2element_set_property;
gobject_class->get_property = gst_v4l2element_get_property;
@@ -426,29 +406,29 @@ gst_v4l2element_class_init (GstV4l2ElementClass *klass)
static void
-gst_v4l2element_init (GstV4l2Element *v4l2element)
+gst_v4l2element_init (GstV4l2Element * v4l2element)
{
- /* some default values */
- v4l2element->video_fd = -1;
- v4l2element->buffer = NULL;
- v4l2element->device = g_strdup("/dev/video");
- v4l2element->display = g_strdup(g_getenv("DISPLAY"));
+ /* some default values */
+ v4l2element->video_fd = -1;
+ v4l2element->buffer = NULL;
+ v4l2element->device = g_strdup ("/dev/video");
+ v4l2element->display = g_strdup (g_getenv ("DISPLAY"));
- v4l2element->channels = NULL;
- v4l2element->norms = NULL;
- v4l2element->colors = NULL;
+ v4l2element->channels = NULL;
+ v4l2element->norms = NULL;
+ v4l2element->colors = NULL;
- v4l2element->overlay = gst_v4l2_xoverlay_new(v4l2element);
+ v4l2element->overlay = gst_v4l2_xoverlay_new (v4l2element);
}
static void
-gst_v4l2element_dispose (GObject *object)
+gst_v4l2element_dispose (GObject * object)
{
- GstV4l2Element *v4l2element = GST_V4L2ELEMENT(object);
+ GstV4l2Element *v4l2element = GST_V4L2ELEMENT (object);
if (v4l2element->overlay) {
- gst_v4l2_xoverlay_free(v4l2element);
+ gst_v4l2_xoverlay_free (v4l2element);
}
if (v4l2element->display) {
@@ -461,37 +441,36 @@ gst_v4l2element_dispose (GObject *object)
v4l2element->norm = NULL;
g_free (v4l2element->channel);
v4l2element->channel = NULL;
-
+
if (((GObjectClass *) parent_class)->dispose)
- ((GObjectClass *) parent_class)->dispose(object);
+ ((GObjectClass *) parent_class)->dispose (object);
}
static void
-gst_v4l2element_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_v4l2element_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstV4l2Element *v4l2element;
GstTuner *tuner;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_V4L2ELEMENT (object));
v4l2element = GST_V4L2ELEMENT (object);
/* stupid GstInterface */
tuner = (GstTuner *) object;
-
+
switch (prop_id) {
case ARG_DEVICE:
- if (!GST_V4L2_IS_OPEN(v4l2element)) {
+ if (!GST_V4L2_IS_OPEN (v4l2element)) {
if (v4l2element->device)
- g_free(v4l2element->device);
- v4l2element->device = g_value_dup_string(value);
+ g_free (v4l2element->device);
+ v4l2element->device = g_value_dup_string (value);
}
break;
case ARG_NORM:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
GstTunerNorm *norm = gst_tuner_get_norm (tuner);
+
if (norm) {
gst_tuner_set_norm (tuner, norm);
}
@@ -502,8 +481,9 @@ gst_v4l2element_set_property (GObject *object,
}
break;
case ARG_CHANNEL:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
GstTunerChannel *channel = gst_tuner_get_channel (tuner);
+
if (channel) {
gst_tuner_set_channel (tuner, channel);
}
@@ -514,9 +494,11 @@ gst_v4l2element_set_property (GObject *object,
}
break;
case ARG_FREQUENCY:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
GstTunerChannel *channel;
- if (!v4l2element->channel) return;
+
+ if (!v4l2element->channel)
+ return;
channel = gst_tuner_get_channel (tuner);
g_assert (channel);
gst_tuner_set_frequency (tuner, channel, g_value_get_ulong (value));
@@ -533,94 +515,91 @@ gst_v4l2element_set_property (GObject *object,
static void
-gst_v4l2element_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_v4l2element_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstV4l2Element *v4l2element;
-
- /* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_V4L2ELEMENT(object));
- v4l2element = GST_V4L2ELEMENT(object);
-
- switch (prop_id) {
- case ARG_DEVICE:
- g_value_set_string(value, v4l2element->device);
- break;
- case ARG_DEVICE_NAME: {
- gchar *new = NULL;
- if (GST_V4L2_IS_OPEN(v4l2element))
- new = v4l2element->vcap.card;
- g_value_set_string(value, new);
- break;
- }
- case ARG_FLAGS: {
- guint flags = 0;
- if (GST_V4L2_IS_OPEN(v4l2element)) {
- flags |= v4l2element->vcap.capabilities &
- 30007;
- }
- g_value_set_flags(value, flags);
- break;
- }
- case ARG_NORM:
- g_value_set_string (value, v4l2element->norm);
- break;
- case ARG_CHANNEL:
- g_value_set_string (value, v4l2element->channel);
- break;
- case ARG_FREQUENCY:
- g_value_set_ulong (value, v4l2element->frequency);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
+ GstV4l2Element *v4l2element;
+
+ /* it's not null if we got it, but it might not be ours */
+ g_return_if_fail (GST_IS_V4L2ELEMENT (object));
+ v4l2element = GST_V4L2ELEMENT (object);
+
+ switch (prop_id) {
+ case ARG_DEVICE:
+ g_value_set_string (value, v4l2element->device);
+ break;
+ case ARG_DEVICE_NAME:{
+ gchar *new = NULL;
+
+ if (GST_V4L2_IS_OPEN (v4l2element))
+ new = v4l2element->vcap.card;
+ g_value_set_string (value, new);
+ break;
+ }
+ case ARG_FLAGS:{
+ guint flags = 0;
+
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
+ flags |= v4l2element->vcap.capabilities & 30007;
+ }
+ g_value_set_flags (value, flags);
+ break;
+ }
+ case ARG_NORM:
+ g_value_set_string (value, v4l2element->norm);
+ break;
+ case ARG_CHANNEL:
+ g_value_set_string (value, v4l2element->channel);
+ break;
+ case ARG_FREQUENCY:
+ g_value_set_ulong (value, v4l2element->frequency);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GstElementStateReturn
-gst_v4l2element_change_state (GstElement *element)
+gst_v4l2element_change_state (GstElement * element)
{
- GstV4l2Element *v4l2element;
-
- g_return_val_if_fail(GST_IS_V4L2ELEMENT(element), GST_STATE_FAILURE);
-
- v4l2element = GST_V4L2ELEMENT(element);
-
- /* if going down into NULL state, close the device if it's open
- * if going to READY, open the device (and set some options)
- */
- switch (GST_STATE_TRANSITION(element)) {
- case GST_STATE_NULL_TO_READY:
- gst_v4l2_set_display(v4l2element);
-
- if (!gst_v4l2_open(v4l2element))
- return GST_STATE_FAILURE;
-
- gst_v4l2_xoverlay_open(v4l2element);
-
- /* emit a signal! whoopie! */
- g_signal_emit(G_OBJECT(v4l2element),
- gst_v4l2element_signals[SIGNAL_OPEN], 0,
- v4l2element->device);
- break;
- case GST_STATE_READY_TO_NULL:
- gst_v4l2_xoverlay_close(v4l2element);
-
- if (!gst_v4l2_close(v4l2element))
- return GST_STATE_FAILURE;
-
- /* emit yet another signal! wheehee! */
- g_signal_emit(G_OBJECT(v4l2element),
- gst_v4l2element_signals[SIGNAL_CLOSE], 0,
- v4l2element->device);
- break;
- }
+ GstV4l2Element *v4l2element;
+
+ g_return_val_if_fail (GST_IS_V4L2ELEMENT (element), GST_STATE_FAILURE);
+
+ v4l2element = GST_V4L2ELEMENT (element);
+
+ /* if going down into NULL state, close the device if it's open
+ * if going to READY, open the device (and set some options)
+ */
+ switch (GST_STATE_TRANSITION (element)) {
+ case GST_STATE_NULL_TO_READY:
+ gst_v4l2_set_display (v4l2element);
+
+ if (!gst_v4l2_open (v4l2element))
+ return GST_STATE_FAILURE;
+
+ gst_v4l2_xoverlay_open (v4l2element);
+
+ /* emit a signal! whoopie! */
+ g_signal_emit (G_OBJECT (v4l2element),
+ gst_v4l2element_signals[SIGNAL_OPEN], 0, v4l2element->device);
+ break;
+ case GST_STATE_READY_TO_NULL:
+ gst_v4l2_xoverlay_close (v4l2element);
+
+ if (!gst_v4l2_close (v4l2element))
+ return GST_STATE_FAILURE;
+
+ /* emit yet another signal! wheehee! */
+ g_signal_emit (G_OBJECT (v4l2element),
+ gst_v4l2element_signals[SIGNAL_CLOSE], 0, v4l2element->device);
+ break;
+ }
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- return GST_STATE_SUCCESS;
+ return GST_STATE_SUCCESS;
}
diff --git a/sys/v4l2/gstv4l2element.h b/sys/v4l2/gstv4l2element.h
index e46b2440..7dcd6846 100644
--- a/sys/v4l2/gstv4l2element.h
+++ b/sys/v4l2/gstv4l2element.h
@@ -55,53 +55,53 @@
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_V4L2ELEMENT, GstV4l2ElementClass))
-typedef struct _GstV4l2Element GstV4l2Element;
-typedef struct _GstV4l2ElementClass GstV4l2ElementClass;
+typedef struct _GstV4l2Element GstV4l2Element;
+typedef struct _GstV4l2ElementClass GstV4l2ElementClass;
-struct _GstV4l2Element {
- GstElement element;
+struct _GstV4l2Element
+{
+ GstElement element;
- /* the video device */
- char *device;
+ /* the video device */
+ char *device;
- /* the video-device's file descriptor */
- gint video_fd;
+ /* the video-device's file descriptor */
+ gint video_fd;
- /* the video buffer (mmap()'ed) */
- guint8 **buffer;
+ /* the video buffer (mmap()'ed) */
+ guint8 **buffer;
- /* the video-device's capabilities */
- struct v4l2_capability vcap;
+ /* the video-device's capabilities */
+ struct v4l2_capability vcap;
- /* the toys available to us */
- GList *channels;
- GList *norms;
- GList *colors;
+ /* the toys available to us */
+ GList *channels;
+ GList *norms;
+ GList *colors;
- /* X-overlay */
- GstXWindowListener *overlay;
- XID xwindow_id;
+ /* X-overlay */
+ GstXWindowListener *overlay;
+ XID xwindow_id;
- /* properties */
- gchar *norm;
- gchar *channel;
- gulong frequency;
+ /* properties */
+ gchar *norm;
+ gchar *channel;
+ gulong frequency;
- /* caching values */
- gchar *display;
+ /* caching values */
+ gchar *display;
};
-struct _GstV4l2ElementClass {
- GstElementClass parent_class;
+struct _GstV4l2ElementClass
+{
+ GstElementClass parent_class;
- /* probed devices */
- GList *devices;
+ /* probed devices */
+ GList *devices;
- /* signals */
- void (*open) (GstElement *element,
- const gchar *device);
- void (*close) (GstElement *element,
- const gchar *device);
+ /* signals */
+ void (*open) (GstElement * element, const gchar * device);
+ void (*close) (GstElement * element, const gchar * device);
};
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index 8b0abe1a..5e5cdddc 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -31,115 +31,102 @@ GST_DEBUG_CATEGORY (v4l2src_debug);
/* elementfactory details */
static GstElementDetails gst_v4l2src_details = {
- "Video (video4linux2) Source",
- "Source/Video",
- "Reads frames (compressed or uncompressed) from a video4linux2 device",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
+ "Video (video4linux2) Source",
+ "Source/Video",
+ "Reads frames (compressed or uncompressed) from a video4linux2 device",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>"
};
/* V4l2Src signals and args */
-enum {
- SIGNAL_FRAME_CAPTURE,
- SIGNAL_FRAME_DROP,
- SIGNAL_FRAME_INSERT,
- SIGNAL_FRAME_LOST,
- LAST_SIGNAL
+enum
+{
+ SIGNAL_FRAME_CAPTURE,
+ SIGNAL_FRAME_DROP,
+ SIGNAL_FRAME_INSERT,
+ SIGNAL_FRAME_LOST,
+ LAST_SIGNAL
};
/* arguments */
-enum {
- ARG_0,
- ARG_NUMBUFS,
- ARG_BUFSIZE,
- ARG_USE_FIXED_FPS
+enum
+{
+ ARG_0,
+ ARG_NUMBUFS,
+ ARG_BUFSIZE,
+ ARG_USE_FIXED_FPS
};
guint32 gst_v4l2_formats[] = {
/* from Linux 2.6.0 videodev2.h */
- V4L2_PIX_FMT_RGB332, /* 8 RGB-3-3-2 */
- V4L2_PIX_FMT_RGB555, /* 16 RGB-5-5-5 */
- V4L2_PIX_FMT_RGB565, /* 16 RGB-5-6-5 */
- V4L2_PIX_FMT_RGB555X, /* 16 RGB-5-5-5 BE */
- V4L2_PIX_FMT_RGB565X, /* 16 RGB-5-6-5 BE */
- V4L2_PIX_FMT_BGR24, /* 24 BGR-8-8-8 */
- V4L2_PIX_FMT_RGB24, /* 24 RGB-8-8-8 */
- V4L2_PIX_FMT_BGR32, /* 32 BGR-8-8-8-8 */
- V4L2_PIX_FMT_RGB32, /* 32 RGB-8-8-8-8 */
- V4L2_PIX_FMT_GREY, /* 8 Greyscale */
- V4L2_PIX_FMT_YVU410, /* 9 YVU 4:1:0 */
- V4L2_PIX_FMT_YVU420, /* 12 YVU 4:2:0 */
- V4L2_PIX_FMT_YUYV, /* 16 YUV 4:2:2 */
- V4L2_PIX_FMT_UYVY, /* 16 YUV 4:2:2 */
- V4L2_PIX_FMT_YUV422P, /* 16 YVU422 planar */
- V4L2_PIX_FMT_YUV411P, /* 16 YVU411 planar */
- V4L2_PIX_FMT_Y41P, /* 12 YUV 4:1:1 */
- V4L2_PIX_FMT_NV12, /* 12 Y/CbCr 4:2:0 */
- V4L2_PIX_FMT_NV21, /* 12 Y/CrCb 4:2:0 */
- V4L2_PIX_FMT_YUV410, /* 9 YUV 4:1:0 */
- V4L2_PIX_FMT_YUV420, /* 12 YUV 4:2:0 */
- V4L2_PIX_FMT_YYUV, /* 16 YUV 4:2:2 */
- V4L2_PIX_FMT_HI240, /* 8 8-bit color */
- V4L2_PIX_FMT_MJPEG, /* Motion-JPEG */
- V4L2_PIX_FMT_JPEG, /* JFIF JPEG */
- V4L2_PIX_FMT_DV, /* 1394 */
- V4L2_PIX_FMT_MPEG, /* MPEG */
- V4L2_PIX_FMT_WNVA /* Winnov hw compres */
+ V4L2_PIX_FMT_RGB332, /* 8 RGB-3-3-2 */
+ V4L2_PIX_FMT_RGB555, /* 16 RGB-5-5-5 */
+ V4L2_PIX_FMT_RGB565, /* 16 RGB-5-6-5 */
+ V4L2_PIX_FMT_RGB555X, /* 16 RGB-5-5-5 BE */
+ V4L2_PIX_FMT_RGB565X, /* 16 RGB-5-6-5 BE */
+ V4L2_PIX_FMT_BGR24, /* 24 BGR-8-8-8 */
+ V4L2_PIX_FMT_RGB24, /* 24 RGB-8-8-8 */
+ V4L2_PIX_FMT_BGR32, /* 32 BGR-8-8-8-8 */
+ V4L2_PIX_FMT_RGB32, /* 32 RGB-8-8-8-8 */
+ V4L2_PIX_FMT_GREY, /* 8 Greyscale */
+ V4L2_PIX_FMT_YVU410, /* 9 YVU 4:1:0 */
+ V4L2_PIX_FMT_YVU420, /* 12 YVU 4:2:0 */
+ V4L2_PIX_FMT_YUYV, /* 16 YUV 4:2:2 */
+ V4L2_PIX_FMT_UYVY, /* 16 YUV 4:2:2 */
+ V4L2_PIX_FMT_YUV422P, /* 16 YVU422 planar */
+ V4L2_PIX_FMT_YUV411P, /* 16 YVU411 planar */
+ V4L2_PIX_FMT_Y41P, /* 12 YUV 4:1:1 */
+ V4L2_PIX_FMT_NV12, /* 12 Y/CbCr 4:2:0 */
+ V4L2_PIX_FMT_NV21, /* 12 Y/CrCb 4:2:0 */
+ V4L2_PIX_FMT_YUV410, /* 9 YUV 4:1:0 */
+ V4L2_PIX_FMT_YUV420, /* 12 YUV 4:2:0 */
+ V4L2_PIX_FMT_YYUV, /* 16 YUV 4:2:2 */
+ V4L2_PIX_FMT_HI240, /* 8 8-bit color */
+ V4L2_PIX_FMT_MJPEG, /* Motion-JPEG */
+ V4L2_PIX_FMT_JPEG, /* JFIF JPEG */
+ V4L2_PIX_FMT_DV, /* 1394 */
+ V4L2_PIX_FMT_MPEG, /* MPEG */
+ V4L2_PIX_FMT_WNVA /* Winnov hw compres */
};
+
#define GST_V4L2_FORMAT_COUNT (G_N_ELEMENTS (gst_v4l2_formats))
GST_FORMATS_FUNCTION (GstPad *, gst_v4l2src_get_formats,
- GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
+ GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
GST_QUERY_TYPE_FUNCTION (GstPad *, gst_v4l2src_get_query_types,
- GST_QUERY_POSITION);
+ GST_QUERY_POSITION);
/* init functions */
-static void gst_v4l2src_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_v4l2src_base_init (gpointer g_class);
-static void gst_v4l2src_init (GTypeInstance * instance,
- gpointer g_class);
+static void gst_v4l2src_class_init (gpointer g_class, gpointer class_data);
+static void gst_v4l2src_base_init (gpointer g_class);
+static void gst_v4l2src_init (GTypeInstance * instance, gpointer g_class);
/* signal functions */
-static void gst_v4l2src_open (GstElement *element,
- const gchar *device);
-static void gst_v4l2src_close (GstElement *element,
- const gchar *device);
+static void gst_v4l2src_open (GstElement * element, const gchar * device);
+static void gst_v4l2src_close (GstElement * element, const gchar * device);
/* pad/buffer functions */
-static const GstCaps * gst_v4l2src_get_all_caps (void);
-static GstPadLinkReturn gst_v4l2src_link (GstPad *pad,
- const GstCaps *caps);
-static GstCaps * gst_v4l2src_getcaps (GstPad *pad);
-static GstCaps * gst_v4l2src_fixate (GstPad * pad,
- const GstCaps * caps);
-static GstData * gst_v4l2src_get (GstPad *pad);
-static gboolean gst_v4l2src_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static gboolean gst_v4l2src_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value);
+static const GstCaps *gst_v4l2src_get_all_caps (void);
+static GstPadLinkReturn gst_v4l2src_link (GstPad * pad, const GstCaps * caps);
+static GstCaps *gst_v4l2src_getcaps (GstPad * pad);
+static GstCaps *gst_v4l2src_fixate (GstPad * pad, const GstCaps * caps);
+static GstData *gst_v4l2src_get (GstPad * pad);
+static gboolean gst_v4l2src_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_v4l2src_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
/* get/set params */
-static void gst_v4l2src_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_v4l2src_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_v4l2src_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_v4l2src_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
/* state handling */
-static GstElementStateReturn
- gst_v4l2src_change_state (GstElement *element);
+static GstElementStateReturn gst_v4l2src_change_state (GstElement * element);
/* set_clock function for A/V sync */
-static void gst_v4l2src_set_clock (GstElement *element,
- GstClock *clock);
+static void gst_v4l2src_set_clock (GstElement * element, GstClock * clock);
static GstElementClass *parent_class = NULL;
static guint gst_v4l2src_signals[LAST_SIGNAL] = { 0 };
@@ -163,7 +150,7 @@ gst_v4l2src_get_type (void)
gst_v4l2src_init,
NULL
};
- v4l2src_type = g_type_register_static(GST_TYPE_V4L2ELEMENT,
+ v4l2src_type = g_type_register_static (GST_TYPE_V4L2ELEMENT,
"GstV4l2Src", &v4l2src_info, 0);
GST_DEBUG_CATEGORY_INIT (v4l2src_debug, "v4l2src", 0, "v4l2src element");
}
@@ -175,7 +162,7 @@ gst_v4l2src_base_init (gpointer g_class)
{
GstPadTemplate *template;
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_v4l2src_details);
template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
@@ -196,40 +183,36 @@ gst_v4l2src_class_init (gpointer g_class, gpointer class_data)
gobject_class->set_property = gst_v4l2src_set_property;
gobject_class->get_property = gst_v4l2src_get_property;
- g_object_class_install_property(gobject_class, ARG_NUMBUFS,
- g_param_spec_int("num_buffers","num_buffers","num_buffers",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_BUFSIZE,
- g_param_spec_int("buffer_size","buffer_size","buffer_size",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, ARG_NUMBUFS,
+ g_param_spec_int ("num_buffers", "num_buffers", "num_buffers",
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_BUFSIZE,
+ g_param_spec_int ("buffer_size", "buffer_size", "buffer_size",
+ G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
- g_object_class_install_property(gobject_class, ARG_USE_FIXED_FPS,
- g_param_spec_boolean("use_fixed_fps", "Use Fixed FPS",
- "Drop/Insert frames to reach a certain FPS (TRUE) "
- "or adapt FPS to suit the number of frabbed frames",
- TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_USE_FIXED_FPS,
+ g_param_spec_boolean ("use_fixed_fps", "Use Fixed FPS",
+ "Drop/Insert frames to reach a certain FPS (TRUE) "
+ "or adapt FPS to suit the number of frabbed frames",
+ TRUE, G_PARAM_READWRITE));
/* signals */
gst_v4l2src_signals[SIGNAL_FRAME_CAPTURE] =
- g_signal_new("frame-capture", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_capture),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-capture", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_capture), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4l2src_signals[SIGNAL_FRAME_DROP] =
- g_signal_new("frame-drop", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_drop),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-drop", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_drop), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4l2src_signals[SIGNAL_FRAME_INSERT] =
- g_signal_new("frame_insert", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_insert),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame_insert", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_insert), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4l2src_signals[SIGNAL_FRAME_LOST] =
- g_signal_new("frame-lost", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_lost),
- NULL, NULL, g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("frame-lost", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_lost), NULL,
+ NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gstelement_class->change_state = gst_v4l2src_change_state;
@@ -241,24 +224,26 @@ gst_v4l2src_class_init (gpointer g_class, gpointer class_data)
static void
-gst_v4l2src_init (GTypeInstance *instance, gpointer g_class)
+gst_v4l2src_init (GTypeInstance * instance, gpointer g_class)
{
GstV4l2Src *v4l2src = GST_V4L2SRC (instance);
-
- GST_FLAG_SET(GST_ELEMENT(v4l2src), GST_ELEMENT_THREAD_SUGGESTED);
- v4l2src->srcpad = gst_pad_new_from_template(
- gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (v4l2src), "src"), "src");
- gst_element_add_pad(GST_ELEMENT(v4l2src), v4l2src->srcpad);
+ GST_FLAG_SET (GST_ELEMENT (v4l2src), GST_ELEMENT_THREAD_SUGGESTED);
+
+ v4l2src->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template
+ (GST_ELEMENT_GET_CLASS (v4l2src), "src"), "src");
+ gst_element_add_pad (GST_ELEMENT (v4l2src), v4l2src->srcpad);
- gst_pad_set_get_function(v4l2src->srcpad, gst_v4l2src_get);
- gst_pad_set_link_function(v4l2src->srcpad, gst_v4l2src_link);
+ gst_pad_set_get_function (v4l2src->srcpad, gst_v4l2src_get);
+ gst_pad_set_link_function (v4l2src->srcpad, gst_v4l2src_link);
gst_pad_set_getcaps_function (v4l2src->srcpad, gst_v4l2src_getcaps);
gst_pad_set_fixate_function (v4l2src->srcpad, gst_v4l2src_fixate);
gst_pad_set_convert_function (v4l2src->srcpad, gst_v4l2src_src_convert);
gst_pad_set_formats_function (v4l2src->srcpad, gst_v4l2src_get_formats);
gst_pad_set_query_function (v4l2src->srcpad, gst_v4l2src_src_query);
- gst_pad_set_query_type_function (v4l2src->srcpad, gst_v4l2src_get_query_types);
+ gst_pad_set_query_type_function (v4l2src->srcpad,
+ gst_v4l2src_get_query_types);
v4l2src->breq.count = 0;
@@ -273,121 +258,113 @@ gst_v4l2src_init (GTypeInstance *instance, gpointer g_class)
static void
-gst_v4l2src_open (GstElement *element,
- const gchar *device)
+gst_v4l2src_open (GstElement * element, const gchar * device)
{
gst_v4l2src_fill_format_list (GST_V4L2SRC (element));
}
static void
-gst_v4l2src_close (GstElement *element,
- const gchar *device)
+gst_v4l2src_close (GstElement * element, const gchar * device)
{
gst_v4l2src_clear_format_list (GST_V4L2SRC (element));
}
static gfloat
-gst_v4l2src_get_fps (GstV4l2Src *v4l2src)
+gst_v4l2src_get_fps (GstV4l2Src * v4l2src)
{
- v4l2_std_id norm;
- const GList *item;
-
- if (!v4l2src->use_fixed_fps &&
- v4l2src->clock != NULL &&
- v4l2src->handled > 0) {
- /* try to get time from clock master and calculate fps */
- GstClockTime time = gst_clock_get_time(v4l2src->clock) -
- v4l2src->substract_time;
- return v4l2src->handled * GST_SECOND / time;
- }
+ v4l2_std_id norm;
+ const GList *item;
+
+ if (!v4l2src->use_fixed_fps && v4l2src->clock != NULL && v4l2src->handled > 0) {
+ /* try to get time from clock master and calculate fps */
+ GstClockTime time = gst_clock_get_time (v4l2src->clock) -
+ v4l2src->substract_time;
+ return v4l2src->handled * GST_SECOND / time;
+ }
- /* if that failed ... */
-
- if (!GST_V4L2_IS_OPEN(GST_V4L2ELEMENT(v4l2src)))
- return 0.;
-
- if (!gst_v4l2_get_norm(GST_V4L2ELEMENT(v4l2src), &norm))
- return 0.;
- for (item = GST_V4L2ELEMENT(v4l2src)->norms;
- item != NULL; item = item->next) {
- GstV4l2TunerNorm *v4l2norm = item->data;
- if (v4l2norm->index == norm)
- return GST_TUNER_NORM(v4l2norm)->fps;
- }
+ /* if that failed ... */
- return 0.;
+ if (!GST_V4L2_IS_OPEN (GST_V4L2ELEMENT (v4l2src)))
+ return 0.;
+
+ if (!gst_v4l2_get_norm (GST_V4L2ELEMENT (v4l2src), &norm))
+ return 0.;
+ for (item = GST_V4L2ELEMENT (v4l2src)->norms; item != NULL; item = item->next) {
+ GstV4l2TunerNorm *v4l2norm = item->data;
+
+ if (v4l2norm->index == norm)
+ return GST_TUNER_NORM (v4l2norm)->fps;
+ }
+
+ return 0.;
}
static gboolean
-gst_v4l2src_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value)
+gst_v4l2src_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
{
- GstV4l2Src *v4l2src;
- gdouble fps;
-
- v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
-
- if ((fps = gst_v4l2src_get_fps(v4l2src)) == 0)
- return FALSE;
-
- switch (src_format) {
- case GST_FORMAT_TIME:
- switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value * fps / GST_SECOND;
- break;
- default:
- return FALSE;
- }
- break;
-
- case GST_FORMAT_DEFAULT:
- switch (*dest_format) {
- case GST_FORMAT_TIME:
- *dest_value = src_value * GST_SECOND / fps;
- break;
- default:
- return FALSE;
- }
- break;
-
- default:
- return FALSE;
- }
+ GstV4l2Src *v4l2src;
+ gdouble fps;
+
+ v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
- return TRUE;
+ if ((fps = gst_v4l2src_get_fps (v4l2src)) == 0)
+ return FALSE;
+
+ switch (src_format) {
+ case GST_FORMAT_TIME:
+ switch (*dest_format) {
+ case GST_FORMAT_DEFAULT:
+ *dest_value = src_value * fps / GST_SECOND;
+ break;
+ default:
+ return FALSE;
+ }
+ break;
+
+ case GST_FORMAT_DEFAULT:
+ switch (*dest_format) {
+ case GST_FORMAT_TIME:
+ *dest_value = src_value * GST_SECOND / fps;
+ break;
+ default:
+ return FALSE;
+ }
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
-gst_v4l2src_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value)
+gst_v4l2src_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value)
{
GstV4l2Src *v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
gboolean res = TRUE;
gdouble fps;
- if ((fps = gst_v4l2src_get_fps(v4l2src)) == 0)
+ if ((fps = gst_v4l2src_get_fps (v4l2src)) == 0)
return FALSE;
switch (type) {
case GST_QUERY_POSITION:
switch (*format) {
- case GST_FORMAT_TIME:
- *value = v4l2src->handled * GST_SECOND / fps;
- break;
- case GST_FORMAT_DEFAULT:
- *value = v4l2src->handled;
- break;
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_TIME:
+ *value = v4l2src->handled * GST_SECOND / fps;
+ break;
+ case GST_FORMAT_DEFAULT:
+ *value = v4l2src->handled;
+ break;
+ default:
+ res = FALSE;
+ break;
}
break;
default:
@@ -404,8 +381,8 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc)
GstStructure *structure = NULL;
switch (fourcc) {
- case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */
- case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
+ case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */
+ case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
structure = gst_structure_new ("video/x-jpeg", NULL);
break;
case V4L2_PIX_FMT_RGB332:
@@ -416,21 +393,25 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc)
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_BGR24:
case V4L2_PIX_FMT_RGB32:
- case V4L2_PIX_FMT_BGR32: {
- guint depth=0, bpp=0;
+ case V4L2_PIX_FMT_BGR32:{
+ guint depth = 0, bpp = 0;
gint endianness = 0;
guint32 r_mask = 0, b_mask = 0, g_mask = 0;
switch (fourcc) {
case V4L2_PIX_FMT_RGB332:
bpp = depth = 8;
- endianness = G_BYTE_ORDER; /* 'like, whatever' */
- r_mask = 0xe0; g_mask = 0x1c; b_mask = 0x03;
+ endianness = G_BYTE_ORDER; /* 'like, whatever' */
+ r_mask = 0xe0;
+ g_mask = 0x1c;
+ b_mask = 0x03;
break;
case V4L2_PIX_FMT_RGB555:
case V4L2_PIX_FMT_RGB555X:
- bpp = 16; depth = 15;
- endianness = fourcc == V4L2_PIX_FMT_RGB555X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
+ bpp = 16;
+ depth = 15;
+ endianness =
+ fourcc == V4L2_PIX_FMT_RGB555X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
r_mask = 0x7c00;
g_mask = 0x03e0;
b_mask = 0x001f;
@@ -438,7 +419,8 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc)
case V4L2_PIX_FMT_RGB565:
case V4L2_PIX_FMT_RGB565X:
bpp = depth = 16;
- endianness = fourcc == V4L2_PIX_FMT_RGB565X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
+ endianness =
+ fourcc == V4L2_PIX_FMT_RGB565X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
r_mask = 0xf800;
g_mask = 0x07e0;
b_mask = 0x001f;
@@ -471,108 +453,107 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc)
b_mask = 0x00ff0000;
break;
default:
- g_assert_not_reached();
+ g_assert_not_reached ();
break;
}
structure = gst_structure_new ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, bpp,
- "depth", G_TYPE_INT, depth,
- "red_mask", G_TYPE_INT, r_mask,
+ "bpp", G_TYPE_INT, bpp,
+ "depth", G_TYPE_INT, depth,
+ "red_mask", G_TYPE_INT, r_mask,
"green_mask", G_TYPE_INT, g_mask,
- "blue_mask", G_TYPE_INT, b_mask,
- "endianness", G_TYPE_INT, endianness,
- NULL);
+ "blue_mask", G_TYPE_INT, b_mask,
+ "endianness", G_TYPE_INT, endianness, NULL);
break;
}
- case V4L2_PIX_FMT_GREY: /* 8 Greyscale */
- case V4L2_PIX_FMT_YUV422P: /* 16 YVU422 planar */
- case V4L2_PIX_FMT_YUV411P: /* 16 YVU411 planar */
- case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
- case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
- case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */
- case V4L2_PIX_FMT_HI240: /* 8 8-bit color */
+ case V4L2_PIX_FMT_GREY: /* 8 Greyscale */
+ case V4L2_PIX_FMT_YUV422P: /* 16 YVU422 planar */
+ case V4L2_PIX_FMT_YUV411P: /* 16 YVU411 planar */
+ case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
+ case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
+ case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */
+ case V4L2_PIX_FMT_HI240: /* 8 8-bit color */
/* FIXME: get correct fourccs here */
break;
case V4L2_PIX_FMT_YVU410:
case V4L2_PIX_FMT_YUV410:
- case V4L2_PIX_FMT_YUV420: /* I420/IYUV */
+ case V4L2_PIX_FMT_YUV420: /* I420/IYUV */
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_UYVY:
- case V4L2_PIX_FMT_Y41P: {
+ case V4L2_PIX_FMT_Y41P:{
guint32 fcc = 0;
switch (fourcc) {
case V4L2_PIX_FMT_YVU410:
- fcc = GST_MAKE_FOURCC('Y','V','U','9');
+ fcc = GST_MAKE_FOURCC ('Y', 'V', 'U', '9');
break;
case V4L2_PIX_FMT_YUV410:
- fcc = GST_MAKE_FOURCC('Y','U','V','9');
+ fcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
break;
case V4L2_PIX_FMT_YUV420:
- fcc = GST_MAKE_FOURCC('I','4','2','0');
+ fcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
break;
case V4L2_PIX_FMT_YUYV:
- fcc = GST_MAKE_FOURCC('Y','U','Y','2');
+ fcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
break;
case V4L2_PIX_FMT_YVU420:
- fcc = GST_MAKE_FOURCC('Y','V','1','2');
+ fcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
break;
case V4L2_PIX_FMT_UYVY:
- fcc = GST_MAKE_FOURCC('U','Y','V','Y');
+ fcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
break;
case V4L2_PIX_FMT_Y41P:
- fcc = GST_MAKE_FOURCC('Y','4','1','B');
+ fcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
break;
default:
- g_assert_not_reached();
+ g_assert_not_reached ();
break;
}
structure = gst_structure_new ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, fcc,
- NULL);
+ "format", GST_TYPE_FOURCC, fcc, NULL);
break;
}
case V4L2_PIX_FMT_DV:
- structure = gst_structure_new ("video/x-dv", "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
+ structure =
+ gst_structure_new ("video/x-dv", "systemstream", G_TYPE_BOOLEAN, TRUE,
+ NULL);
break;
- case V4L2_PIX_FMT_MPEG: /* MPEG */
+ case V4L2_PIX_FMT_MPEG: /* MPEG */
/* someone figure out the MPEG format used... */
break;
- case V4L2_PIX_FMT_WNVA: /* Winnov hw compres */
+ case V4L2_PIX_FMT_WNVA: /* Winnov hw compres */
break;
default:
GST_DEBUG ("Unknown fourcc 0x%08x " GST_FOURCC_FORMAT,
- fourcc, GST_FOURCC_ARGS(fourcc));
+ fourcc, GST_FOURCC_ARGS (fourcc));
break;
}
#if 0
- gst_caps_set_simple (caps,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", G_TYPE_DOUBLE, fps,
- NULL);
+ gst_caps_set_simple (caps,
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height, "framerate", G_TYPE_DOUBLE, fps, NULL);
#endif
return structure;
}
static struct v4l2_fmtdesc *
-gst_v4l2src_get_format_from_fourcc (GstV4l2Src *v4l2src, guint32 fourcc)
-{
+gst_v4l2src_get_format_from_fourcc (GstV4l2Src * v4l2src, guint32 fourcc)
+{
struct v4l2_fmtdesc *fmt;
GSList *walk;
-
+
if (fourcc == 0)
return NULL;
-
+
walk = v4l2src->formats;
while (walk) {
fmt = (struct v4l2_fmtdesc *) walk->data;
if (fmt->pixelformat == fourcc)
return fmt;
/* special case for jpeg */
- if ((fmt->pixelformat == V4L2_PIX_FMT_MJPEG && fourcc == V4L2_PIX_FMT_JPEG) ||
- (fmt->pixelformat == V4L2_PIX_FMT_JPEG && fourcc == V4L2_PIX_FMT_MJPEG)) {
+ if ((fmt->pixelformat == V4L2_PIX_FMT_MJPEG && fourcc == V4L2_PIX_FMT_JPEG)
+ || (fmt->pixelformat == V4L2_PIX_FMT_JPEG
+ && fourcc == V4L2_PIX_FMT_MJPEG)) {
return fmt;
}
walk = g_slist_next (walk);
@@ -582,36 +563,36 @@ gst_v4l2src_get_format_from_fourcc (GstV4l2Src *v4l2src, guint32 fourcc)
}
static guint32
-gst_v4l2_fourcc_from_structure (GstStructure *structure)
+gst_v4l2_fourcc_from_structure (GstStructure * structure)
{
guint32 fourcc = 0;
const gchar *mimetype = gst_structure_get_name (structure);
- if (!strcmp(mimetype, "video/x-raw-yuv") ||
- !strcmp(mimetype, "video/x-raw-rgb")) {
- if (!strcmp(mimetype, "video/x-raw-rgb"))
- fourcc = GST_MAKE_FOURCC('R','G','B',' ');
+ if (!strcmp (mimetype, "video/x-raw-yuv") ||
+ !strcmp (mimetype, "video/x-raw-rgb")) {
+ if (!strcmp (mimetype, "video/x-raw-rgb"))
+ fourcc = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
else
gst_structure_get_fourcc (structure, "format", &fourcc);
switch (fourcc) {
- case GST_MAKE_FOURCC('I','4','2','0'):
- case GST_MAKE_FOURCC('I','Y','U','V'):
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ case GST_MAKE_FOURCC ('I', 'Y', 'U', 'V'):
fourcc = V4L2_PIX_FMT_YUV420;
break;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
fourcc = V4L2_PIX_FMT_YUYV;
break;
- case GST_MAKE_FOURCC('Y','4','1','P'):
+ case GST_MAKE_FOURCC ('Y', '4', '1', 'P'):
fourcc = V4L2_PIX_FMT_Y41P;
break;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
fourcc = V4L2_PIX_FMT_UYVY;
break;
- case GST_MAKE_FOURCC('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
fourcc = V4L2_PIX_FMT_YVU420;
break;
- case GST_MAKE_FOURCC('R','G','B',' '): {
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):{
gint depth, endianness, r_mask;
gst_structure_get_int (structure, "depth", &depth);
@@ -624,29 +605,23 @@ gst_v4l2_fourcc_from_structure (GstStructure *structure)
break;
case 15:
fourcc = (endianness == G_LITTLE_ENDIAN) ?
- V4L2_PIX_FMT_RGB555 :
- V4L2_PIX_FMT_RGB555X;
+ V4L2_PIX_FMT_RGB555 : V4L2_PIX_FMT_RGB555X;
break;
case 16:
fourcc = (endianness == G_LITTLE_ENDIAN) ?
- V4L2_PIX_FMT_RGB565 :
- V4L2_PIX_FMT_RGB565X;
+ V4L2_PIX_FMT_RGB565 : V4L2_PIX_FMT_RGB565X;
break;
case 24:
- fourcc = (r_mask == 0xFF) ?
- V4L2_PIX_FMT_BGR24 :
- V4L2_PIX_FMT_RGB24;
+ fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR24 : V4L2_PIX_FMT_RGB24;
break;
case 32:
- fourcc = (r_mask == 0xFF) ?
- V4L2_PIX_FMT_BGR32 :
- V4L2_PIX_FMT_RGB32;
+ fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR32 : V4L2_PIX_FMT_RGB32;
break;
}
- default:
- break;
+ default:
+ break;
}
- }
+ }
} else if (strcmp (mimetype, "video/x-dv") == 0) {
fourcc = V4L2_PIX_FMT_DV;
} else if (strcmp (mimetype, "video/x-jpeg") == 0) {
@@ -657,7 +632,7 @@ gst_v4l2_fourcc_from_structure (GstStructure *structure)
}
static struct v4l2_fmtdesc *
-gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src *v4l2src, GstStructure *structure)
+gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src * v4l2src, GstStructure * structure)
{
return gst_v4l2src_get_format_from_fourcc (v4l2src,
gst_v4l2_fourcc_from_structure (structure));
@@ -679,8 +654,7 @@ gst_v4l2src_get_all_caps (void)
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, 4096,
"height", GST_TYPE_INT_RANGE, 1, 4096,
- "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE,
- NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE, NULL);
gst_caps_append_structure (caps, structure);
}
@@ -691,7 +665,7 @@ gst_v4l2src_get_all_caps (void)
}
static GstCaps *
-gst_v4l2src_fixate (GstPad *pad, const GstCaps *const_caps)
+gst_v4l2src_fixate (GstPad * pad, const GstCaps * const_caps)
{
gint i;
GstStructure *structure;
@@ -702,25 +676,31 @@ gst_v4l2src_fixate (GstPad *pad, const GstCaps *const_caps)
caps_str = gst_caps_to_string (caps);
GST_DEBUG_OBJECT (gst_pad_get_parent (pad), "fixating caps %s", caps_str);
g_free (caps_str);
-
+
for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
- changed |= gst_caps_structure_fixate_field_nearest_int (structure, "width", G_MAXINT);
+ changed |=
+ gst_caps_structure_fixate_field_nearest_int (structure, "width",
+ G_MAXINT);
}
- if (changed) return caps;
+ if (changed)
+ return caps;
for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
- changed |= gst_caps_structure_fixate_field_nearest_int (structure, "height", G_MAXINT);
+ changed |=
+ gst_caps_structure_fixate_field_nearest_int (structure, "height",
+ G_MAXINT);
}
- if (changed) return caps;
+ if (changed)
+ return caps;
gst_caps_free (caps);
return NULL;
}
static GstPadLinkReturn
-gst_v4l2src_link (GstPad *pad, const GstCaps *caps)
+gst_v4l2src_link (GstPad * pad, const GstCaps * caps)
{
GstV4l2Src *v4l2src;
GstV4l2Element *v4l2element;
@@ -728,33 +708,33 @@ gst_v4l2src_link (GstPad *pad, const GstCaps *caps)
int w, h;
GstStructure *structure;
- v4l2src = GST_V4L2SRC(gst_pad_get_parent (pad));
- v4l2element = GST_V4L2ELEMENT(v4l2src);
+ v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
+ v4l2element = GST_V4L2ELEMENT (v4l2src);
structure = gst_caps_get_structure (caps, 0);
/* clean up if we still haven't cleaned up our previous
* capture session */
- if (GST_V4L2_IS_ACTIVE(v4l2element)) {
- if (!gst_v4l2src_capture_deinit(v4l2src))
- return GST_PAD_LINK_REFUSED;
- } else if (!GST_V4L2_IS_OPEN(v4l2element)) {
- return GST_PAD_LINK_DELAYED;
+ if (GST_V4L2_IS_ACTIVE (v4l2element)) {
+ if (!gst_v4l2src_capture_deinit (v4l2src))
+ return GST_PAD_LINK_REFUSED;
+ } else if (!GST_V4L2_IS_OPEN (v4l2element)) {
+ return GST_PAD_LINK_DELAYED;
}
/* we want our own v4l2 type of fourcc codes */
- if (!(format = gst_v4l2_caps_to_v4l2fourcc(v4l2src, structure))) {
- return GST_PAD_LINK_REFUSED;
+ if (!(format = gst_v4l2_caps_to_v4l2fourcc (v4l2src, structure))) {
+ return GST_PAD_LINK_REFUSED;
}
gst_structure_get_int (structure, "width", &w);
gst_structure_get_int (structure, "height", &h);
/* we found the pixelformat! - try it out */
- if (gst_v4l2src_set_capture(v4l2src, format, w, h)) {
- if (gst_v4l2src_capture_init(v4l2src)) {
- return GST_PAD_LINK_OK;
- }
+ if (gst_v4l2src_set_capture (v4l2src, format, w, h)) {
+ if (gst_v4l2src_capture_init (v4l2src)) {
+ return GST_PAD_LINK_OK;
+ }
}
return GST_PAD_LINK_REFUSED;
@@ -762,29 +742,29 @@ gst_v4l2src_link (GstPad *pad, const GstCaps *caps)
static GstCaps *
-gst_v4l2src_getcaps (GstPad *pad)
+gst_v4l2src_getcaps (GstPad * pad)
{
- GstV4l2Src *v4l2src = GST_V4L2SRC(gst_pad_get_parent (pad));
+ GstV4l2Src *v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
GstCaps *caps;
struct v4l2_fmtdesc *format;
int min_w, max_w, min_h, max_h;
GSList *walk;
GstStructure *structure;
- if (!GST_V4L2_IS_OPEN(GST_V4L2ELEMENT(v4l2src))) {
- return gst_caps_new_any ();
+ if (!GST_V4L2_IS_OPEN (GST_V4L2ELEMENT (v4l2src))) {
+ return gst_caps_new_any ();
}
/* build our own capslist */
- caps = gst_caps_new_empty();
+ caps = gst_caps_new_empty ();
walk = v4l2src->formats;
while (walk) {
format = (struct v4l2_fmtdesc *) walk->data;
walk = g_slist_next (walk);
/* get size delimiters */
- if (!gst_v4l2src_get_size_limits(v4l2src, format,
- &min_w, &max_w, &min_h, &max_h)) {
+ if (!gst_v4l2src_get_size_limits (v4l2src, format,
+ &min_w, &max_w, &min_h, &max_h)) {
continue;
}
@@ -795,8 +775,7 @@ gst_v4l2src_getcaps (GstPad *pad)
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, min_w, max_w,
"height", GST_TYPE_INT_RANGE, min_h, max_h,
- "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE,
- NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE, NULL);
gst_caps_append_structure (caps, structure);
}
@@ -805,8 +784,8 @@ gst_v4l2src_getcaps (GstPad *pad)
return caps;
}
-static GstData*
-gst_v4l2src_get (GstPad *pad)
+static GstData *
+gst_v4l2src_get (GstPad * pad)
{
GstV4l2Src *v4l2src;
GstBuffer *buf;
@@ -815,9 +794,9 @@ gst_v4l2src_get (GstPad *pad)
v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
- if (v4l2src->use_fixed_fps &&
- (fps = gst_v4l2src_get_fps(v4l2src)) == 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL), ("could not get frame rate for element"));
+ if (v4l2src->use_fixed_fps && (fps = gst_v4l2src_get_fps (v4l2src)) == 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
+ ("could not get frame rate for element"));
return NULL;
}
@@ -827,13 +806,14 @@ gst_v4l2src_get (GstPad *pad)
v4l2src->need_writes--;
} else {
GstClockTime time;
+
/* grab a frame from the device */
- num = gst_v4l2src_grab_frame(v4l2src);
+ num = gst_v4l2src_grab_frame (v4l2src);
if (num == -1)
return NULL;
/* to check if v4l2 sets the correct time */
- time = GST_TIMEVAL_TO_TIME(v4l2src->pool->buffers[num].buffer.timestamp);
+ time = GST_TIMEVAL_TO_TIME (v4l2src->pool->buffers[num].buffer.timestamp);
if (v4l2src->clock && v4l2src->use_fixed_fps && time != 0) {
gboolean have_frame = FALSE;
@@ -847,9 +827,12 @@ gst_v4l2src_get (GstPad *pad)
/* first check whether we lost any frames according to the device */
if (v4l2src->last_seq != 0) {
- if (v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq > 1) {
- v4l2src->need_writes = v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq;
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_LOST], 0,
+ if (v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq >
+ 1) {
+ v4l2src->need_writes =
+ v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq;
+ g_signal_emit (G_OBJECT (v4l2src),
+ gst_v4l2src_signals[SIGNAL_FRAME_LOST], 0,
v4l2src->need_writes - 1);
}
}
@@ -865,23 +848,27 @@ gst_v4l2src_get (GstPad *pad)
* timeframe. This means that if time - begin_time = X sec,
* we want to have written X*fps frames. If we've written
* more - drop, if we've written less - dup... */
- if (v4l2src->handled * (GST_SECOND/fps) - time > 1.5 * (GST_SECOND/fps)) {
+ if (v4l2src->handled * (GST_SECOND / fps) - time >
+ 1.5 * (GST_SECOND / fps)) {
/* yo dude, we've got too many frames here! Drop! DROP! */
- v4l2src->need_writes--; /* -= (v4l2src->handled - (time / fps)); */
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_DROP], 0);
- } else if (v4l2src->handled * (GST_SECOND/fps) - time < -1.5 * (GST_SECOND/fps)) {
+ v4l2src->need_writes--; /* -= (v4l2src->handled - (time / fps)); */
+ g_signal_emit (G_OBJECT (v4l2src),
+ gst_v4l2src_signals[SIGNAL_FRAME_DROP], 0);
+ } else if (v4l2src->handled * (GST_SECOND / fps) - time <
+ -1.5 * (GST_SECOND / fps)) {
/* this means we're lagging far behind */
- v4l2src->need_writes++; /* += ((time / fps) - v4l2src->handled); */
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_INSERT], 0);
+ v4l2src->need_writes++; /* += ((time / fps) - v4l2src->handled); */
+ g_signal_emit (G_OBJECT (v4l2src),
+ gst_v4l2src_signals[SIGNAL_FRAME_INSERT], 0);
}
if (v4l2src->need_writes > 0) {
have_frame = TRUE;
v4l2src->need_writes--;
} else {
- if (!gst_v4l2src_queue_frame(v4l2src, num))
+ if (!gst_v4l2src_queue_frame (v4l2src, num))
return NULL;
- num = gst_v4l2src_grab_frame(v4l2src);
+ num = gst_v4l2src_grab_frame (v4l2src);
if (num == -1)
return NULL;
}
@@ -889,17 +876,18 @@ gst_v4l2src_get (GstPad *pad)
}
g_assert (num != -1);
- GST_LOG_OBJECT (v4l2src, "buffer %d needs %d writes", num, v4l2src->need_writes + 1);
- i = v4l2src->pool->buffers[num].buffer.bytesused > 0 ?
- v4l2src->pool->buffers[num].buffer.bytesused :
- v4l2src->pool->buffers[num].length;
+ GST_LOG_OBJECT (v4l2src, "buffer %d needs %d writes", num,
+ v4l2src->need_writes + 1);
+ i = v4l2src->pool->buffers[num].buffer.bytesused >
+ 0 ? v4l2src->pool->buffers[num].buffer.bytesused : v4l2src->pool->
+ buffers[num].length;
/* check if this is the last buffer in the queue. If so do a memcpy to put it back asap
to avoid framedrops and deadlocks because of stupid elements */
if (gst_atomic_int_read (&v4l2src->pool->refcount) == v4l2src->breq.count) {
GST_LOG_OBJECT (v4l2src, "using memcpy'd buffer");
buf = gst_buffer_new_and_alloc (i);
memcpy (GST_BUFFER_DATA (buf), v4l2src->pool->buffers[num].start, i);
- if (!gst_v4l2src_queue_frame(v4l2src, num)) {
+ if (!gst_v4l2src_queue_frame (v4l2src, num)) {
gst_data_unref (GST_DATA (buf));
return NULL;
}
@@ -920,7 +908,8 @@ gst_v4l2src_get (GstPad *pad)
GST_BUFFER_DURATION (buf) = GST_SECOND / fps;
} else {
/* calculate time based on our own clock */
- GST_BUFFER_TIMESTAMP(buf) = GST_TIMEVAL_TO_TIME(v4l2src->pool->buffers[num].buffer.timestamp) -
+ GST_BUFFER_TIMESTAMP (buf) =
+ GST_TIMEVAL_TO_TIME (v4l2src->pool->buffers[num].buffer.timestamp) -
v4l2src->substract_time;
}
if (v4l2src->need_writes > 0) {
@@ -932,135 +921,130 @@ gst_v4l2src_get (GstPad *pad)
}
v4l2src->handled++;
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_CAPTURE], 0);
+ g_signal_emit (G_OBJECT (v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_CAPTURE],
+ 0);
return GST_DATA (buf);
}
static void
-gst_v4l2src_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_v4l2src_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstV4l2Src *v4l2src;
-
- g_return_if_fail(GST_IS_V4L2SRC(object));
- v4l2src = GST_V4L2SRC(object);
-
- switch (prop_id) {
- case ARG_NUMBUFS:
- if (!GST_V4L2_IS_ACTIVE(GST_V4L2ELEMENT(v4l2src))) {
- v4l2src->breq.count = g_value_get_int(value);
- }
- break;
-
- case ARG_USE_FIXED_FPS:
- if (!GST_V4L2_IS_ACTIVE(GST_V4L2ELEMENT(v4l2src))) {
- v4l2src->use_fixed_fps = g_value_get_boolean(value);
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GstV4l2Src *v4l2src;
+
+ g_return_if_fail (GST_IS_V4L2SRC (object));
+ v4l2src = GST_V4L2SRC (object);
+
+ switch (prop_id) {
+ case ARG_NUMBUFS:
+ if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT (v4l2src))) {
+ v4l2src->breq.count = g_value_get_int (value);
+ }
+ break;
+
+ case ARG_USE_FIXED_FPS:
+ if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT (v4l2src))) {
+ v4l2src->use_fixed_fps = g_value_get_boolean (value);
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gst_v4l2src_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_v4l2src_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstV4l2Src *v4l2src;
+ GstV4l2Src *v4l2src;
- g_return_if_fail(GST_IS_V4L2SRC(object));
- v4l2src = GST_V4L2SRC(object);
+ g_return_if_fail (GST_IS_V4L2SRC (object));
+ v4l2src = GST_V4L2SRC (object);
- switch (prop_id) {
- case ARG_NUMBUFS:
- g_value_set_int(value, v4l2src->breq.count);
- break;
+ switch (prop_id) {
+ case ARG_NUMBUFS:
+ g_value_set_int (value, v4l2src->breq.count);
+ break;
- case ARG_BUFSIZE:
- g_value_set_int(value, v4l2src->format.fmt.pix.sizeimage);
- break;
+ case ARG_BUFSIZE:
+ g_value_set_int (value, v4l2src->format.fmt.pix.sizeimage);
+ break;
- case ARG_USE_FIXED_FPS:
- g_value_set_boolean(value, v4l2src->use_fixed_fps);
- break;
+ case ARG_USE_FIXED_FPS:
+ g_value_set_boolean (value, v4l2src->use_fixed_fps);
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GstElementStateReturn
-gst_v4l2src_change_state (GstElement *element)
+gst_v4l2src_change_state (GstElement * element)
{
- GstV4l2Src *v4l2src;
- gint transition = GST_STATE_TRANSITION (element);
- GstElementStateReturn parent_return;
- GTimeVal time;
-
- g_return_val_if_fail(GST_IS_V4L2SRC(element), GST_STATE_FAILURE);
- v4l2src = GST_V4L2SRC(element);
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state) {
- parent_return = GST_ELEMENT_CLASS (parent_class)->change_state (element);
- if (parent_return != GST_STATE_SUCCESS)
- return parent_return;
- }
+ GstV4l2Src *v4l2src;
+ gint transition = GST_STATE_TRANSITION (element);
+ GstElementStateReturn parent_return;
+ GTimeVal time;
- switch (transition) {
- case GST_STATE_NULL_TO_READY:
- if (!gst_v4l2src_get_capture(v4l2src))
- return GST_STATE_FAILURE;
- break;
- case GST_STATE_READY_TO_PAUSED:
- v4l2src->handled = 0;
- v4l2src->need_writes = 0;
- v4l2src->substract_time = 0;
- /* buffer setup moved to capsnego */
- break;
- case GST_STATE_PAUSED_TO_PLAYING:
- /* queue all buffer, start streaming capture */
- if (!gst_v4l2src_capture_start(v4l2src))
- return GST_STATE_FAILURE;
- g_get_current_time(&time);
- v4l2src->substract_time = GST_TIMEVAL_TO_TIME(time) -
- v4l2src->substract_time;
- v4l2src->last_seq = 0;
- break;
- case GST_STATE_PLAYING_TO_PAUSED:
- g_get_current_time(&time);
- v4l2src->substract_time = GST_TIMEVAL_TO_TIME(time) -
- v4l2src->substract_time;
- /* de-queue all queued buffers */
- if (!gst_v4l2src_capture_stop(v4l2src))
- return GST_STATE_FAILURE;
- break;
- case GST_STATE_PAUSED_TO_READY:
- /* stop capturing, unmap all buffers */
- if (!gst_v4l2src_capture_deinit(v4l2src))
- return GST_STATE_FAILURE;
- break;
- case GST_STATE_READY_TO_NULL:
- break;
- }
+ g_return_val_if_fail (GST_IS_V4L2SRC (element), GST_STATE_FAILURE);
+ v4l2src = GST_V4L2SRC (element);
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state) {
+ parent_return = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ if (parent_return != GST_STATE_SUCCESS)
+ return parent_return;
+ }
- return GST_STATE_SUCCESS;
+ switch (transition) {
+ case GST_STATE_NULL_TO_READY:
+ if (!gst_v4l2src_get_capture (v4l2src))
+ return GST_STATE_FAILURE;
+ break;
+ case GST_STATE_READY_TO_PAUSED:
+ v4l2src->handled = 0;
+ v4l2src->need_writes = 0;
+ v4l2src->substract_time = 0;
+ /* buffer setup moved to capsnego */
+ break;
+ case GST_STATE_PAUSED_TO_PLAYING:
+ /* queue all buffer, start streaming capture */
+ if (!gst_v4l2src_capture_start (v4l2src))
+ return GST_STATE_FAILURE;
+ g_get_current_time (&time);
+ v4l2src->substract_time = GST_TIMEVAL_TO_TIME (time) -
+ v4l2src->substract_time;
+ v4l2src->last_seq = 0;
+ break;
+ case GST_STATE_PLAYING_TO_PAUSED:
+ g_get_current_time (&time);
+ v4l2src->substract_time = GST_TIMEVAL_TO_TIME (time) -
+ v4l2src->substract_time;
+ /* de-queue all queued buffers */
+ if (!gst_v4l2src_capture_stop (v4l2src))
+ return GST_STATE_FAILURE;
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ /* stop capturing, unmap all buffers */
+ if (!gst_v4l2src_capture_deinit (v4l2src))
+ return GST_STATE_FAILURE;
+ break;
+ case GST_STATE_READY_TO_NULL:
+ break;
+ }
+
+ return GST_STATE_SUCCESS;
}
static void
-gst_v4l2src_set_clock (GstElement *element,
- GstClock *clock)
+gst_v4l2src_set_clock (GstElement * element, GstClock * clock)
{
- GST_V4L2SRC(element)->clock = clock;
+ GST_V4L2SRC (element)->clock = clock;
}
-
diff --git a/sys/v4l2/gstv4l2src.h b/sys/v4l2/gstv4l2src.h
index ca528d1e..d68f9cf8 100644
--- a/sys/v4l2/gstv4l2src.h
+++ b/sys/v4l2/gstv4l2src.h
@@ -38,72 +38,75 @@ GST_DEBUG_CATEGORY_EXTERN (v4l2src_debug);
#define GST_IS_V4L2SRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_V4L2SRC))
-typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
-typedef struct _GstV4l2Buffer GstV4l2Buffer;
-typedef struct _GstV4l2Src GstV4l2Src;
-typedef struct _GstV4l2SrcClass GstV4l2SrcClass;
+typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
+typedef struct _GstV4l2Buffer GstV4l2Buffer;
+typedef struct _GstV4l2Src GstV4l2Src;
+typedef struct _GstV4l2SrcClass GstV4l2SrcClass;
/* global info */
-struct _GstV4l2BufferPool {
- GstAtomicInt refcount; /* number of users: 1 for every buffer, 1 for element */
- gint video_fd;
- guint buffer_count;
- GstV4l2Buffer * buffers;
+struct _GstV4l2BufferPool
+{
+ GstAtomicInt refcount; /* number of users: 1 for every buffer, 1 for element */
+ gint video_fd;
+ guint buffer_count;
+ GstV4l2Buffer *buffers;
};
-struct _GstV4l2Buffer {
- struct v4l2_buffer buffer;
- guint8 * start;
- guint length;
- GstAtomicInt refcount; /* add 1 if in use by element, add 1 if in use by GstBuffer */
- GstV4l2BufferPool * pool;
+struct _GstV4l2Buffer
+{
+ struct v4l2_buffer buffer;
+ guint8 *start;
+ guint length;
+ GstAtomicInt refcount; /* add 1 if in use by element, add 1 if in use by GstBuffer */
+ GstV4l2BufferPool *pool;
};
-struct _GstV4l2Src {
- GstV4l2Element v4l2element;
+struct _GstV4l2Src
+{
+ GstV4l2Element v4l2element;
- /* pads */
- GstPad *srcpad;
+ /* pads */
+ GstPad *srcpad;
- /* internal lists */
- GSList *formats; /* list of available capture formats */
+ /* internal lists */
+ GSList *formats; /* list of available capture formats */
- /* buffers */
- GstV4l2BufferPool *pool;
+ /* buffers */
+ GstV4l2BufferPool *pool;
- struct v4l2_requestbuffers breq;
- struct v4l2_format format;
+ struct v4l2_requestbuffers breq;
+ struct v4l2_format format;
- /* True if we want to stop */
- gboolean quit;
+ /* True if we want to stop */
+ gboolean quit;
- /* A/V sync... frame counter and internal cache */
- gulong handled;
- gint need_writes;
- GstBuffer *cached_buffer;
- gulong last_seq;
+ /* A/V sync... frame counter and internal cache */
+ gulong handled;
+ gint need_writes;
+ GstBuffer *cached_buffer;
+ gulong last_seq;
- /* clock */
- GstClock *clock;
-
- /* time to substract from clock time to get back to timestamp */
- GstClockTime substract_time;
+ /* clock */
+ GstClock *clock;
- /* how are we going to push buffers? */
- gboolean use_fixed_fps;
+ /* time to substract from clock time to get back to timestamp */
+ GstClockTime substract_time;
+
+ /* how are we going to push buffers? */
+ gboolean use_fixed_fps;
};
-struct _GstV4l2SrcClass {
- GstV4l2ElementClass parent_class;
+struct _GstV4l2SrcClass
+{
+ GstV4l2ElementClass parent_class;
- void (*frame_capture) (GObject *object);
- void (*frame_drop) (GObject *object);
- void (*frame_insert) (GObject *object);
- void (*frame_lost) (GObject *object,
- gint num_lost);
+ void (*frame_capture) (GObject * object);
+ void (*frame_drop) (GObject * object);
+ void (*frame_insert) (GObject * object);
+ void (*frame_lost) (GObject * object, gint num_lost);
};
-GType gst_v4l2src_get_type(void);
+GType gst_v4l2src_get_type (void);
#endif /* __GST_V4L2SRC_H__ */
diff --git a/sys/v4l2/gstv4l2tuner.c b/sys/v4l2/gstv4l2tuner.c
index f4f2cd64..5d5626f2 100644
--- a/sys/v4l2/gstv4l2tuner.c
+++ b/sys/v4l2/gstv4l2tuner.c
@@ -30,33 +30,28 @@
#include "gstv4l2element.h"
#include "v4l2_calls.h"
-static void gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *klass);
-static void gst_v4l2_tuner_channel_init (GstV4l2TunerChannel *channel);
+static void gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *
+ klass);
+static void gst_v4l2_tuner_channel_init (GstV4l2TunerChannel * channel);
-static void gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass *klass);
-static void gst_v4l2_tuner_norm_init (GstV4l2TunerNorm *norm);
+static void gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass * klass);
+static void gst_v4l2_tuner_norm_init (GstV4l2TunerNorm * norm);
-static const GList *
- gst_v4l2_tuner_list_channels (GstTuner *mixer);
-static void gst_v4l2_tuner_set_channel (GstTuner *mixer,
- GstTunerChannel *channel);
-static GstTunerChannel *
- gst_v4l2_tuner_get_channel (GstTuner *mixer);
+static const GList *gst_v4l2_tuner_list_channels (GstTuner * mixer);
+static void gst_v4l2_tuner_set_channel (GstTuner * mixer,
+ GstTunerChannel * channel);
+static GstTunerChannel *gst_v4l2_tuner_get_channel (GstTuner * mixer);
-static const GList *
- gst_v4l2_tuner_list_norms (GstTuner *mixer);
-static void gst_v4l2_tuner_set_norm (GstTuner *mixer,
- GstTunerNorm *norm);
-static GstTunerNorm *
- gst_v4l2_tuner_get_norm (GstTuner *mixer);
+static const GList *gst_v4l2_tuner_list_norms (GstTuner * mixer);
+static void gst_v4l2_tuner_set_norm (GstTuner * mixer, GstTunerNorm * norm);
+static GstTunerNorm *gst_v4l2_tuner_get_norm (GstTuner * mixer);
-static void gst_v4l2_tuner_set_frequency (GstTuner *mixer,
- GstTunerChannel *channel,
- gulong frequency);
-static gulong gst_v4l2_tuner_get_frequency (GstTuner *mixer,
- GstTunerChannel *channel);
-static gint gst_v4l2_tuner_signal_strength (GstTuner *mixer,
- GstTunerChannel *channel);
+static void gst_v4l2_tuner_set_frequency (GstTuner * mixer,
+ GstTunerChannel * channel, gulong frequency);
+static gulong gst_v4l2_tuner_get_frequency (GstTuner * mixer,
+ GstTunerChannel * channel);
+static gint gst_v4l2_tuner_signal_strength (GstTuner * mixer,
+ GstTunerChannel * channel);
static GstTunerNormClass *norm_parent_class = NULL;
static GstTunerChannelClass *channel_parent_class = NULL;
@@ -82,21 +77,20 @@ gst_v4l2_tuner_channel_get_type (void)
gst_v4l2_tuner_channel_type =
g_type_register_static (GST_TYPE_TUNER_CHANNEL,
- "GstV4l2TunerChannel",
- &v4l2_tuner_channel_info, 0);
+ "GstV4l2TunerChannel", &v4l2_tuner_channel_info, 0);
}
return gst_v4l2_tuner_channel_type;
}
static void
-gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *klass)
+gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass * klass)
{
channel_parent_class = g_type_class_ref (GST_TYPE_TUNER_CHANNEL);
}
static void
-gst_v4l2_tuner_channel_init (GstV4l2TunerChannel *channel)
+gst_v4l2_tuner_channel_init (GstV4l2TunerChannel * channel)
{
channel->index = 0;
channel->tuner = 0;
@@ -124,27 +118,26 @@ gst_v4l2_tuner_norm_get_type (void)
gst_v4l2_tuner_norm_type =
g_type_register_static (GST_TYPE_TUNER_NORM,
- "GstV4l2TunerNorm",
- &v4l2_tuner_norm_info, 0);
+ "GstV4l2TunerNorm", &v4l2_tuner_norm_info, 0);
}
return gst_v4l2_tuner_norm_type;
}
static void
-gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass *klass)
+gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass * klass)
{
norm_parent_class = g_type_class_ref (GST_TYPE_TUNER_NORM);
}
static void
-gst_v4l2_tuner_norm_init (GstV4l2TunerNorm *norm)
+gst_v4l2_tuner_norm_init (GstV4l2TunerNorm * norm)
{
norm->index = 0;
}
void
-gst_v4l2_tuner_interface_init (GstTunerClass *klass)
+gst_v4l2_tuner_interface_init (GstTunerClass * klass)
{
/* default virtual functions */
klass->list_channels = gst_v4l2_tuner_list_channels;
@@ -161,7 +154,7 @@ gst_v4l2_tuner_interface_init (GstTunerClass *klass)
}
static gboolean
-gst_v4l2_tuner_is_sink (GstV4l2Element *v4l2element)
+gst_v4l2_tuner_is_sink (GstV4l2Element * v4l2element)
{
const GList *pads = gst_element_get_pad_list (GST_ELEMENT (v4l2element));
GstPadDirection dir = GST_PAD_UNKNOWN;
@@ -174,8 +167,8 @@ gst_v4l2_tuner_is_sink (GstV4l2Element *v4l2element)
}
static gboolean
-gst_v4l2_tuner_contains_channel (GstV4l2Element *v4l2element,
- GstV4l2TunerChannel *v4l2channel)
+gst_v4l2_tuner_contains_channel (GstV4l2Element * v4l2element,
+ GstV4l2TunerChannel * v4l2channel)
{
const GList *item;
@@ -187,15 +180,14 @@ gst_v4l2_tuner_contains_channel (GstV4l2Element *v4l2element,
}
static const GList *
-gst_v4l2_tuner_list_channels (GstTuner *mixer)
+gst_v4l2_tuner_list_channels (GstTuner * mixer)
{
/* ... or output, if we're a sink... */
return GST_V4L2ELEMENT (mixer)->channels;
}
static void
-gst_v4l2_tuner_set_channel (GstTuner *mixer,
- GstTunerChannel *channel)
+gst_v4l2_tuner_set_channel (GstTuner * mixer, GstTunerChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
@@ -205,7 +197,7 @@ gst_v4l2_tuner_set_channel (GstTuner *mixer,
g_return_if_fail (gst_v4l2_tuner_contains_channel (v4l2element, v4l2channel));
/* ... or output, if we're a sink... */
- if (gst_v4l2_tuner_is_sink (v4l2element) ?
+ if (gst_v4l2_tuner_is_sink (v4l2element) ?
gst_v4l2_set_output (v4l2element, v4l2channel->index) :
gst_v4l2_set_input (v4l2element, v4l2channel->index)) {
gst_tuner_channel_changed (mixer, channel);
@@ -214,7 +206,7 @@ gst_v4l2_tuner_set_channel (GstTuner *mixer,
}
static GstTunerChannel *
-gst_v4l2_tuner_get_channel (GstTuner *mixer)
+gst_v4l2_tuner_get_channel (GstTuner * mixer)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GList *item;
@@ -238,8 +230,8 @@ gst_v4l2_tuner_get_channel (GstTuner *mixer)
}
static gboolean
-gst_v4l2_tuner_contains_norm (GstV4l2Element *v4l2element,
- GstV4l2TunerNorm *v4l2norm)
+gst_v4l2_tuner_contains_norm (GstV4l2Element * v4l2element,
+ GstV4l2TunerNorm * v4l2norm)
{
const GList *item;
@@ -251,14 +243,13 @@ gst_v4l2_tuner_contains_norm (GstV4l2Element *v4l2element,
}
static const GList *
-gst_v4l2_tuner_list_norms (GstTuner *mixer)
+gst_v4l2_tuner_list_norms (GstTuner * mixer)
{
return GST_V4L2ELEMENT (mixer)->norms;
}
static void
-gst_v4l2_tuner_set_norm (GstTuner *mixer,
- GstTunerNorm *norm)
+gst_v4l2_tuner_set_norm (GstTuner * mixer, GstTunerNorm * norm)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerNorm *v4l2norm = GST_V4L2_TUNER_NORM (norm);
@@ -269,12 +260,12 @@ gst_v4l2_tuner_set_norm (GstTuner *mixer,
if (gst_v4l2_set_norm (v4l2element, v4l2norm->index)) {
gst_tuner_norm_changed (mixer, norm);
- g_object_notify (G_OBJECT (v4l2element), "norm");
+ g_object_notify (G_OBJECT (v4l2element), "norm");
}
}
static GstTunerNorm *
-gst_v4l2_tuner_get_norm (GstTuner *mixer)
+gst_v4l2_tuner_get_norm (GstTuner * mixer)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GList *item;
@@ -294,9 +285,8 @@ gst_v4l2_tuner_get_norm (GstTuner *mixer)
}
static void
-gst_v4l2_tuner_set_frequency (GstTuner *mixer,
- GstTunerChannel *channel,
- gulong frequency)
+gst_v4l2_tuner_set_frequency (GstTuner * mixer,
+ GstTunerChannel * channel, gulong frequency)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
@@ -305,7 +295,7 @@ gst_v4l2_tuner_set_frequency (GstTuner *mixer,
/* assert that we're opened and that we're using a known item */
g_return_if_fail (GST_V4L2_IS_OPEN (v4l2element));
g_return_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY));
+ GST_TUNER_CHANNEL_FREQUENCY));
g_return_if_fail (gst_v4l2_tuner_contains_channel (v4l2element, v4l2channel));
gst_v4l2_get_input (v4l2element, &chan);
@@ -313,14 +303,13 @@ gst_v4l2_tuner_set_frequency (GstTuner *mixer,
GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
if (gst_v4l2_set_frequency (v4l2element, v4l2channel->tuner, frequency)) {
gst_tuner_frequency_changed (mixer, channel, frequency);
- g_object_notify (G_OBJECT (v4l2element), "frequency");
+ g_object_notify (G_OBJECT (v4l2element), "frequency");
}
}
}
static gulong
-gst_v4l2_tuner_get_frequency (GstTuner *mixer,
- GstTunerChannel *channel)
+gst_v4l2_tuner_get_frequency (GstTuner * mixer, GstTunerChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
@@ -330,9 +319,9 @@ gst_v4l2_tuner_get_frequency (GstTuner *mixer,
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY), 0);
+ GST_TUNER_CHANNEL_FREQUENCY), 0);
g_return_val_if_fail (gst_v4l2_tuner_contains_channel (v4l2element,
- v4l2channel), 0);
+ v4l2channel), 0);
gst_v4l2_get_input (v4l2element, &chan);
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
@@ -344,8 +333,7 @@ gst_v4l2_tuner_get_frequency (GstTuner *mixer,
}
static gint
-gst_v4l2_tuner_signal_strength (GstTuner *mixer,
- GstTunerChannel *channel)
+gst_v4l2_tuner_signal_strength (GstTuner * mixer, GstTunerChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
@@ -355,9 +343,9 @@ gst_v4l2_tuner_signal_strength (GstTuner *mixer,
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY), 0);
+ GST_TUNER_CHANNEL_FREQUENCY), 0);
g_return_val_if_fail (gst_v4l2_tuner_contains_channel (v4l2element,
- v4l2channel), 0);
+ v4l2channel), 0);
gst_v4l2_get_input (v4l2element, &chan);
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
diff --git a/sys/v4l2/gstv4l2tuner.h b/sys/v4l2/gstv4l2tuner.h
index a768ea2f..729fe221 100644
--- a/sys/v4l2/gstv4l2tuner.h
+++ b/sys/v4l2/gstv4l2tuner.h
@@ -28,7 +28,6 @@
#include "gstv4l2element.h"
G_BEGIN_DECLS
-
#define GST_TYPE_V4L2_TUNER_CHANNEL \
(gst_v4l2_tuner_channel_get_type ())
#define GST_V4L2_TUNER_CHANNEL(obj) \
@@ -41,16 +40,17 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_TUNER_CHANNEL))
#define GST_IS_V4L2_TUNER_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_TUNER_CHANNEL))
-
-typedef struct _GstV4l2TunerChannel {
+ typedef struct _GstV4l2TunerChannel
+{
GstTunerChannel parent;
- guint32 index;
- guint32 tuner;
- guint32 audio;
+ guint32 index;
+ guint32 tuner;
+ guint32 audio;
} GstV4l2TunerChannel;
-typedef struct _GstV4l2TunerChannelClass {
+typedef struct _GstV4l2TunerChannelClass
+{
GstTunerChannelClass parent;
} GstV4l2TunerChannelClass;
@@ -67,19 +67,21 @@ typedef struct _GstV4l2TunerChannelClass {
#define GST_IS_V4L2_TUNER_NORM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_TUNER_NORM))
-typedef struct _GstV4l2TunerNorm {
+typedef struct _GstV4l2TunerNorm
+{
GstTunerNorm parent;
- v4l2_std_id index;
+ v4l2_std_id index;
} GstV4l2TunerNorm;
-typedef struct _GstV4l2TunerNormClass {
+typedef struct _GstV4l2TunerNormClass
+{
GstTunerNormClass parent;
} GstV4l2TunerNormClass;
-GType gst_v4l2_tuner_channel_get_type (void);
-GType gst_v4l2_tuner_norm_get_type (void);
+GType gst_v4l2_tuner_channel_get_type (void);
+GType gst_v4l2_tuner_norm_get_type (void);
-void gst_v4l2_tuner_interface_init (GstTunerClass *klass);
+void gst_v4l2_tuner_interface_init (GstTunerClass * klass);
#endif /* __GST_V4L2_TUNER_H__ */
diff --git a/sys/v4l2/gstv4l2xoverlay.c b/sys/v4l2/gstv4l2xoverlay.c
index 10c5f77b..1af62cc1 100644
--- a/sys/v4l2/gstv4l2xoverlay.c
+++ b/sys/v4l2/gstv4l2xoverlay.c
@@ -31,24 +31,23 @@
#include "gstv4l2element.h"
#include "v4l2_calls.h"
-static void gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
- XID xwindow_id);
+static void gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay * overlay,
+ XID xwindow_id);
void
-gst_v4l2_xoverlay_interface_init (GstXOverlayClass *klass)
+gst_v4l2_xoverlay_interface_init (GstXOverlayClass * klass)
{
/* default virtual functions */
klass->set_xwindow_id = gst_v4l2_xoverlay_set_xwindow_id;
}
GstXWindowListener *
-gst_v4l2_xoverlay_new (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_new (GstV4l2Element * v4l2element)
{
- GstXWindowListener *xwin =
- gst_x_window_listener_new (NULL,
- (MapWindowFunc) gst_v4l2_enable_overlay,
- (SetWindowFunc) gst_v4l2_set_window,
- (gpointer) v4l2element);
+ GstXWindowListener *xwin = gst_x_window_listener_new (NULL,
+ (MapWindowFunc) gst_v4l2_enable_overlay,
+ (SetWindowFunc) gst_v4l2_set_window,
+ (gpointer) v4l2element);
v4l2element->overlay = xwin;
v4l2element->xwindow_id = 0;
@@ -57,7 +56,7 @@ gst_v4l2_xoverlay_new (GstV4l2Element *v4l2element)
}
void
-gst_v4l2_xoverlay_free (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_free (GstV4l2Element * v4l2element)
{
gst_v4l2_xoverlay_close (v4l2element);
g_object_unref (G_OBJECT (v4l2element->overlay));
@@ -65,7 +64,7 @@ gst_v4l2_xoverlay_free (GstV4l2Element *v4l2element)
}
void
-gst_v4l2_xoverlay_open (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element)
{
GstXWindowListener *xwin = v4l2element->overlay;
@@ -73,22 +72,20 @@ gst_v4l2_xoverlay_open (GstV4l2Element *v4l2element)
xwin->display_name = g_strdup (v4l2element->display);
if (v4l2element->xwindow_id != 0 &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, v4l2element->xwindow_id);
}
}
}
void
-gst_v4l2_xoverlay_close (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_close (GstV4l2Element * v4l2element)
{
GstXWindowListener *xwin = v4l2element->overlay;
if (xwin != NULL) {
if (v4l2element->xwindow_id != 0 &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, 0);
}
@@ -98,8 +95,7 @@ gst_v4l2_xoverlay_close (GstV4l2Element *v4l2element)
}
static void
-gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
- XID xwindow_id)
+gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (overlay);
GstXWindowListener *xwin = v4l2element->overlay;
@@ -110,9 +106,7 @@ gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
if (gst_element_get_state (GST_ELEMENT (v4l2element)) != GST_STATE_NULL &&
v4l2element->xwindow_id != 0 &&
- xwin != NULL &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin != NULL && xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, 0);
}
@@ -120,9 +114,7 @@ gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
if (gst_element_get_state (GST_ELEMENT (v4l2element)) != GST_STATE_NULL &&
v4l2element->xwindow_id != 0 &&
- xwin != NULL &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin != NULL && xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, v4l2element->xwindow_id);
}
}
diff --git a/sys/v4l2/gstv4l2xoverlay.h b/sys/v4l2/gstv4l2xoverlay.h
index cfcdfd35..d5cb7796 100644
--- a/sys/v4l2/gstv4l2xoverlay.h
+++ b/sys/v4l2/gstv4l2xoverlay.h
@@ -27,16 +27,13 @@
#include "gstv4l2element.h"
-G_BEGIN_DECLS
+G_BEGIN_DECLS void gst_v4l2_xoverlay_interface_init (GstXOverlayClass * klass);
-void gst_v4l2_xoverlay_interface_init (GstXOverlayClass *klass);
-
-GstXWindowListener *
- gst_v4l2_xoverlay_new (GstV4l2Element *v4l2element);
-void gst_v4l2_xoverlay_free (GstV4l2Element *v4l2element);
+GstXWindowListener *gst_v4l2_xoverlay_new (GstV4l2Element * v4l2element);
+void gst_v4l2_xoverlay_free (GstV4l2Element * v4l2element);
/* signal handlers */
-void gst_v4l2_xoverlay_open (GstV4l2Element *v4l2element);
-void gst_v4l2_xoverlay_close (GstV4l2Element *v4l2element);
+void gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element);
+void gst_v4l2_xoverlay_close (GstV4l2Element * v4l2element);
#endif /* __GST_V4L2_X_OVERLAY_H__ */
diff --git a/sys/v4l2/v4l2-overlay_calls.c b/sys/v4l2/v4l2-overlay_calls.c
index 4d948d0b..d4a10ab7 100644
--- a/sys/v4l2/v4l2-overlay_calls.c
+++ b/sys/v4l2/v4l2-overlay_calls.c
@@ -43,39 +43,37 @@
******************************************************/
gboolean
-gst_v4l2_set_display (GstV4l2Element *v4l2element)
+gst_v4l2_set_display (GstV4l2Element * v4l2element)
{
- gchar *buff;
-
- if (v4l2element->display)
- g_free(v4l2element->display);
- v4l2element->display = g_strdup(g_getenv("DISPLAY"));
-
- DEBUG("trying to set overlay to '%s'", v4l2element->display);
-
- /* start v4l-conf */
- buff = g_strdup_printf("v4l-conf -q -c %s -d %s",
- v4l2element->device, v4l2element->display);
-
- switch (system(buff)) {
- case -1:
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
- (_("Could not start v4l-conf.")),
- GST_ERROR_SYSTEM);
- g_free(buff);
- return FALSE;
- case 0:
- break;
- default:
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
- (_("Executing v4l-conf failed.")),
- GST_ERROR_SYSTEM);
- g_free(buff);
- return FALSE;
- }
-
- g_free(buff);
- return TRUE;
+ gchar *buff;
+
+ if (v4l2element->display)
+ g_free (v4l2element->display);
+ v4l2element->display = g_strdup (g_getenv ("DISPLAY"));
+
+ DEBUG ("trying to set overlay to '%s'", v4l2element->display);
+
+ /* start v4l-conf */
+ buff = g_strdup_printf ("v4l-conf -q -c %s -d %s",
+ v4l2element->device, v4l2element->display);
+
+ switch (system (buff)) {
+ case -1:
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
+ (_("Could not start v4l-conf.")), GST_ERROR_SYSTEM);
+ g_free (buff);
+ return FALSE;
+ case 0:
+ break;
+ default:
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
+ (_("Executing v4l-conf failed.")), GST_ERROR_SYSTEM);
+ g_free (buff);
+ return FALSE;
+ }
+
+ g_free (buff);
+ return TRUE;
}
@@ -86,38 +84,33 @@ gst_v4l2_set_display (GstV4l2Element *v4l2element)
******************************************************/
gboolean
-gst_v4l2_set_window (GstElement *element,
- gint x,
- gint y,
- gint w,
- gint h,
- struct v4l2_clip *clips,
- gint num_clips)
+gst_v4l2_set_window (GstElement * element,
+ gint x, gint y, gint w, gint h, struct v4l2_clip * clips, gint num_clips)
{
- struct v4l2_format fmt;
- GstV4l2Element *v4l2element = GST_V4L2ELEMENT(element);
-
- DEBUG("trying to set video window to %dx%d,%d,%d", x,y,w,h);
- GST_V4L2_CHECK_OVERLAY(v4l2element);
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- fmt.type = V4L2_CAP_VIDEO_OVERLAY;
- fmt.fmt.win.clipcount = 0;
- fmt.fmt.win.w.left = x;
- fmt.fmt.win.w.top = y;
- fmt.fmt.win.w.width = w;
- fmt.fmt.win.w.height = h;
- fmt.fmt.win.clips = clips;
- fmt.fmt.win.clipcount = num_clips;
- fmt.fmt.win.bitmap = NULL;
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_FMT, &fmt) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to set the video window: %s", g_strerror (errno)));
- return FALSE;
- }
-
- return TRUE;
+ struct v4l2_format fmt;
+ GstV4l2Element *v4l2element = GST_V4L2ELEMENT (element);
+
+ DEBUG ("trying to set video window to %dx%d,%d,%d", x, y, w, h);
+ GST_V4L2_CHECK_OVERLAY (v4l2element);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ fmt.type = V4L2_CAP_VIDEO_OVERLAY;
+ fmt.fmt.win.clipcount = 0;
+ fmt.fmt.win.w.left = x;
+ fmt.fmt.win.w.top = y;
+ fmt.fmt.win.w.width = w;
+ fmt.fmt.win.w.height = h;
+ fmt.fmt.win.clips = clips;
+ fmt.fmt.win.clipcount = num_clips;
+ fmt.fmt.win.bitmap = NULL;
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_FMT, &fmt) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
+ ("Failed to set the video window: %s", g_strerror (errno)));
+ return FALSE;
+ }
+
+ return TRUE;
}
@@ -128,21 +121,20 @@ gst_v4l2_set_window (GstElement *element,
******************************************************/
gboolean
-gst_v4l2_enable_overlay (GstV4l2Element *v4l2element,
- gboolean enable)
+gst_v4l2_enable_overlay (GstV4l2Element * v4l2element, gboolean enable)
{
- gint doit = enable?1:0;
+ gint doit = enable ? 1 : 0;
- DEBUG("trying to %s overlay display", enable?"enable":"disable");
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_OVERLAY(v4l2element);
+ DEBUG ("trying to %s overlay display", enable ? "enable" : "disable");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_OVERLAY (v4l2element);
- if (ioctl(v4l2element->video_fd, VIDIOC_OVERLAY, &doit) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to %s overlay display: %s",
- enable?"enable":"disable", g_strerror (errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_OVERLAY, &doit) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
+ ("Failed to %s overlay display: %s",
+ enable ? "enable" : "disable", g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
index f7c3d3a0..f75ea550 100644
--- a/sys/v4l2/v4l2_calls.c
+++ b/sys/v4l2/v4l2_calls.c
@@ -49,19 +49,19 @@
******************************************************/
static gboolean
-gst_v4l2_get_capabilities (GstV4l2Element *v4l2element)
+gst_v4l2_get_capabilities (GstV4l2Element * v4l2element)
{
- DEBUG("getting capabilities");
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_QUERYCAP, &(v4l2element->vcap)) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Error getting %s capabilities: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("getting capabilities");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_QUERYCAP, &(v4l2element->vcap)) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Error getting %s capabilities: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -72,288 +72,269 @@ gst_v4l2_get_capabilities (GstV4l2Element *v4l2element)
******************************************************/
static gboolean
-gst_v4l2_fill_lists (GstV4l2Element *v4l2element)
+gst_v4l2_fill_lists (GstV4l2Element * v4l2element)
{
- gint n;
- const GList *pads =
- gst_element_get_pad_list (GST_ELEMENT (v4l2element));
- GstPadDirection dir = GST_PAD_UNKNOWN;
-
- DEBUG("getting enumerations");
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- /* sinks have outputs, all others have inputs */
- if (pads && g_list_length ((GList *) pads) == 1)
- dir = GST_PAD_DIRECTION (GST_PAD (pads->data));
-
- if (dir != GST_PAD_SINK) {
- /* and now, the inputs */
- for (n=0;;n++) {
- struct v4l2_input input;
- GstV4l2TunerChannel *v4l2channel;
- GstTunerChannel *channel;
-
- input.index = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_ENUMINPUT,
- &input) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in input enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
-
- v4l2channel =
- g_object_new(GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
- channel = GST_TUNER_CHANNEL(v4l2channel);
- channel->label = g_strdup(input.name);
- channel->flags = GST_TUNER_CHANNEL_INPUT;
- v4l2channel->index = n;
- if (input.type == V4L2_INPUT_TYPE_TUNER) {
- struct v4l2_tuner vtun;
-
- v4l2channel->tuner = input.tuner;
- channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
-
- vtun.index = input.tuner;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_TUNER,
- &vtun) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get tuner %d settings on %s: %s",
- input.tuner,
- v4l2element->device,
- g_strerror (errno)));
- g_object_unref(G_OBJECT(channel));
- return FALSE;
- }
- channel->min_frequency = vtun.rangelow;
- channel->max_frequency = vtun.rangehigh;
- channel->min_signal = 0;
- channel->max_signal = 0xffff;
- }
- if (input.audioset) {
- /* we take the first. We don't care for
- * the others for now */
- while (!(input.audioset &
- (1<<v4l2channel->audio)))
- v4l2channel->audio++;
- channel->flags |= GST_TUNER_CHANNEL_AUDIO;
- }
-
- v4l2element->channels =
- g_list_append(v4l2element->channels,
- (gpointer) channel);
- }
- } else {
- /* outputs */
- for (n=0;;n++) {
- struct v4l2_output output;
- GstV4l2TunerChannel *v4l2channel;
- GstTunerChannel *channel;
-
- output.index = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_ENUMOUTPUT,
- &output) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in output enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
-
- v4l2channel = g_object_new(GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
- channel = GST_TUNER_CHANNEL(v4l2channel);
- channel->label = g_strdup(output.name);
- channel->flags = GST_TUNER_CHANNEL_OUTPUT;
- v4l2channel->index = n;
- if (output.audioset) {
- /* we take the first. We don't care for
- * the others for now */
- while (!(output.audioset &
- (1<<v4l2channel->audio)))
- v4l2channel->audio++;
- channel->flags |= GST_TUNER_CHANNEL_AUDIO;
- }
-
- v4l2element->channels =
- g_list_append(v4l2element->channels,
- (gpointer) channel);
- }
+ gint n;
+ const GList *pads = gst_element_get_pad_list (GST_ELEMENT (v4l2element));
+ GstPadDirection dir = GST_PAD_UNKNOWN;
+
+ DEBUG ("getting enumerations");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ /* sinks have outputs, all others have inputs */
+ if (pads && g_list_length ((GList *) pads) == 1)
+ dir = GST_PAD_DIRECTION (GST_PAD (pads->data));
+
+ if (dir != GST_PAD_SINK) {
+ /* and now, the inputs */
+ for (n = 0;; n++) {
+ struct v4l2_input input;
+ GstV4l2TunerChannel *v4l2channel;
+ GstTunerChannel *channel;
+
+ input.index = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in input enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
}
-
- /* norms... */
- for (n=0;;n++) {
- struct v4l2_standard standard;
- GstV4l2TunerNorm *v4l2norm;
- GstTunerNorm *norm;
-
- standard.index = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_ENUMSTD, &standard) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in norm enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
-
- v4l2norm = g_object_new(GST_TYPE_V4L2_TUNER_NORM, NULL);
- norm = GST_TUNER_NORM (v4l2norm);
- norm->label = g_strdup(standard.name);
- norm->fps = (gfloat) standard.frameperiod.denominator /
- standard.frameperiod.numerator;
- v4l2norm->index = standard.id;
-
- v4l2element->norms = g_list_append(v4l2element->norms,
- (gpointer) norm);
+ }
+
+ v4l2channel = g_object_new (GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
+ channel = GST_TUNER_CHANNEL (v4l2channel);
+ channel->label = g_strdup (input.name);
+ channel->flags = GST_TUNER_CHANNEL_INPUT;
+ v4l2channel->index = n;
+ if (input.type == V4L2_INPUT_TYPE_TUNER) {
+ struct v4l2_tuner vtun;
+
+ v4l2channel->tuner = input.tuner;
+ channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
+
+ vtun.index = input.tuner;
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_TUNER, &vtun) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get tuner %d settings on %s: %s",
+ input.tuner, v4l2element->device, g_strerror (errno)));
+ g_object_unref (G_OBJECT (channel));
+ return FALSE;
+ }
+ channel->min_frequency = vtun.rangelow;
+ channel->max_frequency = vtun.rangehigh;
+ channel->min_signal = 0;
+ channel->max_signal = 0xffff;
+ }
+ if (input.audioset) {
+ /* we take the first. We don't care for
+ * the others for now */
+ while (!(input.audioset & (1 << v4l2channel->audio)))
+ v4l2channel->audio++;
+ channel->flags |= GST_TUNER_CHANNEL_AUDIO;
+ }
+
+ v4l2element->channels =
+ g_list_append (v4l2element->channels, (gpointer) channel);
+ }
+ } else {
+ /* outputs */
+ for (n = 0;; n++) {
+ struct v4l2_output output;
+ GstV4l2TunerChannel *v4l2channel;
+ GstTunerChannel *channel;
+
+ output.index = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_ENUMOUTPUT, &output) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in output enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
}
+ }
+
+ v4l2channel = g_object_new (GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
+ channel = GST_TUNER_CHANNEL (v4l2channel);
+ channel->label = g_strdup (output.name);
+ channel->flags = GST_TUNER_CHANNEL_OUTPUT;
+ v4l2channel->index = n;
+ if (output.audioset) {
+ /* we take the first. We don't care for
+ * the others for now */
+ while (!(output.audioset & (1 << v4l2channel->audio)))
+ v4l2channel->audio++;
+ channel->flags |= GST_TUNER_CHANNEL_AUDIO;
+ }
+
+ v4l2element->channels =
+ g_list_append (v4l2element->channels, (gpointer) channel);
+ }
+ }
- /* and lastly, controls+menus (if appropriate) */
- for (n=V4L2_CID_BASE;;n++) {
- struct v4l2_queryctrl control;
- GstV4l2ColorBalanceChannel *v4l2channel;
- GstColorBalanceChannel *channel;
-
- /* hacky... */
- if (n == V4L2_CID_LASTP1)
- n = V4L2_CID_PRIVATE_BASE;
-
- control.id = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_QUERYCTRL, &control) < 0) {
- if (errno == EINVAL) {
- if (n < V4L2_CID_PRIVATE_BASE)
- continue;
- else
- break;
- } else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in control enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
- if (control.flags & V4L2_CTRL_FLAG_DISABLED)
- continue;
-
- switch (n) {
- case V4L2_CID_BRIGHTNESS:
- case V4L2_CID_CONTRAST:
- case V4L2_CID_SATURATION:
- case V4L2_CID_HUE:
- case V4L2_CID_BLACK_LEVEL:
- case V4L2_CID_AUTO_WHITE_BALANCE:
- case V4L2_CID_DO_WHITE_BALANCE:
- case V4L2_CID_RED_BALANCE:
- case V4L2_CID_BLUE_BALANCE:
- case V4L2_CID_GAMMA:
- case V4L2_CID_EXPOSURE:
- case V4L2_CID_AUTOGAIN:
- case V4L2_CID_GAIN:
- /* we only handle these for now */
- break;
- default:
- DEBUG("ControlID %s (%d) unhandled, FIXME",
- control.name, n);
- control.id++;
- break;
- }
- if (n != control.id)
- continue;
-
- v4l2channel = g_object_new(GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL,
- NULL);
- channel = GST_COLOR_BALANCE_CHANNEL(v4l2channel);
- channel->label = g_strdup(control.name);
- v4l2channel->index = n;
+ /* norms... */
+ for (n = 0;; n++) {
+ struct v4l2_standard standard;
+ GstV4l2TunerNorm *v4l2norm;
+ GstTunerNorm *norm;
+
+ standard.index = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_ENUMSTD, &standard) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in norm enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
+ }
+
+ v4l2norm = g_object_new (GST_TYPE_V4L2_TUNER_NORM, NULL);
+ norm = GST_TUNER_NORM (v4l2norm);
+ norm->label = g_strdup (standard.name);
+ norm->fps = (gfloat) standard.frameperiod.denominator /
+ standard.frameperiod.numerator;
+ v4l2norm->index = standard.id;
+
+ v4l2element->norms = g_list_append (v4l2element->norms, (gpointer) norm);
+ }
+
+ /* and lastly, controls+menus (if appropriate) */
+ for (n = V4L2_CID_BASE;; n++) {
+ struct v4l2_queryctrl control;
+ GstV4l2ColorBalanceChannel *v4l2channel;
+ GstColorBalanceChannel *channel;
+
+ /* hacky... */
+ if (n == V4L2_CID_LASTP1)
+ n = V4L2_CID_PRIVATE_BASE;
+
+ control.id = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_QUERYCTRL, &control) < 0) {
+ if (errno == EINVAL) {
+ if (n < V4L2_CID_PRIVATE_BASE)
+ continue;
+ else
+ break;
+ } else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in control enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
+ }
+ if (control.flags & V4L2_CTRL_FLAG_DISABLED)
+ continue;
+
+ switch (n) {
+ case V4L2_CID_BRIGHTNESS:
+ case V4L2_CID_CONTRAST:
+ case V4L2_CID_SATURATION:
+ case V4L2_CID_HUE:
+ case V4L2_CID_BLACK_LEVEL:
+ case V4L2_CID_AUTO_WHITE_BALANCE:
+ case V4L2_CID_DO_WHITE_BALANCE:
+ case V4L2_CID_RED_BALANCE:
+ case V4L2_CID_BLUE_BALANCE:
+ case V4L2_CID_GAMMA:
+ case V4L2_CID_EXPOSURE:
+ case V4L2_CID_AUTOGAIN:
+ case V4L2_CID_GAIN:
+ /* we only handle these for now */
+ break;
+ default:
+ DEBUG ("ControlID %s (%d) unhandled, FIXME", control.name, n);
+ control.id++;
+ break;
+ }
+ if (n != control.id)
+ continue;
+
+ v4l2channel = g_object_new (GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL, NULL);
+ channel = GST_COLOR_BALANCE_CHANNEL (v4l2channel);
+ channel->label = g_strdup (control.name);
+ v4l2channel->index = n;
#if 0
- if (control.type == V4L2_CTRL_TYPE_MENU) {
- struct v4l2_querymenu menu, *mptr;
- int i;
- menu.id = n;
- for (i=0;;i++) {
- menu.index = i;
- if (ioctl(v4l2element->video_fd, VIDIOC_QUERYMENU, &menu) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in menu enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
- mptr = g_malloc(sizeof(menu));
- memcpy(mptr, &menu, sizeof(menu));
- menus = g_list_append(menus, mptr);
- }
- }
- v4l2element->menus = g_list_append(v4l2element->menus, menus);
+ if (control.type == V4L2_CTRL_TYPE_MENU) {
+ struct v4l2_querymenu menu, *mptr;
+ int i;
+
+ menu.id = n;
+ for (i = 0;; i++) {
+ menu.index = i;
+ if (ioctl (v4l2element->video_fd, VIDIOC_QUERYMENU, &menu) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in menu enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
+ }
+ mptr = g_malloc (sizeof (menu));
+ memcpy (mptr, &menu, sizeof (menu));
+ menus = g_list_append (menus, mptr);
+ }
+ }
+ v4l2element->menus = g_list_append (v4l2element->menus, menus);
#endif
- switch (control.type) {
- case V4L2_CTRL_TYPE_INTEGER:
- channel->min_value = control.minimum;
- channel->max_value = control.maximum;
- break;
- case V4L2_CTRL_TYPE_BOOLEAN:
- channel->min_value = FALSE;
- channel->max_value = TRUE;
- break;
- default:
- channel->min_value =
- channel->max_value = 0;
- break;
- }
-
- v4l2element->colors = g_list_append(v4l2element->colors,
- (gpointer) channel);
- }
+ switch (control.type) {
+ case V4L2_CTRL_TYPE_INTEGER:
+ channel->min_value = control.minimum;
+ channel->max_value = control.maximum;
+ break;
+ case V4L2_CTRL_TYPE_BOOLEAN:
+ channel->min_value = FALSE;
+ channel->max_value = TRUE;
+ break;
+ default:
+ channel->min_value = channel->max_value = 0;
+ break;
+ }
- return TRUE;
+ v4l2element->colors = g_list_append (v4l2element->colors,
+ (gpointer) channel);
+ }
+
+ return TRUE;
}
static void
-gst_v4l2_empty_lists (GstV4l2Element *v4l2element)
+gst_v4l2_empty_lists (GstV4l2Element * v4l2element)
{
- DEBUG("deleting enumerations");
+ DEBUG ("deleting enumerations");
- g_list_foreach (v4l2element->channels, (GFunc) g_object_unref, NULL);
- g_list_free (v4l2element->channels);
- v4l2element->channels = NULL;
+ g_list_foreach (v4l2element->channels, (GFunc) g_object_unref, NULL);
+ g_list_free (v4l2element->channels);
+ v4l2element->channels = NULL;
- g_list_foreach (v4l2element->norms, (GFunc) g_object_unref, NULL);
- g_list_free (v4l2element->norms);
- v4l2element->norms = NULL;
+ g_list_foreach (v4l2element->norms, (GFunc) g_object_unref, NULL);
+ g_list_free (v4l2element->norms);
+ v4l2element->norms = NULL;
- g_list_foreach (v4l2element->colors, (GFunc) g_object_unref, NULL);
- g_list_free (v4l2element->colors);
- v4l2element->colors = NULL;
+ g_list_foreach (v4l2element->colors, (GFunc) g_object_unref, NULL);
+ g_list_free (v4l2element->colors);
+ v4l2element->colors = NULL;
}
/* FIXME: move this stuff to gstv4l2tuner.c? */
static void
-gst_v4l2_set_defaults (GstV4l2Element *v4l2element)
+gst_v4l2_set_defaults (GstV4l2Element * v4l2element)
{
GstTunerNorm *norm = NULL;
GstTunerChannel *channel = NULL;
GstTuner *tuner = GST_TUNER (v4l2element);
-
+
if (v4l2element->norm)
norm = gst_tuner_find_norm_by_name (tuner, v4l2element->norm);
if (norm) {
@@ -362,18 +343,19 @@ gst_v4l2_set_defaults (GstV4l2Element *v4l2element)
norm = GST_TUNER_NORM (gst_tuner_get_norm (GST_TUNER (v4l2element)));
v4l2element->norm = g_strdup (norm->label);
gst_tuner_norm_changed (tuner, norm);
- g_object_notify (G_OBJECT (v4l2element), "norm");
+ g_object_notify (G_OBJECT (v4l2element), "norm");
}
-
- if (v4l2element->channel)
+
+ if (v4l2element->channel)
channel = gst_tuner_find_channel_by_name (tuner, v4l2element->channel);
if (channel) {
gst_tuner_set_channel (tuner, channel);
} else {
- channel = GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2element)));
+ channel =
+ GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2element)));
v4l2element->channel = g_strdup (channel->label);
gst_tuner_channel_changed (tuner, channel);
- g_object_notify (G_OBJECT (v4l2element), "channel");
+ g_object_notify (G_OBJECT (v4l2element), "channel");
}
if (v4l2element->frequency != 0) {
gst_tuner_set_frequency (tuner, channel, v4l2element->frequency);
@@ -396,61 +378,61 @@ gst_v4l2_set_defaults (GstV4l2Element *v4l2element)
******************************************************/
gboolean
-gst_v4l2_open (GstV4l2Element *v4l2element)
+gst_v4l2_open (GstV4l2Element * v4l2element)
{
- DEBUG("Trying to open device %s", v4l2element->device);
- GST_V4L2_CHECK_NOT_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- /* be sure we have a device */
- if (!v4l2element->device)
- v4l2element->device = g_strdup("/dev/video");
-
- /* open the device */
- v4l2element->video_fd = open(v4l2element->device, O_RDWR);
- if (!GST_V4L2_IS_OPEN(v4l2element)) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, OPEN_READ_WRITE,
- (_("Could not open device \"%s\" for reading and writing."), v4l2element->device),
- GST_ERROR_SYSTEM);
- goto error;
- }
+ DEBUG ("Trying to open device %s", v4l2element->device);
+ GST_V4L2_CHECK_NOT_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ /* be sure we have a device */
+ if (!v4l2element->device)
+ v4l2element->device = g_strdup ("/dev/video");
+
+ /* open the device */
+ v4l2element->video_fd = open (v4l2element->device, O_RDWR);
+ if (!GST_V4L2_IS_OPEN (v4l2element)) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, OPEN_READ_WRITE,
+ (_("Could not open device \"%s\" for reading and writing."),
+ v4l2element->device), GST_ERROR_SYSTEM);
+ goto error;
+ }
- /* get capabilities */
- if (!gst_v4l2_get_capabilities(v4l2element)) {
- goto error;
- }
+ /* get capabilities */
+ if (!gst_v4l2_get_capabilities (v4l2element)) {
+ goto error;
+ }
- /* do we need to be a capture device? */
- if (GST_IS_V4L2SRC(v4l2element) &&
- !(v4l2element->vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, NOT_FOUND,
- (_("Device \"%s\" is not a capture device."), v4l2element->device),
- ("Capabilities: 0x%x", v4l2element->vcap.capabilities));
- goto error;
- }
+ /* do we need to be a capture device? */
+ if (GST_IS_V4L2SRC (v4l2element) &&
+ !(v4l2element->vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, NOT_FOUND,
+ (_("Device \"%s\" is not a capture device."), v4l2element->device),
+ ("Capabilities: 0x%x", v4l2element->vcap.capabilities));
+ goto error;
+ }
- /* create enumerations */
- if (!gst_v4l2_fill_lists(v4l2element))
- goto error;
+ /* create enumerations */
+ if (!gst_v4l2_fill_lists (v4l2element))
+ goto error;
- /* set defaults */
- gst_v4l2_set_defaults (v4l2element);
+ /* set defaults */
+ gst_v4l2_set_defaults (v4l2element);
- GST_INFO_OBJECT (v4l2element, "Opened device '%s' (%s) successfully\n",
- v4l2element->vcap.card, v4l2element->device);
+ GST_INFO_OBJECT (v4l2element, "Opened device '%s' (%s) successfully\n",
+ v4l2element->vcap.card, v4l2element->device);
- return TRUE;
+ return TRUE;
error:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
- /* close device */
- close(v4l2element->video_fd);
- v4l2element->video_fd = -1;
- }
- /* empty lists */
- gst_v4l2_empty_lists(v4l2element);
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
+ /* close device */
+ close (v4l2element->video_fd);
+ v4l2element->video_fd = -1;
+ }
+ /* empty lists */
+ gst_v4l2_empty_lists (v4l2element);
- return FALSE;
+ return FALSE;
}
@@ -461,20 +443,20 @@ error:
******************************************************/
gboolean
-gst_v4l2_close (GstV4l2Element *v4l2element)
+gst_v4l2_close (GstV4l2Element * v4l2element)
{
- DEBUG("Trying to close %s", v4l2element->device);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
+ DEBUG ("Trying to close %s", v4l2element->device);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
- /* close device */
- close(v4l2element->video_fd);
- v4l2element->video_fd = -1;
+ /* close device */
+ close (v4l2element->video_fd);
+ v4l2element->video_fd = -1;
- /* empty lists */
- gst_v4l2_empty_lists(v4l2element);
+ /* empty lists */
+ gst_v4l2_empty_lists (v4l2element);
- return TRUE;
+ return TRUE;
}
@@ -485,20 +467,19 @@ gst_v4l2_close (GstV4l2Element *v4l2element)
******************************************************/
gboolean
-gst_v4l2_get_norm (GstV4l2Element *v4l2element,
- v4l2_std_id *norm)
+gst_v4l2_get_norm (GstV4l2Element * v4l2element, v4l2_std_id * norm)
{
- DEBUG("getting norm");
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_G_STD, norm) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get the current norm for device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("getting norm");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_STD, norm) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get the current norm for device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -509,21 +490,20 @@ gst_v4l2_get_norm (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_set_norm (GstV4l2Element *v4l2element,
- v4l2_std_id norm)
+gst_v4l2_set_norm (GstV4l2Element * v4l2element, v4l2_std_id norm)
{
- DEBUG("trying to set norm to %llx", norm);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_STD, &norm) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set norm 0x%llx for device %s: %s",
- norm, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("trying to set norm to %llx", norm);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_STD, &norm) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set norm 0x%llx for device %s: %s",
+ norm, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -534,24 +514,23 @@ gst_v4l2_set_norm (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_get_input (GstV4l2Element *v4l2element,
- gint *input)
+gst_v4l2_get_input (GstV4l2Element * v4l2element, gint * input)
{
- gint n;
+ gint n;
- DEBUG("trying to get input");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("trying to get input");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- if (ioctl(v4l2element->video_fd, VIDIOC_G_INPUT, &n) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get current input on device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_INPUT, &n) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get current input on device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *input = n;
+ *input = n;
- return TRUE;
+ return TRUE;
}
@@ -562,21 +541,20 @@ gst_v4l2_get_input (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_set_input (GstV4l2Element *v4l2element,
- gint input)
+gst_v4l2_set_input (GstV4l2Element * v4l2element, gint input)
{
- DEBUG("trying to set input to %d", input);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_INPUT, &input) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set input %d on device %s: %s",
- input, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("trying to set input to %d", input);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_INPUT, &input) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set input %d on device %s: %s",
+ input, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -587,24 +565,23 @@ gst_v4l2_set_input (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_get_output (GstV4l2Element *v4l2element,
- gint *output)
+gst_v4l2_get_output (GstV4l2Element * v4l2element, gint * output)
{
- gint n;
+ gint n;
- DEBUG("trying to get output");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("trying to get output");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- if (ioctl(v4l2element->video_fd, VIDIOC_G_OUTPUT, &n) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get current output on device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_OUTPUT, &n) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get current output on device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *output = n;
+ *output = n;
- return TRUE;
+ return TRUE;
}
@@ -615,21 +592,20 @@ gst_v4l2_get_output (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_set_output (GstV4l2Element *v4l2element,
- gint output)
+gst_v4l2_set_output (GstV4l2Element * v4l2element, gint output)
{
- DEBUG("trying to set output to %d", output);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_OUTPUT, &output) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set output %d on device %s: %s",
- output, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("trying to set output to %d", output);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_OUTPUT, &output) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set output %d on device %s: %s",
+ output, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -640,26 +616,25 @@ gst_v4l2_set_output (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_get_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *frequency)
+gst_v4l2_get_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * frequency)
{
- struct v4l2_frequency freq;
+ struct v4l2_frequency freq;
- DEBUG("getting current tuner frequency");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("getting current tuner frequency");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- freq.tuner = tunernum;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get current tuner frequency for device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ freq.tuner = tunernum;
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get current tuner frequency for device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *frequency = freq.frequency;
+ *frequency = freq.frequency;
- return TRUE;
+ return TRUE;
}
@@ -670,29 +645,28 @@ gst_v4l2_get_frequency (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_set_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong frequency)
+gst_v4l2_set_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong frequency)
{
- struct v4l2_frequency freq;
-
- DEBUG("setting current tuner frequency to %lu", frequency);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- freq.tuner = tunernum;
- /* fill in type - ignore error */
- ioctl(v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq);
- freq.frequency = frequency;
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_FREQUENCY, &freq) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set tuner frequency to %lu for device %s: %s",
- frequency, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ struct v4l2_frequency freq;
+
+ DEBUG ("setting current tuner frequency to %lu", frequency);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ freq.tuner = tunernum;
+ /* fill in type - ignore error */
+ ioctl (v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq);
+ freq.frequency = frequency;
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_FREQUENCY, &freq) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set tuner frequency to %lu for device %s: %s",
+ frequency, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -703,26 +677,25 @@ gst_v4l2_set_frequency (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_signal_strength (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *signal_strength)
+gst_v4l2_signal_strength (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * signal_strength)
{
- struct v4l2_tuner tuner;
+ struct v4l2_tuner tuner;
- DEBUG("trying to get signal strength");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("trying to get signal strength");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- tuner.index = tunernum;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_TUNER, &tuner) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get signal strength for device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ tuner.index = tunernum;
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_TUNER, &tuner) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get signal strength for device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *signal_strength = tuner.signal;
+ *signal_strength = tuner.signal;
- return TRUE;
+ return TRUE;
}
@@ -733,28 +706,27 @@ gst_v4l2_signal_strength (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_get_attribute (GstV4l2Element *v4l2element,
- int attribute_num,
- int *value)
+gst_v4l2_get_attribute (GstV4l2Element * v4l2element,
+ int attribute_num, int *value)
{
- struct v4l2_control control;
+ struct v4l2_control control;
- GST_V4L2_CHECK_OPEN(v4l2element);
+ GST_V4L2_CHECK_OPEN (v4l2element);
- DEBUG("getting value of attribute %d", attribute_num);
+ DEBUG ("getting value of attribute %d", attribute_num);
- control.id = attribute_num;
+ control.id = attribute_num;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_CTRL, &control) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get value for control %d on device %s: %s",
- attribute_num, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_CTRL, &control) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get value for control %d on device %s: %s",
+ attribute_num, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *value = control.value;
+ *value = control.value;
- return TRUE;
+ return TRUE;
}
@@ -765,26 +737,24 @@ gst_v4l2_get_attribute (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_set_attribute (GstV4l2Element *v4l2element,
- int attribute_num,
- const int value)
+gst_v4l2_set_attribute (GstV4l2Element * v4l2element,
+ int attribute_num, const int value)
{
- struct v4l2_control control;
+ struct v4l2_control control;
- GST_V4L2_CHECK_OPEN(v4l2element);
+ GST_V4L2_CHECK_OPEN (v4l2element);
- DEBUG("setting value of attribute %d to %d", attribute_num, value);
+ DEBUG ("setting value of attribute %d to %d", attribute_num, value);
- control.id = attribute_num;
- control.value = value;
+ control.id = attribute_num;
+ control.value = value;
- if (ioctl(v4l2element->video_fd, VIDIOC_S_CTRL, &control) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set value %d for control %d on device %s: %s",
- value, attribute_num, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_CTRL, &control) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set value %d for control %d on device %s: %s",
+ value, attribute_num, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-
diff --git a/sys/v4l2/v4l2_calls.h b/sys/v4l2/v4l2_calls.h
index 428c57aa..488e7bca 100644
--- a/sys/v4l2/v4l2_calls.h
+++ b/sys/v4l2/v4l2_calls.h
@@ -82,50 +82,36 @@
/* open/close the device */
-gboolean gst_v4l2_open (GstV4l2Element *v4l2element);
-gboolean gst_v4l2_close (GstV4l2Element *v4l2element);
+gboolean gst_v4l2_open (GstV4l2Element * v4l2element);
+gboolean gst_v4l2_close (GstV4l2Element * v4l2element);
/* norm/input/output */
-gboolean gst_v4l2_get_norm (GstV4l2Element *v4l2element,
- v4l2_std_id *norm);
-gboolean gst_v4l2_set_norm (GstV4l2Element *v4l2element,
- v4l2_std_id norm);
-gboolean gst_v4l2_get_input (GstV4l2Element *v4l2element,
- gint *input);
-gboolean gst_v4l2_set_input (GstV4l2Element *v4l2element,
- gint input);
-gboolean gst_v4l2_get_output (GstV4l2Element *v4l2element,
- gint *output);
-gboolean gst_v4l2_set_output (GstV4l2Element *v4l2element,
- gint output);
+gboolean gst_v4l2_get_norm (GstV4l2Element * v4l2element, v4l2_std_id * norm);
+gboolean gst_v4l2_set_norm (GstV4l2Element * v4l2element, v4l2_std_id norm);
+gboolean gst_v4l2_get_input (GstV4l2Element * v4l2element, gint * input);
+gboolean gst_v4l2_set_input (GstV4l2Element * v4l2element, gint input);
+gboolean gst_v4l2_get_output (GstV4l2Element * v4l2element, gint * output);
+gboolean gst_v4l2_set_output (GstV4l2Element * v4l2element, gint output);
/* frequency control */
-gboolean gst_v4l2_get_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *frequency);
-gboolean gst_v4l2_set_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong frequency);
-gboolean gst_v4l2_signal_strength (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *signal);
+gboolean gst_v4l2_get_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * frequency);
+gboolean gst_v4l2_set_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong frequency);
+gboolean gst_v4l2_signal_strength (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * signal);
/* attribute control */
-gboolean gst_v4l2_get_attribute (GstV4l2Element *v4l2element,
- int attribute,
- int *value);
-gboolean gst_v4l2_set_attribute (GstV4l2Element *v4l2element,
- int attribute,
- const int value);
+gboolean gst_v4l2_get_attribute (GstV4l2Element * v4l2element,
+ int attribute, int *value);
+gboolean gst_v4l2_set_attribute (GstV4l2Element * v4l2element,
+ int attribute, const int value);
/* overlay */
-gboolean gst_v4l2_set_display (GstV4l2Element *v4l2element);
-gboolean gst_v4l2_set_window (GstElement *element,
- gint x, gint y,
- gint w, gint h,
- struct v4l2_clip *clips,
- gint num_clips);
-gboolean gst_v4l2_enable_overlay (GstV4l2Element *v4l2element,
- gboolean enable);
+gboolean gst_v4l2_set_display (GstV4l2Element * v4l2element);
+gboolean gst_v4l2_set_window (GstElement * element,
+ gint x, gint y, gint w, gint h, struct v4l2_clip *clips, gint num_clips);
+gboolean gst_v4l2_enable_overlay (GstV4l2Element * v4l2element,
+ gboolean enable);
#endif /* __V4L2_CALLS_H__ */
diff --git a/sys/v4l2/v4l2src_calls.c b/sys/v4l2/v4l2src_calls.c
index 8b3276a6..00d710eb 100644
--- a/sys/v4l2/v4l2src_calls.c
+++ b/sys/v4l2/v4l2src_calls.c
@@ -56,7 +56,7 @@
******************************************************/
gboolean
-gst_v4l2src_fill_format_list (GstV4l2Src *v4l2src)
+gst_v4l2src_fill_format_list (GstV4l2Src * v4l2src)
{
gint n;
struct v4l2_fmtdesc *format;
@@ -64,22 +64,24 @@ gst_v4l2src_fill_format_list (GstV4l2Src *v4l2src)
GST_DEBUG_OBJECT (v4l2src, "getting src format enumerations");
/* format enumeration */
- for (n=0;;n++) {
+ for (n = 0;; n++) {
format = g_new (struct v4l2_fmtdesc, 1);
+
format->index = n;
format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_ENUM_FMT, format) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_ENUM_FMT,
+ format) < 0) {
if (errno == EINVAL) {
- break; /* end of enumeration */
+ break; /* end of enumeration */
} else {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
("failed to get number %d in pixelformat enumeration for %s: %s",
- n, GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
+ n, GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
g_free (format);
return FALSE;
}
}
- GST_LOG_OBJECT (v4l2src, "got format"GST_FOURCC_FORMAT,
+ GST_LOG_OBJECT (v4l2src, "got format" GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (format->pixelformat));
v4l2src->formats = g_slist_prepend (v4l2src->formats, format);
}
@@ -95,7 +97,7 @@ gst_v4l2src_fill_format_list (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_clear_format_list (GstV4l2Src *v4l2src)
+gst_v4l2src_clear_format_list (GstV4l2Src * v4l2src)
{
g_slist_foreach (v4l2src->formats, (GFunc) g_free, NULL);
g_slist_free (v4l2src->formats);
@@ -111,15 +113,16 @@ gst_v4l2src_clear_format_list (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_queue_frame (GstV4l2Src *v4l2src,
- guint i)
+gst_v4l2src_queue_frame (GstV4l2Src * v4l2src, guint i)
{
GST_LOG_OBJECT (v4l2src, "queueing frame %u", i);
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_QBUF, &v4l2src->pool->buffers[i].buffer) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_QBUF,
+ &v4l2src->pool->buffers[i].buffer) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, WRITE,
- (_("Could not write to device \"%s\"."), GST_V4L2ELEMENT(v4l2src)->device),
- ("Error queueing buffer %u on device %s", i, g_strerror(errno)));
+ (_("Could not write to device \"%s\"."),
+ GST_V4L2ELEMENT (v4l2src)->device),
+ ("Error queueing buffer %u on device %s", i, g_strerror (errno)));
return FALSE;
}
@@ -134,16 +137,17 @@ gst_v4l2src_queue_frame (GstV4l2Src *v4l2src,
******************************************************/
gint
-gst_v4l2src_grab_frame (GstV4l2Src *v4l2src)
+gst_v4l2src_grab_frame (GstV4l2Src * v4l2src)
{
struct v4l2_buffer buffer;
-
+
buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- while (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0) {
+ while (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0) {
/* if the sync() got interrupted, we can retry */
if (errno != EINTR) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SYNC, (NULL), ("could not sync on a buffer on device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SYNC, (NULL),
+ ("could not sync on a buffer on device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
return -1;
}
GST_DEBUG_OBJECT (v4l2src, "grab got interrupted");
@@ -162,21 +166,22 @@ gst_v4l2src_grab_frame (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_get_capture (GstV4l2Src *v4l2src)
+gst_v4l2src_get_capture (GstV4l2Src * v4l2src)
{
- DEBUG("Getting capture format");
+ DEBUG ("Getting capture format");
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
- v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_G_FMT, &v4l2src->format) < 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
- ("failed to get pixelformat for device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
- return FALSE;
- }
+ v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_G_FMT,
+ &v4l2src->format) < 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
+ ("failed to get pixelformat for device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -187,33 +192,33 @@ gst_v4l2src_get_capture (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_set_capture (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *fmt,
- gint width,
- gint height)
+gst_v4l2src_set_capture (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc * fmt, gint width, gint height)
{
- DEBUG("Setting capture format to %dx%d, format %s",
- width, height, fmt->description);
-
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_NOT_ACTIVE(GST_V4L2ELEMENT(v4l2src));
-
- memset(&v4l2src->format, 0, sizeof(struct v4l2_format));
- v4l2src->format.fmt.pix.width = width;
- v4l2src->format.fmt.pix.height = height;
- v4l2src->format.fmt.pix.pixelformat = fmt->pixelformat;
- v4l2src->format.fmt.pix.field = V4L2_FIELD_INTERLACED;
- v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_S_FMT, &v4l2src->format) < 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
- ("failed to set pixelformat to %s @ %dx%d for device %s: %s",
- fmt->description, width, height, GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
- return FALSE;
- }
-
- /* update internal info */
- return gst_v4l2src_get_capture(v4l2src);
+ DEBUG ("Setting capture format to %dx%d, format %s",
+ width, height, fmt->description);
+
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_NOT_ACTIVE (GST_V4L2ELEMENT (v4l2src));
+
+ memset (&v4l2src->format, 0, sizeof (struct v4l2_format));
+ v4l2src->format.fmt.pix.width = width;
+ v4l2src->format.fmt.pix.height = height;
+ v4l2src->format.fmt.pix.pixelformat = fmt->pixelformat;
+ v4l2src->format.fmt.pix.field = V4L2_FIELD_INTERLACED;
+ v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_S_FMT,
+ &v4l2src->format) < 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
+ ("failed to set pixelformat to %s @ %dx%d for device %s: %s",
+ fmt->description, width, height, GST_V4L2ELEMENT (v4l2src)->device,
+ g_strerror (errno)));
+ return FALSE;
+ }
+
+ /* update internal info */
+ return gst_v4l2src_get_capture (v4l2src);
}
@@ -224,15 +229,15 @@ gst_v4l2src_set_capture (GstV4l2Src *v4l2src,
******************************************************/
gboolean
-gst_v4l2src_capture_init (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_init (GstV4l2Src * v4l2src)
{
gint n;
guint buffers;
GST_DEBUG_OBJECT (v4l2src, "initting the capture system");
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_NOT_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_NOT_ACTIVE (GST_V4L2ELEMENT (v4l2src));
/* request buffer info */
buffers = v4l2src->breq.count;
@@ -244,25 +249,32 @@ gst_v4l2src_capture_init (GstV4l2Src *v4l2src)
}
v4l2src->breq.type = v4l2src->format.type;
v4l2src->breq.memory = V4L2_MEMORY_MMAP;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_REQBUFS, &v4l2src->breq) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_REQBUFS,
+ &v4l2src->breq) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
- (_("Could not get buffers from device \"%s\"."), GST_V4L2ELEMENT(v4l2src)->device),
- ("error requesting %d buffers: %s", v4l2src->breq.count, g_strerror (errno)));
+ (_("Could not get buffers from device \"%s\"."),
+ GST_V4L2ELEMENT (v4l2src)->device),
+ ("error requesting %d buffers: %s", v4l2src->breq.count,
+ g_strerror (errno)));
return FALSE;
}
if (v4l2src->breq.count < GST_V4L2_MIN_BUFFERS) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
- (_("Could not get enough buffers from device \"%s\"."), GST_V4L2ELEMENT(v4l2src)->device),
- ("we received %d, we want at least %d", v4l2src->breq.count, GST_V4L2_MIN_BUFFERS));
+ (_("Could not get enough buffers from device \"%s\"."),
+ GST_V4L2ELEMENT (v4l2src)->device),
+ ("we received %d, we want at least %d", v4l2src->breq.count,
+ GST_V4L2_MIN_BUFFERS));
v4l2src->breq.count = buffers;
return FALSE;
}
if (v4l2src->breq.count != buffers)
g_object_notify (G_OBJECT (v4l2src), "num_buffers");
- GST_INFO_OBJECT (v4l2src, "Got %d buffers ("GST_FOURCC_FORMAT") of size %d KB\n",
- v4l2src->breq.count, GST_FOURCC_ARGS (v4l2src->format.fmt.pix.pixelformat),
+ GST_INFO_OBJECT (v4l2src,
+ "Got %d buffers (" GST_FOURCC_FORMAT ") of size %d KB\n",
+ v4l2src->breq.count,
+ GST_FOURCC_ARGS (v4l2src->format.fmt.pix.pixelformat),
v4l2src->format.fmt.pix.sizeimage / 1024);
/* Map the buffers */
@@ -279,29 +291,32 @@ gst_v4l2src_capture_init (GstV4l2Src *v4l2src)
buffer->pool = v4l2src->pool;
buffer->buffer.index = n;
buffer->buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_QUERYBUF, &buffer->buffer) < 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
- ("Could not get buffer properties of buffer %d: %s", n, g_strerror (errno)));
- gst_v4l2src_capture_deinit(v4l2src);
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_QUERYBUF,
+ &buffer->buffer) < 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
+ ("Could not get buffer properties of buffer %d: %s", n,
+ g_strerror (errno)));
+ gst_v4l2src_capture_deinit (v4l2src);
return FALSE;
}
- buffer->start = mmap (0, buffer->buffer.length, PROT_READ|PROT_WRITE, MAP_SHARED,
- GST_V4L2ELEMENT(v4l2src)->video_fd, buffer->buffer.m.offset);
+ buffer->start =
+ mmap (0, buffer->buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED,
+ GST_V4L2ELEMENT (v4l2src)->video_fd, buffer->buffer.m.offset);
if (buffer->start == MAP_FAILED) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
- ("Could not mmap video buffer %d: %s", n, g_strerror (errno)));
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
+ ("Could not mmap video buffer %d: %s", n, g_strerror (errno)));
buffer->start = 0;
gst_v4l2src_capture_deinit (v4l2src);
return FALSE;
}
buffer->length = buffer->buffer.length;
- if (!gst_v4l2src_queue_frame(v4l2src, n)) {
+ if (!gst_v4l2src_queue_frame (v4l2src, n)) {
gst_v4l2src_capture_deinit (v4l2src);
return FALSE;
}
}
- GST_V4L2_SET_ACTIVE(GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_SET_ACTIVE (GST_V4L2ELEMENT (v4l2src));
return TRUE;
}
@@ -313,24 +328,24 @@ gst_v4l2src_capture_init (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_capture_start (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_start (GstV4l2Src * v4l2src)
{
gint type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
GST_DEBUG_OBJECT (v4l2src, "starting the capturing");
-
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT(v4l2src))) {
+
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT (v4l2src))) {
gst_pad_renegotiate (v4l2src->srcpad);
}
- GST_V4L2_CHECK_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_ACTIVE (GST_V4L2ELEMENT (v4l2src));
v4l2src->quit = FALSE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_STREAMON, &type) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_STREAMON, &type) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, OPEN_READ, (NULL),
- ("Error starting streaming capture from device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror(errno)));
+ ("Error starting streaming capture from device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
return FALSE;
}
@@ -345,31 +360,31 @@ gst_v4l2src_capture_start (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_capture_stop (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_stop (GstV4l2Src * v4l2src)
{
gint type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
GST_DEBUG_OBJECT (v4l2src, "stopping capturing");
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_ACTIVE (GST_V4L2ELEMENT (v4l2src));
/* we actually need to sync on all queued buffers but not
* on the non-queued ones */
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_STREAMOFF, &type) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_STREAMOFF, &type) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, CLOSE, (NULL),
- ("Error stopping streaming capture from device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
+ ("Error stopping streaming capture from device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
return FALSE;
}
/* make an optional pending wait stop */
v4l2src->quit = TRUE;
-
+
return TRUE;
}
static void
-gst_v4l2src_buffer_pool_free (GstV4l2BufferPool *pool, gboolean do_close)
+gst_v4l2src_buffer_pool_free (GstV4l2BufferPool * pool, gboolean do_close)
{
guint i;
@@ -385,16 +400,16 @@ gst_v4l2src_buffer_pool_free (GstV4l2BufferPool *pool, gboolean do_close)
}
void
-gst_v4l2src_free_buffer (GstBuffer *buffer)
+gst_v4l2src_free_buffer (GstBuffer * buffer)
{
GstV4l2Buffer *buf = (GstV4l2Buffer *) GST_BUFFER_PRIVATE (buffer);
-
+
GST_LOG ("freeing buffer %p (nr. %d)", buffer, buf->buffer.index);
-
+
if (!gst_atomic_int_dec_and_test (&buf->refcount)) {
/* we're still in use, add to queue again
note: this might fail because the device is already stopped (race) */
- if (ioctl(buf->pool->video_fd, VIDIOC_QBUF, &buf->buffer) < 0)
+ if (ioctl (buf->pool->video_fd, VIDIOC_QBUF, &buf->buffer) < 0)
GST_INFO ("readding to queue failed, assuming video device is stopped");
}
if (gst_atomic_int_dec_and_test (&buf->pool->refcount)) {
@@ -410,14 +425,14 @@ gst_v4l2src_free_buffer (GstBuffer *buffer)
******************************************************/
gboolean
-gst_v4l2src_capture_deinit (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_deinit (GstV4l2Src * v4l2src)
{
gint i, dequeue = 0;
-
+
GST_DEBUG_OBJECT (v4l2src, "deinitting capture system");
-
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_ACTIVE (GST_V4L2ELEMENT (v4l2src));
/* free the buffers */
for (i = 0; i < v4l2src->breq.count; i++) {
@@ -426,16 +441,18 @@ gst_v4l2src_capture_deinit (GstV4l2Src *v4l2src)
}
for (i = 0; i < dequeue; i++) {
struct v4l2_buffer buffer;
- buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0)
- GST_WARNING_OBJECT (v4l2src, "Could not dequeue buffer on uninitialization");
+
+ buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0)
+ GST_WARNING_OBJECT (v4l2src,
+ "Could not dequeue buffer on uninitialization");
}
if (gst_atomic_int_dec_and_test (&v4l2src->pool->refcount)) {
/* we're last thing that used all this */
gst_v4l2src_buffer_pool_free (v4l2src->pool, FALSE);
}
v4l2src->pool = NULL;
-
+
GST_V4L2_SET_INACTIVE (GST_V4L2ELEMENT (v4l2src));
return TRUE;
}
@@ -446,46 +463,45 @@ gst_v4l2src_capture_deinit (GstV4l2Src *v4l2src)
*/
gboolean
-gst_v4l2src_get_size_limits (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *format,
- gint *min_w, gint *max_w,
- gint *min_h, gint *max_h)
+gst_v4l2src_get_size_limits (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc * format,
+ gint * min_w, gint * max_w, gint * min_h, gint * max_h)
{
- struct v4l2_format fmt;
-
- GST_LOG_OBJECT (v4l2src, "getting size limits with format " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (format->pixelformat));
-
- /* get size delimiters */
- memset(&fmt, 0, sizeof(fmt));
- fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- fmt.fmt.pix.width = 0;
- fmt.fmt.pix.height = 0;
- fmt.fmt.pix.pixelformat = format->pixelformat;
- fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd,
- VIDIOC_TRY_FMT, &fmt) < 0) {
- return FALSE;
- }
-
- if (min_w)
- *min_w = fmt.fmt.pix.width;
- if (min_h)
- *min_h = fmt.fmt.pix.height;
- GST_LOG_OBJECT (v4l2src, "got min size %dx%d", fmt.fmt.pix.width, fmt.fmt.pix.height);
-
- fmt.fmt.pix.width = G_MAXINT;
- fmt.fmt.pix.height = 576;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd,
- VIDIOC_TRY_FMT, &fmt) < 0) {
- return FALSE;
- }
-
- if (max_w)
- *max_w = fmt.fmt.pix.width;
- if (max_h)
- *max_h = fmt.fmt.pix.height;
- GST_LOG_OBJECT (v4l2src, "got max size %dx%d", fmt.fmt.pix.width, fmt.fmt.pix.height);
-
- return TRUE;
+ struct v4l2_format fmt;
+
+ GST_LOG_OBJECT (v4l2src, "getting size limits with format " GST_FOURCC_FORMAT,
+ GST_FOURCC_ARGS (format->pixelformat));
+
+ /* get size delimiters */
+ memset (&fmt, 0, sizeof (fmt));
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmt.fmt.pix.width = 0;
+ fmt.fmt.pix.height = 0;
+ fmt.fmt.pix.pixelformat = format->pixelformat;
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_TRY_FMT, &fmt) < 0) {
+ return FALSE;
+ }
+
+ if (min_w)
+ *min_w = fmt.fmt.pix.width;
+ if (min_h)
+ *min_h = fmt.fmt.pix.height;
+ GST_LOG_OBJECT (v4l2src, "got min size %dx%d", fmt.fmt.pix.width,
+ fmt.fmt.pix.height);
+
+ fmt.fmt.pix.width = G_MAXINT;
+ fmt.fmt.pix.height = 576;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_TRY_FMT, &fmt) < 0) {
+ return FALSE;
+ }
+
+ if (max_w)
+ *max_w = fmt.fmt.pix.width;
+ if (max_h)
+ *max_h = fmt.fmt.pix.height;
+ GST_LOG_OBJECT (v4l2src, "got max size %dx%d", fmt.fmt.pix.width,
+ fmt.fmt.pix.height);
+
+ return TRUE;
}
diff --git a/sys/v4l2/v4l2src_calls.h b/sys/v4l2/v4l2src_calls.h
index dc5fca0c..043dddf0 100644
--- a/sys/v4l2/v4l2src_calls.h
+++ b/sys/v4l2/v4l2src_calls.h
@@ -24,30 +24,25 @@
#include "v4l2_calls.h"
-gboolean gst_v4l2src_get_capture (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_set_capture (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *fmt,
- gint width,
- gint height);
-gboolean gst_v4l2src_capture_init (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_capture_start (GstV4l2Src *v4l2src);
-gint gst_v4l2src_grab_frame (GstV4l2Src *v4l2src);
-guint8 * gst_v4l2src_get_buffer (GstV4l2Src *v4l2src,
- gint num);
-gboolean gst_v4l2src_queue_frame (GstV4l2Src *v4l2src,
- guint i);
-gboolean gst_v4l2src_capture_stop (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_capture_deinit (GstV4l2Src *v4l2src);
-
-gboolean gst_v4l2src_fill_format_list (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_clear_format_list (GstV4l2Src *v4l2src);
+gboolean gst_v4l2src_get_capture (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_set_capture (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc *fmt, gint width, gint height);
+gboolean gst_v4l2src_capture_init (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_capture_start (GstV4l2Src * v4l2src);
+gint gst_v4l2src_grab_frame (GstV4l2Src * v4l2src);
+guint8 *gst_v4l2src_get_buffer (GstV4l2Src * v4l2src, gint num);
+gboolean gst_v4l2src_queue_frame (GstV4l2Src * v4l2src, guint i);
+gboolean gst_v4l2src_capture_stop (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_capture_deinit (GstV4l2Src * v4l2src);
+
+gboolean gst_v4l2src_fill_format_list (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_clear_format_list (GstV4l2Src * v4l2src);
/* hacky */
-gboolean gst_v4l2src_get_size_limits (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *fmt,
- gint *min_w, gint *max_w,
- gint *min_h, gint *max_h);
+gboolean gst_v4l2src_get_size_limits (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc *fmt,
+ gint * min_w, gint * max_w, gint * min_h, gint * max_h);
+
+void gst_v4l2src_free_buffer (GstBuffer * buffer);
-void gst_v4l2src_free_buffer (GstBuffer *buffer);
-
#endif /* __V4L2SRC_CALLS_H__ */
diff --git a/sys/vcd/vcdsrc.c b/sys/vcd/vcdsrc.c
index 0824e679..b2868628 100644
--- a/sys/vcd/vcdsrc.c
+++ b/sys/vcd/vcdsrc.c
@@ -37,21 +37,21 @@
#include <vcdsrc.h>
-static GstElementDetails vcdsrc_details = GST_ELEMENT_DETAILS (
- "VCD Source",
- "Source/File",
- "Asynchronous read from VCD disk",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails vcdsrc_details = GST_ELEMENT_DETAILS ("VCD Source",
+ "Source/File",
+ "Asynchronous read from VCD disk",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* VCDSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION,
ARG_TRACK,
@@ -60,20 +60,24 @@ enum {
ARG_MAX_ERRORS,
};
-static void vcdsrc_base_init (gpointer g_class);
-static void vcdsrc_class_init (VCDSrcClass *klass);
-static void vcdsrc_init (VCDSrc *vcdsrc);
-static void vcdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void vcdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void vcdsrc_base_init (gpointer g_class);
+static void vcdsrc_class_init (VCDSrcClass * klass);
+static void vcdsrc_init (VCDSrc * vcdsrc);
+static void vcdsrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void vcdsrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstData *vcdsrc_get (GstPad * pad);
-static GstData * vcdsrc_get (GstPad *pad);
/*static GstBuffer * vcdsrc_get_region (GstPad *pad,gulong offset,gulong size); */
-static GstElementStateReturn vcdsrc_change_state (GstElement *element);
+static GstElementStateReturn vcdsrc_change_state (GstElement * element);
-static void vcdsrc_recalculate(VCDSrc *vcdsrc);
+static void vcdsrc_recalculate (VCDSrc * vcdsrc);
static GstElementClass *parent_class = NULL;
+
/*static guint vcdsrc_signals[LAST_SIGNAL] = { 0 }; */
GType
@@ -83,17 +87,18 @@ vcdsrc_get_type (void)
if (!vcdsrc_type) {
static const GTypeInfo vcdsrc_info = {
- sizeof(VCDSrcClass),
+ sizeof (VCDSrcClass),
vcdsrc_base_init,
NULL,
- (GClassInitFunc)vcdsrc_class_init,
+ (GClassInitFunc) vcdsrc_class_init,
NULL,
NULL,
- sizeof(VCDSrc),
+ sizeof (VCDSrc),
0,
- (GInstanceInitFunc)vcdsrc_init,
+ (GInstanceInitFunc) vcdsrc_init,
};
- vcdsrc_type = g_type_register_static(GST_TYPE_ELEMENT, "VCDSrc", &vcdsrc_info, 0);
+ vcdsrc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "VCDSrc", &vcdsrc_info, 0);
}
return vcdsrc_type;
}
@@ -102,34 +107,27 @@ static void
vcdsrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (element_class, &vcdsrc_details);
}
static void
-vcdsrc_class_init (VCDSrcClass *klass)
+vcdsrc_class_init (VCDSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_peek_parent (klass);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATION,
- g_param_spec_string("location","location","location",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TRACK,
- g_param_spec_int("track","track","track",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BYTESPERREAD,
- g_param_spec_int("bytesperread","bytesperread","bytesperread",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OFFSET,
- g_param_spec_int("offset","offset","offset",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MAX_ERRORS,
- g_param_spec_int("max-errors","","", 0,G_MAXINT,16,G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, g_param_spec_string ("location", "location", "location", NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TRACK, g_param_spec_int ("track", "track", "track", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTESPERREAD, g_param_spec_int ("bytesperread", "bytesperread", "bytesperread", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OFFSET, g_param_spec_int ("offset", "offset", "offset", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_ERRORS,
+ g_param_spec_int ("max-errors", "", "", 0, G_MAXINT, 16,
+ G_PARAM_READWRITE));
gobject_class->set_property = vcdsrc_set_property;
gobject_class->get_property = vcdsrc_get_property;
@@ -138,12 +136,12 @@ vcdsrc_class_init (VCDSrcClass *klass)
}
static void
-vcdsrc_init (VCDSrc *vcdsrc)
+vcdsrc_init (VCDSrc * vcdsrc)
{
- vcdsrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
+ vcdsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_get_function (vcdsrc->srcpad, vcdsrc_get);
/* gst_pad_set_get_region_function (vcdsrc->srcpad, vcdsrc_getregion); */
- gst_element_add_pad(GST_ELEMENT(vcdsrc),vcdsrc->srcpad);
+ gst_element_add_pad (GST_ELEMENT (vcdsrc), vcdsrc->srcpad);
vcdsrc->device = g_strdup ("/dev/cdrom");
vcdsrc->track = 2;
@@ -157,30 +155,32 @@ vcdsrc_init (VCDSrc *vcdsrc)
static void
-vcdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+vcdsrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
VCDSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_VCDSRC(object));
- src = VCDSRC(object);
+ g_return_if_fail (GST_IS_VCDSRC (object));
+ src = VCDSRC (object);
switch (prop_id) {
case ARG_LOCATION:
/* the element must be stopped in order to do this */
/* g_return_if_fail(!GST_FLAG_IS_SET(src,GST_STATE_RUNNING)); */
- if (src->device) g_free(src->device);
+ if (src->device)
+ g_free (src->device);
/* clear the filename if we get a NULL (is that possible?) */
if (g_value_get_string (value) == NULL)
- src->device = NULL;
+ src->device = NULL;
/* otherwise set the new filename */
else
- src->device = g_strdup(g_value_get_string (value));
+ src->device = g_strdup (g_value_get_string (value));
break;
case ARG_TRACK:
src->track = g_value_get_int (value);
- vcdsrc_recalculate(src);
+ vcdsrc_recalculate (src);
break;
/* case ARG_BYTESPERREAD:
src->bytes_per_read = g_value_get_int (value);
@@ -198,13 +198,14 @@ vcdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParam
}
static void
-vcdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+vcdsrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
VCDSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_VCDSRC(object));
- src = VCDSRC(object);
+ g_return_if_fail (GST_IS_VCDSRC (object));
+ src = VCDSRC (object);
switch (prop_id) {
case ARG_LOCATION:
@@ -229,7 +230,7 @@ vcdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *
}
static GstData *
-vcdsrc_get (GstPad *pad)
+vcdsrc_get (GstPad * pad)
{
VCDSrc *vcdsrc;
GstBuffer *buf;
@@ -239,25 +240,25 @@ vcdsrc_get (GstPad *pad)
/* fprintf(stderr,"in vcdsrc_push\n"); */
- g_return_val_if_fail(pad != NULL, NULL);
- g_return_val_if_fail(GST_IS_PAD(pad), NULL);
+ g_return_val_if_fail (pad != NULL, NULL);
+ g_return_val_if_fail (GST_IS_PAD (pad), NULL);
vcdsrc = VCDSRC (GST_OBJECT_PARENT (pad));
g_return_val_if_fail (GST_FLAG_IS_SET (vcdsrc, VCDSRC_OPEN), NULL);
/* create the buffer */
/* FIXME: should eventually use a bufferpool for this */
- buf = gst_buffer_new();
- g_return_val_if_fail(buf != NULL, NULL);
+ buf = gst_buffer_new ();
+ g_return_val_if_fail (buf != NULL, NULL);
/* allocate the space for the buffer data */
- GST_BUFFER_DATA(buf) = g_malloc(vcdsrc->bytes_per_read);
- memset(GST_BUFFER_DATA(buf),0,vcdsrc->bytes_per_read);
- g_return_val_if_fail(GST_BUFFER_DATA(buf) != NULL, NULL);
+ GST_BUFFER_DATA (buf) = g_malloc (vcdsrc->bytes_per_read);
+ memset (GST_BUFFER_DATA (buf), 0, vcdsrc->bytes_per_read);
+ g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
- msf = (struct cdrom_msf *)GST_BUFFER_DATA(buf);
+ msf = (struct cdrom_msf *) GST_BUFFER_DATA (buf);
- read_sector:
+read_sector:
/* read it in from the device */
offset = vcdsrc->trackoffset + vcdsrc->curoffset;
@@ -268,16 +269,14 @@ vcdsrc_get (GstPad *pad)
/*gst_info("msf is %d:%d:%d\n",msf->cdmsf_min0,msf->cdmsf_sec0, */
/* msf->cdmsf_frame0); */
- if (ioctl(vcdsrc->fd,CDROMREADRAW,msf)) {
- if (++error_count > vcdsrc->max_errors)
- {
- gst_element_set_eos (GST_ELEMENT (vcdsrc));
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
+ if (ioctl (vcdsrc->fd, CDROMREADRAW, msf)) {
+ if (++error_count > vcdsrc->max_errors) {
+ gst_element_set_eos (GST_ELEMENT (vcdsrc));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ }
fprintf (stderr, "%s while reading raw data from cdrom at %d:%d:%d\n",
- strerror (errno),
- msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
+ strerror (errno), msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
vcdsrc->curoffset += 1;
/* Or we can return a zero-filled buffer. Which is better? */
@@ -285,8 +284,8 @@ vcdsrc_get (GstPad *pad)
}
- GST_BUFFER_OFFSET(buf) = vcdsrc->curoffset;
- GST_BUFFER_SIZE(buf) = vcdsrc->bytes_per_read;
+ GST_BUFFER_OFFSET (buf) = vcdsrc->curoffset;
+ GST_BUFFER_SIZE (buf) = vcdsrc->bytes_per_read;
vcdsrc->curoffset += 1;
return GST_DATA (buf);
@@ -294,22 +293,22 @@ vcdsrc_get (GstPad *pad)
/* open the file, necessary to go to RUNNING state */
static gboolean
-vcdsrc_open_file(VCDSrc *src)
+vcdsrc_open_file (VCDSrc * src)
{
int i;
- g_return_val_if_fail(!GST_FLAG_IS_SET(src,VCDSRC_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (src, VCDSRC_OPEN), FALSE);
/* open the device */
- src->fd = open(src->device,O_RDONLY);
+ src->fd = open (src->device, O_RDONLY);
if (src->fd < 0) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), GST_ERROR_SYSTEM);
return FALSE;
}
/* read the table of contents */
- if (ioctl(src->fd,CDROMREADTOCHDR,&src->tochdr)) {
- perror("reading toc of VCD\n");
+ if (ioctl (src->fd, CDROMREADTOCHDR, &src->tochdr)) {
+ perror ("reading toc of VCD\n");
/* FIXME */
/* exit(1); */
}
@@ -319,96 +318,91 @@ vcdsrc_open_file(VCDSrc *src)
src->tracks = g_new (struct cdrom_tocentry, src->numtracks);
/* read each track entry */
- for (i=0;i<src->numtracks;i++) {
- src->tracks[i].cdte_track = i+1;
+ for (i = 0; i < src->numtracks; i++) {
+ src->tracks[i].cdte_track = i + 1;
src->tracks[i].cdte_format = CDROM_MSF;
- if (ioctl(src->fd,CDROMREADTOCENTRY, &src->tracks[i])) {
- perror("reading tocentry");
+ if (ioctl (src->fd, CDROMREADTOCENTRY, &src->tracks[i])) {
+ perror ("reading tocentry");
/* FIXME */
/* exit(1);*/
}
- fprintf(stderr,"VCDSrc: track begins at %d:%d:%d\n",
- src->tracks[i].cdte_addr.msf.minute,
- src->tracks[i].cdte_addr.msf.second,
- src->tracks[i].cdte_addr.msf.frame);
+ fprintf (stderr, "VCDSrc: track begins at %d:%d:%d\n",
+ src->tracks[i].cdte_addr.msf.minute,
+ src->tracks[i].cdte_addr.msf.second,
+ src->tracks[i].cdte_addr.msf.frame);
}
src->trackoffset =
-(((src->tracks[src->track-1].cdte_addr.msf.minute * 60) +
- src->tracks[src->track-1].cdte_addr.msf.second) * 75) +
- src->tracks[src->track-1].cdte_addr.msf.frame;
- fprintf(stderr,"VCDSrc: track offset is %ld\n",src->trackoffset);
+ (((src->tracks[src->track - 1].cdte_addr.msf.minute * 60) +
+ src->tracks[src->track - 1].cdte_addr.msf.second) * 75) +
+ src->tracks[src->track - 1].cdte_addr.msf.frame;
+ fprintf (stderr, "VCDSrc: track offset is %ld\n", src->trackoffset);
- GST_FLAG_SET(src,VCDSRC_OPEN);
+ GST_FLAG_SET (src, VCDSRC_OPEN);
return TRUE;
}
/* close the file */
static void
-vcdsrc_close_file (VCDSrc *src)
+vcdsrc_close_file (VCDSrc * src)
{
- g_return_if_fail(GST_FLAG_IS_SET(src,VCDSRC_OPEN));
+ g_return_if_fail (GST_FLAG_IS_SET (src, VCDSRC_OPEN));
/* close the file */
- close(src->fd);
+ close (src->fd);
/* zero out a lot of our state */
src->fd = 0;
src->curoffset = 0;
src->seq = 0;
- GST_FLAG_UNSET(src,VCDSRC_OPEN);
+ GST_FLAG_UNSET (src, VCDSRC_OPEN);
}
static GstElementStateReturn
-vcdsrc_change_state (GstElement *element)
+vcdsrc_change_state (GstElement * element)
{
- g_return_val_if_fail(GST_IS_VCDSRC(element), GST_STATE_FAILURE);
+ g_return_val_if_fail (GST_IS_VCDSRC (element), GST_STATE_FAILURE);
/* if going down into NULL state, close the file if it's open */
- if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
- if (GST_FLAG_IS_SET(element,VCDSRC_OPEN))
- vcdsrc_close_file(VCDSRC(element));
- /* otherwise (READY or higher) we need to open the sound card */
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
+ if (GST_FLAG_IS_SET (element, VCDSRC_OPEN))
+ vcdsrc_close_file (VCDSRC (element));
+ /* otherwise (READY or higher) we need to open the sound card */
} else {
- if (!GST_FLAG_IS_SET(element,VCDSRC_OPEN)) {
- if (!vcdsrc_open_file(VCDSRC(element)))
- return GST_STATE_FAILURE;
+ if (!GST_FLAG_IS_SET (element, VCDSRC_OPEN)) {
+ if (!vcdsrc_open_file (VCDSRC (element)))
+ return GST_STATE_FAILURE;
}
}
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
static void
-vcdsrc_recalculate (VCDSrc *vcdsrc)
+vcdsrc_recalculate (VCDSrc * vcdsrc)
{
- if (GST_FLAG_IS_SET(vcdsrc,VCDSRC_OPEN)) {
+ if (GST_FLAG_IS_SET (vcdsrc, VCDSRC_OPEN)) {
/* calculate track offset (beginning of track) */
vcdsrc->trackoffset =
-(((vcdsrc->tracks[vcdsrc->track-1].cdte_addr.msf.minute * 60) +
- vcdsrc->tracks[vcdsrc->track-1].cdte_addr.msf.second) * 75) +
- vcdsrc->tracks[vcdsrc->track-1].cdte_addr.msf.frame;
- fprintf(stderr,"VCDSrc: track offset is %ld\n",vcdsrc->trackoffset);
+ (((vcdsrc->tracks[vcdsrc->track - 1].cdte_addr.msf.minute * 60) +
+ vcdsrc->tracks[vcdsrc->track - 1].cdte_addr.msf.second) * 75) +
+ vcdsrc->tracks[vcdsrc->track - 1].cdte_addr.msf.frame;
+ fprintf (stderr, "VCDSrc: track offset is %ld\n", vcdsrc->trackoffset);
}
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "vcdsrc", GST_RANK_NONE, GST_TYPE_VCDSRC);
+ return gst_element_register (plugin, "vcdsrc", GST_RANK_NONE,
+ GST_TYPE_VCDSRC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "vcdsrc",
- "Asynchronous read from VCD disk",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "vcdsrc",
+ "Asynchronous read from VCD disk",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
diff --git a/sys/vcd/vcdsrc.h b/sys/vcd/vcdsrc.h
index ab2c74da..5026cd78 100644
--- a/sys/vcd/vcdsrc.h
+++ b/sys/vcd/vcdsrc.h
@@ -28,8 +28,9 @@
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define VCD_BYTES_PER_SECTOR 2352
@@ -46,51 +47,54 @@ extern "C" {
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VCDSRC))
/* NOTE: per-element flags start with 16 for now */
-typedef enum {
- VCDSRC_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+ {
+ VCDSRC_OPEN = GST_ELEMENT_FLAG_LAST,
- VCDSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
-} VCDSrcFlags;
+ VCDSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } VCDSrcFlags;
-typedef struct _VCDSrc VCDSrc;
-typedef struct _VCDSrcClass VCDSrcClass;
+ typedef struct _VCDSrc VCDSrc;
+ typedef struct _VCDSrcClass VCDSrcClass;
-struct _VCDSrc {
- GstElement element;
- /* pads */
- GstPad *srcpad;
+ struct _VCDSrc
+ {
+ GstElement element;
+ /* pads */
+ GstPad *srcpad;
- /* device */
- gchar *device;
- /* track number */
- gint track;
- /* fd */
- gint fd;
+ /* device */
+ gchar *device;
+ /* track number */
+ gint track;
+ /* fd */
+ gint fd;
- struct cdrom_tochdr tochdr;
- gint numtracks;
- struct cdrom_tocentry *tracks;
+ struct cdrom_tochdr tochdr;
+ gint numtracks;
+ struct cdrom_tocentry *tracks;
- /* current time offset */
- gulong trackoffset;
- gulong frameoffset;
+ /* current time offset */
+ gulong trackoffset;
+ gulong frameoffset;
- gulong curoffset; /* current offset in file */
- gulong bytes_per_read; /* bytes per read */
+ gulong curoffset; /* current offset in file */
+ gulong bytes_per_read; /* bytes per read */
- gulong seq; /* buffer sequence number */
- int max_errors;
-};
+ gulong seq; /* buffer sequence number */
+ int max_errors;
+ };
-struct _VCDSrcClass {
- GstElementClass parent_class;
-};
+ struct _VCDSrcClass
+ {
+ GstElementClass parent_class;
+ };
-GType vcdsrc_get_type(void);
+ GType vcdsrc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __VCDSRC_H__ */
+#endif /* __VCDSRC_H__ */