/* gstreamermm - a C++ wrapper for gstreamer * * Copyright 2008-2016 The gstreamermm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include _DEFS(gstreamermm,gst) namespace Gst { /** A simple base class for audio sinks. * This is the most simple base class for audio sinks that only requires * subclasses to implement a set of simple virtual functions: * * - open_vfunc() - Open the device. * - prepare_vfunc() - Configure the device with the specified format. * - write_vfunc() - Write samples to the device. * - reset_vfunc() - Unblock writes and flush the device. * - get_delay_vfunc() - Get the number of samples written but not yet played * by the device. * - unprepare_vfunc() - Undo operations done by prepare. * - close_vfunc() - Close the device. * * All scheduling of samples and timestamps is done in this base class together * with Gst::AudioBaseSink using a default implementation of a * Gst::AudioRingBuffer that uses threads. * * Last reviewed on 2016-04-23 (1.8.0) * * @ingroup GstBaseClasses */ class AudioSink : public Gst::AudioBaseSink { _CLASS_GOBJECT(AudioSink, GstAudioSink, GST_AUDIO_SINK, Gst::AudioBaseSink, GstAudioBaseSink) public: /** vfunc to open the device. No configuration needs to be done at this * point. This function is also used to check if the device is available. */ _WRAP_VFUNC(bool open(), "open") /** vfunc to prepare the device to operate with the specified parameters. */ virtual bool prepare_audiosink_vfunc(Gst::AudioRingBufferSpec& spec); /** vfunc to undo operations done in prepare. */ _WRAP_VFUNC(bool unprepare(), "unprepare") /** vfunc to close the device. */ _WRAP_VFUNC(bool close(), "close") /** vfunc to write data to the device. */ _WRAP_VFUNC(int write(gpointer data, guint lenght), "write") /** vfunc to return how many samples are still in the device. This is used to * drive the synchronisation. */ _WRAP_VFUNC(guint get_delay() const, "delay") /** vfunc to return as quickly as possible from a write and flush any pending * samples from the device. */ _WRAP_VFUNC(void reset(), "reset") protected: #m4begin _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS) klass->prepare = &prepare_audiosink_vfunc_callback; _SECTION(SECTION_PH_VFUNCS) static gboolean prepare_audiosink_vfunc_callback(GstAudioSink* self, GstAudioRingBufferSpec* spec); _POP() #m4end }; } // namespace Gst