gst_plugins_base/gst-libs/gst/cdda/gstcddabasesrc.h
changeset 0 0e761a78d257
child 8 4a7fac7dd34a
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     1 /* GStreamer
       
     2  * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
       
     3  * Copyright (C) 2005 Tim-Philipp Müller <tim centricular net>
       
     4  *
       
     5  * This library is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Library General Public
       
     7  * License as published by the Free Software Foundation; either
       
     8  * version 2 of the License, or (at your option) any later version.
       
     9  *
       
    10  * This library is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13  * Library General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Library General Public
       
    16  * License along with this library; if not, write to the
       
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    18  * Boston, MA 02111-1307, USA.
       
    19  */
       
    20 
       
    21 #ifndef __GST_CDDA_BASE_SRC_H__
       
    22 #define __GST_CDDA_BASE_SRC_H__
       
    23 
       
    24 #include <gst/gst.h>
       
    25 #include <gst/base/gstpushsrc.h>
       
    26 
       
    27 /* must include this for backwards-compatibility so the
       
    28  * GST_TAG_CDDA_* defines are included. Remove in 0.11 */
       
    29 #include <gst/tag/tag.h>
       
    30 
       
    31 G_BEGIN_DECLS
       
    32 
       
    33 #define GST_TYPE_CDDA_BASE_SRC            (gst_cdda_base_src_get_type())
       
    34 #define GST_CDDA_BASE_SRC(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_CDDA_BASE_SRC, GstCddaBaseSrc))
       
    35 #define GST_CDDA_BASE_SRC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_CDDA_BASE_SRC, GstCddaBaseSrcClass))
       
    36 #define GST_IS_CDDA_BASE_SRC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_CDDA_BASE_SRC))
       
    37 #define GST_IS_CDDA_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_CDDA_BASE_SRC))
       
    38 #define GST_CDDA_BASE_SRC_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CDDA_BASE_SRC, GstCddaBaseSrcClass))
       
    39 
       
    40 typedef struct _GstCddaBaseSrc GstCddaBaseSrc;
       
    41 typedef struct _GstCddaBaseSrcClass GstCddaBaseSrcClass;
       
    42 typedef struct _GstCddaBaseSrcTrack GstCddaBaseSrcTrack;
       
    43 
       
    44 /**
       
    45  * GstCddaBaseSrcMode:
       
    46  * @GST_CDDA_BASE_SRC_MODE_NORMAL     : each single track is a stream
       
    47  * @GST_CDDA_BASE_SRC_MODE_CONTINUOUS : the entire disc is a single stream
       
    48  *
       
    49  * Mode in which the CD audio source operates. Influences timestamping,
       
    50  * EOS handling and seeking.
       
    51  */
       
    52 typedef enum {
       
    53   GST_CDDA_BASE_SRC_MODE_NORMAL,          /* stream = one track  */
       
    54   GST_CDDA_BASE_SRC_MODE_CONTINUOUS       /* stream = whole disc */
       
    55 } GstCddaBaseSrcMode;
       
    56 
       
    57 /**
       
    58  * GstCddaBaseSrcTrack:
       
    59  * @is_audio: Whether this is an audio track
       
    60  * @num: Track number in TOC (usually starts from 1, but not always)
       
    61  * @start: The first sector of this track (LBA)
       
    62  * @end: The last sector of this track (LBA)
       
    63  * @tags: Track-specific tags (e.g. from cd-text information), or NULL
       
    64  *
       
    65  * CD track abstraction to communicate TOC entries to the base class.
       
    66  */
       
    67 struct _GstCddaBaseSrcTrack {
       
    68   gboolean     is_audio;      /* TRUE if this is an audio track             */
       
    69   guint        num;           /* real track number (usually starts from 1)  */
       
    70   guint        start;         /* first sector of track (LBA, not LSN!)      */
       
    71   guint        end;           /* last sector of track  (LBA, not LSN!)      */
       
    72   GstTagList  *tags;          /* NULL or tags for track (e.g. from cd-text) */
       
    73 
       
    74   /*< private >*/
       
    75   guint        _gst_reserved1[GST_PADDING/2];
       
    76   gpointer     _gst_reserved2[GST_PADDING/2];
       
    77 };
       
    78 
       
    79 struct _GstCddaBaseSrc {
       
    80   GstPushSrc            pushsrc;
       
    81 
       
    82   /*< protected >*/ /* for use by sub-classes only */
       
    83   GstTagList           *tags;            /* tags that apply to all tracks   */
       
    84 
       
    85   /*< private >*/
       
    86   GstCddaBaseSrcMode    mode;
       
    87 
       
    88   gchar                *device;
       
    89 
       
    90   guint                 num_tracks;
       
    91   guint                 num_all_tracks;
       
    92   GstCddaBaseSrcTrack  *tracks;
       
    93 
       
    94   gint                  cur_track;       /* current track (starting from 0) */
       
    95   gint                  prev_track;      /* current track last time         */
       
    96   gint                  cur_sector;      /* current sector                  */
       
    97   gint                  seek_sector;     /* -1 or sector to seek to         */
       
    98 
       
    99   gint                  uri_track;
       
   100   gchar                *uri;
       
   101 
       
   102   guint32               discid;          /* cddb disc id (for unit test)    */
       
   103   gchar                 mb_discid[32];   /* musicbrainz discid              */
       
   104 
       
   105   GstIndex             *index;
       
   106   gint                  index_id;
       
   107 
       
   108   gint                  toc_offset;
       
   109   gboolean              toc_bias;
       
   110 
       
   111   /*< private >*/
       
   112   guint                 _gst_reserved1[GST_PADDING/2];
       
   113   gpointer              _gst_reserved2[GST_PADDING/2];
       
   114 };
       
   115 
       
   116 struct _GstCddaBaseSrcClass {
       
   117   GstPushSrcClass pushsrc_class;
       
   118 
       
   119   /* open/close the CD device */
       
   120   gboolean    (*open)               (GstCddaBaseSrc *src, const gchar *device);
       
   121   void        (*close)              (GstCddaBaseSrc *src);
       
   122 
       
   123   /* read one sector (LBA) */
       
   124   GstBuffer * (*read_sector)        (GstCddaBaseSrc *src, gint sector);
       
   125 
       
   126   /* return default device or NULL (optional) */
       
   127   gchar *     (*get_default_device) (GstCddaBaseSrc *src);
       
   128 
       
   129   /* return NULL-terminated string array of CD devices, or NULL (optional) */
       
   130   gchar **    (*probe_devices)      (GstCddaBaseSrc *src);
       
   131 
       
   132   /*< private >*/
       
   133   gpointer       _gst_reserved[GST_PADDING];
       
   134 };
       
   135 #ifdef __SYMBIAN32__
       
   136 IMPORT_C
       
   137 #endif
       
   138 
       
   139 
       
   140 GType    gst_cdda_base_src_get_type (void);
       
   141 #ifdef __SYMBIAN32__
       
   142 IMPORT_C
       
   143 #endif
       
   144 
       
   145 
       
   146 gboolean gst_cdda_base_src_add_track (GstCddaBaseSrc      * src,
       
   147                                       GstCddaBaseSrcTrack * track);
       
   148 
       
   149 #if 0
       
   150 /*
       
   151  * GST_TAG_CDDA_TRACK_TAGS:
       
   152  *
       
   153  * Tag details for all available tracks
       
   154  * FiXME: find out which type we want for this!
       
   155  */
       
   156 #define GST_TAG_CDDA_TRACK_TAGS               "track-tags"
       
   157 #endif
       
   158 
       
   159 G_END_DECLS
       
   160 
       
   161 #endif /* __GST_CDDA_BASE_SRC_H__ */
       
   162