Another mini-lib down, to make space for new mini libs.
Remove bogus copyright line while at it.
GST_PLUGINS_BASE_BUILT_SOURCES := \
pkgconfig/gstreamer-app-0.10.pc \
pkgconfig/gstreamer-audio-0.10.pc \
- pkgconfig/gstreamer-cdda-0.10.pc \
pkgconfig/gstreamer-fft-0.10.pc \
pkgconfig/gstreamer-interfaces-0.10.pc \
pkgconfig/gstreamer-pbutils-0.10.pc \
pkgconfig/gstreamer-video-0.10.pc \
pkgconfig/gstreamer-app-0.10-uninstalled.pc \
pkgconfig/gstreamer-audio-0.10-uninstalled.pc \
- pkgconfig/gstreamer-cdda-0.10-uninstalled.pc \
pkgconfig/gstreamer-fft-0.10-uninstalled.pc \
pkgconfig/gstreamer-interfaces-0.10-uninstalled.pc \
pkgconfig/gstreamer-pbutils-0.10-uninstalled.pc \
gst-libs/gst/Makefile
gst-libs/gst/audio/Makefile
gst-libs/gst/app/Makefile
-gst-libs/gst/cdda/Makefile
gst-libs/gst/fft/Makefile
gst-libs/gst/interfaces/Makefile
gst-libs/gst/riff/Makefile
pkgconfig/gstreamer-audio-uninstalled.pc
pkgconfig/gstreamer-app.pc
pkgconfig/gstreamer-app-uninstalled.pc
-pkgconfig/gstreamer-cdda.pc
-pkgconfig/gstreamer-cdda-uninstalled.pc
pkgconfig/gstreamer-fft.pc
pkgconfig/gstreamer-fft-uninstalled.pc
pkgconfig/gstreamer-interfaces.pc
GTKDOC_LIBS = \
$(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-@GST_MAJORMINOR@.la \
$(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \
- $(top_builddir)/gst-libs/gst/cdda/libgstcdda-@GST_MAJORMINOR@.la \
$(top_builddir)/gst-libs/gst/fft/libgstfft-@GST_MAJORMINOR@.la \
$(top_builddir)/gst-libs/gst/rtp/libgstrtp-@GST_MAJORMINOR@.la \
$(top_builddir)/gst-libs/gst/rtsp/libgstrtsp-@GST_MAJORMINOR@.la \
<filename>-lgstaudio-&GST_MAJORMINOR;</filename> to the library flags.
</para>
<xi:include href="xml/gstaudio.xml" />
+ <xi:include href="xml/gstaudiocdsrc.xml" />
<xi:include href="xml/gstaudioclock.xml" />
<xi:include href="xml/gstaudiodecoder.xml" />
<xi:include href="xml/gstaudioencoder.xml" />
<xi:include href="xml/gstaudioiec61937.xml" />
</chapter>
- <chapter id="gstreamer-cdda">
- <title>CDDA Library</title>
- <para>
- This library should be linked to by getting cflags and libs from
- <filename>gstreamer-plugins-base-&GST_MAJORMINOR;.pc</filename> and adding
- <filename>-lgstcdda-&GST_MAJORMINOR;</filename> to the library flags.
- </para>
- <xi:include href="xml/gstcddabasesrc.xml" />
- </chapter>
-
<chapter id="gstreamer-ffft">
<title>FFT Library</title>
<para>
GST_AUDIO_CLOCK_CAST
</SECTION>
+<SECTION>
+<FILE>gstaudiocdsrc</FILE>
+<INCLUDE>gst/audio/gstaudiocdsrc.h</INCLUDE>
+GstAudioCdSrc
+GstAudioCdSrcClass
+GstAudioCdSrcTrack
+GstAudioCdSrcMode
+gst_audio_cd_src_add_track
+<SUBSECTION Standard>
+GST_TYPE_AUDIO_CD_SRC_MODE
+gst_audio_cd_src_mode_get_type
+GST_AUDIO_CD_SRC
+GST_AUDIO_CD_SRC_CLASS
+GST_AUDIO_CD_SRC_GET_CLASS
+GST_IS_AUDIO_CD_SRC
+GST_IS_AUDIO_CD_SRC_CLASS
+GST_TYPE_AUDIO_CD_SRC
+gst_audio_cd_src_get_type
+</SECTION>
+
<SECTION>
<FILE>gstaudiodecoder</FILE>
<INCLUDE>gst/audio/gstaudiodecoder.h</INCLUDE>
gst_audio_iec61937_payload
</SECTION>
-
-# cdda
-
-<SECTION>
-<FILE>gstcddabasesrc</FILE>
-<INCLUDE>gst/cdda/gstcddabasesrc.h</INCLUDE>
-GstCddaBaseSrc
-GstCddaBaseSrcClass
-GstCddaBaseSrcTrack
-GstCddaBaseSrcMode
-gst_cdda_base_src_add_track
-<SUBSECTION Standard>
-GST_TYPE_CDDA_BASE_SRC_MODE
-gst_cdda_base_src_mode_get_type
-GST_CDDA_BASE_SRC
-GST_CDDA_BASE_SRC_CLASS
-GST_CDDA_BASE_SRC_GET_CLASS
-GST_IS_CDDA_BASE_SRC
-GST_IS_CDDA_BASE_SRC_CLASS
-GST_TYPE_CDDA_BASE_SRC
-gst_cdda_base_src_get_type
-</SECTION>
-
# fft
<SECTION>
#include <gst/gst.h>
+#include <gst/audio/gstaudiocdsrc.h>
+gst_audio_cd_src_get_type
#include <gst/audio/gstaudioclock.h>
gst_audio_clock_get_type
#include <gst/audio/gstaudiodecoder.h>
#include <gst/audio/gstaudioringbuffer.h>
gst_audio_ring_buffer_get_type
-
-#include <gst/cdda/gstcddabasesrc.h>
-gst_cdda_base_src_get_type
-
-
#include <gst/interfaces/colorbalance.h>
gst_color_balance_get_type
gst_color_balance_channel_get_type
# The interfaces directory has to be built before the others,
# otherwise some generated header files will be missing for the
# plugins in the other directories.
-# Also, the tag directory has to be built before the cdda directory.
SUBDIRS = \
interfaces \
tag \
- cdda \
fft \
rtp \
sdp \
noinst_HEADERS = gettext.h gst-i18n-plugin.h
# dependencies:
-audio: interfaces
-
-cdda: tag
+audio: interfaces tag
riff: tag audio
gstaudioclock.c \
mixerutils.c \
multichannel.c \
+ gstaudiocdsrc.c \
gstaudiodecoder.c \
gstaudioencoder.c \
gstaudiobasesink.c \
gstaudioringbuffer.h \
gstaudioclock.h \
gstaudiofilter.h \
+ gstaudiocdsrc.h \
gstaudiodecoder.h \
gstaudioencoder.h \
gstaudiobasesink.h \
libgstaudio_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
libgstaudio_@GST_MAJORMINOR@_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) \
- $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-@GST_MAJORMINOR@.la
+ $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-@GST_MAJORMINOR@.la \
+ $(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la
libgstaudio_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
include $(top_srcdir)/common/gst-glib-gen.mak
--- /dev/null
+/* GStreamer Audio CD Source Base Class
+ * Copyright (C) 2005 Tim-Philipp Müller <tim centricular net>
+ *
+ * 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.
+ */
+
+/* TODO:
+ *
+ * - in ::start(), we want to post a tags message with an array or a list
+ * of tagslists of all tracks, so that applications know at least the
+ * number of tracks and all track durations immediately without having
+ * to do any querying. We have to decide what type and name to use for
+ * this array of track taglists.
+ *
+ * - FIX cddb discid calculation algorithm for mixed mode CDs - do we use
+ * offsets and duration of ALL tracks (data + audio) for the CDDB ID
+ * calculation, or only audio tracks?
+ *
+ * - Do we really need properties for the TOC bias/offset stuff? Wouldn't
+ * environment variables make much more sense? Do we need this at all
+ * (does it only affect ancient hardware?)
+ */
+
+/**
+ * SECTION:gstaudiocdsrc
+ * @short_description: Base class for Audio CD sources
+ *
+ * <refsect2>
+ * <para>
+ * Provides a base class for CD digital audio (CDDA) sources, which handles
+ * things like seeking, querying, discid calculation, tags, and buffer
+ * timestamping.
+ * </para>
+ * <title>Using GstAudioCdSrc-based elements in applications</title>
+ * <para>
+ * GstAudioCdSrc registers two #GstFormat<!-- -->s of its own, namely
+ * the "track" format and the "sector" format. Applications will usually
+ * only find the "track" format interesting. You can retrieve that #GstFormat
+ * for use in seek events or queries with gst_format_get_by_nick("track").
+ * </para>
+ * <para>
+ * In order to query the number of tracks, for example, an application would
+ * set the CDDA source element to READY or PAUSED state and then query the
+ * the number of tracks via gst_element_query_duration() using the track
+ * format acquired above. Applications can query the currently playing track
+ * in the same way.
+ * </para>
+ * <para>
+ * Alternatively, applications may retrieve the currently playing track and
+ * the total number of tracks from the taglist that will posted on the bus
+ * whenever the CD is opened or the currently playing track changes. The
+ * taglist will contain GST_TAG_TRACK_NUMBER and GST_TAG_TRACK_COUNT tags.
+ * </para>
+ * <para>
+ * Applications playing back CD audio using playbin and cdda://n URIs should
+ * issue a seek command in track format to change between tracks, rather than
+ * setting a new cdda://n+1 URI on playbin (as setting a new URI on playbin
+ * involves closing and re-opening the CD device, which is much much slower).
+ * </para>
+ * <title>Tags and meta-information</title>
+ * <para>
+ * CDDA sources will automatically emit a number of tags, details about which
+ * can be found in the libgsttag documentation. Those tags are:
+ * #GST_TAG_CDDA_CDDB_DISCID, #GST_TAG_CDDA_CDDB_DISCID_FULL,
+ * #GST_TAG_CDDA_MUSICBRAINZ_DISCID, #GST_TAG_CDDA_MUSICBRAINZ_DISCID_FULL,
+ * among others.
+ * </para>
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <stdlib.h> /* for strtol */
+
+#include <gst/tag/tag.h>
+#include <gst/audio/audio.h>
+#include "gstaudiocdsrc.h"
+#include "gst/gst-i18n-plugin.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_audio_cd_src_debug);
+#define GST_CAT_DEFAULT gst_audio_cd_src_debug
+
+#define DEFAULT_DEVICE "/dev/cdrom"
+
+#define CD_FRAMESIZE_RAW (2352)
+
+#define SECTORS_PER_SECOND (75)
+#define SECTORS_PER_MINUTE (75*60)
+#define SAMPLES_PER_SECTOR (CD_FRAMESIZE_RAW >> 2)
+#define TIME_INTERVAL_FROM_SECTORS(sectors) ((SAMPLES_PER_SECTOR * sectors * GST_SECOND) / 44100)
+#define SECTORS_FROM_TIME_INTERVAL(dtime) (dtime * 44100 / (SAMPLES_PER_SECTOR * GST_SECOND))
+
+enum
+{
+ ARG_0,
+ ARG_MODE,
+ ARG_DEVICE,
+ ARG_TRACK,
+ ARG_TOC_OFFSET,
+ ARG_TOC_BIAS
+};
+
+static void gst_audio_cd_src_uri_handler_init (gpointer g_iface,
+ gpointer iface_data);
+static void gst_audio_cd_src_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_audio_cd_src_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_audio_cd_src_finalize (GObject * obj);
+static gboolean gst_audio_cd_src_query (GstBaseSrc * src, GstQuery * query);
+static gboolean gst_audio_cd_src_handle_event (GstBaseSrc * basesrc,
+ GstEvent * event);
+static gboolean gst_audio_cd_src_do_seek (GstBaseSrc * basesrc,
+ GstSegment * segment);
+static gboolean gst_audio_cd_src_start (GstBaseSrc * basesrc);
+static gboolean gst_audio_cd_src_stop (GstBaseSrc * basesrc);
+static GstFlowReturn gst_audio_cd_src_create (GstPushSrc * pushsrc,
+ GstBuffer ** buf);
+static gboolean gst_audio_cd_src_is_seekable (GstBaseSrc * basesrc);
+static void gst_audio_cd_src_update_duration (GstAudioCdSrc * src);
+static void gst_audio_cd_src_set_index (GstElement * src, GstIndex * index);
+static GstIndex *gst_audio_cd_src_get_index (GstElement * src);
+
+#define gst_audio_cd_src_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstAudioCdSrc, gst_audio_cd_src, GST_TYPE_PUSH_SRC,
+ G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
+ gst_audio_cd_src_uri_handler_init));
+
+#define SRC_CAPS \
+ "audio/x-raw, " \
+ "format = (string) " GST_AUDIO_NE(S16) ", " \
+ "rate = (int) 44100, " \
+ "channels = (int) 2" \
+
+static GstStaticPadTemplate gst_audio_cd_src_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (SRC_CAPS)
+ );
+
+/* our two formats */
+static GstFormat track_format;
+static GstFormat sector_format;
+
+GType
+gst_audio_cd_src_mode_get_type (void)
+{
+ static GType mode_type; /* 0 */
+ static const GEnumValue modes[] = {
+ {GST_AUDIO_CD_SRC_MODE_NORMAL, "Stream consists of a single track",
+ "normal"},
+ {GST_AUDIO_CD_SRC_MODE_CONTINUOUS, "Stream consists of the whole disc",
+ "continuous"},
+ {0, NULL, NULL}
+ };
+
+ if (mode_type == 0)
+ mode_type = g_enum_register_static ("GstAudioCdSrcMode", modes);
+
+ return mode_type;
+}
+
+static void
+gst_audio_cd_src_class_init (GstAudioCdSrcClass * klass)
+{
+ GstElementClass *element_class;
+ GstPushSrcClass *pushsrc_class;
+ GstBaseSrcClass *basesrc_class;
+ GObjectClass *gobject_class;
+
+ gobject_class = (GObjectClass *) klass;
+ element_class = (GstElementClass *) klass;
+ basesrc_class = (GstBaseSrcClass *) klass;
+ pushsrc_class = (GstPushSrcClass *) klass;
+
+ GST_DEBUG_CATEGORY_INIT (gst_audio_cd_src_debug, "audiocdsrc", 0,
+ "Audio CD source base class");
+
+ /* our very own formats */
+ track_format = gst_format_register ("track", "CD track");
+ sector_format = gst_format_register ("sector", "CD sector");
+
+ /* register CDDA tags */
+ gst_tag_register_musicbrainz_tags ();
+
+#if 0
+ ///// FIXME: what type to use here? ///////
+ gst_tag_register (GST_TAG_CDDA_TRACK_TAGS, GST_TAG_FLAG_META, GST_TYPE_TAG_LIST, "track-tags", "CDDA taglist for one track", gst_tag_merge_use_first); ///////////// FIXME: right function??? ///////
+#endif
+
+ gobject_class->set_property = gst_audio_cd_src_set_property;
+ gobject_class->get_property = gst_audio_cd_src_get_property;
+ gobject_class->finalize = gst_audio_cd_src_finalize;
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEVICE,
+ g_param_spec_string ("device", "Device", "CD device location",
+ NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE,
+ g_param_spec_enum ("mode", "Mode", "Mode", GST_TYPE_AUDIO_CD_SRC_MODE,
+ GST_AUDIO_CD_SRC_MODE_NORMAL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TRACK,
+ g_param_spec_uint ("track", "Track", "Track", 1, 99, 1,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+#if 0
+ /* Do we really need this toc adjustment stuff as properties? does the user
+ * have a chance to set it in practice, e.g. when using sound-juicer, rb,
+ * totem, whatever? Shouldn't we rather use environment variables
+ * for this? (tpm) */
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOC_OFFSET,
+ g_param_spec_int ("toc-offset", "Table of contents offset",
+ "Add <n> sectors to the values reported", G_MININT, G_MAXINT, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOC_BIAS,
+ g_param_spec_boolean ("toc-bias", "Table of contents 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", FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#endif
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_audio_cd_src_src_template));
+
+ element_class->set_index = GST_DEBUG_FUNCPTR (gst_audio_cd_src_set_index);
+ element_class->get_index = GST_DEBUG_FUNCPTR (gst_audio_cd_src_get_index);
+
+ basesrc_class->start = GST_DEBUG_FUNCPTR (gst_audio_cd_src_start);
+ basesrc_class->stop = GST_DEBUG_FUNCPTR (gst_audio_cd_src_stop);
+ basesrc_class->query = GST_DEBUG_FUNCPTR (gst_audio_cd_src_query);
+ basesrc_class->event = GST_DEBUG_FUNCPTR (gst_audio_cd_src_handle_event);
+ basesrc_class->do_seek = GST_DEBUG_FUNCPTR (gst_audio_cd_src_do_seek);
+ basesrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_audio_cd_src_is_seekable);
+
+ pushsrc_class->create = GST_DEBUG_FUNCPTR (gst_audio_cd_src_create);
+}
+
+static void
+gst_audio_cd_src_init (GstAudioCdSrc * src)
+{
+ /* we're not live and we operate in time */
+ gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
+ gst_base_src_set_live (GST_BASE_SRC (src), FALSE);
+
+ src->device = NULL;
+ src->mode = GST_AUDIO_CD_SRC_MODE_NORMAL;
+ src->uri_track = -1;
+}
+
+static void
+gst_audio_cd_src_finalize (GObject * obj)
+{
+ GstAudioCdSrc *cddasrc = GST_AUDIO_CD_SRC (obj);
+
+ g_free (cddasrc->uri);
+ g_free (cddasrc->device);
+
+ if (cddasrc->index)
+ gst_object_unref (cddasrc->index);
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+gst_audio_cd_src_set_device (GstAudioCdSrc * src, const gchar * device)
+{
+ if (src->device)
+ g_free (src->device);
+ src->device = NULL;
+
+ if (!device)
+ return;
+
+ /* skip multiple slashes */
+ while (*device == '/' && *(device + 1) == '/')
+ device++;
+
+#ifdef __sun
+ /*
+ * On Solaris, /dev/rdsk is used for accessing the CD device, but some
+ * applications pass in /dev/dsk, so correct.
+ */
+ if (strncmp (device, "/dev/dsk", 8) == 0) {
+ gchar *rdsk_value;
+ rdsk_value = g_strdup_printf ("/dev/rdsk%s", device + 8);
+ src->device = g_strdup (rdsk_value);
+ g_free (rdsk_value);
+ } else {
+#endif
+ src->device = g_strdup (device);
+#ifdef __sun
+ }
+#endif
+}
+
+static void
+gst_audio_cd_src_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (object);
+
+ GST_OBJECT_LOCK (src);
+
+ switch (prop_id) {
+ case ARG_MODE:{
+ src->mode = g_value_get_enum (value);
+ break;
+ }
+ case ARG_DEVICE:{
+ const gchar *dev = g_value_get_string (value);
+
+ gst_audio_cd_src_set_device (src, dev);
+ break;
+ }
+ case ARG_TRACK:{
+ guint track = g_value_get_uint (value);
+
+ if (src->num_tracks > 0 && track > src->num_tracks) {
+ g_warning ("Invalid track %u", track);
+ } else if (track > 0 && src->tracks != NULL) {
+ src->cur_sector = src->tracks[track - 1].start;
+ src->uri_track = track;
+ } else {
+ src->uri_track = track; /* seek will be done in start() */
+ }
+ break;
+ }
+ case ARG_TOC_OFFSET:{
+ src->toc_offset = g_value_get_int (value);
+ break;
+ }
+ case ARG_TOC_BIAS:{
+ src->toc_bias = g_value_get_boolean (value);
+ break;
+ }
+ default:{
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+ }
+
+ GST_OBJECT_UNLOCK (src);
+}
+
+static void
+gst_audio_cd_src_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstAudioCdSrcClass *klass = GST_AUDIO_CD_SRC_GET_CLASS (object);
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (object);
+
+ GST_OBJECT_LOCK (src);
+
+ switch (prop_id) {
+ case ARG_MODE:
+ g_value_set_enum (value, src->mode);
+ break;
+ case ARG_DEVICE:{
+ if (src->device == NULL && klass->get_default_device != NULL) {
+ gchar *d = klass->get_default_device (src);
+
+ if (d != NULL) {
+ g_value_set_string (value, DEFAULT_DEVICE);
+ g_free (d);
+ break;
+ }
+ }
+ if (src->device == NULL)
+ g_value_set_string (value, DEFAULT_DEVICE);
+ else
+ g_value_set_string (value, src->device);
+ break;
+ }
+ case ARG_TRACK:{
+ if (src->num_tracks <= 0 && src->uri_track > 0) {
+ g_value_set_uint (value, src->uri_track);
+ } else {
+ g_value_set_uint (value, src->cur_track + 1);
+ }
+ break;
+ }
+ case ARG_TOC_OFFSET:
+ g_value_set_int (value, src->toc_offset);
+ break;
+ case ARG_TOC_BIAS:
+ g_value_set_boolean (value, src->toc_bias);
+ break;
+ default:{
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+ }
+
+ GST_OBJECT_UNLOCK (src);
+}
+
+static gint
+gst_audio_cd_src_get_track_from_sector (GstAudioCdSrc * src, gint sector)
+{
+ gint i;
+
+ for (i = 0; i < src->num_tracks; ++i) {
+ if (sector >= src->tracks[i].start && sector <= src->tracks[i].end)
+ return i;
+ }
+ return -1;
+}
+
+static gboolean
+gst_audio_cd_src_convert (GstAudioCdSrc * src, GstFormat src_format,
+ gint64 src_val, GstFormat dest_format, gint64 * dest_val)
+{
+ gboolean started;
+
+ GST_LOG_OBJECT (src, "converting value %" G_GINT64_FORMAT " from %s into %s",
+ src_val, gst_format_get_name (src_format),
+ gst_format_get_name (dest_format));
+
+ if (src_format == dest_format) {
+ *dest_val = src_val;
+ return TRUE;
+ }
+
+ started = GST_OBJECT_FLAG_IS_SET (GST_BASE_SRC (src), GST_BASE_SRC_STARTED);
+
+ if (src_format == track_format) {
+ if (!started)
+ goto not_started;
+ if (src_val < 0 || src_val >= src->num_tracks) {
+ GST_DEBUG_OBJECT (src, "track number %d out of bounds", (gint) src_val);
+ goto wrong_value;
+ }
+ src_format = GST_FORMAT_DEFAULT;
+ src_val = src->tracks[src_val].start * SAMPLES_PER_SECTOR;
+ } else if (src_format == sector_format) {
+ src_format = GST_FORMAT_DEFAULT;
+ src_val = src_val * SAMPLES_PER_SECTOR;
+ }
+
+ if (src_format == dest_format) {
+ *dest_val = src_val;
+ goto done;
+ }
+
+ switch (src_format) {
+ case GST_FORMAT_BYTES:
+ /* convert to samples (4 bytes per sample) */
+ src_val = src_val >> 2;
+ /* fallthrough */
+ case GST_FORMAT_DEFAULT:{
+ switch (dest_format) {
+ case GST_FORMAT_BYTES:{
+ if (src_val < 0) {
+ GST_DEBUG_OBJECT (src, "sample source value negative");
+ goto wrong_value;
+ }
+ *dest_val = src_val << 2; /* 4 bytes per sample */
+ break;
+ }
+ case GST_FORMAT_TIME:{
+ *dest_val = gst_util_uint64_scale_int (src_val, GST_SECOND, 44100);
+ break;
+ }
+ default:{
+ gint64 sector = src_val / SAMPLES_PER_SECTOR;
+
+ if (dest_format == sector_format) {
+ *dest_val = sector;
+ } else if (dest_format == track_format) {
+ if (!started)
+ goto not_started;
+ *dest_val = gst_audio_cd_src_get_track_from_sector (src, sector);
+ } else {
+ goto unknown_format;
+ }
+ break;
+ }
+ }
+ break;
+ }
+ case GST_FORMAT_TIME:{
+ gint64 sample_offset;
+
+ if (src_val == GST_CLOCK_TIME_NONE) {
+ GST_DEBUG_OBJECT (src, "source time value invalid");
+ goto wrong_value;
+ }
+
+ sample_offset = gst_util_uint64_scale_int (src_val, 44100, GST_SECOND);
+ switch (dest_format) {
+ case GST_FORMAT_BYTES:{
+ *dest_val = sample_offset << 2; /* 4 bytes per sample */
+ break;
+ }
+ case GST_FORMAT_DEFAULT:{
+ *dest_val = sample_offset;
+ break;
+ }
+ default:{
+ gint64 sector = sample_offset / SAMPLES_PER_SECTOR;
+
+ if (dest_format == sector_format) {
+ *dest_val = sector;
+ } else if (dest_format == track_format) {
+ if (!started)
+ goto not_started;
+ *dest_val = gst_audio_cd_src_get_track_from_sector (src, sector);
+ } else {
+ goto unknown_format;
+ }
+ break;
+ }
+ }
+ break;
+ }
+ default:{
+ goto unknown_format;
+ }
+ }
+
+done:
+ {
+ GST_LOG_OBJECT (src, "returning %" G_GINT64_FORMAT, *dest_val);
+ return TRUE;
+ }
+
+unknown_format:
+ {
+ GST_DEBUG_OBJECT (src, "conversion failed: %s", "unsupported format");
+ return FALSE;
+ }
+
+wrong_value:
+ {
+ GST_DEBUG_OBJECT (src, "conversion failed: %s",
+ "source value not within allowed range");
+ return FALSE;
+ }
+
+not_started:
+ {
+ GST_DEBUG_OBJECT (src, "conversion failed: %s",
+ "cannot do this conversion, device not open");
+ return FALSE;
+ }
+}
+
+static gboolean
+gst_audio_cd_src_query (GstBaseSrc * basesrc, GstQuery * query)
+{
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (basesrc);
+ gboolean started;
+
+ started = GST_OBJECT_FLAG_IS_SET (basesrc, GST_BASE_SRC_STARTED);
+
+ GST_LOG_OBJECT (src, "handling %s query",
+ gst_query_type_get_name (GST_QUERY_TYPE (query)));
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_DURATION:{
+ GstFormat dest_format;
+ gint64 dest_val;
+ guint sectors;
+
+ gst_query_parse_duration (query, &dest_format, NULL);
+
+ if (!started)
+ return FALSE;
+
+ g_assert (src->tracks != NULL);
+
+ if (dest_format == track_format) {
+ GST_LOG_OBJECT (src, "duration: %d tracks", src->num_tracks);
+ gst_query_set_duration (query, track_format, src->num_tracks);
+ return TRUE;
+ }
+
+ if (src->cur_track < 0 || src->cur_track >= src->num_tracks)
+ return FALSE;
+
+ if (src->mode == GST_AUDIO_CD_SRC_MODE_NORMAL) {
+ sectors = src->tracks[src->cur_track].end -
+ src->tracks[src->cur_track].start + 1;
+ } else {
+ sectors = src->tracks[src->num_tracks - 1].end -
+ src->tracks[0].start + 1;
+ }
+
+ /* ... and convert into final format */
+ if (!gst_audio_cd_src_convert (src, sector_format, sectors,
+ dest_format, &dest_val)) {
+ return FALSE;
+ }
+
+ gst_query_set_duration (query, dest_format, dest_val);
+
+ GST_LOG ("duration: %u sectors, %" G_GINT64_FORMAT " in format %s",
+ sectors, dest_val, gst_format_get_name (dest_format));
+ break;
+ }
+ case GST_QUERY_POSITION:{
+ GstFormat dest_format;
+ gint64 pos_sector;
+ gint64 dest_val;
+
+ gst_query_parse_position (query, &dest_format, NULL);
+
+ if (!started)
+ return FALSE;
+
+ g_assert (src->tracks != NULL);
+
+ if (dest_format == track_format) {
+ GST_LOG_OBJECT (src, "position: track %d", src->cur_track);
+ gst_query_set_position (query, track_format, src->cur_track);
+ return TRUE;
+ }
+
+ if (src->cur_track < 0 || src->cur_track >= src->num_tracks)
+ return FALSE;
+
+ if (src->mode == GST_AUDIO_CD_SRC_MODE_NORMAL) {
+ pos_sector = src->cur_sector - src->tracks[src->cur_track].start;
+ } else {
+ pos_sector = src->cur_sector - src->tracks[0].start;
+ }
+
+ if (!gst_audio_cd_src_convert (src, sector_format, pos_sector,
+ dest_format, &dest_val)) {
+ return FALSE;
+ }
+
+ gst_query_set_position (query, dest_format, dest_val);
+
+ GST_LOG ("position: sector %u, %" G_GINT64_FORMAT " in format %s",
+ (guint) pos_sector, dest_val, gst_format_get_name (dest_format));
+ break;
+ }
+ case GST_QUERY_CONVERT:{
+ GstFormat src_format, dest_format;
+ gint64 src_val, dest_val;
+
+ gst_query_parse_convert (query, &src_format, &src_val, &dest_format,
+ NULL);
+
+ if (!gst_audio_cd_src_convert (src, src_format, src_val, dest_format,
+ &dest_val)) {
+ return FALSE;
+ }
+
+ gst_query_set_convert (query, src_format, src_val, dest_format, dest_val);
+ break;
+ }
+ default:{
+ GST_DEBUG_OBJECT (src, "unhandled query, chaining up to parent class");
+ return GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);
+ }
+ }
+
+ return TRUE;
+}
+
+static gboolean
+gst_audio_cd_src_is_seekable (GstBaseSrc * basesrc)
+{
+ return TRUE;
+}
+
+static gboolean
+gst_audio_cd_src_do_seek (GstBaseSrc * basesrc, GstSegment * segment)
+{
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (basesrc);
+ gint64 seek_sector;
+
+ GST_DEBUG_OBJECT (src, "segment %" GST_TIME_FORMAT "-%" GST_TIME_FORMAT,
+ GST_TIME_ARGS (segment->start), GST_TIME_ARGS (segment->stop));
+
+ if (!gst_audio_cd_src_convert (src, GST_FORMAT_TIME, segment->start,
+ sector_format, &seek_sector)) {
+ GST_WARNING_OBJECT (src, "conversion failed");
+ return FALSE;
+ }
+
+ /* we should only really be called when open */
+ g_assert (src->cur_track >= 0 && src->cur_track < src->num_tracks);
+
+ switch (src->mode) {
+ case GST_AUDIO_CD_SRC_MODE_NORMAL:
+ seek_sector += src->tracks[src->cur_track].start;
+ break;
+ case GST_AUDIO_CD_SRC_MODE_CONTINUOUS:
+ seek_sector += src->tracks[0].start;
+ break;
+ default:
+ g_return_val_if_reached (FALSE);
+ }
+
+ src->cur_sector = (gint) seek_sector;
+
+ GST_DEBUG_OBJECT (src, "seek'd to sector %d", src->cur_sector);
+
+ return TRUE;
+}
+
+static gboolean
+gst_audio_cd_src_handle_track_seek (GstAudioCdSrc * src, gdouble rate,
+ GstSeekFlags flags, GstSeekType start_type, gint64 start,
+ GstSeekType stop_type, gint64 stop)
+{
+ GstBaseSrc *basesrc = GST_BASE_SRC (src);
+ GstEvent *event;
+
+ if ((flags & GST_SEEK_FLAG_SEGMENT) == GST_SEEK_FLAG_SEGMENT) {
+ gint64 start_time = -1;
+ gint64 stop_time = -1;
+
+ if (src->mode != GST_AUDIO_CD_SRC_MODE_CONTINUOUS) {
+ GST_DEBUG_OBJECT (src, "segment seek in track format is only "
+ "supported in CONTINUOUS mode, not in mode %d", src->mode);
+ return FALSE;
+ }
+
+ switch (start_type) {
+ case GST_SEEK_TYPE_SET:
+ if (!gst_audio_cd_src_convert (src, track_format, start,
+ GST_FORMAT_TIME, &start_time)) {
+ GST_DEBUG_OBJECT (src, "cannot convert track %d to time",
+ (gint) start);
+ return FALSE;
+ }
+ break;
+ case GST_SEEK_TYPE_END:
+ if (!gst_audio_cd_src_convert (src, track_format,
+ src->num_tracks - start - 1, GST_FORMAT_TIME, &start_time)) {
+ GST_DEBUG_OBJECT (src, "cannot convert track %d to time",
+ (gint) start);
+ return FALSE;
+ }
+ start_type = GST_SEEK_TYPE_SET;
+ break;
+ case GST_SEEK_TYPE_NONE:
+ start_time = -1;
+ break;
+ default:
+ g_return_val_if_reached (FALSE);
+ }
+
+ switch (stop_type) {
+ case GST_SEEK_TYPE_SET:
+ if (!gst_audio_cd_src_convert (src, track_format, stop,
+ GST_FORMAT_TIME, &stop_time)) {
+ GST_DEBUG_OBJECT (src, "cannot convert track %d to time",
+ (gint) stop);
+ return FALSE;
+ }
+ break;
+ case GST_SEEK_TYPE_END:
+ if (!gst_audio_cd_src_convert (src, track_format,
+ src->num_tracks - stop - 1, GST_FORMAT_TIME, &stop_time)) {
+ GST_DEBUG_OBJECT (src, "cannot convert track %d to time",
+ (gint) stop);
+ return FALSE;
+ }
+ stop_type = GST_SEEK_TYPE_SET;
+ break;
+ case GST_SEEK_TYPE_NONE:
+ stop_time = -1;
+ break;
+ default:
+ g_return_val_if_reached (FALSE);
+ }
+
+ GST_LOG_OBJECT (src, "seek segment %" GST_TIME_FORMAT "-%" GST_TIME_FORMAT,
+ GST_TIME_ARGS (start_time), GST_TIME_ARGS (stop_time));
+
+ /* send fake segment seek event in TIME format to
+ * base class, which will hopefully handle the rest */
+
+ event = gst_event_new_seek (rate, GST_FORMAT_TIME, flags, start_type,
+ start_time, stop_type, stop_time);
+
+ return GST_BASE_SRC_CLASS (parent_class)->event (basesrc, event);
+ }
+
+ /* not a segment seek */
+
+ if (start_type == GST_SEEK_TYPE_NONE) {
+ GST_LOG_OBJECT (src, "start seek type is NONE, nothing to do");
+ return TRUE;
+ }
+
+ if (stop_type != GST_SEEK_TYPE_NONE) {
+ GST_WARNING_OBJECT (src, "ignoring stop seek type (expected NONE)");
+ }
+
+ if (start < 0 || start >= src->num_tracks) {
+ GST_DEBUG_OBJECT (src, "invalid track %" G_GINT64_FORMAT, start);
+ return FALSE;
+ }
+
+ GST_DEBUG_OBJECT (src, "seeking to track %" G_GINT64_FORMAT, start + 1);
+
+ src->cur_sector = src->tracks[start].start;
+ GST_DEBUG_OBJECT (src, "starting at sector %d", src->cur_sector);
+
+ if (src->cur_track != start) {
+ src->cur_track = (gint) start;
+ src->uri_track = -1;
+ src->prev_track = -1;
+
+ gst_audio_cd_src_update_duration (src);
+ } else {
+ GST_DEBUG_OBJECT (src, "is current track, just seeking back to start");
+ }
+
+ /* send fake segment seek event in TIME format to
+ * base class (so we get a newsegment etc.) */
+ event = gst_event_new_seek (rate, GST_FORMAT_TIME, flags,
+ GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE, -1);
+
+ return GST_BASE_SRC_CLASS (parent_class)->event (basesrc, event);
+}
+
+static gboolean
+gst_audio_cd_src_handle_event (GstBaseSrc * basesrc, GstEvent * event)
+{
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (basesrc);
+ gboolean ret = FALSE;
+
+ GST_LOG_OBJECT (src, "handling %s event", GST_EVENT_TYPE_NAME (event));
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_SEEK:{
+ GstSeekType start_type, stop_type;
+ GstSeekFlags flags;
+ GstFormat format;
+ gdouble rate;
+ gint64 start, stop;
+
+ if (!GST_OBJECT_FLAG_IS_SET (basesrc, GST_BASE_SRC_STARTED)) {
+ GST_DEBUG_OBJECT (src, "seek failed: device not open");
+ break;
+ }
+
+ gst_event_parse_seek (event, &rate, &format, &flags, &start_type, &start,
+ &stop_type, &stop);
+
+ if (format == sector_format) {
+ GST_DEBUG_OBJECT (src, "seek in sector format not supported");
+ break;
+ }
+
+ if (format == track_format) {
+ ret = gst_audio_cd_src_handle_track_seek (src, rate, flags,
+ start_type, start, stop_type, stop);
+ } else {
+ GST_LOG_OBJECT (src, "let base class handle seek in %s format",
+ gst_format_get_name (format));
+ event = gst_event_ref (event);
+ ret = GST_BASE_SRC_CLASS (parent_class)->event (basesrc, event);
+ }
+ break;
+ }
+ default:{
+ GST_LOG_OBJECT (src, "let base class handle event");
+ ret = GST_BASE_SRC_CLASS (parent_class)->event (basesrc, event);
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static GstURIType
+gst_audio_cd_src_uri_get_type (GType type)
+{
+ return GST_URI_SRC;
+}
+
+static gchar **
+gst_audio_cd_src_uri_get_protocols (GType type)
+{
+ static gchar *protocols[] = { (char *) "cdda", NULL };
+
+ return protocols;
+}
+
+static const gchar *
+gst_audio_cd_src_uri_get_uri (GstURIHandler * handler)
+{
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (handler);
+
+ GST_OBJECT_LOCK (src);
+
+ g_free (src->uri);
+
+ if (GST_OBJECT_FLAG_IS_SET (GST_BASE_SRC (src), GST_BASE_SRC_STARTED)) {
+ src->uri =
+ g_strdup_printf ("cdda://%s#%d", src->device,
+ (src->uri_track > 0) ? src->uri_track : 1);
+ } else {
+ src->uri = g_strdup ("cdda://1");
+ }
+
+ GST_OBJECT_UNLOCK (src);
+
+ return src->uri;
+}
+
+/* Note: gst_element_make_from_uri() might call us with just 'cdda://' as
+ * URI and expects us to return TRUE then (and this might be in any state) */
+
+/* We accept URIs of the format cdda://(device#track)|(track) */
+
+static gboolean
+gst_audio_cd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+{
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (handler);
+ gchar *protocol;
+ const gchar *location;
+ gchar *track_number;
+
+ GST_OBJECT_LOCK (src);
+
+ protocol = gst_uri_get_protocol (uri);
+ if (!protocol || g_ascii_strcasecmp (protocol, "cdda") != 0) {
+ g_free (protocol);
+ goto failed;
+ }
+ g_free (protocol);
+
+ location = uri + 7;
+ track_number = g_strrstr (location, "#");
+ src->uri_track = 0;
+ /* FIXME 0.11: ignore URI fragments that look like device paths for
+ * the benefit of rhythmbox and possibly other applications.
+ */
+ if (track_number && track_number[1] != '/') {
+ gchar *device, *nuri = g_strdup (uri);
+
+ track_number = nuri + (track_number - uri);
+ *track_number = '\0';
+ device = gst_uri_get_location (nuri);
+ gst_audio_cd_src_set_device (src, device);
+ g_free (device);
+ src->uri_track = strtol (track_number + 1, NULL, 10);
+ g_free (nuri);
+ } else {
+ if (*location == '\0')
+ src->uri_track = 1;
+ else
+ src->uri_track = strtol (location, NULL, 10);
+ }
+
+ if (src->uri_track < 1)
+ goto failed;
+
+ if (src->num_tracks > 0
+ && src->tracks != NULL && src->uri_track > src->num_tracks)
+ goto failed;
+
+ if (src->uri_track > 0 && src->tracks != NULL) {
+ GST_OBJECT_UNLOCK (src);
+
+ gst_pad_send_event (GST_BASE_SRC_PAD (src),
+ gst_event_new_seek (1.0, track_format, GST_SEEK_FLAG_FLUSH,
+ GST_SEEK_TYPE_SET, src->uri_track - 1, GST_SEEK_TYPE_NONE, -1));
+ } else {
+ /* seek will be done in start() */
+ GST_OBJECT_UNLOCK (src);
+ }
+
+ GST_LOG_OBJECT (handler, "successfully handled uri '%s'", uri);
+
+ return TRUE;
+
+failed:
+ {
+ GST_OBJECT_UNLOCK (src);
+ GST_DEBUG_OBJECT (src, "cannot handle URI '%s'", uri);
+ return FALSE;
+ }
+}
+
+static void
+gst_audio_cd_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
+{
+ GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
+
+ iface->get_type = gst_audio_cd_src_uri_get_type;
+ iface->get_uri = gst_audio_cd_src_uri_get_uri;
+ iface->set_uri = gst_audio_cd_src_uri_set_uri;
+ iface->get_protocols = gst_audio_cd_src_uri_get_protocols;
+}
+
+/**
+ * gst_audio_cd_src_add_track:
+ * @src: a #GstAudioCdSrc
+ * @track: address of #GstAudioCdSrcTrack to add
+ *
+ * CDDA sources use this function from their start vfunc to announce the
+ * available data and audio tracks to the base source class. The caller
+ * should allocate @track on the stack, the base source will do a shallow
+ * copy of the structure (and take ownership of the taglist if there is one).
+ *
+ * Returns: FALSE on error, otherwise TRUE.
+ */
+
+gboolean
+gst_audio_cd_src_add_track (GstAudioCdSrc * src, GstAudioCdSrcTrack * track)
+{
+ g_return_val_if_fail (GST_IS_AUDIO_CD_SRC (src), FALSE);
+ g_return_val_if_fail (track != NULL, FALSE);
+ g_return_val_if_fail (track->num > 0, FALSE);
+
+ GST_DEBUG_OBJECT (src, "adding track %2u (%2u) [%6u-%6u] [%5s], tags: %"
+ GST_PTR_FORMAT, src->num_tracks + 1, track->num, track->start,
+ track->end, (track->is_audio) ? "AUDIO" : "DATA ", track->tags);
+
+ if (src->num_tracks > 0) {
+ guint end_of_previous_track = src->tracks[src->num_tracks - 1].end;
+
+ if (track->start <= end_of_previous_track) {
+ GST_WARNING ("track %2u overlaps with previous tracks", track->num);
+ return FALSE;
+ }
+ }
+
+ GST_OBJECT_LOCK (src);
+
+ ++src->num_tracks;
+ src->tracks = g_renew (GstAudioCdSrcTrack, src->tracks, src->num_tracks);
+ src->tracks[src->num_tracks - 1] = *track;
+
+ GST_OBJECT_UNLOCK (src);
+
+ return TRUE;
+}
+
+static void
+gst_audio_cd_src_update_duration (GstAudioCdSrc * src)
+{
+ GstBaseSrc *basesrc;
+ gint64 dur;
+
+ basesrc = GST_BASE_SRC (src);
+
+ if (!gst_pad_query_duration (GST_BASE_SRC_PAD (src), GST_FORMAT_TIME, &dur)) {
+ dur = GST_CLOCK_TIME_NONE;
+ }
+ basesrc->segment.duration = dur;
+
+ gst_element_post_message (GST_ELEMENT (src),
+ gst_message_new_duration (GST_OBJECT (src), GST_FORMAT_TIME, -1));
+
+ GST_LOG_OBJECT (src, "duration updated to %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (dur));
+}
+
+#define CD_MSF_OFFSET 150
+
+/* the cddb hash function */
+static guint
+cddb_sum (gint n)
+{
+ guint ret;
+
+ ret = 0;
+ while (n > 0) {
+ ret += (n % 10);
+ n /= 10;
+ }
+ return ret;
+}
+
+static void
+gst_audio_cd_src_calculate_musicbrainz_discid (GstAudioCdSrc * src)
+{
+ GString *s;
+ GChecksum *sha;
+ guchar digest[20];
+ gchar *ptr;
+ gchar tmp[9];
+ gulong i;
+ guint leadout_sector;
+ gsize digest_len;
+
+ s = g_string_new (NULL);
+
+ leadout_sector = src->tracks[src->num_tracks - 1].end + 1 + CD_MSF_OFFSET;
+
+ /* generate SHA digest */
+ sha = g_checksum_new (G_CHECKSUM_SHA1);
+ g_snprintf (tmp, sizeof (tmp), "%02X", src->tracks[0].num);
+ g_string_append_printf (s, "%02X", src->tracks[0].num);
+ g_checksum_update (sha, (guchar *) tmp, 2);
+
+ g_snprintf (tmp, sizeof (tmp), "%02X", src->tracks[src->num_tracks - 1].num);
+ g_string_append_printf (s, " %02X", src->tracks[src->num_tracks - 1].num);
+ g_checksum_update (sha, (guchar *) tmp, 2);
+
+ g_snprintf (tmp, sizeof (tmp), "%08X", leadout_sector);
+ g_string_append_printf (s, " %08X", leadout_sector);
+ g_checksum_update (sha, (guchar *) tmp, 8);
+
+ for (i = 0; i < 99; i++) {
+ if (i < src->num_tracks) {
+ guint frame_offset = src->tracks[i].start + CD_MSF_OFFSET;
+
+ g_snprintf (tmp, sizeof (tmp), "%08X", frame_offset);
+ g_string_append_printf (s, " %08X", frame_offset);
+ g_checksum_update (sha, (guchar *) tmp, 8);
+ } else {
+ g_checksum_update (sha, (guchar *) "00000000", 8);
+ }
+ }
+ digest_len = 20;
+ g_checksum_get_digest (sha, (guint8 *) & digest, &digest_len);
+
+ /* re-encode to base64 */
+ ptr = g_base64_encode (digest, digest_len);
+ g_checksum_free (sha);
+ i = strlen (ptr);
+
+ g_assert (i < sizeof (src->mb_discid) + 1);
+ memcpy (src->mb_discid, ptr, i);
+ src->mb_discid[i] = '\0';
+ free (ptr);
+
+ /* Replace '/', '+' and '=' by '_', '.' and '-' as specified on
+ * http://musicbrainz.org/doc/DiscIDCalculation
+ */
+ for (ptr = src->mb_discid; *ptr != '\0'; ptr++) {
+ if (*ptr == '/')
+ *ptr = '_';
+ else if (*ptr == '+')
+ *ptr = '.';
+ else if (*ptr == '=')
+ *ptr = '-';
+ }
+
+ GST_DEBUG_OBJECT (src, "musicbrainz-discid = %s", src->mb_discid);
+ GST_DEBUG_OBJECT (src, "musicbrainz-discid-full = %s", s->str);
+
+ gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
+ GST_TAG_CDDA_MUSICBRAINZ_DISCID, src->mb_discid,
+ GST_TAG_CDDA_MUSICBRAINZ_DISCID_FULL, s->str, NULL);
+
+ g_string_free (s, TRUE);
+}
+
+static void
+lba_to_msf (guint sector, guint * p_m, guint * p_s, guint * p_f, guint * p_secs)
+{
+ guint m, s, f;
+
+ m = sector / SECTORS_PER_MINUTE;
+ sector = sector % SECTORS_PER_MINUTE;
+ s = sector / SECTORS_PER_SECOND;
+ f = sector % SECTORS_PER_SECOND;
+
+ if (p_m)
+ *p_m = m;
+ if (p_s)
+ *p_s = s;
+ if (p_f)
+ *p_f = f;
+ if (p_secs)
+ *p_secs = s + (m * 60);
+}
+
+static void
+gst_audio_cd_src_calculate_cddb_id (GstAudioCdSrc * src)
+{
+ GString *s;
+ guint first_sector = 0, last_sector = 0;
+ guint start_secs, end_secs, secs, len_secs;
+ guint total_secs, num_audio_tracks;
+ guint id, t, i;
+
+ id = 0;
+ total_secs = 0;
+ num_audio_tracks = 0;
+
+ /* FIXME: do we use offsets and duration of ALL tracks (data + audio)
+ * for the CDDB ID calculation, or only audio tracks? */
+ for (i = 0; i < src->num_tracks; ++i) {
+ if (1) { /* src->tracks[i].is_audio) { */
+ if (num_audio_tracks == 0) {
+ first_sector = src->tracks[i].start + CD_MSF_OFFSET;
+ }
+ last_sector = src->tracks[i].end + CD_MSF_OFFSET + 1;
+ ++num_audio_tracks;
+
+ lba_to_msf (src->tracks[i].start + CD_MSF_OFFSET, NULL, NULL, NULL,
+ &secs);
+
+ len_secs = (src->tracks[i].end - src->tracks[i].start + 1) / 75;
+
+ GST_DEBUG_OBJECT (src, "track %02u: lsn %6u (%02u:%02u), "
+ "length: %u seconds (%02u:%02u)",
+ num_audio_tracks, src->tracks[i].start + CD_MSF_OFFSET,
+ secs / 60, secs % 60, len_secs, len_secs / 60, len_secs % 60);
+
+ id += cddb_sum (secs);
+ total_secs += len_secs;
+ }
+ }
+
+ /* first_sector = src->tracks[0].start + CD_MSF_OFFSET; */
+ lba_to_msf (first_sector, NULL, NULL, NULL, &start_secs);
+
+ /* last_sector = src->tracks[src->num_tracks-1].end + CD_MSF_OFFSET; */
+ lba_to_msf (last_sector, NULL, NULL, NULL, &end_secs);
+
+ GST_DEBUG_OBJECT (src, "first_sector = %u = %u secs (%02u:%02u)",
+ first_sector, start_secs, start_secs / 60, start_secs % 60);
+ GST_DEBUG_OBJECT (src, "last_sector = %u = %u secs (%02u:%02u)",
+ last_sector, end_secs, end_secs / 60, end_secs % 60);
+
+ t = end_secs - start_secs;
+
+ GST_DEBUG_OBJECT (src, "total length = %u secs (%02u:%02u), added title "
+ "lengths = %u seconds (%02u:%02u)", t, t / 60, t % 60, total_secs,
+ total_secs / 60, total_secs % 60);
+
+ src->discid = ((id % 0xff) << 24 | t << 8 | num_audio_tracks);
+
+ s = g_string_new (NULL);
+ g_string_append_printf (s, "%08x", src->discid);
+
+ gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
+ GST_TAG_CDDA_CDDB_DISCID, s->str, NULL);
+
+ g_string_append_printf (s, " %u", src->num_tracks);
+ for (i = 0; i < src->num_tracks; ++i) {
+ g_string_append_printf (s, " %u", src->tracks[i].start + CD_MSF_OFFSET);
+ }
+ g_string_append_printf (s, " %u", t);
+
+ gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
+ GST_TAG_CDDA_CDDB_DISCID_FULL, s->str, NULL);
+
+ GST_DEBUG_OBJECT (src, "cddb discid = %s", s->str);
+
+ g_string_free (s, TRUE);
+}
+
+static void
+gst_audio_cd_src_add_tags (GstAudioCdSrc * src)
+{
+ gint i;
+
+ /* fill in details for each track */
+ for (i = 0; i < src->num_tracks; ++i) {
+ gint64 duration;
+ guint num_sectors;
+
+ if (src->tracks[i].tags == NULL)
+ src->tracks[i].tags = gst_tag_list_new_empty ();
+
+ num_sectors = src->tracks[i].end - src->tracks[i].start + 1;
+ gst_audio_cd_src_convert (src, sector_format, num_sectors,
+ GST_FORMAT_TIME, &duration);
+
+ gst_tag_list_add (src->tracks[i].tags,
+ GST_TAG_MERGE_REPLACE,
+ GST_TAG_TRACK_NUMBER, i + 1,
+ GST_TAG_TRACK_COUNT, src->num_tracks, GST_TAG_DURATION, duration, NULL);
+ }
+
+ /* now fill in per-album tags and include each track's tags
+ * in the album tags, so that interested parties can retrieve
+ * the relevant details for each track in one go */
+
+ /* /////////////////////////////// FIXME should we rather insert num_tracks
+ * tags by the name of 'track-tags' and have the caller use
+ * gst_tag_list_get_value_index() rather than use tag names incl.
+ * the track number ?? *////////////////////////////////////////
+
+ gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
+ GST_TAG_TRACK_COUNT, src->num_tracks, NULL);
+#if 0
+ for (i = 0; i < src->num_tracks; ++i) {
+ gst_tag_list_add (src->tags, GST_TAG_MERGE_APPEND,
+ GST_TAG_CDDA_TRACK_TAGS, src->tracks[i].tags, NULL);
+ }
+#endif
+
+ GST_DEBUG ("src->tags = %" GST_PTR_FORMAT, src->tags);
+}
+
+static void
+gst_audio_cd_src_add_index_associations (GstAudioCdSrc * src)
+{
+ gint i;
+
+ for (i = 0; i < src->num_tracks; i++) {
+ gint64 sector;
+
+ sector = src->tracks[i].start;
+ gst_index_add_association (src->index, src->index_id, GST_ASSOCIATION_FLAG_KEY_UNIT, track_format, i, /* here we count from 0 */
+ 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);
+ }
+}
+
+static void
+gst_audio_cd_src_set_index (GstElement * element, GstIndex * index)
+{
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (element);
+ GstIndex *old;
+
+ GST_OBJECT_LOCK (element);
+ old = src->index;
+ if (old == index) {
+ GST_OBJECT_UNLOCK (element);
+ return;
+ }
+ if (index)
+ gst_object_ref (index);
+ src->index = index;
+ GST_OBJECT_UNLOCK (element);
+ if (old)
+ gst_object_unref (old);
+
+ if (index) {
+ gst_index_get_writer_id (index, GST_OBJECT (src), &src->index_id);
+ gst_index_add_format (index, src->index_id, track_format);
+ gst_index_add_format (index, src->index_id, sector_format);
+ }
+}
+
+
+static GstIndex *
+gst_audio_cd_src_get_index (GstElement * element)
+{
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (element);
+ GstIndex *index;
+
+ GST_OBJECT_LOCK (element);
+ if ((index = src->index))
+ gst_object_ref (index);
+ GST_OBJECT_UNLOCK (element);
+
+ return index;
+}
+
+static gint
+gst_audio_cd_src_track_sort_func (gconstpointer a, gconstpointer b,
+ gpointer foo)
+{
+ GstAudioCdSrcTrack *track_a = ((GstAudioCdSrcTrack *) a);
+ GstAudioCdSrcTrack *track_b = ((GstAudioCdSrcTrack *) b);
+
+ /* sort data tracks to the end, and audio tracks by track number */
+ if (track_a->is_audio == track_b->is_audio)
+ return (gint) track_a->num - (gint) track_b->num;
+
+ if (track_a->is_audio) {
+ return -1;
+ } else {
+ return 1;
+ }
+}
+
+static gboolean
+gst_audio_cd_src_start (GstBaseSrc * basesrc)
+{
+ GstAudioCdSrcClass *klass = GST_AUDIO_CD_SRC_GET_CLASS (basesrc);
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (basesrc);
+ gboolean ret;
+ gchar *device = NULL;
+
+ src->discid = 0;
+ src->mb_discid[0] = '\0';
+
+ g_assert (klass->open != NULL);
+
+ if (src->device != NULL) {
+ device = g_strdup (src->device);
+ } else if (klass->get_default_device != NULL) {
+ device = klass->get_default_device (src);
+ }
+
+ if (device == NULL)
+ device = g_strdup (DEFAULT_DEVICE);
+
+ GST_LOG_OBJECT (basesrc, "opening device %s", device);
+
+ src->tags = gst_tag_list_new_empty ();
+
+ ret = klass->open (src, device);
+ g_free (device);
+ device = NULL;
+
+ if (!ret) {
+ GST_DEBUG_OBJECT (basesrc, "failed to open device");
+ /* subclass (should have) posted an error message with the details */
+ gst_audio_cd_src_stop (basesrc);
+ return FALSE;
+ }
+
+ if (src->num_tracks == 0 || src->tracks == NULL) {
+ GST_DEBUG_OBJECT (src, "no tracks");
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+ (_("This CD has no audio tracks")), (NULL));
+ gst_audio_cd_src_stop (basesrc);
+ return FALSE;
+ }
+
+ /* need to calculate disc IDs before we ditch the data tracks */
+ gst_audio_cd_src_calculate_cddb_id (src);
+ gst_audio_cd_src_calculate_musicbrainz_discid (src);
+
+#if 0
+ /* adjust sector offsets if necessary */
+ if (src->toc_bias) {
+ src->toc_offset -= src->tracks[0].start;
+ }
+ for (i = 0; i < src->num_tracks; ++i) {
+ src->tracks[i].start += src->toc_offset;
+ src->tracks[i].end += src->toc_offset;
+ }
+#endif
+
+ /* now that we calculated the various disc IDs,
+ * sort the data tracks to end and ignore them */
+ src->num_all_tracks = src->num_tracks;
+
+ g_qsort_with_data (src->tracks, src->num_tracks,
+ sizeof (GstAudioCdSrcTrack), gst_audio_cd_src_track_sort_func, NULL);
+
+ while (src->num_tracks > 0 && !src->tracks[src->num_tracks - 1].is_audio)
+ --src->num_tracks;
+
+ if (src->num_tracks == 0) {
+ GST_DEBUG_OBJECT (src, "no audio tracks");
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+ (_("This CD has no audio tracks")), (NULL));
+ gst_audio_cd_src_stop (basesrc);
+ return FALSE;
+ }
+
+ gst_audio_cd_src_add_tags (src);
+
+ if (src->index && GST_INDEX_IS_WRITABLE (src->index))
+ gst_audio_cd_src_add_index_associations (src);
+
+ src->cur_track = 0;
+ src->prev_track = -1;
+
+ if (src->uri_track > 0 && src->uri_track <= src->num_tracks) {
+ GST_LOG_OBJECT (src, "seek to track %d", src->uri_track);
+ src->cur_track = src->uri_track - 1;
+ src->uri_track = -1;
+ src->mode = GST_AUDIO_CD_SRC_MODE_NORMAL;
+ }
+
+ src->cur_sector = src->tracks[src->cur_track].start;
+ GST_LOG_OBJECT (src, "starting at sector %d", src->cur_sector);
+
+ gst_audio_cd_src_update_duration (src);
+
+ return TRUE;
+}
+
+static void
+gst_audio_cd_src_clear_tracks (GstAudioCdSrc * src)
+{
+ if (src->tracks != NULL) {
+ gint i;
+
+ for (i = 0; i < src->num_all_tracks; ++i) {
+ if (src->tracks[i].tags)
+ gst_tag_list_free (src->tracks[i].tags);
+ }
+
+ g_free (src->tracks);
+ src->tracks = NULL;
+ }
+ src->num_tracks = 0;
+ src->num_all_tracks = 0;
+}
+
+static gboolean
+gst_audio_cd_src_stop (GstBaseSrc * basesrc)
+{
+ GstAudioCdSrcClass *klass = GST_AUDIO_CD_SRC_GET_CLASS (basesrc);
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (basesrc);
+
+ g_assert (klass->close != NULL);
+
+ klass->close (src);
+
+ gst_audio_cd_src_clear_tracks (src);
+
+ if (src->tags) {
+ gst_tag_list_free (src->tags);
+ src->tags = NULL;
+ }
+
+ src->prev_track = -1;
+ src->cur_track = -1;
+
+ return TRUE;
+}
+
+
+static GstFlowReturn
+gst_audio_cd_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
+{
+ GstAudioCdSrcClass *klass = GST_AUDIO_CD_SRC_GET_CLASS (pushsrc);
+ GstAudioCdSrc *src = GST_AUDIO_CD_SRC (pushsrc);
+ GstBuffer *buf;
+ gboolean eos;
+
+ GstClockTime position = GST_CLOCK_TIME_NONE;
+ GstClockTime duration = GST_CLOCK_TIME_NONE;
+ gint64 qry_position;
+
+ g_assert (klass->read_sector != NULL);
+
+ switch (src->mode) {
+ case GST_AUDIO_CD_SRC_MODE_NORMAL:
+ eos = (src->cur_sector > src->tracks[src->cur_track].end);
+ break;
+ case GST_AUDIO_CD_SRC_MODE_CONTINUOUS:
+ eos = (src->cur_sector > src->tracks[src->num_tracks - 1].end);
+ src->cur_track = gst_audio_cd_src_get_track_from_sector (src,
+ src->cur_sector);
+ break;
+ default:
+ g_return_val_if_reached (GST_FLOW_ERROR);
+ }
+
+ if (eos) {
+ src->prev_track = -1;
+ GST_DEBUG_OBJECT (src, "EOS at sector %d, cur_track=%d, mode=%d",
+ src->cur_sector, src->cur_track, src->mode);
+ /* base class will send EOS for us */
+ return GST_FLOW_EOS;
+ }
+
+ if (src->prev_track != src->cur_track) {
+ GstTagList *tags;
+
+ tags = gst_tag_list_merge (src->tags, src->tracks[src->cur_track].tags,
+ GST_TAG_MERGE_REPLACE);
+ GST_LOG_OBJECT (src, "announcing tags: %" GST_PTR_FORMAT, tags);
+ gst_pad_push_event (GST_BASE_SRC_PAD (src), gst_event_new_tag (tags));
+ src->prev_track = src->cur_track;
+
+ gst_audio_cd_src_update_duration (src);
+
+ g_object_notify (G_OBJECT (src), "track");
+ }
+
+ GST_LOG_OBJECT (src, "asking for sector %u", src->cur_sector);
+
+ buf = klass->read_sector (src, src->cur_sector);
+
+ if (buf == NULL) {
+ GST_WARNING_OBJECT (src, "failed to read sector %u", src->cur_sector);
+ return GST_FLOW_ERROR;
+ }
+
+ if (gst_pad_query_position (GST_BASE_SRC_PAD (src), GST_FORMAT_TIME,
+ &qry_position)) {
+ gint64 next_ts = 0;
+
+ position = (GstClockTime) qry_position;
+
+ ++src->cur_sector;
+ if (gst_pad_query_position (GST_BASE_SRC_PAD (src), GST_FORMAT_TIME,
+ &next_ts)) {
+ duration = (GstClockTime) (next_ts - qry_position);
+ }
+ --src->cur_sector;
+ }
+
+ /* fallback duration: 4 bytes per sample, 44100 samples per second */
+ if (duration == GST_CLOCK_TIME_NONE) {
+ duration = gst_util_uint64_scale_int (gst_buffer_get_size (buf) >> 2,
+ GST_SECOND, 44100);
+ }
+
+ GST_BUFFER_TIMESTAMP (buf) = position;
+ GST_BUFFER_DURATION (buf) = duration;
+
+ GST_LOG_OBJECT (src, "pushing sector %d with timestamp %" GST_TIME_FORMAT,
+ src->cur_sector, GST_TIME_ARGS (position));
+
+ ++src->cur_sector;
+
+ *buffer = buf;
+
+ return GST_FLOW_OK;
+}
--- /dev/null
+/* GStreamer Audio CD Source Base Class
+ * Copyright (C) 2005 Tim-Philipp Müller <tim centricular net>
+ *
+ * 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_AUDIO_CD_SRC_H__
+#define __GST_AUDIO_CD_SRC_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstpushsrc.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_CD_SRC (gst_audio_cd_src_get_type())
+#define GST_AUDIO_CD_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AUDIO_CD_SRC, GstAudioCdSrc))
+#define GST_AUDIO_CD_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AUDIO_CD_SRC, GstAudioCdSrcClass))
+#define GST_IS_AUDIO_CD_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AUDIO_CD_SRC))
+#define GST_IS_AUDIO_CD_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AUDIO_CD_SRC))
+#define GST_AUDIO_CD_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIO_CD_SRC, GstAudioCdSrcClass))
+
+typedef struct _GstAudioCdSrc GstAudioCdSrc;
+typedef struct _GstAudioCdSrcClass GstAudioCdSrcClass;
+typedef struct _GstAudioCdSrcTrack GstAudioCdSrcTrack;
+
+/**
+ * GstAudioCdSrcMode:
+ * @GST_AUDIO_CD_SRC_MODE_NORMAL : each single track is a stream
+ * @GST_AUDIO_CD_SRC_MODE_CONTINUOUS : the entire disc is a single stream
+ *
+ * Mode in which the CD audio source operates. Influences timestamping,
+ * EOS handling and seeking.
+ */
+typedef enum {
+ GST_AUDIO_CD_SRC_MODE_NORMAL, /* stream = one track */
+ GST_AUDIO_CD_SRC_MODE_CONTINUOUS /* stream = whole disc */
+} GstAudioCdSrcMode;
+
+#define GST_TYPE_AUDIO_CD_SRC_MODE (gst_audio_cd_src_mode_get_type ())
+
+/**
+ * GstAudioCdSrcTrack:
+ * @is_audio: Whether this is an audio track
+ * @num: Track number in TOC (usually starts from 1, but not always)
+ * @start: The first sector of this track (LBA)
+ * @end: The last sector of this track (LBA)
+ * @tags: Track-specific tags (e.g. from cd-text information), or NULL
+ *
+ * CD track abstraction to communicate TOC entries to the base class.
+ */
+struct _GstAudioCdSrcTrack {
+ gboolean is_audio; /* TRUE if this is an audio track */
+ guint num; /* real track number (usually starts from 1) */
+ guint start; /* first sector of track (LBA, not LSN!) */
+ guint end; /* last sector of track (LBA, not LSN!) */
+ GstTagList *tags; /* NULL or tags for track (e.g. from cd-text) */
+
+ /*< private >*/
+ guint _gst_reserved1[GST_PADDING/2];
+ gpointer _gst_reserved2[GST_PADDING/2];
+};
+
+struct _GstAudioCdSrc {
+ GstPushSrc pushsrc;
+
+ /*< protected >*/ /* for use by sub-classes only */
+ GstTagList *tags; /* tags that apply to all tracks */
+
+ /*< private >*/
+ GstAudioCdSrcMode mode;
+
+ gchar *device;
+
+ guint num_tracks;
+ guint num_all_tracks;
+ GstAudioCdSrcTrack *tracks;
+
+ gint cur_track; /* current track (starting from 0) */
+ gint prev_track; /* current track last time */
+ gint cur_sector; /* current sector */
+ gint seek_sector; /* -1 or sector to seek to */
+
+ gint uri_track;
+ gchar *uri;
+
+ guint32 discid; /* cddb disc id (for unit test) */
+ gchar mb_discid[32]; /* musicbrainz discid */
+
+ GstIndex *index;
+ gint index_id;
+
+ gint toc_offset;
+ gboolean toc_bias;
+
+ /*< private >*/
+ guint _gst_reserved1[GST_PADDING/2];
+ gpointer _gst_reserved2[GST_PADDING/2];
+};
+
+/**
+ * GstAudioCdSrcClass:
+ * @pushsrc_class: the parent class
+ * @open: opening the device
+ * @close: closing the device
+ * @read_sector: reading a sector
+ * @get_default_device: getting the default device
+ * @probe_devices: probing possible devices
+ *
+ * Audio CD source base class.
+ */
+struct _GstAudioCdSrcClass {
+ GstPushSrcClass pushsrc_class;
+
+ /* open/close the CD device */
+ gboolean (*open) (GstAudioCdSrc *src, const gchar *device);
+ void (*close) (GstAudioCdSrc *src);
+
+ /* read one sector (LBA) */
+ GstBuffer * (*read_sector) (GstAudioCdSrc *src, gint sector);
+
+ /* return default device or NULL (optional) */
+ gchar * (*get_default_device) (GstAudioCdSrc *src);
+
+ /* return NULL-terminated string array of CD devices, or NULL (optional) */
+ /* FIXME 0.11: reconsider for new probing/device discovery API, remove if in doubt */
+ gchar ** (*probe_devices) (GstAudioCdSrc *src);
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+GType gst_audio_cd_src_get_type (void);
+GType gst_audio_cd_src_mode_get_type (void);
+
+gboolean gst_audio_cd_src_add_track (GstAudioCdSrc * src,
+ GstAudioCdSrcTrack * track);
+
+#if 0
+/*
+ * GST_TAG_CDDA_TRACK_TAGS:
+ *
+ * Tag details for all available tracks
+ * FiXME: find out which type we want for this!
+ */
+#define GST_TAG_CDDA_TRACK_TAGS "track-tags"
+#endif
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_CD_SRC_H__ */
+
+++ /dev/null
-lib_LTLIBRARIES = libgstcdda-@GST_MAJORMINOR@.la
-
-libgstcdda_@GST_MAJORMINOR@_la_SOURCES = \
- gstcddabasesrc.c
-
-libgstcdda_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/cdda
-libgstcdda_@GST_MAJORMINOR@include_HEADERS = \
- gstcddabasesrc.h
-
-libgstcdda_@GST_MAJORMINOR@_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) \
- $(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la
-libgstcdda_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
-libgstcdda_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
-
-# Disabled until this is fixed:
-# http://bugzilla.gnome.org/show_bug.cgi?id=594209
-if FALSE
-if HAVE_INTROSPECTION
-BUILT_GIRSOURCES = GstCdda-@GST_MAJORMINOR@.gir
-
-gir_headers=$(patsubst %,$(srcdir)/%, $(libgstcdda_@GST_MAJORMINOR@include_HEADERS))
-gir_sources=$(patsubst %,$(srcdir)/%, $(libgstcdda_@GST_MAJORMINOR@_la_SOURCES))
-gir_cincludes=$(patsubst %,--c-include='gst/cdda/%',$(libgstcdda_@GST_MAJORMINOR@include_HEADERS))
-
-GstCdda-@GST_MAJORMINOR@.gir: $(INTROSPECTION_SCANNER) libgstcdda-@GST_MAJORMINOR@.la
- $(AM_V_GEN)PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" \
- GST_PLUGIN_SYSTEM_PATH="" GST_PLUGIN_PATH="" GST_REGISTRY_UPDATE=no \
- $(INTROSPECTION_SCANNER) -v --namespace GstCdda \
- --nsversion=@GST_MAJORMINOR@ \
- --strip-prefix=Gst \
- $(gir_cincludes) \
- -DGST_USE_UNSTABLE_API \
- --add-include-path=$(builddir)/../tag \
- --add-include-path=`$(PKG_CONFIG) --variable=girdir gstreamer-@GST_MAJORMINOR@` \
- --add-include-path=`$(PKG_CONFIG) --variable=girdir gstreamer-base-@GST_MAJORMINOR@` \
- --library=libgstcdda-@GST_MAJORMINOR@.la \
- --include=Gst-@GST_MAJORMINOR@ \
- --include=GstBase-@GST_MAJORMINOR@ \
- --include=GstTag-@GST_MAJORMINOR@ \
- --libtool="$(top_builddir)/libtool" \
- --pkg gstreamer-@GST_MAJORMINOR@ \
- --pkg gstreamer-base-@GST_MAJORMINOR@ \
- --pkg gstreamer-tag-@GST_MAJORMINOR@ \
- --pkg-export gstreamer-cdda-@GST_MAJORMINOR@ \
- --add-init-section="gst_init(NULL,NULL);" \
- --output $@ \
- $(gir_headers) \
- $(gir_sources)
-
-# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to
-# install anything - we need to install inside our prefix.
-girdir = $(datadir)/gir-1.0
-gir_DATA = $(BUILT_GIRSOURCES)
-
-typelibsdir = $(libdir)/girepository-1.0/
-
-typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
-
-%.typelib: %.gir $(INTROSPECTION_COMPILER)
- $(AM_V_GEN)PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" \
- $(INTROSPECTION_COMPILER) \
- --includedir=$(srcdir) \
- --includedir=$(builddir) \
- --includedir=$(builddir)/../tag \
- --includedir=`$(PKG_CONFIG) --variable=girdir gstreamer-@GST_MAJORMINOR@` \
- --includedir=`$(PKG_CONFIG) --variable=girdir gstreamer-base-@GST_MAJORMINOR@` \
- $(INTROSPECTION_COMPILER_OPTS) $< -o $(@F)
-
-CLEANFILES = $(BUILT_GIRSOURCES) $(typelibs_DATA)
-endif
-endif
+++ /dev/null
-/* GStreamer
- * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
- * Copyright (C) 2005 Tim-Philipp Müller <tim centricular net>
- *
- * 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.
- */
-
-/* TODO:
- *
- * - in ::start(), we want to post a tags message with an array or a list
- * of tagslists of all tracks, so that applications know at least the
- * number of tracks and all track durations immediately without having
- * to do any querying. We have to decide what type and name to use for
- * this array of track taglists.
- *
- * - FIX cddb discid calculation algorithm for mixed mode CDs - do we use
- * offsets and duration of ALL tracks (data + audio) for the CDDB ID
- * calculation, or only audio tracks?
- *
- * - Do we really need properties for the TOC bias/offset stuff? Wouldn't
- * environment variables make much more sense? Do we need this at all
- * (does it only affect ancient hardware?)
- */
-
-/**
- * SECTION:gstcddabasesrc
- * @short_description: Base class for CD digital audio (CDDA) sources
- *
- * <refsect2>
- * <para>
- * Provides a base class for CDDA sources, which handles things like seeking,
- * querying, discid calculation, tags, and buffer timestamping.
- * </para>
- * <title>Using GstCddaBaseSrc-based elements in applications</title>
- * <para>
- * GstCddaBaseSrc registers two #GstFormat<!-- -->s of its own, namely
- * the "track" format and the "sector" format. Applications will usually
- * only find the "track" format interesting. You can retrieve that #GstFormat
- * for use in seek events or queries with gst_format_get_by_nick("track").
- * </para>
- * <para>
- * In order to query the number of tracks, for example, an application would
- * set the CDDA source element to READY or PAUSED state and then query the
- * the number of tracks via gst_element_query_duration() using the track
- * format acquired above. Applications can query the currently playing track
- * in the same way.
- * </para>
- * <para>
- * Alternatively, applications may retrieve the currently playing track and
- * the total number of tracks from the taglist that will posted on the bus
- * whenever the CD is opened or the currently playing track changes. The
- * taglist will contain GST_TAG_TRACK_NUMBER and GST_TAG_TRACK_COUNT tags.
- * </para>
- * <para>
- * Applications playing back CD audio using playbin and cdda://n URIs should
- * issue a seek command in track format to change between tracks, rather than
- * setting a new cdda://n+1 URI on playbin (as setting a new URI on playbin
- * involves closing and re-opening the CD device, which is much much slower).
- * </para>
- * <title>Tags and meta-information</title>
- * <para>
- * CDDA sources will automatically emit a number of tags, details about which
- * can be found in the libgsttag documentation. Those tags are:
- * #GST_TAG_CDDA_CDDB_DISCID, #GST_TAG_CDDA_CDDB_DISCID_FULL,
- * #GST_TAG_CDDA_MUSICBRAINZ_DISCID, #GST_TAG_CDDA_MUSICBRAINZ_DISCID_FULL,
- * among others.
- * </para>
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <stdlib.h> /* for strtol */
-
-#include <gst/audio/audio.h>
-#include "gstcddabasesrc.h"
-#include "gst/gst-i18n-plugin.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_cdda_base_src_debug);
-#define GST_CAT_DEFAULT gst_cdda_base_src_debug
-
-#define DEFAULT_DEVICE "/dev/cdrom"
-
-#define CD_FRAMESIZE_RAW (2352)
-
-#define SECTORS_PER_SECOND (75)
-#define SECTORS_PER_MINUTE (75*60)
-#define SAMPLES_PER_SECTOR (CD_FRAMESIZE_RAW >> 2)
-#define TIME_INTERVAL_FROM_SECTORS(sectors) ((SAMPLES_PER_SECTOR * sectors * GST_SECOND) / 44100)
-#define SECTORS_FROM_TIME_INTERVAL(dtime) (dtime * 44100 / (SAMPLES_PER_SECTOR * GST_SECOND))
-
-enum
-{
- ARG_0,
- ARG_MODE,
- ARG_DEVICE,
- ARG_TRACK,
- ARG_TOC_OFFSET,
- ARG_TOC_BIAS
-};
-
-static void gst_cdda_base_src_uri_handler_init (gpointer g_iface,
- gpointer iface_data);
-static void gst_cdda_base_src_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-static void gst_cdda_base_src_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_cdda_base_src_finalize (GObject * obj);
-static gboolean gst_cdda_base_src_query (GstBaseSrc * src, GstQuery * query);
-static gboolean gst_cdda_base_src_handle_event (GstBaseSrc * basesrc,
- GstEvent * event);
-static gboolean gst_cdda_base_src_do_seek (GstBaseSrc * basesrc,
- GstSegment * segment);
-static gboolean gst_cdda_base_src_start (GstBaseSrc * basesrc);
-static gboolean gst_cdda_base_src_stop (GstBaseSrc * basesrc);
-static GstFlowReturn gst_cdda_base_src_create (GstPushSrc * pushsrc,
- GstBuffer ** buf);
-static gboolean gst_cdda_base_src_is_seekable (GstBaseSrc * basesrc);
-static void gst_cdda_base_src_update_duration (GstCddaBaseSrc * src);
-static void gst_cdda_base_src_set_index (GstElement * src, GstIndex * index);
-static GstIndex *gst_cdda_base_src_get_index (GstElement * src);
-
-#define gst_cdda_base_src_parent_class parent_class
-G_DEFINE_TYPE_WITH_CODE (GstCddaBaseSrc, gst_cdda_base_src, GST_TYPE_PUSH_SRC,
- G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
- gst_cdda_base_src_uri_handler_init));
-
-#define SRC_CAPS \
- "audio/x-raw, " \
- "format = (string) " GST_AUDIO_NE(S16) ", " \
- "rate = (int) 44100, " \
- "channels = (int) 2" \
-
-static GstStaticPadTemplate gst_cdda_base_src_src_template =
-GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (SRC_CAPS)
- );
-
-/* our two formats */
-static GstFormat track_format;
-static GstFormat sector_format;
-
-GType
-gst_cdda_base_src_mode_get_type (void)
-{
- static GType mode_type; /* 0 */
- static const GEnumValue modes[] = {
- {GST_CDDA_BASE_SRC_MODE_NORMAL, "Stream consists of a single track",
- "normal"},
- {GST_CDDA_BASE_SRC_MODE_CONTINUOUS, "Stream consists of the whole disc",
- "continuous"},
- {0, NULL, NULL}
- };
-
- if (mode_type == 0)
- mode_type = g_enum_register_static ("GstCddaBaseSrcMode", modes);
-
- return mode_type;
-}
-
-static void
-gst_cdda_base_src_class_init (GstCddaBaseSrcClass * klass)
-{
- GstElementClass *element_class;
- GstPushSrcClass *pushsrc_class;
- GstBaseSrcClass *basesrc_class;
- GObjectClass *gobject_class;
-
- gobject_class = (GObjectClass *) klass;
- element_class = (GstElementClass *) klass;
- basesrc_class = (GstBaseSrcClass *) klass;
- pushsrc_class = (GstPushSrcClass *) klass;
-
- GST_DEBUG_CATEGORY_INIT (gst_cdda_base_src_debug, "cddabasesrc", 0,
- "CDDA Base Source");
-
- /* our very own formats */
- track_format = gst_format_register ("track", "CD track");
- sector_format = gst_format_register ("sector", "CD sector");
-
- /* register CDDA tags */
- gst_tag_register_musicbrainz_tags ();
-
-#if 0
- ///// FIXME: what type to use here? ///////
- gst_tag_register (GST_TAG_CDDA_TRACK_TAGS, GST_TAG_FLAG_META, GST_TYPE_TAG_LIST, "track-tags", "CDDA taglist for one track", gst_tag_merge_use_first); ///////////// FIXME: right function??? ///////
-#endif
-
- gobject_class->set_property = gst_cdda_base_src_set_property;
- gobject_class->get_property = gst_cdda_base_src_get_property;
- gobject_class->finalize = gst_cdda_base_src_finalize;
-
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEVICE,
- g_param_spec_string ("device", "Device", "CD device location",
- NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE,
- g_param_spec_enum ("mode", "Mode", "Mode", GST_TYPE_CDDA_BASE_SRC_MODE,
- GST_CDDA_BASE_SRC_MODE_NORMAL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TRACK,
- g_param_spec_uint ("track", "Track", "Track", 1, 99, 1,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-#if 0
- /* Do we really need this toc adjustment stuff as properties? does the user
- * have a chance to set it in practice, e.g. when using sound-juicer, rb,
- * totem, whatever? Shouldn't we rather use environment variables
- * for this? (tpm) */
-
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOC_OFFSET,
- g_param_spec_int ("toc-offset", "Table of contents offset",
- "Add <n> sectors to the values reported", G_MININT, G_MAXINT, 0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOC_BIAS,
- g_param_spec_boolean ("toc-bias", "Table of contents 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", FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-#endif
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_cdda_base_src_src_template));
-
- element_class->set_index = GST_DEBUG_FUNCPTR (gst_cdda_base_src_set_index);
- element_class->get_index = GST_DEBUG_FUNCPTR (gst_cdda_base_src_get_index);
-
- basesrc_class->start = GST_DEBUG_FUNCPTR (gst_cdda_base_src_start);
- basesrc_class->stop = GST_DEBUG_FUNCPTR (gst_cdda_base_src_stop);
- basesrc_class->query = GST_DEBUG_FUNCPTR (gst_cdda_base_src_query);
- basesrc_class->event = GST_DEBUG_FUNCPTR (gst_cdda_base_src_handle_event);
- basesrc_class->do_seek = GST_DEBUG_FUNCPTR (gst_cdda_base_src_do_seek);
- basesrc_class->is_seekable =
- GST_DEBUG_FUNCPTR (gst_cdda_base_src_is_seekable);
-
- pushsrc_class->create = GST_DEBUG_FUNCPTR (gst_cdda_base_src_create);
-}
-
-static void
-gst_cdda_base_src_init (GstCddaBaseSrc * src)
-{
- /* we're not live and we operate in time */
- gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
- gst_base_src_set_live (GST_BASE_SRC (src), FALSE);
-
- src->device = NULL;
- src->mode = GST_CDDA_BASE_SRC_MODE_NORMAL;
- src->uri_track = -1;
-}
-
-static void
-gst_cdda_base_src_finalize (GObject * obj)
-{
- GstCddaBaseSrc *cddasrc = GST_CDDA_BASE_SRC (obj);
-
- g_free (cddasrc->uri);
- g_free (cddasrc->device);
-
- if (cddasrc->index)
- gst_object_unref (cddasrc->index);
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-static void
-gst_cdda_base_src_set_device (GstCddaBaseSrc * src, const gchar * device)
-{
- if (src->device)
- g_free (src->device);
- src->device = NULL;
-
- if (!device)
- return;
-
- /* skip multiple slashes */
- while (*device == '/' && *(device + 1) == '/')
- device++;
-
-#ifdef __sun
- /*
- * On Solaris, /dev/rdsk is used for accessing the CD device, but some
- * applications pass in /dev/dsk, so correct.
- */
- if (strncmp (device, "/dev/dsk", 8) == 0) {
- gchar *rdsk_value;
- rdsk_value = g_strdup_printf ("/dev/rdsk%s", device + 8);
- src->device = g_strdup (rdsk_value);
- g_free (rdsk_value);
- } else {
-#endif
- src->device = g_strdup (device);
-#ifdef __sun
- }
-#endif
-}
-
-static void
-gst_cdda_base_src_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (object);
-
- GST_OBJECT_LOCK (src);
-
- switch (prop_id) {
- case ARG_MODE:{
- src->mode = g_value_get_enum (value);
- break;
- }
- case ARG_DEVICE:{
- const gchar *dev = g_value_get_string (value);
-
- gst_cdda_base_src_set_device (src, dev);
- break;
- }
- case ARG_TRACK:{
- guint track = g_value_get_uint (value);
-
- if (src->num_tracks > 0 && track > src->num_tracks) {
- g_warning ("Invalid track %u", track);
- } else if (track > 0 && src->tracks != NULL) {
- src->cur_sector = src->tracks[track - 1].start;
- src->uri_track = track;
- } else {
- src->uri_track = track; /* seek will be done in start() */
- }
- break;
- }
- case ARG_TOC_OFFSET:{
- src->toc_offset = g_value_get_int (value);
- break;
- }
- case ARG_TOC_BIAS:{
- src->toc_bias = g_value_get_boolean (value);
- break;
- }
- default:{
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
- }
-
- GST_OBJECT_UNLOCK (src);
-}
-
-static void
-gst_cdda_base_src_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstCddaBaseSrcClass *klass = GST_CDDA_BASE_SRC_GET_CLASS (object);
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (object);
-
- GST_OBJECT_LOCK (src);
-
- switch (prop_id) {
- case ARG_MODE:
- g_value_set_enum (value, src->mode);
- break;
- case ARG_DEVICE:{
- if (src->device == NULL && klass->get_default_device != NULL) {
- gchar *d = klass->get_default_device (src);
-
- if (d != NULL) {
- g_value_set_string (value, DEFAULT_DEVICE);
- g_free (d);
- break;
- }
- }
- if (src->device == NULL)
- g_value_set_string (value, DEFAULT_DEVICE);
- else
- g_value_set_string (value, src->device);
- break;
- }
- case ARG_TRACK:{
- if (src->num_tracks <= 0 && src->uri_track > 0) {
- g_value_set_uint (value, src->uri_track);
- } else {
- g_value_set_uint (value, src->cur_track + 1);
- }
- break;
- }
- case ARG_TOC_OFFSET:
- g_value_set_int (value, src->toc_offset);
- break;
- case ARG_TOC_BIAS:
- g_value_set_boolean (value, src->toc_bias);
- break;
- default:{
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
- }
-
- GST_OBJECT_UNLOCK (src);
-}
-
-static gint
-gst_cdda_base_src_get_track_from_sector (GstCddaBaseSrc * src, gint sector)
-{
- gint i;
-
- for (i = 0; i < src->num_tracks; ++i) {
- if (sector >= src->tracks[i].start && sector <= src->tracks[i].end)
- return i;
- }
- return -1;
-}
-
-static gboolean
-gst_cdda_base_src_convert (GstCddaBaseSrc * src, GstFormat src_format,
- gint64 src_val, GstFormat dest_format, gint64 * dest_val)
-{
- gboolean started;
-
- GST_LOG_OBJECT (src, "converting value %" G_GINT64_FORMAT " from %s into %s",
- src_val, gst_format_get_name (src_format),
- gst_format_get_name (dest_format));
-
- if (src_format == dest_format) {
- *dest_val = src_val;
- return TRUE;
- }
-
- started = GST_OBJECT_FLAG_IS_SET (GST_BASE_SRC (src), GST_BASE_SRC_STARTED);
-
- if (src_format == track_format) {
- if (!started)
- goto not_started;
- if (src_val < 0 || src_val >= src->num_tracks) {
- GST_DEBUG_OBJECT (src, "track number %d out of bounds", (gint) src_val);
- goto wrong_value;
- }
- src_format = GST_FORMAT_DEFAULT;
- src_val = src->tracks[src_val].start * SAMPLES_PER_SECTOR;
- } else if (src_format == sector_format) {
- src_format = GST_FORMAT_DEFAULT;
- src_val = src_val * SAMPLES_PER_SECTOR;
- }
-
- if (src_format == dest_format) {
- *dest_val = src_val;
- goto done;
- }
-
- switch (src_format) {
- case GST_FORMAT_BYTES:
- /* convert to samples (4 bytes per sample) */
- src_val = src_val >> 2;
- /* fallthrough */
- case GST_FORMAT_DEFAULT:{
- switch (dest_format) {
- case GST_FORMAT_BYTES:{
- if (src_val < 0) {
- GST_DEBUG_OBJECT (src, "sample source value negative");
- goto wrong_value;
- }
- *dest_val = src_val << 2; /* 4 bytes per sample */
- break;
- }
- case GST_FORMAT_TIME:{
- *dest_val = gst_util_uint64_scale_int (src_val, GST_SECOND, 44100);
- break;
- }
- default:{
- gint64 sector = src_val / SAMPLES_PER_SECTOR;
-
- if (dest_format == sector_format) {
- *dest_val = sector;
- } else if (dest_format == track_format) {
- if (!started)
- goto not_started;
- *dest_val = gst_cdda_base_src_get_track_from_sector (src, sector);
- } else {
- goto unknown_format;
- }
- break;
- }
- }
- break;
- }
- case GST_FORMAT_TIME:{
- gint64 sample_offset;
-
- if (src_val == GST_CLOCK_TIME_NONE) {
- GST_DEBUG_OBJECT (src, "source time value invalid");
- goto wrong_value;
- }
-
- sample_offset = gst_util_uint64_scale_int (src_val, 44100, GST_SECOND);
- switch (dest_format) {
- case GST_FORMAT_BYTES:{
- *dest_val = sample_offset << 2; /* 4 bytes per sample */
- break;
- }
- case GST_FORMAT_DEFAULT:{
- *dest_val = sample_offset;
- break;
- }
- default:{
- gint64 sector = sample_offset / SAMPLES_PER_SECTOR;
-
- if (dest_format == sector_format) {
- *dest_val = sector;
- } else if (dest_format == track_format) {
- if (!started)
- goto not_started;
- *dest_val = gst_cdda_base_src_get_track_from_sector (src, sector);
- } else {
- goto unknown_format;
- }
- break;
- }
- }
- break;
- }
- default:{
- goto unknown_format;
- }
- }
-
-done:
- {
- GST_LOG_OBJECT (src, "returning %" G_GINT64_FORMAT, *dest_val);
- return TRUE;
- }
-
-unknown_format:
- {
- GST_DEBUG_OBJECT (src, "conversion failed: %s", "unsupported format");
- return FALSE;
- }
-
-wrong_value:
- {
- GST_DEBUG_OBJECT (src, "conversion failed: %s",
- "source value not within allowed range");
- return FALSE;
- }
-
-not_started:
- {
- GST_DEBUG_OBJECT (src, "conversion failed: %s",
- "cannot do this conversion, device not open");
- return FALSE;
- }
-}
-
-static gboolean
-gst_cdda_base_src_query (GstBaseSrc * basesrc, GstQuery * query)
-{
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (basesrc);
- gboolean started;
-
- started = GST_OBJECT_FLAG_IS_SET (basesrc, GST_BASE_SRC_STARTED);
-
- GST_LOG_OBJECT (src, "handling %s query",
- gst_query_type_get_name (GST_QUERY_TYPE (query)));
-
- switch (GST_QUERY_TYPE (query)) {
- case GST_QUERY_DURATION:{
- GstFormat dest_format;
- gint64 dest_val;
- guint sectors;
-
- gst_query_parse_duration (query, &dest_format, NULL);
-
- if (!started)
- return FALSE;
-
- g_assert (src->tracks != NULL);
-
- if (dest_format == track_format) {
- GST_LOG_OBJECT (src, "duration: %d tracks", src->num_tracks);
- gst_query_set_duration (query, track_format, src->num_tracks);
- return TRUE;
- }
-
- if (src->cur_track < 0 || src->cur_track >= src->num_tracks)
- return FALSE;
-
- if (src->mode == GST_CDDA_BASE_SRC_MODE_NORMAL) {
- sectors = src->tracks[src->cur_track].end -
- src->tracks[src->cur_track].start + 1;
- } else {
- sectors = src->tracks[src->num_tracks - 1].end -
- src->tracks[0].start + 1;
- }
-
- /* ... and convert into final format */
- if (!gst_cdda_base_src_convert (src, sector_format, sectors,
- dest_format, &dest_val)) {
- return FALSE;
- }
-
- gst_query_set_duration (query, dest_format, dest_val);
-
- GST_LOG ("duration: %u sectors, %" G_GINT64_FORMAT " in format %s",
- sectors, dest_val, gst_format_get_name (dest_format));
- break;
- }
- case GST_QUERY_POSITION:{
- GstFormat dest_format;
- gint64 pos_sector;
- gint64 dest_val;
-
- gst_query_parse_position (query, &dest_format, NULL);
-
- if (!started)
- return FALSE;
-
- g_assert (src->tracks != NULL);
-
- if (dest_format == track_format) {
- GST_LOG_OBJECT (src, "position: track %d", src->cur_track);
- gst_query_set_position (query, track_format, src->cur_track);
- return TRUE;
- }
-
- if (src->cur_track < 0 || src->cur_track >= src->num_tracks)
- return FALSE;
-
- if (src->mode == GST_CDDA_BASE_SRC_MODE_NORMAL) {
- pos_sector = src->cur_sector - src->tracks[src->cur_track].start;
- } else {
- pos_sector = src->cur_sector - src->tracks[0].start;
- }
-
- if (!gst_cdda_base_src_convert (src, sector_format, pos_sector,
- dest_format, &dest_val)) {
- return FALSE;
- }
-
- gst_query_set_position (query, dest_format, dest_val);
-
- GST_LOG ("position: sector %u, %" G_GINT64_FORMAT " in format %s",
- (guint) pos_sector, dest_val, gst_format_get_name (dest_format));
- break;
- }
- case GST_QUERY_CONVERT:{
- GstFormat src_format, dest_format;
- gint64 src_val, dest_val;
-
- gst_query_parse_convert (query, &src_format, &src_val, &dest_format,
- NULL);
-
- if (!gst_cdda_base_src_convert (src, src_format, src_val, dest_format,
- &dest_val)) {
- return FALSE;
- }
-
- gst_query_set_convert (query, src_format, src_val, dest_format, dest_val);
- break;
- }
- default:{
- GST_DEBUG_OBJECT (src, "unhandled query, chaining up to parent class");
- return GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);
- }
- }
-
- return TRUE;
-}
-
-static gboolean
-gst_cdda_base_src_is_seekable (GstBaseSrc * basesrc)
-{
- return TRUE;
-}
-
-static gboolean
-gst_cdda_base_src_do_seek (GstBaseSrc * basesrc, GstSegment * segment)
-{
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (basesrc);
- gint64 seek_sector;
-
- GST_DEBUG_OBJECT (src, "segment %" GST_TIME_FORMAT "-%" GST_TIME_FORMAT,
- GST_TIME_ARGS (segment->start), GST_TIME_ARGS (segment->stop));
-
- if (!gst_cdda_base_src_convert (src, GST_FORMAT_TIME, segment->start,
- sector_format, &seek_sector)) {
- GST_WARNING_OBJECT (src, "conversion failed");
- return FALSE;
- }
-
- /* we should only really be called when open */
- g_assert (src->cur_track >= 0 && src->cur_track < src->num_tracks);
-
- switch (src->mode) {
- case GST_CDDA_BASE_SRC_MODE_NORMAL:
- seek_sector += src->tracks[src->cur_track].start;
- break;
- case GST_CDDA_BASE_SRC_MODE_CONTINUOUS:
- seek_sector += src->tracks[0].start;
- break;
- default:
- g_return_val_if_reached (FALSE);
- }
-
- src->cur_sector = (gint) seek_sector;
-
- GST_DEBUG_OBJECT (src, "seek'd to sector %d", src->cur_sector);
-
- return TRUE;
-}
-
-static gboolean
-gst_cdda_base_src_handle_track_seek (GstCddaBaseSrc * src, gdouble rate,
- GstSeekFlags flags, GstSeekType start_type, gint64 start,
- GstSeekType stop_type, gint64 stop)
-{
- GstBaseSrc *basesrc = GST_BASE_SRC (src);
- GstEvent *event;
-
- if ((flags & GST_SEEK_FLAG_SEGMENT) == GST_SEEK_FLAG_SEGMENT) {
- gint64 start_time = -1;
- gint64 stop_time = -1;
-
- if (src->mode != GST_CDDA_BASE_SRC_MODE_CONTINUOUS) {
- GST_DEBUG_OBJECT (src, "segment seek in track format is only "
- "supported in CONTINUOUS mode, not in mode %d", src->mode);
- return FALSE;
- }
-
- switch (start_type) {
- case GST_SEEK_TYPE_SET:
- if (!gst_cdda_base_src_convert (src, track_format, start,
- GST_FORMAT_TIME, &start_time)) {
- GST_DEBUG_OBJECT (src, "cannot convert track %d to time",
- (gint) start);
- return FALSE;
- }
- break;
- case GST_SEEK_TYPE_END:
- if (!gst_cdda_base_src_convert (src, track_format,
- src->num_tracks - start - 1, GST_FORMAT_TIME, &start_time)) {
- GST_DEBUG_OBJECT (src, "cannot convert track %d to time",
- (gint) start);
- return FALSE;
- }
- start_type = GST_SEEK_TYPE_SET;
- break;
- case GST_SEEK_TYPE_NONE:
- start_time = -1;
- break;
- default:
- g_return_val_if_reached (FALSE);
- }
-
- switch (stop_type) {
- case GST_SEEK_TYPE_SET:
- if (!gst_cdda_base_src_convert (src, track_format, stop,
- GST_FORMAT_TIME, &stop_time)) {
- GST_DEBUG_OBJECT (src, "cannot convert track %d to time",
- (gint) stop);
- return FALSE;
- }
- break;
- case GST_SEEK_TYPE_END:
- if (!gst_cdda_base_src_convert (src, track_format,
- src->num_tracks - stop - 1, GST_FORMAT_TIME, &stop_time)) {
- GST_DEBUG_OBJECT (src, "cannot convert track %d to time",
- (gint) stop);
- return FALSE;
- }
- stop_type = GST_SEEK_TYPE_SET;
- break;
- case GST_SEEK_TYPE_NONE:
- stop_time = -1;
- break;
- default:
- g_return_val_if_reached (FALSE);
- }
-
- GST_LOG_OBJECT (src, "seek segment %" GST_TIME_FORMAT "-%" GST_TIME_FORMAT,
- GST_TIME_ARGS (start_time), GST_TIME_ARGS (stop_time));
-
- /* send fake segment seek event in TIME format to
- * base class, which will hopefully handle the rest */
-
- event = gst_event_new_seek (rate, GST_FORMAT_TIME, flags, start_type,
- start_time, stop_type, stop_time);
-
- return GST_BASE_SRC_CLASS (parent_class)->event (basesrc, event);
- }
-
- /* not a segment seek */
-
- if (start_type == GST_SEEK_TYPE_NONE) {
- GST_LOG_OBJECT (src, "start seek type is NONE, nothing to do");
- return TRUE;
- }
-
- if (stop_type != GST_SEEK_TYPE_NONE) {
- GST_WARNING_OBJECT (src, "ignoring stop seek type (expected NONE)");
- }
-
- if (start < 0 || start >= src->num_tracks) {
- GST_DEBUG_OBJECT (src, "invalid track %" G_GINT64_FORMAT, start);
- return FALSE;
- }
-
- GST_DEBUG_OBJECT (src, "seeking to track %" G_GINT64_FORMAT, start + 1);
-
- src->cur_sector = src->tracks[start].start;
- GST_DEBUG_OBJECT (src, "starting at sector %d", src->cur_sector);
-
- if (src->cur_track != start) {
- src->cur_track = (gint) start;
- src->uri_track = -1;
- src->prev_track = -1;
-
- gst_cdda_base_src_update_duration (src);
- } else {
- GST_DEBUG_OBJECT (src, "is current track, just seeking back to start");
- }
-
- /* send fake segment seek event in TIME format to
- * base class (so we get a newsegment etc.) */
- event = gst_event_new_seek (rate, GST_FORMAT_TIME, flags,
- GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE, -1);
-
- return GST_BASE_SRC_CLASS (parent_class)->event (basesrc, event);
-}
-
-static gboolean
-gst_cdda_base_src_handle_event (GstBaseSrc * basesrc, GstEvent * event)
-{
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (basesrc);
- gboolean ret = FALSE;
-
- GST_LOG_OBJECT (src, "handling %s event", GST_EVENT_TYPE_NAME (event));
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_SEEK:{
- GstSeekType start_type, stop_type;
- GstSeekFlags flags;
- GstFormat format;
- gdouble rate;
- gint64 start, stop;
-
- if (!GST_OBJECT_FLAG_IS_SET (basesrc, GST_BASE_SRC_STARTED)) {
- GST_DEBUG_OBJECT (src, "seek failed: device not open");
- break;
- }
-
- gst_event_parse_seek (event, &rate, &format, &flags, &start_type, &start,
- &stop_type, &stop);
-
- if (format == sector_format) {
- GST_DEBUG_OBJECT (src, "seek in sector format not supported");
- break;
- }
-
- if (format == track_format) {
- ret = gst_cdda_base_src_handle_track_seek (src, rate, flags,
- start_type, start, stop_type, stop);
- } else {
- GST_LOG_OBJECT (src, "let base class handle seek in %s format",
- gst_format_get_name (format));
- event = gst_event_ref (event);
- ret = GST_BASE_SRC_CLASS (parent_class)->event (basesrc, event);
- }
- break;
- }
- default:{
- GST_LOG_OBJECT (src, "let base class handle event");
- ret = GST_BASE_SRC_CLASS (parent_class)->event (basesrc, event);
- break;
- }
- }
-
- return ret;
-}
-
-static GstURIType
-gst_cdda_base_src_uri_get_type (GType type)
-{
- return GST_URI_SRC;
-}
-
-static gchar **
-gst_cdda_base_src_uri_get_protocols (GType type)
-{
- static gchar *protocols[] = { (char *) "cdda", NULL };
-
- return protocols;
-}
-
-static const gchar *
-gst_cdda_base_src_uri_get_uri (GstURIHandler * handler)
-{
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (handler);
-
- GST_OBJECT_LOCK (src);
-
- g_free (src->uri);
-
- if (GST_OBJECT_FLAG_IS_SET (GST_BASE_SRC (src), GST_BASE_SRC_STARTED)) {
- src->uri =
- g_strdup_printf ("cdda://%s#%d", src->device,
- (src->uri_track > 0) ? src->uri_track : 1);
- } else {
- src->uri = g_strdup ("cdda://1");
- }
-
- GST_OBJECT_UNLOCK (src);
-
- return src->uri;
-}
-
-/* Note: gst_element_make_from_uri() might call us with just 'cdda://' as
- * URI and expects us to return TRUE then (and this might be in any state) */
-
-/* We accept URIs of the format cdda://(device#track)|(track) */
-
-static gboolean
-gst_cdda_base_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
-{
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (handler);
- gchar *protocol;
- const gchar *location;
- gchar *track_number;
-
- GST_OBJECT_LOCK (src);
-
- protocol = gst_uri_get_protocol (uri);
- if (!protocol || g_ascii_strcasecmp (protocol, "cdda") != 0) {
- g_free (protocol);
- goto failed;
- }
- g_free (protocol);
-
- location = uri + 7;
- track_number = g_strrstr (location, "#");
- src->uri_track = 0;
- /* FIXME 0.11: ignore URI fragments that look like device paths for
- * the benefit of rhythmbox and possibly other applications.
- */
- if (track_number && track_number[1] != '/') {
- gchar *device, *nuri = g_strdup (uri);
-
- track_number = nuri + (track_number - uri);
- *track_number = '\0';
- device = gst_uri_get_location (nuri);
- gst_cdda_base_src_set_device (src, device);
- g_free (device);
- src->uri_track = strtol (track_number + 1, NULL, 10);
- g_free (nuri);
- } else {
- if (*location == '\0')
- src->uri_track = 1;
- else
- src->uri_track = strtol (location, NULL, 10);
- }
-
- if (src->uri_track < 1)
- goto failed;
-
- if (src->num_tracks > 0
- && src->tracks != NULL && src->uri_track > src->num_tracks)
- goto failed;
-
- if (src->uri_track > 0 && src->tracks != NULL) {
- GST_OBJECT_UNLOCK (src);
-
- gst_pad_send_event (GST_BASE_SRC_PAD (src),
- gst_event_new_seek (1.0, track_format, GST_SEEK_FLAG_FLUSH,
- GST_SEEK_TYPE_SET, src->uri_track - 1, GST_SEEK_TYPE_NONE, -1));
- } else {
- /* seek will be done in start() */
- GST_OBJECT_UNLOCK (src);
- }
-
- GST_LOG_OBJECT (handler, "successfully handled uri '%s'", uri);
-
- return TRUE;
-
-failed:
- {
- GST_OBJECT_UNLOCK (src);
- GST_DEBUG_OBJECT (src, "cannot handle URI '%s'", uri);
- return FALSE;
- }
-}
-
-static void
-gst_cdda_base_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
-{
- GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
-
- iface->get_type = gst_cdda_base_src_uri_get_type;
- iface->get_uri = gst_cdda_base_src_uri_get_uri;
- iface->set_uri = gst_cdda_base_src_uri_set_uri;
- iface->get_protocols = gst_cdda_base_src_uri_get_protocols;
-}
-
-/**
- * gst_cdda_base_src_add_track:
- * @src: a #GstCddaBaseSrc
- * @track: address of #GstCddaBaseSrcTrack to add
- *
- * CDDA sources use this function from their start vfunc to announce the
- * available data and audio tracks to the base source class. The caller
- * should allocate @track on the stack, the base source will do a shallow
- * copy of the structure (and take ownership of the taglist if there is one).
- *
- * Returns: FALSE on error, otherwise TRUE.
- */
-
-gboolean
-gst_cdda_base_src_add_track (GstCddaBaseSrc * src, GstCddaBaseSrcTrack * track)
-{
- g_return_val_if_fail (GST_IS_CDDA_BASE_SRC (src), FALSE);
- g_return_val_if_fail (track != NULL, FALSE);
- g_return_val_if_fail (track->num > 0, FALSE);
-
- GST_DEBUG_OBJECT (src, "adding track %2u (%2u) [%6u-%6u] [%5s], tags: %"
- GST_PTR_FORMAT, src->num_tracks + 1, track->num, track->start,
- track->end, (track->is_audio) ? "AUDIO" : "DATA ", track->tags);
-
- if (src->num_tracks > 0) {
- guint end_of_previous_track = src->tracks[src->num_tracks - 1].end;
-
- if (track->start <= end_of_previous_track) {
- GST_WARNING ("track %2u overlaps with previous tracks", track->num);
- return FALSE;
- }
- }
-
- GST_OBJECT_LOCK (src);
-
- ++src->num_tracks;
- src->tracks = g_renew (GstCddaBaseSrcTrack, src->tracks, src->num_tracks);
- src->tracks[src->num_tracks - 1] = *track;
-
- GST_OBJECT_UNLOCK (src);
-
- return TRUE;
-}
-
-static void
-gst_cdda_base_src_update_duration (GstCddaBaseSrc * src)
-{
- GstBaseSrc *basesrc;
- gint64 dur;
-
- basesrc = GST_BASE_SRC (src);
-
- if (!gst_pad_query_duration (GST_BASE_SRC_PAD (src), GST_FORMAT_TIME, &dur)) {
- dur = GST_CLOCK_TIME_NONE;
- }
- basesrc->segment.duration = dur;
-
- gst_element_post_message (GST_ELEMENT (src),
- gst_message_new_duration (GST_OBJECT (src), GST_FORMAT_TIME, -1));
-
- GST_LOG_OBJECT (src, "duration updated to %" GST_TIME_FORMAT,
- GST_TIME_ARGS (dur));
-}
-
-#define CD_MSF_OFFSET 150
-
-/* the cddb hash function */
-static guint
-cddb_sum (gint n)
-{
- guint ret;
-
- ret = 0;
- while (n > 0) {
- ret += (n % 10);
- n /= 10;
- }
- return ret;
-}
-
-static void
-gst_cddabasesrc_calculate_musicbrainz_discid (GstCddaBaseSrc * src)
-{
- GString *s;
- GChecksum *sha;
- guchar digest[20];
- gchar *ptr;
- gchar tmp[9];
- gulong i;
- guint leadout_sector;
- gsize digest_len;
-
- s = g_string_new (NULL);
-
- leadout_sector = src->tracks[src->num_tracks - 1].end + 1 + CD_MSF_OFFSET;
-
- /* generate SHA digest */
- sha = g_checksum_new (G_CHECKSUM_SHA1);
- g_snprintf (tmp, sizeof (tmp), "%02X", src->tracks[0].num);
- g_string_append_printf (s, "%02X", src->tracks[0].num);
- g_checksum_update (sha, (guchar *) tmp, 2);
-
- g_snprintf (tmp, sizeof (tmp), "%02X", src->tracks[src->num_tracks - 1].num);
- g_string_append_printf (s, " %02X", src->tracks[src->num_tracks - 1].num);
- g_checksum_update (sha, (guchar *) tmp, 2);
-
- g_snprintf (tmp, sizeof (tmp), "%08X", leadout_sector);
- g_string_append_printf (s, " %08X", leadout_sector);
- g_checksum_update (sha, (guchar *) tmp, 8);
-
- for (i = 0; i < 99; i++) {
- if (i < src->num_tracks) {
- guint frame_offset = src->tracks[i].start + CD_MSF_OFFSET;
-
- g_snprintf (tmp, sizeof (tmp), "%08X", frame_offset);
- g_string_append_printf (s, " %08X", frame_offset);
- g_checksum_update (sha, (guchar *) tmp, 8);
- } else {
- g_checksum_update (sha, (guchar *) "00000000", 8);
- }
- }
- digest_len = 20;
- g_checksum_get_digest (sha, (guint8 *) & digest, &digest_len);
-
- /* re-encode to base64 */
- ptr = g_base64_encode (digest, digest_len);
- g_checksum_free (sha);
- i = strlen (ptr);
-
- g_assert (i < sizeof (src->mb_discid) + 1);
- memcpy (src->mb_discid, ptr, i);
- src->mb_discid[i] = '\0';
- free (ptr);
-
- /* Replace '/', '+' and '=' by '_', '.' and '-' as specified on
- * http://musicbrainz.org/doc/DiscIDCalculation
- */
- for (ptr = src->mb_discid; *ptr != '\0'; ptr++) {
- if (*ptr == '/')
- *ptr = '_';
- else if (*ptr == '+')
- *ptr = '.';
- else if (*ptr == '=')
- *ptr = '-';
- }
-
- GST_DEBUG_OBJECT (src, "musicbrainz-discid = %s", src->mb_discid);
- GST_DEBUG_OBJECT (src, "musicbrainz-discid-full = %s", s->str);
-
- gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
- GST_TAG_CDDA_MUSICBRAINZ_DISCID, src->mb_discid,
- GST_TAG_CDDA_MUSICBRAINZ_DISCID_FULL, s->str, NULL);
-
- g_string_free (s, TRUE);
-}
-
-static void
-lba_to_msf (guint sector, guint * p_m, guint * p_s, guint * p_f, guint * p_secs)
-{
- guint m, s, f;
-
- m = sector / SECTORS_PER_MINUTE;
- sector = sector % SECTORS_PER_MINUTE;
- s = sector / SECTORS_PER_SECOND;
- f = sector % SECTORS_PER_SECOND;
-
- if (p_m)
- *p_m = m;
- if (p_s)
- *p_s = s;
- if (p_f)
- *p_f = f;
- if (p_secs)
- *p_secs = s + (m * 60);
-}
-
-static void
-gst_cdda_base_src_calculate_cddb_id (GstCddaBaseSrc * src)
-{
- GString *s;
- guint first_sector = 0, last_sector = 0;
- guint start_secs, end_secs, secs, len_secs;
- guint total_secs, num_audio_tracks;
- guint id, t, i;
-
- id = 0;
- total_secs = 0;
- num_audio_tracks = 0;
-
- /* FIXME: do we use offsets and duration of ALL tracks (data + audio)
- * for the CDDB ID calculation, or only audio tracks? */
- for (i = 0; i < src->num_tracks; ++i) {
- if (1) { /* src->tracks[i].is_audio) { */
- if (num_audio_tracks == 0) {
- first_sector = src->tracks[i].start + CD_MSF_OFFSET;
- }
- last_sector = src->tracks[i].end + CD_MSF_OFFSET + 1;
- ++num_audio_tracks;
-
- lba_to_msf (src->tracks[i].start + CD_MSF_OFFSET, NULL, NULL, NULL,
- &secs);
-
- len_secs = (src->tracks[i].end - src->tracks[i].start + 1) / 75;
-
- GST_DEBUG_OBJECT (src, "track %02u: lsn %6u (%02u:%02u), "
- "length: %u seconds (%02u:%02u)",
- num_audio_tracks, src->tracks[i].start + CD_MSF_OFFSET,
- secs / 60, secs % 60, len_secs, len_secs / 60, len_secs % 60);
-
- id += cddb_sum (secs);
- total_secs += len_secs;
- }
- }
-
- /* first_sector = src->tracks[0].start + CD_MSF_OFFSET; */
- lba_to_msf (first_sector, NULL, NULL, NULL, &start_secs);
-
- /* last_sector = src->tracks[src->num_tracks-1].end + CD_MSF_OFFSET; */
- lba_to_msf (last_sector, NULL, NULL, NULL, &end_secs);
-
- GST_DEBUG_OBJECT (src, "first_sector = %u = %u secs (%02u:%02u)",
- first_sector, start_secs, start_secs / 60, start_secs % 60);
- GST_DEBUG_OBJECT (src, "last_sector = %u = %u secs (%02u:%02u)",
- last_sector, end_secs, end_secs / 60, end_secs % 60);
-
- t = end_secs - start_secs;
-
- GST_DEBUG_OBJECT (src, "total length = %u secs (%02u:%02u), added title "
- "lengths = %u seconds (%02u:%02u)", t, t / 60, t % 60, total_secs,
- total_secs / 60, total_secs % 60);
-
- src->discid = ((id % 0xff) << 24 | t << 8 | num_audio_tracks);
-
- s = g_string_new (NULL);
- g_string_append_printf (s, "%08x", src->discid);
-
- gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
- GST_TAG_CDDA_CDDB_DISCID, s->str, NULL);
-
- g_string_append_printf (s, " %u", src->num_tracks);
- for (i = 0; i < src->num_tracks; ++i) {
- g_string_append_printf (s, " %u", src->tracks[i].start + CD_MSF_OFFSET);
- }
- g_string_append_printf (s, " %u", t);
-
- gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
- GST_TAG_CDDA_CDDB_DISCID_FULL, s->str, NULL);
-
- GST_DEBUG_OBJECT (src, "cddb discid = %s", s->str);
-
- g_string_free (s, TRUE);
-}
-
-static void
-gst_cdda_base_src_add_tags (GstCddaBaseSrc * src)
-{
- gint i;
-
- /* fill in details for each track */
- for (i = 0; i < src->num_tracks; ++i) {
- gint64 duration;
- guint num_sectors;
-
- if (src->tracks[i].tags == NULL)
- src->tracks[i].tags = gst_tag_list_new_empty ();
-
- num_sectors = src->tracks[i].end - src->tracks[i].start + 1;
- gst_cdda_base_src_convert (src, sector_format, num_sectors,
- GST_FORMAT_TIME, &duration);
-
- gst_tag_list_add (src->tracks[i].tags,
- GST_TAG_MERGE_REPLACE,
- GST_TAG_TRACK_NUMBER, i + 1,
- GST_TAG_TRACK_COUNT, src->num_tracks, GST_TAG_DURATION, duration, NULL);
- }
-
- /* now fill in per-album tags and include each track's tags
- * in the album tags, so that interested parties can retrieve
- * the relevant details for each track in one go */
-
- /* /////////////////////////////// FIXME should we rather insert num_tracks
- * tags by the name of 'track-tags' and have the caller use
- * gst_tag_list_get_value_index() rather than use tag names incl.
- * the track number ?? *////////////////////////////////////////
-
- gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
- GST_TAG_TRACK_COUNT, src->num_tracks, NULL);
-#if 0
- for (i = 0; i < src->num_tracks; ++i) {
- gst_tag_list_add (src->tags, GST_TAG_MERGE_APPEND,
- GST_TAG_CDDA_TRACK_TAGS, src->tracks[i].tags, NULL);
- }
-#endif
-
- GST_DEBUG ("src->tags = %" GST_PTR_FORMAT, src->tags);
-}
-
-static void
-gst_cdda_base_src_add_index_associations (GstCddaBaseSrc * src)
-{
- gint i;
-
- for (i = 0; i < src->num_tracks; i++) {
- gint64 sector;
-
- sector = src->tracks[i].start;
- gst_index_add_association (src->index, src->index_id, GST_ASSOCIATION_FLAG_KEY_UNIT, track_format, i, /* here we count from 0 */
- 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);
- }
-}
-
-static void
-gst_cdda_base_src_set_index (GstElement * element, GstIndex * index)
-{
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (element);
- GstIndex *old;
-
- GST_OBJECT_LOCK (element);
- old = src->index;
- if (old == index) {
- GST_OBJECT_UNLOCK (element);
- return;
- }
- if (index)
- gst_object_ref (index);
- src->index = index;
- GST_OBJECT_UNLOCK (element);
- if (old)
- gst_object_unref (old);
-
- if (index) {
- gst_index_get_writer_id (index, GST_OBJECT (src), &src->index_id);
- gst_index_add_format (index, src->index_id, track_format);
- gst_index_add_format (index, src->index_id, sector_format);
- }
-}
-
-
-static GstIndex *
-gst_cdda_base_src_get_index (GstElement * element)
-{
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (element);
- GstIndex *index;
-
- GST_OBJECT_LOCK (element);
- if ((index = src->index))
- gst_object_ref (index);
- GST_OBJECT_UNLOCK (element);
-
- return index;
-}
-
-static gint
-gst_cdda_base_src_track_sort_func (gconstpointer a, gconstpointer b,
- gpointer foo)
-{
- GstCddaBaseSrcTrack *track_a = ((GstCddaBaseSrcTrack *) a);
- GstCddaBaseSrcTrack *track_b = ((GstCddaBaseSrcTrack *) b);
-
- /* sort data tracks to the end, and audio tracks by track number */
- if (track_a->is_audio == track_b->is_audio)
- return (gint) track_a->num - (gint) track_b->num;
-
- if (track_a->is_audio) {
- return -1;
- } else {
- return 1;
- }
-}
-
-static gboolean
-gst_cdda_base_src_start (GstBaseSrc * basesrc)
-{
- GstCddaBaseSrcClass *klass = GST_CDDA_BASE_SRC_GET_CLASS (basesrc);
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (basesrc);
- gboolean ret;
- gchar *device = NULL;
-
- src->discid = 0;
- src->mb_discid[0] = '\0';
-
- g_assert (klass->open != NULL);
-
- if (src->device != NULL) {
- device = g_strdup (src->device);
- } else if (klass->get_default_device != NULL) {
- device = klass->get_default_device (src);
- }
-
- if (device == NULL)
- device = g_strdup (DEFAULT_DEVICE);
-
- GST_LOG_OBJECT (basesrc, "opening device %s", device);
-
- src->tags = gst_tag_list_new_empty ();
-
- ret = klass->open (src, device);
- g_free (device);
- device = NULL;
-
- if (!ret) {
- GST_DEBUG_OBJECT (basesrc, "failed to open device");
- /* subclass (should have) posted an error message with the details */
- gst_cdda_base_src_stop (basesrc);
- return FALSE;
- }
-
- if (src->num_tracks == 0 || src->tracks == NULL) {
- GST_DEBUG_OBJECT (src, "no tracks");
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("This CD has no audio tracks")), (NULL));
- gst_cdda_base_src_stop (basesrc);
- return FALSE;
- }
-
- /* need to calculate disc IDs before we ditch the data tracks */
- gst_cdda_base_src_calculate_cddb_id (src);
- gst_cddabasesrc_calculate_musicbrainz_discid (src);
-
-#if 0
- /* adjust sector offsets if necessary */
- if (src->toc_bias) {
- src->toc_offset -= src->tracks[0].start;
- }
- for (i = 0; i < src->num_tracks; ++i) {
- src->tracks[i].start += src->toc_offset;
- src->tracks[i].end += src->toc_offset;
- }
-#endif
-
- /* now that we calculated the various disc IDs,
- * sort the data tracks to end and ignore them */
- src->num_all_tracks = src->num_tracks;
-
- g_qsort_with_data (src->tracks, src->num_tracks,
- sizeof (GstCddaBaseSrcTrack), gst_cdda_base_src_track_sort_func, NULL);
-
- while (src->num_tracks > 0 && !src->tracks[src->num_tracks - 1].is_audio)
- --src->num_tracks;
-
- if (src->num_tracks == 0) {
- GST_DEBUG_OBJECT (src, "no audio tracks");
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("This CD has no audio tracks")), (NULL));
- gst_cdda_base_src_stop (basesrc);
- return FALSE;
- }
-
- gst_cdda_base_src_add_tags (src);
-
- if (src->index && GST_INDEX_IS_WRITABLE (src->index))
- gst_cdda_base_src_add_index_associations (src);
-
- src->cur_track = 0;
- src->prev_track = -1;
-
- if (src->uri_track > 0 && src->uri_track <= src->num_tracks) {
- GST_LOG_OBJECT (src, "seek to track %d", src->uri_track);
- src->cur_track = src->uri_track - 1;
- src->uri_track = -1;
- src->mode = GST_CDDA_BASE_SRC_MODE_NORMAL;
- }
-
- src->cur_sector = src->tracks[src->cur_track].start;
- GST_LOG_OBJECT (src, "starting at sector %d", src->cur_sector);
-
- gst_cdda_base_src_update_duration (src);
-
- return TRUE;
-}
-
-static void
-gst_cdda_base_src_clear_tracks (GstCddaBaseSrc * src)
-{
- if (src->tracks != NULL) {
- gint i;
-
- for (i = 0; i < src->num_all_tracks; ++i) {
- if (src->tracks[i].tags)
- gst_tag_list_free (src->tracks[i].tags);
- }
-
- g_free (src->tracks);
- src->tracks = NULL;
- }
- src->num_tracks = 0;
- src->num_all_tracks = 0;
-}
-
-static gboolean
-gst_cdda_base_src_stop (GstBaseSrc * basesrc)
-{
- GstCddaBaseSrcClass *klass = GST_CDDA_BASE_SRC_GET_CLASS (basesrc);
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (basesrc);
-
- g_assert (klass->close != NULL);
-
- klass->close (src);
-
- gst_cdda_base_src_clear_tracks (src);
-
- if (src->tags) {
- gst_tag_list_free (src->tags);
- src->tags = NULL;
- }
-
- src->prev_track = -1;
- src->cur_track = -1;
-
- return TRUE;
-}
-
-
-static GstFlowReturn
-gst_cdda_base_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
-{
- GstCddaBaseSrcClass *klass = GST_CDDA_BASE_SRC_GET_CLASS (pushsrc);
- GstCddaBaseSrc *src = GST_CDDA_BASE_SRC (pushsrc);
- GstBuffer *buf;
- gboolean eos;
-
- GstClockTime position = GST_CLOCK_TIME_NONE;
- GstClockTime duration = GST_CLOCK_TIME_NONE;
- gint64 qry_position;
-
- g_assert (klass->read_sector != NULL);
-
- switch (src->mode) {
- case GST_CDDA_BASE_SRC_MODE_NORMAL:
- eos = (src->cur_sector > src->tracks[src->cur_track].end);
- break;
- case GST_CDDA_BASE_SRC_MODE_CONTINUOUS:
- eos = (src->cur_sector > src->tracks[src->num_tracks - 1].end);
- src->cur_track = gst_cdda_base_src_get_track_from_sector (src,
- src->cur_sector);
- break;
- default:
- g_return_val_if_reached (GST_FLOW_ERROR);
- }
-
- if (eos) {
- src->prev_track = -1;
- GST_DEBUG_OBJECT (src, "EOS at sector %d, cur_track=%d, mode=%d",
- src->cur_sector, src->cur_track, src->mode);
- /* base class will send EOS for us */
- return GST_FLOW_EOS;
- }
-
- if (src->prev_track != src->cur_track) {
- GstTagList *tags;
-
- tags = gst_tag_list_merge (src->tags, src->tracks[src->cur_track].tags,
- GST_TAG_MERGE_REPLACE);
- GST_LOG_OBJECT (src, "announcing tags: %" GST_PTR_FORMAT, tags);
- gst_pad_push_event (GST_BASE_SRC_PAD (src), gst_event_new_tag (tags));
- src->prev_track = src->cur_track;
-
- gst_cdda_base_src_update_duration (src);
-
- g_object_notify (G_OBJECT (src), "track");
- }
-
- GST_LOG_OBJECT (src, "asking for sector %u", src->cur_sector);
-
- buf = klass->read_sector (src, src->cur_sector);
-
- if (buf == NULL) {
- GST_WARNING_OBJECT (src, "failed to read sector %u", src->cur_sector);
- return GST_FLOW_ERROR;
- }
-
- if (gst_pad_query_position (GST_BASE_SRC_PAD (src), GST_FORMAT_TIME,
- &qry_position)) {
- gint64 next_ts = 0;
-
- position = (GstClockTime) qry_position;
-
- ++src->cur_sector;
- if (gst_pad_query_position (GST_BASE_SRC_PAD (src), GST_FORMAT_TIME,
- &next_ts)) {
- duration = (GstClockTime) (next_ts - qry_position);
- }
- --src->cur_sector;
- }
-
- /* fallback duration: 4 bytes per sample, 44100 samples per second */
- if (duration == GST_CLOCK_TIME_NONE) {
- duration = gst_util_uint64_scale_int (gst_buffer_get_size (buf) >> 2,
- GST_SECOND, 44100);
- }
-
- GST_BUFFER_TIMESTAMP (buf) = position;
- GST_BUFFER_DURATION (buf) = duration;
-
- GST_LOG_OBJECT (src, "pushing sector %d with timestamp %" GST_TIME_FORMAT,
- src->cur_sector, GST_TIME_ARGS (position));
-
- ++src->cur_sector;
-
- *buffer = buf;
-
- return GST_FLOW_OK;
-}
+++ /dev/null
-/* GStreamer
- * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
- * Copyright (C) 2005 Tim-Philipp Müller <tim centricular net>
- *
- * 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_CDDA_BASE_SRC_H__
-#define __GST_CDDA_BASE_SRC_H__
-
-#include <gst/gst.h>
-#include <gst/base/gstpushsrc.h>
-
-/* must include this for backwards-compatibility so the
- * GST_TAG_CDDA_* defines are included. Remove in 0.11 */
-#include <gst/tag/tag.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_CDDA_BASE_SRC (gst_cdda_base_src_get_type())
-#define GST_CDDA_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_CDDA_BASE_SRC, GstCddaBaseSrc))
-#define GST_CDDA_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_CDDA_BASE_SRC, GstCddaBaseSrcClass))
-#define GST_IS_CDDA_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_CDDA_BASE_SRC))
-#define GST_IS_CDDA_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_CDDA_BASE_SRC))
-#define GST_CDDA_BASE_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CDDA_BASE_SRC, GstCddaBaseSrcClass))
-
-typedef struct _GstCddaBaseSrc GstCddaBaseSrc;
-typedef struct _GstCddaBaseSrcClass GstCddaBaseSrcClass;
-typedef struct _GstCddaBaseSrcTrack GstCddaBaseSrcTrack;
-
-/**
- * GstCddaBaseSrcMode:
- * @GST_CDDA_BASE_SRC_MODE_NORMAL : each single track is a stream
- * @GST_CDDA_BASE_SRC_MODE_CONTINUOUS : the entire disc is a single stream
- *
- * Mode in which the CD audio source operates. Influences timestamping,
- * EOS handling and seeking.
- */
-typedef enum {
- GST_CDDA_BASE_SRC_MODE_NORMAL, /* stream = one track */
- GST_CDDA_BASE_SRC_MODE_CONTINUOUS /* stream = whole disc */
-} GstCddaBaseSrcMode;
-
-#define GST_TYPE_CDDA_BASE_SRC_MODE (gst_cdda_base_src_mode_get_type ())
-
-/**
- * GstCddaBaseSrcTrack:
- * @is_audio: Whether this is an audio track
- * @num: Track number in TOC (usually starts from 1, but not always)
- * @start: The first sector of this track (LBA)
- * @end: The last sector of this track (LBA)
- * @tags: Track-specific tags (e.g. from cd-text information), or NULL
- *
- * CD track abstraction to communicate TOC entries to the base class.
- */
-struct _GstCddaBaseSrcTrack {
- gboolean is_audio; /* TRUE if this is an audio track */
- guint num; /* real track number (usually starts from 1) */
- guint start; /* first sector of track (LBA, not LSN!) */
- guint end; /* last sector of track (LBA, not LSN!) */
- GstTagList *tags; /* NULL or tags for track (e.g. from cd-text) */
-
- /*< private >*/
- guint _gst_reserved1[GST_PADDING/2];
- gpointer _gst_reserved2[GST_PADDING/2];
-};
-
-struct _GstCddaBaseSrc {
- GstPushSrc pushsrc;
-
- /*< protected >*/ /* for use by sub-classes only */
- GstTagList *tags; /* tags that apply to all tracks */
-
- /*< private >*/
- GstCddaBaseSrcMode mode;
-
- gchar *device;
-
- guint num_tracks;
- guint num_all_tracks;
- GstCddaBaseSrcTrack *tracks;
-
- gint cur_track; /* current track (starting from 0) */
- gint prev_track; /* current track last time */
- gint cur_sector; /* current sector */
- gint seek_sector; /* -1 or sector to seek to */
-
- gint uri_track;
- gchar *uri;
-
- guint32 discid; /* cddb disc id (for unit test) */
- gchar mb_discid[32]; /* musicbrainz discid */
-
- GstIndex *index;
- gint index_id;
-
- gint toc_offset;
- gboolean toc_bias;
-
- /*< private >*/
- guint _gst_reserved1[GST_PADDING/2];
- gpointer _gst_reserved2[GST_PADDING/2];
-};
-
-/**
- * GstCddaBaseSrcClass:
- * @pushsrc_class: the parent class
- * @open: opening the device
- * @close: closing the device
- * @read_sector: reading a sector
- * @get_default_device: getting the default device
- * @probe_devices: probing possible devices
- *
- * Cdda source base class.
- */
-struct _GstCddaBaseSrcClass {
- GstPushSrcClass pushsrc_class;
-
- /* open/close the CD device */
- gboolean (*open) (GstCddaBaseSrc *src, const gchar *device);
- void (*close) (GstCddaBaseSrc *src);
-
- /* read one sector (LBA) */
- GstBuffer * (*read_sector) (GstCddaBaseSrc *src, gint sector);
-
- /* return default device or NULL (optional) */
- gchar * (*get_default_device) (GstCddaBaseSrc *src);
-
- /* return NULL-terminated string array of CD devices, or NULL (optional) */
- gchar ** (*probe_devices) (GstCddaBaseSrc *src);
-
- /*< private >*/
- gpointer _gst_reserved[GST_PADDING];
-};
-
-GType gst_cdda_base_src_get_type (void);
-GType gst_cdda_base_src_mode_get_type (void);
-
-gboolean gst_cdda_base_src_add_track (GstCddaBaseSrc * src,
- GstCddaBaseSrcTrack * track);
-
-#if 0
-/*
- * GST_TAG_CDDA_TRACK_TAGS:
- *
- * Tag details for all available tracks
- * FiXME: find out which type we want for this!
- */
-#define GST_TAG_CDDA_TRACK_TAGS "track-tags"
-#endif
-
-G_END_DECLS
-
-#endif /* __GST_CDDA_BASE_SRC_H__ */
-
# libraries
%{_libdir}/libgstaudio-%{majorminor}.so.*
-%{_libdir}/libgstcdda-%{majorminor}.so*
%{_libdir}/libgstinterfaces-%{majorminor}.so.*
%{_libdir}/libgstpbutils-%{majorminor}.so*
%{_libdir}/libgstriff-%{majorminor}.so.*
%{_includedir}/gstreamer-%{majorminor}/gst/tag/tag.h
%{_includedir}/gstreamer-%{majorminor}/gst/video/gstvideofilter.h
%{_includedir}/gstreamer-%{majorminor}/gst/video/gstvideosink.h
-%{_includedir}/gstreamer-%{majorminor}/gst/cdda/gstcddabasesrc.h
+%{_includedir}/gstreamer-%{majorminor}/gst/audio/gstaudiocdsrc.h
%{_includedir}/gstreamer-%{majorminor}/gst/audio/mixerutils.h
%{_includedir}/gstreamer-%{majorminor}/gst/interfaces/videoorientation.h
%{_includedir}/gstreamer-%{majorminor}/gst/pbutils/descriptions.h
%{_libdir}/libgstrtp-%{majorminor}.so
%{_libdir}/libgstinterfaces-%{majorminor}.so
%{_libdir}/libgstpbutils-%{majorminor}.so
-%{_libdir}/libgstcdda-%{majorminor}.so
%{_libdir}/libgstapp-%{majorminor}.so
# pkg-config files
%{_libdir}/pkgconfig/gstreamer-plugins-base-%{majorminor}.pc
%{_libdir}/pkgconfig/gstreamer-audio-%{majorminor}.pc
-%{_libdir}/pkgconfig/gstreamer-cdda-%{majorminor}.pc
%{_libdir}/pkgconfig/gstreamer-fft-%{majorminor}.pc
%{_libdir}/pkgconfig/gstreamer-interfaces-%{majorminor}.pc
%{_libdir}/pkgconfig/gstreamer-pbutils-%{majorminor}.pc
pcverfiles = \
gstreamer-audio-@GST_MAJORMINOR@.pc \
gstreamer-app-@GST_MAJORMINOR@.pc \
- gstreamer-cdda-@GST_MAJORMINOR@.pc \
gstreamer-fft-@GST_MAJORMINOR@.pc \
gstreamer-interfaces-@GST_MAJORMINOR@.pc \
gstreamer-pbutils-@GST_MAJORMINOR@.pc \
pcverfiles_uninstalled = \
gstreamer-audio-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-app-@GST_MAJORMINOR@-uninstalled.pc \
- gstreamer-cdda-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-fft-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-interfaces-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-pbutils-@GST_MAJORMINOR@-uninstalled.pc \
pcinfiles = \
gstreamer-audio.pc.in gstreamer-audio-uninstalled.pc.in \
gstreamer-app.pc.in gstreamer-app-uninstalled.pc.in \
- gstreamer-cdda.pc.in gstreamer-cdda-uninstalled.pc.in \
gstreamer-fft.pc.in gstreamer-fft-uninstalled.pc.in \
gstreamer-interfaces.pc.in gstreamer-interfaces-uninstalled.pc.in \
gstreamer-pbutils.pc.in gstreamer-pbutils-uninstalled.pc.in \
+++ /dev/null
-# the standard variables don't make sense for an uninstalled copy
-prefix=
-exec_prefix=
-libdir=
-# includedir is builddir because it is used to find gstconfig.h in places
-includedir=@abs_top_builddir@/gst-libs
-girdir=@abs_top_builddir@/gst-libs/gst/cdda
-typelibdir=@abs_top_builddir@/gst-libs/gst/cdda
-
-Name: GStreamer CDDA Library, Uninstalled
-Description: CDDA base classes, uninstalled
-Version: @VERSION@
-Requires: gstreamer-@GST_MAJORMINOR@ gstreamer-base-@GST_MAJORMINOR@ gstreamer-tag-@GST_MAJORMINOR@
-Libs: @abs_top_builddir@/gst-libs/gst/cdda/libgstcdda-@GST_MAJORMINOR@.la
-Cflags: -I@abs_top_srcdir@/gst-libs -I@abs_top_builddir@/gst-libs
-
+++ /dev/null
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@/gstreamer-@GST_MAJORMINOR@
-datarootdir=${prefix}/share
-datadir=${datarootdir}
-girdir=${datadir}/gir-1.0
-typelibdir=${libdir}/girepository-1.0
-
-Name: GStreamer CDDA Library
-Description: CDDA base classes
-Requires: gstreamer-@GST_MAJORMINOR@ gstreamer-base-@GST_MAJORMINOR@ gstreamer-tag-@GST_MAJORMINOR@
-Version: @VERSION@
-Libs: -L${libdir} -lgstcdda-@GST_MAJORMINOR@
-Cflags: -I${includedir}
-
Description: Streaming media framework, base plugins libraries, uninstalled
Version: @VERSION@
Requires: gstreamer-@GST_MAJORMINOR@
-Libs: -L@abs_top_builddir@/gst-libs/gst/audio -L@abs_top_builddir@/gst-libs/gst/cdda -L@abs_top_builddir@/gst-libs/gst/fft -L@abs_top_builddir@/gst-libs/gst/floatcast -L@abs_top_builddir@/gst-libs/gst/interfaces -L@abs_top_builddir@/gst-libs/gst/riff -L@abs_top_builddir@/gst-libs/gst/rtp -L@abs_top_builddir@/gst-libs/gst/rtsp -L@abs_top_builddir@/gst-libs/gst/sdp -L@abs_top_builddir@/gst-libs/gst/tag -L@abs_top_builddir@/gst-libs/gst/pbutils -L@abs_top_builddir@/gst-libs/gst/video -L@abs_top_builddir@/gst-libs/gst/app
+Libs: -L@abs_top_builddir@/gst-libs/gst/audio -L@abs_top_builddir@/gst-libs/gst/fft -L@abs_top_builddir@/gst-libs/gst/interfaces -L@abs_top_builddir@/gst-libs/gst/riff -L@abs_top_builddir@/gst-libs/gst/rtp -L@abs_top_builddir@/gst-libs/gst/rtsp -L@abs_top_builddir@/gst-libs/gst/sdp -L@abs_top_builddir@/gst-libs/gst/tag -L@abs_top_builddir@/gst-libs/gst/pbutils -L@abs_top_builddir@/gst-libs/gst/video -L@abs_top_builddir@/gst-libs/gst/app
Cflags: -I@abs_top_srcdir@/gst-libs -I@abs_top_builddir@/gst-libs
-libraries=app audio cdda fft floatcast interfaces riff rtp rtsp sdp tag pbutils video
+libraries=app audio fft interfaces riff rtp rtsp sdp tag pbutils video
Libs: -L${libdir}
Cflags: -I${includedir}
-libraries=audio cdda fft floatcast interfaces riff rtp tag pbutils video
+libraries=audio fft interfaces riff rtp tag pbutils video
gst/tcp/gsttcp.c
gst/tcp/gsttcpclientsink.c
gst/tcp/gsttcpclientsrc.c
+gst-libs/gst/audio/gstaudiocdsrc.c
gst-libs/gst/audio/gstbaseaudiosrc.c
gst-libs/gst/tag/gsttagdemux.c
gst-libs/gst/tag/tags.c
-gst-libs/gst/cdda/gstcddabasesrc.c
gst-libs/gst/pbutils/descriptions.c
gst-libs/gst/pbutils/missing-plugins.c
win32/common/interfaces-enumtypes.h
win32/common/libgstapp.def
win32/common/libgstaudio.def
-win32/common/libgstcdda.def
win32/common/libgstinterfaces.def
win32/common/libgstpbutils.def
win32/common/libgstriff.def
win32/vs6/libgstaudioresample.dsp
win32/vs6/libgstaudioscale.dsp
win32/vs6/libgstaudiotestsrc.dsp
-win32/vs6/libgstcdda.dsp
win32/vs6/libgstdecodebin2.dsp
win32/vs6/libgstdecodebin.dsp
win32/vs6/libgstfft.dsp
+++ /dev/null
-EXPORTS
- gst_cdda_base_src_add_track
- gst_cdda_base_src_get_type
- gst_cdda_base_src_mode_get_type
+++ /dev/null
-# Microsoft Developer Studio Project File - Name="libgstcdda" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102\r
-\r
-CFG=libgstcdda - Win32 Debug\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "libgstcdda.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "libgstcdda.mak" CFG="libgstcdda - Win32 Debug"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "libgstcdda - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE "libgstcdda - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-MTL=midl.exe\r
-RSC=rc.exe\r
-\r
-!IF "$(CFG)" == "libgstcdda - Win32 Release"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release"\r
-# PROP BASE Intermediate_Dir "Release"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release"\r
-# PROP Intermediate_Dir "Release"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBGSTCDDA_EXPORTS" /YX /FD /c\r
-# ADD CPP /nologo /MD /W3 /O2 /I "../../gst-libs" /I "../../../gstreamer" /I "../common" /I "../../../gstreamer/libs" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBGSTCDDA_EXPORTS" /D "HAVE_CONFIG_H" /FD /c\r
-# SUBTRACT CPP /YX\r
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x40c /d "NDEBUG"\r
-# ADD RSC /l 0x40c /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386\r
-# ADD LINK32 glib-2.0.lib gobject-2.0.lib libgstreamer-0.10.lib libgstbase-0.10.lib libgsttag-0.10.lib /nologo /dll /machine:I386 /out:"Release/libgstcdda-0.10.dll" /libpath:"../../../gstreamer/win32/vs6/release" /libpath:"./release"\r
-# Begin Special Build Tool\r
-TargetPath=.\Release\libgstcdda-0.10.dll\r
-SOURCE="$(InputPath)"\r
-PostBuild_Cmds=copy /Y $(TargetPath) c:\gstreamer\bin\r
-# End Special Build Tool\r
-\r
-!ELSEIF "$(CFG)" == "libgstcdda - Win32 Debug"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 1\r
-# PROP BASE Output_Dir "Debug"\r
-# PROP BASE Intermediate_Dir "Debug"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 1\r
-# PROP Output_Dir "Debug"\r
-# PROP Intermediate_Dir "Debug"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBGSTCDDA_EXPORTS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "../../gst-libs" /I "../../../gstreamer" /I "../common" /I "../../../gstreamer/libs" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBGSTCDDA_EXPORTS" /D "HAVE_CONFIG_H" /FD /GZ /c\r
-# SUBTRACT CPP /YX\r
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x40c /d "_DEBUG"\r
-# ADD RSC /l 0x40c /d "_DEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 glib-2.0D.lib gobject-2.0D.lib libgstreamer-0.10.lib libgstbase-0.10.lib libgsttag-0.10.lib /nologo /dll /debug /machine:I386 /out:"Debug/libgstcdda-0.10.dll" /pdbtype:sept /libpath:"../../../gstreamer/win32/vs6/debug" /libpath:"./debug"\r
-# Begin Special Build Tool\r
-TargetPath=.\Debug\libgstcdda-0.10.dll\r
-SOURCE="$(InputPath)"\r
-PostBuild_Cmds=copy /Y $(TargetPath) c:\gstreamer\debug\bin\r
-# End Special Build Tool\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "libgstcdda - Win32 Release"\r
-# Name "libgstcdda - Win32 Debug"\r
-# Begin Group "Source Files"\r
-\r
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
-# Begin Source File\r
-\r
-SOURCE="..\..\gst-libs\gst\cdda\base64.c"\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE="..\..\gst-libs\gst\cdda\gstcddabasesrc.c"\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\common\libgstcdda.def\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE="..\..\gst-libs\gst\cdda\sha1.c"\r
-# End Source File\r
-# End Group\r
-# Begin Group "Header Files"\r
-\r
-# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
-# Begin Source File\r
-\r
-SOURCE="..\..\gst-libs\gst\cdda\base64.h"\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE="..\..\gst-libs\gst\cdda\gstcddabasesrc.h"\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE="..\..\gst-libs\gst\cdda\sha1.h"\r
-# End Source File\r
-# End Group\r
-# Begin Group "Resource Files"\r
-\r
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
-# End Group\r
-# End Target\r
-# End Project\r