summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>2003-10-10 12:24:20 +0000
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>2003-10-10 12:24:20 +0000
commit39b91cdb495b9f9b326e79a10f64753a097c203c (patch)
treed73cde761fa1ad9856cb12ddd724082c0999f77d
parent715b0097be24824bef899de3cb35d1c8808946dc (diff)
downloadgst-plugins-bad-39b91cdb495b9f9b326e79a10f64753a097c203c.tar.gz
gst-plugins-bad-39b91cdb495b9f9b326e79a10f64753a097c203c.tar.bz2
gst-plugins-bad-39b91cdb495b9f9b326e79a10f64753a097c203c.zip
Make GstMixerTrack a GObject. I also want to make it emit several signals, starting work is in here but it's not full...
Original commit message from CVS: Make GstMixerTrack a GObject. I also want to make it emit several signals, starting work is in here but it's not fully implemented yet. for OSS, this will cause issues, but for ALSA, this is all automated.
-rw-r--r--gst-libs/gst/mixer/Makefile.am15
-rw-r--r--gst-libs/gst/mixer/mixer.c4
-rw-r--r--gst-libs/gst/mixer/mixer.h29
-rw-r--r--gst-libs/gst/mixer/mixertrack.c122
-rw-r--r--gst-libs/gst/mixer/mixertrack.h86
5 files changed, 221 insertions, 35 deletions
diff --git a/gst-libs/gst/mixer/Makefile.am b/gst-libs/gst/mixer/Makefile.am
index de67658f..32be46fd 100644
--- a/gst-libs/gst/mixer/Makefile.am
+++ b/gst-libs/gst/mixer/Makefile.am
@@ -1,10 +1,15 @@
-lib_LTLIBRARIES = libgstmixer.la
+libgstinterfacesincludedir = \
+ $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/mixer
-libgstmixer_la_SOURCES = mixer.c
+libgstinterfacesinclude_HEADERS = \
+ mixer.h \
+ mixertrack.h
-libgstmixerincludedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/mixer
-libgstmixerinclude_HEADERS = mixer.h
+lib_LTLIBRARIES = libgstmixer.la
-libgstmixer_la_LIBADD =
+libgstmixer_la_SOURCES = \
+ mixer.c \
+ mixertrack.c
+libgstmixer_la_LIBADD =
libgstmixer_la_CFLAGS = $(GST_CFLAGS) $(GST_OPT_CFLAGS)
libgstmixer_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
diff --git a/gst-libs/gst/mixer/mixer.c b/gst-libs/gst/mixer/mixer.c
index 8dbc6ad5..28d10e6a 100644
--- a/gst-libs/gst/mixer/mixer.c
+++ b/gst-libs/gst/mixer/mixer.c
@@ -23,7 +23,7 @@
#include "config.h"
#endif
-#include <gst/mixer/mixer.h>
+#include "mixer.h"
static void gst_mixer_class_init (GstMixerClass *klass);
@@ -67,7 +67,7 @@ gst_mixer_class_init (GstMixerClass *klass)
}
const GList *
-gst_mixer_list_tracks (GstMixer *mixer)
+gst_mixer_list_tracks (GstMixer *mixer)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
diff --git a/gst-libs/gst/mixer/mixer.h b/gst-libs/gst/mixer/mixer.h
index 5639758e..6ee49e3a 100644
--- a/gst-libs/gst/mixer/mixer.h
+++ b/gst-libs/gst/mixer/mixer.h
@@ -23,6 +23,7 @@
#define __GST_MIXER_H__
#include <gst/gst.h>
+#include <gst/mixer/mixertrack.h>
G_BEGIN_DECLS
@@ -39,34 +40,6 @@ G_BEGIN_DECLS
#define GST_MIXER_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_MIXER, GstMixerClass))
-/* In this interface, a `track' is a unit of recording or playback, pretty much
- * equivalent to what comes in or goes out through a GstPad. Each track can have
- * one or more `channels', which are logical parts of the track. A `stereo
- * track', then, would be one stream with two channels, while a `mono track'
- * would be a stream with a single channel. More complex examples are possible
- * as well ; for example, professional audio hardware might handle audio tracks
- * with 8 or 16 channels each.
- *
- * All these are audio terms. I don't know exactly what this would translate to
- * for video, but a track might be an entire video stream, and a channel might
- * be the information for one of the colors in the stream.
- */
-
-#define GST_MIXER_TRACK_INPUT (1<<0)
-#define GST_MIXER_TRACK_OUTPUT (1<<1)
-#define GST_MIXER_TRACK_MUTE (1<<2)
-#define GST_MIXER_TRACK_RECORD (1<<3)
-
-typedef struct _GstMixerTrack {
- gchar *label;
- gint num_channels,
- flags,
- min_volume, max_volume;
-} GstMixerTrack;
-
-#define GST_MIXER_TRACK_HAS_FLAG(track, flag) \
- ((track)->flags & flag)
-
typedef struct _GstMixer GstMixer;
typedef struct _GstMixerClass {
diff --git a/gst-libs/gst/mixer/mixertrack.c b/gst-libs/gst/mixer/mixertrack.c
new file mode 100644
index 00000000..242b5915
--- /dev/null
+++ b/gst-libs/gst/mixer/mixertrack.c
@@ -0,0 +1,122 @@
+/* GStreamer Mixer
+ * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * mixertrack.c: mixer track object design
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "mixertrack.h"
+
+enum {
+ /* FILL ME */
+ SIGNAL_VOLUME_CHANGED,
+ SIGNAL_RECORD_TOGGLED,
+ SIGNAL_MUTE_TOGGLED,
+ LAST_SIGNAL
+};
+
+static void gst_mixer_track_class_init (GstMixerTrackClass *klass);
+static void gst_mixer_track_init (GstMixerTrack *mixer);
+static void gst_mixer_track_dispose (GObject *object);
+
+static GObjectClass *parent_class = NULL;
+static guint signals[LAST_SIGNAL] = { 0 };
+
+GType
+gst_mixer_track_get_type (void)
+{
+ static GType gst_mixer_track_type = 0;
+
+ if (!gst_mixer_track_type) {
+ static const GTypeInfo mixer_track_info = {
+ sizeof (GstMixerTrackClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gst_mixer_track_class_init,
+ NULL,
+ NULL,
+ sizeof (GstMixerTrack),
+ 0,
+ (GInstanceInitFunc) gst_mixer_track_init,
+ NULL
+ };
+
+ gst_mixer_track_type =
+ g_type_register_static (G_TYPE_OBJECT,
+ "GstMixerTrack",
+ &mixer_track_info, 0);
+ }
+
+ return gst_mixer_track_type;
+}
+
+static void
+gst_mixer_track_class_init (GstMixerTrackClass *klass)
+{
+ GObjectClass *object_klass = (GObjectClass *) klass;
+
+ parent_class = g_type_class_ref (G_TYPE_OBJECT);
+
+ signals[SIGNAL_RECORD_TOGGLED] =
+ g_signal_new ("record_toggled", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMixerTrackClass,
+ record_toggled),
+ NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ signals[SIGNAL_MUTE_TOGGLED] =
+ g_signal_new ("mute_toggled", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMixerTrackClass,
+ mute_toggled),
+ NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ signals[SIGNAL_VOLUME_CHANGED] =
+ g_signal_new ("volume_changed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMixerTrackClass,
+ volume_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ object_klass->dispose = gst_mixer_track_dispose;
+}
+
+static void
+gst_mixer_track_init (GstMixerTrack *channel)
+{
+ channel->label = NULL;
+ channel->min_volume = channel->max_volume = 0;
+ channel->flags = 0;
+ channel->num_channels = 0;
+}
+
+static void
+gst_mixer_track_dispose (GObject *object)
+{
+ GstMixerTrack *channel = GST_MIXER_TRACK (object);
+
+ if (channel->label)
+ g_free (channel->label);
+
+ if (parent_class->dispose)
+ parent_class->dispose (object);
+}
diff --git a/gst-libs/gst/mixer/mixertrack.h b/gst-libs/gst/mixer/mixertrack.h
new file mode 100644
index 00000000..cb010822
--- /dev/null
+++ b/gst-libs/gst/mixer/mixertrack.h
@@ -0,0 +1,86 @@
+/* GStreamer Mixer
+ * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * mixertrack.h: mixer track object
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_MIXER_TRACK_H__
+#define __GST_MIXER_TRACK_H__
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_MIXER_TRACK \
+ (gst_mixer_track_get_type ())
+#define GST_MIXER_TRACK(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MIXER_TRACK, \
+ GstMixerTrack))
+#define GST_MIXER_TRACK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MIXER_TRACK, \
+ GstMixerTrackClass))
+#define GST_IS_MIXER_TRACK(obj) \
+ (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:
+ *
+ * A track is a single input/output stream (e.g. line-in,
+ * microphone, etc.). Channels are then single streams
+ * within a track. A mono stream has one channel, a stereo
+ * stream has two, etc.
+ */
+
+typedef enum {
+ GST_MIXER_TRACK_INPUT = (1<<0),
+ GST_MIXER_TRACK_OUTPUT = (1<<1),
+ GST_MIXER_TRACK_MUTE = (1<<2),
+ GST_MIXER_TRACK_RECORD = (1<<3),
+} GstMixerTrackFlags;
+
+#define GST_MIXER_TRACK_HAS_FLAG(channel, flag) \
+ ((channel)->flags & flag)
+
+typedef struct _GstMixerTrack {
+ GObject parent;
+
+ gchar *label;
+ GstMixerTrackFlags flags;
+ gint num_channels,
+ min_volume,
+ max_volume;
+} GstMixerTrack;
+
+typedef struct _GstMixerTrackClass {
+ GObjectClass parent;
+
+ void (* mute_toggled) (GstMixerTrack *channel,
+ gboolean on);
+ void (* record_toggled) (GstMixerTrack *channel,
+ gboolean on);
+ void (* volume_changed) (GstMixerTrack *channel,
+ gint *volumes);
+} GstMixerTrackClass;
+
+GType gst_mixer_track_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_MIXER_TRACK_H__ */