2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-22 23:43:34 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* Library <2001> Thomas Vander Stichele <thomas@apestaart.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2004-02-27 21:47:49 +00:00
|
|
|
#ifndef __GST_AUDIO_AUDIO_H__
|
|
|
|
#define __GST_AUDIO_AUDIO_H__
|
|
|
|
|
2003-07-19 23:47:42 +00:00
|
|
|
G_BEGIN_DECLS
|
2004-03-15 16:32:55 +00:00
|
|
|
|
2002-09-09 08:39:58 +00:00
|
|
|
/* For people that are looking at this source: the purpose of these defines is
|
2001-12-22 23:43:34 +00:00
|
|
|
* to make GstCaps a bit easier, in that you don't have to know all of the
|
|
|
|
* properties that need to be defined. you can just use these macros. currently
|
|
|
|
* (8/01) the only plugins that use these are the passthrough, speed, volume,
|
2003-07-19 23:47:42 +00:00
|
|
|
* adder, and [de]interleave plugins. These are for convenience only, and do not
|
|
|
|
* specify the 'limits' of GStreamer. you might also use these definitions as a
|
2001-12-22 23:43:34 +00:00
|
|
|
* base for making your own caps, if need be.
|
|
|
|
*
|
2003-07-19 23:47:42 +00:00
|
|
|
* For example, to make a source pad that can output streams of either mono
|
|
|
|
* float or any channel int:
|
|
|
|
*
|
|
|
|
* template = gst_pad_template_new
|
|
|
|
* ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
|
|
|
|
* gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int",
|
|
|
|
* GST_AUDIO_INT_PAD_TEMPLATE_PROPS),
|
|
|
|
* gst_caps_new ("sink_float", "audio/x-raw-float",
|
|
|
|
* GST_AUDIO_FLOAT_PAD_TEMPLATE_PROPS)),
|
|
|
|
* NULL);
|
|
|
|
*
|
|
|
|
* sinkpad = gst_pad_new_from_template(template, "sink");
|
|
|
|
*
|
|
|
|
* Andy Wingo, 18 August 2001
|
2002-09-09 08:39:58 +00:00
|
|
|
* Thomas, 6 September 2002 */
|
2004-03-15 16:32:55 +00:00
|
|
|
|
2005-09-23 18:14:54 +00:00
|
|
|
/* conversion macros */
|
2007-02-15 15:17:23 +00:00
|
|
|
/**
|
|
|
|
* GST_FRAMES_TO_CLOCK_TIME:
|
|
|
|
* @frames: sample frames
|
|
|
|
* @rate: sampling rate
|
|
|
|
*
|
|
|
|
* Calculate clocktime from sample @frames and @rate.
|
|
|
|
*/
|
2005-09-23 18:14:54 +00:00
|
|
|
#define GST_FRAMES_TO_CLOCK_TIME(frames, rate) \
|
2010-01-19 08:25:35 +00:00
|
|
|
((GstClockTime) gst_util_uint64_scale_round (frames, GST_SECOND, rate))
|
2005-09-23 18:14:54 +00:00
|
|
|
|
2007-02-15 15:17:23 +00:00
|
|
|
/**
|
|
|
|
* GST_CLOCK_TIME_TO_FRAMES:
|
|
|
|
* @clocktime: clock time
|
|
|
|
* @rate: sampling rate
|
|
|
|
*
|
|
|
|
* Calculate frames from @clocktime and sample @rate.
|
|
|
|
*/
|
2005-09-23 18:14:54 +00:00
|
|
|
#define GST_CLOCK_TIME_TO_FRAMES(clocktime, rate) \
|
2010-01-19 08:25:35 +00:00
|
|
|
gst_util_uint64_scale_round (clocktime, rate, GST_SECOND)
|
2005-09-23 18:14:54 +00:00
|
|
|
|
2007-02-15 15:17:23 +00:00
|
|
|
/**
|
|
|
|
* GST_AUDIO_DEF_RATE:
|
|
|
|
*
|
|
|
|
* Standard sampling rate used in consumer audio.
|
|
|
|
*/
|
2003-07-19 23:47:42 +00:00
|
|
|
#define GST_AUDIO_DEF_RATE 44100
|
2004-03-15 16:32:55 +00:00
|
|
|
|
2008-08-11 08:34:56 +00:00
|
|
|
/**
|
|
|
|
* GST_AUDIO_INT_PAD_TEMPLATE_CAPS:
|
|
|
|
*
|
|
|
|
* Template caps for integer audio. Can be used when defining a
|
|
|
|
* #GstStaticPadTemplate
|
|
|
|
*/
|
2003-12-22 01:47:09 +00:00
|
|
|
#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
|
|
|
|
"audio/x-raw-int, " \
|
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"channels = (int) [ 1, MAX ], " \
|
|
|
|
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
|
2004-05-10 23:55:17 +00:00
|
|
|
"width = (int) { 8, 16, 24, 32 }, " \
|
2003-12-22 01:47:09 +00:00
|
|
|
"depth = (int) [ 1, 32 ], " \
|
2005-07-10 12:03:58 +00:00
|
|
|
"signed = (boolean) { true, false }"
|
2004-03-15 16:32:55 +00:00
|
|
|
|
2008-08-11 08:34:56 +00:00
|
|
|
/**
|
|
|
|
* GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS:
|
|
|
|
*
|
|
|
|
* Template caps for 16bit integer stereo audio in native byte-order.
|
|
|
|
* Can be used when defining a #GstStaticPadTemplate
|
|
|
|
*/
|
2003-12-22 01:47:09 +00:00
|
|
|
#define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS \
|
|
|
|
"audio/x-raw-int, " \
|
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"channels = (int) 2, " \
|
|
|
|
"endianness = (int) BYTE_ORDER, " \
|
|
|
|
"width = (int) 16, " \
|
|
|
|
"depth = (int) 16, " \
|
2005-07-10 12:03:58 +00:00
|
|
|
"signed = (boolean) true"
|
2004-03-15 16:32:55 +00:00
|
|
|
|
2008-08-11 08:34:56 +00:00
|
|
|
/**
|
|
|
|
* GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS:
|
|
|
|
*
|
|
|
|
* Template caps for float audio. Can be used when defining a
|
|
|
|
* #GstStaticPadTemplate
|
|
|
|
*/
|
2003-12-22 01:47:09 +00:00
|
|
|
#define GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS \
|
|
|
|
"audio/x-raw-float, " \
|
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"channels = (int) [ 1, MAX ], " \
|
|
|
|
"endianness = (int) { LITTLE_ENDIAN , BIG_ENDIAN }, " \
|
2005-10-19 17:02:46 +00:00
|
|
|
"width = (int) { 32, 64 }"
|
2004-03-15 16:32:55 +00:00
|
|
|
|
2008-08-11 08:34:56 +00:00
|
|
|
/**
|
|
|
|
* GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS:
|
|
|
|
*
|
|
|
|
* Template caps for 32bit float mono audio in native byte-order.
|
|
|
|
* Can be used when defining a #GstStaticPadTemplate
|
|
|
|
*/
|
2003-12-22 01:47:09 +00:00
|
|
|
#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS \
|
|
|
|
"audio/x-raw-float, " \
|
2004-11-09 06:08:22 +00:00
|
|
|
"width = (int) 32, " \
|
2003-12-22 01:47:09 +00:00
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"channels = (int) 1, " \
|
2005-10-19 17:02:46 +00:00
|
|
|
"endianness = (int) BYTE_ORDER"
|
2004-03-15 16:32:55 +00:00
|
|
|
|
2001-12-22 23:43:34 +00:00
|
|
|
/*
|
|
|
|
* this library defines and implements some helper functions for audio
|
|
|
|
* handling
|
|
|
|
*/
|
2004-03-15 16:32:55 +00:00
|
|
|
|
2001-12-22 23:43:34 +00:00
|
|
|
/* get byte size of audio frame (based on caps of pad */
|
2004-03-15 16:32:55 +00:00
|
|
|
int gst_audio_frame_byte_size (GstPad* pad);
|
2001-12-22 23:43:34 +00:00
|
|
|
|
|
|
|
/* get length in frames of buffer */
|
2004-03-15 16:32:55 +00:00
|
|
|
long gst_audio_frame_length (GstPad* pad, GstBuffer* buf);
|
2001-12-22 23:43:34 +00:00
|
|
|
|
2005-11-21 23:51:45 +00:00
|
|
|
GstClockTime gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf);
|
2005-11-21 22:56:33 +00:00
|
|
|
|
2001-12-22 23:43:34 +00:00
|
|
|
/* check if the buffer size is a whole multiple of the frame size */
|
2004-03-15 16:32:55 +00:00
|
|
|
gboolean gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf);
|
2001-12-22 23:43:34 +00:00
|
|
|
|
2004-01-12 19:35:54 +00:00
|
|
|
/* functions useful for _getcaps functions */
|
2007-02-15 15:17:23 +00:00
|
|
|
/**
|
|
|
|
* GstAudioFieldFlag:
|
|
|
|
*
|
|
|
|
* Do not use anymore.
|
2007-10-31 12:47:41 +00:00
|
|
|
*
|
|
|
|
* Deprecated: use gst_structure_set() directly
|
2007-02-15 15:17:23 +00:00
|
|
|
*/
|
2007-11-01 08:06:13 +00:00
|
|
|
#ifndef GST_DISABLE_DEPRECATED
|
2004-03-15 16:32:55 +00:00
|
|
|
typedef enum {
|
|
|
|
GST_AUDIO_FIELD_RATE = (1 << 0),
|
|
|
|
GST_AUDIO_FIELD_CHANNELS = (1 << 1),
|
|
|
|
GST_AUDIO_FIELD_ENDIANNESS = (1 << 2),
|
|
|
|
GST_AUDIO_FIELD_WIDTH = (1 << 3),
|
|
|
|
GST_AUDIO_FIELD_DEPTH = (1 << 4),
|
2008-09-13 11:04:02 +00:00
|
|
|
GST_AUDIO_FIELD_SIGNED = (1 << 5)
|
2004-01-12 19:35:54 +00:00
|
|
|
} GstAudioFieldFlag;
|
2007-11-01 08:06:13 +00:00
|
|
|
#endif
|
2004-01-12 19:35:54 +00:00
|
|
|
|
2007-07-23 18:26:09 +00:00
|
|
|
#ifndef GST_DISABLE_DEPRECATED
|
2004-03-15 16:32:55 +00:00
|
|
|
void gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag);
|
2007-07-23 18:26:09 +00:00
|
|
|
#endif /* GST_DISABLE_DEPRECATED */
|
|
|
|
|
|
|
|
GstBuffer *gst_audio_buffer_clip (GstBuffer *buffer, GstSegment *segment, gint rate, gint frame_size);
|
2004-01-12 19:35:54 +00:00
|
|
|
|
2003-07-19 23:47:42 +00:00
|
|
|
G_END_DECLS
|
2004-03-15 16:32:55 +00:00
|
|
|
|
2004-02-27 21:47:49 +00:00
|
|
|
#endif /* __GST_AUDIO_AUDIO_H__ */
|