2002-01-19 15:02:09 +00:00
|
|
|
/* GStreamer
|
2003-03-03 22:17:28 +00:00
|
|
|
* Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* PCM - A-Law conversion
|
|
|
|
* Copyright (C) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
2001-12-22 23:27:31 +00:00
|
|
|
*
|
|
|
|
* 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
|
2003-03-03 22:17:28 +00:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2001-12-22 23:27:31 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-11-06 22:14:17 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-22 23:27:31 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include "alaw-encode.h"
|
|
|
|
|
|
|
|
extern GstPadTemplate *alawenc_src_template, *alawenc_sink_template;
|
|
|
|
|
|
|
|
/* Stereo signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-22 23:27:31 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-22 23:27:31 +00:00
|
|
|
ARG_0
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_alawenc_class_init (GstALawEncClass * klass);
|
|
|
|
static void gst_alawenc_base_init (GstALawEncClass * klass);
|
|
|
|
static void gst_alawenc_init (GstALawEnc * alawenc);
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_alawenc_chain (GstPad * pad, GstData * _data);
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2003-03-03 22:17:28 +00:00
|
|
|
/*
|
|
|
|
* s16_to_alaw() - Convert a 16-bit linear PCM value to 8-bit A-law
|
|
|
|
*
|
|
|
|
* s16_to_alaw() accepts an 16-bit integer and encodes it as A-law data.
|
|
|
|
*
|
|
|
|
* Linear Input Code Compressed Code
|
|
|
|
* ------------------------ ---------------
|
|
|
|
* 0000000wxyza 000wxyz
|
|
|
|
* 0000001wxyza 001wxyz
|
|
|
|
* 000001wxyzab 010wxyz
|
|
|
|
* 00001wxyzabc 011wxyz
|
|
|
|
* 0001wxyzabcd 100wxyz
|
|
|
|
* 001wxyzabcde 101wxyz
|
|
|
|
* 01wxyzabcdef 110wxyz
|
|
|
|
* 1wxyzabcdefg 111wxyz
|
|
|
|
*
|
|
|
|
* For further information see John C. Bellamy's Digital Telephony, 1982,
|
|
|
|
* John Wiley & Sons, pps 98-111 and 472-476.
|
|
|
|
*/
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static inline gint
|
|
|
|
val_seg (gint val)
|
2003-03-03 22:17:28 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
gint r = 1;
|
|
|
|
|
|
|
|
val >>= 8;
|
|
|
|
if (val & 0xf0) {
|
|
|
|
val >>= 4;
|
|
|
|
r += 4;
|
|
|
|
}
|
|
|
|
if (val & 0x0c) {
|
|
|
|
val >>= 2;
|
|
|
|
r += 2;
|
|
|
|
}
|
|
|
|
if (val & 0x02)
|
|
|
|
r += 1;
|
|
|
|
return r;
|
2003-03-03 22:17:28 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static guint8
|
|
|
|
s16_to_alaw (gint pcm_val)
|
2003-03-03 22:17:28 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
gint seg;
|
|
|
|
guint8 mask;
|
|
|
|
guint8 aval;
|
|
|
|
|
|
|
|
if (pcm_val >= 0) {
|
|
|
|
mask = 0xD5;
|
|
|
|
} else {
|
|
|
|
mask = 0x55;
|
|
|
|
pcm_val = -pcm_val;
|
|
|
|
if (pcm_val > 0x7fff)
|
|
|
|
pcm_val = 0x7fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pcm_val < 256)
|
|
|
|
aval = pcm_val >> 4;
|
|
|
|
else {
|
|
|
|
/* Convert the scaled magnitude to segment number. */
|
|
|
|
seg = val_seg (pcm_val);
|
|
|
|
aval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0x0f);
|
|
|
|
}
|
|
|
|
return aval ^ mask;
|
2003-03-03 22:17:28 +00:00
|
|
|
}
|
2001-12-22 23:27:31 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-01-19 15:02:09 +00:00
|
|
|
/*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-22 23:27:31 +00:00
|
|
|
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
static GstCaps *
|
|
|
|
alawenc_getcaps (GstPad * pad)
|
|
|
|
{
|
|
|
|
GstALawEnc *alawenc = GST_ALAWENC (gst_pad_get_parent (pad));
|
|
|
|
GstPad *otherpad;
|
|
|
|
GstCaps *base_caps, *othercaps;
|
|
|
|
GstStructure *structure;
|
|
|
|
const GValue *rate, *chans;
|
|
|
|
|
|
|
|
if (pad == alawenc->srcpad) {
|
|
|
|
otherpad = alawenc->sinkpad;
|
2004-05-09 22:56:56 +00:00
|
|
|
base_caps = gst_caps_new_simple ("audio/x-alaw", NULL);
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
} else {
|
|
|
|
otherpad = alawenc->srcpad;
|
|
|
|
base_caps = gst_caps_new_simple ("audio/x-raw-int",
|
|
|
|
"width", G_TYPE_INT, 16, "depth", G_TYPE_INT, 16,
|
|
|
|
"endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
|
|
|
|
}
|
|
|
|
othercaps = gst_pad_get_allowed_caps (otherpad);
|
|
|
|
|
|
|
|
/* Not fully correct, but usually, all structures in a caps have
|
|
|
|
* the same samplerate and channels range. */
|
|
|
|
structure = gst_caps_get_structure (othercaps, 0);
|
|
|
|
rate = gst_structure_get_value (structure, "rate");
|
|
|
|
chans = gst_structure_get_value (structure, "channels");
|
|
|
|
if (!rate || !chans)
|
|
|
|
return gst_caps_new_empty ();
|
|
|
|
|
|
|
|
/* Set the samplerate/channels on the to-be-returned caps */
|
|
|
|
structure = gst_caps_get_structure (base_caps, 0);
|
|
|
|
gst_structure_set_value (structure, "rate", rate);
|
|
|
|
gst_structure_set_value (structure, "channels", chans);
|
|
|
|
gst_caps_free (othercaps);
|
|
|
|
|
|
|
|
return base_caps;
|
|
|
|
}
|
|
|
|
|
2003-03-03 22:17:28 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
alawenc_link (GstPad * pad, const GstCaps * caps)
|
2001-12-22 23:27:31 +00:00
|
|
|
{
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
GstALawEnc *alawenc = GST_ALAWENC (gst_pad_get_parent (pad));
|
|
|
|
GstPad *otherpad;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
const GValue *rate, *chans;
|
|
|
|
GstCaps *base_caps;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
rate = gst_structure_get_value (structure, "rate");
|
|
|
|
chans = gst_structure_get_value (structure, "channels");
|
|
|
|
if (!rate || !chans)
|
2004-03-14 22:34:33 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
if (pad == alawenc->sinkpad) {
|
|
|
|
otherpad = alawenc->srcpad;
|
2004-05-09 22:56:56 +00:00
|
|
|
base_caps = gst_caps_new_simple ("audio/x-alaw", NULL);
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
} else {
|
|
|
|
otherpad = alawenc->sinkpad;
|
|
|
|
base_caps = gst_caps_new_simple ("audio/x-raw-int",
|
|
|
|
"width", G_TYPE_INT, 16, "depth", G_TYPE_INT, 16,
|
|
|
|
"endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure (base_caps, 0);
|
|
|
|
gst_structure_set_value (structure, "rate", rate);
|
|
|
|
gst_structure_set_value (structure, "channels", chans);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
return gst_pad_try_set_caps (otherpad, base_caps);
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2001-12-22 23:27:31 +00:00
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_alawenc_get_type (void)
|
|
|
|
{
|
2001-12-22 23:27:31 +00:00
|
|
|
static GType alawenc_type = 0;
|
|
|
|
|
|
|
|
if (!alawenc_type) {
|
|
|
|
static const GTypeInfo alawenc_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstALawEncClass),
|
|
|
|
(GBaseInitFunc) gst_alawenc_base_init,
|
2001-12-22 23:27:31 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GClassInitFunc) gst_alawenc_class_init,
|
2001-12-22 23:27:31 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstALawEnc),
|
2001-12-22 23:27:31 +00:00
|
|
|
0,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GInstanceInitFunc) gst_alawenc_init,
|
2001-12-22 23:27:31 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
alawenc_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstALawEnc", &alawenc_info,
|
|
|
|
0);
|
2001-12-22 23:27:31 +00:00
|
|
|
}
|
|
|
|
return alawenc_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 18:13:24 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_alawenc_base_init (GstALawEncClass * klass)
|
2003-11-02 18:13:24 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
GstElementDetails alawenc_details = {
|
|
|
|
"PCM to A Law conversion",
|
|
|
|
"Codec/Encoder/Audio",
|
|
|
|
"Convert 16bit PCM to 8bit A law",
|
|
|
|
"Zaheer Merali <zaheer@bellworldwide.net>"
|
|
|
|
};
|
2003-11-02 18:13:24 +00:00
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class, alawenc_src_template);
|
|
|
|
gst_element_class_add_pad_template (element_class, alawenc_sink_template);
|
|
|
|
gst_element_class_set_details (element_class, &alawenc_details);
|
|
|
|
}
|
|
|
|
|
2001-12-22 23:27:31 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_alawenc_class_init (GstALawEncClass * klass)
|
2001-12-22 23:27:31 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2001-12-22 23:27:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_alawenc_init (GstALawEnc * alawenc)
|
2001-12-22 23:27:31 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
alawenc->sinkpad = gst_pad_new_from_template (alawenc_sink_template, "sink");
|
2003-03-03 22:17:28 +00:00
|
|
|
gst_pad_set_link_function (alawenc->sinkpad, alawenc_link);
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
gst_pad_set_getcaps_function (alawenc->sinkpad, alawenc_getcaps);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_set_chain_function (alawenc->sinkpad, gst_alawenc_chain);
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (alawenc), alawenc->sinkpad);
|
|
|
|
|
|
|
|
alawenc->srcpad = gst_pad_new_from_template (alawenc_src_template, "src");
|
|
|
|
gst_pad_set_link_function (alawenc->srcpad, alawenc_link);
|
|
|
|
gst_pad_set_getcaps_function (alawenc->srcpad, alawenc_getcaps);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (alawenc), alawenc->srcpad);
|
2001-12-22 23:27:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_alawenc_chain (GstPad * pad, GstData * _data)
|
2001-12-22 23:27:31 +00:00
|
|
|
{
|
2003-10-08 16:08:18 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
2001-12-22 23:27:31 +00:00
|
|
|
GstALawEnc *alawenc;
|
|
|
|
gint16 *linear_data;
|
|
|
|
guint8 *alaw_data;
|
2004-03-14 22:34:33 +00:00
|
|
|
GstBuffer *outbuf;
|
2003-03-03 22:17:28 +00:00
|
|
|
gint i;
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
|
|
|
g_return_if_fail (buf != NULL);
|
|
|
|
|
|
|
|
alawenc = GST_ALAWENC (GST_OBJECT_PARENT (pad));
|
|
|
|
g_return_if_fail (alawenc != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ALAWENC (alawenc));
|
2001-12-22 23:27:31 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
linear_data = (gint16 *) GST_BUFFER_DATA (buf);
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buf) / 2);
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
|
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
|
2004-03-14 22:34:33 +00:00
|
|
|
alaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < GST_BUFFER_SIZE (outbuf); i++) {
|
2003-03-03 22:17:28 +00:00
|
|
|
*alaw_data = s16_to_alaw (*linear_data);
|
2003-03-24 04:06:08 +00:00
|
|
|
alaw_data++;
|
|
|
|
linear_data++;
|
2003-03-03 22:17:28 +00:00
|
|
|
}
|
gst/law/: Fix capsnego in all four, remove the unused property functions and simplify the chain functions slightly. I...
Original commit message from CVS:
* gst/law/alaw-decode.c: (alawdec_getcaps), (alawdec_link),
(gst_alawdec_base_init), (gst_alawdec_class_init),
(gst_alawdec_init), (gst_alawdec_chain):
* gst/law/alaw-encode.c: (alawenc_getcaps), (alawenc_link),
(gst_alawenc_base_init), (gst_alawenc_class_init),
(gst_alawenc_init), (gst_alawenc_chain):
* gst/law/mulaw-decode.c: (mulawdec_getcaps), (mulawdec_link),
(gst_mulawdec_base_init), (gst_mulawdec_class_init),
(gst_mulawdec_init), (gst_mulawdec_chain):
* gst/law/mulaw-encode.c: (mulawenc_getcaps), (mulawenc_link),
(gst_mulawenc_base_init), (gst_mulawenc_class_init),
(gst_mulawenc_init), (gst_mulawenc_chain):
Fix capsnego in all four, remove the unused property functions and
simplify the chain functions slightly. I guess we could use macros
or something similar for those, since the code is so similar, but
I'm currently too lazy...
2004-03-26 01:56:11 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
gst_pad_push (alawenc->srcpad, GST_DATA (outbuf));
|
2001-12-22 23:27:31 +00:00
|
|
|
}
|