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>
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
#include <gst/audio/audioclock.h>
|
|
|
|
|
2003-07-19 23:47:42 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
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 */
|
|
|
|
|
2003-07-19 23:47:42 +00:00
|
|
|
#define GST_AUDIO_DEF_RATE 44100
|
2001-12-22 23:43:34 +00:00
|
|
|
|
|
|
|
#define GST_AUDIO_INT_PAD_TEMPLATE_PROPS \
|
2003-07-19 23:47:42 +00:00
|
|
|
gst_props_new (\
|
|
|
|
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
|
|
|
|
"channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\
|
|
|
|
"endianness", GST_PROPS_LIST (\
|
|
|
|
GST_PROPS_INT (G_LITTLE_ENDIAN),\
|
|
|
|
GST_PROPS_INT (G_BIG_ENDIAN)\
|
|
|
|
),\
|
|
|
|
"width", GST_PROPS_LIST (\
|
|
|
|
GST_PROPS_INT (8),\
|
|
|
|
GST_PROPS_INT (16),\
|
|
|
|
GST_PROPS_INT (32)\
|
|
|
|
),\
|
|
|
|
"depth", GST_PROPS_INT_RANGE (1, 32),\
|
|
|
|
"signed", GST_PROPS_LIST (\
|
|
|
|
GST_PROPS_BOOLEAN (TRUE),\
|
|
|
|
GST_PROPS_BOOLEAN (FALSE)\
|
|
|
|
),\
|
2003-11-16 22:04:16 +00:00
|
|
|
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
|
2003-07-19 23:47:42 +00:00
|
|
|
NULL)
|
2001-12-22 23:43:34 +00:00
|
|
|
|
2003-11-16 22:04:16 +00:00
|
|
|
/* "standard" int audio is native order, 16 bit stereo. */
|
|
|
|
#define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_PROPS \
|
2003-07-19 23:47:42 +00:00
|
|
|
gst_props_new (\
|
|
|
|
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
|
2003-11-16 22:04:16 +00:00
|
|
|
"channels", GST_PROPS_INT (2),\
|
|
|
|
"endianness", GST_PROPS_INT (G_BYTE_ORDER),\
|
|
|
|
"width", GST_PROPS_INT (16),\
|
|
|
|
"depth", GST_PROPS_INT (16),\
|
2003-07-19 23:47:42 +00:00
|
|
|
"signed", GST_PROPS_LIST (\
|
|
|
|
GST_PROPS_BOOLEAN (TRUE),\
|
|
|
|
GST_PROPS_BOOLEAN (FALSE)\
|
|
|
|
),\
|
2003-11-16 22:04:16 +00:00
|
|
|
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
|
2003-07-19 23:47:42 +00:00
|
|
|
NULL)
|
|
|
|
|
|
|
|
#define GST_AUDIO_FLOAT_PAD_TEMPLATE_PROPS \
|
|
|
|
gst_props_new (\
|
|
|
|
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
|
|
|
|
"channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\
|
|
|
|
"endianness", GST_PROPS_LIST (\
|
|
|
|
GST_PROPS_INT (G_LITTLE_ENDIAN),\
|
|
|
|
GST_PROPS_INT (G_BIG_ENDIAN)\
|
|
|
|
),\
|
|
|
|
"width", GST_PROPS_LIST (\
|
|
|
|
GST_PROPS_INT (32),\
|
|
|
|
GST_PROPS_INT (64)\
|
|
|
|
),\
|
|
|
|
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
|
|
|
|
NULL)
|
|
|
|
|
2003-11-16 22:04:16 +00:00
|
|
|
/* "standard" float audio is native order, 32 bit mono. */
|
2003-07-19 23:47:42 +00:00
|
|
|
#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS \
|
|
|
|
gst_props_new (\
|
|
|
|
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
|
|
|
|
"channels", GST_PROPS_INT (1),\
|
|
|
|
"endianness", GST_PROPS_INT (G_BYTE_ORDER),\
|
|
|
|
"width", GST_PROPS_INT (32),\
|
|
|
|
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
|
|
|
|
NULL)
|
2001-12-22 23:43:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* this library defines and implements some helper functions for audio
|
|
|
|
* handling
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* get byte size of audio frame (based on caps of pad */
|
2003-07-19 23:47:42 +00:00
|
|
|
int gst_audio_frame_byte_size (GstPad* pad);
|
2001-12-22 23:43:34 +00:00
|
|
|
|
|
|
|
/* get length in frames of buffer */
|
2003-07-19 23:47:42 +00:00
|
|
|
long gst_audio_frame_length (GstPad* pad, GstBuffer* buf);
|
2001-12-22 23:43:34 +00:00
|
|
|
|
|
|
|
/* get frame rate based on caps */
|
2003-07-19 23:47:42 +00:00
|
|
|
long gst_audio_frame_rate (GstPad *pad);
|
2001-12-22 23:43:34 +00:00
|
|
|
|
|
|
|
/* calculate length in seconds of audio buffer buf based on caps of pad */
|
2003-07-19 23:47:42 +00:00
|
|
|
double gst_audio_length (GstPad* pad, GstBuffer* buf);
|
2001-12-22 23:43:34 +00:00
|
|
|
|
|
|
|
/* calculate highest possible sample value based on capabilities of pad */
|
2003-07-19 23:47:42 +00:00
|
|
|
long gst_audio_highest_sample_value (GstPad* pad);
|
2001-12-22 23:43:34 +00:00
|
|
|
|
|
|
|
/* check if the buffer size is a whole multiple of the frame size */
|
2003-07-19 23:47:42 +00:00
|
|
|
gboolean gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf);
|
2001-12-22 23:43:34 +00:00
|
|
|
|
2003-07-19 23:47:42 +00:00
|
|
|
G_END_DECLS
|
2001-12-22 23:43:34 +00:00
|
|
|
|