diff options
Diffstat (limited to 'sys')
28 files changed, 1149 insertions, 1140 deletions
diff --git a/sys/cdrom/gstcdplayer.c b/sys/cdrom/gstcdplayer.c index f76e9df6..a53b2bc8 100644 --- a/sys/cdrom/gstcdplayer.c +++ b/sys/cdrom/gstcdplayer.c @@ -84,7 +84,7 @@ cdplayer_get_type (void) }; cdplayer_type = - g_type_register_static (GST_TYPE_BIN, "CDPlayer", &cdplayer_info, 0); + g_type_register_static (GST_TYPE_BIN, "CDPlayer", &cdplayer_info, 0); } return cdplayer_type; @@ -120,25 +120,25 @@ cdplayer_class_init (CDPlayerClass * klass) g_object_class_install_property (gobject_klass, ARG_DEVICE, g_param_spec_string ("device", "device", "CDROM device", NULL, - G_PARAM_READWRITE)); + 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_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)); + "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)); + "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)); + "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)); + 0, G_MAXUINT, 1, G_PARAM_READABLE)); cdplayer_signals[TRACK_CHANGE] = g_signal_new ("track-change", G_TYPE_FROM_CLASS (klass), @@ -178,7 +178,7 @@ cdplayer_set_property (GObject * object, guint prop_id, const GValue * value, case ARG_DEVICE: // FIXME prolly should uhh.. stop it or something if (cdp->device) { - g_free (cdp->device); + g_free (cdp->device); } cdp->device = g_strdup (g_value_get_string (value)); @@ -261,13 +261,13 @@ cdplayer_iterate (GstBin * bin) case CD_PLAYING: current_track = cd_current_track (CDPLAYER_CD (cdp)); if (current_track > cdp->end_track && cdp->end_track != 0) { - return FALSE; + return FALSE; } 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); + cdp->current_track = current_track; + g_signal_emit (G_OBJECT (cdp), cdplayer_signals[TRACK_CHANGE], 0, + cdp->current_track); } return TRUE; @@ -301,44 +301,44 @@ cdplayer_change_state (GstElement * element) switch (pending) { case GST_STATE_READY: if (state != GST_STATE_PAUSED) { - if (cd_init (CDPLAYER_CD (cdp), cdp->device) == FALSE) { - return GST_STATE_FAILURE; - } - cdp->num_tracks = cdp->cd.num_tracks; - cdp->cddb_discid = cd_cddb_discid (CDPLAYER_CD (cdp)); + if (cd_init (CDPLAYER_CD (cdp), cdp->device) == FALSE) { + return GST_STATE_FAILURE; + } + cdp->num_tracks = cdp->cd.num_tracks; + cdp->cddb_discid = cd_cddb_discid (CDPLAYER_CD (cdp)); } break; case GST_STATE_PAUSED: /* ready->paused is not useful */ if (state != GST_STATE_READY) { - if (cd_pause (CDPLAYER_CD (cdp)) == FALSE) { - return GST_STATE_FAILURE; - } + if (cd_pause (CDPLAYER_CD (cdp)) == FALSE) { + return GST_STATE_FAILURE; + } - cdp->paused = TRUE; + cdp->paused = TRUE; } break; case GST_STATE_PLAYING: if (cdp->paused == TRUE) { - if (cd_resume (CDPLAYER_CD (cdp)) == FALSE) { - return GST_STATE_FAILURE; - } + if (cd_resume (CDPLAYER_CD (cdp)) == FALSE) { + return GST_STATE_FAILURE; + } - cdp->paused = FALSE; + cdp->paused = FALSE; } else { - if (cd_start (CDPLAYER_CD (cdp), cdp->start_track, - cdp->end_track) == FALSE) { - return GST_STATE_FAILURE; - } + if (cd_start (CDPLAYER_CD (cdp), cdp->start_track, + cdp->end_track) == FALSE) { + return GST_STATE_FAILURE; + } } break; case GST_STATE_NULL: /* stop & close fd */ if (cd_stop (CDPLAYER_CD (cdp)) == FALSE - || cd_close (CDPLAYER_CD (cdp)) == FALSE) { - return GST_STATE_FAILURE; + || cd_close (CDPLAYER_CD (cdp)) == FALSE) { + return GST_STATE_FAILURE; } break; @@ -361,5 +361,5 @@ plugin_init (GstPlugin * plugin) GST_TYPE_CDPLAYER); } -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "cdplayer", "CD Player", plugin_init, VERSION, GST_LICENSE, /* ? */ +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/dxr3/ac3_padder.c b/sys/dxr3/ac3_padder.c index 606923a7..9e778bac 100644 --- a/sys/dxr3/ac3_padder.c +++ b/sys/dxr3/ac3_padder.c @@ -152,101 +152,101 @@ 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; + 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; + 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; + 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; + 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; } } diff --git a/sys/dxr3/dxr3audiosink.c b/sys/dxr3/dxr3audiosink.c index a1a7b8e6..558dcb0c 100644 --- a/sys/dxr3/dxr3audiosink.c +++ b/sys/dxr3/dxr3audiosink.c @@ -73,11 +73,11 @@ 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") + "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 = @@ -85,7 +85,7 @@ 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 */ + /* no parameters needed, we don't need a parsed stream */ ) ); @@ -143,8 +143,9 @@ dxr3audiosink_get_type (void) 0, (GInstanceInitFunc) dxr3audiosink_init, }; + dxr3audiosink_type = g_type_register_static (GST_TYPE_ELEMENT, - "Dxr3AudioSink", &dxr3audiosink_info, 0); + "Dxr3AudioSink", &dxr3audiosink_info, 0); } return dxr3audiosink_type; @@ -184,7 +185,7 @@ dxr3audiosink_class_init (Dxr3AudioSinkClass * klass) 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)); + "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; @@ -249,7 +250,7 @@ dxr3audiosink_set_property (GObject * object, guint prop_id, 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); + dxr3audiosink_set_mode_pcm (sink); } g_object_notify (G_OBJECT (sink), "digital-pcm"); break; @@ -294,8 +295,8 @@ dxr3audiosink_open (Dxr3AudioSink * sink) 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; } @@ -306,8 +307,8 @@ dxr3audiosink_open (Dxr3AudioSink * sink) 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; } @@ -339,8 +340,8 @@ dxr3audiosink_set_mode_pcm (Dxr3AudioSink * sink) 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; } @@ -353,8 +354,8 @@ dxr3audiosink_set_mode_pcm (Dxr3AudioSink * sink) 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; } @@ -390,8 +391,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; } @@ -418,15 +419,15 @@ dxr3audiosink_close (Dxr3AudioSink * sink) 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; } @@ -495,18 +496,18 @@ dxr3audiosink_handle_event (GstPad * pad, GstEvent * event) 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); - } - - /* Report the flush operation. */ - g_signal_emit (G_OBJECT (sink), - dxr3audiosink_signals[SIGNAL_FLUSHED], 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); } break; default: @@ -561,21 +562,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); } } @@ -627,40 +628,40 @@ dxr3audiosink_chain_ac3 (GstPad * pad, GstData * _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); @@ -714,7 +715,7 @@ dxr3audiosink_change_state (GstElement * element) } else { if (!GST_FLAG_IS_SET (element, DXR3AUDIOSINK_OPEN)) { if (!dxr3audiosink_open (DXR3AUDIOSINK (element))) { - return GST_STATE_FAILURE; + return GST_STATE_FAILURE; } } } diff --git a/sys/dxr3/dxr3init.c b/sys/dxr3/dxr3init.c index d5bbd0f2..921d4f89 100644 --- a/sys/dxr3/dxr3init.c +++ b/sys/dxr3/dxr3init.c @@ -34,11 +34,11 @@ static gboolean 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 diff --git a/sys/dxr3/dxr3spusink.c b/sys/dxr3/dxr3spusink.c index 1652cdc6..0d7e6457 100644 --- a/sys/dxr3/dxr3spusink.c +++ b/sys/dxr3/dxr3spusink.c @@ -122,8 +122,9 @@ dxr3spusink_get_type (void) 0, (GInstanceInitFunc) dxr3spusink_init, }; + dxr3spusink_type = g_type_register_static (GST_TYPE_ELEMENT, - "Dxr3SpuSink", &dxr3spusink_info, 0); + "Dxr3SpuSink", &dxr3spusink_info, 0); } return dxr3spusink_type; } @@ -264,8 +265,8 @@ dxr3spusink_open (Dxr3SpuSink * sink) 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; } @@ -276,8 +277,8 @@ dxr3spusink_open (Dxr3SpuSink * sink) 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; } @@ -294,15 +295,15 @@ dxr3spusink_close (Dxr3SpuSink * sink) 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) { 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; } @@ -335,19 +336,19 @@ dxr3spusink_handle_event (GstPad * pad, GstEvent * event) switch (type) { case GST_EVENT_FLUSH: if (sink->control_fd >= 0) { - int subdevice; + int subdevice; - subdevice = EM8300_SUBDEVICE_SUBPICTURE; - ioctl (sink->control_fd, EM8300_IOCTL_FLUSH, &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. */ + /* 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); + /* Report the flush operation. */ + g_signal_emit (G_OBJECT (sink), dxr3spusink_signals[SIGNAL_FLUSHED], 0); } break; default: @@ -387,10 +388,10 @@ dxr3spusink_chain (GstPad * pad, GstData * _data) } 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); } } @@ -406,9 +407,9 @@ dxr3spusink_change_state (GstElement * element) 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: @@ -421,7 +422,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; } @@ -470,7 +471,7 @@ dxr3spusink_set_clut (Dxr3SpuSink * sink, const guint32 * clut) if (ioctl (sink->spu_fd, EM8300_IOCTL_SPU_SETPALETTE, clut_fixed)) fprintf (stderr, "dxr3spusink: failed to set CLUT (%s)\n", - strerror (errno)); + strerror (errno)); } @@ -489,7 +490,7 @@ 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)); } } @@ -499,7 +500,7 @@ 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)); } } diff --git a/sys/dxr3/dxr3videosink.c b/sys/dxr3/dxr3videosink.c index 616c12f3..80805913 100644 --- a/sys/dxr3/dxr3videosink.c +++ b/sys/dxr3/dxr3videosink.c @@ -63,18 +63,18 @@ enum /* 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. */ + 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. */ + PARSE_STATE_WAITING, /* Waiting for the start of a sequence. */ + PARSE_STATE_START, /* Start of sequence seen. */ + PARSE_STATE_PICTURE, /* Picture start seen. */ }; @@ -88,9 +88,9 @@ 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 */ + "mpegversion = (int) { 1, 2 }, " "systemstream = (boolean) FALSE" + /* width/height/framerate omitted, we don't + * need a parsed stream */ ) ); @@ -146,8 +146,9 @@ dxr3videosink_get_type (void) 0, (GInstanceInitFunc) dxr3videosink_init, }; + dxr3videosink_type = g_type_register_static (GST_TYPE_ELEMENT, - "Dxr3VideoSink", &dxr3videosink_info, 0); + "Dxr3VideoSink", &dxr3videosink_info, 0); } return dxr3videosink_type; @@ -267,8 +268,8 @@ dxr3videosink_open (Dxr3VideoSink * sink) 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; } @@ -279,8 +280,8 @@ dxr3videosink_open (Dxr3VideoSink * sink) 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; } @@ -297,15 +298,15 @@ dxr3videosink_close (Dxr3VideoSink * sink) 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) { 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; } @@ -353,28 +354,28 @@ dxr3videosink_next_start_code (Dxr3VideoSink * sink) switch (sink->scan_state) { case SCAN_STATE_WAITING: - if (c == 0x00) { - sink->scan_state = SCAN_STATE_0; - } - break; + 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; + 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; + 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++; + sink->scan_state = SCAN_STATE_WAITING; + return c; } sink->scan_pos++; @@ -402,8 +403,8 @@ dxr3videosink_discard_data (Dxr3VideoSink * sink, guint cut) sink->cur_buf = NULL; } 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; } @@ -448,10 +449,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; @@ -476,45 +477,45 @@ dxr3videosink_parse_data (Dxr3VideoSink * sink) 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; + 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; + 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; + 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; } @@ -548,7 +549,7 @@ 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); @@ -567,19 +568,19 @@ dxr3videosink_handle_event (GstPad * pad, GstEvent * event) /* 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); - } + 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"); */ } @@ -642,9 +643,9 @@ dxr3videosink_change_state (GstElement * element) 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: @@ -661,7 +662,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; } diff --git a/sys/glsink/gstgl_nvimage.c b/sys/glsink/gstgl_nvimage.c index 1aab5c4f..38e6dece 100644 --- a/sys/glsink/gstgl_nvimage.c +++ b/sys/glsink/gstgl_nvimage.c @@ -55,7 +55,7 @@ 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; }; @@ -154,10 +154,10 @@ gst_gl_nvimage_get_caps (GstImageInfo * info) } 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)) + "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; @@ -190,7 +190,7 @@ gst_gl_nvimage_set_caps (GstImageInfo * info, GstCaps * caps) GST_DEBUG ("GL_NVImage: Format is invalid !\n"); return NULL; } - if (0) //conn->port == (XvPortID) -1) + if (0) //conn->port == (XvPortID) -1) { /* this happens if the plugin can't handle the caps, so no warning */ g_free (conn); @@ -266,7 +266,7 @@ gst_gl_nvimage_put_image (GstImageInfo * info, GstImageData * image) 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 + 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); @@ -348,11 +348,11 @@ gst_gl_nvimage_put_image (GstImageInfo * info, GstImageData * image) printf ("Recording frame #%d\n", framenr); glReadPixels (0, 0, img_width, img_height, GL_RGB, GL_UNSIGNED_BYTE, - cap_image_data); + 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); + cap_image_data + (img_height - 1 - i) * img_width * 3, img_width * 3); sprintf (capfilename, "cap%04d.ppm", framenr); FILE *outfile = fopen (capfilename, "wb"); @@ -363,7 +363,7 @@ gst_gl_nvimage_put_image (GstImageInfo * info, GstImageData * image) 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); + outfile); fclose (outfile); } framenr++; diff --git a/sys/glsink/gstgl_pdrimage.c b/sys/glsink/gstgl_pdrimage.c index 20582ebf..82ac254a 100644 --- a/sys/glsink/gstgl_pdrimage.c +++ b/sys/glsink/gstgl_pdrimage.c @@ -55,7 +55,7 @@ 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; }; @@ -143,10 +143,10 @@ gst_gl_nvimage_get_caps (GstImageInfo * info) } 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)) + "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; } @@ -178,7 +178,7 @@ gst_gl_nvimage_set_caps (GstImageInfo * info, GstCaps * caps) GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: Format is invalid !\n"); return NULL; } - if (0) //conn->port == (XvPortID) -1) + if (0) //conn->port == (XvPortID) -1) { /* this happens if the plugin can't handle the caps, so no warning */ g_free (conn); @@ -216,15 +216,15 @@ gst_gl_nvimage_get_image (GstImageInfo * info, GstImageConnection * conn) image->data.size = nvconn->w * nvconn->h * 3 / 2; - if (slot < AGP_BUFSLOTS) // found an AGP buffer slot + 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 + 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->slot = AGP_BUFSLOTS; // no AGP slot } image->conn = nvconn; @@ -325,13 +325,13 @@ gst_gl_nvimage_open_conn (GstImageConnection * conn, GstImageInfo * info) if (!xconn->m_memory) { printf - ("Unable to acquire graphics card mem... will acquire in normal memory.\n"); + ("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); + AGP_BUFSLOTS * YUVTEX_SIZE, xconn->m_memory); glEnableClientState (GL_WRITE_PIXEL_DATA_RANGE_NV); for (slot = 0; slot < AGP_BUFSLOTS; slot++) diff --git a/sys/glsink/gstgl_rgbimage.c b/sys/glsink/gstgl_rgbimage.c index 8c61e390..f836bc50 100644 --- a/sys/glsink/gstgl_rgbimage.c +++ b/sys/glsink/gstgl_rgbimage.c @@ -32,8 +32,8 @@ typedef struct _GstGLImageConnection 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; @@ -131,15 +131,15 @@ gst_gl_rgbimage_get_caps (GstImageInfo * info) 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) - ); + 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); } @@ -260,7 +260,7 @@ gst_gl_rgbimage_put_image (GstImageInfo * info, GstImageData * image) 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 + 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); @@ -321,11 +321,11 @@ gst_gl_rgbimage_put_image (GstImageInfo * info, GstImageData * image) printf ("Recording frame #%d\n", framenr); glReadPixels (0, 0, img_width, img_height, GL_RGB, GL_UNSIGNED_BYTE, - cap_image_data); + 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); + cap_image_data + (img_height - 1 - i) * img_width * 3, img_width * 3); sprintf (capfilename, "cap%04d.ppm", framenr); FILE *outfile = fopen (capfilename, "wb"); @@ -336,7 +336,7 @@ gst_gl_rgbimage_put_image (GstImageInfo * info, GstImageData * image) 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); + outfile); fclose (outfile); } framenr++; diff --git a/sys/glsink/gstglsink.c b/sys/glsink/gstglsink.c index a545c2a8..6773b31f 100644 --- a/sys/glsink/gstglsink.c +++ b/sys/glsink/gstglsink.c @@ -56,13 +56,13 @@ GST_PAD_TEMPLATE_FACTORY (gst_glsink_sink_template_factory, 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)), + "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)) + "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 */ @@ -106,9 +106,9 @@ GST_PAD_TEMPLATE_FACTORY (gst_glsink_sink_template_factory, 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 ? */ + 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; @@ -189,9 +189,10 @@ GST_PAD_TEMPLATE_FACTORY (gst_glsink_sink_template_factory, 0, (GInstanceInitFunc) gst_glsink_init, }; + videosink_type = - g_type_register_static (GST_TYPE_ELEMENT, "GstGLSink", &videosink_info, - 0); + g_type_register_static (GST_TYPE_ELEMENT, "GstGLSink", &videosink_info, + 0); } return videosink_type; } @@ -218,25 +219,25 @@ gst_glsink_class_init (GstGLSinkClass * 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_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_READWRITE)); g_object_class_install_property (gobject_class, ARG_REPAINT, g_param_spec_boolean ("repaint", "Repaint", "repaint the current frame", - FALSE, G_PARAM_WRITABLE)); + 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)); + 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)); + "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; @@ -366,7 +367,7 @@ gst_glsink_buffer_free (GstBufferPool * pool, GstBuffer * buffer, { GstGLSink *sink = GST_GLSINK (gst_buffer_pool_get_user_data (GST_BUFFER_BUFFERPOOL - (buffer))); + (buffer))); gst_glsink_append_cache (sink, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer)); @@ -463,8 +464,8 @@ gst_glsink_getcaps (GstPad * pad, GstCaps * caps) gst_glxwindow_hook_context (sink->hook); while (list) { ret = - gst_caps_append (ret, - ((GstImagePlugin *) list->data)->get_caps (sink->hook)); + gst_caps_append (ret, + ((GstImagePlugin *) list->data)->get_caps (sink->hook)); list = g_list_next (list); } @@ -499,7 +500,7 @@ 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; } @@ -518,11 +519,11 @@ gst_glsink_chain (GstPad * pad, GstData * _data) frame_drops++; return; } - frame_drops = 0; // we made it - reset time + frame_drops = 0; // we made it - reset time GstClockReturn ret; GstClockID id = - gst_clock_new_single_shot_id (sink->clock, GST_BUFFER_TIMESTAMP (buf)); + 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); @@ -552,7 +553,7 @@ gst_glsink_chain (GstPad * pad, GstData * _data) glClearDepth (1.0f); glClearColor (0, 0, 0, 0); - glEnable (GL_AUTO_NORMAL); // let OpenGL generate the Normals + glEnable (GL_AUTO_NORMAL); // let OpenGL generate the Normals glDisable (GL_BLEND); glDisable (GL_CULL_FACE); @@ -594,19 +595,19 @@ gst_glsink_chain (GstPad * pad, GstData * _data) sink->hook->dumpvideo = sink->dumpvideo; sink->plugin->put_image (sink->hook, - (GstImageData *) GST_BUFFER_POOL_PRIVATE (buf)); + (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)); + 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)); + 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)); + (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer)); sink->last_image = buffer; gst_buffer_unref (buf); @@ -640,7 +641,7 @@ gst_glsink_set_property (GObject * object, guint prop_id, const GValue * value, break; case ARG_HOOK: if (sink->hook) { - sink->hook->free_info (sink->hook); + sink->hook->free_info (sink->hook); } sink->hook = g_value_get_pointer (value); break; @@ -658,8 +659,8 @@ gst_glsink_set_property (GObject * object, guint prop_id, const GValue * value, 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: @@ -732,10 +733,10 @@ gst_glsink_change_state (GstElement * element) 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; + gst_buffer_unref (sink->last_image); + sink->last_image = NULL; } break; case GST_STATE_READY_TO_NULL: diff --git a/sys/glsink/gstglxwindow.c b/sys/glsink/gstglxwindow.c index 8fdacb2f..cc4da88c 100644 --- a/sys/glsink/gstglxwindow.c +++ b/sys/glsink/gstglxwindow.c @@ -17,7 +17,7 @@ #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 */ @@ -41,9 +41,9 @@ static int attrListDbl[] = { }; -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 @@ -202,10 +202,10 @@ gst_glxwindow_new (GstElement * sink) { /* create a window in window mode */ new->attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | - StructureNotifyMask; + 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); + 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); @@ -215,7 +215,7 @@ gst_glxwindow_new (GstElement * sink) 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); + title, None, NULL, 0, NULL); XMapRaised (new->dpy, new->win); } /* connect the glx-context to the window */ @@ -238,14 +238,14 @@ gst_glxwindow_new (GstElement * sink) 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 + glDisable (GL_COLOR_MATERIAL); // Enable Material Coloring + glEnable (GL_AUTO_NORMAL); // let OpenGL generate the Normals glDisable (GL_BLEND); diff --git a/sys/glsink/regcomb_yuvrgb.c b/sys/glsink/regcomb_yuvrgb.c index 54727d1e..151b8e18 100644 --- a/sys/glsink/regcomb_yuvrgb.c +++ b/sys/glsink/regcomb_yuvrgb.c @@ -29,22 +29,23 @@ 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 +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 + 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 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. +#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); @@ -59,17 +60,17 @@ GenerateRGBTables (unsigned char *Ytable, // Y-palette 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 + 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 + 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 + 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 @@ -315,7 +316,7 @@ PowerOfTwo (unsigned int i) // 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! +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); diff --git a/sys/qcam/dark.c b/sys/qcam/dark.c index e15a53c9..416d37bc 100644 --- a/sys/qcam/dark.c +++ b/sys/qcam/dark.c @@ -154,21 +154,21 @@ fixdark (const struct qcam *q, scanbuf * scan) return 0; for (y = 0; y < MAX_HEIGHT; y++) for (x = 0; x < MAX_HEIGHT; x++) - if (master_darkmask1[y][x] < smallest_dm) { - smallest_dm = master_darkmask1[y][x]; + 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; } if (brightness < smallest_dm) { #ifdef DEBUG fprintf (stderr, - "Brightness %d (dark current starts at %d), no fixup needed\n", - brightness, smallest_dm); + "Brightness %d (dark current starts at %d), no fixup needed\n", + brightness, smallest_dm); #endif return 1; } @@ -181,16 +181,16 @@ fixdark (const struct qcam *q, scanbuf * scan) for (y = 0; y < max_height; y++) for (x = 0; x < max_width; x++) if (scale == 1) { - darkmask[y][x] = master_darkmask1[y][x]; + darkmask[y][x] = master_darkmask1[y][x]; } else if (scale == 2) { - darkmask[y][x] = master_darkmask2[y][x]; + darkmask[y][x] = master_darkmask2[y][x]; } else if (scale == 4) { - darkmask[y][x] = master_darkmask4[y][x]; + 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; + return 0; } do { @@ -202,52 +202,52 @@ fixdark (const struct qcam *q, scanbuf * scan) 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 */ - new_image[y][x] = val; - } 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]) { - pixelcount++; - pixeltotal += scan[y * width + x - 1]; - } - } - if (x < width - 1) { /* right */ - if (brightness < darkmask[ccd_y][ccd_x + 1]) { - pixelcount++; - pixeltotal += scan[y * width + x + 1]; - } - } - if (y > 0) { /* above */ - if (brightness < darkmask[ccd_y - 1][ccd_x]) { - pixelcount++; - pixeltotal += scan[(y - 1) * width + x]; - } - } - if (y < height - 1) { /* below */ - if (brightness < darkmask[ccd_y + 1][ccd_x]) { - pixelcount++; - pixeltotal += scan[(y + 1) * width + x]; - } - } + val = scan[y * width + x]; + if (brightness < darkmask[ccd_y][ccd_x]) { /* good pixel */ + new_image[y][x] = val; + } 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]) { + pixelcount++; + pixeltotal += scan[y * width + x - 1]; + } + } + if (x < width - 1) { /* right */ + if (brightness < darkmask[ccd_y][ccd_x + 1]) { + pixelcount++; + pixeltotal += scan[y * width + x + 1]; + } + } + if (y > 0) { /* above */ + if (brightness < darkmask[ccd_y - 1][ccd_x]) { + pixelcount++; + pixeltotal += scan[(y - 1) * width + x]; + } + } + if (y < height - 1) { /* below */ + if (brightness < darkmask[ccd_y + 1][ccd_x]) { + pixelcount++; + pixeltotal += scan[(y + 1) * width + x]; + } + } - if (pixelcount == 0) { /* no valid neighbors! */ - again = 1; - } else { - new_image[y][x] = pixeltotal / pixelcount; - /* mark this pixel as valid, so we don't loop forever */ - darkmask[ccd_y][ccd_x] = 255; - } - } + if (pixelcount == 0) { /* no valid neighbors! */ + again = 1; + } else { + new_image[y][x] = pixeltotal / pixelcount; + /* mark this pixel as valid, so we don't loop forever */ + darkmask[ccd_y][ccd_x] = 255; + } + } } } 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 diff --git a/sys/qcam/exposure.c b/sys/qcam/exposure.c index b63e364f..8f18e488 100644 --- a/sys/qcam/exposure.c +++ b/sys/qcam/exposure.c @@ -223,7 +223,7 @@ qcip_autoexposure (struct qcam *q, scanbuf * scan) /* set target if it has not been explicitly set */ if (luminance_std_target == -1) { - luminance_std_target = q->bpp == 6 ? 10 : 2; + luminance_std_target = q->bpp == 6 ? 10 : 2; } /* Adjust contrast to reach target luminance standard deviation */ @@ -231,15 +231,15 @@ qcip_autoexposure (struct qcam *q, scanbuf * scan) 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; - } + 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); + lum_std, luminance_std_target, luminance_std_tolerance); #endif break; diff --git a/sys/qcam/gstqcamsrc.c b/sys/qcam/gstqcamsrc.c index 0c68ca13..ea6a2c1a 100644 --- a/sys/qcam/gstqcamsrc.c +++ b/sys/qcam/gstqcamsrc.c @@ -73,9 +73,10 @@ gst_autoexp_mode_get_type (void) {AE_NONE, "3", "None"}, {0, NULL, NULL}, }; + if (!autoexp_mode_type) { autoexp_mode_type = - g_enum_register_static ("GstAutoExposureMode", autoexp_modes); + g_enum_register_static ("GstAutoExposureMode", autoexp_modes); } return autoexp_mode_type; } @@ -140,9 +141,10 @@ gst_qcamsrc_get_type (void) (GInstanceInitFunc) gst_qcamsrc_init, NULL }; + qcamsrc_type = - g_type_register_static (GST_TYPE_ELEMENT, "GstQCamSrc", &qcamsrc_info, - 0); + g_type_register_static (GST_TYPE_ELEMENT, "GstQCamSrc", &qcamsrc_info, + 0); } return qcamsrc_type; } @@ -168,37 +170,37 @@ gst_qcamsrc_class_init (GstQCamSrcClass * klass) 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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; @@ -256,10 +258,10 @@ gst_qcamsrc_get (GstPad * pad) 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)); + "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); @@ -324,7 +326,7 @@ gst_qcamsrc_set_property (GObject * object, guint prop_id, const GValue * value, case ARG_AUTOEXP: src->autoexposure = g_value_get_enum (value); if (src->autoexposure != AE_NONE) - qcip_set_autoexposure_mode (src->autoexposure); + qcip_set_autoexposure_mode (src->autoexposure); break; default: break; @@ -395,8 +397,8 @@ gst_qcamsrc_change_state (GstElement * element) if (!GST_FLAG_IS_SET (element, GST_QCAMSRC_OPEN)) { gst_info ("qcamsrc: opening\n"); if (!gst_qcamsrc_open (GST_QCAMSRC (element))) { - gst_info ("qcamsrc: open failed\n"); - return GST_STATE_FAILURE; + gst_info ("qcamsrc: open failed\n"); + return GST_STATE_FAILURE; } } } @@ -431,7 +433,7 @@ static gboolean plugin_init (GstPlugin * plugin) { if (!gst_element_register (plugin, "qcamsrc", GST_RANK_NONE, - GST_TYPE_QCAMSRC)) + GST_TYPE_QCAMSRC)) return FALSE; return TRUE; diff --git a/sys/qcam/qcam-Linux.c b/sys/qcam/qcam-Linux.c index 2c959e72..41f7046c 100644 --- a/sys/qcam/qcam-Linux.c +++ b/sys/qcam/qcam-Linux.c @@ -82,7 +82,7 @@ int enable_ports (const struct qcam *q) { if (q->port < 0x278) - return 1; /* Better safe than sorry */ + return 1; /* Better safe than sorry */ if (q->port > 0x3bc) return 1; return (ioperm (q->port, 3, 1)); @@ -115,7 +115,7 @@ 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 */ + 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); @@ -131,7 +131,7 @@ qc_lock_wait (struct qcam *q, int wait) 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)) #endif @@ -142,9 +142,9 @@ qc_lock_wait (struct qcam *q, int wait) return 1; fprintf (stderr, "%s - %d: waiting for exclusive lock on fd %d...\n", - __FILE__, __LINE__, q->fd); + __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"); @@ -202,7 +202,7 @@ qc_unlock (struct qcam *q) static struct flock sfl; #if 1 - if (-1 == q->fd) { /* port was not locked */ + if (-1 == q->fd) { /* port was not locked */ return 1; } @@ -220,7 +220,7 @@ qc_unlock (struct qcam *q) char lockfile[128]; sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port); - unlink (lockfile); /* What would I do with an error? */ + unlink (lockfile); /* What would I do with an error? */ #endif return 0; diff --git a/sys/qcam/qcam-lib.c b/sys/qcam/qcam-lib.c index e7208cdc..c472e577 100644 --- a/sys/qcam/qcam-lib.c +++ b/sys/qcam/qcam-lib.c @@ -252,8 +252,8 @@ qc_calibrate (struct qcam *q) 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 */ @@ -294,7 +294,7 @@ qc_init (void) q = malloc (sizeof (struct qcam)); - q->port = 0; /* Port 0 == Autoprobe */ + q->port = 0; /* Port 0 == Autoprobe */ q->port_mode = (QC_ANY | QC_NOTSET); q->width = 160; q->height = 120; @@ -306,11 +306,11 @@ qc_init (void) 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; } @@ -470,9 +470,9 @@ qc_detect (const struct qcam *q) /* Be liberal in what you accept... */ if (count > 3 && count < 15) - return 1; /* found */ + return 1; /* found */ else - return 0; /* not found */ + return 0; /* not found */ } @@ -498,9 +498,9 @@ qc_reset (struct qcam *q) write_lpdata (q, 0x75); if (read_lpdata (q) != 0x75) { - q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR; + q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR; } else { - q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR; + q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR; } break; @@ -514,7 +514,7 @@ qc_reset (struct qcam *q) write_lpcontrol (q, 0xb); usleep (250); write_lpcontrol (q, 0xe); - (void) qc_setscanmode (q); /* in case port_mode changed */ + (void) qc_setscanmode (q); /* in case port_mode changed */ } @@ -600,7 +600,7 @@ qc_set (struct qcam *q) } else { val = q->width * q->bpp; val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) * - q->transfer_scale; + q->transfer_scale; } val = (val + val2 - 1) / val2; qc_command (q, 0x13); @@ -639,7 +639,7 @@ qc_readbytes (const struct qcam *q, char buffer[]) } switch (q->port_mode & QC_MODE_MASK) { - case QC_BIDIR: /* Bi-directional Port */ + case QC_BIDIR: /* Bi-directional Port */ write_lpcontrol (q, 0x26); lo = (qc_waithand2 (q, 1) >> 1); hi = (read_lpstatus (q) >> 3) & 0x1f; @@ -647,74 +647,74 @@ qc_readbytes (const struct qcam *q, char buffer[]) 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; + 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 */ + 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; + 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. */ + case QC_SERIAL: /* Serial Interface. Just in case. */ default: fprintf (stderr, "Mode %x not supported\n", q->port_mode); ret = -1; @@ -770,7 +770,7 @@ qc_scan (const struct qcam * q) } if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) { - write_lpcontrol (q, 0x2e); /* turn port around */ + write_lpcontrol (q, 0x2e); /* turn port around */ write_lpcontrol (q, 0x26); (void) qc_waithand (q, 1); write_lpcontrol (q, 0x2e); @@ -801,18 +801,18 @@ qc_scan (const struct qcam * q) 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); - if (buffer[k] == 0 && invert == 16) { - /* 4bpp is odd (again) -- inverter is 16, not 15, but output - must be 0-15 -- bls */ - buffer[k] = 16; - } - ret[i * pixels_per_line + pixels_read + k] = invert - buffer[k]; + assert (buffer[k] <= invert); + assert (buffer[k] >= 0); + if (buffer[k] == 0 && invert == 16) { + /* 4bpp is odd (again) -- inverter is 16, not 15, but output + must be 0-15 -- bls */ + buffer[k] = 16; + } + 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) { diff --git a/sys/qcam/qcam-os.c b/sys/qcam/qcam-os.c index 2c959e72..41f7046c 100644 --- a/sys/qcam/qcam-os.c +++ b/sys/qcam/qcam-os.c @@ -82,7 +82,7 @@ int enable_ports (const struct qcam *q) { if (q->port < 0x278) - return 1; /* Better safe than sorry */ + return 1; /* Better safe than sorry */ if (q->port > 0x3bc) return 1; return (ioperm (q->port, 3, 1)); @@ -115,7 +115,7 @@ 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 */ + 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); @@ -131,7 +131,7 @@ qc_lock_wait (struct qcam *q, int wait) 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)) #endif @@ -142,9 +142,9 @@ qc_lock_wait (struct qcam *q, int wait) return 1; fprintf (stderr, "%s - %d: waiting for exclusive lock on fd %d...\n", - __FILE__, __LINE__, q->fd); + __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"); @@ -202,7 +202,7 @@ qc_unlock (struct qcam *q) static struct flock sfl; #if 1 - if (-1 == q->fd) { /* port was not locked */ + if (-1 == q->fd) { /* port was not locked */ return 1; } @@ -220,7 +220,7 @@ qc_unlock (struct qcam *q) char lockfile[128]; sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port); - unlink (lockfile); /* What would I do with an error? */ + unlink (lockfile); /* What would I do with an error? */ #endif return 0; diff --git a/sys/v4l2/gstv4l2.c b/sys/v4l2/gstv4l2.c index 633ce52e..194cb077 100644 --- a/sys/v4l2/gstv4l2.c +++ b/sys/v4l2/gstv4l2.c @@ -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 diff --git a/sys/v4l2/gstv4l2colorbalance.c b/sys/v4l2/gstv4l2colorbalance.c index 274043d8..db53d7f9 100644 --- a/sys/v4l2/gstv4l2colorbalance.c +++ b/sys/v4l2/gstv4l2colorbalance.c @@ -62,8 +62,8 @@ 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); + g_type_register_static (GST_TYPE_COLOR_BALANCE_CHANNEL, + "GstV4l2ColorBalanceChannel", &v4l2_tuner_channel_info, 0); } return gst_v4l2_color_balance_channel_type; @@ -123,7 +123,7 @@ gst_v4l2_color_balance_set_value (GstColorBalance * balance, /* 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); } @@ -140,7 +140,7 @@ gst_v4l2_color_balance_get_value (GstColorBalance * balance, /* 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/gstv4l2element.c b/sys/v4l2/gstv4l2element.c index 246d4949..1595e87f 100644 --- a/sys/v4l2/gstv4l2element.c +++ b/sys/v4l2/gstv4l2element.c @@ -138,22 +138,22 @@ gst_v4l2_class_probe_devices (GstV4l2ElementClass * klass, gboolean check) /* 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); + 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); } } @@ -301,19 +301,19 @@ gst_v4l2element_get_type (void) }; v4l2element_type = - g_type_register_static (GST_TYPE_ELEMENT, - "GstV4l2Element", &v4l2element_info, 0); + g_type_register_static (GST_TYPE_ELEMENT, + "GstV4l2Element", &v4l2element_info, 0); g_type_add_interface_static (v4l2element_type, - GST_TYPE_IMPLEMENTS_INTERFACE, &v4l2iface_info); + GST_TYPE_IMPLEMENTS_INTERFACE, &v4l2iface_info); g_type_add_interface_static (v4l2element_type, - GST_TYPE_TUNER, &v4l2_tuner_info); + GST_TYPE_TUNER, &v4l2_tuner_info); g_type_add_interface_static (v4l2element_type, - GST_TYPE_X_OVERLAY, &v4l2_xoverlay_info); + GST_TYPE_X_OVERLAY, &v4l2_xoverlay_info); g_type_add_interface_static (v4l2element_type, - GST_TYPE_COLOR_BALANCE, &v4l2_colorbalance_info); + GST_TYPE_COLOR_BALANCE, &v4l2_colorbalance_info); g_type_add_interface_static (v4l2element_type, - GST_TYPE_PROPERTY_PROBE, &v4l2_propertyprobe_info); + GST_TYPE_PROPERTY_PROBE, &v4l2_propertyprobe_info); } return v4l2element_type; @@ -329,20 +329,20 @@ gst_v4l2_device_get_type (void) if (v4l2_device_type == 0) { static const GFlagsValue values[] = { {V4L2_CAP_VIDEO_CAPTURE, "CAPTURE", - "Device can capture"}, + "Device can capture"}, {V4L2_CAP_VIDEO_OUTPUT, "PLAYBACK", - "Device can playback"}, + "Device can playback"}, {V4L2_CAP_VIDEO_OVERLAY, "OVERLAY", - "Device can do overlay"}, + "Device can do overlay"}, {V4L2_CAP_TUNER, "TUNER", - "Device has a tuner"}, + "Device has a tuner"}, {V4L2_CAP_AUDIO, "AUDIO", - "Device handles audio"}, + "Device handles audio"}, {0, NULL, NULL} }; v4l2_device_type = - g_flags_register_static ("GstV4l2DeviceTypeFlags", values); + g_flags_register_static ("GstV4l2DeviceTypeFlags", values); } return v4l2_device_type; @@ -368,22 +368,22 @@ gst_v4l2element_class_init (GstV4l2ElementClass * klass) g_object_class_install_property (gobject_class, ARG_DEVICE, g_param_spec_string ("device", "Device", "Device location", - NULL, G_PARAM_READWRITE)); + 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)); + "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)); + 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)); + "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)); + "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)); + "frequency to tune to", 0, G_MAXULONG, 0, G_PARAM_READWRITE)); /* signals */ gst_v4l2element_signals[SIGNAL_OPEN] = @@ -462,49 +462,49 @@ gst_v4l2element_set_property (GObject * object, switch (prop_id) { case ARG_DEVICE: if (!GST_V4L2_IS_OPEN (v4l2element)) { - if (v4l2element->device) - g_free (v4l2element->device); - v4l2element->device = g_value_dup_string (value); + if (v4l2element->device) + g_free (v4l2element->device); + v4l2element->device = g_value_dup_string (value); } break; case ARG_NORM: if (GST_V4L2_IS_OPEN (v4l2element)) { - GstTunerNorm *norm = gst_tuner_get_norm (tuner); + GstTunerNorm *norm = gst_tuner_get_norm (tuner); - if (norm) { - gst_tuner_set_norm (tuner, norm); - } + if (norm) { + gst_tuner_set_norm (tuner, norm); + } } else { - g_free (v4l2element->norm); - v4l2element->norm = g_value_dup_string (value); - g_object_notify (object, "norm"); + g_free (v4l2element->norm); + v4l2element->norm = g_value_dup_string (value); + g_object_notify (object, "norm"); } break; case ARG_CHANNEL: if (GST_V4L2_IS_OPEN (v4l2element)) { - GstTunerChannel *channel = gst_tuner_get_channel (tuner); + GstTunerChannel *channel = gst_tuner_get_channel (tuner); - if (channel) { - gst_tuner_set_channel (tuner, channel); - } + if (channel) { + gst_tuner_set_channel (tuner, channel); + } } else { - g_free (v4l2element->channel); - v4l2element->channel = g_value_dup_string (value); - g_object_notify (object, "channel"); + g_free (v4l2element->channel); + v4l2element->channel = g_value_dup_string (value); + g_object_notify (object, "channel"); } break; case ARG_FREQUENCY: if (GST_V4L2_IS_OPEN (v4l2element)) { - GstTunerChannel *channel; + GstTunerChannel *channel; - if (!v4l2element->channel) - return; - channel = gst_tuner_get_channel (tuner); - g_assert (channel); - gst_tuner_set_frequency (tuner, channel, g_value_get_ulong (value)); + if (!v4l2element->channel) + return; + channel = gst_tuner_get_channel (tuner); + g_assert (channel); + gst_tuner_set_frequency (tuner, channel, g_value_get_ulong (value)); } else { - v4l2element->frequency = g_value_get_ulong (value); - g_object_notify (object, "frequency"); + v4l2element->frequency = g_value_get_ulong (value); + g_object_notify (object, "frequency"); } break; default: @@ -532,7 +532,7 @@ gst_v4l2element_get_property (GObject * object, gchar *new = NULL; if (GST_V4L2_IS_OPEN (v4l2element)) - new = v4l2element->vcap.card; + new = v4l2element->vcap.card; g_value_set_string (value, new); break; } @@ -540,7 +540,7 @@ gst_v4l2element_get_property (GObject * object, guint flags = 0; if (GST_V4L2_IS_OPEN (v4l2element)) { - flags |= v4l2element->vcap.capabilities & 30007; + flags |= v4l2element->vcap.capabilities & 30007; } g_value_set_flags (value, flags); break; @@ -578,23 +578,23 @@ gst_v4l2element_change_state (GstElement * element) gst_v4l2_set_display (v4l2element); if (!gst_v4l2_open (v4l2element)) - return GST_STATE_FAILURE; + 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); + 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; + return GST_STATE_FAILURE; /* emit yet another signal! wheehee! */ g_signal_emit (G_OBJECT (v4l2element), - gst_v4l2element_signals[SIGNAL_CLOSE], 0, v4l2element->device); + gst_v4l2element_signals[SIGNAL_CLOSE], 0, v4l2element->device); break; } diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c index 5e5cdddc..bc9c66a2 100644 --- a/sys/v4l2/gstv4l2src.c +++ b/sys/v4l2/gstv4l2src.c @@ -58,34 +58,34 @@ enum 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)) @@ -150,8 +150,9 @@ gst_v4l2src_get_type (void) gst_v4l2src_init, NULL }; + v4l2src_type = g_type_register_static (GST_TYPE_V4L2ELEMENT, - "GstV4l2Src", &v4l2src_info, 0); + "GstV4l2Src", &v4l2src_info, 0); GST_DEBUG_CATEGORY_INIT (v4l2src_debug, "v4l2src", 0, "v4l2src element"); } return v4l2src_type; @@ -185,16 +186,16 @@ gst_v4l2src_class_init (gpointer g_class, gpointer class_data) 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_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_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)); + "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] = @@ -280,7 +281,7 @@ gst_v4l2src_get_fps (GstV4l2Src * v4l2src) 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; + v4l2src->substract_time; return v4l2src->handled * GST_SECOND / time; } @@ -317,21 +318,21 @@ gst_v4l2src_src_convert (GstPad * pad, 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; + 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; + case GST_FORMAT_TIME: + *dest_value = src_value * GST_SECOND / fps; + break; + default: + return FALSE; } break; @@ -356,15 +357,15 @@ gst_v4l2src_src_query (GstPad * pad, 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: @@ -381,8 +382,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: @@ -399,84 +400,84 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc) 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; - 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; - r_mask = 0x7c00; - g_mask = 0x03e0; - b_mask = 0x001f; - break; - 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; - r_mask = 0xf800; - g_mask = 0x07e0; - b_mask = 0x001f; - case V4L2_PIX_FMT_RGB24: - bpp = depth = 24; - endianness = G_BIG_ENDIAN; - r_mask = 0xff0000; - g_mask = 0x00ff00; - b_mask = 0x0000ff; - break; - case V4L2_PIX_FMT_BGR24: - bpp = depth = 24; - endianness = G_BIG_ENDIAN; - r_mask = 0x0000ff; - g_mask = 0x00ff00; - b_mask = 0xff0000; - break; - case V4L2_PIX_FMT_RGB32: - bpp = depth = 32; - endianness = G_BIG_ENDIAN; - r_mask = 0xff000000; - g_mask = 0x00ff0000; - b_mask = 0x0000ff00; - break; - case V4L2_PIX_FMT_BGR32: - bpp = depth = 32; - endianness = G_BIG_ENDIAN; - r_mask = 0x000000ff; - g_mask = 0x0000ff00; - b_mask = 0x00ff0000; - break; - default: - g_assert_not_reached (); - break; + case V4L2_PIX_FMT_RGB332: + bpp = depth = 8; + 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; + r_mask = 0x7c00; + g_mask = 0x03e0; + b_mask = 0x001f; + break; + 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; + r_mask = 0xf800; + g_mask = 0x07e0; + b_mask = 0x001f; + case V4L2_PIX_FMT_RGB24: + bpp = depth = 24; + endianness = G_BIG_ENDIAN; + r_mask = 0xff0000; + g_mask = 0x00ff00; + b_mask = 0x0000ff; + break; + case V4L2_PIX_FMT_BGR24: + bpp = depth = 24; + endianness = G_BIG_ENDIAN; + r_mask = 0x0000ff; + g_mask = 0x00ff00; + b_mask = 0xff0000; + break; + case V4L2_PIX_FMT_RGB32: + bpp = depth = 32; + endianness = G_BIG_ENDIAN; + r_mask = 0xff000000; + g_mask = 0x00ff0000; + b_mask = 0x0000ff00; + break; + case V4L2_PIX_FMT_BGR32: + bpp = depth = 32; + endianness = G_BIG_ENDIAN; + r_mask = 0x000000ff; + g_mask = 0x0000ff00; + b_mask = 0x00ff0000; + break; + default: + 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, - "green_mask", G_TYPE_INT, g_mask, - "blue_mask", G_TYPE_INT, b_mask, - "endianness", G_TYPE_INT, endianness, NULL); + "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); 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: @@ -484,48 +485,48 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc) guint32 fcc = 0; switch (fourcc) { - case V4L2_PIX_FMT_YVU410: - fcc = GST_MAKE_FOURCC ('Y', 'V', 'U', '9'); - break; - case V4L2_PIX_FMT_YUV410: - fcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9'); - break; - case V4L2_PIX_FMT_YUV420: - fcc = GST_MAKE_FOURCC ('I', '4', '2', '0'); - break; - case V4L2_PIX_FMT_YUYV: - fcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'); - break; - case V4L2_PIX_FMT_YVU420: - fcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2'); - break; - case V4L2_PIX_FMT_UYVY: - fcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'); - break; - case V4L2_PIX_FMT_Y41P: - fcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B'); - break; - default: - g_assert_not_reached (); - break; + case V4L2_PIX_FMT_YVU410: + fcc = GST_MAKE_FOURCC ('Y', 'V', 'U', '9'); + break; + case V4L2_PIX_FMT_YUV410: + fcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9'); + break; + case V4L2_PIX_FMT_YUV420: + fcc = GST_MAKE_FOURCC ('I', '4', '2', '0'); + break; + case V4L2_PIX_FMT_YUYV: + fcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'); + break; + case V4L2_PIX_FMT_YVU420: + fcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2'); + break; + case V4L2_PIX_FMT_UYVY: + fcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'); + break; + case V4L2_PIX_FMT_Y41P: + fcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B'); + break; + default: + 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); + 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 @@ -552,8 +553,8 @@ gst_v4l2src_get_format_from_fourcc (GstV4l2Src * v4l2src, guint32 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)) { + || (fmt->pixelformat == V4L2_PIX_FMT_JPEG + && fourcc == V4L2_PIX_FMT_MJPEG)) { return fmt; } walk = g_slist_next (walk); @@ -578,48 +579,48 @@ gst_v4l2_fourcc_from_structure (GstStructure * structure) switch (fourcc) { case GST_MAKE_FOURCC ('I', '4', '2', '0'): case GST_MAKE_FOURCC ('I', 'Y', 'U', 'V'): - fourcc = V4L2_PIX_FMT_YUV420; - break; + fourcc = V4L2_PIX_FMT_YUV420; + break; case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'): - fourcc = V4L2_PIX_FMT_YUYV; - break; + fourcc = V4L2_PIX_FMT_YUYV; + break; case GST_MAKE_FOURCC ('Y', '4', '1', 'P'): - fourcc = V4L2_PIX_FMT_Y41P; - break; + fourcc = V4L2_PIX_FMT_Y41P; + break; case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'): - fourcc = V4L2_PIX_FMT_UYVY; - break; + fourcc = V4L2_PIX_FMT_UYVY; + break; case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): - fourcc = V4L2_PIX_FMT_YVU420; - break; + fourcc = V4L2_PIX_FMT_YVU420; + break; case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):{ - gint depth, endianness, r_mask; - - gst_structure_get_int (structure, "depth", &depth); - gst_structure_get_int (structure, "endianness", &endianness); - gst_structure_get_int (structure, "red_mask", &r_mask); - - switch (depth) { - case 8: - fourcc = V4L2_PIX_FMT_RGB332; - break; - case 15: - fourcc = (endianness == G_LITTLE_ENDIAN) ? - V4L2_PIX_FMT_RGB555 : V4L2_PIX_FMT_RGB555X; - break; - case 16: - fourcc = (endianness == G_LITTLE_ENDIAN) ? - V4L2_PIX_FMT_RGB565 : V4L2_PIX_FMT_RGB565X; - break; - case 24: - 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; - break; - } + gint depth, endianness, r_mask; + + gst_structure_get_int (structure, "depth", &depth); + gst_structure_get_int (structure, "endianness", &endianness); + gst_structure_get_int (structure, "red_mask", &r_mask); + + switch (depth) { + case 8: + fourcc = V4L2_PIX_FMT_RGB332; + break; + case 15: + fourcc = (endianness == G_LITTLE_ENDIAN) ? + V4L2_PIX_FMT_RGB555 : V4L2_PIX_FMT_RGB555X; + break; + case 16: + fourcc = (endianness == G_LITTLE_ENDIAN) ? + V4L2_PIX_FMT_RGB565 : V4L2_PIX_FMT_RGB565X; + break; + case 24: + 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; + break; + } default: - break; + break; } } } else if (strcmp (mimetype, "video/x-dv") == 0) { @@ -651,12 +652,12 @@ gst_v4l2src_get_all_caps (void) for (i = 0; i < GST_V4L2_FORMAT_COUNT; i++) { structure = gst_v4l2src_v4l2fourcc_to_caps (gst_v4l2_formats[i]); if (structure) { - 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); + 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); - gst_caps_append_structure (caps, structure); + gst_caps_append_structure (caps, structure); } } } @@ -680,8 +681,8 @@ gst_v4l2src_fixate (GstPad * pad, const GstCaps * const_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, "width", - G_MAXINT); + gst_caps_structure_fixate_field_nearest_int (structure, "width", + G_MAXINT); } if (changed) return caps; @@ -689,8 +690,8 @@ gst_v4l2src_fixate (GstPad * pad, const GstCaps * const_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); + gst_caps_structure_fixate_field_nearest_int (structure, "height", + G_MAXINT); } if (changed) return caps; @@ -764,7 +765,7 @@ gst_v4l2src_getcaps (GstPad * pad) /* get size delimiters */ if (!gst_v4l2src_get_size_limits (v4l2src, format, - &min_w, &max_w, &min_h, &max_h)) { + &min_w, &max_w, &min_h, &max_h)) { continue; } @@ -773,9 +774,9 @@ gst_v4l2src_getcaps (GstPad * pad) if (structure) { 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); + "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); gst_caps_append_structure (caps, structure); } @@ -796,7 +797,7 @@ gst_v4l2src_get (GstPad * 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")); + ("could not get frame rate for element")); return NULL; } @@ -818,69 +819,69 @@ gst_v4l2src_get (GstPad * pad) gboolean have_frame = FALSE; do { - /* FIXME: isn't this v4l2 timestamp its own clock?! */ - /* by default, we use the frame once */ - v4l2src->need_writes = 1; - - g_assert (time >= v4l2src->substract_time); - time -= v4l2src->substract_time; - - /* 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, - v4l2src->need_writes - 1); - } - } - v4l2src->last_seq = v4l2src->pool->buffers[num].buffer.sequence; - - /* decide how often we're going to write the frame - set - * v4lmjpegsrc->need_writes to (that-1) and have_frame to TRUE - * if we're going to write it - else, just continue. - * - * time is generally the system or audio clock. Let's - * say that we've written one second of audio, then we want - * to have written one second of video too, within the same - * 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)) { - /* 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)) { - /* 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); - } - - if (v4l2src->need_writes > 0) { - have_frame = TRUE; - v4l2src->need_writes--; - } else { - if (!gst_v4l2src_queue_frame (v4l2src, num)) - return NULL; - num = gst_v4l2src_grab_frame (v4l2src); - if (num == -1) - return NULL; - } + /* FIXME: isn't this v4l2 timestamp its own clock?! */ + /* by default, we use the frame once */ + v4l2src->need_writes = 1; + + g_assert (time >= v4l2src->substract_time); + time -= v4l2src->substract_time; + + /* 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, + v4l2src->need_writes - 1); + } + } + v4l2src->last_seq = v4l2src->pool->buffers[num].buffer.sequence; + + /* decide how often we're going to write the frame - set + * v4lmjpegsrc->need_writes to (that-1) and have_frame to TRUE + * if we're going to write it - else, just continue. + * + * time is generally the system or audio clock. Let's + * say that we've written one second of audio, then we want + * to have written one second of video too, within the same + * 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)) { + /* 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)) { + /* 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); + } + + if (v4l2src->need_writes > 0) { + have_frame = TRUE; + v4l2src->need_writes--; + } else { + if (!gst_v4l2src_queue_frame (v4l2src, num)) + return NULL; + num = gst_v4l2src_grab_frame (v4l2src); + if (num == -1) + return NULL; + } } while (!have_frame); } g_assert (num != -1); GST_LOG_OBJECT (v4l2src, "buffer %d needs %d writes", num, - v4l2src->need_writes + 1); + v4l2src->need_writes + 1); i = v4l2src->pool->buffers[num].buffer.bytesused > - 0 ? v4l2src->pool->buffers[num].buffer.bytesused : v4l2src->pool-> - buffers[num].length; + 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) { @@ -888,8 +889,8 @@ gst_v4l2src_get (GstPad * pad) 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)) { - gst_data_unref (GST_DATA (buf)); - return NULL; + gst_data_unref (GST_DATA (buf)); + return NULL; } } else { GST_LOG_OBJECT (v4l2src, "using mmap'd buffer"); @@ -909,13 +910,13 @@ gst_v4l2src_get (GstPad * pad) } else { /* calculate time based on our own clock */ GST_BUFFER_TIMESTAMP (buf) = - GST_TIMEVAL_TO_TIME (v4l2src->pool->buffers[num].buffer.timestamp) - - v4l2src->substract_time; + GST_TIMEVAL_TO_TIME (v4l2src->pool->buffers[num].buffer.timestamp) - + v4l2src->substract_time; } if (v4l2src->need_writes > 0) { v4l2src->cached_buffer = buf; for (i = 0; i < v4l2src->need_writes; i++) { - gst_data_ref (GST_DATA (buf)); + gst_data_ref (GST_DATA (buf)); } } } @@ -939,13 +940,13 @@ gst_v4l2src_set_property (GObject * object, switch (prop_id) { case ARG_NUMBUFS: if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT (v4l2src))) { - v4l2src->breq.count = g_value_get_int (value); + 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); + v4l2src->use_fixed_fps = g_value_get_boolean (value); } break; @@ -1005,7 +1006,7 @@ gst_v4l2src_change_state (GstElement * element) switch (transition) { case GST_STATE_NULL_TO_READY: if (!gst_v4l2src_get_capture (v4l2src)) - return GST_STATE_FAILURE; + return GST_STATE_FAILURE; break; case GST_STATE_READY_TO_PAUSED: v4l2src->handled = 0; @@ -1016,24 +1017,24 @@ gst_v4l2src_change_state (GstElement * element) case GST_STATE_PAUSED_TO_PLAYING: /* queue all buffer, start streaming capture */ if (!gst_v4l2src_capture_start (v4l2src)) - return GST_STATE_FAILURE; + return GST_STATE_FAILURE; g_get_current_time (&time); v4l2src->substract_time = GST_TIMEVAL_TO_TIME (time) - - v4l2src->substract_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; + v4l2src->substract_time; /* de-queue all queued buffers */ if (!gst_v4l2src_capture_stop (v4l2src)) - return GST_STATE_FAILURE; + 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; + return GST_STATE_FAILURE; break; case GST_STATE_READY_TO_NULL: break; diff --git a/sys/v4l2/gstv4l2tuner.c b/sys/v4l2/gstv4l2tuner.c index 5d5626f2..79e3214b 100644 --- a/sys/v4l2/gstv4l2tuner.c +++ b/sys/v4l2/gstv4l2tuner.c @@ -76,8 +76,8 @@ 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); + g_type_register_static (GST_TYPE_TUNER_CHANNEL, + "GstV4l2TunerChannel", &v4l2_tuner_channel_info, 0); } return gst_v4l2_tuner_channel_type; @@ -117,8 +117,8 @@ 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); + g_type_register_static (GST_TYPE_TUNER_NORM, + "GstV4l2TunerNorm", &v4l2_tuner_norm_info, 0); } return gst_v4l2_tuner_norm_type; @@ -295,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); @@ -319,9 +319,9 @@ gst_v4l2_tuner_get_frequency (GstTuner * mixer, GstTunerChannel * channel) /* 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 && @@ -343,9 +343,9 @@ gst_v4l2_tuner_signal_strength (GstTuner * mixer, GstTunerChannel * channel) /* 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/gstv4l2xoverlay.c b/sys/v4l2/gstv4l2xoverlay.c index 1af62cc1..515d8463 100644 --- a/sys/v4l2/gstv4l2xoverlay.c +++ b/sys/v4l2/gstv4l2xoverlay.c @@ -72,7 +72,7 @@ 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); } } @@ -85,7 +85,7 @@ gst_v4l2_xoverlay_close (GstV4l2Element * v4l2element) 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); } diff --git a/sys/v4l2/v4l2-overlay_calls.c b/sys/v4l2/v4l2-overlay_calls.c index d4a10ab7..0876879d 100644 --- a/sys/v4l2/v4l2-overlay_calls.c +++ b/sys/v4l2/v4l2-overlay_calls.c @@ -60,14 +60,14 @@ gst_v4l2_set_display (GstV4l2Element * v4l2element) switch (system (buff)) { case -1: GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED, - (_("Could not start v4l-conf.")), GST_ERROR_SYSTEM); + (_("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); + (_("Executing v4l-conf failed.")), GST_ERROR_SYSTEM); g_free (buff); return FALSE; } @@ -106,7 +106,7 @@ gst_v4l2_set_window (GstElement * element, 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))); + ("Failed to set the video window: %s", g_strerror (errno))); return FALSE; } @@ -131,8 +131,8 @@ gst_v4l2_enable_overlay (GstV4l2Element * v4l2element, gboolean enable) 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))); + ("Failed to %s overlay display: %s", + enable ? "enable" : "disable", g_strerror (errno))); return FALSE; } diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c index f75ea550..92de8a42 100644 --- a/sys/v4l2/v4l2_calls.c +++ b/sys/v4l2/v4l2_calls.c @@ -56,8 +56,8 @@ gst_v4l2_get_capabilities (GstV4l2Element * 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))); + ("Error getting %s capabilities: %s", + v4l2element->device, g_strerror (errno))); return FALSE; } @@ -94,14 +94,14 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element) 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; - } + 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); @@ -110,34 +110,34 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element) 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; + 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; + /* 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); + g_list_append (v4l2element->channels, (gpointer) channel); } } else { /* outputs */ @@ -148,14 +148,14 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element) 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; - } + 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); @@ -164,15 +164,15 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element) 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; + /* 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); + g_list_append (v4l2element->channels, (gpointer) channel); } } @@ -185,12 +185,12 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element) standard.index = n; if (ioctl (v4l2element->video_fd, VIDIOC_ENUMSTD, &standard) < 0) { if (errno == EINVAL) - break; /* end of enumeration */ + 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; + 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; } } @@ -198,7 +198,7 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element) norm = GST_TUNER_NORM (v4l2norm); norm->label = g_strdup (standard.name); norm->fps = (gfloat) standard.frameperiod.denominator / - standard.frameperiod.numerator; + standard.frameperiod.numerator; v4l2norm->index = standard.id; v4l2element->norms = g_list_append (v4l2element->norms, (gpointer) norm); @@ -217,15 +217,15 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element) control.id = n; if (ioctl (v4l2element->video_fd, VIDIOC_QUERYCTRL, &control) < 0) { if (errno == EINVAL) { - if (n < V4L2_CID_PRIVATE_BASE) - continue; - else - break; + 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; + 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) @@ -245,12 +245,12 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element) case V4L2_CID_EXPOSURE: case V4L2_CID_AUTOGAIN: case V4L2_CID_GAIN: - /* we only handle these for now */ - break; + /* we only handle these for now */ + break; default: - DEBUG ("ControlID %s (%d) unhandled, FIXME", control.name, n); - control.id++; - break; + DEBUG ("ControlID %s (%d) unhandled, FIXME", control.name, n); + control.id++; + break; } if (n != control.id) continue; @@ -267,20 +267,20 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element) 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); + 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); @@ -288,20 +288,20 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element) switch (control.type) { case V4L2_CTRL_TYPE_INTEGER: - channel->min_value = control.minimum; - channel->max_value = control.maximum; - break; + 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; + channel->min_value = FALSE; + channel->max_value = TRUE; + break; default: - channel->min_value = channel->max_value = 0; - break; + channel->min_value = channel->max_value = 0; + break; } v4l2element->colors = g_list_append (v4l2element->colors, - (gpointer) channel); + (gpointer) channel); } return TRUE; @@ -352,7 +352,7 @@ gst_v4l2_set_defaults (GstV4l2Element * v4l2element) gst_tuner_set_channel (tuner, channel); } else { channel = - GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2element))); + 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"); @@ -392,8 +392,8 @@ gst_v4l2_open (GstV4l2Element * v4l2element) 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); + (_("Could not open device \"%s\" for reading and writing."), + v4l2element->device), GST_ERROR_SYSTEM); goto error; } @@ -406,8 +406,8 @@ gst_v4l2_open (GstV4l2Element * v4l2element) 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)); + (_("Device \"%s\" is not a capture device."), v4l2element->device), + ("Capabilities: 0x%x", v4l2element->vcap.capabilities)); goto error; } @@ -474,8 +474,8 @@ gst_v4l2_get_norm (GstV4l2Element * v4l2element, v4l2_std_id * norm) 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))); + ("Failed to get the current norm for device %s: %s", + v4l2element->device, g_strerror (errno))); return FALSE; } @@ -498,8 +498,8 @@ gst_v4l2_set_norm (GstV4l2Element * v4l2element, v4l2_std_id norm) 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))); + ("Failed to set norm 0x%llx for device %s: %s", + norm, v4l2element->device, g_strerror (errno))); return FALSE; } @@ -523,8 +523,8 @@ gst_v4l2_get_input (GstV4l2Element * v4l2element, gint * input) 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))); + ("Failed to get current input on device %s: %s", + v4l2element->device, g_strerror (errno))); return FALSE; } @@ -549,8 +549,8 @@ gst_v4l2_set_input (GstV4l2Element * v4l2element, gint input) 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))); + ("Failed to set input %d on device %s: %s", + input, v4l2element->device, g_strerror (errno))); return FALSE; } @@ -574,8 +574,8 @@ gst_v4l2_get_output (GstV4l2Element * v4l2element, gint * output) 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))); + ("Failed to get current output on device %s: %s", + v4l2element->device, g_strerror (errno))); return FALSE; } @@ -600,8 +600,8 @@ gst_v4l2_set_output (GstV4l2Element * v4l2element, gint output) 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))); + ("Failed to set output %d on device %s: %s", + output, v4l2element->device, g_strerror (errno))); return FALSE; } @@ -627,8 +627,8 @@ gst_v4l2_get_frequency (GstV4l2Element * 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))); + ("Failed to get current tuner frequency for device %s: %s", + v4l2element->device, g_strerror (errno))); return FALSE; } @@ -661,8 +661,8 @@ gst_v4l2_set_frequency (GstV4l2Element * v4l2element, 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))); + ("Failed to set tuner frequency to %lu for device %s: %s", + frequency, v4l2element->device, g_strerror (errno))); return FALSE; } @@ -688,8 +688,8 @@ gst_v4l2_signal_strength (GstV4l2Element * 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))); + ("Failed to get signal strength for device %s: %s", + v4l2element->device, g_strerror (errno))); return FALSE; } @@ -719,8 +719,8 @@ gst_v4l2_get_attribute (GstV4l2Element * v4l2element, 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))); + ("Failed to get value for control %d on device %s: %s", + attribute_num, v4l2element->device, g_strerror (errno))); return FALSE; } @@ -751,8 +751,8 @@ gst_v4l2_set_attribute (GstV4l2Element * v4l2element, 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))); + ("Failed to set value %d for control %d on device %s: %s", + value, attribute_num, v4l2element->device, g_strerror (errno))); return FALSE; } diff --git a/sys/v4l2/v4l2src_calls.c b/sys/v4l2/v4l2src_calls.c index 00d710eb..a2db4f2b 100644 --- a/sys/v4l2/v4l2src_calls.c +++ b/sys/v4l2/v4l2src_calls.c @@ -70,19 +70,19 @@ gst_v4l2src_fill_format_list (GstV4l2Src * v4l2src) format->index = n; format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_ENUM_FMT, - format) < 0) { + 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))); - g_free (format); - return FALSE; + 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))); + g_free (format); + return FALSE; } } GST_LOG_OBJECT (v4l2src, "got format" GST_FOURCC_FORMAT, - GST_FOURCC_ARGS (format->pixelformat)); + GST_FOURCC_ARGS (format->pixelformat)); v4l2src->formats = g_slist_prepend (v4l2src->formats, format); } @@ -118,11 +118,11 @@ 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) { + &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; } @@ -146,8 +146,8 @@ gst_v4l2src_grab_frame (GstV4l2Src * v4l2src) /* 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))); + ("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"); @@ -174,10 +174,10 @@ gst_v4l2src_get_capture (GstV4l2Src * v4l2src) v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_G_FMT, - &v4l2src->format) < 0) { + &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))); + ("failed to get pixelformat for device %s: %s", + GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno))); return FALSE; } @@ -209,11 +209,11 @@ gst_v4l2src_set_capture (GstV4l2Src * v4l2src, v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_S_FMT, - &v4l2src->format) < 0) { + &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))); + ("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; } @@ -250,21 +250,21 @@ 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) { + &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; } @@ -292,19 +292,19 @@ gst_v4l2src_capture_init (GstV4l2Src * v4l2src) buffer->buffer.index = n; buffer->buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_QUERYBUF, - &buffer->buffer) < 0) { + &buffer->buffer) < 0) { GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL), - ("Could not get buffer properties of buffer %d: %s", n, - g_strerror (errno))); + ("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); + 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))); + ("Could not mmap video buffer %d: %s", n, g_strerror (errno))); buffer->start = 0; gst_v4l2src_capture_deinit (v4l2src); return FALSE; @@ -344,8 +344,8 @@ gst_v4l2src_capture_start (GstV4l2Src * v4l2src) 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; } @@ -372,8 +372,8 @@ gst_v4l2src_capture_stop (GstV4l2Src * v4l2src) * on the non-queued ones */ 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; } @@ -445,7 +445,7 @@ gst_v4l2src_capture_deinit (GstV4l2Src * v4l2src) 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"); + "Could not dequeue buffer on uninitialization"); } if (gst_atomic_int_dec_and_test (&v4l2src->pool->refcount)) { /* we're last thing that used all this */ diff --git a/sys/vcd/vcdsrc.c b/sys/vcd/vcdsrc.c index b2868628..cb6389b2 100644 --- a/sys/vcd/vcdsrc.c +++ b/sys/vcd/vcdsrc.c @@ -97,8 +97,9 @@ vcdsrc_get_type (void) 0, (GInstanceInitFunc) vcdsrc_init, }; + vcdsrc_type = - g_type_register_static (GST_TYPE_ELEMENT, "VCDSrc", &vcdsrc_info, 0); + g_type_register_static (GST_TYPE_ELEMENT, "VCDSrc", &vcdsrc_info, 0); } return vcdsrc_type; } @@ -121,13 +122,13 @@ vcdsrc_class_init (VCDSrcClass * 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_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_PARAM_READWRITE)); gobject_class->set_property = vcdsrc_set_property; gobject_class->get_property = vcdsrc_get_property; @@ -170,13 +171,13 @@ vcdsrc_set_property (GObject * object, guint prop_id, const GValue * value, /* g_return_if_fail(!GST_FLAG_IS_SET(src,GST_STATE_RUNNING)); */ if (src->device) - g_free (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); @@ -276,7 +277,7 @@ read_sector: } 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? */ @@ -327,14 +328,14 @@ vcdsrc_open_file (VCDSrc * src) /* 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); + 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.second) * 75) + src->tracks[src->track - 1].cdte_addr.msf.frame; fprintf (stderr, "VCDSrc: track offset is %ld\n", src->trackoffset); @@ -372,7 +373,7 @@ vcdsrc_change_state (GstElement * element) } else { if (!GST_FLAG_IS_SET (element, VCDSRC_OPEN)) { if (!vcdsrc_open_file (VCDSRC (element))) - return GST_STATE_FAILURE; + return GST_STATE_FAILURE; } } @@ -387,9 +388,9 @@ vcdsrc_recalculate (VCDSrc * vcdsrc) 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; + (((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); } } |