mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
gst/law/: Compulsive clean-ups: use boilerplate macros, add debug categories, fix up things to conform to symbol nome...
Original commit message from CVS: * gst/law/alaw-decode.c: * gst/law/alaw-decode.h: * gst/law/alaw-encode.c: * gst/law/alaw-encode.h: * gst/law/alaw.c: * gst/law/mulaw-conversion.h: Compulsive clean-ups: use boilerplate macros, add debug categories, fix up things to conform to symbol nomenklatura, etc.
This commit is contained in:
parent
89dee84fd7
commit
ab3379a6ac
7 changed files with 169 additions and 189 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2007-09-25 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/law/alaw-decode.c:
|
||||
* gst/law/alaw-decode.h:
|
||||
* gst/law/alaw-encode.c:
|
||||
* gst/law/alaw-encode.h:
|
||||
* gst/law/alaw.c:
|
||||
* gst/law/mulaw-conversion.h:
|
||||
Compulsive clean-ups: use boilerplate macros, add debug
|
||||
categories, fix up things to conform to symbol nomenklatura,
|
||||
etc.
|
||||
|
||||
2007-09-25 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
Based on patch by: Laurent Glayal <spglegle yahoo fr>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
* PCM - A-Law conversion
|
||||
* Copyright (C) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
||||
/* GStreamer A-Law to PCM conversion
|
||||
* Copyright (C) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -22,34 +20,20 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "alaw-decode.h"
|
||||
|
||||
extern GstPadTemplate *alawdec_src_template, *alawdec_sink_template;
|
||||
extern GstPadTemplate *alawdec_src_template;
|
||||
extern GstPadTemplate *alawdec_sink_template;
|
||||
|
||||
/* Stereo signals and args */
|
||||
enum
|
||||
{
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
GST_DEBUG_CATEGORY_STATIC (alaw_dec_debug);
|
||||
#define GST_CAT_DEFAULT alaw_dec_debug
|
||||
|
||||
enum
|
||||
{
|
||||
ARG_0
|
||||
};
|
||||
|
||||
static void gst_alawdec_class_init (GstALawDecClass * klass);
|
||||
static void gst_alawdec_base_init (GstALawDecClass * klass);
|
||||
static void gst_alawdec_init (GstALawDec * alawdec);
|
||||
static GstStateChangeReturn
|
||||
gst_alawdec_change_state (GstElement * element, GstStateChange transition);
|
||||
gst_alaw_dec_change_state (GstElement * element, GstStateChange transition);
|
||||
static GstFlowReturn gst_alaw_dec_chain (GstPad * pad, GstBuffer * buffer);
|
||||
|
||||
static GstFlowReturn gst_alawdec_chain (GstPad * pad, GstBuffer * buffer);
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
/*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */
|
||||
GST_BOILERPLATE (GstALawDec, gst_alaw_dec, GstElement, GST_TYPE_ELEMENT);
|
||||
|
||||
/* some day we might have defines in gstconfig.h that tell us about the
|
||||
* desired cpu/memory/binary size trade-offs */
|
||||
|
@ -121,14 +105,14 @@ alaw_to_s16 (guint8 a_val)
|
|||
#endif /* GST_ALAW_DEC_USE_TABLE */
|
||||
|
||||
static gboolean
|
||||
alawdec_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||
gst_alaw_dec_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||
{
|
||||
GstALawDec *alawdec;
|
||||
GstStructure *structure;
|
||||
int rate, channels;
|
||||
gboolean ret;
|
||||
|
||||
alawdec = GST_ALAWDEC (GST_PAD_PARENT (pad));
|
||||
alawdec = GST_ALAW_DEC (GST_PAD_PARENT (pad));
|
||||
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
ret = gst_structure_get_int (structure, "rate", &rate);
|
||||
|
@ -145,65 +129,42 @@ alawdec_sink_setcaps (GstPad * pad, GstCaps * caps)
|
|||
"signed", G_TYPE_BOOLEAN, TRUE,
|
||||
"rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL);
|
||||
|
||||
GST_DEBUG_OBJECT (alawdec, "rate=%d, channels=%d", rate, channels);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_alawdec_get_type (void)
|
||||
{
|
||||
static GType alawdec_type = 0;
|
||||
|
||||
if (!alawdec_type) {
|
||||
static const GTypeInfo alawdec_info = {
|
||||
sizeof (GstALawDecClass),
|
||||
(GBaseInitFunc) gst_alawdec_base_init,
|
||||
NULL,
|
||||
(GClassInitFunc) gst_alawdec_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GstALawDec),
|
||||
0,
|
||||
(GInstanceInitFunc) gst_alawdec_init,
|
||||
};
|
||||
|
||||
alawdec_type =
|
||||
g_type_register_static (GST_TYPE_ELEMENT, "GstALawDec", &alawdec_info,
|
||||
0);
|
||||
}
|
||||
return alawdec_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_alawdec_base_init (GstALawDecClass * klass)
|
||||
gst_alaw_dec_base_init (gpointer klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
const GstElementDetails alawdec_details =
|
||||
GST_ELEMENT_DETAILS ("A Law audio decoder",
|
||||
"Codec/Decoder/Audio",
|
||||
"Convert 8bit A law to 16bit PCM",
|
||||
"Zaheer Abbas Merali <zaheerabbas at merali dot org>");
|
||||
|
||||
gst_element_class_add_pad_template (element_class, alawdec_src_template);
|
||||
gst_element_class_add_pad_template (element_class, alawdec_sink_template);
|
||||
gst_element_class_set_details (element_class, &alawdec_details);
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "A Law audio decoder",
|
||||
"Codec/Decoder/Audio", "Convert 8bit A law to 16bit PCM",
|
||||
"Zaheer Abbas Merali <zaheerabbas at merali dot org>");
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (alaw_dec_debug, "alawdec", 0, "A Law audio decoder");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_alawdec_class_init (GstALawDecClass * klass)
|
||||
gst_alaw_dec_class_init (GstALawDecClass * klass)
|
||||
{
|
||||
GstElementClass *element_class = (GstElementClass *) klass;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
element_class->change_state = GST_DEBUG_FUNCPTR (gst_alawdec_change_state);
|
||||
element_class->change_state = GST_DEBUG_FUNCPTR (gst_alaw_dec_change_state);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_alawdec_init (GstALawDec * alawdec)
|
||||
gst_alaw_dec_init (GstALawDec * alawdec, GstALawDecClass * klass)
|
||||
{
|
||||
alawdec->sinkpad = gst_pad_new_from_template (alawdec_sink_template, "sink");
|
||||
gst_pad_set_setcaps_function (alawdec->sinkpad, alawdec_sink_setcaps);
|
||||
gst_pad_set_chain_function (alawdec->sinkpad, gst_alawdec_chain);
|
||||
gst_pad_set_setcaps_function (alawdec->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_alaw_dec_sink_setcaps));
|
||||
gst_pad_set_chain_function (alawdec->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_alaw_dec_chain));
|
||||
gst_element_add_pad (GST_ELEMENT (alawdec), alawdec->sinkpad);
|
||||
|
||||
alawdec->srcpad = gst_pad_new_from_template (alawdec_src_template, "src");
|
||||
|
@ -212,7 +173,7 @@ gst_alawdec_init (GstALawDec * alawdec)
|
|||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_alawdec_chain (GstPad * pad, GstBuffer * buffer)
|
||||
gst_alaw_dec_chain (GstPad * pad, GstBuffer * buffer)
|
||||
{
|
||||
GstALawDec *alawdec;
|
||||
gint16 *linear_data;
|
||||
|
@ -222,7 +183,13 @@ gst_alawdec_chain (GstPad * pad, GstBuffer * buffer)
|
|||
gint i;
|
||||
GstFlowReturn ret;
|
||||
|
||||
alawdec = GST_ALAWDEC (gst_pad_get_parent (pad));
|
||||
alawdec = GST_ALAW_DEC (GST_PAD_PARENT (pad));
|
||||
|
||||
if (G_UNLIKELY (alawdec->srccaps == NULL))
|
||||
goto not_negotiated;
|
||||
|
||||
GST_LOG_OBJECT (alawdec, "buffer with ts=%" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
|
||||
|
||||
alaw_data = GST_BUFFER_DATA (buffer);
|
||||
alaw_size = GST_BUFFER_SIZE (buffer);
|
||||
|
@ -241,20 +208,27 @@ gst_alawdec_chain (GstPad * pad, GstBuffer * buffer)
|
|||
for (i = 0; i < alaw_size; i++) {
|
||||
linear_data[i] = alaw_to_s16 (alaw_data[i]);
|
||||
}
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
ret = gst_pad_push (alawdec->srcpad, outbuf);
|
||||
|
||||
gst_object_unref (alawdec);
|
||||
done:
|
||||
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return ret;
|
||||
|
||||
not_negotiated:
|
||||
{
|
||||
ret = GST_FLOW_NOT_NEGOTIATED;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_alawdec_change_state (GstElement * element, GstStateChange transition)
|
||||
gst_alaw_dec_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
GstStateChangeReturn ret;
|
||||
GstALawDec *dec = GST_ALAWDEC (element);
|
||||
GstALawDec *dec = GST_ALAW_DEC (element);
|
||||
|
||||
switch (transition) {
|
||||
default:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
/* GStreamer A-Law to PCM conversion
|
||||
* Copyright (C) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -17,24 +17,23 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GST_ALAWDECODE_H__
|
||||
#define __GST_ALAWDECODE_H__
|
||||
#ifndef __GST_ALAW_DECODE_H__
|
||||
#define __GST_ALAW_DECODE_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_ALAWDEC \
|
||||
(gst_alawdec_get_type())
|
||||
#define GST_ALAWDEC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALAWDEC,GstALawDec))
|
||||
#define GST_ALAWDEC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALAWDEC,GstALawDecClass))
|
||||
#define GST_IS_ALAWDEC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALAWDEC))
|
||||
#define GST_IS_ALAWDEC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALAWDEC))
|
||||
#define GST_TYPE_ALAW_DEC \
|
||||
(gst_alaw_dec_get_type())
|
||||
#define GST_ALAW_DEC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALAW_DEC,GstALawDec))
|
||||
#define GST_ALAW_DEC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALAW_DEC,GstALawDecClass))
|
||||
#define GST_IS_ALAW_DEC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALAW_DEC))
|
||||
#define GST_IS_ALAW_DEC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALAW_DEC))
|
||||
|
||||
typedef struct _GstALawDec GstALawDec;
|
||||
typedef struct _GstALawDecClass GstALawDecClass;
|
||||
|
@ -50,8 +49,9 @@ struct _GstALawDecClass {
|
|||
GstElementClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_alawdec_get_type(void);
|
||||
GType gst_alaw_dec_get_type(void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_STEREO_H__ */
|
||||
#endif /* __GST_ALAW_DECODE_H__ */
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
* PCM - A-Law conversion
|
||||
* Copyright (C) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
||||
/* GStreamer PCM to A-Law conversion
|
||||
* Copyright (C) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -22,28 +20,18 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "alaw-encode.h"
|
||||
|
||||
extern GstPadTemplate *alawenc_src_template, *alawenc_sink_template;
|
||||
GST_DEBUG_CATEGORY_STATIC (alaw_enc_debug);
|
||||
#define GST_CAT_DEFAULT alaw_enc_debug
|
||||
|
||||
/* Stereo signals and args */
|
||||
enum
|
||||
{
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
extern GstPadTemplate *alawenc_src_template;
|
||||
extern GstPadTemplate *alawenc_sink_template;
|
||||
|
||||
enum
|
||||
{
|
||||
ARG_0
|
||||
};
|
||||
static GstFlowReturn gst_alaw_enc_chain (GstPad * pad, GstBuffer * buffer);
|
||||
|
||||
static void gst_alawenc_class_init (GstALawEncClass * klass);
|
||||
static void gst_alawenc_base_init (GstALawEncClass * klass);
|
||||
static void gst_alawenc_init (GstALawEnc * alawenc);
|
||||
|
||||
static GstFlowReturn gst_alawenc_chain (GstPad * pad, GstBuffer * buffer);
|
||||
GST_BOILERPLATE (GstALawEnc, gst_alaw_enc, GstElement, GST_TYPE_ELEMENT);
|
||||
|
||||
/* some day we might have defines in gstconfig.h that tell us about the
|
||||
* desired cpu/memory/binary size trade-offs */
|
||||
|
@ -303,18 +291,14 @@ s16_to_alaw (gint pcm_val)
|
|||
|
||||
#endif /* GST_ALAW_ENC_USE_TABLE */
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
/*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
static GstCaps *
|
||||
alawenc_getcaps (GstPad * pad)
|
||||
gst_alaw_enc_getcaps (GstPad * pad)
|
||||
{
|
||||
GstALawEnc *alawenc;
|
||||
GstPad *otherpad;
|
||||
GstCaps *base_caps, *othercaps;
|
||||
|
||||
alawenc = GST_ALAWENC (GST_PAD_PARENT (pad));
|
||||
alawenc = GST_ALAW_ENC (GST_PAD_PARENT (pad));
|
||||
|
||||
/* we can do what our template says */
|
||||
base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
||||
|
@ -362,14 +346,15 @@ alawenc_getcaps (GstPad * pad)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
alawenc_setcaps (GstPad * pad, GstCaps * caps)
|
||||
gst_alaw_enc_setcaps (GstPad * pad, GstCaps * caps)
|
||||
{
|
||||
GstALawEnc *alawenc;
|
||||
GstPad *otherpad;
|
||||
GstStructure *structure;
|
||||
gboolean ret;
|
||||
GstCaps *base_caps;
|
||||
|
||||
alawenc = GST_ALAWENC (GST_PAD_PARENT (pad));
|
||||
alawenc = GST_ALAW_ENC (GST_PAD_PARENT (pad));
|
||||
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
gst_structure_get_int (structure, "channels", &alawenc->channels);
|
||||
|
@ -387,71 +372,55 @@ alawenc_setcaps (GstPad * pad, GstCaps * caps)
|
|||
gst_structure_set (structure, "channels", G_TYPE_INT, alawenc->channels,
|
||||
NULL);
|
||||
|
||||
gst_pad_set_caps (otherpad, base_caps);
|
||||
GST_DEBUG_OBJECT (alawenc, "rate=%d, channels=%d", alawenc->rate,
|
||||
alawenc->channels);
|
||||
|
||||
ret = gst_pad_set_caps (otherpad, base_caps);
|
||||
|
||||
gst_caps_unref (base_caps);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_alawenc_get_type (void)
|
||||
{
|
||||
static GType alawenc_type = 0;
|
||||
|
||||
if (!alawenc_type) {
|
||||
static const GTypeInfo alawenc_info = {
|
||||
sizeof (GstALawEncClass),
|
||||
(GBaseInitFunc) gst_alawenc_base_init,
|
||||
NULL,
|
||||
(GClassInitFunc) gst_alawenc_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GstALawEnc),
|
||||
0,
|
||||
(GInstanceInitFunc) gst_alawenc_init,
|
||||
};
|
||||
|
||||
alawenc_type =
|
||||
g_type_register_static (GST_TYPE_ELEMENT, "GstALawEnc", &alawenc_info,
|
||||
0);
|
||||
}
|
||||
return alawenc_type;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_alawenc_base_init (GstALawEncClass * klass)
|
||||
gst_alaw_enc_base_init (gpointer klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
const GstElementDetails alawenc_details =
|
||||
GST_ELEMENT_DETAILS ("A Law audio encoder",
|
||||
"Codec/Encoder/Audio",
|
||||
"Convert 16bit PCM to 8bit A law",
|
||||
"Zaheer Abbas Merali <zaheerabbas at merali dot org>");
|
||||
|
||||
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);
|
||||
|
||||
gst_element_class_set_details_simple (element_class,
|
||||
"A Law audio encoder", "Codec/Encoder/Audio",
|
||||
"Convert 16bit PCM to 8bit A law",
|
||||
"Zaheer Abbas Merali <zaheerabbas at merali dot org>");
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (alaw_enc_debug, "alawenc", 0, "A Law audio encoder");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_alawenc_class_init (GstALawEncClass * klass)
|
||||
gst_alaw_enc_class_init (GstALawEncClass * klass)
|
||||
{
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
/* nothing to do here for now */
|
||||
}
|
||||
|
||||
static void
|
||||
gst_alawenc_init (GstALawEnc * alawenc)
|
||||
gst_alaw_enc_init (GstALawEnc * alawenc, GstALawEncClass * klass)
|
||||
{
|
||||
alawenc->sinkpad = gst_pad_new_from_template (alawenc_sink_template, "sink");
|
||||
gst_pad_set_setcaps_function (alawenc->sinkpad, alawenc_setcaps);
|
||||
gst_pad_set_getcaps_function (alawenc->sinkpad, alawenc_getcaps);
|
||||
gst_pad_set_chain_function (alawenc->sinkpad, gst_alawenc_chain);
|
||||
gst_pad_set_setcaps_function (alawenc->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_alaw_enc_setcaps));
|
||||
gst_pad_set_getcaps_function (alawenc->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_alaw_enc_getcaps));
|
||||
gst_pad_set_chain_function (alawenc->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_alaw_enc_chain));
|
||||
gst_element_add_pad (GST_ELEMENT (alawenc), alawenc->sinkpad);
|
||||
|
||||
alawenc->srcpad = gst_pad_new_from_template (alawenc_src_template, "src");
|
||||
gst_pad_set_setcaps_function (alawenc->srcpad, alawenc_setcaps);
|
||||
gst_pad_set_getcaps_function (alawenc->srcpad, alawenc_getcaps);
|
||||
gst_pad_set_setcaps_function (alawenc->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_alaw_enc_setcaps));
|
||||
gst_pad_set_getcaps_function (alawenc->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_alaw_enc_getcaps));
|
||||
gst_element_add_pad (GST_ELEMENT (alawenc), alawenc->srcpad);
|
||||
|
||||
/* init rest */
|
||||
|
@ -460,7 +429,7 @@ gst_alawenc_init (GstALawEnc * alawenc)
|
|||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_alawenc_chain (GstPad * pad, GstBuffer * buffer)
|
||||
gst_alaw_enc_chain (GstPad * pad, GstBuffer * buffer)
|
||||
{
|
||||
GstALawEnc *alawenc;
|
||||
gint16 *linear_data;
|
||||
|
@ -472,9 +441,9 @@ gst_alawenc_chain (GstPad * pad, GstBuffer * buffer)
|
|||
GstFlowReturn ret;
|
||||
GstClockTime timestamp, duration;
|
||||
|
||||
alawenc = GST_ALAWENC (gst_pad_get_parent (pad));
|
||||
alawenc = GST_ALAW_ENC (GST_PAD_PARENT (pad));
|
||||
|
||||
if (!alawenc->rate || !alawenc->channels)
|
||||
if (G_UNLIKELY (alawenc->rate == 0 || alawenc->channels == 0))
|
||||
goto not_negotiated;
|
||||
|
||||
linear_data = (gint16 *) GST_BUFFER_DATA (buffer);
|
||||
|
@ -484,7 +453,11 @@ gst_alawenc_chain (GstPad * pad, GstBuffer * buffer)
|
|||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
duration = GST_BUFFER_DURATION (buffer);
|
||||
if (duration == -1) {
|
||||
|
||||
GST_LOG_OBJECT (alawenc, "buffer with ts=%" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (timestamp));
|
||||
|
||||
if (duration == GST_CLOCK_TIME_NONE) {
|
||||
duration = gst_util_uint64_scale_int (alaw_size,
|
||||
GST_SECOND, alawenc->rate * alawenc->channels);
|
||||
}
|
||||
|
@ -505,12 +478,11 @@ gst_alawenc_chain (GstPad * pad, GstBuffer * buffer)
|
|||
alaw_data[i] = s16_to_alaw (linear_data[i]);
|
||||
}
|
||||
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
ret = gst_pad_push (alawenc->srcpad, outbuf);
|
||||
|
||||
done:
|
||||
gst_object_unref (alawenc);
|
||||
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
/* GStreamer PCM to A-Law conversion
|
||||
* Copyright (C) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -18,23 +18,23 @@
|
|||
*/
|
||||
|
||||
|
||||
#ifndef __GST_ALAWENCODE_H__
|
||||
#define __GST_ALAWENCODE_H__
|
||||
#ifndef __GST_ALAW_ENCODE_H__
|
||||
#define __GST_ALAW_ENCODE_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_ALAWENC \
|
||||
(gst_alawenc_get_type())
|
||||
#define GST_ALAWENC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALAWENC,GstALawEnc))
|
||||
#define GST_ALAWENC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALAWENC,GstALawEncClass))
|
||||
#define GST_IS_ALAWENC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALAWENC))
|
||||
#define GST_IS_ALAWENC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALAWENC))
|
||||
#define GST_TYPE_ALAW_ENC \
|
||||
(gst_alaw_enc_get_type())
|
||||
#define GST_ALAW_ENC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALAW_ENC,GstALawEnc))
|
||||
#define GST_ALAW_ENC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALAW_ENC,GstALawEncClass))
|
||||
#define GST_IS_ALAW_ENC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALAW_ENC))
|
||||
#define GST_IS_ALAW_ENC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALAW_ENC))
|
||||
|
||||
typedef struct _GstALawEnc GstALawEnc;
|
||||
typedef struct _GstALawEncClass GstALawEncClass;
|
||||
|
@ -52,8 +52,8 @@ struct _GstALawEncClass {
|
|||
GstElementClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_alawenc_get_type(void);
|
||||
GType gst_alaw_enc_get_type(void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_STEREO_H__ */
|
||||
#endif /* __GST_ALAW_ENCODE_H__ */
|
||||
|
|
|
@ -1,6 +1,25 @@
|
|||
/* GStreamer PCM/A-Law conversions
|
||||
*
|
||||
* 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.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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "alaw-encode.h"
|
||||
#include "alaw-decode.h"
|
||||
|
||||
|
@ -46,14 +65,15 @@ plugin_init (GstPlugin * plugin)
|
|||
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, alaw_caps);
|
||||
|
||||
if (!gst_element_register (plugin, "alawenc",
|
||||
GST_RANK_NONE, GST_TYPE_ALAWENC) ||
|
||||
GST_RANK_NONE, GST_TYPE_ALAW_ENC) ||
|
||||
!gst_element_register (plugin, "alawdec",
|
||||
GST_RANK_PRIMARY, GST_TYPE_ALAWDEC))
|
||||
GST_RANK_PRIMARY, GST_TYPE_ALAW_DEC))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* FIXME 0.11: merge alaw and mulaw into one plugin? */
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"alaw",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _GST_ULAWDECODE_H
|
||||
#define _GST_ULAWDECODE_H
|
||||
#ifndef _GST_ULAW_CONVERSION_H
|
||||
#define _GST_ULAW_CONVERSION_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
|
@ -7,4 +7,6 @@ void
|
|||
mulaw_encode(gint16* in, guint8* out, gint numsamples);
|
||||
void
|
||||
mulaw_decode(guint8* in,gint16* out,gint numsamples);
|
||||
#endif
|
||||
|
||||
#endif /* _GST_ULAW_CONVERSION_H */
|
||||
|
||||
|
|
Loading…
Reference in a new issue