Debian Codegraph @

gstreamer/src/audiocdsrc.hg

raw
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2016 The gstreamermm Development Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 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 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <gst/audio/gstaudiocdsrc.h>
21 #include <gstreamermm/pushsrc.h>
22 #include <gstreamermm/taglist.h>
23 #include <glibmm/arrayhandle.h>
24
25 _DEFS(gstreamermm,gst)
26
27 namespace Gst
28 {
29
30 _WRAP_ENUM(AudioCdSrcMode,GstAudioCdSrcMode)
31
32 /** A base class for CD digital audio (CDDA) sources, which handles
33 * things like seeking, querying, discid calculation, tags, and buffer
34 * timestamping.
35 *
36 * Gst::AudioCdSrc registers two Gst::Formats of its own, namely the
37 * "track" format and the "sector" format. Applications will usually only find
38 * the "track" format interesting. You can retrieve that Gst::Format for use in
39 * seek events or queries with Gst::get_format("track").
40 *
41 * In order to query the number of tracks, for example, an application would
42 * set the CDDA source element to READY or PAUSED state and then query the the
43 * number of tracks via Gst::Element::query_duration() using the track format
44 * acquired above. Applications can query the currently playing track in the
45 * same way.
46 *
47 * Alternatively, applications may retrieve the currently playing track and the
48 * total number of tracks from the taglist that will be posted on the bus
49 * whenever the CD is opened or the currently playing track changes. The
50 * taglist will contain Gst::TAG_TRACK_NUMBER and Gst::TAG_TRACK_COUNT tags.
51 *
52 * Applications playing back CD audio using playbin and cdda://n URIs should
53 * issue a seek command in track format to change between tracks, rather than
54 * setting a new cdda://n+1 URI on playbin (as setting a new URI on playbin
55 * involves closing and re-opening the CD device, which is much much slower).
56 *
57 * CDDA sources will automatically emit a number of tags, details about which
58 * can be found in the libgsttag documentation. Those tags are:
59 * Gst::TAG_CDDA_CDDB_DISCID, Gst::TAG_CDDA_CDDB_DISCID_FULL,
60 * Gst::TAG_CDDA_MUSICBRAINZ_DISCID, Gst::TAG_CDDA_MUSICBRAINZ_DISCID_FULL,
61 * among others.
62 *
63 * Applications will be informed of the available tracks via a TOC message
64 * on the pipeline's Gst::Bus. The Gst::Toc will contain a Gst::TocEntry for
65 * each track, with information about each track. The duration for each
66 * track can be retrieved via the Gst::TAG_DURATION tag from each entry's
67 * tag list, or calculated via Gst::TocEntry::get_start_stop_times().
68 * The track entries in the TOC will be sorted by track number.
69 *
70 * Last reviewed on 2016-05-16 (1.8.0)
71 *
72 * @ingroup GstBaseClasses
73 */
74 class AudioCdSrc : public Gst::PushSrc
75 {
76 _CLASS_GOBJECT(AudioCdSrc, GstAudioCdSrc, GST_AUDIO_CD_SRC, Gst::PushSrc, GstPushSrc)
77
78 public:
79 /** CDDA sources use this function from their start vfunc to announce the
80 * available data and audio tracks to the base source class.
81 *
82 * @param num Track number in TOC (usually starts from 1, but not always).
83 * @param start The first sector of the track (LBA).
84 * @param end The last sector of the track (LBA).
85 * @param is_audio Whether this is an audio track.
86 * @param tags Track-specific tags (e.g. from cd-text information).
87 * @return false on error, otherwise true.
88 */
89 bool add_track(guint num, guint start, guint end, bool is_audio = true,
90 const Gst::TagList& tags = Gst::TagList());
91 _IGNORE(gst_audio_cd_src_add_track)
92
93 _WRAP_PROPERTY("device", std::string)
94 _WRAP_PROPERTY("mode", AudioCdSrcMode)
95 _WRAP_PROPERTY("track", guint)
96
97 /** Virtual function to open a CD device.
98 */
99 _WRAP_VFUNC(bool open(const std::string& device), "open")
100
101 /** Virtual function to close the device.
102 */
103 _WRAP_VFUNC(void close(), "close")
104
105 /** Virtual function to read one sector (LBA).
106 */
107 _WRAP_VFUNC(Glib::RefPtr<Gst::Buffer> read_sector(gint sector), "read_sector")
108 };
109
110 } // namespace Gst