2005-09-01 17:31:21 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2004 Martin Soto <martinsoto@users.sourceforge.net>
|
2005-09-21 16:21:45 +00:00
|
|
|
2005 Michael Smith <msmith@fluendo.com>
|
2005-09-01 17:31:21 +00:00
|
|
|
*
|
2005-09-21 16:21:45 +00:00
|
|
|
* ac3iec.c: Pad AC3 frames into IEC958 frames for the S/PDIF interface.
|
2005-09-01 17:31:21 +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
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
#include "ac3iec.h"
|
|
|
|
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (ac3iec_debug);
|
|
|
|
#define GST_CAT_DEFAULT (ac3iec_debug)
|
|
|
|
|
|
|
|
|
|
|
|
/* The duration of a single IEC958 frame. */
|
|
|
|
#define IEC958_FRAME_DURATION (32 * GST_MSECOND)
|
|
|
|
|
|
|
|
/* AC3IEC signals and args */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
LAST_SIGNAL,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2005-12-26 17:48:32 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_RAW_AUDIO,
|
2005-09-01 17:31:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static GstStaticPadTemplate ac3iec_sink_template =
|
2005-12-23 15:48:04 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
2005-09-01 17:31:21 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2005-12-23 15:48:04 +00:00
|
|
|
GST_STATIC_CAPS ("audio/x-private1-ac3; audio/x-ac3; audio/ac3")
|
2005-09-01 17:31:21 +00:00
|
|
|
);
|
|
|
|
|
2005-12-26 17:48:32 +00:00
|
|
|
/* Two different output caps are possible. */
|
2006-05-19 13:55:11 +00:00
|
|
|
#define NORMAL_CAPS_DEF "audio/x-iec958, rate = (int){32000, 44100, 48000}"
|
2005-12-26 17:48:32 +00:00
|
|
|
#define RAW_AUDIO_CAPS_DEF "audio/x-raw-int, " \
|
|
|
|
"endianness = (int) " G_STRINGIFY (G_BIG_ENDIAN) ", " \
|
|
|
|
"signed = (boolean) true, " \
|
|
|
|
"width = (int) 16, " \
|
|
|
|
"depth = (int) 16, " \
|
2006-05-19 13:55:11 +00:00
|
|
|
"rate = (int){32000, 44100, 48000}, " \
|
2005-12-26 17:48:32 +00:00
|
|
|
"channels = (int) 2"
|
|
|
|
|
|
|
|
static GstStaticCaps normal_caps = GST_STATIC_CAPS (NORMAL_CAPS_DEF);
|
|
|
|
static GstStaticCaps raw_audio_caps = GST_STATIC_CAPS (RAW_AUDIO_CAPS_DEF);
|
|
|
|
|
2005-09-01 17:31:21 +00:00
|
|
|
static GstStaticPadTemplate ac3iec_src_template =
|
2005-12-26 17:48:32 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
2005-09-01 17:31:21 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2005-12-26 17:48:32 +00:00
|
|
|
GST_STATIC_CAPS (NORMAL_CAPS_DEF ";" RAW_AUDIO_CAPS_DEF));
|
2005-09-01 17:31:21 +00:00
|
|
|
|
|
|
|
static void ac3iec_base_init (gpointer g_class);
|
|
|
|
static void ac3iec_class_init (AC3IECClass * klass);
|
|
|
|
static void ac3iec_init (AC3IEC * ac3iec);
|
|
|
|
static void ac3iec_finalize (GObject * object);
|
|
|
|
|
|
|
|
static void ac3iec_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void ac3iec_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
|
|
|
|
2005-12-23 15:48:04 +00:00
|
|
|
static gboolean ac3iec_setcaps (GstPad * pad, GstCaps * caps);
|
2005-09-02 13:37:13 +00:00
|
|
|
static GstFlowReturn ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf);
|
|
|
|
static GstFlowReturn ac3iec_chain_raw (GstPad * pad, GstBuffer * buf);
|
2005-09-01 17:31:21 +00:00
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
static GstStateChangeReturn ac3iec_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2005-09-01 17:31:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
|
|
|
/* static guint ac3iec_signals[LAST_SIGNAL] = { 0 }; */
|
|
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
ac3iec_get_type (void)
|
|
|
|
{
|
|
|
|
static GType ac3iec_type = 0;
|
|
|
|
|
|
|
|
if (!ac3iec_type) {
|
|
|
|
static const GTypeInfo ac3iec_info = {
|
|
|
|
sizeof (AC3IECClass),
|
|
|
|
ac3iec_base_init,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) ac3iec_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (AC3IEC),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) ac3iec_init,
|
|
|
|
};
|
|
|
|
ac3iec_type = g_type_register_static (GST_TYPE_ELEMENT,
|
|
|
|
"AC3IEC", &ac3iec_info, 0);
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (ac3iec_debug, "ac3iec", 0,
|
|
|
|
"AC3 to IEC958 padding element");
|
|
|
|
}
|
|
|
|
return ac3iec_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ac3iec_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
2010-03-18 14:53:14 +00:00
|
|
|
gst_element_class_set_details_simple (element_class, "AC3 to IEC958 filter",
|
|
|
|
"Codec/Muxer/Audio",
|
|
|
|
"Pads AC3 frames into IEC958 frames suitable for a raw S/PDIF interface",
|
|
|
|
"Martin Soto <martinsoto@users.sourceforge.net>");
|
2005-09-01 17:31:21 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&ac3iec_sink_template));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&ac3iec_src_template));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
ac3iec_class_init (AC3IECClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
|
|
|
|
2006-04-08 21:42:19 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2005-09-01 17:31:21 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = ac3iec_set_property;
|
|
|
|
gobject_class->get_property = ac3iec_get_property;
|
|
|
|
gobject_class->finalize = ac3iec_finalize;
|
|
|
|
|
2005-12-26 17:48:32 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_RAW_AUDIO,
|
|
|
|
g_param_spec_boolean ("raw-audio", "raw-audio",
|
|
|
|
"If true, source pad caps are set to raw audio.",
|
|
|
|
FALSE, G_PARAM_READWRITE));
|
|
|
|
|
2005-09-01 17:31:21 +00:00
|
|
|
gstelement_class->change_state = ac3iec_change_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
ac3iec_init (AC3IEC * ac3iec)
|
|
|
|
{
|
|
|
|
ac3iec->sink =
|
2007-06-22 10:57:06 +00:00
|
|
|
gst_pad_new_from_static_template (&ac3iec_sink_template, "sink");
|
2005-12-23 15:48:04 +00:00
|
|
|
gst_pad_set_setcaps_function (ac3iec->sink, ac3iec_setcaps);
|
2005-09-02 13:37:13 +00:00
|
|
|
gst_pad_set_chain_function (ac3iec->sink, ac3iec_chain_dvd);
|
2005-11-18 16:14:00 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (ac3iec), ac3iec->sink);
|
2005-09-01 17:31:21 +00:00
|
|
|
|
2007-06-22 10:57:06 +00:00
|
|
|
ac3iec->src = gst_pad_new_from_static_template (&ac3iec_src_template, "src");
|
2005-11-18 16:14:00 +00:00
|
|
|
gst_pad_use_fixed_caps (ac3iec->src);
|
2005-09-01 17:31:21 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (ac3iec), ac3iec->src);
|
|
|
|
|
|
|
|
ac3iec->cur_ts = GST_CLOCK_TIME_NONE;
|
|
|
|
|
|
|
|
ac3iec->padder = g_malloc (sizeof (ac3_padder));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
ac3iec_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
AC3IEC *ac3iec = AC3IEC (object);
|
|
|
|
|
|
|
|
g_free (ac3iec->padder);
|
2007-09-20 11:47:52 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2005-09-01 17:31:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ac3iec_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2005-12-26 17:48:32 +00:00
|
|
|
AC3IEC *ac3iec = AC3IEC (object);
|
2005-09-01 17:31:21 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2005-12-26 17:48:32 +00:00
|
|
|
case PROP_RAW_AUDIO:
|
|
|
|
{
|
|
|
|
ac3iec->raw_audio = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
}
|
2005-09-01 17:31:21 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-23 15:48:04 +00:00
|
|
|
static gboolean
|
|
|
|
ac3iec_setcaps (GstPad * pad, GstCaps * caps)
|
|
|
|
{
|
|
|
|
AC3IEC *ac3iec = AC3IEC (gst_pad_get_parent (pad));
|
|
|
|
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
if (structure && gst_structure_has_name (structure, "audio/x-private1-ac3"))
|
|
|
|
ac3iec->dvdmode = TRUE;
|
|
|
|
else
|
|
|
|
ac3iec->dvdmode = FALSE;
|
|
|
|
|
|
|
|
gst_object_unref (ac3iec);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2005-09-01 17:31:21 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
ac3iec_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2005-12-26 17:48:32 +00:00
|
|
|
AC3IEC *ac3iec = AC3IEC (object);
|
2005-09-01 17:31:21 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2005-12-26 17:48:32 +00:00
|
|
|
case PROP_RAW_AUDIO:
|
|
|
|
g_value_set_boolean (value, ac3iec->raw_audio);
|
|
|
|
break;
|
2005-09-01 17:31:21 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2005-09-02 13:37:13 +00:00
|
|
|
ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
guint first_access;
|
|
|
|
guint8 *data;
|
|
|
|
guint size;
|
|
|
|
gint offset;
|
|
|
|
gint len;
|
|
|
|
GstBuffer *subbuf;
|
|
|
|
GstFlowReturn ret;
|
2005-12-23 15:48:04 +00:00
|
|
|
AC3IEC *ac3iec = AC3IEC (gst_pad_get_parent (pad));
|
2005-09-02 13:37:13 +00:00
|
|
|
|
2005-12-23 15:48:04 +00:00
|
|
|
if (ac3iec->dvdmode) {
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
|
|
|
data = GST_BUFFER_DATA (buf);
|
2005-09-02 13:37:13 +00:00
|
|
|
|
2005-12-23 15:48:04 +00:00
|
|
|
first_access = (data[0] << 8) | data[1];
|
2005-09-02 13:37:13 +00:00
|
|
|
|
2005-12-23 15:48:04 +00:00
|
|
|
/* Skip the first_access header */
|
|
|
|
offset = 2;
|
2005-09-02 13:37:13 +00:00
|
|
|
|
2005-12-23 15:48:04 +00:00
|
|
|
if (first_access > 1) {
|
|
|
|
/* Length of data before first_access */
|
|
|
|
len = first_access - 1;
|
2005-09-02 13:37:13 +00:00
|
|
|
|
2005-12-23 15:48:04 +00:00
|
|
|
/* Ensure we don't crash if fed totally invalid data */
|
|
|
|
if (offset + len > size) {
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len > 0) {
|
|
|
|
subbuf = gst_buffer_create_sub (buf, offset, len);
|
|
|
|
GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE;
|
|
|
|
ret = ac3iec_chain_raw (pad, subbuf);
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += len;
|
|
|
|
len = size - offset;
|
2005-11-18 16:14:00 +00:00
|
|
|
|
2005-09-02 13:37:13 +00:00
|
|
|
subbuf = gst_buffer_create_sub (buf, offset, len);
|
2005-12-23 15:48:04 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (subbuf) = GST_BUFFER_TIMESTAMP (buf);
|
|
|
|
|
2005-09-02 13:37:13 +00:00
|
|
|
ret = ac3iec_chain_raw (pad, subbuf);
|
2005-12-23 15:48:04 +00:00
|
|
|
} else {
|
|
|
|
/* Ensure we don't crash if fed totally invalid data */
|
|
|
|
if (size < 2) {
|
|
|
|
ret = GST_FLOW_ERROR;
|
2005-09-02 13:37:13 +00:00
|
|
|
goto done;
|
2005-12-23 15:48:04 +00:00
|
|
|
}
|
2005-09-02 13:37:13 +00:00
|
|
|
|
2005-12-23 15:48:04 +00:00
|
|
|
/* No first_access, so no timestamp */
|
|
|
|
subbuf = gst_buffer_create_sub (buf, offset, size - offset);
|
|
|
|
GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE;
|
|
|
|
ret = ac3iec_chain_raw (pad, subbuf);
|
2005-11-18 16:14:00 +00:00
|
|
|
}
|
2005-12-23 15:48:04 +00:00
|
|
|
} else {
|
|
|
|
ret = ac3iec_chain_raw (pad, buf);
|
|
|
|
gst_object_unref (ac3iec);
|
|
|
|
return ret;
|
2005-09-02 13:37:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2005-12-23 15:48:04 +00:00
|
|
|
gst_object_unref (ac3iec);
|
2005-09-02 13:37:13 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
ac3iec_chain_raw (GstPad * pad, GstBuffer * buf)
|
2005-09-01 17:31:21 +00:00
|
|
|
{
|
|
|
|
GstBuffer *new;
|
|
|
|
AC3IEC *ac3iec;
|
|
|
|
int event;
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
|
|
|
|
g_return_val_if_fail (pad != NULL, GST_FLOW_ERROR);
|
|
|
|
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
|
|
|
g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
|
|
|
|
|
|
|
|
ac3iec = AC3IEC (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
if (GST_BUFFER_TIMESTAMP (buf) != GST_CLOCK_TIME_NONE) {
|
|
|
|
/* Whoever tells me why it is necessary to add a frame in order to
|
|
|
|
get synchronized sound will get a beer from me. */
|
|
|
|
ac3iec->cur_ts = GST_BUFFER_TIMESTAMP (buf) + IEC958_FRAME_DURATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Push the new data into the padder. */
|
|
|
|
ac3p_push_data (ac3iec->padder, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
|
|
|
|
|
|
|
/* Parse the data. */
|
|
|
|
event = ac3p_parse (ac3iec->padder);
|
|
|
|
while (event != AC3P_EVENT_PUSH) {
|
|
|
|
if (event == AC3P_EVENT_FRAME) {
|
2006-06-05 20:57:12 +00:00
|
|
|
GstCaps *bufcaps = NULL;
|
|
|
|
|
2006-05-19 13:55:11 +00:00
|
|
|
if (ac3iec->caps == NULL) {
|
|
|
|
gint rate = ac3iec->padder->rate;
|
|
|
|
|
|
|
|
if (ac3iec->raw_audio) {
|
|
|
|
ac3iec->caps =
|
|
|
|
gst_caps_make_writable (gst_static_caps_get (&raw_audio_caps));
|
|
|
|
} else {
|
|
|
|
ac3iec->caps =
|
|
|
|
gst_caps_make_writable (gst_static_caps_get (&normal_caps));
|
|
|
|
}
|
|
|
|
gst_structure_set (gst_caps_get_structure (ac3iec->caps, 0), "rate",
|
|
|
|
G_TYPE_INT, rate, NULL);
|
|
|
|
gst_pad_set_caps (ac3iec->src, ac3iec->caps);
|
|
|
|
}
|
|
|
|
|
2005-09-01 17:31:21 +00:00
|
|
|
/* We have a new frame: */
|
2006-06-05 20:57:12 +00:00
|
|
|
bufcaps = GST_PAD_CAPS (ac3iec->src);
|
2005-09-01 17:31:21 +00:00
|
|
|
|
|
|
|
/* Create a new buffer, and copy the frame data into it. */
|
2005-12-05 13:03:40 +00:00
|
|
|
ret =
|
|
|
|
gst_pad_alloc_buffer_and_set_caps (ac3iec->src, 0,
|
|
|
|
AC3P_IEC_FRAME_SIZE, bufcaps, &new);
|
2005-09-02 13:37:13 +00:00
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto buffer_alloc_failed;
|
|
|
|
|
2005-09-01 17:31:21 +00:00
|
|
|
memcpy (GST_BUFFER_DATA (new), ac3p_frame (ac3iec->padder),
|
|
|
|
AC3P_IEC_FRAME_SIZE);
|
|
|
|
|
|
|
|
/* Set the timestamp. */
|
|
|
|
GST_BUFFER_TIMESTAMP (new) = ac3iec->cur_ts;
|
2005-10-17 17:50:45 +00:00
|
|
|
GST_BUFFER_DURATION (new) = IEC958_FRAME_DURATION;
|
2005-09-01 17:31:21 +00:00
|
|
|
ac3iec->cur_ts = GST_CLOCK_TIME_NONE;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (ac3iec, "Pushing IEC958 buffer of size %d",
|
|
|
|
GST_BUFFER_SIZE (new));
|
|
|
|
/* Push the buffer to the source pad. */
|
|
|
|
ret = gst_pad_push (ac3iec->src, new);
|
|
|
|
}
|
|
|
|
|
|
|
|
event = ac3p_parse (ac3iec->padder);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
2005-09-02 13:37:13 +00:00
|
|
|
done:
|
|
|
|
gst_object_unref (ac3iec);
|
|
|
|
|
2005-09-01 17:31:21 +00:00
|
|
|
return ret;
|
2005-09-02 13:37:13 +00:00
|
|
|
|
|
|
|
buffer_alloc_failed:
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
goto done;
|
|
|
|
|
2005-09-01 17:31:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
ac3iec_change_state (GstElement * element, GstStateChange transition)
|
2005-09-01 17:31:21 +00:00
|
|
|
{
|
|
|
|
AC3IEC *ac3iec;
|
2006-05-19 13:55:11 +00:00
|
|
|
GstStateChangeReturn ret;
|
2005-09-01 17:31:21 +00:00
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
g_return_val_if_fail (GST_IS_AC3IEC (element), GST_STATE_CHANGE_FAILURE);
|
2005-09-01 17:31:21 +00:00
|
|
|
|
|
|
|
ac3iec = AC3IEC (element);
|
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
2005-09-01 17:31:21 +00:00
|
|
|
break;
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2005-09-01 17:31:21 +00:00
|
|
|
ac3p_init (ac3iec->padder);
|
|
|
|
break;
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
2005-09-01 17:31:21 +00:00
|
|
|
break;
|
2006-05-19 13:55:11 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
|
|
|
|
switch (transition) {
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
2005-09-01 17:31:21 +00:00
|
|
|
break;
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2005-09-21 16:21:45 +00:00
|
|
|
ac3p_clear (ac3iec->padder);
|
2007-08-16 07:17:13 +00:00
|
|
|
if (ac3iec->caps) {
|
|
|
|
gst_caps_unref (ac3iec->caps);
|
|
|
|
ac3iec->caps = NULL;
|
|
|
|
}
|
2005-09-01 17:31:21 +00:00
|
|
|
break;
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2005-09-01 17:31:21 +00:00
|
|
|
break;
|
2006-05-19 13:55:11 +00:00
|
|
|
default:
|
|
|
|
break;
|
2005-09-01 17:31:21 +00:00
|
|
|
}
|
|
|
|
|
2006-05-19 13:55:11 +00:00
|
|
|
return ret;
|
2005-09-01 17:31:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
plugin_init (GstPlugin * plugin)
|
|
|
|
{
|
|
|
|
if (!gst_element_register (plugin, "ac3iec958", GST_RANK_NONE,
|
|
|
|
GST_TYPE_AC3IEC)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"iec958",
|
2005-09-21 16:21:45 +00:00
|
|
|
"Convert raw AC3 into IEC958 (S/PDIF) frames",
|
2006-04-01 09:54:39 +00:00
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|