gst-indent

Original commit message from CVS:
gst-indent
This commit is contained in:
Thomas Vander Stichele 2004-03-14 22:34:34 +00:00
parent e9bef8b9bd
commit 4df3f18839
215 changed files with 17714 additions and 18367 deletions

View file

@ -1,3 +1,7 @@
2004-03-14 Thomas Vander Stichele <thomas at apestaart dot org>
* *.c, *.h: run gst-indent
2004-03-14 Benjamin Otte <otte@gnome.org>
* gst/modplug/gstmodplug.cc:

View file

@ -44,7 +44,8 @@ main (gint argc, gchar *argv[])
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
demux = gst_element_factory_make ("mpegdemux", "demux");
g_return_val_if_fail (demux, -1);
g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func), pipeline);
g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func),
pipeline);
thread = gst_thread_new ("thread");
queue = gst_element_factory_make ("queue", "queue");
@ -70,10 +71,8 @@ main (gint argc, gchar *argv[])
gst_element_link (mpeg2dec, "src", colorspace, "sink");
/* force RGB data passing between colorspace and xvideosink */
res = gst_element_link_filtered (colorspace, "src", xvideosink, "sink",
GST_CAPS_NEW (
"filtercaps",
"video/raw",
"format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
GST_CAPS_NEW ("filtercaps",
"video/raw", "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
));
if (!res) {
g_print ("could not connect colorspace and xvideosink\n");

View file

@ -48,6 +48,7 @@ typedef struct _filter_data _filter_data_t;
/* internal prototypes when they can't be avoided */
void cb_remove_and_destroy (GtkWidget * widget, gpointer user_data);
//void cb_dynparm_value_changed (GtkWidget *widget, gpointer user_data);
void cb_dynparm_value_changed (GtkRange * range, GstDParam * dparam);
@ -67,24 +68,21 @@ gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction,
g_print ("DEBUG: find_unconnected start\n");
elements = (GList *) gst_bin_get_list (bin);
/* traverse all elements looking for unconnected pads */
while (elements && pad == NULL)
{
while (elements && pad == NULL) {
element = GST_ELEMENT (elements->data);
g_print ("DEBUG: looking in element %s\n", gst_element_get_name (element));
pads = gst_element_get_pad_list (element);
while (pads)
{
while (pads) {
/* check if the direction matches */
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction)
{
if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL)
{
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) {
if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) {
/* found it ! */
g_print ("DEBUG: found an unconnected pad !\n");
pad = GST_PAD (pads->data);
}
}
if (pad) break; /* found one already */
if (pad)
break; /* found one already */
pads = g_list_next (pads);
}
elements = g_list_next (elements);
@ -150,23 +148,19 @@ ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui)
gtk_container_add (GTK_CONTAINER (control), widget);
gtk_widget_show (widget);
if ((dpman = gst_dpman_get_manager (element)))
{
if ((dpman = gst_dpman_get_manager (element))) {
ui_feedback_add (ui, "Found Dynamic Parameters on filter element.\n");
specs = gst_dpman_list_dparam_specs (dpman);
for (i = 0; specs[i] != NULL; ++i)
{
for (i = 0; specs[i] != NULL; ++i) {
hbox = gtk_hbox_new (FALSE, 0);
widget = gtk_label_new (g_param_spec_get_name (specs[i]));
gtk_container_add (GTK_CONTAINER (hbox), widget);
gtk_widget_show (widget);
switch (G_PARAM_SPEC_VALUE_TYPE (specs[i]))
{
switch (G_PARAM_SPEC_VALUE_TYPE (specs[i])) {
case G_TYPE_INT64:
widget = gtk_hscale_new_with_range (
(gdouble) (((GParamSpecInt64 *) specs[i])->minimum),
(gdouble) (((GParamSpecInt64*)specs[i])->maximum),
1.0);
(gdouble) (((GParamSpecInt64 *) specs[i])->maximum), 1.0);
gtk_range_set_value (GTK_RANGE (widget),
(gdouble) ((GParamSpecInt64 *) specs[i])->default_value);
break;
@ -174,16 +168,14 @@ ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui)
case G_TYPE_INT:
widget = gtk_hscale_new_with_range (
(gdouble) (((GParamSpecInt *) specs[i])->minimum),
(gdouble) (((GParamSpecInt*)specs[i])->maximum),
1.0);
(gdouble) (((GParamSpecInt *) specs[i])->maximum), 1.0);
gtk_range_set_value (GTK_RANGE (widget),
(gdouble) ((GParamSpecInt *) specs[i])->default_value);
break;
case G_TYPE_FLOAT:
widget = gtk_hscale_new_with_range (
(gdouble) (((GParamSpecFloat *) specs[i])->minimum),
(gdouble) (((GParamSpecFloat*)specs[i])->maximum),
0.00001);
(gdouble) (((GParamSpecFloat *) specs[i])->maximum), 0.00001);
gtk_range_set_value (GTK_RANGE (widget),
(gdouble) ((GParamSpecFloat *) specs[i])->default_value);
break;
@ -192,8 +184,7 @@ ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui)
dparam = gst_dpsmooth_new (G_PARAM_SPEC_VALUE_TYPE (specs[i]));
g_object_set (G_OBJECT (dparam), "update_period", 2000000LL, NULL);
g_assert (gst_dpman_attach_dparam (dpman,
(gchar *) g_param_spec_get_name (specs[i]),
dparam));
(gchar *) g_param_spec_get_name (specs[i]), dparam));
gst_dpman_set_mode (dpman, "asynchronous");
g_signal_connect (widget, "value-changed",
G_CALLBACK (cb_dynparm_value_changed), dparam);
@ -227,6 +218,7 @@ cb_dynparm_value_changed (GtkRange *range, GstDParam *dparam)
GtkHScale *adj = GTK_HSCALE (widget);
*/
gdouble value = 0.0;
g_assert (GST_IS_DPARAM (dparam));
g_assert (GTK_IS_RANGE (range));
@ -234,21 +226,17 @@ cb_dynparm_value_changed (GtkRange *range, GstDParam *dparam)
g_print ("DEBUG: setting value to %f\n", value);
switch (G_PARAM_SPEC_VALUE_TYPE (GST_DPARAM_PARAM_SPEC (dparam)))
{
switch (G_PARAM_SPEC_VALUE_TYPE (GST_DPARAM_PARAM_SPEC (dparam))) {
case G_TYPE_INT64:
g_object_set (G_OBJECT (dparam), "value_int64",
(gint64) value, NULL);
g_object_set (G_OBJECT (dparam), "value_int64", (gint64) value, NULL);
break;
case G_TYPE_INT:
g_object_set (G_OBJECT (dparam), "value_int",
(gint) value, NULL);
g_object_set (G_OBJECT (dparam), "value_int", (gint) value, NULL);
break;
case G_TYPE_FLOAT:
g_object_set (G_OBJECT (dparam), "value_float",
(gfloat) value, NULL);
g_object_set (G_OBJECT (dparam), "value_float", (gfloat) value, NULL);
break;
}
}
@ -267,8 +255,7 @@ cb_play_clicked (GtkButton *button, gpointer *user_data)
_filter_data_t *fd = (_filter_data_t *) user_data;
g_return_if_fail (GST_IS_PIPELINE (fd->pipeline));
if (GST_STATE (fd->pipeline) == GST_STATE_PLAYING)
{
if (GST_STATE (fd->pipeline) == GST_STATE_PLAYING) {
ui_feedback_add (fd->ui, "Pipeline is already playing !\n");
return;
}
@ -280,8 +267,7 @@ cb_stop_clicked (GtkButton *button, gpointer *user_data)
{
_filter_data_t *fd = (_filter_data_t *) user_data;
if (GST_STATE (fd->pipeline) != GST_STATE_PLAYING)
{
if (GST_STATE (fd->pipeline) != GST_STATE_PLAYING) {
ui_feedback_add (fd->ui, "Pipeline is not playing !\n");
return;
}
@ -299,44 +285,49 @@ cb_parse_clicked (GtkButton *button, gpointer *user_data)
g_print ("DEBUG: you pressed parse.\n");
ui_feedback_clear (fd->ui);
ui_feedback_add (fd->ui, "Parsing pipeline ...\n");
if (fd->input_pipe) g_free (fd->input_pipe);
if (fd->output_pipe) g_free (fd->output_pipe);
if (fd->filter_element) g_free (fd->filter_element);
if (fd->input_pipe)
g_free (fd->input_pipe);
if (fd->output_pipe)
g_free (fd->output_pipe);
if (fd->filter_element)
g_free (fd->filter_element);
fd->input_pipe = g_strdup_printf ("bin.( %s )",
gtk_entry_get_text (GTK_ENTRY (fd->ui->input)));
fd->output_pipe = g_strdup_printf ("bin.( %s )",
gtk_entry_get_text (GTK_ENTRY (fd->ui->output)));
/* gtkcombo.h says I can access the entry field directly */
fd->filter_element = g_strdup (gtk_entry_get_text (GTK_ENTRY (filter->entry)));
g_print ("Input pipeline :\t%s (%d)\n", fd->input_pipe, (int)strlen (fd->input_pipe));
g_print ("Filter element :\t%s (%d)\n", fd->filter_element, (int)strlen (fd->filter_element));
g_print ("Output pipeline :\t%s (%d)\n", fd->output_pipe, (int)strlen (fd->output_pipe));
fd->filter_element =
g_strdup (gtk_entry_get_text (GTK_ENTRY (filter->entry)));
g_print ("Input pipeline :\t%s (%d)\n", fd->input_pipe,
(int) strlen (fd->input_pipe));
g_print ("Filter element :\t%s (%d)\n", fd->filter_element,
(int) strlen (fd->filter_element));
g_print ("Output pipeline :\t%s (%d)\n", fd->output_pipe,
(int) strlen (fd->output_pipe));
/* try to create in and out bins */
if (strlen (fd->input_pipe) == 0)
{
if (strlen (fd->input_pipe) == 0) {
ui_feedback_add (fd->ui, "Error : try setting an input pipe.\n");
return;
}
if (fd->input) gst_object_unref (GST_OBJECT (fd->input));
if (fd->input)
gst_object_unref (GST_OBJECT (fd->input));
fd->input = GST_ELEMENT (gst_parse_launch (fd->input_pipe, &error));
if (error)
{
if (error) {
ui_feedback_add (fd->ui, "Error : parsing input pipeline : %s\n",
error->message);
g_error_free (error);
return;
}
if (strlen (fd->output_pipe) == 0)
{
if (strlen (fd->output_pipe) == 0) {
ui_feedback_add (fd->ui, "Error : try setting an output pipe.\n");
return;
}
if (fd->output) gst_object_unref (GST_OBJECT (fd->output));
if (fd->output)
gst_object_unref (GST_OBJECT (fd->output));
fd->output = GST_ELEMENT (gst_parse_launch (fd->output_pipe, &error));
if (error)
{
if (error) {
ui_feedback_add (fd->ui, "Error : parsing output pipeline : %s\n",
error->message);
g_error_free (error);
@ -344,10 +335,10 @@ cb_parse_clicked (GtkButton *button, gpointer *user_data)
}
/* try to create filter */
if (fd->filter) gst_object_unref (GST_OBJECT (fd->filter));
if (fd->filter)
gst_object_unref (GST_OBJECT (fd->filter));
fd->filter = gst_element_factory_make (fd->filter_element, "filter");
if (fd->filter == NULL)
{
if (fd->filter == NULL) {
ui_feedback_add (fd->ui, "Error : could not create element %s\n",
fd->filter_element);
return;
@ -361,22 +352,19 @@ cb_parse_clicked (GtkButton *button, gpointer *user_data)
/* add the players to it */
gst_bin_add_many (GST_BIN (fd->pipeline),
fd->input, fd->filter,
fd->output, NULL);
fd->input, fd->filter, fd->output, NULL);
/* connect filter to input and output bin */
src_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->input), GST_PAD_SRC,
"source");
if (src_pad == NULL)
{
if (src_pad == NULL) {
ui_feedback_add (fd->ui,
"Error : could not find an unconnected source pad !\n");
return;
}
sink_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->output), GST_PAD_SINK,
"sink");
if (sink_pad == NULL)
{
if (sink_pad == NULL) {
ui_feedback_add (fd->ui,
"Error : could not find an unconnected sink pad !\n");
return;
@ -386,7 +374,8 @@ cb_parse_clicked (GtkButton *button, gpointer *user_data)
gst_element_link_many (fd->input, fd->filter, fd->output, NULL);
if (fd->pipe_string) g_free (fd->pipe_string);
if (fd->pipe_string)
g_free (fd->pipe_string);
fd->pipe_string = g_strdup_printf ("%s ! %s ! %s", fd->input_pipe,
fd->filter_element, fd->output_pipe);
g_print ("Pipeline : %s\n", fd->pipe_string);
@ -465,7 +454,7 @@ create_ui (_filter_ui_t *fui, _filter_data_t *fd)
/* feedback widget */
fui->fb_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (fui->feedback));
gtk_text_buffer_set_text (fui->fb_buffer,
"Hello, and welcome to the GStreamer filter demo app !\n"\
"Hello, and welcome to the GStreamer filter demo app !\n"
"I'll be your feedback window for today.\n", -1);
/* selection widget */
@ -527,4 +516,3 @@ main (int argc, char *argv[])
return 0;
}

View file

@ -35,8 +35,8 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
} else {
str = g_strdup_value_contents (
gst_tag_list_get_value_index (list, tag, i));
str =
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
if (i == 0) {
@ -114,8 +114,7 @@ main (int argc, char *argv[])
/* Creating the GstPlay object */
play = gst_play_new (&error);
if (error)
{
if (error) {
g_print ("Error: could not create play object:\n%s\n", error->message);
g_error_free (error);
return 1;
@ -149,8 +148,7 @@ main (int argc, char *argv[])
G_CALLBACK (got_found_tag), NULL);
g_signal_connect (G_OBJECT (play), "error",
G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (G_OBJECT (play), "eos",
G_CALLBACK (got_eos), NULL);
g_signal_connect (G_OBJECT (play), "eos", G_CALLBACK (got_eos), NULL);
/* Change state to PLAYING */
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);

View file

@ -33,14 +33,14 @@ entry_added (GstIndex *index, GstIndexEntry *entry)
break;
case GST_INDEX_ENTRY_FORMAT:
g_print ("%d: registered format %d for %s\n", entry->id,
GST_INDEX_FORMAT_FORMAT (entry),
GST_INDEX_FORMAT_KEY (entry));
GST_INDEX_FORMAT_FORMAT (entry), GST_INDEX_FORMAT_KEY (entry));
break;
case GST_INDEX_ENTRY_ASSOCIATION:
{
gint i;
g_print ("%p, %d: %08x ", entry, entry->id, GST_INDEX_ASSOC_FLAGS (entry));
g_print ("%p, %d: %08x ", entry, entry->id,
GST_INDEX_ASSOC_FLAGS (entry));
for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) {
g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i),
GST_INDEX_ASSOC_VALUE (entry, i));
@ -79,10 +79,7 @@ dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
static void
setup_dynamic_linking (GstElement * pipeline,
GstElement * element,
const gchar *padname,
GstPad *target,
GstElement *bin,
GstIndex *index)
const gchar * padname, GstPad * target, GstElement * bin, GstIndex * index)
{
dyn_link *link;
@ -93,7 +90,8 @@ setup_dynamic_linking (GstElement *pipeline,
link->pipeline = pipeline;
link->index = index;
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), link);
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link),
link);
}
static GstElement *
@ -147,15 +145,13 @@ make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index)
gst_bin_add (GST_BIN (video_bin), video_decoder);
setup_dynamic_linking (pipeline, demux, "video_00",
gst_element_get_pad (video_decoder, "sink"),
video_bin, index);
gst_element_get_pad (video_decoder, "sink"), video_bin, index);
audio_bin = gst_bin_new ("audio_bin");
audio_decoder = gst_element_factory_make ("mad", "audio_decoder");
setup_dynamic_linking (pipeline, demux, "audio_00",
gst_element_get_pad (audio_decoder, "sink"),
audio_bin, index);
gst_element_get_pad (audio_decoder, "sink"), audio_bin, index);
gst_bin_add (GST_BIN (audio_bin), audio_decoder);
@ -228,7 +224,8 @@ main (gint argc, gchar *argv[])
index = gst_index_factory_make ("memindex");
if (index) {
if (verbose)
g_signal_connect (G_OBJECT (index), "entry_added", G_CALLBACK (entry_added), NULL);
g_signal_connect (G_OBJECT (index), "entry_added",
G_CALLBACK (entry_added), NULL);
g_object_set (G_OBJECT (index), "resolver", 1, NULL);
}
@ -301,8 +298,7 @@ main (gint argc, gchar *argv[])
g_print ("seeking %s...\n", argv[2]);
event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND);
res = gst_pad_send_event (pad, event);
if (!res) {
@ -322,4 +318,3 @@ main (gint argc, gchar *argv[])
return 1;
}

View file

@ -24,14 +24,13 @@ get_position_info (GstElement *cdparanoia)
definition = gst_format_get_details (*formats);
format = *formats;
res = gst_pad_query (pad, GST_QUERY_POSITION,
&format, &position);
res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &position);
if (format == GST_FORMAT_TIME) {
position /= GST_SECOND;
g_print ("%s: %lld:%02lld", definition->nick, position/60, position%60);
}
else {
g_print ("%s: %lld:%02lld", definition->nick, position / 60,
position % 60);
} else {
g_print ("%s: %lld", definition->nick, position);
}
@ -70,22 +69,20 @@ get_track_info (GstElement *cdparanoia)
definition = gst_format_get_details (*formats);
format = *formats;
res = gst_pad_query (pad, GST_QUERY_TOTAL,
&format, &total);
res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &total);
if (res) {
if (format == GST_FORMAT_TIME) {
total /= GST_SECOND;
g_print ("%s total: %lld:%02lld\n", definition->nick, total/60, total%60);
}
else
g_print ("%s total: %lld:%02lld\n", definition->nick, total / 60,
total % 60);
} else
g_print ("%s total: %lld\n", definition->nick, total);
if (format == track_format)
total_tracks = total;
else if (format == GST_FORMAT_TIME)
total_time = total;
}
else
} else
g_print ("failed to get %s total\n", definition->nick);
formats++;
@ -102,11 +99,9 @@ get_track_info (GstElement *cdparanoia)
GstFormat format;
format = GST_FORMAT_TIME;
res = gst_pad_convert (pad, track_format, i,
&format, &time);
res = gst_pad_convert (pad, track_format, i, &format, &time);
time /= GST_SECOND;
}
else {
} else {
time = total_time;
res = TRUE;
}
@ -120,11 +115,9 @@ get_track_info (GstElement *cdparanoia)
g_print ("track %d: %lld:%02lld -> %lld:%02lld, length: %lld:%02lld\n",
i - 1,
time_count / 60, time_count % 60,
time / 60, time % 60,
length / 60, length % 60);
time / 60, time % 60, length / 60, length % 60);
}
}
else {
} else {
g_print ("could not get time for track %d\n", i);
}
@ -177,9 +170,7 @@ main (int argc, char **argv)
g_print ("playing from track 3\n");
/* seek to track3 */
event = gst_event_new_seek (track_format |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
3);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 3);
res = gst_pad_send_event (pad, event);
if (!res)
@ -199,8 +190,7 @@ main (int argc, char **argv)
/* seek to some seconds */
event = gst_event_new_segment_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
25 * GST_SECOND, 29 * GST_SECOND);
GST_SEEK_FLAG_FLUSH, 25 * GST_SECOND, 29 * GST_SECOND);
res = gst_pad_send_event (pad, event);
if (!res)
g_warning ("seek failed");

View file

@ -29,8 +29,7 @@ make_cdaudio_pipeline (void)
}
static gchar *
format_value (GtkScale *scale,
gdouble value)
format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
@ -41,9 +40,7 @@ format_value (GtkScale *scale,
subseconds = (gint64) real / (GST_SECOND / 100);
return g_strdup_printf ("%02lld:%02lld:%02lld",
seconds/60,
seconds%60,
subseconds%100);
seconds / 60, seconds % 60, subseconds % 100);
}
typedef struct
@ -52,8 +49,7 @@ typedef struct
const GstFormat format;
} seek_format;
static seek_format seek_formats[] =
{
static seek_format seek_formats[] = {
{"tim", GST_FORMAT_TIME},
{"byt", GST_FORMAT_BYTES},
{"buf", GST_FORMAT_BUFFERS},
@ -81,8 +77,7 @@ query_durations ()
res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
@ -111,8 +106,7 @@ query_positions ()
res = gst_element_query (element, GST_QUERY_POSITION, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
@ -134,6 +128,7 @@ update_scale (gpointer data)
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
}
if (clock)
@ -141,7 +136,8 @@ update_scale (gpointer data)
if (stats) {
if (clock)
g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
g_print ("clock: %13llu (%s)\n", position,
gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
}
@ -188,8 +184,7 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
g_print ("seek to %lld on element %s\n", real, GST_ELEMENT_NAME (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
@ -199,7 +194,8 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
return FALSE;
}
@ -211,7 +207,8 @@ play_cb (GtkButton * button, gpointer data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
@ -237,8 +234,7 @@ int
main (int argc, char **argv)
{
GtkWidget *window, *hbox, *vbox,
*play_button, *pause_button, *stop_button,
*hscale;
*play_button, *pause_button, *stop_button, *hscale;
struct poptOption options[] = {
{"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
"Show element stats", NULL},
@ -250,8 +246,10 @@ main (int argc, char **argv)
pipeline = make_cdaudio_pipeline ();
g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (pipeline, "deep_notify",
G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
NULL);
/* initialize gui elements ... */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@ -261,7 +259,8 @@ main (int argc, char **argv)
pause_button = gtk_button_new_with_label ("pause");
stop_button = gtk_button_new_with_label ("stop");
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
@ -283,9 +282,12 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline);
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
pipeline);
g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL);
/* show the gui. */

View file

@ -36,8 +36,7 @@ gst_element_factory_make_or_warn (gchar *type, gchar *name)
GstElement *element = gst_element_factory_make (type, name);
if (!element) {
g_warning ("Failed to create element %s of type %s",
name, type);
g_warning ("Failed to create element %s of type %s", name, type);
}
return element;
@ -60,7 +59,8 @@ dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
}
static void
setup_dynamic_link (GstElement *element, const gchar *padname, GstPad *target, GstElement *bin)
setup_dynamic_link (GstElement * element, const gchar * padname,
GstPad * target, GstElement * bin)
{
dyn_link *connect;
@ -69,7 +69,8 @@ setup_dynamic_link (GstElement *element, const gchar *padname, GstPad *target, G
connect->target = target;
connect->bin = bin;
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), connect);
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link),
connect);
}
static GstElement *
@ -340,7 +341,8 @@ make_avi_pipeline (const gchar *location)
{
GstElement *pipeline, *audio_bin, *video_bin;
GstElement *src, *demux, *a_decoder, *v_decoder, *audiosink, *videosink;
GstElement *a_queue = NULL, *audio_thread = NULL, *v_queue = NULL, *video_thread = NULL;
GstElement *a_queue = NULL, *audio_thread = NULL, *v_queue =
NULL, *video_thread = NULL;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
@ -369,12 +371,14 @@ make_avi_pipeline (const gchar *location)
gst_bin_add (GST_BIN (audio_thread), audiosink);
gst_element_set_state (audio_bin, GST_STATE_PAUSED);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
"sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
video_bin = gst_bin_new ("v_decoder_bin");
//v_decoder = gst_element_factory_make_or_warn ("identity", "v_dec");
@ -395,12 +399,14 @@ make_avi_pipeline (const gchar *location)
gst_element_set_state (video_bin, GST_STATE_PAUSED);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
"sink"), video_bin);
seekable = gst_element_get_pad (v_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
return pipeline;
}
@ -441,12 +447,14 @@ make_mpeg_pipeline (const gchar *location)
gst_bin_add (GST_BIN (audio_thread), a_queue);
gst_bin_add (GST_BIN (audio_thread), audiosink);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
"sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
video_bin = gst_bin_new ("v_decoder_bin");
v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
@ -461,12 +469,14 @@ make_mpeg_pipeline (const gchar *location)
gst_bin_add_many (GST_BIN (video_bin), v_decoder, video_thread, NULL);
gst_bin_add_many (GST_BIN (video_thread), v_queue, v_filter, videosink, NULL);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
"sink"), video_bin);
seekable = gst_element_get_pad (v_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
return pipeline;
}
@ -508,12 +518,14 @@ make_mpegnt_pipeline (const gchar *location)
gst_bin_add (GST_BIN (audio_thread), a_queue);
gst_bin_add (GST_BIN (audio_thread), audiosink);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
"sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
video_bin = gst_bin_new ("v_decoder_bin");
v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
@ -523,12 +535,14 @@ make_mpegnt_pipeline (const gchar *location)
gst_bin_add_many (GST_BIN (video_bin), v_decoder, v_filter, videosink, NULL);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
"sink"), video_bin);
seekable = gst_element_get_pad (v_decoder, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
return pipeline;
}
@ -540,8 +554,7 @@ make_playerbin_pipeline (const gchar *location)
}
static gchar *
format_value (GtkScale *scale,
gdouble value)
format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
@ -552,9 +565,7 @@ format_value (GtkScale *scale,
subseconds = (gint64) real / (GST_SECOND / 100);
return g_strdup_printf ("%02lld:%02lld:%02lld",
seconds/60,
seconds%60,
subseconds%100);
seconds / 60, seconds % 60, subseconds % 100);
}
typedef struct
@ -563,8 +574,7 @@ typedef struct
const GstFormat format;
} seek_format;
static seek_format seek_formats[] =
{
static seek_format seek_formats[] = {
{"tim", GST_FORMAT_TIME},
{"byt", GST_FORMAT_BYTES},
{"buf", GST_FORMAT_BUFFERS},
@ -588,12 +598,9 @@ query_rates (void)
format = seek_formats[i].format;
if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND,
&format, &value))
{
if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format, &value)) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
@ -624,8 +631,7 @@ query_durations ()
res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
@ -655,8 +661,7 @@ query_positions ()
res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
@ -679,12 +684,14 @@ update_scale (gpointer data)
if (seekable_pads) {
GstPad *pad = GST_PAD (seekable_pads->data);
gst_pad_query (pad, GST_QUERY_TOTAL, &format, &duration);
}
position = gst_clock_get_time (clock);
if (stats) {
g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
g_print ("clock: %13llu (%s)\n", position,
gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
query_rates ();
@ -725,15 +732,17 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
gboolean res;
GstEvent *s_event;
#ifdef PAD_SEEK
GList *walk = seekable_pads;
while (walk) {
GstPad *seekable = GST_PAD (walk->data);
g_print ("seek to %lld on pad %s:%s\n", real, GST_DEBUG_PAD_NAME (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
g_print ("seek to %lld on pad %s:%s\n", real,
GST_DEBUG_PAD_NAME (seekable));
s_event =
gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
res = gst_pad_send_event (seekable, s_event);
@ -746,9 +755,10 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
while (walk) {
GstElement *seekable = GST_ELEMENT (walk->data);
g_print ("seek to %lld on element %s\n", real, gst_element_get_name (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
g_print ("seek to %lld on element %s\n", real,
gst_element_get_name (seekable));
s_event =
gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
@ -759,7 +769,8 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
return FALSE;
}
@ -770,7 +781,8 @@ play_cb (GtkButton * button, gpointer data)
if (gst_element_get_state (pipeline) != GST_STATE_PLAYING) {
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
@ -833,8 +845,7 @@ int
main (int argc, char **argv)
{
GtkWidget *window, *hbox, *vbox,
*play_button, *pause_button, *stop_button,
*hscale;
*play_button, *pause_button, *stop_button, *hscale;
struct poptOption options[] = {
{"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
"Show pad stats", NULL},
@ -868,7 +879,8 @@ main (int argc, char **argv)
pause_button = gtk_button_new_with_label ("pause");
stop_button = gtk_button_new_with_label ("stop");
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
@ -890,16 +902,21 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline);
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
pipeline);
g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL);
/* show the gui. */
gtk_widget_show_all (window);
g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (pipeline, "deep_notify",
G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
NULL);
gtk_main ();

View file

@ -23,12 +23,12 @@ static GstElement*
make_spider_pipeline (const gchar * location, gboolean thread)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink, *videosink, *a_thread, *v_thread, *a_queue, *v_queue;
GstElement *src, *decoder, *audiosink, *videosink, *a_thread, *v_thread,
*a_queue, *v_queue;
if (thread) {
pipeline = gst_thread_new ("app");
}
else {
} else {
pipeline = gst_pipeline_new ("app");
}
@ -64,15 +64,16 @@ make_spider_pipeline (const gchar *location, gboolean thread)
seekable_elements = g_list_prepend (seekable_elements, videosink);
seekable_elements = g_list_prepend (seekable_elements, audiosink);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (audiosink, "sink"));
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (videosink, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (audiosink, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (videosink, "sink"));
return pipeline;
}
static gchar *
format_value (GtkScale *scale,
gdouble value)
format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
@ -83,9 +84,7 @@ format_value (GtkScale *scale,
subseconds = (gint64) real / (GST_SECOND / 100);
return g_strdup_printf ("%02lld:%02lld:%02lld",
seconds/60,
seconds%60,
subseconds%100);
seconds / 60, seconds % 60, subseconds % 100);
}
typedef struct
@ -94,8 +93,7 @@ typedef struct
const GstFormat format;
} seek_format;
static seek_format seek_formats[] =
{
static seek_format seek_formats[] = {
{"tim", GST_FORMAT_TIME},
{"byt", GST_FORMAT_BYTES},
{"buf", GST_FORMAT_BUFFERS},
@ -119,12 +117,9 @@ query_rates (void)
format = seek_formats[i].format;
if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND,
&format, &value))
{
if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format, &value)) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
@ -155,8 +150,7 @@ query_durations ()
res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
@ -185,8 +179,7 @@ query_positions ()
res = gst_element_query (element, GST_QUERY_POSITION, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
@ -208,12 +201,14 @@ update_scale (gpointer data)
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
}
position = gst_clock_get_time (clock);
if (stats) {
g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
g_print ("clock: %13llu (%s)\n", position,
gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
query_rates ();
@ -260,8 +255,7 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
g_print ("seek to %lld on element %s\n", real, GST_ELEMENT_NAME (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
@ -271,7 +265,8 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
return FALSE;
}
@ -283,7 +278,8 @@ play_cb (GtkButton * button, gpointer data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
@ -309,8 +305,7 @@ int
main (int argc, char **argv)
{
GtkWidget *window, *hbox, *vbox,
*play_button, *pause_button, *stop_button,
*hscale;
*play_button, *pause_button, *stop_button, *hscale;
gboolean threaded = FALSE;
struct poptOption options[] = {
{"threaded", 't', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &threaded, 0,
@ -338,7 +333,8 @@ main (int argc, char **argv)
pause_button = gtk_button_new_with_label ("pause");
stop_button = gtk_button_new_with_label ("stop");
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
@ -360,9 +356,12 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline);
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
pipeline);
g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL);
/* show the gui. */

View file

@ -4,7 +4,8 @@
static gboolean ready = FALSE;
struct probe_context {
struct probe_context
{
GstElement *pipeline;
GstElement *element;
GstPad *pad;
@ -21,6 +22,7 @@ static void
print_caps (GstCaps * caps)
{
char *s;
s = gst_caps_to_string (caps);
g_print (" %s\n", s);
g_free (s);
@ -30,6 +32,7 @@ static void
print_format (GstCaps * caps)
{
char *s;
s = gst_caps_to_string (caps);
g_print (" format: %s\n", s);
g_free (s);
@ -62,11 +65,9 @@ print_lbs_info (struct probe_context *context, gint stream)
/* get start and end position of this stream */
res = gst_pad_convert (context->pad,
context->ls_format, stream,
&format, &value_start);
context->ls_format, stream, &format, &value_start);
res &= gst_pad_convert (context->pad,
context->ls_format, stream + 1,
&format, &value_end);
context->ls_format, stream + 1, &format, &value_end);
if (res) {
/* substract to get the length */
@ -76,12 +77,10 @@ print_lbs_info (struct probe_context *context, gint stream)
value_end /= (GST_SECOND / 100);
g_print (" %s: %lld:%02lld.%02lld\n", definition->nick,
value_end / 6000, (value_end / 100) % 60, (value_end % 100));
}
else {
} else {
g_print (" %s: %lld\n", definition->nick, value_end);
}
}
else
} else
g_print (" could not get logical stream %s\n", definition->nick);
}
@ -99,8 +98,7 @@ deep_notify (GObject *object, GstObject *origin,
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
context->metadata = g_value_peek_pointer (&value);
}
else if (!strcmp (pspec->name, "streaminfo")) {
} else if (!strcmp (pspec->name, "streaminfo")) {
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
@ -127,9 +125,7 @@ collect_logical_stream_properties (struct probe_context *context, gint stream)
/* seek to stream */
event = gst_event_new_seek (context->ls_format |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
stream);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, stream);
res = gst_pad_send_event (context->pad, event);
if (!res) {
g_warning ("seek to logical track failed");
@ -141,7 +137,8 @@ collect_logical_stream_properties (struct probe_context *context, gint stream)
ready = FALSE;
while (gst_bin_iterate (GST_BIN (context->pipeline)) && !ready) {
count++;
if (count > 10) break;
if (count > 10)
break;
}
print_caps (context->metadata);
@ -177,8 +174,7 @@ collect_stream_properties (struct probe_context *context)
format = *formats;
formats++;
res = gst_pad_query (context->pad, GST_QUERY_TOTAL,
&format, &value);
res = gst_pad_query (context->pad, GST_QUERY_TOTAL, &format, &value);
definition = gst_format_get_details (format);
@ -187,8 +183,7 @@ collect_stream_properties (struct probe_context *context)
value /= (GST_SECOND / 100);
g_print (" total %s: %lld:%02lld.%02lld\n", definition->nick,
value / 6000, (value / 100) % 60, (value % 100));
}
else {
} else {
if (format == context->ls_format)
context->total_ls = value;
g_print (" total %s: %lld\n", definition->nick, value);

View file

@ -46,7 +46,8 @@ main (gint argc, gchar *argv[])
pipeline = GST_ELEMENT (gst_parse_launch (description, &error));
if (!pipeline) {
if (error)
g_print ("ERROR: pipeline could not be constructed: %s\n", error->message);
g_print ("ERROR: pipeline could not be constructed: %s\n",
error->message);
else
g_print ("ERROR: pipeline could not be constructed\n");
return -1;
@ -71,12 +72,10 @@ main (gint argc, gchar *argv[])
format = GST_FORMAT_TIME;
/* get the position */
gst_pad_query (enc_src, GST_QUERY_POSITION,
&format, &position);
gst_pad_query (enc_src, GST_QUERY_POSITION, &format, &position);
/* get the total duration */
gst_pad_query (enc_src, GST_QUERY_TOTAL,
&format, &duration);
gst_pad_query (enc_src, GST_QUERY_TOTAL, &format, &duration);
format = GST_FORMAT_BYTES;
/* see how many bytes are genereated per 8 seconds (== bitrate) */
@ -92,9 +91,7 @@ main (gint argc, gchar *argv[])
(gint) (position / (GST_SECOND)) % 60,
(gint) (duration / (GST_SECOND * 60)),
(gint) (duration / (GST_SECOND)) % 60,
bitrate_dec,
bitrate_enc,
(gfloat)bitrate_dec/bitrate_enc);
bitrate_dec, bitrate_enc, (gfloat) bitrate_dec / bitrate_enc);
}
g_print ("\n");

View file

@ -46,16 +46,14 @@ switch_timer (GstElement *video_switch)
gint nb_sources, active_source;
g_object_get (G_OBJECT (video_switch), "nb_sources", &nb_sources, NULL);
g_object_get (G_OBJECT (video_switch), "active_source",
&active_source, NULL);
g_object_get (G_OBJECT (video_switch), "active_source", &active_source, NULL);
active_source++;
if (active_source > nb_sources - 1)
active_source = 0;
g_object_set (G_OBJECT (video_switch), "active_source",
active_source, NULL);
g_object_set (G_OBJECT (video_switch), "active_source", active_source, NULL);
g_message ("current number of sources : %d, active source %d",
nb_sources, active_source);
@ -88,8 +86,7 @@ main (int argc, char *argv[])
gst_element_link (src2, video_switch);
gst_element_link (video_switch, video_sink);
g_signal_connect (G_OBJECT (pipeline), "eos",
G_CALLBACK (got_eos), NULL);
g_signal_connect (G_OBJECT (pipeline), "eos", G_CALLBACK (got_eos), NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);

View file

@ -32,30 +32,24 @@
#include "gstalsamixer.h"
/* GObject functions */
static void gst_alsa_class_init (gpointer g_class,
gpointer class_data);
static void gst_alsa_class_init (gpointer g_class, gpointer class_data);
static void gst_alsa_init (GstAlsa * this);
static void gst_alsa_dispose (GObject * object);
static void gst_alsa_set_property (GObject * object,
guint prop_id,
const GValue * value,
GParamSpec * pspec);
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_alsa_get_property (GObject * object,
guint prop_id,
GValue * value,
GParamSpec * pspec);
guint prop_id, GValue * value, GParamSpec * pspec);
/* interface */
static void gst_alsa_probe_interface_init (GstPropertyProbeInterface * iface);
/* GStreamer functions for pads and state changing */
static GstPad *gst_alsa_request_new_pad (GstElement * element,
GstPadTemplate * templ,
const gchar * name);
GstPadTemplate * templ, const gchar * name);
static GstElementStateReturn gst_alsa_change_state (GstElement * element);
static GstClock *gst_alsa_get_clock (GstElement * element);
static void gst_alsa_set_clock (GstElement * element,
GstClock * clock);
static void gst_alsa_set_clock (GstElement * element, GstClock * clock);
/* ALSA setup / start / stop functions */
static gboolean gst_alsa_probe_hw_params (GstAlsa * this,
GstAlsaFormat * format);
@ -72,27 +66,17 @@ static gboolean gst_alsa_close_audio (GstAlsa * this);
static const GstFormat *gst_alsa_get_formats (GstPad * pad);
static gboolean gst_alsa_convert (GstAlsa * this,
GstFormat src_format,
gint64 src_value,
GstFormat * dest_format,
gint64 * dest_value);
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
static gboolean gst_alsa_pad_convert (GstPad * pad,
GstFormat src_format,
gint64 src_value,
GstFormat * dest_format,
gint64 * dest_value);
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
static const GstQueryType *gst_alsa_get_query_types (GstPad * pad);
static gboolean gst_alsa_query_func (GstElement * element,
GstQueryType type,
GstFormat * format,
gint64 * value);
GstQueryType type, GstFormat * format, gint64 * value);
static gboolean gst_alsa_query (GstElement * element,
GstQueryType type,
GstFormat * format,
gint64 * value);
GstQueryType type, GstFormat * format, gint64 * value);
static gboolean gst_alsa_pad_query (GstPad * pad,
GstQueryType type,
GstFormat * format,
gint64 * value);
GstQueryType type, GstFormat * format, gint64 * value);
/*** TYPE FUNCTIONS ***********************************************************/
@ -119,11 +103,11 @@ gst_alsa_get_type (void)
NULL
};
alsa_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAlsa", &alsa_info, 0);
alsa_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstAlsa", &alsa_info, 0);
g_type_add_interface_static (alsa_type,
GST_TYPE_PROPERTY_PROBE,
&alsa_probe_info);
GST_TYPE_PROPERTY_PROBE, &alsa_probe_info);
}
return alsa_type;
@ -170,8 +154,7 @@ gst_alsa_class_init (gpointer g_class, gpointer class_data)
"default", G_PARAM_READWRITE));
g_object_class_install_property (object_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 (object_class, ARG_PERIODCOUNT,
g_param_spec_int ("period-count", "Period count",
"Number of hardware buffers to use",
@ -195,7 +178,8 @@ gst_alsa_class_init (gpointer g_class, gpointer class_data)
g_object_class_install_property (object_class, ARG_MAXDISCONT,
g_param_spec_uint64 ("max-discont", "Maximum Discontinuity",
"GStreamer timeunits before the timestamp syncing starts dropping/inserting samples",
/* rounding errors */ 1000, GST_SECOND, GST_ALSA_DEFAULT_DISCONT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
/* rounding errors */ 1000, GST_SECOND, GST_ALSA_DEFAULT_DISCONT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
element_class->change_state = GST_DEBUG_FUNCPTR (gst_alsa_change_state);
element_class->query = GST_DEBUG_FUNCPTR (gst_alsa_query);
@ -227,7 +211,8 @@ gst_alsa_dispose (GObject *object)
}
static void
gst_alsa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
gst_alsa_set_property (GObject * object, guint prop_id, const GValue * value,
GParamSpec * pspec)
{
GstAlsa *this;
gint buffer_size;
@ -276,7 +261,8 @@ gst_alsa_set_property (GObject *object, guint prop_id, const GValue *value, GPar
}
static void
gst_alsa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
gst_alsa_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstAlsa *this;
@ -324,14 +310,14 @@ gst_alsa_probe_get_properties (GstPropertyProbe *probe)
static GList *list = NULL;
if (!list) {
list = g_list_append (NULL, g_object_class_find_property (klass, "device")); }
list = g_list_append (NULL, g_object_class_find_property (klass, "device"));
}
return list;
}
static gboolean
gst_alsa_class_probe_devices (GstAlsaClass *klass,
gboolean check)
gst_alsa_class_probe_devices (GstAlsaClass * klass, gboolean check)
{
static gboolean init = FALSE;
@ -389,8 +375,7 @@ gst_alsa_class_list_devices (GstAlsaClass *klass)
static void
gst_alsa_probe_probe_property (GstPropertyProbe * probe,
guint prop_id,
const GParamSpec *pspec)
guint prop_id, const GParamSpec * pspec)
{
GstAlsaClass *klass = GST_ALSA_GET_CLASS (probe);
@ -406,8 +391,7 @@ gst_alsa_probe_probe_property (GstPropertyProbe *probe,
static gboolean
gst_alsa_probe_needs_probe (GstPropertyProbe * probe,
guint prop_id,
const GParamSpec *pspec)
guint prop_id, const GParamSpec * pspec)
{
GstAlsaClass *klass = GST_ALSA_GET_CLASS (probe);
gboolean ret = FALSE;
@ -426,8 +410,7 @@ gst_alsa_probe_needs_probe (GstPropertyProbe *probe,
static GValueArray *
gst_alsa_probe_get_values (GstPropertyProbe * probe,
guint prop_id,
const GParamSpec *pspec)
guint prop_id, const GParamSpec * pspec)
{
GstAlsaClass *klass = GST_ALSA_GET_CLASS (probe);
GValueArray *array = NULL;
@ -456,7 +439,8 @@ gst_alsa_probe_interface_init (GstPropertyProbeInterface *iface)
/*** GSTREAMER PAD / QUERY / CONVERSION / STATE FUNCTIONS *********************/
static GstPad *
gst_alsa_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name)
gst_alsa_request_new_pad (GstElement * element, GstPadTemplate * templ,
const gchar * name)
{
GstAlsa *this;
gint track = 0;
@ -483,7 +467,8 @@ gst_alsa_request_new_pad (GstElement *element, GstPadTemplate *templ, const gcha
/* if the user doesn't care, use the lowest available track number */
if (track == 0) {
for (track = 1; track < GST_ALSA_MAX_TRACKS; track++) {
if (this->pad[track] != NULL) goto found_track;
if (this->pad[track] != NULL)
goto found_track;
}
return NULL;
}
@ -536,7 +521,9 @@ gst_alsa_get_format (const GstStructure *structure)
endianness = G_BYTE_ORDER;
}
ret->format = snd_pcm_build_linear_format (depth, width, sign ? 0 : 1, endianness == G_LITTLE_ENDIAN ? 0 : 1);
ret->format =
snd_pcm_build_linear_format (depth, width, sign ? 0 : 1,
endianness == G_LITTLE_ENDIAN ? 0 : 1);
} else if (!strncmp (mimetype, "audio/x-raw-float", 17)) {
gint width;
@ -586,11 +573,12 @@ error:
static inline gboolean
gst_alsa_formats_match (GstAlsaFormat * one, GstAlsaFormat * two)
{
if (one == two) return TRUE;
if (one == NULL || two == NULL) return FALSE;
if (one == two)
return TRUE;
if (one == NULL || two == NULL)
return FALSE;
return (one->format == two->format) &&
(one->rate == two->rate) &&
(one->channels == two->channels);
(one->rate == two->rate) && (one->channels == two->channels);
}
/* get props for a spec */
@ -606,20 +594,26 @@ gst_alsa_get_caps_internal (snd_pcm_format_t format)
GstStructure *structure = gst_structure_new ("audio/x-raw-int",
"width", G_TYPE_INT, (gint) snd_pcm_format_physical_width (format),
"depth", G_TYPE_INT, (gint) snd_pcm_format_width (format),
"signed", G_TYPE_BOOLEAN, snd_pcm_format_signed (format) == 1 ? TRUE : FALSE,
"signed", G_TYPE_BOOLEAN,
snd_pcm_format_signed (format) == 1 ? TRUE : FALSE,
NULL);
/* endianness */
if (snd_pcm_format_physical_width (format) > 8) {
switch (snd_pcm_format_little_endian (format)) {
case 0:
gst_structure_set (structure, "endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL);
gst_structure_set (structure, "endianness", G_TYPE_INT, G_BIG_ENDIAN,
NULL);
break;
case 1:
gst_structure_set (structure, "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, NULL);
gst_structure_set (structure, "endianness", G_TYPE_INT,
G_LITTLE_ENDIAN, NULL);
break;
default:
GST_WARNING ("Unknown byte order in sound driver. Continuing by assuming system byte order.");
gst_structure_set (structure, "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
GST_WARNING
("Unknown byte order in sound driver. Continuing by assuming system byte order.");
gst_structure_set (structure, "endianness", G_TYPE_INT, G_BYTE_ORDER,
NULL);
break;
}
}
@ -631,8 +625,7 @@ gst_alsa_get_caps_internal (snd_pcm_format_t format)
return gst_caps_new_simple ("audio/x-raw-float",
"width", G_TYPE_INT, (gint) snd_pcm_format_width (format),
"endianness", G_TYPE_INT, G_BYTE_ORDER,
NULL);
"endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
}
return NULL;
}
@ -735,7 +728,8 @@ gst_alsa_get_caps (GstPad *pad)
ERROR_CHECK (snd_pcm_hw_params_get_channels_max (hw_params, &max_rate),
"Couldn't get maximum channel count for device %s: %s", this->device);
min_channels = min_rate;
max_channels = max_rate > GST_ALSA_MAX_CHANNELS ? GST_ALSA_MAX_CHANNELS : max_rate;
max_channels =
max_rate > GST_ALSA_MAX_CHANNELS ? GST_ALSA_MAX_CHANNELS : max_rate;
}
ERROR_CHECK (snd_pcm_hw_params_get_rate_min (hw_params, &min_rate, &i),
@ -750,10 +744,12 @@ gst_alsa_get_caps (GstPad *pad)
for (i = 0; i <= SND_PCM_FORMAT_LAST; i++) {
if (snd_pcm_format_mask_test (mask, i)) {
GstCaps *caps = gst_alsa_get_caps_internal (i);
/* we can never use a format we can't set caps for */
if (caps != NULL) {
g_assert (gst_caps_get_size (caps) == 1);
add_channels (gst_caps_get_structure (caps, 0), min_rate, max_rate, min_channels, max_channels);
add_channels (gst_caps_get_structure (caps, 0), min_rate, max_rate,
min_channels, max_channels);
if (ret) {
gst_caps_append (ret, caps);
} else {
@ -768,6 +764,7 @@ gst_alsa_get_caps (GstPad *pad)
return gst_caps_new_empty ();
} else {
G_GNUC_UNUSED gchar *str = gst_caps_to_string (ret);
GST_LOG_OBJECT (this, "get_caps returns %s", str);
g_free (str);
return ret;
@ -780,7 +777,9 @@ gst_alsa_fixate (GstPad *pad, const GstCaps *caps)
GstCaps *newcaps;
GstStructure *structure;
newcaps = gst_caps_new_full (gst_structure_copy(gst_caps_get_structure (caps, 0)), NULL);
newcaps =
gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps, 0)),
NULL);
structure = gst_caps_get_structure (newcaps, 0);
if (gst_caps_structure_fixate_field_nearest_int (structure, "rate", 44100)) {
@ -845,9 +844,13 @@ gst_alsa_link (GstPad *pad, const GstCaps *caps)
continue;
if (gst_pad_try_set_caps (this->pad[i], caps) == GST_PAD_LINK_REFUSED) {
if (this->format) {
GstCaps *old = gst_alsa_caps (this->format->format, this->format->rate, this->format->channels);
GstCaps *old =
gst_alsa_caps (this->format->format, this->format->rate,
this->format->channels);
for (--i; i >= 0; i--) {
if (gst_pad_try_set_caps (this->pad[i], old) == GST_PAD_LINK_REFUSED) {
if (gst_pad_try_set_caps (this->pad[i],
old) == GST_PAD_LINK_REFUSED) {
GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
("could not reset caps to a sane value"));
gst_caps_free (old);
@ -866,7 +869,8 @@ gst_alsa_link (GstPad *pad, const GstCaps *caps)
GST_FLAG_UNSET (this, GST_ALSA_CAPS_NEGO);
/* sync the params */
if (GST_FLAG_IS_SET (this, GST_ALSA_RUNNING)) gst_alsa_stop_audio (this);
if (GST_FLAG_IS_SET (this, GST_ALSA_RUNNING))
gst_alsa_stop_audio (this);
g_free (this->format);
this->format = format;
if (!gst_alsa_start_audio (this)) {
@ -897,17 +901,20 @@ gst_alsa_change_state (GstElement *element)
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!(GST_FLAG_IS_SET (element, GST_ALSA_OPEN) ||
gst_alsa_open_audio (this))) return GST_STATE_FAILURE;
gst_alsa_open_audio (this)))
return GST_STATE_FAILURE;
break;
case GST_STATE_READY_TO_PAUSED:
if (!(GST_FLAG_IS_SET (element, GST_ALSA_RUNNING) ||
gst_alsa_start_audio (this))) return GST_STATE_FAILURE;
gst_alsa_start_audio (this)))
return GST_STATE_FAILURE;
this->transmitted = 0;
break;
case GST_STATE_PAUSED_TO_PLAYING:
if (snd_pcm_state (this->handle) == SND_PCM_STATE_PAUSED) {
if ((err = snd_pcm_pause (this->handle, 0)) < 0) {
GST_ERROR_OBJECT (this, "Error unpausing sound: %s", snd_strerror (err));
GST_ERROR_OBJECT (this, "Error unpausing sound: %s",
snd_strerror (err));
return GST_STATE_FAILURE;
}
} else if (!(GST_FLAG_IS_SET (element, GST_ALSA_RUNNING) ||
@ -920,23 +927,27 @@ gst_alsa_change_state (GstElement *element)
if (GST_ALSA_CAPS_IS_SET (this, GST_ALSA_CAPS_PAUSE)) {
if (snd_pcm_state (this->handle) == SND_PCM_STATE_RUNNING) {
if ((err = snd_pcm_pause (this->handle, 1)) < 0) {
GST_ERROR_OBJECT (this, "Error pausing sound: %s", snd_strerror (err));
GST_ERROR_OBJECT (this, "Error pausing sound: %s",
snd_strerror (err));
return GST_STATE_FAILURE;
}
}
} else {
/* if device doesn't know how to pause, we just stop */
if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING)) gst_alsa_stop_audio (this);
if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING))
gst_alsa_stop_audio (this);
}
gst_alsa_clock_stop (this->clock);
break;
case GST_STATE_PAUSED_TO_READY:
if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING)) gst_alsa_stop_audio (this);
if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING))
gst_alsa_stop_audio (this);
g_free (this->format);
this->format = NULL;
break;
case GST_STATE_READY_TO_NULL:
if (GST_FLAG_IS_SET (element, GST_ALSA_OPEN)) gst_alsa_close_audio (this);
if (GST_FLAG_IS_SET (element, GST_ALSA_OPEN))
gst_alsa_close_audio (this);
break;
default:
@ -951,11 +962,14 @@ gst_alsa_change_state (GstElement *element)
static GstClock *
gst_alsa_get_clock (GstElement * element)
{ return GST_CLOCK (GST_ALSA (element)->clock); }
{
return GST_CLOCK (GST_ALSA (element)->clock);
}
static void
gst_alsa_set_clock (GstElement * element, GstClock * clock)
{ /* we need this function just so everybody knows we use a clock */ }
{ /* we need this function just so everybody knows we use a clock */
}
/*** AUDIO PROCESSING *********************************************************/
@ -963,11 +977,13 @@ inline snd_pcm_sframes_t
gst_alsa_update_avail (GstAlsa * this)
{
snd_pcm_sframes_t avail = snd_pcm_avail_update (this->handle);
if (avail < 0) {
if (avail == -EPIPE) {
gst_alsa_xrun_recovery (this);
} else {
GST_WARNING_OBJECT (this, "unknown ALSA avail_update return value (%d)", (int) avail);
GST_WARNING_OBJECT (this, "unknown ALSA avail_update return value (%d)",
(int) avail);
}
}
return avail;
@ -991,7 +1007,8 @@ gst_alsa_pcm_wait (GstAlsa *this)
}
}
if (!gst_alsa_xrun_recovery (this)) {
GST_ERROR_OBJECT (this, "error waiting for alsa pcm: (%d: %s)", err, snd_strerror (err));
GST_ERROR_OBJECT (this, "error waiting for alsa pcm: (%d: %s)", err,
snd_strerror (err));
return FALSE;
}
}
@ -1053,7 +1070,8 @@ gst_alsa_xrun_recovery (GstAlsa *this)
gettimeofday (&now, 0);
snd_pcm_status_get_trigger_tstamp (status, &tstamp);
timersub (&now, &tstamp, &diff);
GST_INFO_OBJECT (this, "alsa: xrun of at least %.3f msecs", diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
GST_INFO_OBJECT (this, "alsa: xrun of at least %.3f msecs",
diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
/* if we're allowed to recover, ... */
if (this->autorecover) {
@ -1086,6 +1104,7 @@ gst_alsa_set_eos (GstAlsa *this)
gst_alsa_drain_audio (this);
gst_element_set_eos (GST_ELEMENT (this));
}
static gboolean
gst_alsa_open_audio (GstAlsa * this)
{
@ -1103,8 +1122,8 @@ gst_alsa_open_audio (GstAlsa *this)
if (snd_pcm_open (&this->handle, this->device,
GST_ALSA_GET_CLASS (this)->stream, SND_PCM_NONBLOCK) < 0) {
GST_ELEMENT_ERROR (GST_ELEMENT (this), RESOURCE, BUSY,
(_("Alsa device \"%s\" is already in use by another program."), this->device),
(NULL));
(_("Alsa device \"%s\" is already in use by another program."),
this->device), (NULL));
return FALSE;
}
@ -1114,6 +1133,7 @@ gst_alsa_open_audio (GstAlsa *this)
GST_FLAG_SET (this, GST_ALSA_OPEN);
return TRUE;
}
/* if someone finds an easy way to merge this with _set_hw_params, go ahead */
static gboolean
gst_alsa_probe_hw_params (GstAlsa * this, GstAlsaFormat * format)
@ -1131,7 +1151,8 @@ gst_alsa_probe_hw_params (GstAlsa *this, GstAlsaFormat *format)
snd_pcm_hw_params_alloca (&hw_params);
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_any (this->handle, hw_params));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_periods_integer (this->handle, hw_params));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_periods_integer (this->handle,
hw_params));
/* enable this for soundcard specific debugging */
/* snd_pcm_hw_params_dump (hw_params, this->out); */
@ -1139,23 +1160,35 @@ gst_alsa_probe_hw_params (GstAlsa *this, GstAlsaFormat *format)
mask = alloca (snd_pcm_access_mask_sizeof ());
snd_pcm_access_mask_none (mask);
if (GST_ELEMENT (this)->numpads == 1) {
snd_pcm_access_mask_set (mask, this->mmap ? SND_PCM_ACCESS_MMAP_INTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_access_mask_set (mask,
this->
mmap ? SND_PCM_ACCESS_MMAP_INTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED);
} else {
snd_pcm_access_mask_set (mask, this->mmap ? SND_PCM_ACCESS_MMAP_NONINTERLEAVED : SND_PCM_ACCESS_RW_NONINTERLEAVED);
snd_pcm_access_mask_set (mask,
this->
mmap ? SND_PCM_ACCESS_MMAP_NONINTERLEAVED :
SND_PCM_ACCESS_RW_NONINTERLEAVED);
}
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_access_mask (this->handle, hw_params, mask));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_access_mask (this->handle,
hw_params, mask));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_format (this->handle, hw_params, format->format));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_channels (this->handle, hw_params, format->channels));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_rate (this->handle, hw_params, format->rate, 0));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_format (this->handle, hw_params,
format->format));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_channels (this->handle, hw_params,
format->channels));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_rate (this->handle, hw_params,
format->rate, 0));
period_count = this->period_count;
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_periods_near (this->handle, hw_params, &period_count, 0));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_periods_near (this->handle,
hw_params, &period_count, 0));
period_size = this->period_size;
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_period_size_near (this->handle, hw_params, &period_size, 0));
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_period_size_near (this->handle,
hw_params, &period_size, 0));
return TRUE;
}
/**
* You must set all hw parameters at once and can't use already set params and
* change them.
@ -1172,7 +1205,8 @@ gst_alsa_set_hw_params (GstAlsa *this)
if (this->format) {
GST_INFO ("Preparing format: %s %dHz, %d channels",
snd_pcm_format_name (this->format->format), this->format->rate, this->format->channels);
snd_pcm_format_name (this->format->format), this->format->rate,
this->format->channels);
} else {
GST_INFO ("Preparing format: (none)");
}
@ -1189,34 +1223,48 @@ gst_alsa_set_hw_params (GstAlsa *this)
mask = alloca (snd_pcm_access_mask_sizeof ());
snd_pcm_access_mask_none (mask);
if (GST_ELEMENT (this)->numpads == 1) {
snd_pcm_access_mask_set (mask, this->mmap ? SND_PCM_ACCESS_MMAP_INTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_access_mask_set (mask,
this->
mmap ? SND_PCM_ACCESS_MMAP_INTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED);
} else {
snd_pcm_access_mask_set (mask, this->mmap ? SND_PCM_ACCESS_MMAP_NONINTERLEAVED : SND_PCM_ACCESS_RW_NONINTERLEAVED);
snd_pcm_access_mask_set (mask,
this->
mmap ? SND_PCM_ACCESS_MMAP_NONINTERLEAVED :
SND_PCM_ACCESS_RW_NONINTERLEAVED);
}
ERROR_CHECK (snd_pcm_hw_params_set_access_mask (this->handle, hw_params, mask),
ERROR_CHECK (snd_pcm_hw_params_set_access_mask (this->handle, hw_params,
mask),
"The Gstreamer ALSA plugin does not support your hardware. Error: %s");
if (this->format) {
ERROR_CHECK (snd_pcm_hw_params_set_format (this->handle, hw_params, this->format->format),
"Sample format (%s) not available: %s", snd_pcm_format_name (this->format->format));
ERROR_CHECK (snd_pcm_hw_params_set_channels (this->handle, hw_params, this->format->channels),
"Channels count (%d) not available: %s", this->format->channels);
ERROR_CHECK (snd_pcm_hw_params_set_rate (this->handle, hw_params, this->format->rate, 0),
"error setting rate (%d): %s", this->format->rate);
ERROR_CHECK (snd_pcm_hw_params_set_format (this->handle, hw_params,
this->format->format), "Sample format (%s) not available: %s",
snd_pcm_format_name (this->format->format));
ERROR_CHECK (snd_pcm_hw_params_set_channels (this->handle, hw_params,
this->format->channels), "Channels count (%d) not available: %s",
this->format->channels);
ERROR_CHECK (snd_pcm_hw_params_set_rate (this->handle, hw_params,
this->format->rate, 0), "error setting rate (%d): %s",
this->format->rate);
}
ERROR_CHECK (snd_pcm_hw_params_set_periods_near (this->handle, hw_params, &this->period_count, 0),
"error setting buffer size to %u: %s", (guint) this->period_count);
ERROR_CHECK (snd_pcm_hw_params_set_period_size_near (this->handle, hw_params, &this->period_size, 0),
"error setting period size to %u frames: %s", (guint) this->period_size);
ERROR_CHECK (snd_pcm_hw_params_set_periods_near (this->handle, hw_params,
&this->period_count, 0), "error setting buffer size to %u: %s",
(guint) this->period_count);
ERROR_CHECK (snd_pcm_hw_params_set_period_size_near (this->handle, hw_params,
&this->period_size, 0), "error setting period size to %u frames: %s",
(guint) this->period_size);
ERROR_CHECK (snd_pcm_hw_params (this->handle, hw_params),
"Could not set hardware parameters: %s");
/* now get the pcm caps */
GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_PAUSE, snd_pcm_hw_params_can_pause (hw_params));
GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_RESUME, snd_pcm_hw_params_can_resume (hw_params));
GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_SYNC_START, snd_pcm_hw_params_can_sync_start (hw_params));
GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_PAUSE,
snd_pcm_hw_params_can_pause (hw_params));
GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_RESUME,
snd_pcm_hw_params_can_resume (hw_params));
GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_SYNC_START,
snd_pcm_hw_params_can_sync_start (hw_params));
if (this->mmap) {
this->transmit = GST_ALSA_GET_CLASS (this)->transmit_mmap;
@ -1226,6 +1274,7 @@ gst_alsa_set_hw_params (GstAlsa *this)
return TRUE;
}
static gboolean
gst_alsa_set_sw_params (GstAlsa * this)
{
@ -1237,14 +1286,16 @@ gst_alsa_set_sw_params (GstAlsa *this)
ERROR_CHECK (snd_pcm_sw_params_set_silence_size (this->handle, sw_params, 0),
"could not set silence size: %s");
ERROR_CHECK (snd_pcm_sw_params_set_silence_threshold (this->handle, sw_params, 0),
"could not set silence threshold: %s");
ERROR_CHECK (snd_pcm_sw_params_set_avail_min (this->handle, sw_params, this->period_size),
"could not set avail min: %s");
ERROR_CHECK (snd_pcm_sw_params_set_silence_threshold (this->handle, sw_params,
0), "could not set silence threshold: %s");
ERROR_CHECK (snd_pcm_sw_params_set_avail_min (this->handle, sw_params,
this->period_size), "could not set avail min: %s");
/* we start explicitly */
ERROR_CHECK (snd_pcm_sw_params_set_start_threshold (this->handle, sw_params, this->period_size * this->period_count + 1),
ERROR_CHECK (snd_pcm_sw_params_set_start_threshold (this->handle, sw_params,
this->period_size * this->period_count + 1),
"could not set start mode: %s");
ERROR_CHECK (snd_pcm_sw_params_set_stop_threshold (this->handle, sw_params, this->period_size * this->period_count),
ERROR_CHECK (snd_pcm_sw_params_set_stop_threshold (this->handle, sw_params,
this->period_size * this->period_count),
"could not set stop mode: %s");
ERROR_CHECK (snd_pcm_sw_params_set_xfer_align (this->handle, sw_params, 1),
"Unable to set transfer align for playback: %s");
@ -1267,6 +1318,7 @@ gst_alsa_start_audio (GstAlsa *this)
GST_FLAG_SET (this, GST_ALSA_RUNNING);
return TRUE;
}
static gboolean
gst_alsa_drain_audio (GstAlsa * this)
{
@ -1281,9 +1333,12 @@ gst_alsa_drain_audio (GstAlsa *this)
/* fall through - clock is already stopped when paused */
case SND_PCM_STATE_PAUSED:
/* snd_pcm_drain only works in blocking mode */
ERROR_CHECK (snd_pcm_nonblock(this->handle, 0), "couldn't set blocking mode: %s");
ERROR_CHECK (snd_pcm_drain (this->handle), "couldn't stop and drain buffer: %s");
ERROR_CHECK (snd_pcm_nonblock(this->handle, 1), "couldn't set non-blocking mode: %s");
ERROR_CHECK (snd_pcm_nonblock (this->handle, 0),
"couldn't set blocking mode: %s");
ERROR_CHECK (snd_pcm_drain (this->handle),
"couldn't stop and drain buffer: %s");
ERROR_CHECK (snd_pcm_nonblock (this->handle, 1),
"couldn't set non-blocking mode: %s");
break;
default:
break;
@ -1351,7 +1406,8 @@ static gboolean
gst_alsa_pad_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
GstFormat * dest_format, gint64 * dest_value)
{
return gst_alsa_convert (GST_ALSA (GST_PAD_PARENT (pad)), src_format, src_value, dest_format, dest_value);
return gst_alsa_convert (GST_ALSA (GST_PAD_PARENT (pad)), src_format,
src_value, dest_format, dest_value);
}
static gboolean
@ -1384,10 +1440,12 @@ gst_alsa_convert (GstAlsa *this, GstFormat src_format, gint64 src_value,
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_value = gst_alsa_timestamp_to_samples (this, (GstClockTime) src_value);
*dest_value =
gst_alsa_timestamp_to_samples (this, (GstClockTime) src_value);
break;
case GST_FORMAT_BYTES:
*dest_value = gst_alsa_timestamp_to_bytes (this, (GstClockTime) src_value);
*dest_value =
gst_alsa_timestamp_to_bytes (this, (GstClockTime) src_value);
break;
default:
res = FALSE;
@ -1429,7 +1487,8 @@ gst_alsa_get_query_types (GstPad *pad)
}
static gboolean
gst_alsa_query_func (GstElement *element, GstQueryType type, GstFormat *format, gint64 *value)
gst_alsa_query_func (GstElement * element, GstQueryType type,
GstFormat * format, gint64 * value)
{
gboolean res = FALSE;
GstAlsa *this = GST_ALSA (element);
@ -1437,12 +1496,18 @@ gst_alsa_query_func (GstElement *element, GstQueryType type, GstFormat *format,
switch (type) {
case GST_QUERY_LATENCY:{
snd_pcm_sframes_t delay;
ERROR_CHECK (snd_pcm_delay (this->handle, &delay), "Error getting delay: %s");
res = gst_alsa_convert (this, GST_FORMAT_DEFAULT, (gint64) delay, format, value);
ERROR_CHECK (snd_pcm_delay (this->handle, &delay),
"Error getting delay: %s");
res =
gst_alsa_convert (this, GST_FORMAT_DEFAULT, (gint64) delay, format,
value);
break;
}
case GST_QUERY_POSITION:
res = gst_alsa_convert (this, GST_FORMAT_TIME, gst_element_get_time (GST_ELEMENT (this)), format, value);
res =
gst_alsa_convert (this, GST_FORMAT_TIME,
gst_element_get_time (GST_ELEMENT (this)), format, value);
break;
default:
break;
@ -1452,18 +1517,21 @@ gst_alsa_query_func (GstElement *element, GstQueryType type, GstFormat *format,
}
static gboolean
gst_alsa_query (GstElement *element, GstQueryType type, GstFormat *format, gint64 *value)
gst_alsa_query (GstElement * element, GstQueryType type, GstFormat * format,
gint64 * value)
{
return gst_alsa_pad_query (GST_ALSA (element)->pad[0], type, format, value);
}
static gboolean
gst_alsa_pad_query (GstPad *pad, GstQueryType type, GstFormat *format, gint64 *value)
gst_alsa_pad_query (GstPad * pad, GstQueryType type, GstFormat * format,
gint64 * value)
{
if (gst_alsa_query_func (GST_PAD_PARENT (pad), type, format, value))
return TRUE;
if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK && gst_pad_query (gst_pad_get_peer (pad), type, format, value))
if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK
&& gst_pad_query (gst_pad_get_peer (pad), type, format, value))
return TRUE;
return FALSE;
@ -1472,7 +1540,8 @@ gst_alsa_pad_query (GstPad *pad, GstQueryType type, GstFormat *format, gint64 *v
inline snd_pcm_uframes_t
gst_alsa_timestamp_to_samples (GstAlsa * this, GstClockTime time)
{
return (snd_pcm_uframes_t) ((time * this->format->rate + this->format->rate / 2) / GST_SECOND);
return (snd_pcm_uframes_t) ((time * this->format->rate +
this->format->rate / 2) / GST_SECOND);
}
inline GstClockTime
@ -1484,23 +1553,27 @@ gst_alsa_samples_to_timestamp (GstAlsa *this, snd_pcm_uframes_t samples)
inline snd_pcm_uframes_t
gst_alsa_bytes_to_samples (GstAlsa * this, guint bytes)
{
return bytes / (snd_pcm_format_physical_width (this->format->format) / 8) / (GST_ELEMENT (this)->numpads == 1 ? this->format->channels : 1);
return bytes / (snd_pcm_format_physical_width (this->format->format) / 8) /
(GST_ELEMENT (this)->numpads == 1 ? this->format->channels : 1);
}
inline guint
gst_alsa_samples_to_bytes (GstAlsa * this, snd_pcm_uframes_t samples)
{
return samples * snd_pcm_format_physical_width (this->format->format) / 8 * (GST_ELEMENT (this)->numpads == 1 ? this->format->channels : 1);
return samples * snd_pcm_format_physical_width (this->format->format) / 8 *
(GST_ELEMENT (this)->numpads == 1 ? this->format->channels : 1);
}
inline GstClockTime
gst_alsa_bytes_to_timestamp (GstAlsa * this, guint bytes)
{
return gst_alsa_samples_to_timestamp (this, gst_alsa_bytes_to_samples (this, bytes));
return gst_alsa_samples_to_timestamp (this, gst_alsa_bytes_to_samples (this,
bytes));
}
inline guint
gst_alsa_timestamp_to_bytes (GstAlsa * this, GstClockTime time)
{
return gst_alsa_samples_to_bytes (this, gst_alsa_timestamp_to_samples (this, time));
return gst_alsa_samples_to_bytes (this, gst_alsa_timestamp_to_samples (this,
time));
}

View file

@ -84,22 +84,22 @@ GST_DEBUG_CATEGORY_EXTERN (alsa_debug);
#define GST_ALSA_DEFAULT_DISCONT (GST_SECOND / 10)
G_BEGIN_DECLS
#define GST_ALSA(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA, GstAlsa))
#define GST_ALSA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA, GstAlsaClass))
#define GST_ALSA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ALSA, GstAlsaClass))
#define GST_IS_ALSA(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_ALSA))
#define GST_IS_ALSA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_ALSA))
#define GST_TYPE_ALSA (gst_alsa_get_type())
enum {
enum
{
GST_ALSA_OPEN = GST_ELEMENT_FLAG_LAST,
GST_ALSA_RUNNING,
GST_ALSA_CAPS_NEGO,
GST_ALSA_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 3,
};
typedef enum {
typedef enum
{
GST_ALSA_CAPS_PAUSE = 0,
GST_ALSA_CAPS_RESUME,
GST_ALSA_CAPS_SYNC_START
@ -118,15 +118,18 @@ typedef struct _GstAlsaClockClass GstAlsaClockClass;
typedef struct _GstAlsa GstAlsa;
typedef struct _GstAlsaClass GstAlsaClass;
typedef int (*GstAlsaTransmitFunction) (GstAlsa *this, snd_pcm_sframes_t *avail);
typedef int (*GstAlsaTransmitFunction) (GstAlsa * this,
snd_pcm_sframes_t * avail);
typedef struct {
typedef struct
{
snd_pcm_format_t format;
guint rate;
gint channels;
} GstAlsaFormat;
struct _GstAlsa {
struct _GstAlsa
{
GstElement parent;
/* array of GstAlsaPads */
@ -160,7 +163,8 @@ struct _GstAlsa {
*/
};
struct _GstAlsaClass {
struct _GstAlsaClass
{
GstElementClass parent_class;
snd_pcm_stream_t stream;
@ -176,14 +180,10 @@ struct _GstAlsaClass {
GType gst_alsa_get_type (void);
void gst_alsa_set_eos (GstAlsa * this);
GstPadLinkReturn gst_alsa_link (GstPad * pad,
const GstCaps * caps);
GstPadLinkReturn gst_alsa_link (GstPad * pad, const GstCaps * caps);
GstCaps *gst_alsa_get_caps (GstPad * pad);
GstCaps * gst_alsa_fixate (GstPad * pad,
const GstCaps * caps);
GstCaps * gst_alsa_caps (snd_pcm_format_t format,
gint rate,
gint channels);
GstCaps *gst_alsa_fixate (GstPad * pad, const GstCaps * caps);
GstCaps *gst_alsa_caps (snd_pcm_format_t format, gint rate, gint channels);
/* audio processing functions */
inline snd_pcm_sframes_t gst_alsa_update_avail (GstAlsa * this);
@ -200,11 +200,8 @@ inline snd_pcm_uframes_t gst_alsa_bytes_to_samples (GstAlsa * this,
guint bytes);
inline guint gst_alsa_samples_to_bytes (GstAlsa * this,
snd_pcm_uframes_t samples);
inline GstClockTime gst_alsa_bytes_to_timestamp (GstAlsa * this,
guint bytes);
inline guint gst_alsa_timestamp_to_bytes (GstAlsa * this,
GstClockTime time);
inline GstClockTime gst_alsa_bytes_to_timestamp (GstAlsa * this, guint bytes);
inline guint gst_alsa_timestamp_to_bytes (GstAlsa * this, GstClockTime time);
G_END_DECLS
#endif /* __GST_ALSA_H__ */

View file

@ -26,18 +26,17 @@
#include "gstalsaclock.h"
/* clock functions */
static void gst_alsa_clock_class_init (gpointer g_class,
gpointer class_data);
static void gst_alsa_clock_class_init (gpointer g_class, gpointer class_data);
static void gst_alsa_clock_init (GstAlsaClock * clock);
static GstClockTime gst_alsa_clock_get_internal_time (GstClock * clock);
static guint64 gst_alsa_clock_get_resolution (GstClock * clock);
static GstClockEntryStatus gst_alsa_clock_wait (GstClock * clock,
GstClockEntry * entry);
static void gst_alsa_clock_unlock (GstClock * clock,
GstClockEntry * entry);
static void gst_alsa_clock_unlock (GstClock * clock, GstClockEntry * entry);
static GstClockClass *clock_parent_class = NULL;
/* static guint gst_alsa_clock_signals[LAST_SIGNAL] = { 0 }; */
GType
@ -90,10 +89,13 @@ gst_alsa_clock_init (GstAlsaClock *clock)
clock->start_time = GST_CLOCK_TIME_NONE;
}
GstAlsaClock *
gst_alsa_clock_new (gchar *name, GstAlsaClockGetTimeFunc get_time, GstAlsa *owner)
gst_alsa_clock_new (gchar * name, GstAlsaClockGetTimeFunc get_time,
GstAlsa * owner)
{
GstAlsaClock *alsa_clock = GST_ALSA_CLOCK (g_object_new (GST_TYPE_ALSA_CLOCK, NULL));
GstAlsaClock *alsa_clock =
GST_ALSA_CLOCK (g_object_new (GST_TYPE_ALSA_CLOCK, NULL));
g_assert (alsa_clock);
@ -106,6 +108,7 @@ gst_alsa_clock_new (gchar *name, GstAlsaClockGetTimeFunc get_time, GstAlsa *owne
return alsa_clock;
}
void
gst_alsa_clock_start (GstAlsaClock * clock)
{
@ -122,13 +125,17 @@ void
gst_alsa_clock_stop (GstAlsaClock * clock)
{
GTimeVal timeval;
g_get_current_time (&timeval);
g_assert (GST_CLOCK_TIME_IS_VALID (clock->start_time));
clock->adjust += GST_TIMEVAL_TO_TIME (timeval) - gst_clock_get_event_time (GST_CLOCK (clock));
clock->adjust +=
GST_TIMEVAL_TO_TIME (timeval) -
gst_clock_get_event_time (GST_CLOCK (clock));
clock->start_time = GST_CLOCK_TIME_NONE;
}
static GstClockTime
gst_alsa_clock_get_internal_time (GstClock * clock)
{
@ -138,6 +145,7 @@ gst_alsa_clock_get_internal_time (GstClock *clock)
return alsa_clock->get_time (alsa_clock->owner) + alsa_clock->start_time;
} else {
GTimeVal timeval;
g_get_current_time (&timeval);
return GST_TIMEVAL_TO_TIME (timeval) + alsa_clock->adjust;
}
@ -168,7 +176,8 @@ gst_alsa_clock_wait (GstClock *clock, GstClockEntry *entry)
return GST_CLOCK_ENTRY_EARLY;
if (diff > clock->max_diff) {
GST_INFO_OBJECT (this, "GstAlsaClock: abnormal clock request diff: %" G_GINT64_FORMAT") >"
GST_INFO_OBJECT (this,
"GstAlsaClock: abnormal clock request diff: %" G_GINT64_FORMAT ") >"
" %" G_GINT64_FORMAT, diff, clock->max_diff);
return GST_CLOCK_ENTRY_EARLY;
}
@ -182,7 +191,8 @@ gst_alsa_clock_wait (GstClock *clock, GstClockEntry *entry)
while (gst_alsa_clock_get_internal_time (clock) < target &&
this->last_unlock < entry_time) {
g_usleep (gst_alsa_clock_get_resolution (clock) * G_USEC_PER_SEC / GST_SECOND);
g_usleep (gst_alsa_clock_get_resolution (clock) * G_USEC_PER_SEC /
GST_SECOND);
}
return entry->status;
@ -194,4 +204,3 @@ gst_alsa_clock_unlock (GstClock *clock, GstClockEntry *entry)
this->last_unlock = this->get_time (this->owner);
}

View file

@ -25,16 +25,15 @@
#include "gstalsa.h"
G_BEGIN_DECLS
#define GST_ALSA_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_CLOCK,GstAlsaClock))
#define GST_ALSA_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_CLOCK,GstAlsaClockClass))
#define GST_IS_ALSA_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_CLOCK))
#define GST_IS_ALSA_CLOCK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_CLOCK))
#define GST_TYPE_ALSA_CLOCK (gst_alsa_clock_get_type())
typedef GstClockTime (*GstAlsaClockGetTimeFunc) (GstAlsa *);
struct _GstAlsaClock {
struct _GstAlsaClock
{
GstSystemClock parent;
GstAlsaClockGetTimeFunc get_time;
@ -45,18 +44,17 @@ struct _GstAlsaClock {
GstClockTime last_unlock; /* time of last unlock request */
};
struct _GstAlsaClockClass {
struct _GstAlsaClockClass
{
GstSystemClockClass parent_class;
};
GType gst_alsa_clock_get_type (void);
GstAlsaClock *gst_alsa_clock_new (gchar * name,
GstAlsaClockGetTimeFunc func,
GstAlsa * owner);
GstAlsaClockGetTimeFunc func, GstAlsa * owner);
void gst_alsa_clock_start (GstAlsaClock * clock);
void gst_alsa_clock_stop (GstAlsaClock * clock);
G_END_DECLS
#endif /* __GST_ALSA_CLOCK_H__ */

View file

@ -24,17 +24,15 @@
#include "gstalsamixer.h"
/* elementfactory information */
static GstElementDetails gst_alsa_mixer_details = GST_ELEMENT_DETAILS (
"Alsa Mixer",
static GstElementDetails gst_alsa_mixer_details =
GST_ELEMENT_DETAILS ("Alsa Mixer",
"Generic/Audio",
"Control sound input and output levels with ALSA",
"Leif Johnson <leif@ambient.2y.net>"
);
"Leif Johnson <leif@ambient.2y.net>");
static void gst_alsa_interface_init (GstImplementsInterfaceClass * klass);
static void gst_alsa_mixer_class_init (gpointer g_class,
gpointer class_data);
static void gst_alsa_mixer_class_init (gpointer g_class, gpointer class_data);
static void gst_alsa_mixer_init (GstAlsaMixer * mixer);
static void gst_alsa_mixer_dispose (GObject * object);
static void gst_alsa_mixer_interface_init (GstMixerClass * klass);
@ -51,18 +49,14 @@ static void gst_alsa_mixer_free_list (GstAlsaMixer * mixer);
static const GList *gst_alsa_mixer_list_tracks (GstMixer * mixer);
static void gst_alsa_mixer_set_volume (GstMixer * mixer,
GstMixerTrack* track,
gint * volumes);
GstMixerTrack * track, gint * volumes);
static void gst_alsa_mixer_get_volume (GstMixer * mixer,
GstMixerTrack* track,
gint * volumes);
GstMixerTrack * track, gint * volumes);
static void gst_alsa_mixer_set_record (GstMixer * mixer,
GstMixerTrack* track,
gboolean record);
GstMixerTrack * track, gboolean record);
static void gst_alsa_mixer_set_mute (GstMixer * mixer,
GstMixerTrack* track,
gboolean mute);
GstMixerTrack * track, gboolean mute);
/*** GOBJECT STUFF ************************************************************/
@ -96,10 +90,14 @@ gst_alsa_mixer_get_type (void)
NULL,
};
alsa_mixer_type = g_type_register_static (GST_TYPE_ALSA, "GstAlsaMixer", &alsa_mixer_info, 0);
alsa_mixer_type =
g_type_register_static (GST_TYPE_ALSA, "GstAlsaMixer", &alsa_mixer_info,
0);
g_type_add_interface_static (alsa_mixer_type, GST_TYPE_IMPLEMENTS_INTERFACE, &alsa_iface_info);
g_type_add_interface_static (alsa_mixer_type, GST_TYPE_MIXER, &alsa_mixer_iface_info);
g_type_add_interface_static (alsa_mixer_type, GST_TYPE_IMPLEMENTS_INTERFACE,
&alsa_iface_info);
g_type_add_interface_static (alsa_mixer_type, GST_TYPE_MIXER,
&alsa_mixer_iface_info);
}
return alsa_mixer_type;
@ -144,8 +142,7 @@ gst_alsa_mixer_init (GstAlsaMixer * mixer)
if ((err = snd_mixer_attach (mixer->mixer_handle, alsa->device)) < 0) {
GST_ERROR_OBJECT (GST_OBJECT (mixer),
"Cannot attach mixer to sound device `%s'.",
alsa->device);
"Cannot attach mixer to sound device `%s'.", alsa->device);
goto error;
}
@ -171,7 +168,8 @@ gst_alsa_mixer_dispose (GObject * object)
{
GstAlsaMixer *mixer = GST_ALSA_MIXER (object);
if (((gint) mixer->mixer_handle) == -1) return;
if (((gint) mixer->mixer_handle) == -1)
return;
snd_mixer_close (mixer->mixer_handle);
mixer->mixer_handle = (snd_mixer_t *) - 1;
@ -223,7 +221,8 @@ gst_alsa_mixer_build_list (GstAlsaMixer *mixer)
for (i = 0; i < count; i++) {
gint channels = 0;
if (! snd_mixer_selem_is_active(element)) continue;
if (!snd_mixer_selem_is_active (element))
continue;
/* find out if this element can be an input */
@ -279,9 +278,11 @@ gst_alsa_mixer_change_state (GstElement *element)
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
gst_alsa_mixer_build_list (this); break;
gst_alsa_mixer_build_list (this);
break;
case GST_STATE_READY_TO_NULL:
gst_alsa_mixer_free_list (this); break;
gst_alsa_mixer_free_list (this);
break;
default:
g_assert_not_reached ();
}
@ -306,8 +307,7 @@ gst_alsa_mixer_list_tracks (GstMixer *mixer)
static void
gst_alsa_mixer_get_volume (GstMixer * mixer,
GstMixerTrack *track,
gint *volumes)
GstMixerTrack * track, gint * volumes)
{
gint i;
GstAlsaMixer *alsa_mixer = GST_ALSA_MIXER (mixer);
@ -321,6 +321,7 @@ gst_alsa_mixer_get_volume (GstMixer *mixer,
} else {
for (i = 0; i < track->num_channels; i++) {
long tmp;
if (snd_mixer_selem_has_playback_channel (alsa_track->element, i)) {
snd_mixer_selem_get_playback_volume (alsa_track->element, i, &tmp);
volumes[i] = (gint) tmp;
@ -334,8 +335,7 @@ gst_alsa_mixer_get_volume (GstMixer *mixer,
static void
gst_alsa_mixer_set_volume (GstMixer * mixer,
GstMixerTrack *track,
gint *volumes)
GstMixerTrack * track, gint * volumes)
{
gint i;
GstAlsaMixer *alsa_mixer = GST_ALSA_MIXER (mixer);
@ -347,9 +347,11 @@ gst_alsa_mixer_set_volume (GstMixer *mixer,
if (!(track->flags & GST_MIXER_TRACK_MUTE)) {
for (i = 0; i < track->num_channels; i++) {
if (snd_mixer_selem_has_playback_channel (alsa_track->element, i))
snd_mixer_selem_set_playback_volume(alsa_track->element, i, (long) volumes[i]);
snd_mixer_selem_set_playback_volume (alsa_track->element, i,
(long) volumes[i]);
else if (snd_mixer_selem_has_capture_channel (alsa_track->element, i))
snd_mixer_selem_set_capture_volume(alsa_track->element, i, (long) volumes[i]);
snd_mixer_selem_set_capture_volume (alsa_track->element, i,
(long) volumes[i]);
}
}
@ -358,9 +360,7 @@ gst_alsa_mixer_set_volume (GstMixer *mixer,
}
static void
gst_alsa_mixer_set_mute (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute)
gst_alsa_mixer_set_mute (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
gint i;
GstAlsaMixer *alsa_mixer = GST_ALSA_MIXER (mixer);
@ -393,8 +393,7 @@ gst_alsa_mixer_set_mute (GstMixer *mixer,
static void
gst_alsa_mixer_set_record (GstMixer * mixer,
GstMixerTrack *track,
gboolean record)
GstMixerTrack * track, gboolean record)
{
GstAlsaMixer *alsa_mixer = GST_ALSA_MIXER (mixer);

View file

@ -24,28 +24,27 @@
#include <gst/mixer/mixer.h>
G_BEGIN_DECLS
#define GST_ALSA_MIXER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_MIXER,GstAlsaMixer))
#define GST_ALSA_MIXER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_MIXER,GstAlsaMixerClass))
#define GST_IS_ALSA_MIXER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_MIXER))
#define GST_IS_ALSA_MIXER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_MIXER))
#define GST_TYPE_ALSA_MIXER (gst_alsa_mixer_get_type())
typedef struct _GstAlsaMixer GstAlsaMixer;
typedef struct _GstAlsaMixerClass GstAlsaMixerClass;
struct _GstAlsaMixer {
struct _GstAlsaMixer
{
GstAlsa parent;
GList *tracklist; /* list of available tracks */
snd_mixer_t *mixer_handle;
};
struct _GstAlsaMixerClass {
struct _GstAlsaMixerClass
{
GstAlsaClass parent;
};
GType gst_alsa_mixer_get_type (void);
G_END_DECLS
#endif /* __GST_ALSA_MIXER_H__ */

View file

@ -47,7 +47,9 @@ gst_alsa_mixer_track_get_type (void)
(GInstanceInitFunc) gst_alsa_mixer_track_init,
};
track_type = g_type_register_static (GST_TYPE_MIXER_TRACK, "GstAlsaMixerTrack", &track_info, 0);
track_type =
g_type_register_static (GST_TYPE_MIXER_TRACK, "GstAlsaMixerTrack",
&track_info, 0);
}
return track_type;
@ -62,13 +64,12 @@ gst_alsa_mixer_track_class_init (gpointer g_class, gpointer class_data)
static void
gst_alsa_mixer_track_init (GstAlsaMixerTrack * alsa_track)
{ }
{
}
GstMixerTrack *
gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
gint track_num,
gint channels,
gint flags)
gint track_num, gint channels, gint flags)
{
gint i;
long min, max;
@ -94,6 +95,7 @@ gst_alsa_mixer_track_new (snd_mixer_elem_t *element,
for (i = 0; i < channels; i++) {
long tmp;
if (snd_mixer_selem_has_playback_channel (element, i)) {
snd_mixer_selem_get_playback_volume (element, i, &tmp);
alsa_track->volumes[i] = (gint) tmp;

View file

@ -23,18 +23,17 @@
#include <gst/mixer/mixertrack.h>
G_BEGIN_DECLS
#define GST_ALSA_MIXER_TRACK_TYPE (gst_alsa_mixer_track_get_type ())
#define GST_ALSA_MIXER_TRACK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_MIXER_TRACK,GstAlsaMixerTrack))
#define GST_ALSA_MIXER_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_MIXER_TRACK,GstAlsaMixerTrackClass))
#define GST_IS_ALSA_MIXER_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_MIXER_TRACK))
#define GST_IS_ALSA_MIXER_TRACK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_MIXER_TRACK))
#define GST_TYPE_ALSA_MIXER_TRACK (gst_alsa_mixer_track_get_type())
typedef struct _GstAlsaMixerTrack GstAlsaMixerTrack;
typedef struct _GstAlsaMixerTrackClass GstAlsaMixerTrackClass;
struct _GstAlsaMixerTrack {
struct _GstAlsaMixerTrack
{
GstMixerTrack parent;
snd_mixer_elem_t *element; /* the ALSA mixer element for this track */
gint track_num;
@ -42,16 +41,14 @@ struct _GstAlsaMixerTrack {
gint volumes[GST_ALSA_MAX_CHANNELS];
};
struct _GstAlsaMixerTrackClass {
struct _GstAlsaMixerTrackClass
{
GstMixerTrackClass parent;
};
GType gst_alsa_mixer_track_get_type (void);
GstMixerTrack *gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
gint track_num,
gint channels,
gint flags);
gint track_num, gint channels, gint flags);
G_END_DECLS
#endif /* __GST_ALSA_MIXER_TRACK_H__ */

View file

@ -34,24 +34,21 @@ plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (alsa_debug, "alsa", 0, "alsa plugins");
if (!gst_element_register (plugin, "alsamixer", GST_RANK_NONE, GST_TYPE_ALSA_MIXER))
if (!gst_element_register (plugin, "alsamixer", GST_RANK_NONE,
GST_TYPE_ALSA_MIXER))
return FALSE;
if (!gst_element_register (plugin, "alsasrc", GST_RANK_NONE, GST_TYPE_ALSA_SRC))
if (!gst_element_register (plugin, "alsasrc", GST_RANK_NONE,
GST_TYPE_ALSA_SRC))
return FALSE;
if (!gst_element_register (plugin, "alsasink", GST_RANK_NONE, GST_TYPE_ALSA_SINK))
if (!gst_element_register (plugin, "alsasink", GST_RANK_NONE,
GST_TYPE_ALSA_SINK))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"alsa",
"ALSA plugin library",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN
)
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)

View file

@ -27,31 +27,25 @@
#include "gstalsaclock.h"
/* elementfactory information */
static GstElementDetails gst_alsa_sink_details = GST_ELEMENT_DETAILS (
"Alsa Sink",
static GstElementDetails gst_alsa_sink_details =
GST_ELEMENT_DETAILS ("Alsa Sink",
"Sink/Audio",
"Output to a sound card via ALSA",
"Thomas Nyberg <thomas@codefactory.se>, "
"Andy Wingo <apwingo@eos.ncsu.edu>, "
"Benjamin Otte <in7y118@public.uni-hamburg.de>"
);
"Benjamin Otte <in7y118@public.uni-hamburg.de>");
static GstPadTemplate *gst_alsa_sink_pad_factory (void);
static GstPadTemplate *gst_alsa_sink_request_pad_factory (void);
static void gst_alsa_sink_base_init (gpointer g_class);
static void gst_alsa_sink_class_init (gpointer g_klass,
gpointer class_data);
static void gst_alsa_sink_class_init (gpointer g_klass, gpointer class_data);
static void gst_alsa_sink_init (GstAlsaSink * this);
static inline void gst_alsa_sink_flush_one_pad (GstAlsaSink * sink,
gint i);
static inline void gst_alsa_sink_flush_one_pad (GstAlsaSink * sink, gint i);
static void gst_alsa_sink_flush_pads (GstAlsaSink * sink);
static int gst_alsa_sink_mmap (GstAlsa * this,
snd_pcm_sframes_t * avail);
static int gst_alsa_sink_write (GstAlsa * this,
snd_pcm_sframes_t * avail);
static int gst_alsa_sink_mmap (GstAlsa * this, snd_pcm_sframes_t * avail);
static int gst_alsa_sink_write (GstAlsa * this, snd_pcm_sframes_t * avail);
static void gst_alsa_sink_loop (GstElement * element);
static gboolean gst_alsa_sink_check_event (GstAlsaSink * sink,
gint pad_nr);
static gboolean gst_alsa_sink_check_event (GstAlsaSink * sink, gint pad_nr);
static GstElementStateReturn gst_alsa_sink_change_state (GstElement * element);
static GstClockTime gst_alsa_sink_get_time (GstAlsa * this);
@ -81,6 +75,7 @@ gst_alsa_sink_request_pad_factory (void)
return template;
}
GType
gst_alsa_sink_get_type (void)
{
@ -99,7 +94,9 @@ gst_alsa_sink_get_type (void)
(GInstanceInitFunc) gst_alsa_sink_init,
};
alsa_sink_type = g_type_register_static (GST_TYPE_ALSA, "GstAlsaSink", &alsa_sink_info, 0);
alsa_sink_type =
g_type_register_static (GST_TYPE_ALSA, "GstAlsaSink", &alsa_sink_info,
0);
}
return alsa_sink_type;
}
@ -109,8 +106,10 @@ gst_alsa_sink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, gst_alsa_sink_pad_factory ());
gst_element_class_add_pad_template (element_class, gst_alsa_sink_request_pad_factory ());
gst_element_class_add_pad_template (element_class,
gst_alsa_sink_pad_factory ());
gst_element_class_add_pad_template (element_class,
gst_alsa_sink_request_pad_factory ());
gst_element_class_set_details (element_class, &gst_alsa_sink_details);
}
@ -142,13 +141,15 @@ gst_alsa_sink_init (GstAlsaSink *sink)
{
GstAlsa *this = GST_ALSA (sink);
this->pad[0] = gst_pad_new_from_template (gst_alsa_sink_pad_factory (), "sink");
this->pad[0] =
gst_pad_new_from_template (gst_alsa_sink_pad_factory (), "sink");
gst_pad_set_link_function (this->pad[0], gst_alsa_link);
gst_pad_set_getcaps_function (this->pad[0], gst_alsa_get_caps);
gst_pad_set_fixate_function (this->pad[0], gst_alsa_fixate);
gst_element_add_pad (GST_ELEMENT (this), this->pad[0]);
this->clock = gst_alsa_clock_new ("alsasinkclock", gst_alsa_sink_get_time, this);
this->clock =
gst_alsa_clock_new ("alsasinkclock", gst_alsa_sink_get_time, this);
/* we hold a ref to our clock until we're disposed */
gst_object_ref (GST_OBJECT (this->clock));
gst_object_sink (GST_OBJECT (this->clock));
@ -189,6 +190,7 @@ gst_alsa_sink_flush_pads (GstAlsaSink *sink)
gst_alsa_sink_flush_one_pad (sink, i);
}
}
/* TRUE, if everything should continue */
static gboolean
gst_alsa_sink_check_event (GstAlsaSink * sink, gint pad_nr)
@ -216,21 +218,25 @@ gst_alsa_sink_check_event (GstAlsaSink *sink, gint pad_nr)
}
if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &value)) {
gst_element_set_time (GST_ELEMENT (this), value);
} else if (gst_event_discont_get_value (event, GST_FORMAT_DEFAULT, &value)) {
} else if (gst_event_discont_get_value (event, GST_FORMAT_DEFAULT,
&value)) {
value = gst_alsa_samples_to_timestamp (this, value);
gst_element_set_time (GST_ELEMENT (this), value);
} else if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &value)) {
} else if (gst_event_discont_get_value (event, GST_FORMAT_BYTES,
&value)) {
value = gst_alsa_bytes_to_timestamp (this, value);
gst_element_set_time (GST_ELEMENT (this), value);
} else {
GST_ERROR_OBJECT (this, "couldn't extract time from discont event. Bad things might happen!");
GST_ERROR_OBJECT (this,
"couldn't extract time from discont event. Bad things might happen!");
}
break;
}
default:
GST_INFO_OBJECT (this, "got an unknown event (Type: %d)", GST_EVENT_TYPE (event));
GST_INFO_OBJECT (this, "got an unknown event (Type: %d)",
GST_EVENT_TYPE (event));
break;
}
gst_event_unref (event);
@ -274,7 +280,9 @@ gst_alsa_sink_mmap (GstAlsa *this, snd_pcm_sframes_t *avail)
return -1;
}
if ((err = snd_pcm_areas_copy (dst, offset, src, 0, this->format->channels, *avail, this->format->format)) < 0) {
if ((err =
snd_pcm_areas_copy (dst, offset, src, 0, this->format->channels,
*avail, this->format->format)) < 0) {
snd_pcm_mmap_commit (this->handle, offset, 0);
GST_ERROR_OBJECT (this, "data copy failed: %s", snd_strerror (err));
return -1;
@ -328,8 +336,10 @@ gst_alsa_sink_loop (GstElement *element)
sink_restart:
avail = gst_alsa_update_avail (this);
if (avail == -EPIPE) goto sink_restart;
if (avail < 0) return;
if (avail == -EPIPE)
goto sink_restart;
if (avail < 0)
return;
if (avail > 0) {
/* Not enough space. We grab data nonetheless and sleep afterwards */
@ -355,9 +365,13 @@ sink_restart:
GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
("ALSA format not negotiated"));
}
samplestamp = gst_alsa_timestamp_to_samples (this, GST_BUFFER_TIMESTAMP (sink->buf[i]));
samplestamp =
gst_alsa_timestamp_to_samples (this,
GST_BUFFER_TIMESTAMP (sink->buf[i]));
max_discont = gst_alsa_timestamp_to_samples (this, this->max_discont);
time_sample = gst_alsa_timestamp_to_samples (this, gst_element_get_time (GST_ELEMENT (this)));
time_sample =
gst_alsa_timestamp_to_samples (this,
gst_element_get_time (GST_ELEMENT (this)));
snd_pcm_delay (this->handle, &sample_diff);
/* actual diff = buffer samplestamp - played - to_play */
sample_diff = samplestamp - time_sample - sample_diff;
@ -374,29 +388,40 @@ no_difference:
/* there are empty samples in front of us, fill them with silence */
int samples = MIN (bytes, sample_diff) *
(element->numpads == 1 ? this->format->channels : 1);
int size = samples * snd_pcm_format_physical_width (this->format->format) / 8;
GST_INFO_OBJECT (this, "Allocating %d bytes (%ld samples) now to resync: sample %ld expected, but got %ld",
int size =
samples * snd_pcm_format_physical_width (this->format->format) /
8;
GST_INFO_OBJECT (this,
"Allocating %d bytes (%ld samples) now to resync: sample %ld expected, but got %ld",
size, MIN (bytes, sample_diff), time_sample, samplestamp);
sink->data[i] = g_try_malloc (size);
if (!sink->data[i]) {
GST_WARNING_OBJECT (this, "error allocating %d bytes, buffers unsynced now.", size);
GST_WARNING_OBJECT (this,
"error allocating %d bytes, buffers unsynced now.", size);
goto no_difference;
}
sink->size[i] = size;
if (0 != snd_pcm_format_set_silence (this->format->format, sink->data[i], samples)) {
GST_WARNING_OBJECT (this, "error silencing buffer, enjoy the noise.");
if (0 != snd_pcm_format_set_silence (this->format->format,
sink->data[i], samples)) {
GST_WARNING_OBJECT (this,
"error silencing buffer, enjoy the noise.");
}
sink->behaviour[i] = 1;
} else if (gst_alsa_samples_to_bytes (this, -sample_diff) >= sink->buf[i]->size) {
GST_INFO_OBJECT (this, "Skipping %lu samples to resync (complete buffer): sample %ld expected, but got %ld",
gst_alsa_bytes_to_samples (this, sink->buf[i]->size), time_sample, samplestamp);
} else if (gst_alsa_samples_to_bytes (this,
-sample_diff) >= sink->buf[i]->size) {
GST_INFO_OBJECT (this,
"Skipping %lu samples to resync (complete buffer): sample %ld expected, but got %ld",
gst_alsa_bytes_to_samples (this, sink->buf[i]->size), time_sample,
samplestamp);
/* this buffer is way behind */
gst_buffer_unref (sink->buf[i]);
sink->buf[i] = NULL;
continue;
} else if (sample_diff < 0) {
gint difference = gst_alsa_samples_to_bytes (this, -samplestamp);
GST_INFO_OBJECT (this, "Skipping %lu samples to resync: sample %ld expected, but got %ld",
GST_INFO_OBJECT (this,
"Skipping %lu samples to resync: sample %ld expected, but got %ld",
(gulong) - sample_diff, time_sample, samplestamp);
/* this buffer is only a bit behind */
sink->size[i] = sink->buf[i]->size - difference;
@ -412,11 +437,16 @@ no_difference:
avail = MIN (avail, gst_alsa_bytes_to_samples (this, bytes));
/* wait until the hw buffer has enough space */
while (gst_element_get_state (element) == GST_STATE_PLAYING && (avail2 = gst_alsa_update_avail (this)) < avail) {
if (avail2 <= -EPIPE) goto sink_restart;
if (avail2 < 0) return;
if (avail2 < avail && snd_pcm_state(this->handle) != SND_PCM_STATE_RUNNING)
if (!gst_alsa_start (this)) return;
while (gst_element_get_state (element) == GST_STATE_PLAYING
&& (avail2 = gst_alsa_update_avail (this)) < avail) {
if (avail2 <= -EPIPE)
goto sink_restart;
if (avail2 < 0)
return;
if (avail2 < avail
&& snd_pcm_state (this->handle) != SND_PCM_STATE_RUNNING)
if (!gst_alsa_start (this))
return;
if (gst_alsa_pcm_wait (this) == FALSE)
return;
}
@ -441,7 +471,8 @@ no_difference:
}
}
if (snd_pcm_state(this->handle) != SND_PCM_STATE_RUNNING && snd_pcm_avail_update (this->handle) == 0) {
if (snd_pcm_state (this->handle) != SND_PCM_STATE_RUNNING
&& snd_pcm_avail_update (this->handle) == 0) {
gst_alsa_start (this);
}
@ -482,9 +513,9 @@ gst_alsa_sink_get_time (GstAlsa *this)
snd_pcm_sframes_t delay;
if (snd_pcm_delay (this->handle, &delay) == 0 && this->format) {
return GST_SECOND * (GstClockTime) (this->transmitted > delay ? this->transmitted - delay : 0) / this->format->rate;
return GST_SECOND * (GstClockTime) (this->transmitted >
delay ? this->transmitted - delay : 0) / this->format->rate;
} else {
return 0;
}
}

View file

@ -25,17 +25,16 @@
#include "gstalsa.h"
G_BEGIN_DECLS
#define GST_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA_SINK, GstAlsaSink))
#define GST_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA_SINK, GstAlsaSinkClass))
#define GST_IS_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_ALSA_SINK))
#define GST_IS_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_ALSA_SINK))
#define GST_TYPE_ALSA_SINK (gst_alsa_sink_get_type())
typedef struct _GstAlsaSink GstAlsaSink;
typedef struct _GstAlsaSinkClass GstAlsaSinkClass;
struct _GstAlsaSink {
struct _GstAlsaSink
{
GstAlsa parent;
/* array of the data on the channels */
@ -46,7 +45,8 @@ struct _GstAlsaSink {
1 = data should be freed, use buffer after that */
};
struct _GstAlsaSinkClass {
struct _GstAlsaSinkClass
{
GstAlsaClass parent_class;
};
@ -55,5 +55,4 @@ GType gst_alsa_sink_get_type (void);
gboolean gst_alsa_sink_factory_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_ALSA_SINK_H__ */

View file

@ -27,24 +27,19 @@
#include "gstalsaclock.h"
/* elementfactory information */
static GstElementDetails gst_alsa_src_details = GST_ELEMENT_DETAILS (
"Alsa Src",
static GstElementDetails gst_alsa_src_details = GST_ELEMENT_DETAILS ("Alsa Src",
"Source/Audio",
"Read from a sound card via ALSA",
"Thomas Nyberg <thomas@codefactory.se>, "
"Andy Wingo <apwingo@eos.ncsu.edu>, "
"Benjamin Otte <in7y118@public.uni-hamburg.de>"
);
"Benjamin Otte <in7y118@public.uni-hamburg.de>");
static GstPadTemplate *gst_alsa_src_pad_factory (void);
static void gst_alsa_src_base_init (gpointer g_class);
static void gst_alsa_src_class_init (gpointer g_class,
gpointer class_data);
static void gst_alsa_src_class_init (gpointer g_class, gpointer class_data);
static void gst_alsa_src_init (GstAlsaSrc * this);
static int gst_alsa_src_mmap (GstAlsa * this,
snd_pcm_sframes_t * avail);
static int gst_alsa_src_read (GstAlsa * this,
snd_pcm_sframes_t * avail);
static int gst_alsa_src_mmap (GstAlsa * this, snd_pcm_sframes_t * avail);
static int gst_alsa_src_read (GstAlsa * this, snd_pcm_sframes_t * avail);
static void gst_alsa_src_loop (GstElement * element);
static void gst_alsa_src_flush (GstAlsaSrc * src);
static GstElementStateReturn gst_alsa_src_change_state (GstElement * element);
@ -83,7 +78,8 @@ gst_alsa_src_get_type (void)
(GInstanceInitFunc) gst_alsa_src_init,
};
alsa_src_type = g_type_register_static (GST_TYPE_ALSA, "GstAlsaSrc", &alsa_src_info, 0);
alsa_src_type =
g_type_register_static (GST_TYPE_ALSA, "GstAlsaSrc", &alsa_src_info, 0);
}
return alsa_src_type;
}
@ -93,7 +89,8 @@ gst_alsa_src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, gst_alsa_src_pad_factory ());
gst_element_class_add_pad_template (element_class,
gst_alsa_src_pad_factory ());
gst_element_class_set_details (element_class, &gst_alsa_src_details);
}
@ -130,7 +127,8 @@ gst_alsa_src_init (GstAlsaSrc *src)
gst_pad_set_getcaps_function (this->pad[0], gst_alsa_get_caps);
gst_element_add_pad (GST_ELEMENT (this), this->pad[0]);
this->clock = gst_alsa_clock_new ("alsasrcclock", gst_alsa_src_get_time, this);
this->clock =
gst_alsa_clock_new ("alsasrcclock", gst_alsa_src_get_time, this);
/* we hold a ref to our clock until we're disposed */
gst_object_ref (GST_OBJECT (this->clock));
gst_object_sink (GST_OBJECT (this->clock));
@ -169,7 +167,10 @@ gst_alsa_src_mmap (GstAlsa *this, snd_pcm_sframes_t *avail)
GST_ERROR_OBJECT (this, "mmap failed: %s", snd_strerror (err));
return -1;
}
if (*avail > 0 && (err = snd_pcm_areas_copy (dst, 0, src, offset, this->format->channels, *avail, this->format->format)) < 0) {
if (*avail > 0
&& (err =
snd_pcm_areas_copy (dst, 0, src, offset, this->format->channels,
*avail, this->format->format)) < 0) {
snd_pcm_mmap_commit (this->handle, offset, 0);
GST_ERROR_OBJECT (this, "data copy failed: %s", snd_strerror (err));
return -1;
@ -224,6 +225,7 @@ gst_alsa_src_adjust_rate (gint rate, gboolean aggressive)
return 0;
}
static gboolean
gst_alsa_src_set_caps (GstAlsaSrc * src, gboolean aggressive)
{
@ -236,19 +238,21 @@ gst_alsa_src_set_caps (GstAlsaSrc *src, gboolean aggressive)
GstAlsa *this = GST_ALSA (src);
all_caps = gst_alsa_get_caps (this->pad[0]);
if (all_caps == NULL) return FALSE;
if (all_caps == NULL)
return FALSE;
/* now intersect this with all caps of the peers... */
for (i = 0; i < GST_ELEMENT (src)->numpads; i++) {
all_caps = gst_caps_intersect (all_caps, gst_pad_get_allowed_caps (this->pad[i]));
all_caps =
gst_caps_intersect (all_caps, gst_pad_get_allowed_caps (this->pad[i]));
if (all_caps == NULL) {
GST_DEBUG ("No compatible caps found in alsasrc (%s)", GST_ELEMENT_NAME (this));
GST_DEBUG ("No compatible caps found in alsasrc (%s)",
GST_ELEMENT_NAME (this));
return FALSE;
}
}
/* construct caps */
caps = gst_caps_new_simple ("audio/x-raw-int",
NULL);
caps = gst_caps_new_simple ("audio/x-raw-int", NULL);
g_assert (gst_caps_get_size (caps) == 1);
structure = gst_caps_get_structure (caps, 0);
@ -267,21 +271,27 @@ gst_alsa_src_set_caps (GstAlsaSrc *src, gboolean aggressive)
gst_structure_set (structure,
"endianness", G_TYPE_INT, endian,
"width", G_TYPE_INT, width,
"depth", G_TYPE_INT, depth,
"signed", G_TYPE_BOOLEAN, sign,
NULL);
"depth", G_TYPE_INT, depth, "signed", G_TYPE_BOOLEAN, sign, NULL);
min_rate = gst_value_get_int_range_min (gst_structure_get_value (walk, "rate"));
max_rate = gst_value_get_int_range_max (gst_structure_get_value (walk, "rate"));
min_channels = gst_value_get_int_range_min (gst_structure_get_value (walk, "channels"));
max_channels = gst_value_get_int_range_max (gst_structure_get_value (walk, "channels"));
min_rate =
gst_value_get_int_range_min (gst_structure_get_value (walk, "rate"));
max_rate =
gst_value_get_int_range_max (gst_structure_get_value (walk, "rate"));
min_channels =
gst_value_get_int_range_min (gst_structure_get_value (walk,
"channels"));
max_channels =
gst_value_get_int_range_max (gst_structure_get_value (walk,
"channels"));
for (rate = max_rate;; rate--) {
if ((rate = gst_alsa_src_adjust_rate (rate, aggressive)) < min_rate)
break;
gst_structure_set (structure, "rate", G_TYPE_INT, rate, NULL);
for (channels = aggressive ? max_channels : MIN (max_channels, 2); channels >= min_channels; channels--) {
for (channels = aggressive ? max_channels : MIN (max_channels, 2);
channels >= min_channels; channels--) {
gst_structure_set (structure, "channels", G_TYPE_INT, channels, NULL);
GST_DEBUG ("trying new caps: %ssigned, endianness: %d, width %d, depth %d, channels %d, rate %d",
GST_DEBUG
("trying new caps: %ssigned, endianness: %d, width %d, depth %d, channels %d, rate %d",
sign ? "" : "un", endian, width, depth, channels, rate);
if (gst_pad_try_set_caps (this->pad[0], caps) != GST_PAD_LINK_REFUSED)
gst_alsa_link (this->pad[0], caps);
@ -299,6 +309,7 @@ gst_alsa_src_set_caps (GstAlsaSrc *src, gboolean aggressive)
return FALSE;
}
/* we transmit buffers of period_size frames */
static void
gst_alsa_src_loop (GstElement * element)
@ -318,8 +329,10 @@ gst_alsa_src_loop (GstElement *element)
}
while ((avail = gst_alsa_update_avail (this)) < this->period_size) {
if (avail == -EPIPE) continue;
if (avail < 0) return;
if (avail == -EPIPE)
continue;
if (avail < 0)
return;
if (snd_pcm_state (this->handle) != SND_PCM_STATE_RUNNING) {
if (!gst_alsa_start (this))
return;
@ -345,8 +358,10 @@ gst_alsa_src_loop (GstElement *element)
return;
if (copied != this->period_size)
GST_BUFFER_SIZE (src->buf[i]) = gst_alsa_samples_to_bytes (this, copied);
GST_BUFFER_TIMESTAMP (src->buf[i]) = gst_alsa_samples_to_timestamp (this, this->transmitted);
GST_BUFFER_DURATION (src->buf[i]) = gst_alsa_samples_to_timestamp (this, copied);
GST_BUFFER_TIMESTAMP (src->buf[i]) =
gst_alsa_samples_to_timestamp (this, this->transmitted);
GST_BUFFER_DURATION (src->buf[i]) =
gst_alsa_samples_to_timestamp (this, copied);
gst_pad_push (this->pad[i], GST_DATA (src->buf[i]));
src->buf[i] = NULL;
}
@ -405,4 +420,3 @@ gst_alsa_src_get_time (GstAlsa *this)
return 0;
}
}

View file

@ -25,22 +25,22 @@
#include "gstalsa.h"
G_BEGIN_DECLS
#define GST_ALSA_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA_SRC, GstAlsaSrc))
#define GST_ALSA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA_SRC, GstAlsaSrcClass))
#define GST_IS_ALSA_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_ALSA_SRC))
#define GST_IS_ALSA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_ALSA_SRC))
#define GST_TYPE_ALSA_SRC (gst_alsa_src_get_type())
typedef struct _GstAlsaSrc GstAlsaSrc;
typedef struct _GstAlsaSrcClass GstAlsaSrcClass;
struct _GstAlsaSrc {
struct _GstAlsaSrc
{
GstAlsa parent;
GstBuffer *buf[GST_ALSA_MAX_TRACKS];
};
struct _GstAlsaSrcClass {
struct _GstAlsaSrcClass
{
GstAlsaClass parent_class;
};
@ -49,5 +49,4 @@ GType gst_alsa_src_get_type (void);
gboolean gst_alsa_src_factory_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_ALSA_SRC_H__ */

View file

@ -53,12 +53,10 @@ static GstElementDetails cdparanoia_details = {
};
static GstStaticPadTemplate cdparanoia_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"audio/x-raw-int, "
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, "
"width = (int) 16, "
@ -84,7 +82,8 @@ gst_paranoia_mode_get_type (void)
};
if (!paranoia_mode_type) {
paranoia_mode_type = g_enum_register_static ("GstParanoiaMode", paranoia_modes);
paranoia_mode_type =
g_enum_register_static ("GstParanoiaMode", paranoia_modes);
}
return paranoia_mode_type;
}
@ -101,7 +100,8 @@ gst_paranoia_endian_get_type (void)
};
if (!paranoia_endian_type) {
paranoia_endian_type = g_enum_register_static ("GstParanoiaEndian", paranoia_endians);
paranoia_endian_type =
g_enum_register_static ("GstParanoiaEndian", paranoia_endians);
}
return paranoia_endian_type;
}
@ -145,19 +145,14 @@ static void cdparanoia_get_property (GObject *object, guint prop_id,
static GstData *cdparanoia_get (GstPad * pad);
static gboolean cdparanoia_event (GstPad * pad, GstEvent * event);
static const GstEventMask*
cdparanoia_get_event_mask (GstPad *pad);
static const GstFormat*
cdparanoia_get_formats (GstPad *pad);
static const GstEventMask *cdparanoia_get_event_mask (GstPad * pad);
static const GstFormat *cdparanoia_get_formats (GstPad * pad);
static gboolean cdparanoia_convert (GstPad * pad,
GstFormat src_format,
gint64 src_value,
GstFormat *dest_format,
gint64 *dest_value);
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
static gboolean cdparanoia_query (GstPad * pad, GstQueryType type,
GstFormat * format, gint64 * value);
static const GstQueryType*
cdparanoia_get_query_types (GstPad *pad);
static const GstQueryType *cdparanoia_get_query_types (GstPad * pad);
static void cdparanoia_set_index (GstElement * element, GstIndex * index);
static GstIndex *cdparanoia_get_index (GstElement * element);
@ -189,7 +184,9 @@ cdparanoia_get_type (void)
(GInstanceInitFunc) cdparanoia_init,
};
cdparanoia_type = g_type_register_static (GST_TYPE_ELEMENT, "CDParanoia", &cdparanoia_info, 0);
cdparanoia_type =
g_type_register_static (GST_TYPE_ELEMENT, "CDParanoia",
&cdparanoia_info, 0);
/* Register the track format */
track_format = gst_format_register ("track", "CD track");
@ -224,61 +221,63 @@ cdparanoia_class_init (CDParanoiaClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
cdparanoia_signals[SMILIE_CHANGE] =
g_signal_new ("smilie-change", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (CDParanoiaClass, smilie_change), NULL, NULL,
g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
g_signal_new ("smilie-change", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CDParanoiaClass, smilie_change), NULL,
NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
cdparanoia_signals[TRANSPORT_ERROR] =
g_signal_new ("transport-error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (CDParanoiaClass, transport_error), NULL, NULL,
g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
g_signal_new ("transport-error", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CDParanoiaClass, transport_error),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
cdparanoia_signals[UNCORRECTED_ERROR] =
g_signal_new ("uncorrected-error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (CDParanoiaClass, uncorrected_error), NULL, NULL,
g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
g_signal_new ("uncorrected-error", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CDParanoiaClass, uncorrected_error),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
g_param_spec_string ("location", "location", "location",
NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GENERIC_DEVICE,
g_param_spec_string ("generic_device", "Generic device", "Use specified generic scsi device",
NULL, G_PARAM_READWRITE));
g_param_spec_string ("generic_device", "Generic device",
"Use specified generic scsi device", NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEFAULT_SECTORS,
g_param_spec_int ("default_sectors", "Default sectors",
"Force default number of sectors in read to n sectors",
-1, 100, -1, G_PARAM_READWRITE));
"Force default number of sectors in read to n sectors", -1, 100, -1,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SEARCH_OVERLAP,
g_param_spec_int ("search_overlap", "Search overlap",
"Force minimum overlap search during verification to n sectors",
-1, 75, -1, G_PARAM_READWRITE));
"Force minimum overlap search during verification to n sectors", -1,
75, -1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ENDIAN,
g_param_spec_enum ("endian", "Endian", "Force endian on drive",
GST_TYPE_PARANOIA_ENDIAN, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_READ_SPEED,
g_param_spec_int ("read_speed", "Read speed", "Read from device at specified speed",
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
g_param_spec_int ("read_speed", "Read speed",
"Read from device at specified speed", G_MININT, G_MAXINT, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOC_OFFSET,
g_param_spec_int("toc_offset", "TOC offset", "Add <n> sectors to the values reported",
G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
g_param_spec_int ("toc_offset", "TOC offset",
"Add <n> sectors to the values reported", G_MININT, G_MAXINT, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOC_BIAS,
g_param_spec_boolean ("toc_bias", "TOC bias",
"Assume that the beginning offset of track 1 as reported in the TOC "
"will be addressed as LBA 0. Necessary for some Toshiba drives to "
"get track boundaries",
TRUE,G_PARAM_READWRITE));
"get track boundaries", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NEVER_SKIP,
g_param_spec_int ("never_skip", "Never skip",
"never accept any less than perfect data reconstruction (don't allow "
"'V's) but if [n] is given, skip after [n] retries without progress.",
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ABORT_ON_SKIP,
g_param_spec_boolean ("abort_on_skip", "Abort on skip", "Abort on imperfect reads/skips",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("abort_on_skip", "Abort on skip",
"Abort on imperfect reads/skips", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARANOIA_MODE,
g_param_spec_enum ("paranoia_mode", "Paranoia mode", "Type of checking to perform",
GST_TYPE_PARANOIA_MODE, 0, G_PARAM_READWRITE));
g_param_spec_enum ("paranoia_mode", "Paranoia mode",
"Type of checking to perform", GST_TYPE_PARANOIA_MODE, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DISCID,
g_param_spec_string ("discid", "discid", "The dics id",
NULL, G_PARAM_READABLE));
g_param_spec_string ("discid", "discid", "The dics id", NULL,
G_PARAM_READABLE));
gobject_class->set_property = cdparanoia_set_property;
gobject_class->get_property = cdparanoia_get_property;
@ -292,14 +291,16 @@ static void
cdparanoia_init (CDParanoia * cdparanoia)
{
cdparanoia->srcpad =
gst_pad_new_from_template (
gst_static_pad_template_get (&cdparanoia_src_template), "src");
gst_pad_new_from_template (gst_static_pad_template_get
(&cdparanoia_src_template), "src");
gst_pad_set_get_function (cdparanoia->srcpad, cdparanoia_get);
gst_pad_set_event_function (cdparanoia->srcpad, cdparanoia_event);
gst_pad_set_event_mask_function (cdparanoia->srcpad, cdparanoia_get_event_mask);
gst_pad_set_event_mask_function (cdparanoia->srcpad,
cdparanoia_get_event_mask);
gst_pad_set_convert_function (cdparanoia->srcpad, cdparanoia_convert);
gst_pad_set_query_function (cdparanoia->srcpad, cdparanoia_query);
gst_pad_set_query_type_function (cdparanoia->srcpad, cdparanoia_get_query_types);
gst_pad_set_query_type_function (cdparanoia->srcpad,
cdparanoia_get_query_types);
gst_pad_set_formats_function (cdparanoia->srcpad, cdparanoia_get_formats);
gst_element_add_pad (GST_ELEMENT (cdparanoia), cdparanoia->srcpad);
@ -322,7 +323,8 @@ cdparanoia_init (CDParanoia *cdparanoia)
static void
cdparanoia_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
cdparanoia_set_property (GObject * object, guint prop_id, const GValue * value,
GParamSpec * pspec)
{
CDParanoia *src;
@ -387,7 +389,8 @@ cdparanoia_set_property (GObject *object, guint prop_id, const GValue *value, GP
}
static void
cdparanoia_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
cdparanoia_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
CDParanoia *src;
@ -437,7 +440,8 @@ cdparanoia_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
* See cdparanoia/interface/common-interface.c:FixupTOC
*/
if (src->d && src->d->cd_extra)
g_warning("DiscID on multisession discs might be broken. Use at own risk.");
g_warning
("DiscID on multisession discs might be broken. Use at own risk.");
g_value_set_string (value, src->discid);
break;
default:
@ -467,8 +471,7 @@ cdparanoia_get (GstPad *pad)
buf = GST_BUFFER (gst_event_new (GST_EVENT_EOS));
gst_element_set_eos (GST_ELEMENT (src));
}
else {
} else {
gint16 *cdda_buf;
gint64 timestamp;
GstFormat format;
@ -479,8 +482,7 @@ cdparanoia_get (GstPad *pad)
/* convert the sequence sector number to a timestamp */
format = GST_FORMAT_TIME;
timestamp = 0LL;
gst_pad_convert (src->srcpad, sector_format, src->seq,
&format, &timestamp);
gst_pad_convert (src->srcpad, sector_format, src->seq, &format, &timestamp);
/* have to copy the buffer for now since we don't own it... */
/* FIXME must ask monty about allowing ownership transfer */
@ -532,7 +534,8 @@ lba_toc_to_msf_toc (TOC *lba_toc, toc_msf *msf_toc, gint tracks)
gint i;
for (i = 0; i <= tracks; i++)
lba_to_msf (lba_toc[i].dwStartSector, &msf_toc[i].m, &msf_toc[i].s, &msf_toc[i].f);
lba_to_msf (lba_toc[i].dwStartSector, &msf_toc[i].m, &msf_toc[i].s,
&msf_toc[i].f);
}
/* the cddb hash function */
@ -565,7 +568,8 @@ cddb_discid (gchar *discid, toc_msf *toc, gint tracks)
/* get all the cddb info at once */
static void
get_cddb_info (TOC *toc, gint tracks, gchar *discid, gint64 *offsets, gint64 *total_seconds)
get_cddb_info (TOC * toc, gint tracks, gchar * discid, gint64 * offsets,
gint64 * total_seconds)
{
toc_msf msf_toc[MAXTRK];
gint i;
@ -595,14 +599,15 @@ add_index_associations (CDParanoia *src)
GST_ASSOCIATION_FLAG_KEY_UNIT,
track_format, i,
sector_format, sector,
GST_FORMAT_TIME, (gint64) (((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100),
GST_FORMAT_BYTES, (gint64) (sector << 2),
GST_FORMAT_DEFAULT, (gint64) ((CD_FRAMESIZE_RAW >> 2) * sector),
NULL);
GST_FORMAT_TIME,
(gint64) (((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100),
GST_FORMAT_BYTES, (gint64) (sector << 2), GST_FORMAT_DEFAULT,
(gint64) ((CD_FRAMESIZE_RAW >> 2) * sector), NULL);
#if 0
g_print ("Added association for track %d\n", i + 1);
g_print ("Sector: %lld\n", sector);
g_print ("Time: %lld\n", (gint64) (((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100));
g_print ("Time: %lld\n",
(gint64) (((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100));
g_print ("Bytes: %lld\n", (gint64) (sector << 2));
g_print ("Units: %lld\n", (gint64) ((CD_FRAMESIZE_RAW >> 2) * sector));
g_print ("-----------\n");
@ -635,8 +640,7 @@ cdparanoia_open (CDParanoia *src)
/* fail if the device couldn't be found */
if (src->d == NULL) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
(_("Could not open CD device for reading.")),
("cdda_identify failed"));
(_("Could not open CD device for reading.")), ("cdda_identify failed"));
return FALSE;
}
@ -652,8 +656,7 @@ cdparanoia_open (CDParanoia *src)
/* open the disc */
if (cdda_open (src->d)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
(_("Could not open CD device for reading.")),
("cdda_open failed"));
(_("Could not open CD device for reading.")), ("cdda_open failed"));
cdda_close (src->d);
src->d = NULL;
return FALSE;
@ -784,13 +787,9 @@ cdparanoia_get_event_mask (GstPad *pad)
{
static const GstEventMask masks[] = {
{GST_EVENT_SEEK, GST_SEEK_METHOD_SET |
GST_SEEK_METHOD_CUR |
GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH },
GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
{GST_EVENT_SEEK_SEGMENT, GST_SEEK_METHOD_SET |
GST_SEEK_METHOD_CUR |
GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH },
GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
{0,}
};
@ -871,8 +870,7 @@ cdparanoia_event (GstPad *pad, GstEvent *event)
src->segment_start_sector = seg_start_sector;
src->cur_sector = src->segment_start_sector;
}
else {
} else {
goto error;
}
}
@ -882,8 +880,7 @@ cdparanoia_event (GstPad *pad, GstEvent *event)
src->segment_end_sector = seg_end_sector;
}
GST_DEBUG ("configured for %d -> %d sectors\n",
src->segment_start_sector,
src->segment_end_sector);
src->segment_start_sector, src->segment_end_sector);
break;
}
default:
@ -940,16 +937,15 @@ cdparanoia_convert (GstPad *pad,
break;
default:
if (*dest_format == track_format || *dest_format == sector_format) {
gint sector = (src_value * 44100) / ((CD_FRAMESIZE_RAW >> 2) * GST_SECOND);
gint sector =
(src_value * 44100) / ((CD_FRAMESIZE_RAW >> 2) * GST_SECOND);
if (*dest_format == sector_format) {
*dest_value = sector;
}
else {
} else {
*dest_value = cdda_sector_gettrack (src->d, sector) - 1;
}
}
else
} else
return FALSE;
break;
}
@ -970,12 +966,10 @@ cdparanoia_convert (GstPad *pad,
if (*dest_format == track_format) {
*dest_value = cdda_sector_gettrack (src->d, sector) - 1;
}
else {
} else {
*dest_value = sector;
}
}
else
} else
return FALSE;
break;
}
@ -990,11 +984,9 @@ cdparanoia_convert (GstPad *pad,
return FALSE;
sector = cdda_track_firstsector (src->d, src_value + 1);
}
else if (src_format == sector_format) {
} else if (src_format == sector_format) {
sector = src_value;
}
else {
} else {
return FALSE;
}
@ -1010,15 +1002,13 @@ cdparanoia_convert (GstPad *pad,
default:
if (*dest_format == sector_format) {
*dest_value = sector;
}
else if (*dest_format == track_format) {
} else if (*dest_format == track_format) {
/* if we go past the last sector, make sure to report the last track */
if (sector > src->last_sector)
*dest_value = cdda_sector_gettrack (src->d, src->last_sector);
else
*dest_value = cdda_sector_gettrack (src->d, sector) - 1;
}
else {
} else {
return FALSE;
}
break;
@ -1061,24 +1051,20 @@ cdparanoia_query (GstPad *pad, GstQueryType type,
/* we take the last sector + 1 so that we also have the full
* size of that last sector */
res = gst_pad_convert (src->srcpad,
sector_format, src->last_sector + 1,
format, value);
sector_format, src->last_sector + 1, format, value);
break;
case GST_QUERY_POSITION:
/* bring our current sector to the requested format */
res = gst_pad_convert (src->srcpad,
sector_format, src->cur_sector,
format, value);
sector_format, src->cur_sector, format, value);
break;
case GST_QUERY_START:
res = gst_pad_convert (src->srcpad,
sector_format, src->segment_start_sector,
format, value);
sector_format, src->segment_start_sector, format, value);
break;
case GST_QUERY_SEGMENT_END:
res = gst_pad_convert (src->srcpad,
sector_format, src->segment_end_sector,
format, value);
sector_format, src->segment_end_sector, format, value);
break;
default:
res = FALSE;
@ -1088,8 +1074,7 @@ cdparanoia_query (GstPad *pad, GstQueryType type,
}
static void
cdparanoia_set_index (GstElement *element,
GstIndex *index)
cdparanoia_set_index (GstElement * element, GstIndex * index)
{
CDParanoia *cdparanoia;
@ -1116,19 +1101,15 @@ cdparanoia_get_index (GstElement *element)
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "cdparanoia", GST_RANK_NONE, GST_TYPE_CDPARANOIA))
if (!gst_element_register (plugin, "cdparanoia", GST_RANK_NONE,
GST_TYPE_CDPARANOIA))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"cdparanoia",
"Read audio from CD in paranoid mode",
plugin_init,
VERSION,
"GPL",
GST_PACKAGE,
GST_ORIGIN)
plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)

View file

@ -26,7 +26,8 @@
#include <gst/gst.h>
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif /* __cplusplus */
#define size16 gint16
@ -57,7 +58,8 @@ extern "C" {
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CDPARANOIA))
/* NOTE: per-element flags start with 16 for now */
typedef enum {
typedef enum
{
CDPARANOIA_OPEN = GST_ELEMENT_FLAG_LAST,
CDPARANOIA_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
@ -66,7 +68,8 @@ typedef enum {
typedef struct _CDParanoia CDParanoia;
typedef struct _CDParanoiaClass CDParanoiaClass;
struct _CDParanoia {
struct _CDParanoia
{
GstElement element;
/* pads */
GstPad *srcpad;
@ -106,7 +109,8 @@ struct _CDParanoia {
gboolean discont_pending;
};
struct _CDParanoiaClass {
struct _CDParanoiaClass
{
GstElementClass parent_class;
/* signal callbacks */

View file

@ -37,7 +37,6 @@ plugin_init(GstPlugin *plugin)
GST_RANK_SECONDARY, gst_gnomevfssink_get_type ())) {
return FALSE;
}
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
@ -46,15 +45,8 @@ plugin_init(GstPlugin *plugin)
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gnomevfs",
"elements to access the Gnome vfs",
plugin_init,
VERSION,
GST_LICENSE,
GST_PACKAGE,
GST_ORIGIN
)
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)

View file

@ -23,13 +23,9 @@
#include <glib-object.h>
G_BEGIN_DECLS
GType gst_gnomevfssink_get_type (void);
G_BEGIN_DECLS GType gst_gnomevfssink_get_type (void);
GType gst_gnomevfssrc_get_type (void);
G_END_DECLS
#endif /* __GST_GNOME_VFS_H__ */

View file

@ -51,13 +51,15 @@
typedef struct _GstGnomeVFSSink GstGnomeVFSSink;
typedef struct _GstGnomeVFSSinkClass GstGnomeVFSSinkClass;
typedef enum {
typedef enum
{
GST_GNOMEVFSSINK_OPEN = GST_ELEMENT_FLAG_LAST,
GST_GNOMEVFSSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} GstGnomeVFSSinkFlags;
struct _GstGnomeVFSSink {
struct _GstGnomeVFSSink
{
GstElement element;
/* filename */
@ -70,7 +72,8 @@ struct _GstGnomeVFSSink {
gboolean erase;
};
struct _GstGnomeVFSSinkClass {
struct _GstGnomeVFSSinkClass
{
GstElementClass parent_class;
/* signals */
@ -79,23 +82,24 @@ struct _GstGnomeVFSSinkClass {
};
/* elementfactory information */
static GstElementDetails gst_gnomevfssink_details = GST_ELEMENT_DETAILS (
"GnomeVFS Sink",
static GstElementDetails gst_gnomevfssink_details =
GST_ELEMENT_DETAILS ("GnomeVFS Sink",
"Sink/File",
"Write stream to a GnomeVFS URI",
"Bastien Nocera <hadess@hadess.net>"
);
"Bastien Nocera <hadess@hadess.net>");
/* GnomeVFSSink signals and args */
enum {
enum
{
/* FILL ME */
SIGNAL_HANDOFF,
SIGNAL_ERASE_ASK,
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
ARG_LOCATION,
ARG_HANDLE,
@ -107,15 +111,18 @@ static void gst_gnomevfssink_base_init (gpointer g_class);
static void gst_gnomevfssink_class_init (GstGnomeVFSSinkClass * klass);
static void gst_gnomevfssink_init (GstGnomeVFSSink * gnomevfssink);
static void gst_gnomevfssink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_gnomevfssink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void gst_gnomevfssink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_gnomevfssink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_gnomevfssink_open_file (GstGnomeVFSSink * sink);
static void gst_gnomevfssink_close_file (GstGnomeVFSSink * sink);
static void gst_gnomevfssink_chain (GstPad * pad, GstData * _data);
static GstElementStateReturn gst_gnomevfssink_change_state (GstElement *element);
static GstElementStateReturn gst_gnomevfssink_change_state (GstElement *
element);
static GstElementClass *parent_class = NULL;
static guint gst_gnomevfssink_signals[LAST_SIGNAL] = { 0 };
@ -137,7 +144,9 @@ gst_gnomevfssink_get_type (void)
0,
(GInstanceInitFunc) gst_gnomevfssink_init,
};
gnomevfssink_type = g_type_register_static (GST_TYPE_ELEMENT, "GstGnomeVFSSink", &gnomevfssink_info, 0);
gnomevfssink_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstGnomeVFSSink",
&gnomevfssink_info, 0);
}
return gnomevfssink_type;
}
@ -162,17 +171,13 @@ gst_gnomevfssink_class_init (GstGnomeVFSSinkClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_element_class_install_std_props (
GST_ELEMENT_CLASS (klass),
"location", ARG_LOCATION, G_PARAM_READWRITE,
NULL);
gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
"location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
g_object_class_install_property (gobject_class,
ARG_HANDLE,
g_param_spec_pointer ("handle",
"GnomeVFSHandle",
"Handle for GnomeVFS",
G_PARAM_READWRITE));
"GnomeVFSHandle", "Handle for GnomeVFS", G_PARAM_READWRITE));
gst_gnomevfssink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -199,6 +204,7 @@ static void
gst_gnomevfssink_init (GstGnomeVFSSink * gnomevfssink)
{
GstPad *pad;
pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (gnomevfssink), pad);
gst_pad_set_chain_function (pad, gst_gnomevfssink_chain);
@ -210,7 +216,8 @@ gst_gnomevfssink_init (GstGnomeVFSSink *gnomevfssink)
}
static void
gst_gnomevfssink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
gst_gnomevfssink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstGnomeVFSSink *sink;
@ -238,7 +245,8 @@ gst_gnomevfssink_set_property (GObject *object, guint prop_id, const GValue *val
}
static void
gst_gnomevfssink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
gst_gnomevfssink_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstGnomeVFSSink *sink;
@ -279,8 +287,7 @@ gst_gnomevfssink_open_file (GstGnomeVFSSink *sink)
if (result != GNOME_VFS_OK) {
if (sink->erase == FALSE) {
g_signal_emit (G_OBJECT (sink),
gst_gnomevfssink_signals[SIGNAL_ERASE_ASK], 0,
sink->erase);
gst_gnomevfssink_signals[SIGNAL_ERASE_ASK], 0, sink->erase);
}
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
(_("Could not open vfs file \"%s\" for writing."), sink->filename),
@ -336,14 +343,16 @@ gst_gnomevfssink_chain (GstPad *pad, GstData *_data)
sink = GST_GNOMEVFSSINK (gst_pad_get_parent (pad));
if (GST_FLAG_IS_SET (sink, GST_GNOMEVFSSINK_OPEN))
{
result = gnome_vfs_write(sink->handle, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE (buf), &bytes_written);
GST_DEBUG ("write: %s, written_bytes: %" G_GUINT64_FORMAT, gnome_vfs_result_to_string(result), bytes_written);
if (bytes_written < GST_BUFFER_SIZE (buf))
{
printf ("gnomevfssink : Warning : %d bytes should be written, only %" G_GUINT64_FORMAT " bytes written\n",
GST_BUFFER_SIZE (buf), bytes_written);
if (GST_FLAG_IS_SET (sink, GST_GNOMEVFSSINK_OPEN)) {
result =
gnome_vfs_write (sink->handle, GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (buf), &bytes_written);
GST_DEBUG ("write: %s, written_bytes: %" G_GUINT64_FORMAT,
gnome_vfs_result_to_string (result), bytes_written);
if (bytes_written < GST_BUFFER_SIZE (buf)) {
printf ("gnomevfssink : Warning : %d bytes should be written, only %"
G_GUINT64_FORMAT " bytes written\n", GST_BUFFER_SIZE (buf),
bytes_written);
}
}
gst_buffer_unref (buf);
@ -372,4 +381,3 @@ gst_gnomevfssink_change_state (GstElement *element)
return GST_STATE_SUCCESS;
}

View file

@ -68,7 +68,8 @@ static GStaticMutex count_lock = G_STATIC_MUTEX_INIT;
static gint ref_count = 0;
static gboolean vfs_owner = FALSE;
typedef enum {
typedef enum
{
GST_GNOMEVFSSRC_OPEN = GST_ELEMENT_FLAG_LAST,
GST_GNOMEVFSSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
@ -77,7 +78,8 @@ typedef enum {
typedef struct _GstGnomeVFSSrc GstGnomeVFSSrc;
typedef struct _GstGnomeVFSSrcClass GstGnomeVFSSrcClass;
struct _GstGnomeVFSSrc {
struct _GstGnomeVFSSrc
{
GstElement element;
/* pads */
GstPad *srcpad;
@ -121,16 +123,16 @@ struct _GstGnomeVFSSrc {
gint audiocast_fd;
};
struct _GstGnomeVFSSrcClass {
struct _GstGnomeVFSSrcClass
{
GstElementClass parent_class;
};
static GstElementDetails gst_gnomevfssrc_details = GST_ELEMENT_DETAILS (
"GnomeVFS Source",
static GstElementDetails gst_gnomevfssrc_details =
GST_ELEMENT_DETAILS ("GnomeVFS Source",
"Source/File",
"Read from any GnomeVFS file",
"Bastien Nocera <hadess@hadess.net>"
);
"Bastien Nocera <hadess@hadess.net>");
static const GstFormat *
@ -159,9 +161,7 @@ gst_gnomevfssrc_get_event_mask (GstPad *pad)
{
static const GstEventMask masks[] = {
{GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
GST_SEEK_METHOD_SET |
GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH },
GST_SEEK_METHOD_SET | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
{GST_EVENT_FLUSH, 0},
{GST_EVENT_SIZE, 0},
{0, 0},
@ -170,11 +170,13 @@ gst_gnomevfssrc_get_event_mask (GstPad *pad)
}
/* GnomeVFSSrc signals and args */
enum {
enum
{
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
ARG_HANDLE,
ARG_LOCATION,
@ -216,7 +218,8 @@ static void audiocast_thread_kill(GstGnomeVFSSrc *src);
static GstElementClass *parent_class = NULL;
GType gst_gnomevfssrc_get_type(void)
GType
gst_gnomevfssrc_get_type (void)
{
static GType gnomevfssrc_type = 0;
@ -234,9 +237,7 @@ GType gst_gnomevfssrc_get_type(void)
};
gnomevfssrc_type =
g_type_register_static (GST_TYPE_ELEMENT,
"GstGnomeVFSSrc",
&gnomevfssrc_info,
0);
"GstGnomeVFSSrc", &gnomevfssrc_info, 0);
}
return gnomevfssrc_type;
}
@ -249,7 +250,8 @@ gst_gnomevfssrc_base_init (gpointer g_class)
gst_element_class_set_details (element_class, &gst_gnomevfssrc_details);
}
static void gst_gnomevfssrc_class_init(GstGnomeVFSSrcClass *klass)
static void
gst_gnomevfssrc_class_init (GstGnomeVFSSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@ -259,20 +261,16 @@ static void gst_gnomevfssrc_class_init(GstGnomeVFSSrcClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_element_class_install_std_props (
GST_ELEMENT_CLASS (klass),
gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
"bytesperread", ARG_BYTESPERREAD, G_PARAM_READWRITE,
"location", ARG_LOCATION, G_PARAM_READWRITE,
NULL);
"location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
gobject_class->dispose = gst_gnomevfssrc_dispose;
g_object_class_install_property (gobject_class,
ARG_HANDLE,
g_param_spec_pointer ("handle",
"GnomeVFSHandle",
"Handle for GnomeVFS",
G_PARAM_READWRITE));
"GnomeVFSHandle", "Handle for GnomeVFS", G_PARAM_READWRITE));
/* icecast stuff */
g_object_class_install_property (gobject_class,
@ -280,44 +278,29 @@ static void gst_gnomevfssrc_class_init(GstGnomeVFSSrcClass *klass)
g_param_spec_boolean ("iradio-mode",
"iradio-mode",
"Enable internet radio mode (extraction of icecast/audiocast metadata)",
FALSE,
G_PARAM_READWRITE));
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
ARG_IRADIO_NAME,
g_param_spec_string ("iradio-name",
"iradio-name",
"Name of the stream",
NULL,
G_PARAM_READABLE));
"iradio-name", "Name of the stream", NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
ARG_IRADIO_GENRE,
g_param_spec_string ("iradio-genre",
"iradio-genre",
"Genre of the stream",
NULL,
G_PARAM_READABLE));
"iradio-genre", "Genre of the stream", NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
ARG_IRADIO_URL,
g_param_spec_string ("iradio-url",
"iradio-url",
"Homepage URL for radio stream",
NULL,
G_PARAM_READABLE));
"Homepage URL for radio stream", NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
ARG_IRADIO_TITLE,
g_param_spec_string ("iradio-title",
"iradio-title",
"Name of currently playing song",
NULL,
G_PARAM_READABLE));
"Name of currently playing song", NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
ARG_SEEKABLE,
g_param_spec_boolean ("seekable",
"seekable",
"TRUE is stream is seekable",
FALSE,
G_PARAM_READABLE));
"seekable", "TRUE is stream is seekable", FALSE, G_PARAM_READABLE));
gstelement_class->set_property = gst_gnomevfssrc_set_property;
gstelement_class->get_property = gst_gnomevfssrc_get_property;
@ -325,7 +308,8 @@ static void gst_gnomevfssrc_class_init(GstGnomeVFSSrcClass *klass)
gstelement_class->change_state = gst_gnomevfssrc_change_state;
}
static void gst_gnomevfssrc_init(GstGnomeVFSSrc *gnomevfssrc)
static void
gst_gnomevfssrc_init (GstGnomeVFSSrc * gnomevfssrc)
{
gnomevfssrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_get_function (gnomevfssrc->srcpad, gst_gnomevfssrc_get);
@ -392,7 +376,9 @@ gst_gnomevfssrc_dispose (GObject *object)
}
static void gst_gnomevfssrc_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
static void
gst_gnomevfssrc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstGnomeVFSSrc *src;
const gchar *location;
@ -420,16 +406,17 @@ static void gst_gnomevfssrc_set_property(GObject *object, guint prop_id, const G
location = g_value_get_string (value);
/* if it's not a proper uri, default to file: -- this
* is a crude test */
if (!strchr (location, ':'))
{
if (!strchr (location, ':')) {
gchar *newloc = gnome_vfs_escape_path_string (location);
if (*newloc == '/')
src->filename = g_strdup_printf ("file://%s", newloc);
else
src->filename = g_strdup_printf ("file://%s/%s", getcwd(cwd, PATH_MAX), newloc);
src->filename =
g_strdup_printf ("file://%s/%s", getcwd (cwd, PATH_MAX),
newloc);
g_free (newloc);
}
else
} else
src->filename = g_strdup (g_value_get_string (value));
}
@ -454,7 +441,9 @@ static void gst_gnomevfssrc_set_property(GObject *object, guint prop_id, const G
}
}
static void gst_gnomevfssrc_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
static void
gst_gnomevfssrc_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstGnomeVFSSrc *src;
@ -513,8 +502,7 @@ unicodify (const char *str, int len, ...)
while ((cset = va_arg (args, char *)) != NULL)
{
if (!strcmp (cset, "locale"))
ret = g_locale_to_utf8 (str, len, &bytes_read,
&bytes_written, NULL);
ret = g_locale_to_utf8 (str, len, &bytes_read, &bytes_written, NULL);
else
ret = g_convert (str, len, "UTF-8", cset,
&bytes_read, &bytes_written, NULL);
@ -536,14 +524,17 @@ gst_gnomevfssrc_unicodify (const char *str)
* icecast/audiocast metadata extraction support code
*/
static int audiocast_init(GstGnomeVFSSrc *src)
static int
audiocast_init (GstGnomeVFSSrc * src)
{
int pipefds[2];
GError *error = NULL;
if (!src->iradio_mode)
return TRUE;
GST_DEBUG ("audiocast: registering listener");
if (audiocast_register_listener(&src->audiocast_port, &src->audiocast_fd) < 0) {
if (audiocast_register_listener (&src->audiocast_port,
&src->audiocast_fd) < 0) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Unable to listen on UDP port %d", src->audiocast_port));
close (src->audiocast_fd);
@ -551,15 +542,15 @@ static int audiocast_init(GstGnomeVFSSrc *src)
}
GST_DEBUG ("audiocast: creating pipe");
src->audiocast_notify_queue = NULL;
if (pipe(pipefds) < 0)
{
if (pipe (pipefds) < 0) {
close (src->audiocast_fd);
return FALSE;
}
src->audiocast_thread_die_infd = pipefds[0];
src->audiocast_thread_die_outfd = pipefds[1];
GST_DEBUG ("audiocast: creating audiocast thread");
src->audiocast_thread = g_thread_create((GThreadFunc) audiocast_thread_run, src, TRUE, &error);
src->audiocast_thread =
g_thread_create ((GThreadFunc) audiocast_thread_run, src, TRUE, &error);
if (error != NULL) {
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL),
("Unable to create thread: %s", error->message));
@ -569,7 +560,8 @@ static int audiocast_init(GstGnomeVFSSrc *src)
return TRUE;
}
static int audiocast_register_listener(gint *port, gint *fd)
static int
audiocast_register_listener (gint * port, gint * fd)
{
struct sockaddr_in sin;
int sock;
@ -591,7 +583,8 @@ static int audiocast_register_listener(gint *port, gint *fd)
if (getsockname (sock, (struct sockaddr *) &sin, &sinlen) < 0)
goto lose_and_close;
GST_DEBUG ("audiocast: listening on local %s:%d", inet_ntoa(sin.sin_addr), g_ntohs(sin.sin_port));
GST_DEBUG ("audiocast: listening on local %s:%d", inet_ntoa (sin.sin_addr),
g_ntohs (sin.sin_port));
*port = g_ntohs (sin.sin_port);
*fd = sock;
@ -603,12 +596,13 @@ lose:
return -1;
}
static void audiocast_do_notifications(GstGnomeVFSSrc *src)
static void
audiocast_do_notifications (GstGnomeVFSSrc * src)
{
/* Send any pending notifications we got from the UDP thread. */
if (src->iradio_mode)
{
if (src->iradio_mode) {
GList *entry;
g_mutex_lock (src->audiocast_queue_mutex);
for (entry = src->audiocast_notify_queue; entry; entry = entry->next)
g_object_notify (G_OBJECT (src), (const gchar *) entry->data);
@ -618,7 +612,8 @@ static void audiocast_do_notifications(GstGnomeVFSSrc *src)
}
}
static gpointer audiocast_thread_run(GstGnomeVFSSrc *src)
static gpointer
audiocast_thread_run (GstGnomeVFSSrc * src)
{
char buf[1025], **lines;
gsize len;
@ -631,8 +626,7 @@ static gpointer audiocast_thread_run(GstGnomeVFSSrc *src)
FD_SET (src->audiocast_fd, &fdset);
FD_SET (src->audiocast_thread_die_infd, &fdset);
while (1)
{
while (1) {
GST_DEBUG ("audiocast thread: dropping into select");
readset = fdset;
if (select (FD_SETSIZE, &readset, NULL, NULL, NULL) < 0) {
@ -641,6 +635,7 @@ static gpointer audiocast_thread_run(GstGnomeVFSSrc *src)
}
if (FD_ISSET (src->audiocast_thread_die_infd, &readset)) {
char buf[1];
GST_DEBUG ("audiocast thread: got die character");
read (src->audiocast_thread_die_infd, buf, 1);
close (src->audiocast_thread_die_infd);
@ -648,13 +643,15 @@ static gpointer audiocast_thread_run(GstGnomeVFSSrc *src)
return NULL;
}
GST_DEBUG ("audiocast thread: reading data");
len = recvfrom(src->audiocast_fd, buf, sizeof(buf) - 1, 0, (struct sockaddr *) &from, &fromlen);
len =
recvfrom (src->audiocast_fd, buf, sizeof (buf) - 1, 0,
(struct sockaddr *) &from, &fromlen);
if (len < 0 && errno == EAGAIN)
continue;
else if (len >= 0)
{
else if (len >= 0) {
int i;
char *valptr, *value;
buf[len] = '\0';
lines = g_strsplit (buf, "\n", 0);
if (!lines)
@ -677,8 +674,7 @@ static gpointer audiocast_thread_run(GstGnomeVFSSrc *src)
continue;
value = gst_gnomevfssrc_unicodify (valptr);
if (!value)
{
if (!value) {
g_print ("Unable to convert \"%s\" to UTF-8!\n", valptr);
continue;
}
@ -690,7 +686,8 @@ static gpointer audiocast_thread_run(GstGnomeVFSSrc *src)
g_mutex_unlock (src->audiocast_udpdata_mutex);
g_mutex_lock (src->audiocast_queue_mutex);
src->audiocast_notify_queue = g_list_append(src->audiocast_notify_queue, "iradio-title");
src->audiocast_notify_queue =
g_list_append (src->audiocast_notify_queue, "iradio-title");
GST_DEBUG ("audiocast title: %s\n", src->iradio_title);
g_mutex_unlock (src->audiocast_queue_mutex);
} else if (!strncmp (lines[i], "x-audiocast-streamurl", 21)) {
@ -700,7 +697,8 @@ static gpointer audiocast_thread_run(GstGnomeVFSSrc *src)
g_mutex_unlock (src->audiocast_udpdata_mutex);
g_mutex_lock (src->audiocast_queue_mutex);
src->audiocast_notify_queue = g_list_append(src->audiocast_notify_queue, "iradio-url");
src->audiocast_notify_queue =
g_list_append (src->audiocast_notify_queue, "iradio-url");
GST_DEBUG ("audiocast url: %s\n", src->iradio_title);
g_mutex_unlock (src->audiocast_queue_mutex);
} else if (!strncmp (lines[i], "x-audiocast-udpseqnr", 20)) {
@ -709,8 +707,10 @@ static gpointer audiocast_thread_run(GstGnomeVFSSrc *src)
sprintf (outbuf, "x-audiocast-ack: %ld \r\n", atol (value));
g_free (value);
if (sendto(src->audiocast_fd, outbuf, strlen(outbuf), 0, (struct sockaddr *) &from, fromlen) <= 0) {
g_print("Error sending response to server: %s\n", strerror(errno));
if (sendto (src->audiocast_fd, outbuf, strlen (outbuf), 0,
(struct sockaddr *) &from, fromlen) <= 0) {
g_print ("Error sending response to server: %s\n",
strerror (errno));
continue;
}
GST_DEBUG ("sent audiocast ack: %s\n", outbuf);
@ -722,7 +722,8 @@ static gpointer audiocast_thread_run(GstGnomeVFSSrc *src)
return NULL;
}
static void audiocast_thread_kill(GstGnomeVFSSrc *src)
static void
audiocast_thread_kill (GstGnomeVFSSrc * src)
{
if (!src->audiocast_thread)
return;
@ -743,10 +744,7 @@ static void audiocast_thread_kill(GstGnomeVFSSrc *src)
static void
gst_gnomevfssrc_send_additional_headers_callback (gconstpointer in,
gsize in_size,
gpointer out,
gsize out_size,
gpointer callback_data)
gsize in_size, gpointer out, gsize out_size, gpointer callback_data)
{
GstGnomeVFSSrc *src = GST_GNOMEVFSSRC (callback_data);
GnomeVFSModuleCallbackAdditionalHeadersOut *out_args =
@ -764,10 +762,7 @@ gst_gnomevfssrc_send_additional_headers_callback (gconstpointer in,
static void
gst_gnomevfssrc_received_headers_callback (gconstpointer in,
gsize in_size,
gpointer out,
gsize out_size,
gpointer callback_data)
gsize in_size, gpointer out, gsize out_size, gpointer callback_data)
{
GList *i;
gint icy_metaint;
@ -783,6 +778,7 @@ gst_gnomevfssrc_received_headers_callback (gconstpointer in,
char *data = (char *) i->data;
char *key = data;
char *value = strchr (data, ':');
if (!value)
continue;
@ -792,8 +788,7 @@ gst_gnomevfssrc_received_headers_callback (gconstpointer in,
continue;
/* Icecast stuff */
if (!strncmp (data, "icy-metaint:", 12)) /* ugh */
{
if (!strncmp (data, "icy-metaint:", 12)) { /* ugh */
sscanf (data + 12, "%d", &icy_metaint);
src->icy_metaint = icy_metaint;
GST_DEBUG ("got icy-metaint %d, killing audiocast thread",
@ -836,14 +831,12 @@ gst_gnomevfssrc_push_callbacks (GstGnomeVFSSrc *gnomevfssrc)
return;
GST_DEBUG ("pushing callbacks");
gnome_vfs_module_callback_push (GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS,
gst_gnomevfssrc_send_additional_headers_callback,
gnomevfssrc,
NULL);
gnome_vfs_module_callback_push (GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS,
gst_gnomevfssrc_received_headers_callback,
gnomevfssrc,
NULL);
gnome_vfs_module_callback_push
(GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS,
gst_gnomevfssrc_send_additional_headers_callback, gnomevfssrc, NULL);
gnome_vfs_module_callback_push
(GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS,
gst_gnomevfssrc_received_headers_callback, gnomevfssrc, NULL);
gnomevfssrc->http_callbacks_pushed = TRUE;
}
@ -855,8 +848,10 @@ gst_gnomevfssrc_pop_callbacks (GstGnomeVFSSrc *gnomevfssrc)
return;
GST_DEBUG ("popping callbacks");
gnome_vfs_module_callback_pop (GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS);
gnome_vfs_module_callback_pop (GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS);
gnome_vfs_module_callback_pop
(GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS);
gnome_vfs_module_callback_pop
(GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS);
}
static void
@ -889,8 +884,7 @@ gst_gnomevfssrc_get_icy_metadata (GstGnomeVFSSrc *src)
while (pos - data < metadata_length) {
res = gnome_vfs_read (src->handle, pos,
metadata_length - (pos - data),
&length);
metadata_length - (pos - data), &length);
/* FIXME: better error handling here? */
if (res != GNOME_VFS_OK) {
g_free (data);
@ -903,32 +897,25 @@ gst_gnomevfssrc_get_icy_metadata (GstGnomeVFSSrc *src)
data[metadata_length] = 0;
tags = g_strsplit (data, "';", 0);
for (i = 0; tags[i]; i++)
{
if (!g_ascii_strncasecmp(tags[i], "StreamTitle=", 12))
{
for (i = 0; tags[i]; i++) {
if (!g_ascii_strncasecmp (tags[i], "StreamTitle=", 12)) {
g_free (src->iradio_title);
src->iradio_title = gst_gnomevfssrc_unicodify (tags[i] + 13);
if (src->iradio_title)
{
if (src->iradio_title) {
GST_DEBUG ("sending notification on icecast title");
g_object_notify (G_OBJECT (src), "iradio-title");
}
else
} else
g_print ("Unable to convert icecast title \"%s\" to UTF-8!\n",
tags[i] + 13);
}
if (!g_ascii_strncasecmp(tags[i], "StreamUrl=", 10))
{
if (!g_ascii_strncasecmp (tags[i], "StreamUrl=", 10)) {
g_free (src->iradio_url);
src->iradio_url = gst_gnomevfssrc_unicodify (tags[i] + 11);
if (src->iradio_url)
{
if (src->iradio_url) {
GST_DEBUG ("sending notification on icecast url");
g_object_notify (G_OBJECT (src), "iradio-url");
}
else
} else
g_print ("Unable to convert icecast url \"%s\" to UTF-8!\n",
tags[i] + 11);
}
@ -945,7 +932,8 @@ gst_gnomevfssrc_get_icy_metadata (GstGnomeVFSSrc *src)
*
* Push a new buffer from the gnomevfssrc at the current offset.
*/
static GstData *gst_gnomevfssrc_get(GstPad *pad)
static GstData *
gst_gnomevfssrc_get (GstPad * pad)
{
GstGnomeVFSSrc *src;
GnomeVFSResult result = 0;
@ -955,12 +943,10 @@ static GstData *gst_gnomevfssrc_get(GstPad *pad)
g_return_val_if_fail (pad != NULL, NULL);
src = GST_GNOMEVFSSRC (gst_pad_get_parent (pad));
g_return_val_if_fail(GST_FLAG_IS_SET(src, GST_GNOMEVFSSRC_OPEN),
NULL);
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_GNOMEVFSSRC_OPEN), NULL);
/* deal with EOF state */
if ((src->curoffset >= src->size) && (src->size != 0))
{
if ((src->curoffset >= src->size) && (src->size != 0)) {
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
@ -980,8 +966,7 @@ static GstData *gst_gnomevfssrc_get(GstPad *pad)
GST_BUFFER_SIZE (buf) = 0;
GST_DEBUG ("doing read: icy_count: %" G_GINT64_FORMAT, src->icy_count);
result = gnome_vfs_read (src->handle, data,
src->icy_metaint - src->icy_count,
&readbytes);
src->icy_metaint - src->icy_count, &readbytes);
/* EOS? */
if (readbytes == 0) {
@ -1007,6 +992,7 @@ static GstData *gst_gnomevfssrc_get(GstPad *pad)
if (src->need_flush) {
GstEvent *event = gst_event_new_flush ();
src->need_flush = FALSE;
gst_buffer_unref (buf);
GST_DEBUG ("gnomevfssrc sending flush");
@ -1015,11 +1001,14 @@ static GstData *gst_gnomevfssrc_get(GstPad *pad)
if (src->new_seek) {
GstEvent *event;
gst_buffer_unref (buf);
GST_DEBUG ("new seek %" G_GINT64_FORMAT, src->curoffset);
src->new_seek = FALSE;
GST_DEBUG ("gnomevfssrc sending discont");
event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL);
event =
gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset,
NULL);
return GST_DATA (event);
}
@ -1029,8 +1018,7 @@ static GstData *gst_gnomevfssrc_get(GstPad *pad)
GST_DEBUG ("read: %s, readbytes: %" G_GINT64_FORMAT,
gnome_vfs_result_to_string (result), readbytes);
/* deal with EOS */
if (readbytes == 0)
{
if (readbytes == 0) {
gst_buffer_unref (buf);
gst_element_set_eos (GST_ELEMENT (src));
@ -1050,20 +1038,21 @@ static GstData *gst_gnomevfssrc_get(GstPad *pad)
}
/* open the file, do stuff necessary to go to READY state */
static gboolean gst_gnomevfssrc_open_file(GstGnomeVFSSrc *src)
static gboolean
gst_gnomevfssrc_open_file (GstGnomeVFSSrc * src)
{
GnomeVFSResult result;
GnomeVFSFileInfo *info;
g_return_val_if_fail(!GST_FLAG_IS_SET(src, GST_GNOMEVFSSRC_OPEN),
FALSE);
g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_GNOMEVFSSRC_OPEN), FALSE);
if (src->filename) {
/* create the uri */
src->uri = gnome_vfs_uri_new (src->filename);
if (!src->uri) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
(_("Could not open vfs file \"%s\" for reading."), src->filename), GST_ERROR_SYSTEM);
(_("Could not open vfs file \"%s\" for reading."), src->filename),
GST_ERROR_SYSTEM);
return FALSE;
}
}
@ -1074,8 +1063,7 @@ static gboolean gst_gnomevfssrc_open_file(GstGnomeVFSSrc *src)
gst_gnomevfssrc_push_callbacks (src);
if (src->filename)
result = gnome_vfs_open_uri(&(src->handle), src->uri,
GNOME_VFS_OPEN_READ);
result = gnome_vfs_open_uri (&(src->handle), src->uri, GNOME_VFS_OPEN_READ);
else
result = GNOME_VFS_OK;
if (result != GNOME_VFS_OK) {
@ -1095,12 +1083,10 @@ static gboolean gst_gnomevfssrc_open_file(GstGnomeVFSSrc *src)
info = gnome_vfs_file_info_new ();
if (gnome_vfs_get_file_info_from_handle (src->handle, info,
GNOME_VFS_FILE_INFO_DEFAULT)
== GNOME_VFS_OK)
{
== GNOME_VFS_OK) {
if (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE)
src->size = info->size;
}
else
} else
GST_DEBUG ("getting info failed: %s", gnome_vfs_result_to_string (result));
gnome_vfs_file_info_unref (info);
@ -1123,7 +1109,8 @@ static gboolean gst_gnomevfssrc_open_file(GstGnomeVFSSrc *src)
return TRUE;
}
static void gst_gnomevfssrc_close_file(GstGnomeVFSSrc *src)
static void
gst_gnomevfssrc_close_file (GstGnomeVFSSrc * src)
{
g_return_if_fail (GST_FLAG_IS_SET (src, GST_GNOMEVFSSRC_OPEN));
@ -1142,23 +1129,21 @@ static void gst_gnomevfssrc_close_file(GstGnomeVFSSrc *src)
GST_FLAG_UNSET (src, GST_GNOMEVFSSRC_OPEN);
}
static GstElementStateReturn gst_gnomevfssrc_change_state(GstElement *element)
static GstElementStateReturn
gst_gnomevfssrc_change_state (GstElement * element)
{
g_return_val_if_fail(GST_IS_GNOMEVFSSRC(element),
GST_STATE_FAILURE);
g_return_val_if_fail (GST_IS_GNOMEVFSSRC (element), GST_STATE_FAILURE);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_READY_TO_PAUSED:
if (!GST_FLAG_IS_SET (element, GST_GNOMEVFSSRC_OPEN)) {
if (!gst_gnomevfssrc_open_file
(GST_GNOMEVFSSRC(element)))
if (!gst_gnomevfssrc_open_file (GST_GNOMEVFSSRC (element)))
return GST_STATE_FAILURE;
}
break;
case GST_STATE_PAUSED_TO_READY:
if (GST_FLAG_IS_SET (element, GST_GNOMEVFSSRC_OPEN))
gst_gnomevfssrc_close_file(GST_GNOMEVFSSRC
(element));
gst_gnomevfssrc_close_file (GST_GNOMEVFSSRC (element));
break;
case GST_STATE_NULL_TO_READY:
case GST_STATE_READY_TO_NULL:
@ -1167,8 +1152,7 @@ static GstElementStateReturn gst_gnomevfssrc_change_state(GstElement *element)
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS(parent_class)->
change_state(element);
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
@ -1240,8 +1224,7 @@ gst_gnomevfssrc_srcpad_event (GstPad *pad, GstEvent *event)
result = gnome_vfs_seek (src->handle,
GNOME_VFS_SEEK_START, desired_offset);
GST_DEBUG ("new_seek: %s",
gnome_vfs_result_to_string(result));
GST_DEBUG ("new_seek: %s", gnome_vfs_result_to_string (result));
if (result != GNOME_VFS_OK) {
gst_event_unref (event);

View file

@ -40,7 +40,8 @@ GST_DEBUG_CATEGORY_STATIC (gst_ogg_demux_debug);
typedef struct _GstOggDemux GstOggDemux;
typedef struct _GstOggDemuxClass GstOggDemuxClass;
typedef enum {
typedef enum
{
/* just because you shouldn't make a valid enum value 0 */
GST_OGG_STATE_INAVLID,
/* just started, we need to decide if we should do setup */
@ -54,7 +55,8 @@ typedef enum {
} GstOggState;
/* all information needed for one ogg stream */
typedef struct {
typedef struct
{
GstPad *pad; /* reference for this pad is held by element we belong to */
gint serial;
@ -69,16 +71,19 @@ typedef struct {
guint flags;
} GstOggPad;
typedef enum {
typedef enum
{
GST_OGG_PAD_NEEDS_DISCONT = (1 << 0),
GST_OGG_PAD_NEEDS_FLUSH = (1 << 1)
}
GstOggPadFlags;
/* all information needed for one ogg chain (relevant for chained bitstreams) */
typedef struct {
typedef struct
{
GSList *pads; /* list of GstOggPad */
} GstOggChain;
#define CURRENT_CHAIN(ogg) (&g_array_index ((ogg)->chains, GstOggChain, (ogg)->current_chain))
#define FOR_PAD_IN_CURRENT_CHAIN(ogg, _pad, ...) G_STMT_START{ \
GSList *_walk; \
@ -88,13 +93,15 @@ typedef struct {
} \
}G_STMT_END
typedef enum {
typedef enum
{
GST_OGG_FLAG_BOS = GST_ELEMENT_FLAG_LAST,
GST_OGG_FLAG_EOS,
GST_OGG_FLAG_WAIT_FOR_DISCONT
} GstOggFlag;
struct _GstOggDemux {
struct _GstOggDemux
{
GstElement element;
/* pad */
@ -114,41 +121,40 @@ struct _GstOggDemux {
guint64 seek_to;
};
struct _GstOggDemuxClass {
struct _GstOggDemuxClass
{
GstElementClass parent_class;
};
/* elementfactory information */
static GstElementDetails gst_ogg_demux_details = GST_ELEMENT_DETAILS (
"ogg demuxer",
static GstElementDetails gst_ogg_demux_details =
GST_ELEMENT_DETAILS ("ogg demuxer",
"Codec/Demuxer",
"demux ogg streams (info about ogg: http://xiph.org)",
"Benjamin Otte <in7y118@public.uni-hamburg.de>"
);
"Benjamin Otte <in7y118@public.uni-hamburg.de>");
/* signals and args */
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
/* FILL ME */
};
static GstStaticPadTemplate ogg_demux_src_template_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS_ANY
);
GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate ogg_demux_sink_template_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/ogg")
@ -157,31 +163,22 @@ GST_STATIC_PAD_TEMPLATE (
static void gst_ogg_demux_finalize (GObject * object);
static gboolean gst_ogg_demux_src_event (GstPad * pad,
GstEvent * event);
static gboolean gst_ogg_demux_src_event (GstPad * pad, GstEvent * event);
static const GstEventMask *gst_ogg_demux_get_event_masks (GstPad * pad);
static const GstQueryType *gst_ogg_demux_get_query_types (GstPad * pad);
static gboolean gst_ogg_demux_src_query (GstPad * pad,
GstQueryType type,
GstFormat * format,
gint64 * value);
GstQueryType type, GstFormat * format, gint64 * value);
static void gst_ogg_demux_chain (GstPad * pad,
GstData * buffer);
static void gst_ogg_demux_chain (GstPad * pad, GstData * buffer);
static GstElementStateReturn gst_ogg_demux_change_state (GstElement * element);
static GstOggPad * gst_ogg_pad_new (GstOggDemux * ogg,
int serial_no);
static void gst_ogg_pad_remove (GstOggDemux * ogg,
GstOggPad * ogg_pad);
static void gst_ogg_pad_reset (GstOggDemux * ogg,
GstOggPad * pad);
static void gst_ogg_demux_push (GstOggDemux * ogg,
ogg_page * page);
static void gst_ogg_pad_push (GstOggDemux * ogg,
GstOggPad * ogg_pad);
static GstOggPad *gst_ogg_pad_new (GstOggDemux * ogg, int serial_no);
static void gst_ogg_pad_remove (GstOggDemux * ogg, GstOggPad * ogg_pad);
static void gst_ogg_pad_reset (GstOggDemux * ogg, GstOggPad * pad);
static void gst_ogg_demux_push (GstOggDemux * ogg, ogg_page * page);
static void gst_ogg_pad_push (GstOggDemux * ogg, GstOggPad * ogg_pad);
static GstCaps *gst_ogg_type_find (ogg_packet * packet);
@ -194,8 +191,7 @@ static void gst_ogg_print (GstOggDemux * demux);
GST_BOILERPLATE (GstOggDemux, gst_ogg_demux, GstElement, GST_TYPE_ELEMENT)
static void
gst_ogg_demux_base_init (gpointer g_class)
static void gst_ogg_demux_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
@ -220,10 +216,12 @@ static void
gst_ogg_demux_init (GstOggDemux * ogg)
{
/* create the sink pad */
ogg->sinkpad = gst_pad_new_from_template(
gst_static_pad_template_get (&ogg_demux_sink_template_factory), "sink");
ogg->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&ogg_demux_sink_template_factory), "sink");
gst_element_add_pad (GST_ELEMENT (ogg), ogg->sinkpad);
gst_pad_set_chain_function (ogg->sinkpad, GST_DEBUG_FUNCPTR (gst_ogg_demux_chain));
gst_pad_set_chain_function (ogg->sinkpad,
GST_DEBUG_FUNCPTR (gst_ogg_demux_chain));
/* initalize variables */
GST_OGG_SET_STATE (ogg, GST_OGG_STATE_START);
@ -249,8 +247,7 @@ static const GstEventMask*
gst_ogg_demux_get_event_masks (GstPad * pad)
{
static const GstEventMask gst_ogg_demux_src_event_masks[] = {
{ GST_EVENT_SEEK, GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH },
{GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH},
{0,}
};
return gst_ogg_demux_src_event_masks;
@ -331,12 +328,14 @@ gst_ogg_demux_src_event (GstPad *pad, GstEvent *event)
cur = gst_ogg_get_pad_by_pad (ogg, pad);
/* FIXME: optimize this so events from inactive chains work?
* in theory there shouldn't be an exisiting pad for inactive chains */
if (cur == NULL) goto error;
if (cur == NULL)
goto error;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
{
gint64 offset;
if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_DEFAULT)
goto error;
offset = GST_EVENT_SEEK_OFFSET (event);
@ -356,21 +355,22 @@ gst_ogg_demux_src_event (GstPad *pad, GstEvent *event)
goto error;
}
if (offset < cur->known_offset) {
GstEvent *restart = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET | GST_EVENT_SEEK_FLAGS (event), 0);
GstEvent *restart =
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET |
GST_EVENT_SEEK_FLAGS (event), 0);
if (!gst_pad_send_event (GST_PAD_PEER (ogg->sinkpad), restart))
goto error;
} else {
FOR_PAD_IN_CURRENT_CHAIN (ogg, pad,
if (GST_PAD_IS_USABLE (pad->pad))
gst_pad_push (pad->pad, GST_DATA (gst_event_new (GST_EVENT_FLUSH)));
);
FOR_PAD_IN_CURRENT_CHAIN (ogg, pad, if (GST_PAD_IS_USABLE (pad->pad))
gst_pad_push (pad->pad,
GST_DATA (gst_event_new (GST_EVENT_FLUSH))););
}
GST_OGG_SET_STATE (ogg, GST_OGG_STATE_SEEK);
FOR_PAD_IN_CURRENT_CHAIN (ogg, pad,
pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;
);
GST_DEBUG_OBJECT (ogg, "initiating seeking to offset %"G_GUINT64_FORMAT, offset);
pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;);
GST_DEBUG_OBJECT (ogg, "initiating seeking to offset %" G_GUINT64_FORMAT,
offset);
ogg->seek_pad = cur;
ogg->seek_to = offset;
gst_event_unref (event);
@ -415,8 +415,7 @@ gst_ogg_demux_handle_event (GstPad *pad, GstEvent *event)
gst_event_unref (event);
GST_FLAG_UNSET (ogg, GST_OGG_FLAG_WAIT_FOR_DISCONT);
FOR_PAD_IN_CURRENT_CHAIN (ogg, pad,
pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;
);
pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;);
break;
case GST_EVENT_EOS:
if (ogg->state == GST_OGG_STATE_SETUP) {
@ -424,12 +423,15 @@ gst_ogg_demux_handle_event (GstPad *pad, GstEvent *event)
} else {
guint i;
GSList *walk;
GST_DEBUG_OBJECT (ogg, "got EOS");
ogg->current_chain = -1;
for (i = 0; i < ogg->chains->len; i++) {
GstOggChain *chain = &g_array_index (ogg->chains, GstOggChain, i);
for (walk = chain->pads; walk; walk = g_slist_next (walk)) {
GstOggPad *pad = (GstOggPad *) walk->data;
if (pad->pad && GST_PAD_IS_USABLE (pad->pad)) {
gst_data_ref (GST_DATA (event));
gst_pad_push (pad->pad, GST_DATA (event));
@ -453,11 +455,13 @@ gst_ogg_pad_get_in_current_chain (GstOggDemux *ogg, int serial)
{
GSList *walk;
if (ogg->current_chain == -1) return NULL;
if (ogg->current_chain == -1)
return NULL;
g_return_val_if_fail (ogg->current_chain < ogg->chains->len, NULL);
for (walk = CURRENT_CHAIN (ogg)->pads; walk; walk = g_slist_next (walk)) {
GstOggPad *pad = (GstOggPad *) walk->data;
if (pad->serial == serial)
return pad;
}
@ -494,17 +498,18 @@ gst_ogg_demux_chain (GstPad *pad, GstData *buffer)
return;
}
GST_LOG_OBJECT (ogg, "queueing buffer %p with offset %llu", buffer, GST_BUFFER_OFFSET (buffer));
GST_LOG_OBJECT (ogg, "queueing buffer %p with offset %llu", buffer,
GST_BUFFER_OFFSET (buffer));
data = (guint8 *) ogg_sync_buffer (&ogg->sync, GST_BUFFER_SIZE (buffer));
memcpy (data, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
if (ogg_sync_wrote (&ogg->sync, GST_BUFFER_SIZE (buffer)) != 0) {
gst_data_unref (buffer);
GST_ELEMENT_ERROR (ogg, LIBRARY, TOO_LAZY, (NULL), ("ogg_sync_wrote failed"));
GST_ELEMENT_ERROR (ogg, LIBRARY, TOO_LAZY, (NULL),
("ogg_sync_wrote failed"));
return;
}
offset_end = GST_BUFFER_OFFSET_IS_VALID (buffer) ?
GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) :
(guint64) -1;
GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) : (guint64) - 1;
gst_data_unref (buffer);
while (pageout_ret != 0) {
ogg_page page;
@ -519,7 +524,9 @@ gst_ogg_demux_chain (GstPad *pad, GstData *buffer)
if (ogg->state == GST_OGG_STATE_SETUP) {
guint64 length;
GstFormat format = GST_FORMAT_BYTES;
if (!gst_pad_query (GST_PAD_PEER (ogg->sinkpad), GST_QUERY_TOTAL, &format, &length))
if (!gst_pad_query (GST_PAD_PEER (ogg->sinkpad), GST_QUERY_TOTAL,
&format, &length))
length = 0;
if (length <= offset_end) {
gst_ogg_start_playing (ogg);
@ -528,32 +535,42 @@ gst_ogg_demux_chain (GstPad *pad, GstData *buffer)
}
break;
case 1:
GST_LOG_OBJECT (ogg, "processing ogg page (serial %d, packet %ld, granule pos %llu",
ogg_page_serialno (&page), ogg_page_pageno (&page), ogg_page_granulepos (&page));
GST_LOG_OBJECT (ogg,
"processing ogg page (serial %d, packet %ld, granule pos %llu",
ogg_page_serialno (&page), ogg_page_pageno (&page),
ogg_page_granulepos (&page));
switch (ogg->state) {
case GST_OGG_STATE_SETUP:
if (ogg_page_eos (&page)) {
GstOggPad *cur = gst_ogg_pad_get_in_current_chain (ogg, ogg_page_serialno (&page));
GstOggPad *cur = gst_ogg_pad_get_in_current_chain (ogg,
ogg_page_serialno (&page));
GST_FLAG_SET (ogg, GST_OGG_FLAG_EOS);
if (!cur) {
GST_ERROR_OBJECT (ogg, "unknown serial %d", ogg_page_serialno (&page));
GST_ERROR_OBJECT (ogg, "unknown serial %d",
ogg_page_serialno (&page));
} else {
cur->pages = ogg_page_pageno (&page);
cur->length = ogg_page_granulepos (&page);
}
} else {
if (GST_FLAG_IS_SET (ogg, GST_OGG_FLAG_EOS) && ogg_page_bos (&page)) {
if (GST_FLAG_IS_SET (ogg, GST_OGG_FLAG_EOS)
&& ogg_page_bos (&page)) {
gst_ogg_add_chain (ogg);
}
GST_FLAG_UNSET (ogg, GST_OGG_FLAG_EOS);
}
if (ogg_page_bos (&page)) {
if (gst_ogg_pad_get_in_current_chain (ogg, ogg_page_serialno (&page))) {
GST_ERROR_OBJECT (ogg, "multiple BOS page for serial %d (page %ld)",
if (gst_ogg_pad_get_in_current_chain (ogg,
ogg_page_serialno (&page))) {
GST_ERROR_OBJECT (ogg,
"multiple BOS page for serial %d (page %ld)",
ogg_page_serialno (&page), ogg_page_pageno (&page));
} else {
GstOggPad *pad = gst_ogg_pad_new (ogg, ogg_page_serialno (&page));
CURRENT_CHAIN (ogg)->pads = g_slist_prepend (CURRENT_CHAIN (ogg)->pads, pad);
GstOggPad *pad =
gst_ogg_pad_new (ogg, ogg_page_serialno (&page));
CURRENT_CHAIN (ogg)->pads =
g_slist_prepend (CURRENT_CHAIN (ogg)->pads, pad);
}
GST_FLAG_SET (ogg, GST_OGG_FLAG_BOS);
} else {
@ -562,11 +579,13 @@ gst_ogg_demux_chain (GstPad *pad, GstData *buffer)
break;
case GST_OGG_STATE_START:
if (gst_pad_send_event (GST_PAD_PEER (ogg->sinkpad),
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_END, 0))) {
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_END,
0))) {
GST_OGG_SET_STATE (ogg, GST_OGG_STATE_SETUP);
GST_DEBUG_OBJECT (ogg, "stream can seek, try setup now");
if (!gst_pad_send_event (GST_PAD_PEER (ogg->sinkpad),
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, 0))) {
gst_event_new_seek (GST_FORMAT_BYTES |
GST_SEEK_METHOD_SET, 0))) {
GST_ELEMENT_ERROR (ogg, CORE, SEEK, (NULL),
("stream can seek to end, but not to start. Can't handle that."));
}
@ -587,7 +606,8 @@ gst_ogg_demux_chain (GstPad *pad, GstData *buffer)
}
break;
default:
GST_WARNING_OBJECT (ogg, "unknown return value %d from ogg_sync_pageout", pageout_ret);
GST_WARNING_OBJECT (ogg,
"unknown return value %d from ogg_sync_pageout", pageout_ret);
pageout_ret = 0;
break;
}
@ -603,13 +623,15 @@ gst_ogg_pad_new (GstOggDemux *ogg, int serial)
ret->serial = serial;
if (ogg_stream_init (&ret->stream, serial) != 0) {
GST_ERROR_OBJECT (ogg, "Could not initialize ogg_stream struct for serial %d.", serial);
GST_ERROR_OBJECT (ogg,
"Could not initialize ogg_stream struct for serial %d.", serial);
g_free (ret);
return NULL;
}
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_SERIAL, serial, NULL);
gst_element_found_tags (GST_ELEMENT (ogg), list);
GST_LOG_OBJECT (ogg, "created new ogg src %p for stream with serial %d", ret, serial);
GST_LOG_OBJECT (ogg, "created new ogg src %p for stream with serial %d", ret,
serial);
return ret;
}
@ -626,8 +648,11 @@ gst_ogg_pad_remove (GstOggDemux *ogg, GstOggPad *pad)
gst_element_remove_pad (GST_ELEMENT (ogg), pad->pad);
}
if (ogg_stream_clear (&pad->stream) != 0)
GST_ERROR_OBJECT (ogg, "ogg_stream_clear (serial %d) did not return 0, ignoring this error", pad->serial);
GST_LOG_OBJECT (ogg, "free ogg src %p for stream with serial %d", pad, pad->serial);
GST_ERROR_OBJECT (ogg,
"ogg_stream_clear (serial %d) did not return 0, ignoring this error",
pad->serial);
GST_LOG_OBJECT (ogg, "free ogg src %p for stream with serial %d", pad,
pad->serial);
g_free (pad);
}
static void
@ -648,42 +673,51 @@ br:
/* now we either have a stream (cur) or not */
if (ogg_page_bos (page)) {
if (cur) {
GST_DEBUG_OBJECT (ogg, "ogg page declared as BOS while stream %d already existed."
GST_DEBUG_OBJECT (ogg,
"ogg page declared as BOS while stream %d already existed."
"Possibly a seek happened.", cur->serial);
} else if (cur) {
GST_DEBUG_OBJECT (ogg, "reactivating deactivated stream %d.", cur->serial);
GST_DEBUG_OBJECT (ogg, "reactivating deactivated stream %d.",
cur->serial);
} else {
/* FIXME: monitor if we are still in creation stage? */
cur = gst_ogg_pad_new (ogg, ogg_page_serialno (page));
if (!cur) {
GST_ELEMENT_ERROR (ogg, LIBRARY, TOO_LAZY, (NULL), ("Creating ogg_stream struct failed."));
GST_ELEMENT_ERROR (ogg, LIBRARY, TOO_LAZY, (NULL),
("Creating ogg_stream struct failed."));
return;
}
if (ogg->current_chain == -1) {
/* add new one at the end */
gst_ogg_add_chain (ogg);
}
CURRENT_CHAIN (ogg)->pads = g_slist_prepend (CURRENT_CHAIN (ogg)->pads, cur);
CURRENT_CHAIN (ogg)->pads =
g_slist_prepend (CURRENT_CHAIN (ogg)->pads, cur);
}
}
if (cur == NULL) {
GST_ELEMENT_ERROR (ogg, STREAM, DECODE, (NULL), ("invalid ogg stream serial no"));
GST_ELEMENT_ERROR (ogg, STREAM, DECODE, (NULL),
("invalid ogg stream serial no"));
return;
}
if (ogg_stream_pagein (&cur->stream, page) != 0) {
GST_WARNING_OBJECT (ogg, "ogg stream choked on page (serial %d), resetting stream", cur->serial);
GST_WARNING_OBJECT (ogg,
"ogg stream choked on page (serial %d), resetting stream", cur->serial);
gst_ogg_pad_reset (ogg, cur);
return;
}
switch (ogg->state) {
case GST_OGG_STATE_SEEK:
GST_LOG_OBJECT (ogg, "in seek - offset now: %"G_GUINT64_FORMAT" (pad %d) - desired offset %"
G_GUINT64_FORMAT" (pad %d)", cur->known_offset, cur->serial,
ogg->seek_to, ogg->seek_pad->serial);
GST_LOG_OBJECT (ogg,
"in seek - offset now: %" G_GUINT64_FORMAT
" (pad %d) - desired offset %" G_GUINT64_FORMAT " (pad %d)",
cur->known_offset, cur->serial, ogg->seek_to, ogg->seek_pad->serial);
if (cur == ogg->seek_pad) {
if (ogg_page_granulepos (page) > ogg->seek_to) {
GST_OGG_SET_STATE (ogg, GST_OGG_STATE_PLAY);
GST_DEBUG_OBJECT (ogg, "ended seek at offset %"G_GUINT64_FORMAT" (requested %"G_GUINT64_FORMAT, cur->known_offset, ogg->seek_to);
GST_DEBUG_OBJECT (ogg,
"ended seek at offset %" G_GUINT64_FORMAT " (requested %"
G_GUINT64_FORMAT, cur->known_offset, ogg->seek_to);
ogg->seek_pad = NULL;
ogg->seek_to = 0;
}
@ -734,17 +768,22 @@ gst_ogg_pad_push (GstOggDemux *ogg, GstOggPad *pad)
gchar *name = g_strdup_printf ("serial_%d", pad->serial);
if (caps == NULL) {
GST_WARNING_OBJECT (ogg, "couldn't find caps for stream with serial %d", pad->serial);
GST_WARNING_OBJECT (ogg,
"couldn't find caps for stream with serial %d", pad->serial);
caps = gst_caps_new_simple ("application/octet-stream", NULL);
}
pad->pad = gst_pad_new_from_template (
gst_static_pad_template_get (&ogg_demux_src_template_factory),
name);
pad->pad =
gst_pad_new_from_template (gst_static_pad_template_get
(&ogg_demux_src_template_factory), name);
g_free (name);
gst_pad_set_event_function (pad->pad, GST_DEBUG_FUNCPTR (gst_ogg_demux_src_event));
gst_pad_set_event_mask_function (pad->pad, GST_DEBUG_FUNCPTR (gst_ogg_demux_get_event_masks));
gst_pad_set_query_function (pad->pad, GST_DEBUG_FUNCPTR (gst_ogg_demux_src_query));
gst_pad_set_query_type_function (pad->pad, GST_DEBUG_FUNCPTR (gst_ogg_demux_get_query_types));
gst_pad_set_event_function (pad->pad,
GST_DEBUG_FUNCPTR (gst_ogg_demux_src_event));
gst_pad_set_event_mask_function (pad->pad,
GST_DEBUG_FUNCPTR (gst_ogg_demux_get_event_masks));
gst_pad_set_query_function (pad->pad,
GST_DEBUG_FUNCPTR (gst_ogg_demux_src_query));
gst_pad_set_query_type_function (pad->pad,
GST_DEBUG_FUNCPTR (gst_ogg_demux_get_query_types));
gst_pad_use_explicit_caps (pad->pad);
gst_pad_set_explicit_caps (pad->pad, caps);
gst_pad_set_active (pad->pad, TRUE);
@ -756,14 +795,18 @@ gst_ogg_pad_push (GstOggDemux *ogg, GstOggPad *pad)
pad->packetno = packet.packetno + 1;
}
/* send discont if needed */
if ((pad->flags & GST_OGG_PAD_NEEDS_DISCONT) && GST_PAD_IS_USABLE (pad->pad)) {
if ((pad->flags & GST_OGG_PAD_NEEDS_DISCONT)
&& GST_PAD_IS_USABLE (pad->pad)) {
GstEvent *event = gst_event_new_discontinuous (FALSE,
GST_FORMAT_DEFAULT, pad->known_offset); /* FIXME: this might be wrong because we can only use the last known offset */
gst_pad_push (pad->pad, GST_DATA (event));
pad->flags &= (~GST_OGG_PAD_NEEDS_DISCONT);
};
/* optimization: use a bufferpool containing the ogg packet? */
buf = gst_pad_alloc_buffer (pad->pad, GST_BUFFER_OFFSET_NONE, packet.bytes);
buf =
gst_pad_alloc_buffer (pad->pad, GST_BUFFER_OFFSET_NONE,
packet.bytes);
memcpy (buf->data, packet.packet, packet.bytes);
if (pad->offset != -1)
GST_BUFFER_OFFSET (buf) = pad->offset;
@ -775,7 +818,9 @@ gst_ogg_pad_push (GstOggDemux *ogg, GstOggPad *pad)
break;
}
default:
GST_ERROR_OBJECT (ogg, "invalid return value %d for ogg_stream_packetout, resetting stream", ret);
GST_ERROR_OBJECT (ogg,
"invalid return value %d for ogg_stream_packetout, resetting stream",
ret);
gst_ogg_pad_reset (ogg, pad);
break;
}
@ -797,6 +842,7 @@ gst_ogg_chains_clear (GstOggDemux *ogg)
for (i = ogg->chains->len - 1; i >= 0; i--) {
GstOggChain *cur = &g_array_index (ogg->chains, GstOggChain, i);
for (walk = cur->pads; walk; walk = g_slist_next (walk)) {
gst_ogg_pad_remove (ogg, (GstOggPad *) walk->data);
}
@ -846,7 +892,8 @@ gst_ogg_demux_change_state (GstElement *element)
* packet of an ogg stream must identify the stream. Therefore ogg can use a
* simplified approach at typefinding.
*/
typedef struct {
typedef struct
{
ogg_packet *packet;
guint best_probability;
GstCaps *caps;
@ -908,32 +955,30 @@ plugin_init (GstPlugin *plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_ogg_demux_debug, "oggdemux", 0, "ogg demuxer");
return gst_element_register (plugin, "oggdemux", GST_RANK_PRIMARY, GST_TYPE_OGG_DEMUX);
return gst_element_register (plugin, "oggdemux", GST_RANK_PRIMARY,
GST_TYPE_OGG_DEMUX);
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"ogg",
"ogg stream manipulation (info about ogg: http://xiph.org)",
plugin_init,
VERSION,
GST_LICENSE,
GST_PACKAGE,
GST_ORIGIN
)
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
/* prints all info about the element */
static void
gst_ogg_print (GstOggDemux *ogg)
static void gst_ogg_print (GstOggDemux * ogg)
{
guint i;
GSList *walk;
for (i = 0; i < ogg->chains->len; i++) {
GstOggChain *chain = &g_array_index (ogg->chains, GstOggChain, i);
GST_INFO_OBJECT (ogg, "chain %d (%u streams):", i, g_slist_length (chain->pads));
GST_INFO_OBJECT (ogg, "chain %d (%u streams):", i,
g_slist_length (chain->pads));
for (walk = chain->pads; walk; walk = g_slist_next (walk)) {
GstOggPad *pad = (GstOggPad *) walk->data;
GST_INFO_OBJECT (ogg, " stream %d:", pad->serial);
GST_INFO_OBJECT (ogg, " length %" G_GUINT64_FORMAT, pad->length);
GST_INFO_OBJECT (ogg, " pages %ld", pad->pages);

View file

@ -17,7 +17,8 @@ static GstElementDetails textoverlay_details = {
"Gustavo J. A. M. Carneiro <gjc@inescporto.pt>"
};
enum {
enum
{
ARG_0,
ARG_TEXT,
ARG_VALIGN,
@ -29,30 +30,25 @@ enum {
static GstStaticPadTemplate textoverlay_src_template_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv, "
"format = (fourcc) I420, "
"width = (int) [ 1, MAX ], "
"height = (int) [ 1, MAX ]")
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
);
static GstStaticPadTemplate video_sink_template_factory =
GST_STATIC_PAD_TEMPLATE (
"video_sink",
GST_STATIC_PAD_TEMPLATE ("video_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv, "
"format = (fourcc) I420, "
"width = (int) [ 1, MAX ], "
"height = (int) [ 1, MAX ]")
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
);
static GstStaticPadTemplate text_sink_template_factory =
GST_STATIC_PAD_TEMPLATE (
"text_sink",
GST_STATIC_PAD_TEMPLATE ("text_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("text/x-pango-markup; text/plain")
@ -62,18 +58,16 @@ static void gst_textoverlay_base_init (gpointer g_class);
static void gst_textoverlay_class_init (GstTextOverlayClass * klass);
static void gst_textoverlay_init (GstTextOverlay * overlay);
static void gst_textoverlay_set_property (GObject * object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_textoverlay_get_property (GObject * object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static GstElementStateReturn gst_textoverlay_change_state(GstElement *element);
guint prop_id, GValue * value, GParamSpec * pspec);
static GstElementStateReturn gst_textoverlay_change_state (GstElement *
element);
static void gst_textoverlay_finalize (GObject * object);
static GstElementClass *parent_class = NULL;
/*static guint gst_textoverlay_signals[LAST_SIGNAL] = { 0 }; */
@ -94,7 +88,8 @@ gst_textoverlay_get_type(void)
0,
(GInstanceInitFunc) gst_textoverlay_init,
};
textoverlay_type = g_type_register_static(GST_TYPE_ELEMENT, "GstTextOverlay",
textoverlay_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstTextOverlay",
&textoverlay_info, 0);
}
return textoverlay_type;
@ -135,8 +130,7 @@ gst_textoverlay_class_init(GstTextOverlayClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TEXT,
g_param_spec_string ("text", "text",
"Text to be display,"
" in pango markup format.",
"", G_PARAM_WRITABLE));
" in pango markup format.", "", G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALIGN,
g_param_spec_string ("valign", "vertical alignment",
"Vertical alignment of the text. "
@ -151,22 +145,19 @@ gst_textoverlay_class_init(GstTextOverlayClass *klass)
g_param_spec_int ("x0", "X position",
"Initial X position."
" Horizontal aligment takes this point"
" as reference.",
G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
" as reference.", G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_Y0,
g_param_spec_int ("y0", "Y position",
"Initial Y position."
" Vertical aligment takes this point"
" as reference.",
G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
" as reference.", G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FONT_DESC,
g_param_spec_string ("font-desc", "font description",
"Pango font description of font "
"to be used for rendering. "
"See documentation of "
"pango_font_description_from_string"
" for syntax.",
"", G_PARAM_WRITABLE));
" for syntax.", "", G_PARAM_WRITABLE));
}
@ -269,6 +260,7 @@ gst_text_overlay_blit_yuv420(GstTextOverlay *overlay, FT_Bitmap *bitmap,
bitp = bitmap->buffer + bitmap->pitch * bitmap_y0 + bitmap_x0;
for (y = bitmap_y0; y < bitmap_height; y++) {
int n;
for (n = bitmap_width; n > 0; --n) {
v = *bitp;
if (v) {
@ -289,12 +281,15 @@ gst_text_overlay_blit_yuv420(GstTextOverlay *overlay, FT_Bitmap *bitmap,
x1 = x0 + bitmap_x0;
bitp = bitmap->buffer + bitmap->pitch * bitmap_y0 + bitmap_x0;
p = pixbuf + video_width * y1 + x1;
u_p = pixbuf + video_width*video_height + (video_width >> 1)*(y1 >> 1) + (x1 >> 1);
u_p =
pixbuf + video_width * video_height + (video_width >> 1) * (y1 >> 1) +
(x1 >> 1);
skip_y = 0;
skip_x = 0;
for (; y < bitmap_height; y++) {
int n;
x1 = x0 + bitmap_x0;
skip_x = 0;
for (n = bitmap_width; n > 0; --n) {
@ -307,7 +302,8 @@ gst_text_overlay_blit_yuv420(GstTextOverlay *overlay, FT_Bitmap *bitmap,
}
if (!skip_y) {
skip_x = !skip_x;
if (!skip_x) u_p++;
if (!skip_x)
u_p++;
}
p++;
bitp++;
@ -340,8 +336,7 @@ gst_textoverlay_video_chain(GstPad *pad, GstData *_data)
x0 = overlay->x0;
y0 = overlay->y0;
switch (overlay->valign)
{
switch (overlay->valign) {
case GST_TEXT_OVERLAY_VALIGN_BOTTOM:
y0 += overlay->bitmap.rows;
break;
@ -352,8 +347,7 @@ gst_textoverlay_video_chain(GstPad *pad, GstData *_data)
break;
}
switch (overlay->halign)
{
switch (overlay->halign) {
case GST_TEXT_OVERLAY_HALIGN_LEFT:
break;
case GST_TEXT_OVERLAY_HALIGN_RIGHT:
@ -468,8 +462,7 @@ gst_textoverlay_change_state(GstElement *element)
overlay = GST_TEXTOVERLAY (element);
switch (GST_STATE_TRANSITION(element))
{
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_PLAYING:
break;
case GST_STATE_PLAYING_TO_PAUSED:
@ -504,24 +497,29 @@ static void
gst_textoverlay_init (GstTextOverlay * overlay)
{
/* video sink */
overlay->video_sinkpad = gst_pad_new_from_template(
gst_static_pad_template_get (&video_sink_template_factory), "video_sink");
overlay->video_sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&video_sink_template_factory), "video_sink");
/* gst_pad_set_chain_function(overlay->video_sinkpad, gst_textoverlay_video_chain); */
gst_pad_set_link_function(overlay->video_sinkpad, gst_textoverlay_video_sinkconnect);
gst_pad_set_link_function (overlay->video_sinkpad,
gst_textoverlay_video_sinkconnect);
gst_element_add_pad (GST_ELEMENT (overlay), overlay->video_sinkpad);
/* text sink */
overlay->text_sinkpad = gst_pad_new_from_template(
gst_static_pad_template_get (&text_sink_template_factory), "text_sink");
overlay->text_sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&text_sink_template_factory), "text_sink");
/* gst_pad_set_link_function(overlay->text_sinkpad, gst_textoverlay_text_sinkconnect); */
gst_element_add_pad (GST_ELEMENT (overlay), overlay->text_sinkpad);
/* (video) source */
overlay->srcpad = gst_pad_new_from_template(
gst_static_pad_template_get (&textoverlay_src_template_factory), "src");
overlay->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&textoverlay_src_template_factory), "src");
gst_element_add_pad (GST_ELEMENT (overlay), overlay->srcpad);
overlay->layout = pango_layout_new(GST_TEXTOVERLAY_GET_CLASS(overlay)->pango_context);
overlay->layout =
pango_layout_new (GST_TEXTOVERLAY_GET_CLASS (overlay)->pango_context);
memset (&overlay->bitmap, 0, sizeof (overlay->bitmap));
overlay->halign = GST_TEXT_OVERLAY_HALIGN_CENTER;
@ -536,7 +534,8 @@ gst_textoverlay_init(GstTextOverlay *overlay)
static void
gst_textoverlay_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
gst_textoverlay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstTextOverlay *overlay;
@ -544,8 +543,7 @@ gst_textoverlay_set_property(GObject *object, guint prop_id, const GValue *value
g_return_if_fail (GST_IS_TEXTOVERLAY (object));
overlay = GST_TEXTOVERLAY (object);
switch (prop_id)
{
switch (prop_id) {
case ARG_TEXT:
if (overlay->default_text) {
@ -590,6 +588,7 @@ gst_textoverlay_set_property(GObject *object, guint prop_id, const GValue *value
case ARG_FONT_DESC:
{
PangoFontDescription *desc;
desc = pango_font_description_from_string (g_value_get_string (value));
if (desc) {
g_message ("font description set: %s", g_value_get_string (value));
@ -597,7 +596,8 @@ gst_textoverlay_set_property(GObject *object, guint prop_id, const GValue *value
pango_font_description_free (desc);
render_text (overlay);
} else
g_warning("font description parse failed: %s", g_value_get_string(value));
g_warning ("font description parse failed: %s",
g_value_get_string (value));
break;
}
@ -607,7 +607,8 @@ gst_textoverlay_set_property(GObject *object, guint prop_id, const GValue *value
}
static void
gst_textoverlay_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
gst_textoverlay_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstTextOverlay *overlay;
@ -625,7 +626,8 @@ gst_textoverlay_get_property(GObject *object, guint prop_id, GValue *value, GPar
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "textoverlay", GST_RANK_PRIMARY, GST_TYPE_TEXTOVERLAY))
if (!gst_element_register (plugin, "textoverlay", GST_RANK_PRIMARY,
GST_TYPE_TEXTOVERLAY))
return FALSE;
/*texttestsrc_plugin_init(module, plugin); */
@ -633,14 +635,7 @@ plugin_init(GstPlugin *plugin)
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"textoverlay",
"Text overlay",
plugin_init,
VERSION,
"GPL",
GST_PACKAGE,
GST_ORIGIN)
"Text overlay", plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)

View file

@ -6,7 +6,6 @@
#include <pango/pangoft2.h>
G_BEGIN_DECLS
#define GST_TYPE_TEXTOVERLAY (gst_textoverlay_get_type())
#define GST_TEXTOVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
GST_TYPE_TEXTOVERLAY, GstTextOverlay))
@ -18,27 +17,29 @@ G_BEGIN_DECLS
GST_TYPE_TEXTOVERLAY))
#define GST_IS_TEXTOVERLAY_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),\
GST_TYPE_TEXTOVERLAY))
typedef struct _GstTextOverlay GstTextOverlay;
typedef struct _GstTextOverlayClass GstTextOverlayClass;
typedef enum _GstTextOverlayVAlign GstTextOverlayVAlign;
typedef enum _GstTextOverlayHAlign GstTextOverlayHAlign;
enum _GstTextOverlayVAlign {
enum _GstTextOverlayVAlign
{
GST_TEXT_OVERLAY_VALIGN_BASELINE,
GST_TEXT_OVERLAY_VALIGN_BOTTOM,
GST_TEXT_OVERLAY_VALIGN_TOP,
};
enum _GstTextOverlayHAlign {
enum _GstTextOverlayHAlign
{
GST_TEXT_OVERLAY_HALIGN_LEFT,
GST_TEXT_OVERLAY_HALIGN_CENTER,
GST_TEXT_OVERLAY_HALIGN_RIGHT,
};
struct _GstTextOverlay {
struct _GstTextOverlay
{
GstElement element;
GstPad *video_sinkpad;
@ -60,14 +61,16 @@ struct _GstTextOverlay {
gboolean need_render;
};
struct _GstTextOverlayClass {
struct _GstTextOverlayClass
{
GstElementClass parent_class;
PangoContext *pango_context;
};
GType gst_textoverlay_get_type(void) G_GNUC_CONST;
GType
gst_textoverlay_get_type (void)
G_GNUC_CONST;
G_END_DECLS
#endif /* __GST_TEXTOVERLAY_H */

View file

@ -45,12 +45,14 @@
/* GstTimeoverlay signals and args */
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
/* FILL ME */
};
@ -59,10 +61,13 @@ static void gst_timeoverlay_base_init (gpointer g_class);
static void gst_timeoverlay_class_init (gpointer g_class, gpointer class_data);
static void gst_timeoverlay_init (GTypeInstance * instance, gpointer g_class);
static void gst_timeoverlay_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_timeoverlay_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void gst_timeoverlay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_timeoverlay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_timeoverlay_planar411(GstVideofilter *videofilter, void *dest, void *src);
static void gst_timeoverlay_planar411 (GstVideofilter * videofilter, void *dest,
void *src);
static void gst_timeoverlay_setup (GstVideofilter * videofilter);
GType
@ -96,12 +101,11 @@ static GstVideofilterFormat gst_timeoverlay_formats[] = {
static void
gst_timeoverlay_base_init (gpointer g_class)
{
static GstElementDetails timeoverlay_details = GST_ELEMENT_DETAILS (
"Time Overlay",
static GstElementDetails timeoverlay_details =
GST_ELEMENT_DETAILS ("Time Overlay",
"Filter/Editor/Video",
"Overlays the time on a video stream",
"David Schleef <ds@schleef.org>"
);
"David Schleef <ds@schleef.org>");
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
int i;
@ -152,7 +156,8 @@ gst_timeoverlay_init (GTypeInstance *instance, gpointer g_class)
}
static void
gst_timeoverlay_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
gst_timeoverlay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstTimeoverlay *src;
@ -173,7 +178,8 @@ gst_timeoverlay_set_property (GObject *object, guint prop_id, const GValue *valu
}
static void
gst_timeoverlay_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
gst_timeoverlay_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstTimeoverlay *src;
@ -193,7 +199,8 @@ gst_timeoverlay_get_property (GObject *object, guint prop_id, GValue *value, GPa
}
}
static gboolean plugin_init (GstPlugin *plugin)
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstvideofilter"))
return FALSE;
@ -202,17 +209,10 @@ static gboolean plugin_init (GstPlugin *plugin)
GST_TYPE_TIMEOVERLAY);
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"timeoverlay",
"Time overlay",
plugin_init,
VERSION,
GST_LICENSE,
GST_PACKAGE,
GST_ORIGIN
)
"Time overlay", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
static void gst_timeoverlay_setup (GstVideofilter * videofilter)
{
@ -246,7 +246,8 @@ static void gst_timeoverlay_setup(GstVideofilter *videofilter)
}
static char *gst_timeoverlay_print_smpte_time(guint64 time)
static char *
gst_timeoverlay_print_smpte_time (guint64 time)
{
int hours;
int minutes;
@ -267,8 +268,8 @@ static char *gst_timeoverlay_print_smpte_time(guint64 time)
return g_strdup_printf ("%02d:%02d:%02d.%03d", hours, minutes, seconds, ms);
}
static void gst_timeoverlay_planar411(GstVideofilter *videofilter,
void *dest, void *src)
static void
gst_timeoverlay_planar411 (GstVideofilter * videofilter, void *dest, void *src)
{
GstTimeoverlay *timeoverlay;
int width;
@ -290,7 +291,9 @@ static void gst_timeoverlay_planar411(GstVideofilter *videofilter,
height = gst_videofilter_get_input_height (videofilter);
layout = pango_layout_new (timeoverlay->context);
string = gst_timeoverlay_print_smpte_time(GST_BUFFER_TIMESTAMP(videofilter->in_buf));
string =
gst_timeoverlay_print_smpte_time (GST_BUFFER_TIMESTAMP (videofilter->
in_buf));
pango_layout_set_text (layout, string, strlen (string));
g_free (string);
@ -310,8 +313,8 @@ static void gst_timeoverlay_planar411(GstVideofilter *videofilter,
}
for (i = 0; i < b_height / 2; i++) {
memset (dest + width * height + i * (width / 2), 128, b_width / 2);
memset(dest + width*height + (width/2)*(height/2) + i*(width/2), 128,
b_width/2);
memset (dest + width * height + (width / 2) * (height / 2) +
i * (width / 2), 128, b_width / 2);
}
bitmap.rows = b_height;
bitmap.width = b_width;
@ -322,4 +325,3 @@ static void gst_timeoverlay_planar411(GstVideofilter *videofilter,
pango_ft2_render_layout (&bitmap, layout, 0, 0);
}

View file

@ -29,7 +29,6 @@
G_BEGIN_DECLS
#define GST_TYPE_TIMEOVERLAY \
(gst_timeoverlay_get_type())
#define GST_TIMEOVERLAY(obj) \
@ -40,11 +39,11 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TIMEOVERLAY))
#define GST_IS_TIMEOVERLAY_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TIMEOVERLAY))
typedef struct _GstTimeoverlay GstTimeoverlay;
typedef struct _GstTimeoverlayClass GstTimeoverlayClass;
struct _GstTimeoverlay {
struct _GstTimeoverlay
{
GstVideofilter videofilter;
PangoFontDescription *font_description;
@ -52,13 +51,12 @@ struct _GstTimeoverlay {
};
struct _GstTimeoverlayClass {
struct _GstTimeoverlayClass
{
GstVideofilterClass parent_class;
};
GType gst_timeoverlay_get_type (void);
G_END_DECLS
#endif /* __GST_TIMEOVERLAY_H__ */

View file

@ -41,7 +41,8 @@
typedef struct _GstTheoraDec GstTheoraDec;
typedef struct _GstTheoraDecClass GstTheoraDecClass;
struct _GstTheoraDec {
struct _GstTheoraDec
{
GstElement element;
GstPad *sinkpad;
@ -55,7 +56,8 @@ struct _GstTheoraDec {
guint64 granulepos;
};
struct _GstTheoraDecClass {
struct _GstTheoraDecClass
{
GstElementClass parent_class;
};
@ -67,41 +69,29 @@ static GstElementDetails theora_dec_details = {
};
static GstStaticPadTemplate theora_dec_src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"video/x-raw-yuv, "
GST_STATIC_CAPS ("video/x-raw-yuv, "
"format = (fourcc) I420, "
"framerate = (double) [0, MAX], "
"width = (int) [ 1, MAX ], "
"height = (int) [ 1, MAX ]"
)
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
);
static GstStaticPadTemplate theora_dec_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"video/x-theora"
)
GST_STATIC_CAPS ("video/x-theora")
);
GST_BOILERPLATE (GstTheoraDec, gst_theora_dec, GstElement, GST_TYPE_ELEMENT);
static void theora_dec_chain (GstPad * pad,
GstData * data);
static GstElementStateReturn
theora_dec_change_state (GstElement * element);
static gboolean theora_dec_src_event (GstPad * pad,
GstEvent * event);
static void theora_dec_chain (GstPad * pad, GstData * data);
static GstElementStateReturn theora_dec_change_state (GstElement * element);
static gboolean theora_dec_src_event (GstPad * pad, GstEvent * event);
static gboolean theora_dec_src_query (GstPad * pad,
GstQueryType query,
GstFormat * format,
gint64 * value);
GstQueryType query, GstFormat * format, gint64 * value);
static void
@ -127,13 +117,15 @@ gst_theora_dec_class_init (GstTheoraDecClass *klass)
static void
gst_theora_dec_init (GstTheoraDec * dec)
{
dec->sinkpad = gst_pad_new_from_template(
gst_static_pad_template_get (&theora_dec_sink_factory), "sink");
dec->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&theora_dec_sink_factory), "sink");
gst_pad_set_chain_function (dec->sinkpad, theora_dec_chain);
gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
dec->srcpad = gst_pad_new_from_template(
gst_static_pad_template_get (&theora_dec_src_factory), "src");
dec->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&theora_dec_src_factory), "src");
gst_pad_use_explicit_caps (dec->srcpad);
gst_pad_set_event_function (dec->srcpad, theora_dec_src_event);
gst_pad_set_query_function (dec->srcpad, theora_dec_src_query);
@ -144,8 +136,10 @@ gst_theora_dec_init (GstTheoraDec *dec)
/* FIXME: copy from libtheora, theora should somehow make this available for seeking */
static int
_theora_ilog(unsigned int v){
_theora_ilog (unsigned int v)
{
int ret = 0;
while (v) {
ret++;
v >>= 1;
@ -154,12 +148,14 @@ _theora_ilog(unsigned int v){
}
static gboolean
theora_dec_from_granulepos (GstTheoraDec *dec, GstFormat format, guint64 from, guint64 *to)
theora_dec_from_granulepos (GstTheoraDec * dec, GstFormat format, guint64 from,
guint64 * to)
{
guint64 framecount;
guint ilog = _theora_ilog (dec->info.keyframe_frequency_force);
if (dec->packetno < 1) return FALSE;
if (dec->packetno < 1)
return FALSE;
/* granulepos is last ilog bits for counting pframes since last iframe and
* bits in front of that for the framenumber of the last iframe. */
@ -168,7 +164,9 @@ theora_dec_from_granulepos (GstTheoraDec *dec, GstFormat format, guint64 from, g
switch (format) {
case GST_FORMAT_TIME:
*to = framecount = from * GST_SECOND * dec->info.fps_denominator / dec->info.fps_numerator;
*to = framecount =
from * GST_SECOND * dec->info.fps_denominator /
dec->info.fps_numerator;
break;
case GST_FORMAT_DEFAULT:
*to = framecount;
@ -184,15 +182,19 @@ theora_dec_from_granulepos (GstTheoraDec *dec, GstFormat format, guint64 from, g
/* FIXME: we can only seek to keyframes... */
static gboolean
theora_dec_to_granulepos (GstTheoraDec *dec, GstFormat format, guint64 from, guint64 *to)
theora_dec_to_granulepos (GstTheoraDec * dec, GstFormat format, guint64 from,
guint64 * to)
{
guint64 framecount;
if (dec->packetno < 1) return FALSE;
if (dec->packetno < 1)
return FALSE;
switch (format) {
case GST_FORMAT_TIME:
framecount = from * dec->info.fps_numerator / (GST_SECOND * dec->info.fps_denominator);
framecount =
from * dec->info.fps_numerator / (GST_SECOND *
dec->info.fps_denominator);
break;
case GST_FORMAT_DEFAULT:
framecount = from;
@ -208,19 +210,22 @@ theora_dec_to_granulepos (GstTheoraDec *dec, GstFormat format, guint64 from, gui
}
static gboolean
theora_dec_src_query (GstPad *pad, GstQueryType query, GstFormat *format, gint64 *value)
theora_dec_src_query (GstPad * pad, GstQueryType query, GstFormat * format,
gint64 * value)
{
gint64 granulepos;
GstTheoraDec *dec = GST_THEORA_DEC (gst_pad_get_parent (pad));
GstFormat my_format = GST_FORMAT_DEFAULT;
if (!gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, &my_format, &granulepos))
if (!gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, &my_format,
&granulepos))
return FALSE;
if (!theora_dec_from_granulepos (dec, *format, granulepos, value))
return FALSE;
GST_LOG_OBJECT (dec, "query %u: peer returned granulepos: %llu - we return %llu (format %u)\n",
GST_LOG_OBJECT (dec,
"query %u: peer returned granulepos: %llu - we return %llu (format %u)\n",
query, granulepos, *value, *format);
return TRUE;
}
@ -241,8 +246,10 @@ theora_dec_src_event (GstPad *pad, GstEvent *event)
GST_EVENT_SEEK_OFFSET (event), &value);
if (res) {
GstEvent *real_seek = gst_event_new_seek (
(GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) | GST_FORMAT_DEFAULT,
(GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) |
GST_FORMAT_DEFAULT,
value);
res = gst_pad_send_event (GST_PAD_PEER (dec->sinkpad), real_seek);
}
gst_event_unref (event);
@ -266,27 +273,37 @@ theora_dec_event (GstTheoraDec *dec, GstEvent *event)
case GST_EVENT_DISCONTINUOUS:
if (gst_event_discont_get_value (event, GST_FORMAT_DEFAULT, &value)) {
dec->granulepos = value;
GST_DEBUG_OBJECT (dec, "setting granuleposition to %"G_GUINT64_FORMAT" after discont\n", value);
GST_DEBUG_OBJECT (dec,
"setting granuleposition to %" G_GUINT64_FORMAT " after discont\n",
value);
} else {
GST_WARNING_OBJECT (dec,
"discont event didn't include offset, we might set it wrong now");
}
if (dec->packetno < 3) {
if (dec->granulepos != 0)
GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("can't handle discont before parsing first 3 packets"));
GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL),
("can't handle discont before parsing first 3 packets"));
dec->packetno = 0;
gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, (guint64) 0,
GST_FORMAT_DEFAULT, (guint64) 0, GST_FORMAT_BYTES, (guint64) 0, 0)));
gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE,
GST_FORMAT_TIME, (guint64) 0, GST_FORMAT_DEFAULT,
(guint64) 0, GST_FORMAT_BYTES, (guint64) 0, 0)));
} else {
dec->packetno = 3;
/* if one of them works, all of them work */
if (theora_dec_from_granulepos (dec, GST_FORMAT_TIME, dec->granulepos, &time) &&
theora_dec_from_granulepos (dec, GST_FORMAT_DEFAULT, dec->granulepos, &value) &&
theora_dec_from_granulepos (dec, GST_FORMAT_BYTES, dec->granulepos, &bytes)) {
gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
GST_FORMAT_DEFAULT, value, GST_FORMAT_BYTES, bytes, 0)));
if (theora_dec_from_granulepos (dec, GST_FORMAT_TIME, dec->granulepos,
&time)
&& theora_dec_from_granulepos (dec, GST_FORMAT_DEFAULT,
dec->granulepos, &value)
&& theora_dec_from_granulepos (dec, GST_FORMAT_BYTES,
dec->granulepos, &bytes)) {
gst_pad_push (dec->srcpad,
GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
time, GST_FORMAT_DEFAULT, value, GST_FORMAT_BYTES, bytes,
0)));
} else {
GST_ERROR_OBJECT (dec, "failed to parse data for DISCONT event, not sending any");
GST_ERROR_OBJECT (dec,
"failed to parse data for DISCONT event, not sending any");
}
}
break;
@ -328,7 +345,10 @@ theora_dec_chain (GstPad *pad, GstData *data)
}
if (packet.packetno == 1) {
gchar *encoder = NULL;
GstTagList *list = gst_tag_list_from_vorbiscomment_buffer (buf, "\201theora", 7, &encoder);
GstTagList *list =
gst_tag_list_from_vorbiscomment_buffer (buf, "\201theora", 7,
&encoder);
if (!list) {
GST_ERROR_OBJECT (dec, "failed to parse tags");
list = gst_tag_list_new ();
@ -343,14 +363,15 @@ theora_dec_chain (GstPad *pad, GstData *data)
gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, 0, list);
} else if (packet.packetno == 2) {
GstCaps *caps;
/* done */
theora_decode_init (&dec->state, &dec->info);
caps = gst_caps_new_simple ("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
"framerate", G_TYPE_DOUBLE, ((gdouble) dec->info.fps_numerator) / dec->info.fps_denominator,
"width", G_TYPE_INT, dec->info.width,
"height", G_TYPE_INT, dec->info.height,
NULL);
"framerate", G_TYPE_DOUBLE,
((gdouble) dec->info.fps_numerator) / dec->info.fps_denominator,
"width", G_TYPE_INT, dec->info.width, "height", G_TYPE_INT,
dec->info.height, NULL);
gst_pad_set_explicit_caps (dec->srcpad, caps);
gst_caps_free (caps);
}
@ -359,11 +380,13 @@ theora_dec_chain (GstPad *pad, GstData *data)
GstBuffer *out;
guint8 *y, *v, *u;
guint i;
/* normal data packet */
#if 0
{
GTimeVal tv;
guint64 time;
g_get_current_time (&tv);
time = GST_TIMEVAL_TO_TIME (tv);
#endif
@ -395,8 +418,11 @@ theora_dec_chain (GstPad *pad, GstData *data)
}
GST_BUFFER_OFFSET (out) = dec->packetno - 4;
GST_BUFFER_OFFSET_END (out) = dec->packetno - 3;
GST_BUFFER_DURATION (out) = GST_SECOND * ((gdouble) dec->info.fps_denominator) / dec->info.fps_numerator;
GST_BUFFER_TIMESTAMP (out) = GST_BUFFER_OFFSET (out) * GST_BUFFER_DURATION (out);
GST_BUFFER_DURATION (out) =
GST_SECOND * ((gdouble) dec->info.fps_denominator) /
dec->info.fps_numerator;
GST_BUFFER_TIMESTAMP (out) =
GST_BUFFER_OFFSET (out) * GST_BUFFER_DURATION (out);
#if 0
g_get_current_time (&tv);
time = GST_TIMEVAL_TO_TIME (tv) - time;
@ -448,19 +474,15 @@ plugin_init (GstPlugin *plugin)
if (!gst_library_load ("gsttags"))
return FALSE;
if (!gst_element_register (plugin, "theoradec", GST_RANK_SECONDARY, gst_theora_dec_get_type ()))
if (!gst_element_register (plugin, "theoradec", GST_RANK_SECONDARY,
gst_theora_dec_get_type ()))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gsttheora",
"Theora plugin library",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN)
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)

View file

@ -35,23 +35,21 @@ plugin_init (GstPlugin *plugin)
if (!gst_library_load ("gsttags"))
return FALSE;
if (!gst_element_register (plugin, "vorbisenc", GST_RANK_NONE, GST_TYPE_VORBISENC))
if (!gst_element_register (plugin, "vorbisenc", GST_RANK_NONE,
GST_TYPE_VORBISENC))
return FALSE;
if (!gst_element_register (plugin, "vorbisdec", GST_RANK_PRIMARY, gst_vorbis_dec_get_type ()))
if (!gst_element_register (plugin, "vorbisdec", GST_RANK_PRIMARY,
gst_vorbis_dec_get_type ()))
return FALSE;
GST_DEBUG_CATEGORY_INIT (vorbisdec_debug, "vorbisdec", 0, "vorbis decoding element");
GST_DEBUG_CATEGORY_INIT (vorbisdec_debug, "vorbisdec", 0,
"vorbis decoding element");
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"vorbis",
"Vorbis plugin library",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN)
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)

View file

@ -36,60 +36,48 @@ static GstElementDetails vorbis_dec_details = {
};
/* Filter signals and args */
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum {
enum
{
ARG_0
};
static GstStaticPadTemplate vorbis_dec_src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"audio/x-raw-float, "
GST_STATIC_CAPS ("audio/x-raw-float, "
"rate = (int) [ 11025, 48000 ], "
"channels = (int) [ 1, 2 ], "
"endianness = (int) BYTE_ORDER, "
"channels = (int) [ 1, 2 ], " "endianness = (int) BYTE_ORDER, "
/* no ifdef in macros, please
#ifdef GST_VORBIS_DEC_SEQUENTIAL
"layout = \"sequential\", "
#endif
*/
"width = (int) 32, "
"buffer-frames = (int) 0"
)
"width = (int) 32, " "buffer-frames = (int) 0")
);
static GstStaticPadTemplate vorbis_dec_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"audio/x-vorbis"
)
GST_STATIC_CAPS ("audio/x-vorbis")
);
GST_BOILERPLATE (GstVorbisDec, gst_vorbis_dec, GstElement, GST_TYPE_ELEMENT);
static void vorbis_dec_chain (GstPad * pad,
GstData * data);
static GstElementStateReturn
vorbis_dec_change_state (GstElement * element);
static const GstFormat*
vorbis_dec_get_formats (GstPad *pad);
static void vorbis_dec_chain (GstPad * pad, GstData * data);
static GstElementStateReturn vorbis_dec_change_state (GstElement * element);
static const GstFormat *vorbis_dec_get_formats (GstPad * pad);
static gboolean vorbis_dec_src_event (GstPad * pad,
GstEvent * event);
static gboolean vorbis_dec_src_event (GstPad * pad, GstEvent * event);
static gboolean vorbis_dec_src_query (GstPad * pad,
GstQueryType query,
GstFormat * format,
gint64 * value);
GstQueryType query, GstFormat * format, gint64 * value);
static void
@ -151,26 +139,26 @@ vorbis_dec_getcaps (GstPad *pad)
return gst_caps_new_simple ("audio/x-raw-float",
"rate", G_TYPE_INT, dec->vi.rate,
"channels", G_TYPE_INT, dec->vi.channels,
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"width", G_TYPE_INT, 32,
"endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32,
#ifdef GST_VORBIS_DEC_SEQUENTIAL
"layout", G_TYPE_STRING, "sequential",
#endif
"buffer-frames", G_TYPE_INT, 0,
NULL);
"buffer-frames", G_TYPE_INT, 0, NULL);
}
static void
gst_vorbis_dec_init (GstVorbisDec * dec)
{
dec->sinkpad = gst_pad_new_from_template(
gst_static_pad_template_get (&vorbis_dec_sink_factory), "sink");
dec->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&vorbis_dec_sink_factory), "sink");
gst_pad_set_chain_function (dec->sinkpad, vorbis_dec_chain);
gst_pad_set_formats_function (dec->sinkpad, vorbis_dec_get_formats);
gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
dec->srcpad = gst_pad_new_from_template(
gst_static_pad_template_get (&vorbis_dec_src_factory), "src");
dec->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&vorbis_dec_src_factory), "src");
gst_pad_set_link_function (dec->srcpad, vorbis_dec_link);
gst_pad_set_getcaps_function (dec->srcpad, vorbis_dec_getcaps);
gst_pad_set_event_function (dec->srcpad, vorbis_dec_src_event);
@ -183,9 +171,11 @@ gst_vorbis_dec_init (GstVorbisDec *dec)
/* FIXME: plug this to the pad convert function */
static gboolean
vorbis_dec_to_granulepos (GstVorbisDec *dec, GstFormat format, guint64 from, guint64 *to)
vorbis_dec_to_granulepos (GstVorbisDec * dec, GstFormat format, guint64 from,
guint64 * to)
{
if (dec->packetno < 1) return FALSE;
if (dec->packetno < 1)
return FALSE;
switch (format) {
case GST_FORMAT_TIME:
@ -203,9 +193,11 @@ vorbis_dec_to_granulepos (GstVorbisDec *dec, GstFormat format, guint64 from, gui
}
static gboolean
vorbis_dec_from_granulepos (GstVorbisDec *dec, GstFormat format, guint64 from, guint64 *to)
vorbis_dec_from_granulepos (GstVorbisDec * dec, GstFormat format, guint64 from,
guint64 * to)
{
if (dec->packetno < 1) return FALSE;
if (dec->packetno < 1)
return FALSE;
switch (format) {
case GST_FORMAT_TIME:
@ -224,19 +216,22 @@ vorbis_dec_from_granulepos (GstVorbisDec *dec, GstFormat format, guint64 from, g
static gboolean
vorbis_dec_src_query (GstPad *pad, GstQueryType query, GstFormat *format, gint64 *value)
vorbis_dec_src_query (GstPad * pad, GstQueryType query, GstFormat * format,
gint64 * value)
{
gint64 granulepos;
GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad));
GstFormat my_format = GST_FORMAT_DEFAULT;
if (!gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, &my_format, &granulepos))
if (!gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, &my_format,
&granulepos))
return FALSE;
if (!vorbis_dec_from_granulepos (dec, *format, granulepos, value))
return FALSE;
GST_LOG_OBJECT (dec, "query %u: peer returned granulepos: %llu - we return %llu (format %u)\n",
GST_LOG_OBJECT (dec,
"query %u: peer returned granulepos: %llu - we return %llu (format %u)\n",
query, granulepos, *value, *format);
return TRUE;
}
@ -255,8 +250,10 @@ vorbis_dec_src_event (GstPad *pad, GstEvent *event)
GST_EVENT_SEEK_OFFSET (event), &value);
if (res) {
GstEvent *real_seek = gst_event_new_seek (
(GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) | GST_FORMAT_DEFAULT,
(GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) |
GST_FORMAT_DEFAULT,
value);
res = gst_pad_send_event (GST_PAD_PEER (dec->sinkpad), real_seek);
}
gst_event_unref (event);
@ -279,27 +276,37 @@ vorbis_dec_event (GstVorbisDec *dec, GstEvent *event)
case GST_EVENT_DISCONTINUOUS:
if (gst_event_discont_get_value (event, GST_FORMAT_DEFAULT, &value)) {
dec->granulepos = value;
GST_DEBUG_OBJECT (dec, "setting granuleposition to %"G_GUINT64_FORMAT" after discont", value);
GST_DEBUG_OBJECT (dec,
"setting granuleposition to %" G_GUINT64_FORMAT " after discont",
value);
} else {
GST_WARNING_OBJECT (dec,
"discont event didn't include offset, we might set it wrong now");
}
if (dec->packetno < 3) {
if (dec->granulepos != 0)
GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("can't handle discont before parsing first 3 packets"));
GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL),
("can't handle discont before parsing first 3 packets"));
dec->packetno = 0;
gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, (guint64) 0,
GST_FORMAT_DEFAULT, (guint64) 0, GST_FORMAT_BYTES, (guint64) 0, 0)));
gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE,
GST_FORMAT_TIME, (guint64) 0, GST_FORMAT_DEFAULT,
(guint64) 0, GST_FORMAT_BYTES, (guint64) 0, 0)));
} else {
dec->packetno = 3;
/* if one of them works, all of them work */
if (vorbis_dec_from_granulepos (dec, GST_FORMAT_TIME, dec->granulepos, &time) &&
vorbis_dec_from_granulepos (dec, GST_FORMAT_DEFAULT, dec->granulepos, &value) &&
vorbis_dec_from_granulepos (dec, GST_FORMAT_BYTES, dec->granulepos, &bytes)) {
gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
GST_FORMAT_DEFAULT, value, GST_FORMAT_BYTES, bytes, 0)));
if (vorbis_dec_from_granulepos (dec, GST_FORMAT_TIME, dec->granulepos,
&time)
&& vorbis_dec_from_granulepos (dec, GST_FORMAT_DEFAULT,
dec->granulepos, &value)
&& vorbis_dec_from_granulepos (dec, GST_FORMAT_BYTES,
dec->granulepos, &bytes)) {
gst_pad_push (dec->srcpad,
GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
time, GST_FORMAT_DEFAULT, value, GST_FORMAT_BYTES, bytes,
0)));
} else {
GST_ERROR_OBJECT (dec, "failed to parse data for DISCONT event, not sending any");
GST_ERROR_OBJECT (dec,
"failed to parse data for DISCONT event, not sending any");
}
#ifdef HAVE_VORBIS_SYNTHESIS_RESTART
vorbis_synthesis_restart (&dec->vd);
@ -337,7 +344,8 @@ vorbis_dec_chain (GstPad *pad, GstData *data)
if (packet.packet[0] / 2 != packet.packetno) {
/* FIXME: just skip? */
GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
(NULL), ("unexpected packet type %d, expected %d", (gint) packet.packet[0], (gint) packet.packetno));
(NULL), ("unexpected packet type %d, expected %d",
(gint) packet.packet[0], (gint) packet.packetno));
gst_data_unref (data);
return;
}
@ -349,7 +357,10 @@ vorbis_dec_chain (GstPad *pad, GstData *data)
}
if (packet.packetno == 1) {
gchar *encoder = NULL;
GstTagList *list = gst_tag_list_from_vorbiscomment_buffer (buf, "\003vorbis", 7, &encoder);
GstTagList *list =
gst_tag_list_from_vorbiscomment_buffer (buf, "\003vorbis", 7,
&encoder);
if (!list) {
GST_ERROR_OBJECT (vd, "couldn't decode comments");
list = gst_tag_list_new ();
@ -401,6 +412,7 @@ vorbis_dec_chain (GstPad *pad, GstData *data)
GstBuffer *out = gst_pad_alloc_buffer (vd->srcpad, GST_BUFFER_OFFSET_NONE,
sample_count * vd->vi.channels * sizeof (float));
float *out_data = (float *) GST_BUFFER_DATA (out);
#ifdef GST_VORBIS_DEC_SEQUENTIAL
for (i = 0; i < vd->vi.channels; i++) {
memcpy (out_data, pcm[i], sample_count * sizeof (float));

View file

@ -27,7 +27,8 @@
#include <vorbis/codec.h>
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif /* __cplusplus */
@ -45,7 +46,8 @@ extern "C" {
typedef struct _GstVorbisDec GstVorbisDec;
typedef struct _GstVorbisDecClass GstVorbisDecClass;
struct _GstVorbisDec {
struct _GstVorbisDec
{
GstElement element;
GstPad *sinkpad;
@ -59,7 +61,8 @@ struct _GstVorbisDec {
guint64 granulepos;
};
struct _GstVorbisDecClass {
struct _GstVorbisDecClass
{
GstElementClass parent_class;
};

View file

@ -37,8 +37,7 @@ GstElementDetails vorbisenc_details = {
"Ogg Vorbis encoder",
"Codec/Encoder/Audio",
"Encodes audio in OGG Vorbis format",
"Monty <monty@xiph.org>, "
"Wim Taymans <wim.taymans@chello.be>",
"Monty <monty@xiph.org>, " "Wim Taymans <wim.taymans@chello.be>",
};
/* VorbisEnc signals and args */
@ -94,10 +93,10 @@ static void gst_vorbisenc_get_property (GObject *object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_vorbisenc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static GstElementStateReturn
gst_vorbisenc_change_state (GstElement *element);
static GstElementStateReturn gst_vorbisenc_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
/*static guint gst_vorbisenc_signals[LAST_SIGNAL] = { 0 }; */
GType
@ -123,9 +122,12 @@ vorbisenc_get_type (void)
NULL
};
vorbisenc_type = g_type_register_static (GST_TYPE_ELEMENT, "VorbisEnc", &vorbisenc_info, 0);
vorbisenc_type =
g_type_register_static (GST_TYPE_ELEMENT, "VorbisEnc", &vorbisenc_info,
0);
g_type_add_interface_static (vorbisenc_type, GST_TYPE_TAG_SETTER, &tag_setter_info);
g_type_add_interface_static (vorbisenc_type, GST_TYPE_TAG_SETTER,
&tag_setter_info);
}
return vorbisenc_type;
}
@ -146,8 +148,7 @@ raw_caps_factory (void)
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
"rate", GST_TYPE_INT_RANGE, 11025, 48000,
"channels", GST_TYPE_INT_RANGE, 1, 2,
NULL);
"channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
}
static void
@ -160,13 +161,13 @@ gst_vorbisenc_base_init (gpointer g_class)
vorbis_caps = vorbis_caps_factory ();
gst_vorbisenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS,
raw_caps);
GST_PAD_ALWAYS, raw_caps);
gst_vorbisenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
GST_PAD_ALWAYS,
vorbis_caps);
gst_element_class_add_pad_template (element_class, gst_vorbisenc_sink_template);
gst_element_class_add_pad_template (element_class, gst_vorbisenc_src_template);
GST_PAD_ALWAYS, vorbis_caps);
gst_element_class_add_pad_template (element_class,
gst_vorbisenc_sink_template);
gst_element_class_add_pad_template (element_class,
gst_vorbisenc_src_template);
gst_element_class_set_details (element_class, &vorbisenc_details);
}
@ -196,14 +197,15 @@ gst_vorbisenc_class_init (VorbisEncClass * klass)
"Specify quality instead of specifying a particular bitrate.",
0.0, 1.0, QUALITY_DEFAULT, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SERIAL,
g_param_spec_int ("serial", "Serial", "Specify a serial number for the stream. (-1 is random)",
-1, G_MAXINT, -1, G_PARAM_READWRITE));
g_param_spec_int ("serial", "Serial",
"Specify a serial number for the stream. (-1 is random)", -1,
G_MAXINT, -1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MANAGED,
g_param_spec_boolean ("managed", "Managed", "Enable bitrate management engine",
FALSE, G_PARAM_READWRITE));
g_param_spec_boolean ("managed", "Managed",
"Enable bitrate management engine", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", "The last status message",
NULL, G_PARAM_READABLE));
g_param_spec_string ("last-message", "last-message",
"The last status message", NULL, G_PARAM_READABLE));
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
@ -244,12 +246,10 @@ gst_vorbisenc_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
if (vorbisenc->samples_in == 0 ||
vorbisenc->bytes_out == 0 ||
vorbisenc->frequency == 0)
vorbisenc->bytes_out == 0 || vorbisenc->frequency == 0)
return FALSE;
avg = (vorbisenc->bytes_out * vorbisenc->frequency)/
(vorbisenc->samples_in);
avg = (vorbisenc->bytes_out * vorbisenc->frequency) / (vorbisenc->samples_in);
switch (src_format) {
case GST_FORMAT_BYTES:
@ -277,8 +277,8 @@ gst_vorbisenc_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
}
static gboolean
gst_vorbisenc_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value)
gst_vorbisenc_convert_sink (GstPad * pad, GstFormat src_format,
gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
guint scale = 1;
@ -374,26 +374,25 @@ gst_vorbisenc_src_query (GstPad *pad, GstQueryType type,
res = FALSE;
peer_formats = gst_pad_get_formats (GST_PAD_PEER (vorbisenc->sinkpad));
peer_formats =
gst_pad_get_formats (GST_PAD_PEER (vorbisenc->sinkpad));
while (peer_formats && *peer_formats && !res) {
GstFormat peer_format = *peer_formats;
/* do the probe */
if (gst_pad_query (GST_PAD_PEER (vorbisenc->sinkpad), GST_QUERY_TOTAL,
&peer_format, &peer_value))
{
if (gst_pad_query (GST_PAD_PEER (vorbisenc->sinkpad),
GST_QUERY_TOTAL, &peer_format, &peer_value)) {
GstFormat conv_format;
/* convert to TIME */
conv_format = GST_FORMAT_TIME;
res = gst_pad_convert (vorbisenc->sinkpad,
peer_format, peer_value,
&conv_format, value);
peer_format, peer_value, &conv_format, value);
/* and to final format */
res &= gst_pad_convert (pad,
GST_FORMAT_TIME, *value,
format, value);
GST_FORMAT_TIME, *value, format, value);
}
peer_formats++;
}
@ -411,8 +410,7 @@ gst_vorbisenc_src_query (GstPad *pad, GstQueryType type,
{
/* we only know about our samples, convert to requested format */
res = gst_pad_convert (pad,
GST_FORMAT_BYTES, vorbisenc->bytes_out,
format, value);
GST_FORMAT_BYTES, vorbisenc->bytes_out, format, value);
break;
}
}
@ -427,18 +425,26 @@ gst_vorbisenc_src_query (GstPad *pad, GstQueryType type,
static void
gst_vorbisenc_init (VorbisEnc * vorbisenc)
{
vorbisenc->sinkpad = gst_pad_new_from_template (gst_vorbisenc_sink_template, "sink");
vorbisenc->sinkpad =
gst_pad_new_from_template (gst_vorbisenc_sink_template, "sink");
gst_element_add_pad (GST_ELEMENT (vorbisenc), vorbisenc->sinkpad);
gst_pad_set_chain_function (vorbisenc->sinkpad, gst_vorbisenc_chain);
gst_pad_set_link_function (vorbisenc->sinkpad, gst_vorbisenc_sinkconnect);
gst_pad_set_convert_function (vorbisenc->sinkpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_convert_sink));
gst_pad_set_formats_function (vorbisenc->sinkpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_get_formats));
gst_pad_set_convert_function (vorbisenc->sinkpad,
GST_DEBUG_FUNCPTR (gst_vorbisenc_convert_sink));
gst_pad_set_formats_function (vorbisenc->sinkpad,
GST_DEBUG_FUNCPTR (gst_vorbisenc_get_formats));
vorbisenc->srcpad = gst_pad_new_from_template (gst_vorbisenc_src_template, "src");
gst_pad_set_query_function (vorbisenc->srcpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_src_query));
gst_pad_set_query_type_function (vorbisenc->srcpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_get_query_types));
gst_pad_set_convert_function (vorbisenc->srcpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_convert_src));
gst_pad_set_formats_function (vorbisenc->srcpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_get_formats));
vorbisenc->srcpad =
gst_pad_new_from_template (gst_vorbisenc_src_template, "src");
gst_pad_set_query_function (vorbisenc->srcpad,
GST_DEBUG_FUNCPTR (gst_vorbisenc_src_query));
gst_pad_set_query_type_function (vorbisenc->srcpad,
GST_DEBUG_FUNCPTR (gst_vorbisenc_get_query_types));
gst_pad_set_convert_function (vorbisenc->srcpad,
GST_DEBUG_FUNCPTR (gst_vorbisenc_convert_src));
gst_pad_set_formats_function (vorbisenc->srcpad,
GST_DEBUG_FUNCPTR (gst_vorbisenc_get_formats));
gst_element_add_pad (GST_ELEMENT (vorbisenc), vorbisenc->srcpad);
vorbisenc->channels = -1;
@ -465,7 +471,8 @@ gst_vorbisenc_init (VorbisEnc * vorbisenc)
static gchar *
gst_vorbisenc_get_tag_value (const GstTagList *list, const gchar *tag, int index)
gst_vorbisenc_get_tag_value (const GstTagList * list, const gchar * tag,
int index)
{
gchar *vorbisvalue = NULL;
@ -479,6 +486,7 @@ gst_vorbisenc_get_tag_value (const GstTagList *list, const gchar *tag, int index
|| (strcmp (tag, GST_TAG_TRACK_COUNT) == 0)
|| (strcmp (tag, GST_TAG_ALBUM_VOLUME_COUNT) == 0)) {
guint track_no;
g_assert (gst_tag_list_get_uint_index (list, tag, index, &track_no));
vorbisvalue = g_strdup_printf ("%u", track_no);
} else if (strcmp (tag, GST_TAG_DATE) == 0) {
@ -488,7 +496,8 @@ gst_vorbisenc_get_tag_value (const GstTagList *list, const gchar *tag, int index
g_assert (gst_tag_list_get_uint_index (list, tag, index, &u));
date = g_date_new_julian (u);
vorbisvalue = g_strdup_printf ("%04d-%02d-%02d", (gint) g_date_get_year (date),
vorbisvalue =
g_strdup_printf ("%04d-%02d-%02d", (gint) g_date_get_year (date),
(gint) g_date_get_month (date), (gint) g_date_get_day (date));
g_date_free (date);
} else if (gst_tag_get_type (tag) == G_TYPE_STRING) {
@ -499,7 +508,8 @@ gst_vorbisenc_get_tag_value (const GstTagList *list, const gchar *tag, int index
}
static void
gst_vorbisenc_metadata_set1 (const GstTagList *list, const gchar *tag, gpointer vorbisenc)
gst_vorbisenc_metadata_set1 (const GstTagList * list, const gchar * tag,
gpointer vorbisenc)
{
const gchar *vorbistag = NULL;
gchar *vorbisvalue = NULL;
@ -531,7 +541,9 @@ gst_vorbisenc_set_metadata (VorbisEnc *vorbisenc)
if (!(vorbisenc->tags || user_tags))
return;
copy = gst_tag_list_merge (user_tags, vorbisenc->tags, gst_tag_setter_get_merge_mode (GST_TAG_SETTER (vorbisenc)));
copy =
gst_tag_list_merge (user_tags, vorbisenc->tags,
gst_tag_setter_get_merge_mode (GST_TAG_SETTER (vorbisenc)));
vorbis_comment_init (&vorbisenc->vc);
gst_tag_list_foreach (copy, gst_vorbisenc_metadata_set1, vorbisenc);
gst_tag_list_free (copy);
@ -570,33 +582,30 @@ update_start_message (VorbisEnc *vorbisenc)
g_strdup_printf ("encoding at average bitrate %d bps %s",
vorbisenc->bitrate, constraints);
g_free (constraints);
}
else {
} else {
vorbisenc->last_message =
g_strdup_printf ("encoding at approximate bitrate %d bps (VBR encoding enabled)",
g_strdup_printf
("encoding at approximate bitrate %d bps (VBR encoding enabled)",
vorbisenc->bitrate);
}
}
else {
} else {
if (vorbisenc->quality_set) {
if (vorbisenc->managed) {
constraints = get_constraints_string (vorbisenc);
vorbisenc->last_message =
g_strdup_printf ("encoding at quality level %2.2f using constrained VBR %s",
g_strdup_printf
("encoding at quality level %2.2f using constrained VBR %s",
vorbisenc->quality, constraints);
g_free (constraints);
}
else {
} else {
vorbisenc->last_message =
g_strdup_printf ("encoding at quality level %2.2f",
vorbisenc->quality);
}
}
else {
} else {
constraints = get_constraints_string (vorbisenc);
vorbisenc->last_message =
g_strdup_printf ("encoding using bitrate management %s",
constraints);
g_strdup_printf ("encoding using bitrate management %s", constraints);
g_free (constraints);
}
}
@ -609,7 +618,8 @@ gst_vorbisenc_setup (VorbisEnc *vorbisenc)
{
gint serial;
if (vorbisenc->bitrate < 0 && vorbisenc->min_bitrate < 0 && vorbisenc->max_bitrate < 0) {
if (vorbisenc->bitrate < 0 && vorbisenc->min_bitrate < 0
&& vorbisenc->max_bitrate < 0) {
vorbisenc->quality_set = TRUE;
}
@ -621,11 +631,9 @@ gst_vorbisenc_setup (VorbisEnc *vorbisenc)
if (vorbisenc->quality_set) {
if (vorbis_encode_setup_vbr (&vorbisenc->vi,
vorbisenc->channels,
vorbisenc->frequency,
vorbisenc->quality))
{
g_warning ("vorbisenc: initialisation failed: invalid parameters for quality");
vorbisenc->channels, vorbisenc->frequency, vorbisenc->quality)) {
g_warning
("vorbisenc: initialisation failed: invalid parameters for quality");
vorbis_info_clear (&vorbisenc->vi);
return FALSE;
}
@ -633,6 +641,7 @@ gst_vorbisenc_setup (VorbisEnc *vorbisenc)
/* do we have optional hard quality restrictions? */
if (vorbisenc->max_bitrate > 0 || vorbisenc->min_bitrate > 0) {
struct ovectl_ratemanage_arg ai;
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_GET, &ai);
/* the bitrates are in kHz */
@ -642,16 +651,15 @@ gst_vorbisenc_setup (VorbisEnc *vorbisenc)
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, &ai);
}
}
else {
} else {
if (vorbis_encode_setup_managed (&vorbisenc->vi,
vorbisenc->channels,
vorbisenc->frequency,
vorbisenc->max_bitrate > 0 ? vorbisenc->max_bitrate : -1,
vorbisenc->bitrate,
vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1))
{
g_warning("vorbisenc: initialisation failed: invalid parameters for bitrate\n");
vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1)) {
g_warning
("vorbisenc: initialisation failed: invalid parameters for bitrate\n");
vorbis_info_clear (&vorbisenc->vi);
return FALSE;
}
@ -659,8 +667,7 @@ gst_vorbisenc_setup (VorbisEnc *vorbisenc)
if (vorbisenc->managed && vorbisenc->bitrate < 0) {
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_AVG, NULL);
}
else if(!vorbisenc->managed) {
} else if (!vorbisenc->managed) {
/* Turn off management entirely (if it was turned on). */
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, NULL);
}
@ -676,8 +683,7 @@ gst_vorbisenc_setup (VorbisEnc *vorbisenc)
if (vorbisenc->serial < 0) {
srand (time (NULL));
serial = rand ();
}
else {
} else {
serial = vorbisenc->serial;
}
@ -693,24 +699,19 @@ gst_vorbisenc_write_page (VorbisEnc *vorbisenc, ogg_page *page)
{
GstBuffer *outbuf;
outbuf = gst_buffer_new_and_alloc (page->header_len +
page->body_len);
outbuf = gst_buffer_new_and_alloc (page->header_len + page->body_len);
memcpy (GST_BUFFER_DATA (outbuf), page->header,
page->header_len);
memcpy (GST_BUFFER_DATA (outbuf), page->header, page->header_len);
memcpy (GST_BUFFER_DATA (outbuf) + page->header_len,
page->body,
page->body_len);
page->body, page->body_len);
GST_DEBUG ("vorbisenc: encoded buffer of %d bytes",
GST_BUFFER_SIZE (outbuf));
GST_DEBUG ("vorbisenc: encoded buffer of %d bytes", GST_BUFFER_SIZE (outbuf));
vorbisenc->bytes_out += GST_BUFFER_SIZE (outbuf);
if (GST_PAD_IS_USABLE (vorbisenc->srcpad)) {
gst_pad_push (vorbisenc->srcpad, GST_DATA (outbuf));
}
else {
} else {
gst_buffer_unref (outbuf);
}
}
@ -752,8 +753,7 @@ gst_vorbisenc_chain (GstPad * pad, GstData *_data)
gst_pad_event_default (pad, event);
return;
}
}
else {
} else {
gint16 *data;
gulong size;
gulong i, j;
@ -761,12 +761,14 @@ gst_vorbisenc_chain (GstPad * pad, GstData *_data)
if (!vorbisenc->setup) {
gst_buffer_unref (buf);
GST_ELEMENT_ERROR (vorbisenc, CORE, NEGOTIATION, (NULL), ("encoder not initialized (input is not audio?)"));
GST_ELEMENT_ERROR (vorbisenc, CORE, NEGOTIATION, (NULL),
("encoder not initialized (input is not audio?)"));
return;
}
if (!vorbisenc->header_sent) {
gint result;
/* Vorbis streams begin with three headers; the initial header (with
most of the codec setup parameters) which is mandated by the Ogg
bitstream spec. The second header holds any comment fields. The
@ -778,7 +780,8 @@ gst_vorbisenc_chain (GstPad * pad, GstData *_data)
ogg_packet header_code;
gst_vorbisenc_set_metadata (vorbisenc);
vorbis_analysis_headerout (&vorbisenc->vd, &vorbisenc->vc, &header, &header_comm, &header_code);
vorbis_analysis_headerout (&vorbisenc->vd, &vorbisenc->vc, &header,
&header_comm, &header_code);
ogg_stream_packetin (&vorbisenc->os, &header); /* automatically placed in its own page */
ogg_stream_packetin (&vorbisenc->os, &header_comm);
ogg_stream_packetin (&vorbisenc->os, &header_code);
@ -855,7 +858,8 @@ gst_vorbisenc_chain (GstPad * pad, GstData *_data)
}
static void
gst_vorbisenc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
gst_vorbisenc_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
VorbisEnc *vorbisenc;
@ -893,8 +897,8 @@ gst_vorbisenc_get_property (GObject * object, guint prop_id, GValue * value, GPa
}
static void
gst_vorbisenc_set_property (GObject * object, guint prop_id, const GValue * value,
GParamSpec * pspec)
gst_vorbisenc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
VorbisEnc *vorbisenc;
@ -983,4 +987,3 @@ gst_vorbisenc_change_state (GstElement *element)
return GST_STATE_SUCCESS;
}

View file

@ -27,7 +27,8 @@
#include <vorbis/codec.h>
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif /* __cplusplus */
#define GST_TYPE_VORBISENC \
@ -44,11 +45,11 @@ extern "C" {
typedef struct _VorbisEnc VorbisEnc;
typedef struct _VorbisEncClass VorbisEncClass;
struct _VorbisEnc {
struct _VorbisEnc
{
GstElement element;
GstPad *sinkpad,
*srcpad;
GstPad *sinkpad, *srcpad;
ogg_stream_state os; /* take physical pages, weld into a logical
stream of packets */
@ -85,7 +86,8 @@ struct _VorbisEnc {
gchar *last_message;
};
struct _VorbisEncClass {
struct _VorbisEncClass
{
GstElementClass parent_class;
};

View file

@ -96,8 +96,7 @@ gst_audio_frame_rate (GstPad *pad)
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0;
}
else {
} else {
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "rate", &rate);
return rate;
@ -125,15 +124,12 @@ gst_audio_length (GstPad* pad, GstBuffer* buf)
g_assert (GST_IS_BUFFER (buf));
/* get caps of pad */
caps = GST_PAD_CAPS (pad);
if (caps == NULL)
{
if (caps == NULL) {
/* ERROR: could not get caps of pad */
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
length = 0.0;
}
else
{
} else {
structure = gst_caps_get_structure (caps, 0);
bytes = GST_BUFFER_SIZE (buf);
gst_structure_get_int (structure, "width", &width);
@ -162,8 +158,7 @@ gst_audio_highest_sample_value (GstPad* pad)
GstStructure *structure;
caps = GST_PAD_CAPS (pad);
if (caps == NULL)
{
if (caps == NULL) {
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
}
@ -172,7 +167,8 @@ gst_audio_highest_sample_value (GstPad* pad)
gst_structure_get_int (structure, "width", &width);
gst_structure_get_boolean (structure, "signed", &is_signed);
if (is_signed) --width;
if (is_signed)
--width;
/* example : 16 bit, signed : samples between -32768 and 32767 */
return ((long) (1 << width));
}
@ -199,8 +195,8 @@ gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf)
* number of list values, and each of the values, terminating with NULL
*/
static void
_gst_audio_structure_set_list (GstStructure *structure, const gchar *fieldname,
GType type, int number, ...)
_gst_audio_structure_set_list (GstStructure * structure,
const gchar * fieldname, GType type, int number, ...)
{
va_list varargs;
GValue value = { 0 };
@ -214,17 +210,16 @@ _gst_audio_structure_set_list (GstStructure *structure, const gchar *fieldname,
va_start (varargs, number);
for (j = 0; j < number; ++j)
{
for (j = 0; j < number; ++j) {
int i;
gboolean b;
GValue list_value = { 0 };
switch (type)
{
switch (type) {
case G_TYPE_INT:
i = va_arg (varargs, int);
g_value_init (&list_value, G_TYPE_INT);
g_value_set_int (&list_value, i);
break;
@ -234,7 +229,8 @@ _gst_audio_structure_set_list (GstStructure *structure, const gchar *fieldname,
g_value_set_boolean (&list_value, b);
break;
default:
g_warning ("_gst_audio_structure_set_list: LIST of given type not implemented.");
g_warning
("_gst_audio_structure_set_list: LIST of given type not implemented.");
}
g_array_append_val (array, list_value);
@ -247,19 +243,25 @@ void
gst_audio_structure_set_int (GstStructure * structure, GstAudioFieldFlag flag)
{
if (flag & GST_AUDIO_FIELD_RATE)
gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT,
NULL);
if (flag & GST_AUDIO_FIELD_CHANNELS)
gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, G_MAXINT,
NULL);
if (flag & GST_AUDIO_FIELD_ENDIANNESS)
_gst_audio_structure_set_list (structure, "endianness", G_TYPE_INT, 2, G_LITTLE_ENDIAN, G_BIG_ENDIAN, NULL);
_gst_audio_structure_set_list (structure, "endianness", G_TYPE_INT, 2,
G_LITTLE_ENDIAN, G_BIG_ENDIAN, NULL);
if (flag & GST_AUDIO_FIELD_WIDTH)
_gst_audio_structure_set_list (structure, "width", G_TYPE_INT, 3, 8, 16, 32, NULL);
_gst_audio_structure_set_list (structure, "width", G_TYPE_INT, 3, 8, 16, 32,
NULL);
if (flag & GST_AUDIO_FIELD_DEPTH)
gst_structure_set (structure, "depth", GST_TYPE_INT_RANGE, 1, 32, NULL);
if (flag & GST_AUDIO_FIELD_SIGNED)
_gst_audio_structure_set_list (structure, "signed", G_TYPE_BOOLEAN, 2, TRUE, FALSE, NULL);
_gst_audio_structure_set_list (structure, "signed", G_TYPE_BOOLEAN, 2, TRUE,
FALSE, NULL);
if (flag & GST_AUDIO_FIELD_BUFFER_FRAMES)
gst_structure_set (structure, "buffer-frames", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set (structure, "buffer-frames", GST_TYPE_INT_RANGE, 1,
G_MAXINT, NULL);
}
static gboolean
@ -268,14 +270,8 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudio",
"Support services for audio plugins",
plugin_init,
VERSION,
GST_LICENSE,
GST_PACKAGE,
GST_ORIGIN
);
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);

View file

@ -26,7 +26,6 @@
#define __GST_AUDIO_AUDIO_H__
G_BEGIN_DECLS
/* For people that are looking at this source: the purpose of these defines is
* to make GstCaps a bit easier, in that you don't have to know all of the
* properties that need to be defined. you can just use these macros. currently
@ -50,9 +49,7 @@ G_BEGIN_DECLS
*
* Andy Wingo, 18 August 2001
* Thomas, 6 September 2002 */
#define GST_AUDIO_DEF_RATE 44100
#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
@ -61,8 +58,6 @@ G_BEGIN_DECLS
"width = (int) { 8, 16, 32 }, " \
"depth = (int) [ 1, 32 ], " \
"signed = (boolean) { true, false }"
/* "standard" int audio is native order, 16 bit stereo. */
#define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS \
"audio/x-raw-int, " \
@ -72,7 +67,6 @@ G_BEGIN_DECLS
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (boolean) true"
#define GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS \
"audio/x-raw-float, " \
"rate = (int) [ 1, MAX ], " \
@ -80,7 +74,6 @@ G_BEGIN_DECLS
"endianness = (int) { LITTLE_ENDIAN , BIG_ENDIAN }, " \
"width = (int) { 32, 64 }, " \
"buffer-frames = (int) [ 1, MAX]"
/* "standard" float audio is native order, 32 bit mono. */
#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS \
"audio/x-raw-float, " \
@ -88,12 +81,10 @@ G_BEGIN_DECLS
"channels = (int) 1, " \
"endianness = (int) BYTE_ORDER, " \
"buffer-frames = (int) [ 1, MAX]"
/*
* this library defines and implements some helper functions for audio
* handling
*/
/* get byte size of audio frame (based on caps of pad */
int gst_audio_frame_byte_size (GstPad * pad);
@ -113,7 +104,8 @@ long gst_audio_highest_sample_value (GstPad* pad);
gboolean gst_audio_is_buffer_framed (GstPad * pad, GstBuffer * buf);
/* functions useful for _getcaps functions */
typedef enum {
typedef enum
{
GST_AUDIO_FIELD_RATE = (1 << 0),
GST_AUDIO_FIELD_CHANNELS = (1 << 1),
GST_AUDIO_FIELD_ENDIANNESS = (1 << 2),
@ -123,8 +115,8 @@ typedef enum {
GST_AUDIO_FIELD_BUFFER_FRAMES = (1 << 6)
} GstAudioFieldFlag;
void gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag);
void gst_audio_structure_set_int (GstStructure * structure,
GstAudioFieldFlag flag);
G_END_DECLS
#endif /* __GST_AUDIO_AUDIO_H__ */

View file

@ -36,6 +36,7 @@ static void gst_audio_clock_id_unschedule (GstClock *clock,
GstClockEntry * entry);
static GstSystemClockClass *parent_class = NULL;
/* static guint gst_audio_clock_signals[LAST_SIGNAL] = { 0 }; */
GType
@ -91,9 +92,11 @@ gst_audio_clock_init (GstAudioClock *clock)
}
GstClock *
gst_audio_clock_new (gchar *name, GstAudioClockGetTimeFunc func, gpointer user_data)
gst_audio_clock_new (gchar * name, GstAudioClockGetTimeFunc func,
gpointer user_data)
{
GstAudioClock *aclock = GST_AUDIO_CLOCK (g_object_new (GST_TYPE_AUDIO_CLOCK, NULL));
GstAudioClock *aclock =
GST_AUDIO_CLOCK (g_object_new (GST_TYPE_AUDIO_CLOCK, NULL));
aclock->func = func;
aclock->user_data = user_data;
@ -117,6 +120,7 @@ gst_audio_clock_set_active (GstAudioClock *aclock, gboolean active)
aclock->adjust = time - aclock->func (clock, aclock->user_data);
} else {
GTimeVal timeval;
g_get_current_time (&timeval);
aclock->adjust = GST_TIMEVAL_TO_TIME (timeval) - time;
@ -175,8 +179,7 @@ gst_audio_clock_id_wait_async (GstClock *clock, GstClockEntry *entry)
GstAudioClock *aclock = (GstAudioClock *) clock;
aclock->async_entries = g_slist_insert_sorted (aclock->async_entries,
entry,
(GCompareFunc)compare_clock_entries);
entry, (GCompareFunc) compare_clock_entries);
/* is this the proper return val? */
return GST_CLOCK_EARLY;
@ -187,6 +190,5 @@ gst_audio_clock_id_unschedule (GstClock *clock, GstClockEntry *entry)
{
GstAudioClock *aclock = (GstAudioClock *) clock;
aclock->async_entries = g_slist_remove (aclock->async_entries,
entry);
aclock->async_entries = g_slist_remove (aclock->async_entries, entry);
}

View file

@ -27,7 +27,6 @@
#include <gst/gstsystemclock.h>
G_BEGIN_DECLS
#define GST_TYPE_AUDIO_CLOCK \
(gst_audio_clock_get_type())
#define GST_AUDIO_CLOCK(obj) \
@ -38,14 +37,15 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_CLOCK))
#define GST_IS_AUDIO_CLOCK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_CLOCK))
typedef struct _GstAudioClock GstAudioClock;
typedef struct _GstAudioClockClass GstAudioClockClass;
typedef GstClockTime (*GstAudioClockGetTimeFunc) (GstClock *clock, gpointer user_data);
typedef GstClockTime (*GstAudioClockGetTimeFunc) (GstClock * clock,
gpointer user_data);
struct _GstAudioClock {
struct _GstAudioClock
{
GstSystemClock clock;
GstClockTime prev1, prev2;
@ -63,7 +63,8 @@ struct _GstAudioClock {
gpointer _gst_reserved[GST_PADDING];
};
struct _GstAudioClockClass {
struct _GstAudioClockClass
{
GstSystemClockClass parent_class;
gpointer _gst_reserved[GST_PADDING];
@ -77,5 +78,4 @@ void gst_audio_clock_set_active (GstAudioClock *aclock, gboolean active);
void gst_audio_clock_update_time (GstAudioClock * aclock, GstClockTime time);
G_END_DECLS
#endif /* __GST_AUDIO_CLOCK_H__ */

View file

@ -29,12 +29,14 @@
/* GstAudiofilter signals and args */
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
ARG_METHOD,
/* FILL ME */
@ -44,8 +46,10 @@ static void gst_audiofilter_base_init (gpointer g_class);
static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data);
static void gst_audiofilter_init (GTypeInstance * instance, gpointer g_class);
static void gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void gst_audiofilter_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_audiofilter_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_audiofilter_chain (GstPad * pad, GstData * _data);
GstCaps *gst_audiofilter_class_get_capslist (GstAudiofilterClass * klass);
@ -75,7 +79,8 @@ gst_audiofilter_get_type (void)
return audiofilter_type;
}
static void gst_audiofilter_base_init (gpointer g_class)
static void
gst_audiofilter_base_init (gpointer g_class)
{
static GstElementDetails audiofilter_details = {
"Audio filter base class",
@ -89,7 +94,8 @@ static void gst_audiofilter_base_init (gpointer g_class)
gst_element_class_set_details (element_class, &audiofilter_details);
}
static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data)
static void
gst_audiofilter_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@ -116,8 +122,7 @@ gst_audiofilter_link (GstPad *pad, const GstCaps *caps)
GST_DEBUG ("gst_audiofilter_link");
audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad));
audiofilter_class = GST_AUDIOFILTER_CLASS (
G_OBJECT_GET_CLASS (audiofilter));
audiofilter_class = GST_AUDIOFILTER_CLASS (G_OBJECT_GET_CLASS (audiofilter));
if (pad == audiofilter->srcpad) {
@ -135,7 +140,8 @@ gst_audiofilter_link (GstPad *pad, const GstCaps *caps)
if (strcmp (gst_structure_get_name (structure), "audio/x-raw-int") == 0) {
ret = gst_structure_get_int (structure, "depth", &audiofilter->depth);
ret &= gst_structure_get_int (structure, "width", &audiofilter->width);
ret &= gst_structure_get_int (structure, "channels", &audiofilter->channels);
ret &=
gst_structure_get_int (structure, "channels", &audiofilter->channels);
} else if (strcmp (gst_structure_get_name (structure), "audio/x-raw-float")
== 0) {
@ -147,7 +153,8 @@ gst_audiofilter_link (GstPad *pad, const GstCaps *caps)
audiofilter->bytes_per_sample = (audiofilter->width / 8) *
audiofilter->channels;
if (audiofilter_class->setup) (audiofilter_class->setup) (audiofilter);
if (audiofilter_class->setup)
(audiofilter_class->setup) (audiofilter);
return GST_PAD_LINK_OK;
}
@ -160,8 +167,8 @@ gst_audiofilter_init (GTypeInstance *instance, gpointer g_class)
GST_DEBUG ("gst_audiofilter_init");
pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
"sink");
pad_template =
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "sink");
g_return_if_fail (pad_template != NULL);
audiofilter->sinkpad = gst_pad_new_from_template (pad_template, "sink");
gst_element_add_pad (GST_ELEMENT (audiofilter), audiofilter->sinkpad);
@ -169,8 +176,8 @@ gst_audiofilter_init (GTypeInstance *instance, gpointer g_class)
gst_pad_set_link_function (audiofilter->sinkpad, gst_audiofilter_link);
gst_pad_set_getcaps_function (audiofilter->sinkpad, gst_pad_proxy_getcaps);
pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
"src");
pad_template =
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src");
g_return_if_fail (pad_template != NULL);
audiofilter->srcpad = gst_pad_new_from_template (pad_template, "src");
gst_element_add_pad (GST_ELEMENT (audiofilter), audiofilter->srcpad);
@ -196,8 +203,7 @@ gst_audiofilter_chain (GstPad *pad, GstData *data)
audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad));
//g_return_if_fail (audiofilter->inited);
audiofilter_class = GST_AUDIOFILTER_CLASS (
G_OBJECT_GET_CLASS (audiofilter));
audiofilter_class = GST_AUDIOFILTER_CLASS (G_OBJECT_GET_CLASS (audiofilter));
GST_DEBUG ("gst_audiofilter_chain: got buffer of %d bytes in '%s'",
GST_BUFFER_SIZE (inbuf), GST_OBJECT_NAME (audiofilter));
@ -241,7 +247,8 @@ gst_audiofilter_chain (GstPad *pad, GstData *data)
}
static void
gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
gst_audiofilter_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstAudiofilter *src;
@ -257,7 +264,8 @@ gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *valu
}
static void
gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
gst_audiofilter_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstAudiofilter *src;
@ -272,8 +280,9 @@ gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GPa
}
}
void gst_audiofilter_class_add_pad_templates (
GstAudiofilterClass *audiofilter_class, const GstCaps *caps)
void
gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *
audiofilter_class, const GstCaps * caps)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (audiofilter_class);
@ -294,15 +303,8 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudiofilter",
"Audio filter parent class",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN
)
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)

View file

@ -25,9 +25,7 @@
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct _GstAudiofilter GstAudiofilter;
G_BEGIN_DECLS typedef struct _GstAudiofilter GstAudiofilter;
typedef struct _GstAudiofilterClass GstAudiofilterClass;
typedef void (*GstAudiofilterFilterFunc) (GstAudiofilter * filter,
@ -49,7 +47,8 @@ typedef void (*GstAudiofilterSetupFunc) (GstAudiofilter *filter);
#define GST_IS_AUDIOFILTER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOFILTER))
struct _GstAudiofilter {
struct _GstAudiofilter
{
GstElement element;
GstPad *sinkpad, *srcpad;
@ -68,7 +67,8 @@ struct _GstAudiofilter {
int bytes_per_sample;
};
struct _GstAudiofilterClass {
struct _GstAudiofilterClass
{
GstElementClass parent_class;
GstCaps *caps;
@ -79,9 +79,8 @@ struct _GstAudiofilterClass {
GType gst_audiofilter_get_type (void);
void gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *audiofilterclass, const GstCaps *caps);
void gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *
audiofilterclass, const GstCaps * caps);
G_END_DECLS
#endif /* __GST_AUDIOFILTER_H__ */

View file

@ -48,37 +48,47 @@ typedef struct _GstAudiofilterTemplateClass GstAudiofilterTemplateClass;
#define GST_IS_AUDIOFILTER_TEMPLATE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOFILTER_TEMPLATE))
struct _GstAudiofilterTemplate {
struct _GstAudiofilterTemplate
{
GstAudiofilter audiofilter;
};
struct _GstAudiofilterTemplateClass {
struct _GstAudiofilterTemplateClass
{
GstAudiofilterClass parent_class;
};
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
/* FILL ME */
};
static void gst_audiofilter_template_base_init (gpointer g_class);
static void gst_audiofilter_template_class_init (gpointer g_class, gpointer class_data);
static void gst_audiofilter_template_init (GTypeInstance *instance, gpointer g_class);
static void gst_audiofilter_template_class_init (gpointer g_class,
gpointer class_data);
static void gst_audiofilter_template_init (GTypeInstance * instance,
gpointer g_class);
static void gst_audiofilter_template_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_audiofilter_template_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void gst_audiofilter_template_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_audiofilter_template_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
static void gst_audiofilter_template_setup (GstAudiofilter * audiofilter);
static void gst_audiofilter_template_filter (GstAudiofilter *audiofilter, GstBuffer *outbuf, GstBuffer *inbuf);
static void gst_audiofilter_template_filter_inplace (GstAudiofilter *audiofilter, GstBuffer *buf);
static void gst_audiofilter_template_filter (GstAudiofilter * audiofilter,
GstBuffer * outbuf, GstBuffer * inbuf);
static void gst_audiofilter_template_filter_inplace (GstAudiofilter *
audiofilter, GstBuffer * buf);
GType
gst_audiofilter_template_get_type (void)
@ -103,7 +113,8 @@ gst_audiofilter_template_get_type (void)
return audiofilter_template_type;
}
static void gst_audiofilter_template_base_init (gpointer g_class)
static void
gst_audiofilter_template_base_init (gpointer g_class)
{
static GstElementDetails audiofilter_template_details = {
"Audio filter template",
@ -162,7 +173,8 @@ gst_audiofilter_template_init (GTypeInstance *instance, gpointer g_class)
}
static void
gst_audiofilter_template_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
gst_audiofilter_template_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstAudiofilterTemplate *src;
@ -178,7 +190,8 @@ gst_audiofilter_template_set_property (GObject *object, guint prop_id, const GVa
}
static void
gst_audiofilter_template_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
gst_audiofilter_template_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstAudiofilterTemplate *src;
@ -203,20 +216,13 @@ plugin_init (GstPlugin *plugin)
GST_TYPE_AUDIOFILTER_TEMPLATE);
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudiofilter_template",
"Audio filter template",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN
)
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
static void
gst_audiofilter_template_setup (GstAudiofilter *audiofilter)
static void gst_audiofilter_template_setup (GstAudiofilter * audiofilter)
{
GstAudiofilterTemplate *audiofilter_template;
@ -245,8 +251,7 @@ gst_audiofilter_template_filter (GstAudiofilter *audiofilter,
/* do something interesting here. This simply copies the source
* to the destination. */
memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf),
audiofilter->size);
memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf), audiofilter->size);
}
static void
@ -262,4 +267,3 @@ gst_audiofilter_template_filter_inplace (GstAudiofilter *audiofilter,
* to the destination. */
}

View file

@ -27,7 +27,8 @@
#include "colorbalance.h"
#include "colorbalance-marshal.h"
enum {
enum
{
VALUE_CHANGED,
LAST_SIGNAL
};
@ -55,8 +56,7 @@ gst_color_balance_get_type (void)
};
gst_color_balance_type = g_type_register_static (G_TYPE_INTERFACE,
"GstColorBalance",
&gst_color_balance_info, 0);
"GstColorBalance", &gst_color_balance_info, 0);
g_type_interface_add_prerequisite (gst_color_balance_type,
GST_TYPE_IMPLEMENTS_INTERFACE);
}
@ -76,8 +76,7 @@ gst_color_balance_class_init (GstColorBalanceClass *klass)
G_STRUCT_OFFSET (GstColorBalanceClass, value_changed),
NULL, NULL,
gst_color_balance_marshal_VOID__OBJECT_INT,
G_TYPE_NONE, 2,
GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
G_TYPE_NONE, 2, GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
initialized = TRUE;
}
@ -104,8 +103,7 @@ gst_color_balance_list_channels (GstColorBalance *balance)
void
gst_color_balance_set_value (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value)
GstColorBalanceChannel * channel, gint value)
{
GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
@ -129,12 +127,10 @@ gst_color_balance_get_value (GstColorBalance *balance,
void
gst_color_balance_value_changed (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value)
GstColorBalanceChannel * channel, gint value)
{
g_signal_emit (G_OBJECT (balance),
gst_color_balance_signals[VALUE_CHANGED],
0, channel, value);
gst_color_balance_signals[VALUE_CHANGED], 0, channel, value);
g_signal_emit_by_name (G_OBJECT (channel), "value_changed", value);
}

View file

@ -27,7 +27,6 @@
#include <gst/colorbalance/colorbalance-enumtypes.h>
G_BEGIN_DECLS
#define GST_TYPE_COLOR_BALANCE \
(gst_color_balance_get_type ())
#define GST_COLOR_BALANCE(obj) \
@ -42,9 +41,7 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_COLOR_BALANCE))
#define GST_COLOR_BALANCE_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_COLOR_BALANCE, GstColorBalanceClass))
#define GST_COLOR_BALANCE_TYPE(klass) (klass->balance_type)
typedef struct _GstColorBalance GstColorBalance;
typedef enum
@ -53,7 +50,8 @@ typedef enum
GST_COLOR_BALANCE_SOFTWARE
} GstColorBalanceType;
typedef struct _GstColorBalanceClass {
typedef struct _GstColorBalanceClass
{
GTypeInterface klass;
GstColorBalanceType balance_type;
@ -62,15 +60,13 @@ typedef struct _GstColorBalanceClass {
const GList *(*list_channels) (GstColorBalance * balance);
void (*set_value) (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value);
GstColorBalanceChannel * channel, gint value);
gint (*get_value) (GstColorBalance * balance,
GstColorBalanceChannel * channel);
/* signals */
void (*value_changed) (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value);
GstColorBalanceChannel * channel, gint value);
gpointer _gst_reserved[GST_PADDING];
} GstColorBalanceClass;
@ -78,19 +74,15 @@ typedef struct _GstColorBalanceClass {
GType gst_color_balance_get_type (void);
/* virtual class function wrappers */
const GList *
gst_color_balance_list_channels (GstColorBalance *balance);
const GList *gst_color_balance_list_channels (GstColorBalance * balance);
void gst_color_balance_set_value (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value);
GstColorBalanceChannel * channel, gint value);
gint gst_color_balance_get_value (GstColorBalance * balance,
GstColorBalanceChannel * channel);
/* trigger signal */
void gst_color_balance_value_changed (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value);
GstColorBalanceChannel * channel, gint value);
G_END_DECLS
#endif /* __GST_COLOR_BALANCE_H__ */

View file

@ -25,13 +25,15 @@
#include "colorbalancechannel.h"
enum {
enum
{
/* FILL ME */
SIGNAL_VALUE_CHANGED,
LAST_SIGNAL
};
static void gst_color_balance_channel_class_init (GstColorBalanceChannelClass *klass);
static void gst_color_balance_channel_class_init (GstColorBalanceChannelClass *
klass);
static void gst_color_balance_channel_init (GstColorBalanceChannel * balance);
static void gst_color_balance_channel_dispose (GObject * object);
@ -59,8 +61,7 @@ gst_color_balance_channel_get_type (void)
gst_color_balance_channel_type =
g_type_register_static (G_TYPE_OBJECT,
"GstColorBalanceChannel",
&color_balance_channel_info, 0);
"GstColorBalanceChannel", &color_balance_channel_info, 0);
}
return gst_color_balance_channel_type;
@ -78,8 +79,7 @@ gst_color_balance_channel_class_init (GstColorBalanceChannelClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstColorBalanceChannelClass,
value_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
object_klass->dispose = gst_color_balance_channel_dispose;
}

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_COLOR_BALANCE_CHANNEL \
(gst_color_balance_channel_get_type ())
#define GST_COLOR_BALANCE_CHANNEL(obj) \
@ -38,21 +37,20 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_COLOR_BALANCE_CHANNEL))
#define GST_IS_COLOR_BALANCE_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_COLOR_BALANCE_CHANNEL))
typedef struct _GstColorBalanceChannel {
typedef struct _GstColorBalanceChannel
{
GObject parent;
gchar *label;
gint min_value,
max_value;
gint min_value, max_value;
} GstColorBalanceChannel;
typedef struct _GstColorBalanceChannelClass {
typedef struct _GstColorBalanceChannelClass
{
GObjectClass parent;
/* signals */
void (* value_changed) (GstColorBalanceChannel *channel,
gint value);
void (*value_changed) (GstColorBalanceChannel * channel, gint value);
gpointer _gst_reserved[GST_PADDING];
} GstColorBalanceChannelClass;
@ -60,5 +58,4 @@ typedef struct _GstColorBalanceChannelClass {
GType gst_color_balance_channel_get_type (void);
G_END_DECLS
#endif /* __GST_COLOR_BALANCE_CHANNEL_H__ */

View file

@ -29,39 +29,31 @@
#include <glib/gtypes.h>
G_BEGIN_DECLS
#if (HAVE_LRINT && HAVE_LRINTF)
/* These defines enable functionality introduced with the 1999 ISO C
** standard. They must be defined before the inclusion of math.h to
** engage them. If optimisation is enabled, these functions will be
** inlined. With optimisation switched off, you have to link in the
** maths library using -lm.
*/
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC9X 1
#define __USE_ISOC99 1
#include <math.h>
#define gst_cast_float(x) ((gint)lrintf(x))
#define gst_cast_double(x) ((gint)lrint(x))
#else
/* use a standard c cast, but do rounding correctly */
#define gst_cast_float(x) ((gint)floor((x)+0.5))
#define gst_cast_double(x) ((gint)floor((x)+0.5))
#endif
inline static gfloat
GFLOAT_SWAP_LE_BE (gfloat in)
{
gint32 swap;
gfloat out;
memcpy (&swap, &in, 4);
swap = GUINT32_SWAP_LE_BE_CONSTANT (swap);
memcpy (&out, &swap, 4);
@ -73,6 +65,7 @@ GDOUBLE_SWAP_LE_BE(gdouble in)
{
gint64 swap;
gdouble out;
memcpy (&swap, &in, 8);
swap = GUINT64_SWAP_LE_BE_CONSTANT (swap);
memcpy (&out, &swap, 8);
@ -101,6 +94,4 @@ GDOUBLE_SWAP_LE_BE(gdouble in)
#define GDOUBLE_FROM_BE(val) (GDOUBLE_TO_BE (val))
G_END_DECLS
#endif /* __FLOATCAST_H__ */

View file

@ -57,22 +57,19 @@ gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction)
elements = (GList *) gst_bin_get_list (bin);
/* traverse all elements looking for unconnected pads */
while (elements && pad == NULL)
{
while (elements && pad == NULL) {
element = GST_ELEMENT (elements->data);
pads = gst_element_get_pad_list (element);
while (pads)
{
while (pads) {
/* check if the direction matches */
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction)
{
if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL)
{
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) {
if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) {
/* found it ! */
pad = GST_PAD (pads->data);
}
}
if (pad) break; /* found one already */
if (pad)
break; /* found one already */
pads = g_list_next (pads);
}
elements = g_list_next (elements);
@ -101,8 +98,7 @@ gst_gconf_get_string (const gchar *key)
value = gconf_client_get_string (gst_gconf_get_client (), full_key, &error);
g_free (full_key);
if (error)
{
if (error) {
g_print ("gst_gconf_get_string: error: %s\n", error->message);
g_error_free (error);
}
@ -124,8 +120,7 @@ gst_gconf_set_string (const gchar *key, const gchar *value)
gchar *full_key = g_strdup_printf ("%s/%s", GST_GCONF_DIR, key);
gconf_client_set_string (gst_gconf_get_client (), full_key, value, &error);
if (error)
{
if (error) {
g_print ("gst_gconf_set_string: error: %s\n", error->message);
g_error_free (error);
}
@ -152,8 +147,7 @@ gst_gconf_render_bin_from_description (const gchar *description)
desc = g_strdup_printf ("bin.( %s )", description);
bin = GST_ELEMENT (gst_parse_launch (desc, &error));
g_free (desc);
if (error)
{
if (error) {
g_print ("DEBUG: gstgconf: error parsing pipeline %s\n%s\n",
description, error->message);
g_error_free (error);
@ -313,11 +307,11 @@ gst_gconf_get_default_visualization_element (void)
ret = gst_element_factory_make ("goom", NULL);
if (!ret)
g_warning ("No GConf default visualization plugin key and goom doesn't work");
g_warning
("No GConf default visualization plugin key and goom doesn't work");
else
g_print ("GConf visualization plugin not found, using goom\n");
}
return ret;
}

View file

@ -28,8 +28,7 @@
#include <gconf/gconf-client.h>
gchar *gst_gconf_get_string (const gchar * key);
void gst_gconf_set_string (const gchar *key,
const gchar *value);
void gst_gconf_set_string (const gchar * key, const gchar * value);
GstElement *gst_gconf_render_bin_from_key (const gchar * key);
GstElement *gst_gconf_render_bin_from_description (const gchar * description);

View file

@ -29,4 +29,3 @@ extern void gst_idct_sse_idct (short *block);
extern void gst_idct_init_float_idct (void);
extern void gst_idct_float_idct (short *block);

View file

@ -72,16 +72,17 @@ static void idctcol (short *blk);
* c[1..7] = 128*sqrt(2)
*/
static void idctrow(blk)
static void
idctrow (blk)
short *blk;
{
int x0, x1, x2, x3, x4, x5, x6, x7, x8;
/* shortcut */
if (!((x1 = blk[4] << 11) | (x2 = blk[6]) | (x3 = blk[2]) |
(x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3])))
{
blk[0]=blk[1]=blk[2]=blk[3]=blk[4]=blk[5]=blk[6]=blk[7]=blk[0]<<3;
(x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3]))) {
blk[0] = blk[1] = blk[2] = blk[3] = blk[4] = blk[5] = blk[6] = blk[7] =
blk[0] << 3;
return;
}
@ -134,17 +135,18 @@ short *blk;
* where: c[0] = 1/1024
* c[1..7] = (1/1024)*sqrt(2)
*/
static void idctcol(blk)
static void
idctcol (blk)
short *blk;
{
int x0, x1, x2, x3, x4, x5, x6, x7, x8;
/* shortcut */
if (!((x1 = (blk[8 * 4] << 8)) | (x2 = blk[8 * 6]) | (x3 = blk[8 * 2]) |
(x4 = blk[8*1]) | (x5 = blk[8*7]) | (x6 = blk[8*5]) | (x7 = blk[8*3])))
{
blk[8*0]=blk[8*1]=blk[8*2]=blk[8*3]=blk[8*4]=blk[8*5]=blk[8*6]=blk[8*7]=
iclp[(blk[8*0]+32)>>6];
(x4 = blk[8 * 1]) | (x5 = blk[8 * 7]) | (x6 = blk[8 * 5]) | (x7 =
blk[8 * 3]))) {
blk[8 * 0] = blk[8 * 1] = blk[8 * 2] = blk[8 * 3] = blk[8 * 4] =
blk[8 * 5] = blk[8 * 6] = blk[8 * 7] = iclp[(blk[8 * 0] + 32) >> 6];
return;
}
@ -189,7 +191,8 @@ short *blk;
}
/* two dimensional inverse discrete cosine transform */
void gst_idct_fast_int_idct(block)
void
gst_idct_fast_int_idct (block)
short *block;
{
int i;
@ -201,7 +204,8 @@ short *block;
idctcol (block + i);
}
void gst_idct_init_fast_int_idct()
void
gst_idct_init_fast_int_idct ()
{
int i;

View file

@ -56,22 +56,24 @@ static double gst_idct_float_c[8][8];
/* initialize DCT coefficient matrix */
void gst_idct_init_float_idct()
void
gst_idct_init_float_idct ()
{
int freq, time;
double scale;
for (freq=0; freq < 8; freq++)
{
for (freq = 0; freq < 8; freq++) {
scale = (freq == 0) ? sqrt (0.125) : 0.5;
for (time = 0; time < 8; time++)
gst_idct_float_c[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5));
gst_idct_float_c[freq][time] =
scale * cos ((PI / 8.0) * freq * (time + 0.5));
}
}
/* perform IDCT matrix multiply for 8x8 coefficient block */
void gst_idct_float_idct(block)
void
gst_idct_float_idct (block)
short *block;
{
int i, j, k, v;
@ -79,8 +81,7 @@ short *block;
double tmp[64];
for (i = 0; i < 8; i++)
for (j=0; j<8; j++)
{
for (j = 0; j < 8; j++) {
partial_product = 0.0;
for (k = 0; k < 8; k++)
@ -93,8 +94,7 @@ short *block;
loop order of i and j */
for (j = 0; j < 8; j++)
for (i=0; i<8; i++)
{
for (i = 0; i < 8; i++) {
partial_product = 0.0;
for (k = 0; k < 8; k++)

View file

@ -27,7 +27,8 @@
static void gst_idct_int_sparse_idct (short *data);
GstIDCT *gst_idct_new(GstIDCTMethod method)
GstIDCT *
gst_idct_new (GstIDCTMethod method)
{
GstIDCT *new = g_malloc (sizeof (GstIDCT));
@ -92,7 +93,8 @@ GstIDCT *gst_idct_new(GstIDCTMethod method)
return new;
}
static void gst_idct_int_sparse_idct(short *data)
static void
gst_idct_int_sparse_idct (short *data)
{
short val;
gint32 v, *dp = (guint32 *) data;
@ -104,23 +106,47 @@ static void gst_idct_int_sparse_idct(short *data)
val += (8 >> 1);
val /= 8;
val = -val;
}
else {
} else {
val = (v + (8 >> 1)) / 8;
}
v = ((val & 0xffff) | (val << 16));
dp[0] = v; dp[1] = v; dp[2] = v; dp[3] = v;
dp[4] = v; dp[5] = v; dp[6] = v; dp[7] = v;
dp[8] = v; dp[9] = v; dp[10] = v; dp[11] = v;
dp[12] = v; dp[13] = v; dp[14] = v; dp[15] = v;
dp[16] = v; dp[17] = v; dp[18] = v; dp[19] = v;
dp[20] = v; dp[21] = v; dp[22] = v; dp[23] = v;
dp[24] = v; dp[25] = v; dp[26] = v; dp[27] = v;
dp[28] = v; dp[29] = v; dp[30] = v; dp[31] = v;
dp[0] = v;
dp[1] = v;
dp[2] = v;
dp[3] = v;
dp[4] = v;
dp[5] = v;
dp[6] = v;
dp[7] = v;
dp[8] = v;
dp[9] = v;
dp[10] = v;
dp[11] = v;
dp[12] = v;
dp[13] = v;
dp[14] = v;
dp[15] = v;
dp[16] = v;
dp[17] = v;
dp[18] = v;
dp[19] = v;
dp[20] = v;
dp[21] = v;
dp[22] = v;
dp[23] = v;
dp[24] = v;
dp[25] = v;
dp[26] = v;
dp[27] = v;
dp[28] = v;
dp[29] = v;
dp[30] = v;
dp[31] = v;
}
void gst_idct_destroy(GstIDCT *idct)
void
gst_idct_destroy (GstIDCT * idct)
{
g_return_if_fail (idct != NULL);
@ -133,14 +159,8 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstidct",
"Accelerated IDCT routines",
plugin_init,
VERSION,
GST_LICENSE,
GST_PACKAGE,
GST_ORIGIN
)
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)

View file

@ -23,7 +23,8 @@
#include <glib.h>
typedef enum {
typedef enum
{
GST_IDCT_DEFAULT,
GST_IDCT_INT,
GST_IDCT_FAST_INT,
@ -38,7 +39,8 @@ typedef void (*GstIDCTFunction) (gshort *block);
#define GST_IDCT_TRANSPOSE(idct) ((idct)->need_transpose)
struct _GstIDCT {
struct _GstIDCT
{
/* private */
GstIDCTFunction convert;
GstIDCTFunction convert_sparse;
@ -47,6 +49,7 @@ struct _GstIDCT {
GstIDCT *gst_idct_new (GstIDCTMethod method);
#define gst_idct_convert(idct, blocks) (idct)->convert((blocks))
#define gst_idct_convert_sparse(idct, blocks) (idct)->convert_sparse((blocks))
void gst_idct_destroy (GstIDCT * idct);

View file

@ -38,7 +38,8 @@ long sumsqerrs[DCTSIZE2];
int maxerr[DCTSIZE2];
char * meets (double val, double limit)
char *
meets (double val, double limit)
{
return ((fabs (val) <= limit) ? "meets" : "FAILS");
}
@ -61,7 +62,8 @@ main(int argc, char **argv)
/* Argument parsing --- not very bulletproof at all */
if (argc != 6) usage(NULL);
if (argc != 6)
usage (NULL);
method = atoi (argv[1]);
minpix = atoi (argv[2]);
@ -93,8 +95,10 @@ main(int argc, char **argv)
ref_fdct ((DCTELEM **) & refcoefs);
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
if (refcoefs[i] < -2048) refcoefs[i] = -2048;
else if (refcoefs[i] > 2047) refcoefs[i] = 2047;
if (refcoefs[i] < -2048)
refcoefs[i] = -2048;
else if (refcoefs[i] > 2047)
refcoefs[i] = 2047;
}
/* perform reference IDCT */
@ -102,8 +106,10 @@ main(int argc, char **argv)
ref_idct (refout);
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
if (refout[i] < -256) refout[i] = -256;
else if (refout[i] > 255) refout[i] = 255;
if (refout[i] < -256)
refout[i] = -256;
else if (refout[i] > 255)
refout[i] = 255;
}
/* perform test IDCT */
@ -113,8 +119,7 @@ main(int argc, char **argv)
testout[i * DCTSIZE + j] = refcoefs[j * DCTSIZE + i];
}
}
}
else {
} else {
memcpy (testout, refcoefs, sizeof (DCTELEM) * DCTSIZE2);
}
@ -122,22 +127,29 @@ main(int argc, char **argv)
gst_idct_convert (idct, testout);
gst_trace_read_tsc (&tscstop);
/*printf("time %llu, %llu %lld\n", tscstart, tscstop, tscstop-tscstart); */
if (tscstop - tscstart < tscmin) tscmin = tscstop-tscstart;
if (tscstop - tscstart > tscmax) tscmax = tscstop-tscstart;
if (tscstop - tscstart < tscmin)
tscmin = tscstop - tscstart;
if (tscstop - tscstart > tscmax)
tscmax = tscstop - tscstart;
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
if (testout[i] < -256) testout[i] = -256;
else if (testout[i] > 255) testout[i] = 255;
if (testout[i] < -256)
testout[i] = -256;
else if (testout[i] > 255)
testout[i] = 255;
}
/* accumulate error stats */
for (i = 0; i < DCTSIZE2; i++) {
register int err = testout[i] - refout[i];
sumerrs[i] += err;
sumsqerrs[i] += err * err;
if (err < 0) err = -err;
if (maxerr[i] < err) maxerr[i] = err;
if (err < 0)
err = -err;
if (maxerr[i] < err)
maxerr[i] = err;
}
if (curiter % 100 == 99) {
@ -149,16 +161,19 @@ main(int argc, char **argv)
/* print results */
printf("IEEE test conditions: -L = %ld, +H = %ld, sign = %ld, #iters = %ld\n",
printf
("IEEE test conditions: -L = %ld, +H = %ld, sign = %ld, #iters = %ld\n",
minpix, maxpix, sign, niters);
printf ("Speed, min time %lld, max %lld\n", tscmin, tscmax);
printf ("Peak absolute values of errors:\n");
for (i = 0, j = 0; i < DCTSIZE2; i++) {
if (j < maxerr[i]) j = maxerr[i];
if (j < maxerr[i])
j = maxerr[i];
printf ("%4d", maxerr[i]);
if ((i%DCTSIZE) == DCTSIZE-1) printf("\n");
if ((i % DCTSIZE) == DCTSIZE - 1)
printf ("\n");
}
printf ("Worst peak error = %d (%s spec limit 1)\n\n", j,
meets ((double) j, 1.0));
@ -167,10 +182,13 @@ main(int argc, char **argv)
max = total = 0.0;
for (i = 0; i < DCTSIZE2; i++) {
double err = (double) sumsqerrs[i] / ((double) niters);
total += (double) sumsqerrs[i];
if (max < err) max = err;
if (max < err)
max = err;
printf (" %8.4f", err);
if ((i%DCTSIZE) == DCTSIZE-1) printf("\n");
if ((i % DCTSIZE) == DCTSIZE - 1)
printf ("\n");
}
printf ("Worst pmse = %.6f (%s spec limit 0.06)\n", max, meets (max, 0.06));
total /= (double) (64 * niters);
@ -181,11 +199,15 @@ main(int argc, char **argv)
max = total = 0.0;
for (i = 0; i < DCTSIZE2; i++) {
double err = (double) sumerrs[i] / ((double) niters);
total += (double) sumerrs[i];
printf (" %8.4f", err);
if (err < 0.0) err = -err;
if (max < err) max = err;
if ((i%DCTSIZE) == DCTSIZE-1) printf("\n");
if (err < 0.0)
err = -err;
if (max < err)
max = err;
if ((i % DCTSIZE) == DCTSIZE - 1)
printf ("\n");
}
printf ("Worst mean error = %.6f (%s spec limit 0.015)\n", max,
meets (max, 0.015));
@ -209,7 +231,8 @@ main(int argc, char **argv)
}
void usage (char *msg)
void
usage (char *msg)
{
if (msg != NULL)
fprintf (stderr, "\nerror: %s\n", msg);
@ -230,7 +253,8 @@ void usage (char *msg)
/* Pseudo-random generator specified by IEEE 1180 */
long ieeerand (long L, long H)
long
ieeerand (long L, long H)
{
static long randx = 1;
static double z = (double) 0x7fffffff;
@ -256,7 +280,8 @@ double coslu[8][8];
/* Routine to initialise the cosine lookup table */
void dct_init(void)
void
dct_init (void)
{
int a, b;
double tmp;
@ -271,7 +296,8 @@ void dct_init(void)
}
void ref_fdct (DCTELEM block[8][8])
void
ref_fdct (DCTELEM block[8][8])
{
int x, y, u, v;
double tmp, tmp2;
@ -305,7 +331,8 @@ void ref_fdct (DCTELEM block[8][8])
}
void ref_idct (DCTELEM block[8][8])
void
ref_idct (DCTELEM block[8][8])
{
int x, y, u, v;
double tmp, tmp2;

View file

@ -53,8 +53,6 @@
#if DCTSIZE != 8
Sorry, this code only copes with 8 x8 DCTs. /* deliberate syntax err */
#endif
/*
* A 2-D IDCT can be done by 1-D IDCT on each row followed by 1-D IDCT
* on each column. Direct algorithms are also available, but they are
@ -90,7 +88,6 @@
* have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis
* shows that the values given below are the most effective.
*/
#ifdef EIGHT_BIT_SAMPLES
#define CONST_BITS 13
#define PASS1_BITS 2
@ -98,22 +95,16 @@
#define CONST_BITS 13
#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
#endif
#define ONE ((INT32) 1)
#define CONST_SCALE (ONE << CONST_BITS)
/* Convert a positive real constant to an integer scaled by CONST_SCALE. */
#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
* causing a lot of useless floating-point operations at run time.
* To get around this we use the following pre-calculated constants.
* If you change CONST_BITS you may want to add appropriate values.
* (With a reasonable C compiler, you can just rely on the FIX() macro...)
*/
#if CONST_BITS == 13
#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */
#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */
@ -141,15 +132,11 @@
#define FIX_2_562915447 FIX(2.562915447)
#define FIX_3_072711026 FIX(3.072711026)
#endif
/* Descale and correctly round an INT32 value that's scaled by N bits.
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
* the fudge factor is correct for either sign of X.
*/
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
* For 8-bit samples with the recommended scaling, all the variable
* and constant values involved are no more than 16 bits wide, so a
@ -160,7 +147,6 @@
* combination of casts.
* NB: for 12-bit samples, a full 32-bit multiplication will be needed.
*/
#ifdef EIGHT_BIT_SAMPLES
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
#define MULTIPLY(var,const) (((INT16) (var)) * ((INT16) (const)))
@ -169,16 +155,12 @@
#define MULTIPLY(var,const) (((INT16) (var)) * ((INT32) (const)))
#endif
#endif
#ifndef MULTIPLY /* default definition */
#define MULTIPLY(var,const) ((var) * (const))
#endif
/*
* Perform the inverse DCT on one block of coefficients.
*/
void
gst_idct_int_idct (DCTBLOCK data)
{
@ -187,12 +169,11 @@ gst_idct_int_idct (DCTBLOCK data)
INT32 z1, z2, z3, z4, z5;
register DCTELEM *dataptr;
int rowctr;
SHIFT_TEMPS
SHIFT_TEMPS
/* Pass 1: process rows. */
/* Note results are scaled up by sqrt(8) compared to a true IDCT; */
/* furthermore, we scale the results by 2**PASS1_BITS. */
dataptr = data;
for (rowctr = DCTSIZE - 1; rowctr >= 0; rowctr--) {
/* Due to quantization, we will usually find that many of the input
@ -331,8 +312,12 @@ gst_idct_int_idct (DCTBLOCK data)
tmp2 = z1 + MULTIPLY (z3, -FIX_1_847759065);
tmp3 = z1 + MULTIPLY (z2, FIX_0_765366865);
tmp0 = ((INT32) dataptr[DCTSIZE*0] + (INT32) dataptr[DCTSIZE*4]) << CONST_BITS;
tmp1 = ((INT32) dataptr[DCTSIZE*0] - (INT32) dataptr[DCTSIZE*4]) << CONST_BITS;
tmp0 =
((INT32) dataptr[DCTSIZE * 0] +
(INT32) dataptr[DCTSIZE * 4]) << CONST_BITS;
tmp1 =
((INT32) dataptr[DCTSIZE * 0] -
(INT32) dataptr[DCTSIZE * 4]) << CONST_BITS;
tmp10 = tmp0 + tmp3;
tmp13 = tmp0 - tmp3;

View file

@ -21,7 +21,6 @@
*
*/
/* MMX32 iDCT algorithm (IEEE-1180 compliant) :: idct_mmx32() */
/* */
/* MPEG2AVI */
@ -103,7 +102,6 @@
/* liaor@umcc.ais.org http://members.tripod.com/~liaor */
/* */
/*;============================================================================= */
/*; */
/*; AP-922 http://developer.intel.com/vtune/cbts/strmsimd */
@ -114,11 +112,9 @@
/*
mword typedef qword
qword ptr equ mword ptr */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <mmx.h>
#define BITS_INV_ACC 4 /*; 4 or 5 for IEEE */
@ -133,13 +129,13 @@ qword ptr equ mword ptr */
/*#define RND_INV_ROW (1024 * (6 - BITS_INV_ACC)) //; 1 << (SHIFT_INV_ROW-1) */
/*#define RND_INV_COL (16 * (BITS_INV_ACC - 3)) //; 1 << (SHIFT_INV_COL-1) */
/*.data */
/*Align 16 */
const static long r_inv_row[2] = { RND_INV_ROW, RND_INV_ROW };
const static long r_inv_col[2] = { RND_INV_COL, RND_INV_COL };
const static long r_inv_corr[2] = { RND_INV_CORR, RND_INV_CORR };
/*const static short r_inv_col[4] = */
/* {RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL}; */
/*const static short r_inv_corr[4] = */
@ -151,10 +147,10 @@ const static long r_inv_corr[2] = {RND_INV_CORR, RND_INV_CORR };
/*#define SHIFT_FRW_COL BITS_FRW_ACC */
/*#define SHIFT_FRW_ROW (BITS_FRW_ACC + 17) */
/*#define RND_FRW_ROW (262144 * (BITS_FRW_ACC - 1)) //; 1 << (SHIFT_FRW_ROW-1) */
const static __int64 one_corr = 0x0001000100010001;
const static long r_frw_row[2] = { RND_FRW_ROW, RND_FRW_ROW };
/*const static short tg_1_16[4] = {13036, 13036, 13036, 13036 }; //tg * (2<<16) + 0.5 */
/*const static short tg_2_16[4] = {27146, 27146, 27146, 27146 }; //tg * (2<<16) + 0.5 */
/*const static short tg_3_16[4] = {-21746, -21746, -21746, -21746 }; //tg * (2<<16) + 0.5 */
@ -162,12 +158,13 @@ const static long r_frw_row[2] = {RND_FRW_ROW, RND_FRW_ROW };
/*const static short ocos_4_16[4] = {23170, 23170, 23170, 23170 }; //cos * (2<<15) + 0.5 */
/*concatenated table, for forward DCT transformation */
const static short tg_all_16[] = {
13036, 13036, 13036, 13036, /* tg * (2<<16) + 0.5 */
const static short tg_all_16[] = { 13036, 13036, 13036, 13036, /* tg * (2<<16) + 0.5 */
27146, 27146, 27146, 27146, /*tg * (2<<16) + 0.5 */
-21746, -21746, -21746, -21746, /* tg * (2<<16) + 0.5 */
-19195, -19195, -19195, -19195, /*cos * (2<<16) + 0.5 */
23170, 23170, 23170, 23170 }; /*cos * (2<<15) + 0.5 */
23170, 23170, 23170, 23170
}; /*cos * (2<<15) + 0.5 */
#define tg_1_16 (tg_all_16 + 0)
#define tg_2_16 (tg_all_16 + 8)
@ -236,51 +233,53 @@ IF _MMX ; MMX code
;=============================================================================
/*; Table for rows 0,4 - constants are multiplied by cos_4_16 */
const short tab_i_04[] = {
16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00 */
const short tab_i_04[] = { 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00 */
21407, 8867, 8867, -21407, /* w07 w05 w03 w01 */
16384, -16384, 16384, 16384, /*; w14 w12 w10 w08 */
-8867, 21407, -21407, -8867, /*; w15 w13 w11 w09 */
22725, 12873, 19266, -22725, /*; w22 w20 w18 w16 */
19266, 4520, -4520, -12873, /*; w23 w21 w19 w17 */
12873, 4520, 4520, 19266, /*; w30 w28 w26 w24 */
-22725, 19266, -12873, -22725 };/*w31 w29 w27 w25 */
-22725, 19266, -12873, -22725
}; /*w31 w29 w27 w25 */
/*; Table for rows 1,7 - constants are multiplied by cos_1_16 */
const short tab_i_17[] = {
22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00 */
const short tab_i_17[] = { 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00 */
29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01 */
22725, -22725, 22725, 22725, /*; w14 w12 w10 w08 */
-12299, 29692, -29692, -12299, /*; w15 w13 w11 w09 */
31521, 17855, 26722, -31521, /*; w22 w20 w18 w16 */
26722, 6270, -6270, -17855, /*; w23 w21 w19 w17 */
17855, 6270, 6270, 26722, /*; w30 w28 w26 w24 */
-31521, 26722, -17855, -31521}; /* w31 w29 w27 w25 */
-31521, 26722, -17855, -31521
}; /* w31 w29 w27 w25 */
/*; Table for rows 2,6 - constants are multiplied by cos_2_16 */
const short tab_i_26[] = {
21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00 */
const short tab_i_26[] = { 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00 */
27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01 */
21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08 */
-11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09 */
29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16 */
25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17 */
16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24 */
-29692, 25172, -16819, -29692}; /* ;w31 w29 w27 w25 */
-29692, 25172, -16819, -29692
}; /* ;w31 w29 w27 w25 */
/*; Table for rows 3,5 - constants are multiplied by cos_3_16 */
const short tab_i_35[] = {
19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00 */
const short tab_i_35[] = { 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00 */
25172, 10426, 10426, -25172, /*; w07 w05 w03 w01 */
19266, -19266, 19266, 19266, /*; w14 w12 w10 w08 */
-10426, 25172, -25172, -10426, /*; w15 w13 w11 w09 */
26722, 15137, 22654, -26722, /*; w22 w20 w18 w16 */
22654, 5315, -5315, -15137, /*; w23 w21 w19 w17 */
15137, 5315, 5315, 22654, /*; w30 w28 w26 w24 */
-26722, 22654, -15137, -26722}; /*; w31 w29 w27 w25 */
*/
-26722, 22654, -15137, -26722
}; /*; w31 w29 w27 w25 */
*/
/* CONCATENATED TABLE, rows 0,1,2,3,4,5,6,7 (in order ) */
/* */
/* In our implementation, however, we only use row0 ! */
@ -366,7 +365,8 @@ static const short tab_i_01234567[] = {
31521, 17855, 26722, -31521, /*; w22 w20 w18 w16 */
26722, 6270, -6270, -17855, /*; w23 w21 w19 w17 */
17855, 6270, 6270, 26722, /*; w30 w28 w26 w24 */
-31521, 26722, -17855, -31521}; /* w31 w29 w27 w25 */
-31521, 26722, -17855, -31521
}; /* w31 w29 w27 w25 */
#define INP eax /* pointer to (short *blk) */
@ -380,21 +380,21 @@ static const short tab_i_01234567[] = {
/* private variables and functions */
/*temporary storage space, 8x8 of shorts */
__inline static void idct_mmx32_rows (short *blk); /* transform rows */
__inline static void idct_mmx32_cols (short *blk); /* transform "columns" */
/* the "column" transform actually transforms rows, it is */
/* identical to the row-transform except for the ROUNDING */
/* and SHIFTING coefficients. */
static void
idct_mmx32_rows( short *blk ) /* transform all 8 rows of 8x8 iDCT block */
{
idct_mmx32_rows (short *blk)
{ /* transform all 8 rows of 8x8 iDCT block */
int x;
short qwTemp[64];
short *out = &qwTemp[0];
short *inptr = blk;
/* this subroutine performs two operations */
/* 1) iDCT row transform */
/* for( i = 0; i < 8; ++ i) */
@ -402,88 +402,62 @@ idct_mmx32_rows( short *blk ) /* transform all 8 rows of 8x8 iDCT block */
/* */
/* 2) transpose the matrix (which was stored in qwTemp[]) */
/* qwTemp[] -> [8x8 matrix transpose] -> blk[] */
for (x = 0; x < 8; x++) { /* transform one row per iteration */
movq_m2r (*(inptr), mm0); /* 0 ; x3 x2 x1 x0 */
movq_m2r (*(inptr + 4), mm1); /* 1 ; x7 x6 x5 x4 */
movq_r2r (mm0, mm2); /* 2 ; x3 x2 x1 x0 */
movq_m2r (*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00 */
punpcklwd_r2r (mm1, mm0); /* x5 x1 x4 x0 */
/* ---------- */
movq_r2r (mm0, mm5); /* 5 ; x5 x1 x4 x0 */
punpckldq_r2r (mm0, mm0); /* x4 x0 x4 x0 */
movq_m2r (*(tab_i_01234567 + 4), mm4); /* 4 ; w07 w05 w03 w01 */
punpckhwd_r2r (mm1, mm2); /* 1 ; x7 x3 x6 x2 */
pmaddwd_r2r (mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00 */
movq_r2r (mm2, mm6); /* 6 ; x7 x3 x6 x2 */
movq_m2r (*(tab_i_01234567 + 16), mm1); /* 1 ; w22 w20 w18 w16 */
punpckldq_r2r (mm2, mm2); /* x6 x2 x6 x2 */
pmaddwd_r2r (mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01 */
punpckhdq_r2r (mm5, mm5); /* x5 x1 x5 x1 */
pmaddwd_m2r (*(tab_i_01234567 + 8), mm0); /* x4*w14+x0*w12 x4*w10+x0*w08 */
punpckhdq_r2r (mm6, mm6); /* x7 x3 x7 x3 */
movq_m2r (*(tab_i_01234567 + 20), mm7); /* 7 ; w23 w21 w19 w17 */
pmaddwd_r2r (mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16 */
paddd_m2r (*(r_inv_row), mm3); /* +rounder */
pmaddwd_r2r (mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17 */
pmaddwd_m2r (*(tab_i_01234567 + 12), mm2); /* x6*w15+x2*w13 x6*w11+x2*w09 */
paddd_r2r (mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0) */
pmaddwd_m2r (*(tab_i_01234567 + 24), mm5); /* x5*w30+x1*w28 x5*w26+x1*w24 */
movq_r2r (mm3, mm4); /* 4 ; a1 a0 */
pmaddwd_m2r (*(tab_i_01234567 + 28), mm6); /* x7*w31+x3*w29 x7*w27+x3*w25 */
paddd_r2r (mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0) */
paddd_m2r (*(r_inv_row), mm0); /* +rounder */
psubd_r2r (mm1, mm3); /* a1-b1 a0-b0 */
psrad_i2r (SHIFT_INV_ROW, mm3); /* y6=a1-b1 y7=a0-b0 */
paddd_r2r (mm4, mm1); /* 4 ; a1+b1 a0+b0 */
paddd_r2r (mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2) */
psrad_i2r (SHIFT_INV_ROW, mm1); /* y1=a1+b1 y0=a0+b0 */
paddd_r2r (mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2) */
movq_r2r (mm0, mm4); /* 4 ; a3 a2 */
paddd_r2r (mm5, mm0); /* a3+b3 a2+b2 */
psubd_r2r (mm5, mm4); /* 5 ; a3-b3 a2-b2 */
psrad_i2r (SHIFT_INV_ROW, mm4); /* y4=a3-b3 y5=a2-b2 */
psrad_i2r (SHIFT_INV_ROW, mm0); /* y3=a3+b3 y2=a2+b2 */
packssdw_r2r (mm3, mm4); /* 3 ; y6 y7 y4 y5 */
packssdw_r2r (mm0, mm1); /* 0 ; y3 y2 y1 y0 */
movq_r2r (mm4, mm7); /* 7 ; y6 y7 y4 y5 */
psrld_i2r (16, mm4); /* 0 y6 0 y4 */
movq_r2m (mm1, *(out)); /* 1 ; save y3 y2 y1 y0 */
pslld_i2r (16, mm7); /* y7 0 y5 0 */
por_r2r (mm4, mm7); /* 4 ; y7 y6 y5 y4 */
/* begin processing row 1 */
movq_r2m (mm7, *(out + 4)); /* 7 ; save y7 y6 y5 y4 */
inptr += 8;
out += 8;
}
/* done with the iDCT row-transformation */
/* now we have to transpose the output 8x8 matrix */
@ -494,7 +468,6 @@ idct_mmx32_rows( short *blk ) /* transform all 8 rows of 8x8 iDCT block */
/* 3) transpose lower-left quad */
/* 4) transpose upper-right quad */
/* mm0 = 1st row [ A B C D ] row1 */
/* mm1 = 2nd row [ E F G H ] 2 */
/* mm2 = 3rd row [ I J K L ] 3 */
@ -502,45 +475,31 @@ idct_mmx32_rows( short *blk ) /* transform all 8 rows of 8x8 iDCT block */
/* 1) transpose upper-left quad */
out = &qwTemp[0];
movq_m2r (*(out + ROW_STRIDE * 0), mm0);
movq_m2r (*(out + ROW_STRIDE * 1), mm1);
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_m2r (*(out + ROW_STRIDE * 2), mm2);
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
movq_m2r (*(out + ROW_STRIDE * 3), mm3);
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
movq_r2r (mm2, mm6);
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
inptr = blk;
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 0)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
/* begin reading next quadrant (lower-right) */
movq_m2r (*(out + ROW_STRIDE * 4 + 4), mm0);
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 2)); /* store row 3 */
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 1)); /* store row 2 */
movq_m2r (*(out + ROW_STRIDE * 5 + 4), mm1);
movq_r2m (mm3, *(inptr + ROW_STRIDE * 3)); /* store row 4 */
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
@ -550,40 +509,29 @@ idct_mmx32_rows( short *blk ) /* transform all 8 rows of 8x8 iDCT block */
/* movq mm1, qword ptr [OUT + ROW_STRIDE*5 + 8] */
/* movq mm4, mm0; // mm4 = copy of row1[A B C D] */
movq_m2r (*(out + ROW_STRIDE * 6 + 4), mm2);
/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5] */
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
movq_m2r (*(out + ROW_STRIDE * 7 + 4), mm3);
movq_r2r (mm2, mm6);
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
; /* slot */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 4 + 4)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
movq_m2r (*(out + ROW_STRIDE * 4), mm0);
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 6 + 4)); /* store row 3 */
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 5 + 4)); /* store row 2 */
; /* slot */
movq_m2r (*(out + ROW_STRIDE * 5), mm1);
; /* slot */
movq_r2m (mm3, *(inptr + ROW_STRIDE * 7 + 4)); /* store row 4 */
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
@ -592,88 +540,67 @@ idct_mmx32_rows( short *blk ) /* transform all 8 rows of 8x8 iDCT block */
/* movq mm1, qword ptr [OUT + ROW_STRIDE * 5 ] */
/* movq mm4, mm0; // mm4 = copy of row1[A B C D] */
movq_m2r (*(out + ROW_STRIDE * 6), mm2);
/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5] */
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
movq_m2r (*(out + ROW_STRIDE * 7), mm3);
movq_r2r (mm2, mm6);
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
; /*slot */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 0 + 4)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
/* begin reading next quadrant (upper-right) */
movq_m2r (*(out + ROW_STRIDE * 0 + 4), mm0);
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 2 + 4)); /* store row 3 */
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 1 + 4)); /* store row 2 */
movq_m2r (*(out + ROW_STRIDE * 1 + 4), mm1);
movq_r2m (mm3, *(inptr + ROW_STRIDE * 3 + 4)); /* store row 4 */
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
/* 2) transpose lower-right quadrant */
/* movq mm0, qword ptr [OUT + ROW_STRIDE*4 + 8] */
/* movq mm1, qword ptr [OUT + ROW_STRIDE*5 + 8] */
/* movq mm4, mm0; // mm4 = copy of row1[A B C D] */
movq_m2r (*(out + ROW_STRIDE * 2 + 4), mm2);
/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5] */
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
movq_m2r (*(out + ROW_STRIDE * 3 + 4), mm3);
movq_r2r (mm2, mm6);
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
; /* slot */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 4)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 5)); /* store row 2 */
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 6)); /* store row 3 */
; /* slot */
movq_r2m (mm3, *(inptr + ROW_STRIDE * 7)); /* store row 4 */
; /* slot */
}
static void
idct_mmx32_cols( short *blk ) /* transform all 8 cols of 8x8 iDCT block */
{
idct_mmx32_cols (short *blk)
{ /* transform all 8 cols of 8x8 iDCT block */
int x;
short *inptr = blk;
/* Despite the function's name, the matrix is transformed */
/* row by row. This function is identical to idct_mmx32_rows(), */
/* except for the SHIFT amount and ROUND_INV amount. */
@ -685,103 +612,77 @@ idct_mmx32_cols( short *blk ) /* transform all 8 cols of 8x8 iDCT block */
/* */
/* 2) transpose the matrix (which was stored in qwTemp[]) */
/* qwTemp[] -> [8x8 matrix transpose] -> blk[] */
for (x = 0; x < 8; x++) { /* transform one row per iteration */
movq_m2r (*(inptr), mm0); /* 0 ; x3 x2 x1 x0 */
movq_m2r (*(inptr + 4), mm1); /* 1 ; x7 x6 x5 x4 */
movq_r2r (mm0, mm2); /* 2 ; x3 x2 x1 x0 */
movq_m2r (*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00 */
punpcklwd_r2r (mm1, mm0); /* x5 x1 x4 x0 */
/* ---------- */
movq_r2r (mm0, mm5); /* 5 ; x5 x1 x4 x0 */
punpckldq_r2r (mm0, mm0); /* x4 x0 x4 x0 */
movq_m2r (*(tab_i_01234567 + 4), mm4); /* 4 ; w07 w05 w03 w01 */
punpckhwd_r2r (mm1, mm2); /* 1 ; x7 x3 x6 x2 */
pmaddwd_r2r (mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00 */
movq_r2r (mm2, mm6); /* 6 ; x7 x3 x6 x2 */
movq_m2r (*(tab_i_01234567 + 16), mm1); /* 1 ; w22 w20 w18 w16 */
punpckldq_r2r (mm2, mm2); /* x6 x2 x6 x2 */
pmaddwd_r2r (mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01 */
punpckhdq_r2r (mm5, mm5); /* x5 x1 x5 x1 */
pmaddwd_m2r (*(tab_i_01234567 + 8), mm0); /* x4*w14+x0*w12 x4*w10+x0*w08 */
punpckhdq_r2r (mm6, mm6); /* x7 x3 x7 x3 */
movq_m2r (*(tab_i_01234567 + 20), mm7); /* 7 ; w23 w21 w19 w17 */
pmaddwd_r2r (mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16 */
paddd_m2r (*(r_inv_col), mm3); /* +rounder */
pmaddwd_r2r (mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17 */
pmaddwd_m2r (*(tab_i_01234567 + 12), mm2); /* x6*w15+x2*w13 x6*w11+x2*w09 */
paddd_r2r (mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0) */
pmaddwd_m2r (*(tab_i_01234567 + 24), mm5); /* x5*w30+x1*w28 x5*w26+x1*w24 */
movq_r2r (mm3, mm4); /* 4 ; a1 a0 */
pmaddwd_m2r (*(tab_i_01234567 + 28), mm6); /* x7*w31+x3*w29 x7*w27+x3*w25 */
paddd_r2r (mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0) */
paddd_m2r (*(r_inv_col), mm0); /* +rounder */
psubd_r2r (mm1, mm3); /* a1-b1 a0-b0 */
psrad_i2r (SHIFT_INV_COL, mm3); /* y6=a1-b1 y7=a0-b0 */
paddd_r2r (mm4, mm1); /* 4 ; a1+b1 a0+b0 */
paddd_r2r (mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2) */
psrad_i2r (SHIFT_INV_COL, mm1); /* y1=a1+b1 y0=a0+b0 */
paddd_r2r (mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2) */
movq_r2r (mm0, mm4); /* 4 ; a3 a2 */
paddd_r2r (mm5, mm0); /* a3+b3 a2+b2 */
psubd_r2r (mm5, mm4); /* 5 ; a3-b3 a2-b2 */
psrad_i2r (SHIFT_INV_COL, mm4); /* y4=a3-b3 y5=a2-b2 */
psrad_i2r (SHIFT_INV_COL, mm0); /* y3=a3+b3 y2=a2+b2 */
packssdw_r2r (mm3, mm4); /* 3 ; y6 y7 y4 y5 */
packssdw_r2r (mm0, mm1); /* 0 ; y3 y2 y1 y0 */
movq_r2r (mm4, mm7); /* 7 ; y6 y7 y4 y5 */
psrld_i2r (16, mm4); /* 0 y6 0 y4 */
movq_r2m (mm1, *(inptr)); /* 1 ; save y3 y2 y1 y0 */
pslld_i2r (16, mm7); /* y7 0 y5 0 */
por_r2r (mm4, mm7); /* 4 ; y7 y6 y5 y4 */
/* begin processing row 1 */
movq_r2m (mm7, *(inptr + 4)); /* 7 ; save y7 y6 y5 y4 */
inptr += 8;
}
/* done with the iDCT column-transformation */
}
/* */
/* public interface to MMX32 IDCT 8x8 operation */
/* */
void
gst_idct_mmx32_idct (short *blk)
{
/* 1) iDCT row transformation */
idct_mmx32_rows (blk); /* 1) transform iDCT row, and transpose */
/* 2) iDCT column transformation */
idct_mmx32_cols (blk); /* 2) transform iDCT row, and transpose */
emms (); /* restore processor state */
/* all done */
}

View file

@ -27,7 +27,8 @@
#include "colorbalance.h"
#include "colorbalance-marshal.h"
enum {
enum
{
VALUE_CHANGED,
LAST_SIGNAL
};
@ -55,8 +56,7 @@ gst_color_balance_get_type (void)
};
gst_color_balance_type = g_type_register_static (G_TYPE_INTERFACE,
"GstColorBalance",
&gst_color_balance_info, 0);
"GstColorBalance", &gst_color_balance_info, 0);
g_type_interface_add_prerequisite (gst_color_balance_type,
GST_TYPE_IMPLEMENTS_INTERFACE);
}
@ -76,8 +76,7 @@ gst_color_balance_class_init (GstColorBalanceClass *klass)
G_STRUCT_OFFSET (GstColorBalanceClass, value_changed),
NULL, NULL,
gst_color_balance_marshal_VOID__OBJECT_INT,
G_TYPE_NONE, 2,
GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
G_TYPE_NONE, 2, GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
initialized = TRUE;
}
@ -104,8 +103,7 @@ gst_color_balance_list_channels (GstColorBalance *balance)
void
gst_color_balance_set_value (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value)
GstColorBalanceChannel * channel, gint value)
{
GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
@ -129,12 +127,10 @@ gst_color_balance_get_value (GstColorBalance *balance,
void
gst_color_balance_value_changed (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value)
GstColorBalanceChannel * channel, gint value)
{
g_signal_emit (G_OBJECT (balance),
gst_color_balance_signals[VALUE_CHANGED],
0, channel, value);
gst_color_balance_signals[VALUE_CHANGED], 0, channel, value);
g_signal_emit_by_name (G_OBJECT (channel), "value_changed", value);
}

View file

@ -27,7 +27,6 @@
#include <gst/colorbalance/colorbalance-enumtypes.h>
G_BEGIN_DECLS
#define GST_TYPE_COLOR_BALANCE \
(gst_color_balance_get_type ())
#define GST_COLOR_BALANCE(obj) \
@ -42,9 +41,7 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_COLOR_BALANCE))
#define GST_COLOR_BALANCE_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_COLOR_BALANCE, GstColorBalanceClass))
#define GST_COLOR_BALANCE_TYPE(klass) (klass->balance_type)
typedef struct _GstColorBalance GstColorBalance;
typedef enum
@ -53,7 +50,8 @@ typedef enum
GST_COLOR_BALANCE_SOFTWARE
} GstColorBalanceType;
typedef struct _GstColorBalanceClass {
typedef struct _GstColorBalanceClass
{
GTypeInterface klass;
GstColorBalanceType balance_type;
@ -62,15 +60,13 @@ typedef struct _GstColorBalanceClass {
const GList *(*list_channels) (GstColorBalance * balance);
void (*set_value) (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value);
GstColorBalanceChannel * channel, gint value);
gint (*get_value) (GstColorBalance * balance,
GstColorBalanceChannel * channel);
/* signals */
void (*value_changed) (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value);
GstColorBalanceChannel * channel, gint value);
gpointer _gst_reserved[GST_PADDING];
} GstColorBalanceClass;
@ -78,19 +74,15 @@ typedef struct _GstColorBalanceClass {
GType gst_color_balance_get_type (void);
/* virtual class function wrappers */
const GList *
gst_color_balance_list_channels (GstColorBalance *balance);
const GList *gst_color_balance_list_channels (GstColorBalance * balance);
void gst_color_balance_set_value (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value);
GstColorBalanceChannel * channel, gint value);
gint gst_color_balance_get_value (GstColorBalance * balance,
GstColorBalanceChannel * channel);
/* trigger signal */
void gst_color_balance_value_changed (GstColorBalance * balance,
GstColorBalanceChannel *channel,
gint value);
GstColorBalanceChannel * channel, gint value);
G_END_DECLS
#endif /* __GST_COLOR_BALANCE_H__ */

View file

@ -25,13 +25,15 @@
#include "colorbalancechannel.h"
enum {
enum
{
/* FILL ME */
SIGNAL_VALUE_CHANGED,
LAST_SIGNAL
};
static void gst_color_balance_channel_class_init (GstColorBalanceChannelClass *klass);
static void gst_color_balance_channel_class_init (GstColorBalanceChannelClass *
klass);
static void gst_color_balance_channel_init (GstColorBalanceChannel * balance);
static void gst_color_balance_channel_dispose (GObject * object);
@ -59,8 +61,7 @@ gst_color_balance_channel_get_type (void)
gst_color_balance_channel_type =
g_type_register_static (G_TYPE_OBJECT,
"GstColorBalanceChannel",
&color_balance_channel_info, 0);
"GstColorBalanceChannel", &color_balance_channel_info, 0);
}
return gst_color_balance_channel_type;
@ -78,8 +79,7 @@ gst_color_balance_channel_class_init (GstColorBalanceChannelClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstColorBalanceChannelClass,
value_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
object_klass->dispose = gst_color_balance_channel_dispose;
}

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_COLOR_BALANCE_CHANNEL \
(gst_color_balance_channel_get_type ())
#define GST_COLOR_BALANCE_CHANNEL(obj) \
@ -38,21 +37,20 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_COLOR_BALANCE_CHANNEL))
#define GST_IS_COLOR_BALANCE_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_COLOR_BALANCE_CHANNEL))
typedef struct _GstColorBalanceChannel {
typedef struct _GstColorBalanceChannel
{
GObject parent;
gchar *label;
gint min_value,
max_value;
gint min_value, max_value;
} GstColorBalanceChannel;
typedef struct _GstColorBalanceChannelClass {
typedef struct _GstColorBalanceChannelClass
{
GObjectClass parent;
/* signals */
void (* value_changed) (GstColorBalanceChannel *channel,
gint value);
void (*value_changed) (GstColorBalanceChannel * channel, gint value);
gpointer _gst_reserved[GST_PADDING];
} GstColorBalanceChannelClass;
@ -60,5 +58,4 @@ typedef struct _GstColorBalanceChannelClass {
GType gst_color_balance_channel_get_type (void);
G_END_DECLS
#endif /* __GST_COLOR_BALANCE_CHANNEL_H__ */

View file

@ -26,7 +26,8 @@
#include "mixer.h"
#include "mixer-marshal.h"
enum {
enum
{
MUTE_TOGGLED,
RECORD_TOGGLED,
VOLUME_CHANGED,
@ -56,8 +57,7 @@ gst_mixer_get_type (void)
};
gst_mixer_type = g_type_register_static (G_TYPE_INTERFACE,
"GstMixer",
&gst_mixer_info, 0);
"GstMixer", &gst_mixer_info, 0);
g_type_interface_add_prerequisite (gst_mixer_type,
GST_TYPE_IMPLEMENTS_INTERFACE);
}
@ -146,9 +146,7 @@ gst_mixer_list_tracks (GstMixer *mixer)
*/
void
gst_mixer_set_volume (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes)
gst_mixer_set_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -169,9 +167,7 @@ gst_mixer_set_volume (GstMixer *mixer,
*/
void
gst_mixer_get_volume (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes)
gst_mixer_get_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -198,9 +194,7 @@ gst_mixer_get_volume (GstMixer *mixer,
*/
void
gst_mixer_set_mute (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute)
gst_mixer_set_mute (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -223,9 +217,7 @@ gst_mixer_set_mute (GstMixer *mixer,
*/
void
gst_mixer_set_record (GstMixer *mixer,
GstMixerTrack *track,
gboolean record)
gst_mixer_set_record (GstMixer * mixer, GstMixerTrack * track, gboolean record)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -235,43 +227,30 @@ gst_mixer_set_record (GstMixer *mixer,
}
void
gst_mixer_mute_toggled (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute)
gst_mixer_mute_toggled (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
g_signal_emit (G_OBJECT (mixer),
gst_mixer_signals[MUTE_TOGGLED], 0,
track, mute);
gst_mixer_signals[MUTE_TOGGLED], 0, track, mute);
g_signal_emit_by_name (G_OBJECT (track),
"mute_toggled",
mute);
g_signal_emit_by_name (G_OBJECT (track), "mute_toggled", mute);
}
void
gst_mixer_record_toggled (GstMixer * mixer,
GstMixerTrack *track,
gboolean record)
GstMixerTrack * track, gboolean record)
{
g_signal_emit (G_OBJECT (mixer),
gst_mixer_signals[RECORD_TOGGLED], 0,
track, record);
gst_mixer_signals[RECORD_TOGGLED], 0, track, record);
g_signal_emit_by_name (G_OBJECT (track),
"record_toggled",
record);
g_signal_emit_by_name (G_OBJECT (track), "record_toggled", record);
}
void
gst_mixer_volume_changed (GstMixer * mixer,
GstMixerTrack *track,
gint *volumes)
GstMixerTrack * track, gint * volumes)
{
g_signal_emit (G_OBJECT (mixer),
gst_mixer_signals[VOLUME_CHANGED], 0,
track, volumes);
gst_mixer_signals[VOLUME_CHANGED], 0, track, volumes);
g_signal_emit_by_name (G_OBJECT (track),
"volume_changed",
volumes);
g_signal_emit_by_name (G_OBJECT (track), "volume_changed", volumes);
}

View file

@ -27,7 +27,6 @@
#include <gst/mixer/mixer-enumtypes.h>
G_BEGIN_DECLS
#define GST_TYPE_MIXER \
(gst_mixer_get_type ())
#define GST_MIXER(obj) \
@ -40,9 +39,7 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MIXER))
#define GST_MIXER_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_MIXER, GstMixerClass))
#define GST_MIXER_TYPE(klass) (klass->mixer_type)
typedef struct _GstMixer GstMixer;
typedef enum
@ -51,7 +48,8 @@ typedef enum
GST_MIXER_SOFTWARE
} GstMixerType;
typedef struct _GstMixerClass {
typedef struct _GstMixerClass
{
GTypeInterface klass;
GstMixerType mixer_type;
@ -59,30 +57,19 @@ typedef struct _GstMixerClass {
/* virtual functions */
const GList *(*list_tracks) (GstMixer * mixer);
void (* set_volume) (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes);
void (* get_volume) (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes);
void (*set_volume) (GstMixer * mixer, GstMixerTrack * track, gint * volumes);
void (*get_volume) (GstMixer * mixer, GstMixerTrack * track, gint * volumes);
void (* set_mute) (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute);
void (* set_record) (GstMixer *mixer,
GstMixerTrack *track,
gboolean record);
void (*set_mute) (GstMixer * mixer, GstMixerTrack * track, gboolean mute);
void (*set_record) (GstMixer * mixer, GstMixerTrack * track, gboolean record);
/* signals */
void (*mute_toggled) (GstMixer * mixer,
GstMixerTrack *channel,
gboolean mute);
GstMixerTrack * channel, gboolean mute);
void (*record_toggled) (GstMixer * mixer,
GstMixerTrack *channel,
gboolean record);
GstMixerTrack * channel, gboolean record);
void (*volume_changed) (GstMixer * mixer,
GstMixerTrack *channel,
gint *volumes);
GstMixerTrack * channel, gint * volumes);
gpointer _gst_reserved[GST_PADDING];
} GstMixerClass;
@ -92,29 +79,21 @@ GType gst_mixer_get_type (void);
/* virtual class function wrappers */
const GList *gst_mixer_list_tracks (GstMixer * mixer);
void gst_mixer_set_volume (GstMixer * mixer,
GstMixerTrack *track,
gint *volumes);
GstMixerTrack * track, gint * volumes);
void gst_mixer_get_volume (GstMixer * mixer,
GstMixerTrack *track,
gint *volumes);
GstMixerTrack * track, gint * volumes);
void gst_mixer_set_mute (GstMixer * mixer,
GstMixerTrack *track,
gboolean mute);
GstMixerTrack * track, gboolean mute);
void gst_mixer_set_record (GstMixer * mixer,
GstMixerTrack *track,
gboolean record);
GstMixerTrack * track, gboolean record);
/* trigger signals */
void gst_mixer_mute_toggled (GstMixer * mixer,
GstMixerTrack *track,
gboolean mute);
GstMixerTrack * track, gboolean mute);
void gst_mixer_record_toggled (GstMixer * mixer,
GstMixerTrack *track,
gboolean record);
GstMixerTrack * track, gboolean record);
void gst_mixer_volume_changed (GstMixer * mixer,
GstMixerTrack *track,
gint *volumes);
GstMixerTrack * track, gint * volumes);
G_END_DECLS
#endif /* __GST_MIXER_H__ */

View file

@ -25,7 +25,8 @@
#include "mixertrack.h"
enum {
enum
{
/* FILL ME */
SIGNAL_VOLUME_CHANGED,
SIGNAL_RECORD_TOGGLED,
@ -61,8 +62,7 @@ gst_mixer_track_get_type (void)
gst_mixer_track_type =
g_type_register_static (G_TYPE_OBJECT,
"GstMixerTrack",
&mixer_track_info, 0);
"GstMixerTrack", &mixer_track_info, 0);
}
return gst_mixer_track_type;

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_MIXER_TRACK \
(gst_mixer_track_get_type ())
#define GST_MIXER_TRACK(obj) \
@ -38,7 +37,6 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MIXER_TRACK))
#define GST_IS_MIXER_TRACK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MIXER_TRACK))
/*
* Naming:
*
@ -54,8 +52,8 @@ G_BEGIN_DECLS
* mixer, which means that setting this track will change
* the hearable volume on any output.
*/
typedef enum {
typedef enum
{
GST_MIXER_TRACK_INPUT = (1 << 0),
GST_MIXER_TRACK_OUTPUT = (1 << 1),
GST_MIXER_TRACK_MUTE = (1 << 2),
@ -67,26 +65,23 @@ typedef enum {
#define GST_MIXER_TRACK_HAS_FLAG(channel, flag) \
((channel)->flags & flag)
typedef struct _GstMixerTrack {
typedef struct _GstMixerTrack
{
GObject parent;
gchar *label;
GstMixerTrackFlags flags;
gint num_channels,
min_volume,
max_volume;
gint num_channels, min_volume, max_volume;
} GstMixerTrack;
typedef struct _GstMixerTrackClass {
typedef struct _GstMixerTrackClass
{
GObjectClass parent;
/* signals */
void (* mute_toggled) (GstMixerTrack *channel,
gboolean mute);
void (* record_toggled) (GstMixerTrack *channel,
gboolean record);
void (* volume_changed) (GstMixerTrack *channel,
gint *volumes);
void (*mute_toggled) (GstMixerTrack * channel, gboolean mute);
void (*record_toggled) (GstMixerTrack * channel, gboolean record);
void (*volume_changed) (GstMixerTrack * channel, gint * volumes);
gpointer _gst_reserved[GST_PADDING];
} GstMixerTrackClass;
@ -94,5 +89,4 @@ typedef struct _GstMixerTrackClass {
GType gst_mixer_track_get_type (void);
G_END_DECLS
#endif /* __GST_MIXER_TRACK_H__ */

View file

@ -46,8 +46,7 @@ gst_navigation_get_type (void)
};
gst_navigation_type = g_type_register_static (G_TYPE_INTERFACE,
"GstNavigation",
&gst_navigation_info, 0);
"GstNavigation", &gst_navigation_info, 0);
}
return gst_navigation_type;
@ -74,22 +73,17 @@ void
gst_navigation_send_key_event (GstNavigation * navigation, const char *event,
const char *key)
{
gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation",
"event", G_TYPE_STRING, event,
"key", G_TYPE_STRING, key, NULL));
gst_navigation_send_event (navigation,
gst_structure_new ("application/x-gst-navigation", "event", G_TYPE_STRING,
event, "key", G_TYPE_STRING, key, NULL));
}
void
gst_navigation_send_mouse_event (GstNavigation * navigation, const char *event,
int button, double x, double y)
{
gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation",
"event", G_TYPE_STRING, event,
"button", G_TYPE_INT, button,
"pointer_x", G_TYPE_DOUBLE, x,
gst_navigation_send_event (navigation,
gst_structure_new ("application/x-gst-navigation", "event", G_TYPE_STRING,
event, "button", G_TYPE_INT, button, "pointer_x", G_TYPE_DOUBLE, x,
"pointer_y", G_TYPE_DOUBLE, y, NULL));
}

View file

@ -26,7 +26,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_NAVIGATION \
(gst_navigation_get_type ())
#define GST_NAVIGATION(obj) \
@ -35,10 +34,10 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NAVIGATION))
#define GST_NAVIGATION_GET_IFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_NAVIGATION, GstNavigationInterface))
typedef struct _GstNavigation GstNavigation;
typedef struct _GstNavigationInterface {
typedef struct _GstNavigationInterface
{
GTypeInterface g_iface;
/* virtual functions */
@ -50,7 +49,8 @@ typedef struct _GstNavigationInterface {
GType gst_navigation_get_type (void);
/* virtual class function wrappers */
void gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure);
void gst_navigation_send_event (GstNavigation * navigation,
GstStructure * structure);
void gst_navigation_send_key_event (GstNavigation * navigation,
const char *event, const char *key);
@ -58,5 +58,4 @@ void gst_navigation_send_mouse_event (GstNavigation *navigation,
const char *event, int button, double x, double y);
G_END_DECLS
#endif /* __GST_NAVIGATION_H__ */

View file

@ -27,7 +27,8 @@
#include "propertyprobe.h"
enum {
enum
{
SIGNAL_PROBE_NEEDED,
LAST_SIGNAL
};
@ -56,8 +57,7 @@ gst_property_probe_get_type (void)
gst_property_probe_type =
g_type_register_static (G_TYPE_INTERFACE,
"GstPropertyProbe",
&gst_property_probe_info, 0);
"GstPropertyProbe", &gst_property_probe_info, 0);
}
return gst_property_probe_type;
@ -70,9 +70,9 @@ gst_property_probe_iface_init (GstPropertyProbeInterface *iface)
if (!initialized) {
gst_property_probe_signals[SIGNAL_PROBE_NEEDED] =
g_signal_new ("probe-needed", G_TYPE_FROM_CLASS (iface), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstPropertyProbeInterface, probe_needed),
NULL, NULL, g_cclosure_marshal_VOID__POINTER,
g_signal_new ("probe-needed", G_TYPE_FROM_CLASS (iface),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstPropertyProbeInterface,
probe_needed), NULL, NULL, g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
initialized = TRUE;
}
@ -108,8 +108,7 @@ gst_property_probe_get_properties (GstPropertyProbe *probe)
}
const GParamSpec *
gst_property_probe_get_property (GstPropertyProbe *probe,
const gchar *name)
gst_property_probe_get_property (GstPropertyProbe * probe, const gchar * name)
{
const GList *pspecs = gst_property_probe_get_properties (probe);

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_PROPERTY_PROBE \
(gst_property_probe_get_type ())
#define GST_PROPERTY_PROBE(obj) \
@ -34,27 +33,23 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PROPERTY_PROBE))
#define GST_PROPERTY_PROBE_GET_IFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_PROPERTY_PROBE, GstPropertyProbeInterface))
typedef struct _GstPropertyProbe GstPropertyProbe; /* dummy typedef */
typedef struct _GstPropertyProbeInterface {
typedef struct _GstPropertyProbeInterface
{
GTypeInterface klass;
/* signals */
void (*probe_needed) (GstPropertyProbe *probe,
const GParamSpec *pspec);
void (*probe_needed) (GstPropertyProbe * probe, const GParamSpec * pspec);
/* virtual functions */
const GList *(*get_properties) (GstPropertyProbe * probe);
gboolean (*needs_probe) (GstPropertyProbe * probe,
guint prop_id,
const GParamSpec *pspec);
guint prop_id, const GParamSpec * pspec);
void (*probe_property) (GstPropertyProbe * probe,
guint prop_id,
const GParamSpec *pspec);
guint prop_id, const GParamSpec * pspec);
GValueArray *(*get_values) (GstPropertyProbe * probe,
guint prop_id,
const GParamSpec *pspec);
guint prop_id, const GParamSpec * pspec);
gpointer _gst_reserved[GST_PADDING];
} GstPropertyProbeInterface;
@ -89,9 +84,8 @@ GValueArray * gst_property_probe_get_values_name (GstPropertyProbe *prob
/* sugar */
GValueArray *gst_property_probe_probe_and_get_values (GstPropertyProbe * probe,
const GParamSpec * pspec);
GValueArray * gst_property_probe_probe_and_get_values_name (GstPropertyProbe *probe,
const gchar *name);
GValueArray *gst_property_probe_probe_and_get_values_name (GstPropertyProbe *
probe, const gchar * name);
G_END_DECLS
#endif /* __GST_PROPERTY_PROBE_H__ */

View file

@ -28,7 +28,8 @@
#include <string.h>
enum {
enum
{
NORM_CHANGED,
CHANNEL_CHANGED,
FREQUENCY_CHANGED,
@ -59,8 +60,7 @@ gst_tuner_get_type (void)
};
gst_tuner_type = g_type_register_static (G_TYPE_INTERFACE,
"GstTuner",
&gst_tuner_info, 0);
"GstTuner", &gst_tuner_info, 0);
g_type_interface_add_prerequisite (gst_tuner_type,
GST_TYPE_IMPLEMENTS_INTERFACE);
}
@ -79,8 +79,7 @@ gst_tuner_class_init (GstTunerClass *klass)
GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerClass, norm_changed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GST_TYPE_TUNER_NORM);
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_TUNER_NORM);
gst_tuner_signals[CHANNEL_CHANGED] =
g_signal_new ("channel-changed",
GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
@ -151,8 +150,7 @@ gst_tuner_list_channels (GstTuner *tuner)
*/
void
gst_tuner_set_channel (GstTuner *tuner,
GstTunerChannel *channel)
gst_tuner_set_channel (GstTuner * tuner, GstTunerChannel * channel)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -214,8 +212,7 @@ gst_tuner_list_norms (GstTuner *tuner)
*/
void
gst_tuner_set_norm (GstTuner *tuner,
GstTunerNorm *norm)
gst_tuner_set_norm (GstTuner * tuner, GstTunerNorm * norm)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -260,8 +257,7 @@ gst_tuner_get_norm (GstTuner *tuner)
void
gst_tuner_set_frequency (GstTuner * tuner,
GstTunerChannel *channel,
gulong frequency)
GstTunerChannel * channel, gulong frequency)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -285,8 +281,7 @@ gst_tuner_set_frequency (GstTuner *tuner,
*/
gulong
gst_tuner_get_frequency (GstTuner *tuner,
GstTunerChannel *channel)
gst_tuner_get_frequency (GstTuner * tuner, GstTunerChannel * channel)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -315,8 +310,7 @@ gst_tuner_get_frequency (GstTuner *tuner,
*/
gint
gst_tuner_signal_strength (GstTuner *tuner,
GstTunerChannel *channel)
gst_tuner_signal_strength (GstTuner * tuner, GstTunerChannel * channel)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -331,8 +325,7 @@ gst_tuner_signal_strength (GstTuner *tuner,
}
GstTunerNorm *
gst_tuner_find_norm_by_name (GstTuner *tuner,
gchar *norm)
gst_tuner_find_norm_by_name (GstTuner * tuner, gchar * norm)
{
GList *walk;
@ -349,8 +342,7 @@ gst_tuner_find_norm_by_name (GstTuner *tuner,
}
GstTunerChannel *
gst_tuner_find_channel_by_name (GstTuner *tuner,
gchar *channel)
gst_tuner_find_channel_by_name (GstTuner * tuner, gchar * channel)
{
GList *walk;
@ -367,59 +359,46 @@ gst_tuner_find_channel_by_name (GstTuner *tuner,
}
void
gst_tuner_channel_changed (GstTuner *tuner,
GstTunerChannel *channel)
gst_tuner_channel_changed (GstTuner * tuner, GstTunerChannel * channel)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_CHANNEL (channel));
g_signal_emit (G_OBJECT (tuner),
gst_tuner_signals[CHANNEL_CHANGED], 0,
channel);
gst_tuner_signals[CHANNEL_CHANGED], 0, channel);
}
void
gst_tuner_norm_changed (GstTuner *tuner,
GstTunerNorm *norm)
gst_tuner_norm_changed (GstTuner * tuner, GstTunerNorm * norm)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_NORM (norm));
g_signal_emit (G_OBJECT (tuner),
gst_tuner_signals[NORM_CHANGED], 0,
norm);
g_signal_emit (G_OBJECT (tuner), gst_tuner_signals[NORM_CHANGED], 0, norm);
}
void
gst_tuner_frequency_changed (GstTuner * tuner,
GstTunerChannel *channel,
gulong frequency)
GstTunerChannel * channel, gulong frequency)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_CHANNEL (channel));
g_signal_emit (G_OBJECT (tuner),
gst_tuner_signals[FREQUENCY_CHANGED], 0,
channel, frequency);
gst_tuner_signals[FREQUENCY_CHANGED], 0, channel, frequency);
g_signal_emit_by_name (G_OBJECT (channel),
"frequency_changed",
frequency);
g_signal_emit_by_name (G_OBJECT (channel), "frequency_changed", frequency);
}
void
gst_tuner_signal_changed (GstTuner * tuner,
GstTunerChannel *channel,
gint signal)
GstTunerChannel * channel, gint signal)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_CHANNEL (channel));
g_signal_emit (G_OBJECT (tuner),
gst_tuner_signals[SIGNAL_CHANGED], 0,
channel, signal);
gst_tuner_signals[SIGNAL_CHANGED], 0, channel, signal);
g_signal_emit_by_name (G_OBJECT (channel),
"signal_changed",
signal);
g_signal_emit_by_name (G_OBJECT (channel), "signal_changed", signal);
}

View file

@ -28,7 +28,6 @@
#include <gst/tuner/tuner-enumtypes.h>
G_BEGIN_DECLS
#define GST_TYPE_TUNER \
(gst_tuner_get_type ())
#define GST_TUNER(obj) \
@ -41,43 +40,33 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TUNER))
#define GST_TUNER_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_TUNER, GstTunerClass))
typedef struct _GstTuner GstTuner;
typedef struct _GstTunerClass {
typedef struct _GstTunerClass
{
GTypeInterface klass;
/* virtual functions */
const GList *(*list_channels) (GstTuner * tuner);
void (* set_channel) (GstTuner *tuner,
GstTunerChannel *channel);
GstTunerChannel *
(* get_channel) (GstTuner *tuner);
void (*set_channel) (GstTuner * tuner, GstTunerChannel * channel);
GstTunerChannel *(*get_channel) (GstTuner * tuner);
const GList *(*list_norms) (GstTuner * tuner);
void (* set_norm) (GstTuner *tuner,
GstTunerNorm *norm);
void (*set_norm) (GstTuner * tuner, GstTunerNorm * norm);
GstTunerNorm *(*get_norm) (GstTuner * tuner);
void (*set_frequency) (GstTuner * tuner,
GstTunerChannel *channel,
gulong frequency);
gulong (* get_frequency) (GstTuner *tuner,
GstTunerChannel *channel);
gint (* signal_strength) (GstTuner *tuner,
GstTunerChannel *channel);
GstTunerChannel * channel, gulong frequency);
gulong (*get_frequency) (GstTuner * tuner, GstTunerChannel * channel);
gint (*signal_strength) (GstTuner * tuner, GstTunerChannel * channel);
/* signals */
void (*channel_changed) (GstTuner *tuner,
GstTunerChannel *channel);
void (*norm_changed) (GstTuner *tuner,
GstTunerNorm *norm);
void (*channel_changed) (GstTuner * tuner, GstTunerChannel * channel);
void (*norm_changed) (GstTuner * tuner, GstTunerNorm * norm);
void (*frequency_changed) (GstTuner * tuner,
GstTunerChannel *channel,
gulong frequency);
GstTunerChannel * channel, gulong frequency);
void (*signal_changed) (GstTuner * tuner,
GstTunerChannel *channel,
gint signal);
GstTunerChannel * channel, gint signal);
gpointer _gst_reserved[GST_PADDING];
} GstTunerClass;
@ -86,42 +75,30 @@ GType gst_tuner_get_type (void);
/* virtual class function wrappers */
const GList *gst_tuner_list_channels (GstTuner * tuner);
void gst_tuner_set_channel (GstTuner *tuner,
GstTunerChannel *channel);
GstTunerChannel *
gst_tuner_get_channel (GstTuner *tuner);
void gst_tuner_set_channel (GstTuner * tuner, GstTunerChannel * channel);
GstTunerChannel *gst_tuner_get_channel (GstTuner * tuner);
const GList *gst_tuner_list_norms (GstTuner * tuner);
void gst_tuner_set_norm (GstTuner *tuner,
GstTunerNorm *channel);
void gst_tuner_set_norm (GstTuner * tuner, GstTunerNorm * channel);
GstTunerNorm *gst_tuner_get_norm (GstTuner * tuner);
void gst_tuner_set_frequency (GstTuner * tuner,
GstTunerChannel *channel,
gulong frequency);
gulong gst_tuner_get_frequency (GstTuner *tuner,
GstTunerChannel *channel);
gint gst_tuner_signal_strength (GstTuner *tuner,
GstTunerChannel *channel);
GstTunerChannel * channel, gulong frequency);
gulong gst_tuner_get_frequency (GstTuner * tuner, GstTunerChannel * channel);
gint gst_tuner_signal_strength (GstTuner * tuner, GstTunerChannel * channel);
/* helper functions */
GstTunerNorm * gst_tuner_find_norm_by_name (GstTuner *tuner,
gchar *norm);
GstTunerNorm *gst_tuner_find_norm_by_name (GstTuner * tuner, gchar * norm);
GstTunerChannel *gst_tuner_find_channel_by_name (GstTuner * tuner,
gchar * channel);
/* trigger signals */
void gst_tuner_channel_changed (GstTuner *tuner,
GstTunerChannel *channel);
void gst_tuner_norm_changed (GstTuner *tuner,
GstTunerNorm *norm);
void gst_tuner_channel_changed (GstTuner * tuner, GstTunerChannel * channel);
void gst_tuner_norm_changed (GstTuner * tuner, GstTunerNorm * norm);
void gst_tuner_frequency_changed (GstTuner * tuner,
GstTunerChannel *channel,
gulong frequency);
GstTunerChannel * channel, gulong frequency);
void gst_tuner_signal_changed (GstTuner * tuner,
GstTunerChannel *channel,
gint signal);
GstTunerChannel * channel, gint signal);
G_END_DECLS
#endif /* __GST_TUNER_H__ */

View file

@ -25,7 +25,8 @@
#include "tunerchannel.h"
enum {
enum
{
/* FILL ME */
SIGNAL_FREQUENCY_CHANGED,
SIGNAL_SIGNAL_CHANGED,
@ -60,8 +61,7 @@ gst_tuner_channel_get_type (void)
gst_tuner_channel_type =
g_type_register_static (G_TYPE_OBJECT,
"GstTunerChannel",
&tuner_channel_info, 0);
"GstTunerChannel", &tuner_channel_info, 0);
}
return gst_tuner_channel_type;
@ -79,15 +79,13 @@ gst_tuner_channel_class_init (GstTunerChannelClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerChannelClass,
frequency_changed),
NULL, NULL, g_cclosure_marshal_VOID__ULONG,
G_TYPE_NONE, 1, G_TYPE_ULONG);
NULL, NULL, g_cclosure_marshal_VOID__ULONG, G_TYPE_NONE, 1, G_TYPE_ULONG);
signals[SIGNAL_SIGNAL_CHANGED] =
g_signal_new ("signal-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerChannelClass,
signal_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
object_klass->dispose = gst_tuner_channel_dispose;
}

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_TUNER_CHANNEL \
(gst_tuner_channel_get_type ())
#define GST_TUNER_CHANNEL(obj) \
@ -38,8 +37,8 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TUNER_CHANNEL))
#define GST_IS_TUNER_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TUNER_CHANNEL))
typedef enum {
typedef enum
{
GST_TUNER_CHANNEL_INPUT = (1 << 0),
GST_TUNER_CHANNEL_OUTPUT = (1 << 1),
GST_TUNER_CHANNEL_FREQUENCY = (1 << 2),
@ -49,25 +48,23 @@ typedef enum {
#define GST_TUNER_CHANNEL_HAS_FLAG(channel, flag) \
((channel)->flags & flag)
typedef struct _GstTunerChannel {
typedef struct _GstTunerChannel
{
GObject parent;
gchar *label;
GstTunerChannelFlags flags;
gulong min_frequency,
max_frequency;
gint min_signal,
max_signal;
gulong min_frequency, max_frequency;
gint min_signal, max_signal;
} GstTunerChannel;
typedef struct _GstTunerChannelClass {
typedef struct _GstTunerChannelClass
{
GObjectClass parent;
/* signals */
void (*frequency_changed) (GstTunerChannel *channel,
gulong frequency);
void (*signal_changed) (GstTunerChannel *channel,
gint signal);
void (*frequency_changed) (GstTunerChannel * channel, gulong frequency);
void (*signal_changed) (GstTunerChannel * channel, gint signal);
gpointer _gst_reserved[GST_PADDING];
} GstTunerChannelClass;
@ -75,5 +72,4 @@ typedef struct _GstTunerChannelClass {
GType gst_tuner_channel_get_type (void);
G_END_DECLS
#endif /* __GST_TUNER_CHANNEL_H__ */

View file

@ -25,7 +25,8 @@
#include "tunernorm.h"
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
@ -35,6 +36,7 @@ static void gst_tuner_norm_init (GstTunerNorm *norm);
static void gst_tuner_norm_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
/*static guint signals[LAST_SIGNAL] = { 0 };*/
GType
@ -58,8 +60,7 @@ gst_tuner_norm_get_type (void)
gst_tuner_norm_type =
g_type_register_static (G_TYPE_OBJECT,
"GstTunerNorm",
&tuner_norm_info, 0);
"GstTunerNorm", &tuner_norm_info, 0);
}
return gst_tuner_norm_type;

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_TUNER_NORM \
(gst_tuner_norm_get_type ())
#define GST_TUNER_NORM(obj) \
@ -36,15 +35,16 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TUNER_NORM))
#define GST_IS_TUNER_NORM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TUNER_NORM))
typedef struct _GstTunerNorm {
typedef struct _GstTunerNorm
{
GObject parent;
gchar *label;
gfloat fps;
} GstTunerNorm;
typedef struct _GstTunerNormClass {
typedef struct _GstTunerNormClass
{
GObjectClass parent;
gpointer _gst_reserved[GST_PADDING];
@ -53,5 +53,4 @@ typedef struct _GstTunerNormClass {
GType gst_tuner_norm_get_type (void);
G_END_DECLS
#endif /* __GST_TUNER_NORM_H__ */

View file

@ -25,7 +25,8 @@
#include "xoverlay.h"
enum {
enum
{
HAVE_XWINDOW_ID,
DESIRED_SIZE,
LAST_SIGNAL
@ -54,8 +55,7 @@ gst_x_overlay_get_type (void)
};
gst_x_overlay_type = g_type_register_static (G_TYPE_INTERFACE,
"GstXOverlay",
&gst_x_overlay_info, 0);
"GstXOverlay", &gst_x_overlay_info, 0);
g_type_interface_add_prerequisite (gst_x_overlay_type,
GST_TYPE_IMPLEMENTS_INTERFACE);
}
@ -64,8 +64,9 @@ gst_x_overlay_get_type (void)
}
/* FIXME: evil hack, we should figure out our marshal handling in this interfaces some day */
extern void gst_marshal_VOID__INT_INT (GClosure *closure, GValue *return_value, guint n_param_values,
const GValue *param_values, gpointer invocation_hint, gpointer marshal_data);
extern void gst_marshal_VOID__INT_INT (GClosure * closure,
GValue * return_value, guint n_param_values, const GValue * param_values,
gpointer invocation_hint, gpointer marshal_data);
static void
gst_x_overlay_base_init (gpointer g_class)
@ -73,22 +74,18 @@ gst_x_overlay_base_init (gpointer g_class)
GstXOverlayClass *overlay_class = (GstXOverlayClass *) g_class;
static gboolean initialized = FALSE;
if (! initialized)
{
if (!initialized) {
gst_x_overlay_signals[HAVE_XWINDOW_ID] =
g_signal_new ("have-xwindow-id",
GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstXOverlayClass, have_xwindow_id),
NULL, NULL,
g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1,
G_TYPE_INT);
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gst_x_overlay_signals[DESIRED_SIZE] =
g_signal_new ("desired-size-changed",
GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstXOverlayClass, desired_size),
NULL, NULL,
gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_INT);
gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
initialized = TRUE;
}
@ -145,7 +142,8 @@ gst_x_overlay_got_xwindow_id (GstXOverlay *overlay, gulong xwindow_id)
* size, width and height are set to 0.
*/
void
gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *height)
gst_x_overlay_get_desired_size (GstXOverlay * overlay, guint * width,
guint * height)
{
guint width_tmp, height_tmp;
GstXOverlayClass *klass;
@ -156,7 +154,8 @@ gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *heigh
if (klass->get_desired_size && GST_IS_X_OVERLAY (overlay)) {
/* this ensures that elements don't need to check width and height for NULL
but apps may use NULL */
klass->get_desired_size (overlay, width ? width : &width_tmp, height ? height : &height_tmp);
klass->get_desired_size (overlay, width ? width : &width_tmp,
height ? height : &height_tmp);
} else {
if (width)
*width = 0;
@ -176,7 +175,8 @@ gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *heigh
* This function should be used by video overlay developpers.
*/
void
gst_x_overlay_got_desired_size (GstXOverlay *overlay, guint width, guint height)
gst_x_overlay_got_desired_size (GstXOverlay * overlay, guint width,
guint height)
{
g_return_if_fail (GST_IS_X_OVERLAY (overlay));

View file

@ -26,7 +26,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_X_OVERLAY \
(gst_x_overlay_get_type ())
#define GST_X_OVERLAY(obj) \
@ -40,27 +39,22 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_X_OVERLAY))
#define GST_X_OVERLAY_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_X_OVERLAY, GstXOverlayClass))
typedef struct _GstXOverlay GstXOverlay;
typedef struct _GstXOverlayClass {
typedef struct _GstXOverlayClass
{
GTypeInterface klass;
/* virtual functions */
void (* set_xwindow_id) (GstXOverlay *overlay,
gulong xwindow_id);
void (*set_xwindow_id) (GstXOverlay * overlay, gulong xwindow_id);
/* optional virtual functions */
void (*get_desired_size) (GstXOverlay * overlay,
guint *width,
guint *height);
guint * width, guint * height);
void (*expose) (GstXOverlay * overlay);
/* signals */
void (*have_xwindow_id) (GstXOverlay *overlay,
gulong xwindow_id);
void (* desired_size) (GstXOverlay *overlay,
guint width,
guint height);
void (*have_xwindow_id) (GstXOverlay * overlay, gulong xwindow_id);
void (*desired_size) (GstXOverlay * overlay, guint width, guint height);
gpointer _gst_reserved[GST_PADDING];
} GstXOverlayClass;
@ -69,13 +63,14 @@ GType gst_x_overlay_get_type (void);
/* virtual class function wrappers */
void gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id);
void gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *height);
void gst_x_overlay_get_desired_size (GstXOverlay * overlay, guint * width,
guint * height);
void gst_x_overlay_expose (GstXOverlay * overlay);
/* public methods to fire signals */
void gst_x_overlay_got_xwindow_id (GstXOverlay * overlay, gulong xwindow_id);
void gst_x_overlay_got_desired_size (GstXOverlay *overlay, guint width, guint height);
void gst_x_overlay_got_desired_size (GstXOverlay * overlay, guint width,
guint height);
G_END_DECLS
#endif /* __GST_X_OVERLAY_H__ */

View file

@ -51,7 +51,8 @@ gmi_stream_new (void)
void
gmi_stream_free (GstMediaInfoStream * stream)
{
if (stream->mime) g_free (stream->mime);
if (stream->mime)
g_free (stream->mime);
/* FIXME: free tracks */
g_free (stream);
}
@ -78,7 +79,8 @@ gmi_track_new (void)
/* callbacks */
static void
have_type_callback (GstElement *typefind, guint probability, GstCaps *type, GstMediaInfoPriv *priv)
have_type_callback (GstElement * typefind, guint probability, GstCaps * type,
GstMediaInfoPriv * priv)
{
GstStructure *str;
const gchar *mime;
@ -90,8 +92,7 @@ have_type_callback (GstElement *typefind, guint probability, GstCaps *type, GstM
/* FIXME: this code doesn't yet work, test it later */
#ifdef DONTWORK
if (strcmp (mime, "application/x-id3") == 0)
{
if (strcmp (mime, "application/x-id3") == 0) {
/* dig a little deeper */
GST_DEBUG ("dealing with id3, digging deeper");
gst_element_set_state (priv->pipeline, GST_STATE_READY);
@ -102,7 +103,8 @@ have_type_callback (GstElement *typefind, guint probability, GstCaps *type, GstM
if (priv->decontainer == NULL)
/* FIXME: signal error */
g_warning ("Couldn't create id3tag");
if (!gst_element_link_many (priv->source, priv->decontainer, priv->typefind, NULL));
if (!gst_element_link_many (priv->source, priv->decontainer, priv->typefind,
NULL));
g_warning ("Couldn't link in id3tag");
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
@ -119,36 +121,34 @@ deep_notify_callback (GObject *object, GstObject *origin,
GValue value = { 0, };
/* we only care about pad notifies */
if (!GST_IS_PAD (origin)) return;
if (!GST_IS_PAD (origin))
return;
/*
GST_DEBUG ("DEBUG: deep_notify: have notify of %s from object %s:%s !",
pspec->name, gst_element_get_name (gst_pad_get_parent (GST_PAD (origin))),
gst_object_get_name (origin));
*/
else if (strcmp (pspec->name, "caps") == 0)
{
else if (strcmp (pspec->name, "caps") == 0) {
/* check if we're getting it from fakesink */
if (GST_IS_PAD (origin) && GST_PAD_PARENT (origin) == priv->fakesink)
{
if (GST_IS_PAD (origin) && GST_PAD_PARENT (origin) == priv->fakesink) {
GST_DEBUG ("have caps on fakesink pad !");
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
priv->format = g_value_peek_pointer (&value);
GST_DEBUG ("caps: %" GST_PTR_FORMAT, priv->format);
}
else GST_DEBUG ("ignoring caps on object %s:%s",
} else
GST_DEBUG ("ignoring caps on object %s:%s",
gst_object_get_name (gst_object_get_parent (origin)),
gst_object_get_name (origin));
}
else if (strcmp (pspec->name, "offset") == 0)
{
} else if (strcmp (pspec->name, "offset") == 0) {
/* we REALLY ignore offsets, we hate them */
}
//else GST_DEBUG ("ignoring notify of %s", pspec->name);
}
typedef struct {
typedef struct
{
guint meta;
guint encoded;
} TagFlagScore;
@ -160,12 +160,15 @@ tag_flag_score (const GstTagList *list, const gchar *tag, gpointer user_data)
GstTagFlag flag;
flag = gst_tag_get_flag (tag);
if (flag == GST_TAG_FLAG_META) score->meta++;
if (flag == GST_TAG_FLAG_ENCODED) score->encoded++;
if (flag == GST_TAG_FLAG_META)
score->meta++;
if (flag == GST_TAG_FLAG_ENCODED)
score->encoded++;
}
void
found_tag_callback (GObject *pipeline, GstElement *source, GstTagList *tags, GstMediaInfoPriv *priv)
found_tag_callback (GObject * pipeline, GstElement * source, GstTagList * tags,
GstMediaInfoPriv * priv)
{
TagFlagScore score;
@ -179,20 +182,18 @@ found_tag_callback (GObject *pipeline, GstElement *source, GstTagList *tags, Gst
gst_tag_list_foreach (tags, tag_flag_score, &score);
if (score.meta > score.encoded)
{
if (score.meta > score.encoded) {
GST_DEBUG ("found tags from decoder, adding them as metadata");
priv->metadata = gst_tag_list_copy (tags);
}
else
{
} else {
GST_DEBUG ("found tags, adding them as streaminfo");
priv->streaminfo = gst_tag_list_copy (tags);
}
}
void
error_callback (GObject *element, GstElement *source, GError *error, gchar *debug, GstMediaInfoPriv *priv)
error_callback (GObject * element, GstElement * source, GError * error,
gchar * debug, GstMediaInfoPriv * priv)
{
g_print ("ERROR: %s\n", error->message);
g_error_free (error);
@ -221,8 +222,7 @@ gst_media_info_error_element (const gchar *element, GError **error)
message = g_strdup_printf ("The %s element could not be found. "
"This element is essential for reading. "
"Please install the right plug-in and verify "
"that it works by running 'gst-inspect %s'",
element, element);
"that it works by running 'gst-inspect %s'", element, element);
gst_media_info_error_create (error, message);
g_free (message);
return;
@ -289,8 +289,7 @@ G_STMT_START { \
TAGS_RESET (priv->streaminfo);
#undef TAGS_RESET
if (priv->stream)
{
if (priv->stream) {
gmi_stream_free (priv->stream);
priv->stream = NULL;
}
@ -311,7 +310,8 @@ gmi_seek_to_track (GstMediaInfo *info, long track)
/* FIXME: consider more nicks as "track" */
track_format = gst_format_get_by_nick ("logical_stream");
if (track_format == 0) return FALSE;
if (track_format == 0)
return FALSE;
GST_DEBUG ("Track format: %d", track_format);
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
@ -319,24 +319,19 @@ gmi_seek_to_track (GstMediaInfo *info, long track)
g_warning ("Couldn't set to play");
g_assert (GST_IS_PAD (info->priv->decoder_pad));
event = gst_event_new_seek (track_format |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
track);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, track);
res = gst_pad_send_event (info->priv->decoder_pad, event);
if (!res)
{
if (!res) {
g_warning ("seek to logical track on pad %s:%s failed",
GST_DEBUG_PAD_NAME (info->priv->decoder_pad));
return FALSE;
}
/* clear structs because of the seek */
if (priv->metadata)
{
if (priv->metadata) {
gst_tag_list_free (priv->metadata);
priv->metadata = NULL;
}
if (priv->streaminfo)
{
if (priv->streaminfo) {
gst_tag_list_free (priv->streaminfo);
priv->streaminfo = NULL;
}
@ -354,31 +349,45 @@ gmi_set_mime (GstMediaInfo *info, const char *mime)
/* FIXME: please figure out proper mp3 mimetypes */
if ((strcmp (mime, "application/x-ogg") == 0) ||
(strcmp (mime, "application/ogg") == 0))
desc = g_strdup_printf ("%s name=source ! oggdemux ! vorbisdec name=decoder ! fakesink name=sink", priv->source_name);
else if ((strcmp (mime, "audio/mpeg") == 0) ||
(strcmp (mime, "audio/x-mp3") == 0) ||
(strcmp (mime, "audio/mp3") == 0) ||
(strcmp (mime, "application/x-id3") == 0) ||
(strcmp (mime, "audio/x-id3") == 0))
desc = g_strdup_printf ("%s name=source ! id3tag ! mad name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
else if ((strcmp (mime, "application/x-flac") == 0) ||
(strcmp (mime, "audio/x-flac") == 0))
desc = g_strdup_printf ("%s name=source ! flacdec name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
else if ((strcmp (mime, "audio/wav") == 0) ||
(strcmp (mime, "audio/x-wav") == 0))
desc = g_strdup_printf ("%s ! wavparse name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
else if (strcmp (mime, "audio/x-mod") == 0 ||
strcmp (mime, "audio/x-s3m") == 0 ||
strcmp (mime, "audio/x-xm") == 0 ||
strcmp (mime, "audio/x-it") == 0)
desc = g_strdup_printf ("%s name=source ! modplug name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
else return FALSE;
desc =
g_strdup_printf
("%s name=source ! oggdemux ! vorbisdec name=decoder ! fakesink name=sink",
priv->source_name);
else if ((strcmp (mime, "audio/mpeg") == 0)
|| (strcmp (mime, "audio/x-mp3") == 0)
|| (strcmp (mime, "audio/mp3") == 0)
|| (strcmp (mime, "application/x-id3") == 0)
|| (strcmp (mime, "audio/x-id3") == 0))
desc =
g_strdup_printf
("%s name=source ! id3tag ! mad name=decoder ! audio/x-raw-int ! fakesink name=sink",
priv->source_name);
else if ((strcmp (mime, "application/x-flac") == 0)
|| (strcmp (mime, "audio/x-flac") == 0))
desc =
g_strdup_printf
("%s name=source ! flacdec name=decoder ! audio/x-raw-int ! fakesink name=sink",
priv->source_name);
else if ((strcmp (mime, "audio/wav") == 0)
|| (strcmp (mime, "audio/x-wav") == 0))
desc =
g_strdup_printf
("%s ! wavparse name=decoder ! audio/x-raw-int ! fakesink name=sink",
priv->source_name);
else if (strcmp (mime, "audio/x-mod") == 0
|| strcmp (mime, "audio/x-s3m") == 0 || strcmp (mime, "audio/x-xm") == 0
|| strcmp (mime, "audio/x-it") == 0)
desc =
g_strdup_printf
("%s name=source ! modplug name=decoder ! audio/x-raw-int ! fakesink name=sink",
priv->source_name);
else
return FALSE;
GST_DEBUG ("using description %s", desc);
priv->pipeline_desc = desc;
priv->pipeline = gst_parse_launch (desc, &error);
if (error)
{
if (error) {
g_warning ("Error parsing pipeline description: %s\n", error->message);
g_error_free (error);
return FALSE;
@ -398,12 +407,15 @@ gmi_set_mime (GstMediaInfo *info, const char *mime)
/* get the "decoder" source pad */
priv->decoder_pad = gst_element_get_pad (priv->decoder, "src");
g_assert (GST_IS_PAD (priv->decoder_pad));
GST_DEBUG ("decoder pad: %s:%s", gst_object_get_name (gst_object_get_parent (GST_OBJECT (priv->decoder_pad))), gst_pad_get_name (priv->decoder_pad));
GST_DEBUG ("decoder pad: %s:%s",
gst_object_get_name (gst_object_get_parent (GST_OBJECT (priv->
decoder_pad))), gst_pad_get_name (priv->decoder_pad));
/* attach notify handler */
g_signal_connect (G_OBJECT (info->priv->pipeline), "deep_notify",
G_CALLBACK (deep_notify_callback), info->priv);
g_signal_connect (G_OBJECT (info->priv->pipeline), "found-tag", G_CALLBACK (found_tag_callback), info->priv);
g_signal_connect (G_OBJECT (info->priv->pipeline), "found-tag",
G_CALLBACK (found_tag_callback), info->priv);
g_signal_connect (G_OBJECT (info->priv->pipeline), "error",
G_CALLBACK (error_callback), info->priv);
@ -414,8 +426,7 @@ gmi_set_mime (GstMediaInfo *info, const char *mime)
void
gmi_clear_decoder (GstMediaInfo * info)
{
if (info->priv->pipeline)
{
if (info->priv->pipeline) {
GST_DEBUG ("Unreffing pipeline");
gst_object_unref (GST_OBJECT (info->priv->pipeline));
}
@ -440,8 +451,7 @@ gmip_find_type_pre (GstMediaInfoPriv *priv, GError **error)
* just use it through this function only */
priv->pipeline = gst_pipeline_new ("pipeline-typefind");
if (!GST_IS_PIPELINE (priv->pipeline))
{
if (!GST_IS_PIPELINE (priv->pipeline)) {
gst_media_info_error_create (error, "Internal GStreamer error.");
return FALSE;
}
@ -455,8 +465,7 @@ gmip_find_type_pre (GstMediaInfoPriv *priv, GError **error)
g_signal_connect (G_OBJECT (priv->typefind), "have-type",
G_CALLBACK (have_type_callback), priv);
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
{
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
@ -471,20 +480,16 @@ gmip_find_type_post (GstMediaInfoPriv *priv)
{
/*clear up typefind */
gst_element_set_state (priv->pipeline, GST_STATE_READY);
if (priv->decontainer)
{
if (priv->decontainer) {
gst_element_unlink (priv->source, priv->decontainer);
gst_element_unlink (priv->decontainer, priv->typefind);
gst_bin_remove (GST_BIN (priv->pipeline), priv->decontainer);
}
else
{
} else {
gst_element_unlink (priv->source, priv->typefind);
}
gst_bin_remove (GST_BIN (priv->pipeline), priv->typefind);
if (priv->type == NULL)
{
if (priv->type == NULL) {
g_warning ("iteration ended, type not found !\n");
return FALSE;
}
@ -500,8 +505,7 @@ gmip_find_type (GstMediaInfoPriv *priv, GError ** error)
if (!gmip_find_type_pre (priv, error))
return FALSE;
GST_DEBUG ("gmip_find_type: iterating");
while ((priv->type == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
while ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
return gmip_find_type_post (priv);
@ -512,8 +516,7 @@ gboolean
gmip_find_stream_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
{
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
@ -541,8 +544,7 @@ gmip_find_stream_post (GstMediaInfoPriv *priv)
/* get supported formats on decoder pad */
formats = gst_pad_get_formats (priv->decoder_pad);
while (*formats)
{
while (*formats) {
const GstFormatDefinition *definition;
format = *formats;
@ -551,13 +553,10 @@ gmip_find_stream_post (GstMediaInfoPriv *priv)
definition = gst_format_get_details (*formats);
GST_DEBUG ("trying to figure out length for format %s", definition->nick);
res = gst_pad_query (priv->decoder_pad, GST_QUERY_TOTAL,
&format, &value);
res = gst_pad_query (priv->decoder_pad, GST_QUERY_TOTAL, &format, &value);
if (res)
{
switch (format)
{
if (res) {
switch (format) {
case GST_FORMAT_TIME:
stream->length_time = value;
GST_DEBUG (" total %s: %lld", definition->nick, value);
@ -568,35 +567,33 @@ gmip_find_stream_post (GstMediaInfoPriv *priv)
default:
/* separation is necessary because track_format doesn't resolve to
* int */
if (format == track_format)
{
if (format == track_format) {
stream->length_tracks = value;
GST_DEBUG (" total %s: %lld", definition->nick, value);
}
else
} else
GST_DEBUG ("unhandled format %s", definition->nick);
}
}
else
} else
GST_DEBUG ("query didn't return result for %s", definition->nick);
formats++;
}
if (stream->length_tracks == 0) stream->length_tracks = 1;
if (stream->length_tracks == 0)
stream->length_tracks = 1;
/* now get number of bytes from the sink pad to get the bitrate */
format = GST_FORMAT_BYTES;
g_assert (GST_IS_PAD (priv->source_pad));
res = gst_pad_query (priv->source_pad, GST_QUERY_TOTAL,
&format, &value);
if (!res) g_warning ("Failed to query on sink pad !");
res = gst_pad_query (priv->source_pad, GST_QUERY_TOTAL, &format, &value);
if (!res)
g_warning ("Failed to query on sink pad !");
bytes = value;
GST_DEBUG ("bitrate calc: bytes gotten: %ld", bytes);
if (bytes)
{
if (bytes) {
double seconds = (double) stream->length_time / GST_SECOND;
double bits = bytes * 8;
stream->bitrate = (long) (bits / seconds);
}
GST_DEBUG ("moving to STATE_METADATA\n");
@ -615,15 +612,12 @@ gmip_find_stream (GstMediaInfoPriv *priv)
/* iterate until caps are found */
/* FIXME: this should be done through the plugin sending some signal
* that it is ready for queries */
while (gst_bin_iterate (GST_BIN (priv->pipeline)) &&
priv->format == NULL)
;
while (gst_bin_iterate (GST_BIN (priv->pipeline)) && priv->format == NULL);
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
== GST_STATE_FAILURE)
g_warning ("Couldn't set to paused");
if (priv->format == NULL)
{
if (priv->format == NULL) {
GMI_DEBUG ("gmip_find_stream: couldn't get caps !");
return FALSE;
}
@ -638,8 +632,7 @@ gmip_find_track_metadata_pre (GstMediaInfoPriv *priv)
* querying - we should make gst smarter by itself instead */
priv->metadata_iters = 0;
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
{
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
@ -662,8 +655,7 @@ gmip_find_track_metadata (GstMediaInfoPriv *priv)
{
gmip_find_track_metadata_pre (priv);
GST_DEBUG ("gmip_find_metadata: iterating");
while ((priv->metadata == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
while ((priv->metadata == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
gmip_find_track_metadata_post (priv);
@ -677,8 +669,7 @@ gboolean
gmip_find_track_streaminfo_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
{
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
@ -694,12 +685,9 @@ gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv)
/* now add total length to this, and maybe even bitrate ? FIXME */
track_format = gst_format_get_by_nick ("logical_stream");
if (track_format == 0)
{
if (track_format == 0) {
g_print ("FIXME: implement getting length of whole track\n");
}
else
{
} else {
/* which one are we at ? */
long track_num;
gint64 value_start, value_end;
@ -707,19 +695,15 @@ gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv)
res = gst_pad_query (priv->decoder_pad, GST_QUERY_POSITION,
&track_format, &value_start);
if (res)
{
if (res) {
format = GST_FORMAT_TIME;
track_num = value_start;
GST_DEBUG ("we are currently at %ld", track_num);
res = gst_pad_convert (priv->decoder_pad,
track_format, track_num,
&format, &value_start);
track_format, track_num, &format, &value_start);
res &= gst_pad_convert (priv->decoder_pad,
track_format, track_num + 1,
&format, &value_end);
if (res)
{
track_format, track_num + 1, &format, &value_end);
if (res) {
/* substract to get the length */
GST_DEBUG ("start %lld, end %lld", value_start, value_end);
value_end -= value_start;
@ -755,8 +739,7 @@ gboolean
gmip_find_track_format_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
{
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
@ -779,13 +762,10 @@ gmip_find_track_format (GstMediaInfoPriv *priv)
{
gmip_find_track_format_pre (priv);
GST_DEBUG ("DEBUG: gmip_find_format: iterating");
while ((priv->format == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
while ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
gmip_find_track_format_post (priv);
return TRUE;
}

View file

@ -96,30 +96,26 @@ struct GstMediaInfoPriv
};
/* declarations */
GstMediaInfoStream *
gmi_stream_new (void);
GstMediaInfoStream *gmi_stream_new (void);
void gmi_stream_free (GstMediaInfoStream * stream);
GstMediaInfoTrack *
gmi_track_new (void);
GstMediaInfoTrack *gmi_track_new (void);
void gmip_reset (GstMediaInfoPriv * priv);
gboolean gmip_init (GstMediaInfoPriv * priv, GError ** error);
void gmi_clear_decoder (GstMediaInfo * info);
gboolean gmi_seek_to_track (GstMediaInfo *info,
long track);
gboolean gmi_seek_to_track (GstMediaInfo * info, long track);
gboolean gmi_set_mime (GstMediaInfo *info,
const char *mime);
gboolean gmi_set_mime (GstMediaInfo * info, const char *mime);
void deep_notify_callback (GObject * object,
GstObject *origin,
GParamSpec *pspec,
GstMediaInfoPriv *priv);
void found_tag_callback (GObject *pipeline, GstElement *source, GstTagList *tags, GstMediaInfoPriv *priv);
void error_callback (GObject *element, GstElement *source, GError *error, gchar *debug, GstMediaInfoPriv *priv);
GstObject * origin, GParamSpec * pspec, GstMediaInfoPriv * priv);
void found_tag_callback (GObject * pipeline, GstElement * source,
GstTagList * tags, GstMediaInfoPriv * priv);
void error_callback (GObject * element, GstElement * source, GError * error,
gchar * debug, GstMediaInfoPriv * priv);
gboolean gmip_find_type_pre (GstMediaInfoPriv * priv, GError ** error);
gboolean gmip_find_type_post (GstMediaInfoPriv * priv);

View file

@ -17,8 +17,8 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
} else {
str = g_strdup_value_contents (
gst_tag_list_get_value_index (list, tag, i));
str =
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
if (i == 0) {
@ -44,13 +44,11 @@ info_print (GstMediaInfoStream *stream)
g_print ("- bitrate: %.3f kbps\n", stream->bitrate / 1000.0);
g_print ("- number of tracks: %ld\n", stream->length_tracks);
p = stream->tracks;
if (p == NULL)
{
if (p == NULL) {
g_print ("- no track information, probably an error\n");
return;
}
for (i = 0; i < stream->length_tracks; ++i)
{
for (i = 0; i < stream->length_tracks; ++i) {
g_print ("- track %d\n", i);
track = (GstMediaInfoTrack *) p->data;
g_print (" - metadata:\n");
@ -80,16 +78,14 @@ main (int argc, char *argv[])
gst_init (&argc, &argv);
info = gst_media_info_new (&error);
if (error != NULL)
{
if (error != NULL) {
g_print ("Error creating media-info object: %s\n", error->message);
g_error_free (error);
return -1;
}
g_assert (G_IS_OBJECT (info));
if (!gst_media_info_set_source (info, "gnomevfssrc", &error))
{
if (!gst_media_info_set_source (info, "gnomevfssrc", &error)) {
g_print ("Could not set gnomevfssrc as a source\n");
g_print ("reason: %s\n", error->message);
g_error_free (error);
@ -97,19 +93,18 @@ main (int argc, char *argv[])
}
g_print ("stream: %p, &stream: %p\n", stream, &stream);
for (i = 1; i < argc; ++i)
{
for (i = 1; i < argc; ++i) {
/*
stream = gst_media_info_read (info, argv[i], GST_MEDIA_INFO_ALL);
*/
gst_media_info_read_with_idler (info, argv[i], GST_MEDIA_INFO_ALL, &error);
while (gst_media_info_read_idler (info, &stream, &error) && stream == NULL)
/* keep idling */ g_print ("+");
/* keep idling */
g_print ("+");
g_print ("\nFILE: %s\n", argv[i]);
g_print ("stream: %p, &stream: %p\n", stream, &stream);
if (error)
{
if (error) {
g_print ("Error reading media info: %s\n", error->message);
g_error_free (error);
}

View file

@ -30,8 +30,7 @@ static void gst_media_info_class_init (GstMediaInfoClass *klass);
static void gst_media_info_instance_init (GstMediaInfo * info);
static void gst_media_info_get_property (GObject * object, guint prop_id,
GValue *value,
GParamSpec *pspec);
GValue * value, GParamSpec * pspec);
static gboolean _media_info_inited = FALSE;
@ -64,6 +63,7 @@ GQuark
gst_media_info_error_quark (void)
{
static GQuark quark = 0;
if (quark == 0)
quark = g_quark_from_static_string ("gst-media-info-error-quark");
return quark;
@ -86,7 +86,8 @@ GST_DEBUG_CATEGORY (gst_media_info_debug);
void
gst_media_info_init (void)
{
if (_media_info_inited) return;
if (_media_info_inited)
return;
/* register our debugging category */
GST_DEBUG_CATEGORY_INIT (gst_media_info_debug, "GST_MEDIA_INFO", 0,
@ -99,8 +100,8 @@ GType
gst_media_info_get_type (void)
{
static GType gst_media_info_type = 0;
if (!gst_media_info_type)
{
if (!gst_media_info_type) {
static const GTypeInfo gst_media_info_info = {
sizeof (GstMediaInfoClass),
(GBaseInitFunc) NULL,
@ -113,8 +114,7 @@ gst_media_info_get_type (void)
NULL
};
gst_media_info_type = g_type_register_static (G_TYPE_OBJECT,
"GstMediaInfo",
&gst_media_info_info, 0);
"GstMediaInfo", &gst_media_info_info, 0);
}
return gst_media_info_type;
}
@ -145,9 +145,7 @@ gst_media_info_class_init (GstMediaInfoClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMediaInfoClass, media_info_signal),
NULL, NULL,
gst_marshal_VOID__VOID,
G_TYPE_NONE, 0);
NULL, NULL, gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
@ -158,7 +156,9 @@ gst_media_info_instance_init (GstMediaInfo *info)
info->priv = g_new0 (GstMediaInfoPriv, 1);
error = &info->priv->error;
if (!_media_info_inited) { gst_media_info_init (); }
if (!_media_info_inited) {
gst_media_info_init ();
}
gmip_init (info->priv, error);
gmip_reset (info->priv);
@ -171,8 +171,7 @@ gst_media_info_get_property (GObject *object, guint prop_id,
{
GstMediaInfo *info = GST_MEDIA_INFO (object);
switch (prop_id)
{
switch (prop_id) {
case PROP_SOURCE:
g_value_set_string (value, info->priv->source_name);
break;
@ -187,15 +186,11 @@ gst_media_info_new (GError **error)
{
GstMediaInfo *info = g_object_new (GST_MEDIA_INFO_TYPE, NULL);
if (info->priv->error)
{
if (error)
{
if (info->priv->error) {
if (error) {
*error = info->priv->error;
info->priv->error = NULL;
}
else
{
} else {
g_warning ("Error creating GstMediaInfo object.\n%s",
info->priv->error->message);
g_error_free (info->priv->error);
@ -208,7 +203,8 @@ gst_media_info_new (GError **error)
* public methods
*/
gboolean
gst_media_info_set_source (GstMediaInfo *info, const char *source, GError **error)
gst_media_info_set_source (GstMediaInfo * info, const char *source,
GError ** error)
{
info->priv->source_name = g_strdup (source);
return TRUE;
@ -236,12 +232,14 @@ gst_media_info_read_with_idler (GstMediaInfo *info, const char *location,
* returns: TRUE if it was able to idle, FALSE if there was an error
*/
gboolean
gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GError **error)
gst_media_info_read_idler (GstMediaInfo * info, GstMediaInfoStream ** streamp,
GError ** error)
{
GstMediaInfoPriv *priv;
/* if it's NULL then we're sure something went wrong higher up) */
if (info == NULL) return FALSE;
if (info == NULL)
return FALSE;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
priv = info->priv;
@ -249,12 +247,10 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
g_assert (streamp != NULL);
g_assert (priv);
switch (priv->state)
{
switch (priv->state) {
case GST_MEDIA_INFO_STATE_NULL:
/* make sure we have a source */
if (!priv->source_name)
{
if (!priv->source_name) {
*error = g_error_new (GST_MEDIA_INFO_ERROR, 0,
"No source set on media info.");
return FALSE;
@ -269,14 +265,12 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
gchar *mime;
GST_LOG ("STATE_TYPEFIND");
if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
{
if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
GST_DEBUG ("iterating while in STATE_TYPEFIND");
GMI_DEBUG ("?");
return TRUE;
}
if (priv->type == NULL)
{
if (priv->type == NULL) {
g_warning ("Couldn't find type\n");
return FALSE;
}
@ -284,11 +278,11 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
GST_DEBUG ("doing find_type_post");
gmip_find_type_post (priv);
GST_DEBUG ("finding out mime type");
mime = g_strdup (gst_structure_get_name (
gst_caps_get_structure(priv->type, 0)));
mime =
g_strdup (gst_structure_get_name (gst_caps_get_structure (priv->type,
0)));
GST_DEBUG ("found out mime type: %s", mime);
if (!gmi_set_mime (info, mime))
{
if (!gmi_set_mime (info, mime)) {
/* FIXME: pop up error */
GST_DEBUG ("no decoder pipeline found for mime %s", mime);
return FALSE;
@ -303,13 +297,11 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
case GST_MEDIA_INFO_STATE_STREAM:
{
GST_LOG ("STATE_STREAM");
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
{
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
GMI_DEBUG ("?");
return TRUE;
}
if (priv->format == NULL)
{
if (priv->format == NULL) {
g_warning ("Couldn't find format\n");
return FALSE;
}
@ -325,21 +317,20 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
{
if ((priv->metadata == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)) &&
priv->metadata_iters < MAX_METADATA_ITERS)
{
priv->metadata_iters < MAX_METADATA_ITERS) {
GMI_DEBUG ("?");
priv->metadata_iters++;
return TRUE;
}
if (priv->metadata_iters == MAX_METADATA_ITERS)
g_print ("iterated a few times, didn't find metadata\n");
if (priv->metadata == NULL)
{
if (priv->metadata == NULL) {
/* this is not a permanent failure */
GST_DEBUG ("Couldn't find metadata");
}
GST_DEBUG ("found metadata of track %ld", priv->current_track_num);
if (!gmip_find_track_metadata_post (priv)) return FALSE;
if (!gmip_find_track_metadata_post (priv))
return FALSE;
GST_DEBUG ("METADATA: going to STREAMINFO\n");
priv->state = GST_MEDIA_INFO_STATE_STREAMINFO;
return gmip_find_track_streaminfo_pre (priv);
@ -347,37 +338,33 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
case GST_MEDIA_INFO_STATE_STREAMINFO:
{
if ((priv->streaminfo == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
{
gst_bin_iterate (GST_BIN (priv->pipeline))) {
GMI_DEBUG ("?");
return TRUE;
}
if (priv->streaminfo == NULL)
{
if (priv->streaminfo == NULL) {
/* this is not a permanent failure */
GST_DEBUG ("Couldn't find streaminfo");
}
else
} else
GST_DEBUG ("found streaminfo of track %ld", priv->current_track_num);
if (!gmip_find_track_streaminfo_post (priv)) return FALSE;
if (!gmip_find_track_streaminfo_post (priv))
return FALSE;
priv->state = GST_MEDIA_INFO_STATE_FORMAT;
return gmip_find_track_format_pre (priv);
}
case GST_MEDIA_INFO_STATE_FORMAT:
{
if ((priv->format == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
{
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
GMI_DEBUG ("?");
return TRUE;
}
if (priv->format == NULL)
{
if (priv->format == NULL) {
g_warning ("Couldn't find format\n");
return FALSE;
}
GST_DEBUG ("found format of track %ld", priv->current_track_num);
if (!gmip_find_track_format_post (priv)) return FALSE;
if (!gmip_find_track_format_post (priv))
return FALSE;
/* save the track info */
priv->stream->tracks = g_list_append (priv->stream->tracks,
priv->current_track);
@ -386,12 +373,10 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
priv->location = NULL;
/* now see if we need to seek to a next track or not */
priv->current_track_num++;
if (priv->current_track_num < priv->stream->length_tracks)
{
if (priv->current_track_num < priv->stream->length_tracks) {
gmi_seek_to_track (info, priv->current_track_num);
priv->current_track = gmi_track_new ();
if (!gmip_find_track_metadata_pre (priv))
{
if (!gmip_find_track_metadata_pre (priv)) {
g_free (priv->current_track);
return FALSE;
}
@ -417,12 +402,14 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
* read all possible info from the file pointed to by location
* use flags to limit the type of information searched for */
GstMediaInfoStream *
gst_media_info_read (GstMediaInfo *info, const char *location, guint16 flags, GError **error)
gst_media_info_read (GstMediaInfo * info, const char *location, guint16 flags,
GError ** error)
{
GstMediaInfoStream *stream = NULL;
gst_media_info_read_with_idler (info, location, flags, error);
if (*error) return FALSE;
if (*error)
return FALSE;
while (gst_media_info_read_idler (info, &stream, error) && stream == NULL)
/* keep looping */ ;
if (*error)

View file

@ -23,9 +23,7 @@
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct GstMediaInfoPriv GstMediaInfoPriv;
G_BEGIN_DECLS typedef struct GstMediaInfoPriv GstMediaInfoPriv;
typedef struct _GstMediaInfo GstMediaInfo;
typedef struct _GstMediaInfoClass GstMediaInfoClass;
@ -44,7 +42,8 @@ struct _GstMediaInfoClass
/* signals */
void (*media_info_signal) (GstMediaInfo * gst_media_info);
void (*error_signal) (GstMediaInfo *gst_media_info, GError *error, const gchar *debug);
void (*error_signal) (GstMediaInfo * gst_media_info, GError * error,
const gchar * debug);
gpointer _gst_reserved[GST_PADDING];
};
@ -108,26 +107,17 @@ GType gst_media_info_get_type (void);
GstMediaInfo *gst_media_info_new (GError ** error);
gboolean gst_media_info_set_source (GstMediaInfo * info,
const char *source,
GError **error);
const char *source, GError ** error);
void gst_media_info_read_with_idler (GstMediaInfo * media_info,
const char *location,
guint16 GST_MEDIA_INFO_FLAGS,
GError **error);
const char *location, guint16 GST_MEDIA_INFO_FLAGS, GError ** error);
gboolean gst_media_info_read_idler (GstMediaInfo * media_info,
GstMediaInfoStream **streamp,
GError **error);
GstMediaInfoStream *
gst_media_info_read (GstMediaInfo *media_info,
const char *location,
guint16 GST_MEDIA_INFO_FLAGS,
GError **error);
GstMediaInfoStream ** streamp, GError ** error);
GstMediaInfoStream *gst_media_info_read (GstMediaInfo * media_info,
const char *location, guint16 GST_MEDIA_INFO_FLAGS, GError ** error);
gboolean gst_media_info_read_many (GstMediaInfo * media_info,
GList *locations,
guint16 GST_MEDIA_INFO_FLAGS,
GError **error);
GstCaps * gst_media_info_get_next (GstMediaInfo *media_info,
GError **error);
GList * locations, guint16 GST_MEDIA_INFO_FLAGS, GError ** error);
GstCaps *gst_media_info_get_next (GstMediaInfo * media_info, GError ** error);
/*
* FIXME: reset ?
gboolean gst_media_info_write (GstMediaInfo *media_info,
@ -136,5 +126,4 @@ gboolean gst_media_info_write (GstMediaInfo *media_info,
*/
G_END_DECLS
#endif /* __GST_MEDIA_INFO_H__ */

View file

@ -26,7 +26,8 @@
#include "mixer.h"
#include "mixer-marshal.h"
enum {
enum
{
MUTE_TOGGLED,
RECORD_TOGGLED,
VOLUME_CHANGED,
@ -56,8 +57,7 @@ gst_mixer_get_type (void)
};
gst_mixer_type = g_type_register_static (G_TYPE_INTERFACE,
"GstMixer",
&gst_mixer_info, 0);
"GstMixer", &gst_mixer_info, 0);
g_type_interface_add_prerequisite (gst_mixer_type,
GST_TYPE_IMPLEMENTS_INTERFACE);
}
@ -146,9 +146,7 @@ gst_mixer_list_tracks (GstMixer *mixer)
*/
void
gst_mixer_set_volume (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes)
gst_mixer_set_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -169,9 +167,7 @@ gst_mixer_set_volume (GstMixer *mixer,
*/
void
gst_mixer_get_volume (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes)
gst_mixer_get_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -198,9 +194,7 @@ gst_mixer_get_volume (GstMixer *mixer,
*/
void
gst_mixer_set_mute (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute)
gst_mixer_set_mute (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -223,9 +217,7 @@ gst_mixer_set_mute (GstMixer *mixer,
*/
void
gst_mixer_set_record (GstMixer *mixer,
GstMixerTrack *track,
gboolean record)
gst_mixer_set_record (GstMixer * mixer, GstMixerTrack * track, gboolean record)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -235,43 +227,30 @@ gst_mixer_set_record (GstMixer *mixer,
}
void
gst_mixer_mute_toggled (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute)
gst_mixer_mute_toggled (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
g_signal_emit (G_OBJECT (mixer),
gst_mixer_signals[MUTE_TOGGLED], 0,
track, mute);
gst_mixer_signals[MUTE_TOGGLED], 0, track, mute);
g_signal_emit_by_name (G_OBJECT (track),
"mute_toggled",
mute);
g_signal_emit_by_name (G_OBJECT (track), "mute_toggled", mute);
}
void
gst_mixer_record_toggled (GstMixer * mixer,
GstMixerTrack *track,
gboolean record)
GstMixerTrack * track, gboolean record)
{
g_signal_emit (G_OBJECT (mixer),
gst_mixer_signals[RECORD_TOGGLED], 0,
track, record);
gst_mixer_signals[RECORD_TOGGLED], 0, track, record);
g_signal_emit_by_name (G_OBJECT (track),
"record_toggled",
record);
g_signal_emit_by_name (G_OBJECT (track), "record_toggled", record);
}
void
gst_mixer_volume_changed (GstMixer * mixer,
GstMixerTrack *track,
gint *volumes)
GstMixerTrack * track, gint * volumes)
{
g_signal_emit (G_OBJECT (mixer),
gst_mixer_signals[VOLUME_CHANGED], 0,
track, volumes);
gst_mixer_signals[VOLUME_CHANGED], 0, track, volumes);
g_signal_emit_by_name (G_OBJECT (track),
"volume_changed",
volumes);
g_signal_emit_by_name (G_OBJECT (track), "volume_changed", volumes);
}

View file

@ -27,7 +27,6 @@
#include <gst/mixer/mixer-enumtypes.h>
G_BEGIN_DECLS
#define GST_TYPE_MIXER \
(gst_mixer_get_type ())
#define GST_MIXER(obj) \
@ -40,9 +39,7 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MIXER))
#define GST_MIXER_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_MIXER, GstMixerClass))
#define GST_MIXER_TYPE(klass) (klass->mixer_type)
typedef struct _GstMixer GstMixer;
typedef enum
@ -51,7 +48,8 @@ typedef enum
GST_MIXER_SOFTWARE
} GstMixerType;
typedef struct _GstMixerClass {
typedef struct _GstMixerClass
{
GTypeInterface klass;
GstMixerType mixer_type;
@ -59,30 +57,19 @@ typedef struct _GstMixerClass {
/* virtual functions */
const GList *(*list_tracks) (GstMixer * mixer);
void (* set_volume) (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes);
void (* get_volume) (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes);
void (*set_volume) (GstMixer * mixer, GstMixerTrack * track, gint * volumes);
void (*get_volume) (GstMixer * mixer, GstMixerTrack * track, gint * volumes);
void (* set_mute) (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute);
void (* set_record) (GstMixer *mixer,
GstMixerTrack *track,
gboolean record);
void (*set_mute) (GstMixer * mixer, GstMixerTrack * track, gboolean mute);
void (*set_record) (GstMixer * mixer, GstMixerTrack * track, gboolean record);
/* signals */
void (*mute_toggled) (GstMixer * mixer,
GstMixerTrack *channel,
gboolean mute);
GstMixerTrack * channel, gboolean mute);
void (*record_toggled) (GstMixer * mixer,
GstMixerTrack *channel,
gboolean record);
GstMixerTrack * channel, gboolean record);
void (*volume_changed) (GstMixer * mixer,
GstMixerTrack *channel,
gint *volumes);
GstMixerTrack * channel, gint * volumes);
gpointer _gst_reserved[GST_PADDING];
} GstMixerClass;
@ -92,29 +79,21 @@ GType gst_mixer_get_type (void);
/* virtual class function wrappers */
const GList *gst_mixer_list_tracks (GstMixer * mixer);
void gst_mixer_set_volume (GstMixer * mixer,
GstMixerTrack *track,
gint *volumes);
GstMixerTrack * track, gint * volumes);
void gst_mixer_get_volume (GstMixer * mixer,
GstMixerTrack *track,
gint *volumes);
GstMixerTrack * track, gint * volumes);
void gst_mixer_set_mute (GstMixer * mixer,
GstMixerTrack *track,
gboolean mute);
GstMixerTrack * track, gboolean mute);
void gst_mixer_set_record (GstMixer * mixer,
GstMixerTrack *track,
gboolean record);
GstMixerTrack * track, gboolean record);
/* trigger signals */
void gst_mixer_mute_toggled (GstMixer * mixer,
GstMixerTrack *track,
gboolean mute);
GstMixerTrack * track, gboolean mute);
void gst_mixer_record_toggled (GstMixer * mixer,
GstMixerTrack *track,
gboolean record);
GstMixerTrack * track, gboolean record);
void gst_mixer_volume_changed (GstMixer * mixer,
GstMixerTrack *track,
gint *volumes);
GstMixerTrack * track, gint * volumes);
G_END_DECLS
#endif /* __GST_MIXER_H__ */

View file

@ -25,7 +25,8 @@
#include "mixertrack.h"
enum {
enum
{
/* FILL ME */
SIGNAL_VOLUME_CHANGED,
SIGNAL_RECORD_TOGGLED,
@ -61,8 +62,7 @@ gst_mixer_track_get_type (void)
gst_mixer_track_type =
g_type_register_static (G_TYPE_OBJECT,
"GstMixerTrack",
&mixer_track_info, 0);
"GstMixerTrack", &mixer_track_info, 0);
}
return gst_mixer_track_type;

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_MIXER_TRACK \
(gst_mixer_track_get_type ())
#define GST_MIXER_TRACK(obj) \
@ -38,7 +37,6 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MIXER_TRACK))
#define GST_IS_MIXER_TRACK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MIXER_TRACK))
/*
* Naming:
*
@ -54,8 +52,8 @@ G_BEGIN_DECLS
* mixer, which means that setting this track will change
* the hearable volume on any output.
*/
typedef enum {
typedef enum
{
GST_MIXER_TRACK_INPUT = (1 << 0),
GST_MIXER_TRACK_OUTPUT = (1 << 1),
GST_MIXER_TRACK_MUTE = (1 << 2),
@ -67,26 +65,23 @@ typedef enum {
#define GST_MIXER_TRACK_HAS_FLAG(channel, flag) \
((channel)->flags & flag)
typedef struct _GstMixerTrack {
typedef struct _GstMixerTrack
{
GObject parent;
gchar *label;
GstMixerTrackFlags flags;
gint num_channels,
min_volume,
max_volume;
gint num_channels, min_volume, max_volume;
} GstMixerTrack;
typedef struct _GstMixerTrackClass {
typedef struct _GstMixerTrackClass
{
GObjectClass parent;
/* signals */
void (* mute_toggled) (GstMixerTrack *channel,
gboolean mute);
void (* record_toggled) (GstMixerTrack *channel,
gboolean record);
void (* volume_changed) (GstMixerTrack *channel,
gint *volumes);
void (*mute_toggled) (GstMixerTrack * channel, gboolean mute);
void (*record_toggled) (GstMixerTrack * channel, gboolean record);
void (*volume_changed) (GstMixerTrack * channel, gint * volumes);
gpointer _gst_reserved[GST_PADDING];
} GstMixerTrackClass;
@ -94,5 +89,4 @@ typedef struct _GstMixerTrackClass {
GType gst_mixer_track_get_type (void);
G_END_DECLS
#endif /* __GST_MIXER_TRACK_H__ */

View file

@ -46,8 +46,7 @@ gst_navigation_get_type (void)
};
gst_navigation_type = g_type_register_static (G_TYPE_INTERFACE,
"GstNavigation",
&gst_navigation_info, 0);
"GstNavigation", &gst_navigation_info, 0);
}
return gst_navigation_type;
@ -74,22 +73,17 @@ void
gst_navigation_send_key_event (GstNavigation * navigation, const char *event,
const char *key)
{
gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation",
"event", G_TYPE_STRING, event,
"key", G_TYPE_STRING, key, NULL));
gst_navigation_send_event (navigation,
gst_structure_new ("application/x-gst-navigation", "event", G_TYPE_STRING,
event, "key", G_TYPE_STRING, key, NULL));
}
void
gst_navigation_send_mouse_event (GstNavigation * navigation, const char *event,
int button, double x, double y)
{
gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation",
"event", G_TYPE_STRING, event,
"button", G_TYPE_INT, button,
"pointer_x", G_TYPE_DOUBLE, x,
gst_navigation_send_event (navigation,
gst_structure_new ("application/x-gst-navigation", "event", G_TYPE_STRING,
event, "button", G_TYPE_INT, button, "pointer_x", G_TYPE_DOUBLE, x,
"pointer_y", G_TYPE_DOUBLE, y, NULL));
}

View file

@ -26,7 +26,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_NAVIGATION \
(gst_navigation_get_type ())
#define GST_NAVIGATION(obj) \
@ -35,10 +34,10 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NAVIGATION))
#define GST_NAVIGATION_GET_IFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_NAVIGATION, GstNavigationInterface))
typedef struct _GstNavigation GstNavigation;
typedef struct _GstNavigationInterface {
typedef struct _GstNavigationInterface
{
GTypeInterface g_iface;
/* virtual functions */
@ -50,7 +49,8 @@ typedef struct _GstNavigationInterface {
GType gst_navigation_get_type (void);
/* virtual class function wrappers */
void gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure);
void gst_navigation_send_event (GstNavigation * navigation,
GstStructure * structure);
void gst_navigation_send_key_event (GstNavigation * navigation,
const char *event, const char *key);
@ -58,5 +58,4 @@ void gst_navigation_send_mouse_event (GstNavigation *navigation,
const char *event, int button, double x, double y);
G_END_DECLS
#endif /* __GST_NAVIGATION_H__ */

View file

@ -34,7 +34,8 @@ enum
LAST_SIGNAL
};
struct _GstPlayPrivate {
struct _GstPlayPrivate
{
char *location;
GHashTable *elements;
@ -67,13 +68,16 @@ static GstPipelineClass *parent_class = NULL;
/* */
/* ======================================================= */
static GstCaps * gst_play_video_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data);
static GstCaps * gst_play_audio_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data);
static GstCaps *gst_play_video_fixate (GstPad * pad, const GstCaps * caps,
gpointer user_data);
static GstCaps *gst_play_audio_fixate (GstPad * pad, const GstCaps * caps,
gpointer user_data);
static GQuark
gst_play_error_quark (void)
{
static GQuark quark = 0;
if (quark == 0)
quark = g_quark_from_static_string ("gst-play-error-quark");
return quark;
@ -102,8 +106,7 @@ gst_play_error_plugin (const gchar *element, GError ** error)
message = g_strdup_printf ("The %s element could not be found. "
"This element is essential for playback. "
"Please install the right plug-in and verify "
"that it works by running 'gst-inspect %s'",
element, element);
"that it works by running 'gst-inspect %s'", element, element);
gst_play_error_create (error, message);
g_free (message);
return;
@ -131,16 +134,21 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
{
/* Threads */
GstElement *work_thread, *audio_thread, *video_thread;
/* Main Thread elements */
GstElement *source, *autoplugger, *audioconvert, *volume, *tee, *identity;
GstElement *identity_cs;
/* Visualization bin */
GstElement *vis_bin, *vis_queue, *vis_element, *vis_cs;
/* Video Thread elements */
GstElement *video_queue, *video_switch, *video_cs, *video_balance;
GstElement *balance_cs, *video_scaler, *video_sink;
/* Audio Thread elements */
GstElement *audio_queue, *audio_sink;
/* Some useful pads */
GstPad *tee_pad1, *tee_pad2;
@ -162,7 +170,8 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
g_hash_table_insert (play->priv->elements, "autoplugger", autoplugger);
/* Make sure we convert audio to the needed format */
GST_PLAY_MAKE_OR_ERROR (audioconvert, "audioconvert", "audioconvert", error);
GST_PLAY_MAKE_OR_ERROR (audioconvert, "audioconvert", "audioconvert",
error);
g_hash_table_insert (play->priv->elements, "audioconvert", audioconvert);
/* Duplicate audio signal to audio sink and visualization thread */
@ -173,7 +182,8 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
g_hash_table_insert (play->priv->elements, "tee_pad2", tee_pad2);
g_hash_table_insert (play->priv->elements, "tee", tee);
gst_bin_add_many (GST_BIN (work_thread), source, autoplugger, audioconvert, tee, NULL);
gst_bin_add_many (GST_BIN (work_thread), source, autoplugger, audioconvert,
tee, NULL);
if (!gst_element_link_many (source, autoplugger, audioconvert, tee, NULL))
GST_PLAY_ERROR_RETURN (error, "Could not link source thread elements");
@ -184,8 +194,7 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
identity_cs = gst_element_factory_make ("ffcolorspace", "identity_cs");
if (!GST_IS_ELEMENT (identity_cs)) {
identity_cs = gst_element_factory_make ("colorspace", "identity_cs");
if (!GST_IS_ELEMENT (identity_cs))
{
if (!GST_IS_ELEMENT (identity_cs)) {
gst_play_error_plugin ("colorspace", error);
return FALSE;
}
@ -199,8 +208,7 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
/* Visualization bin (note: it s not added to the pipeline yet) */
{
vis_bin = gst_bin_new ("vis_bin");
if (!GST_IS_ELEMENT (vis_bin))
{
if (!GST_IS_ELEMENT (vis_bin)) {
gst_play_error_plugin ("bin", error);
return FALSE;
}
@ -219,8 +227,7 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
vis_cs = gst_element_factory_make ("ffcolorspace", "vis_cs");
if (!GST_IS_ELEMENT (vis_cs)) {
vis_cs = gst_element_factory_make ("colorspace", "vis_cs");
if (!GST_IS_ELEMENT (vis_cs))
{
if (!GST_IS_ELEMENT (vis_cs)) {
gst_play_error_plugin ("colorspace", error);
return FALSE;
}
@ -230,9 +237,10 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
gst_bin_add_many (GST_BIN (vis_bin), vis_queue, vis_element, vis_cs, NULL);
if (!gst_element_link_many (vis_queue, vis_element, vis_cs, NULL))
GST_PLAY_ERROR_RETURN (error, "Could not link visualisation thread elements");
gst_element_add_ghost_pad (vis_bin,
gst_element_get_pad (vis_cs, "src"), "src");
GST_PLAY_ERROR_RETURN (error,
"Could not link visualisation thread elements");
gst_element_add_ghost_pad (vis_bin, gst_element_get_pad (vis_cs, "src"),
"src");
}
/* Creating our video output bin */
{
@ -251,8 +259,7 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
video_cs = gst_element_factory_make ("ffcolorspace", "video_cs");
if (!GST_IS_ELEMENT (video_cs)) {
video_cs = gst_element_factory_make ("colorspace", "video_cs");
if (!GST_IS_ELEMENT (video_cs))
{
if (!GST_IS_ELEMENT (video_cs)) {
gst_play_error_plugin ("colorspace", error);
return FALSE;
}
@ -260,15 +267,15 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
g_hash_table_insert (play->priv->elements, "video_cs", video_cs);
/* Software colorbalance */
GST_PLAY_MAKE_OR_ERROR (video_balance, "videobalance", "video_balance", error);
GST_PLAY_MAKE_OR_ERROR (video_balance, "videobalance", "video_balance",
error);
g_hash_table_insert (play->priv->elements, "video_balance", video_balance);
/* Colorspace conversion */
balance_cs = gst_element_factory_make ("ffcolorspace", "balance_cs");
if (!GST_IS_ELEMENT (balance_cs)) {
balance_cs = gst_element_factory_make ("colorspace", "balance_cs");
if (!GST_IS_ELEMENT (balance_cs))
{
if (!GST_IS_ELEMENT (balance_cs)) {
gst_play_error_plugin ("colorspace", error);
return FALSE;
}
@ -285,26 +292,32 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
GST_PLAY_MAKE_OR_ERROR (video_sink, "fakesink", "video_sink", error);
g_hash_table_insert (play->priv->elements, "video_sink", video_sink);
gst_bin_add_many (GST_BIN (video_thread), video_queue, video_switch, video_cs,
video_balance, balance_cs, video_scaler, video_sink, NULL);
gst_bin_add_many (GST_BIN (video_thread), video_queue, video_switch,
video_cs, video_balance, balance_cs, video_scaler, video_sink, NULL);
/* break down linking so we can figure out what might be failing */
if (!gst_element_link (video_queue, video_switch))
GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (queue and switch)");
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (queue and switch)");
if (!gst_element_link (video_switch, video_cs))
GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (switch and cs)");
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (switch and cs)");
if (!gst_element_link (video_cs, video_balance))
GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (cs and balance)");
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (cs and balance)");
if (!gst_element_link (video_balance, balance_cs))
GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (balance and balance_cs)");
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (balance and balance_cs)");
if (!gst_element_link (balance_cs, video_scaler))
GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (balance_cs and scaler)");
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (balance_cs and scaler)");
if (!gst_element_link (video_scaler, video_sink))
GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (balance_cs and scaler)");
gst_element_add_ghost_pad (video_thread,
gst_element_get_pad (video_queue, "sink"),
"sink");
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (balance_cs and scaler)");
gst_element_add_ghost_pad (video_thread, gst_element_get_pad (video_queue,
"sink"), "sink");
if (!gst_element_link (identity_cs, video_thread))
GST_PLAY_ERROR_RETURN (error, "Could not link video output thread elements");
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread elements");
}
/* Creating our audio output bin
{ queue ! fakesink } */
@ -327,12 +340,13 @@ gst_play_pipeline_setup (GstPlay *play, GError **error)
GST_PLAY_MAKE_OR_ERROR (audio_sink, "fakesink", "audio_sink", error);
g_hash_table_insert (play->priv->elements, "audio_sink", audio_sink);
gst_bin_add_many (GST_BIN (audio_thread), audio_queue, volume, audio_sink, NULL);
gst_bin_add_many (GST_BIN (audio_thread), audio_queue, volume, audio_sink,
NULL);
if (!gst_element_link_many (audio_queue, volume, audio_sink, NULL))
GST_PLAY_ERROR_RETURN (error, "Could not link audio output thread elements");
gst_element_add_ghost_pad (audio_thread,
gst_element_get_pad (audio_queue, "sink"),
"sink");
GST_PLAY_ERROR_RETURN (error,
"Could not link audio output thread elements");
gst_element_add_ghost_pad (audio_thread, gst_element_get_pad (audio_queue,
"sink"), "sink");
gst_pad_link (tee_pad2, gst_element_get_pad (audio_queue, "sink"));
}
@ -358,8 +372,7 @@ gst_play_tick_callback (GstPlay *play)
g_return_val_if_fail (play != NULL, FALSE);
/* just return without updating the UI when we are in the middle of seeking */
if (play->priv->tick_unblock_remaining > 0)
{
if (play->priv->tick_unblock_remaining > 0) {
play->priv->tick_unblock_remaining -= TICK_INTERVAL_MSEC;
return TRUE;
}
@ -436,8 +449,7 @@ gst_play_get_length_callback (GstPlay *play)
if (play->priv->get_length_attempt > 15) {
play->priv->length_id = 0;
return FALSE;
}
else
} else
return TRUE;
}
@ -449,7 +461,8 @@ gst_play_video_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data)
GST_DEBUG ("video fixate %p %" GST_PTR_FORMAT, pad, caps);
if (gst_caps_get_size (caps) > 1) return NULL;
if (gst_caps_get_size (caps) > 1)
return NULL;
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
@ -478,8 +491,9 @@ gst_play_audio_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data)
GST_DEBUG ("audio fixate %p %" GST_PTR_FORMAT, pad, caps);
newcaps = gst_caps_new_full (gst_structure_copy (
gst_caps_get_structure (caps, 0)), NULL);
newcaps =
gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps, 0)),
NULL);
structure = gst_caps_get_structure (newcaps, 0);
if (gst_caps_structure_fixate_field_nearest_int (structure, "rate", 44100)) {
@ -518,8 +532,7 @@ gst_play_state_change (GstElement *element, GstElementState old,
}
play->priv->tick_id = g_timeout_add (TICK_INTERVAL_MSEC,
(GSourceFunc) gst_play_tick_callback,
play);
(GSourceFunc) gst_play_tick_callback, play);
play->priv->get_length_attempt = 0;
@ -529,10 +542,8 @@ gst_play_state_change (GstElement *element, GstElementState old,
}
play->priv->length_id = g_timeout_add (TICK_INTERVAL_MSEC,
(GSourceFunc) gst_play_get_length_callback,
play);
}
else {
(GSourceFunc) gst_play_get_length_callback, play);
} else {
if (play->priv->tick_id) {
g_source_remove (play->priv->tick_id);
play->priv->tick_id = 0;
@ -548,7 +559,8 @@ gst_play_state_change (GstElement *element, GstElementState old,
}
static void
gst_play_identity_handoff (GstElement *identity, GstBuffer *buf, GstPlay *play)
gst_play_identity_handoff (GstElement * identity, GstBuffer * buf,
GstPlay * play)
{
g_signal_handler_disconnect (G_OBJECT (identity), play->priv->handoff_hid);
play->priv->handoff_hid = 0;
@ -605,8 +617,7 @@ gst_play_init (GstPlay *play)
play->priv->error = NULL;
play->priv->debug = NULL;
if (!gst_play_pipeline_setup (play, &play->priv->error))
{
if (!gst_play_pipeline_setup (play, &play->priv->error)) {
g_warning ("libgstplay: failed initializing pipeline, error: %s",
play->priv->error->message);
}
@ -637,8 +648,7 @@ gst_play_class_init (GstPlayClass *klass)
g_signal_new ("have-video-size", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GstPlayClass, have_video_size), NULL, NULL,
gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_INT);
gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
}
/* ======================================================= */
@ -757,8 +767,7 @@ gst_play_seek_to_time (GstPlay * play, gint64 time_nanos)
"audioconvert");
audio_sink_element = g_hash_table_lookup (play->priv->elements,
"audio_sink_element");
video_seek_element = g_hash_table_lookup (play->priv->elements,
"identity");
video_seek_element = g_hash_table_lookup (play->priv->elements, "identity");
if (GST_IS_ELEMENT (audio_seek_element) &&
GST_IS_ELEMENT (video_seek_element) &&
@ -771,12 +780,10 @@ gst_play_seek_to_time (GstPlay * play, gint64 time_nanos)
play->priv->tick_unblock_remaining = 500;
s = gst_element_seek (video_seek_element, GST_FORMAT_TIME |
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH,
time_nanos);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, time_nanos);
if (!s) {
s = gst_element_seek (audio_seek_element, GST_FORMAT_TIME |
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH,
time_nanos);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, time_nanos);
}
if (s) {
@ -890,8 +897,7 @@ gst_play_set_video_sink (GstPlay *play, GstElement *video_sink)
video_sink_element);
if (GST_IS_X_OVERLAY (video_sink_element)) {
g_signal_connect (G_OBJECT (video_sink_element),
"desired_size_changed",
G_CALLBACK (gst_play_have_video_size), play);
"desired_size_changed", G_CALLBACK (gst_play_have_video_size), play);
}
}
@ -982,8 +988,7 @@ gst_play_set_visualization (GstPlay *play, GstElement *vis_element)
vis_queue = g_hash_table_lookup (play->priv->elements, "vis_queue");
if (!GST_IS_ELEMENT (vis_queue))
return FALSE;
old_vis_element = g_hash_table_lookup (play->priv->elements,
"vis_element");
old_vis_element = g_hash_table_lookup (play->priv->elements, "vis_element");
if (!GST_IS_ELEMENT (old_vis_element))
return FALSE;
vis_cs = g_hash_table_lookup (play->priv->elements, "vis_cs");
@ -1079,8 +1084,7 @@ gst_play_connect_visualization (GstPlay * play, gboolean connect)
gst_element_release_request_pad (video_switch, switch_pad);
gst_object_ref (GST_OBJECT (vis_bin));
gst_bin_remove (GST_BIN (video_thread), vis_bin);
}
else {
} else {
/* If we are supposed to disconnect then nothing to do we return */
if (!connect) {
@ -1097,8 +1101,7 @@ gst_play_connect_visualization (GstPlay * play, gboolean connect)
/* Adding, linking */
play->priv->handoff_hid = g_signal_connect (G_OBJECT (identity),
"handoff",
G_CALLBACK (gst_play_identity_handoff), play);
"handoff", G_CALLBACK (gst_play_identity_handoff), play);
gst_bin_add (GST_BIN (video_thread), vis_bin);
gst_pad_link (tee_pad1, vis_queue_pad);
gst_element_link (vis_bin, video_switch);
@ -1153,8 +1156,7 @@ gst_play_get_sink_element (GstPlay *play,
element = gst_play_get_sink_element (play, element, sink_type);
if (GST_IS_ELEMENT (element))
return element;
}
else {
} else {
pads = gst_element_get_pad_list (element);
has_src = FALSE;
has_correct_type = FALSE;
@ -1163,8 +1165,7 @@ gst_play_get_sink_element (GstPlay *play,
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == GST_PAD_SRC) {
has_src = TRUE;
break;
}
else {
} else {
/* If not a src pad checking caps */
GstCaps *caps;
GstStructure *structure;
@ -1227,16 +1228,13 @@ gst_play_new (GError **error)
{
GstPlay *play = g_object_new (GST_TYPE_PLAY, NULL);
if (play->priv->error)
{
if (error)
{
if (play->priv->error) {
if (error) {
*error = play->priv->error;
play->priv->error = NULL;
}
else
{
g_warning ("Error creating GstPlay object.\n%s", play->priv->error->message);
} else {
g_warning ("Error creating GstPlay object.\n%s",
play->priv->error->message);
g_error_free (play->priv->error);
}
}

View file

@ -70,27 +70,19 @@ struct _GstPlayClass
GType gst_play_get_type (void);
GstPlay *gst_play_new (GError ** error);
gboolean gst_play_set_data_src (GstPlay *play,
GstElement *data_src);
gboolean gst_play_set_video_sink (GstPlay *play,
GstElement *video_sink);
gboolean gst_play_set_audio_sink (GstPlay *play,
GstElement *audio_sink);
gboolean gst_play_set_data_src (GstPlay * play, GstElement * data_src);
gboolean gst_play_set_video_sink (GstPlay * play, GstElement * video_sink);
gboolean gst_play_set_audio_sink (GstPlay * play, GstElement * audio_sink);
gboolean gst_play_set_visualization (GstPlay *play,
GstElement *element);
gboolean gst_play_connect_visualization (GstPlay *play,
gboolean connect);
gboolean gst_play_set_visualization (GstPlay * play, GstElement * element);
gboolean gst_play_connect_visualization (GstPlay * play, gboolean connect);
gboolean gst_play_set_location (GstPlay *play,
const char *location);
gboolean gst_play_set_location (GstPlay * play, const char *location);
char *gst_play_get_location (GstPlay * play);
gboolean gst_play_seek_to_time (GstPlay *play,
gint64 time_nanos);
gboolean gst_play_seek_to_time (GstPlay * play, gint64 time_nanos);
GstElement *gst_play_get_sink_element (GstPlay * play,
GstElement *element,
GstPlaySinkType sink_type);
GstElement * element, GstPlaySinkType sink_type);
#endif /* __GST_PLAY_H__ */

View file

@ -27,7 +27,8 @@
#include "propertyprobe.h"
enum {
enum
{
SIGNAL_PROBE_NEEDED,
LAST_SIGNAL
};
@ -56,8 +57,7 @@ gst_property_probe_get_type (void)
gst_property_probe_type =
g_type_register_static (G_TYPE_INTERFACE,
"GstPropertyProbe",
&gst_property_probe_info, 0);
"GstPropertyProbe", &gst_property_probe_info, 0);
}
return gst_property_probe_type;
@ -70,9 +70,9 @@ gst_property_probe_iface_init (GstPropertyProbeInterface *iface)
if (!initialized) {
gst_property_probe_signals[SIGNAL_PROBE_NEEDED] =
g_signal_new ("probe-needed", G_TYPE_FROM_CLASS (iface), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstPropertyProbeInterface, probe_needed),
NULL, NULL, g_cclosure_marshal_VOID__POINTER,
g_signal_new ("probe-needed", G_TYPE_FROM_CLASS (iface),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstPropertyProbeInterface,
probe_needed), NULL, NULL, g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
initialized = TRUE;
}
@ -108,8 +108,7 @@ gst_property_probe_get_properties (GstPropertyProbe *probe)
}
const GParamSpec *
gst_property_probe_get_property (GstPropertyProbe *probe,
const gchar *name)
gst_property_probe_get_property (GstPropertyProbe * probe, const gchar * name)
{
const GList *pspecs = gst_property_probe_get_properties (probe);

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_PROPERTY_PROBE \
(gst_property_probe_get_type ())
#define GST_PROPERTY_PROBE(obj) \
@ -34,27 +33,23 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PROPERTY_PROBE))
#define GST_PROPERTY_PROBE_GET_IFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_PROPERTY_PROBE, GstPropertyProbeInterface))
typedef struct _GstPropertyProbe GstPropertyProbe; /* dummy typedef */
typedef struct _GstPropertyProbeInterface {
typedef struct _GstPropertyProbeInterface
{
GTypeInterface klass;
/* signals */
void (*probe_needed) (GstPropertyProbe *probe,
const GParamSpec *pspec);
void (*probe_needed) (GstPropertyProbe * probe, const GParamSpec * pspec);
/* virtual functions */
const GList *(*get_properties) (GstPropertyProbe * probe);
gboolean (*needs_probe) (GstPropertyProbe * probe,
guint prop_id,
const GParamSpec *pspec);
guint prop_id, const GParamSpec * pspec);
void (*probe_property) (GstPropertyProbe * probe,
guint prop_id,
const GParamSpec *pspec);
guint prop_id, const GParamSpec * pspec);
GValueArray *(*get_values) (GstPropertyProbe * probe,
guint prop_id,
const GParamSpec *pspec);
guint prop_id, const GParamSpec * pspec);
gpointer _gst_reserved[GST_PADDING];
} GstPropertyProbeInterface;
@ -89,9 +84,8 @@ GValueArray * gst_property_probe_get_values_name (GstPropertyProbe *prob
/* sugar */
GValueArray *gst_property_probe_probe_and_get_values (GstPropertyProbe * probe,
const GParamSpec * pspec);
GValueArray * gst_property_probe_probe_and_get_values_name (GstPropertyProbe *probe,
const gchar *name);
GValueArray *gst_property_probe_probe_and_get_values_name (GstPropertyProbe *
probe, const gchar * name);
G_END_DECLS
#endif /* __GST_PROPERTY_PROBE_H__ */

View file

@ -29,33 +29,40 @@
/*#include <ml.h> */
#include "private.h"
void conv_double_float_ref(double *dest, float *src, int n)
void
conv_double_float_ref (double *dest, float *src, int n)
{
int i;
for (i = 0; i < n; i++) {
dest[i] = src[i];
}
}
void conv_float_double_ref(float *dest, double *src, int n)
void
conv_float_double_ref (float *dest, double *src, int n)
{
int i;
for (i = 0; i < n; i++) {
dest[i] = src[i];
}
}
void conv_double_float_dstr(double *dest, float *src, int n, int dstr)
void
conv_double_float_dstr (double *dest, float *src, int n, int dstr)
{
int i;
void *d = dest;
for (i = 0; i < n; i++) {
(*(double *) d) = *src++;
d += dstr;
}
}
void conv_float_double_sstr(float *dest, double *src, int n, int sstr)
void
conv_float_double_sstr (float *dest, double *src, int n, int sstr)
{
int i;
void *s = src;
@ -65,4 +72,3 @@ void conv_float_double_sstr(float *dest, double *src, int n, int sstr)
s += sstr;
}
}

Some files were not shown because too many files have changed in this diff Show more